Re: [PATCHES] pg_id.c windows fix
OK, patch applied. I changed DWORD to unsigned long. --- Andrew Dunstan wrote: > Here's a patch for pg_id.c that lets it compile cleanly and run on Windows. > > cheers > > andrew > > Index: src/bin/pg_id/pg_id.c > === > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_id/pg_id.c,v > retrieving revision 1.22.2.1 > diff -c -w -r1.22.2.1 pg_id.c > *** src/bin/pg_id/pg_id.c 7 Sep 2003 04:37:04 - 1.22.2.1 > --- src/bin/pg_id/pg_id.c 4 Oct 2003 13:33:30 - > *** > *** 38,43 > --- 38,44 > char pw_name[128]; > } pass_win32; > struct passwd_win32 *pw = &pass_win32; > + DWORD pwname_size = sizeof(pass_win32.pw_name) - 1; > > pw->pw_uid = 1; > #endif > *** > *** 113,119 > exit(1); > } > > ! GetUserName(pw->pw_name, sizeof(pw->pw_name)-1); > #endif > > if (!limit_user_info) > --- 114,120 > exit(1); > } > > ! GetUserName(pw->pw_name, &pwname_size); > #endif > > if (!limit_user_info) -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [PATCHES] pg_id.c windows fix
That's not the issue. It complained because it wanted a pointer to the size. The relevant lines in winbase.h files are: BOOL WINAPI GetUserNameA (LPSTR,PDWORD); #define GetUserName GetUserNameA I am using Mingw. cheers andrew - Original Message - From: "Bruce Momjian" <[EMAIL PROTECTED]> To: "Andrew Dunstan" <[EMAIL PROTECTED]> Cc: "PG Patches" <[EMAIL PROTECTED]> Sent: Sunday, October 05, 2003 12:17 AM Subject: Re: [PATCHES] pg_id.c windows fix > > Can you tell me what Win32 compile environment can't handle a sizeof() > as a function parameter? > > ! GetUserName(pw->pw_name, sizeof(pw->pw_name)-1); > > Does casting to DWORD help? > > -- - > > Andrew Dunstan wrote: > > Here's a patch for pg_id.c that lets it compile cleanly and run on Windows. > > > > cheers > > > > andrew > > > > Index: src/bin/pg_id/pg_id.c > > === > > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_id/pg_id.c,v > > retrieving revision 1.22.2.1 > > diff -c -w -r1.22.2.1 pg_id.c > > *** src/bin/pg_id/pg_id.c 7 Sep 2003 04:37:04 - 1.22.2.1 > > --- src/bin/pg_id/pg_id.c 4 Oct 2003 13:33:30 - > > *** > > *** 38,43 > > --- 38,44 > > char pw_name[128]; > > } pass_win32; > > struct passwd_win32 *pw = &pass_win32; > > + DWORD pwname_size = sizeof(pass_win32.pw_name) - 1; > > > > pw->pw_uid = 1; > > #endif > > *** > > *** 113,119 > > exit(1); > > } > > > > ! GetUserName(pw->pw_name, sizeof(pw->pw_name)-1); > > #endif > > > > if (!limit_user_info) > > --- 114,120 > > exit(1); > > } > > > > ! GetUserName(pw->pw_name, &pwname_size); > > #endif > > > > if (!limit_user_info) > > -- > Bruce Momjian| http://candle.pha.pa.us > [EMAIL PROTECTED] | (610) 359-1001 > + If your life is a hard drive, | 13 Roberts Road > + Christ can be your backup.| Newtown Square, Pennsylvania 19073 > > ---(end of broadcast)--- > TIP 4: Don't 'kill -9' the postmaster ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [PATCHES] pg_id.c windows fix
On Sun, 5 Oct 2003, Bruce Momjian wrote: > > Can you tell me what Win32 compile environment can't handle a sizeof() > as a function parameter? > > ! GetUserName(pw->pw_name, sizeof(pw->pw_name)-1); > > Does casting to DWORD help? > > ! GetUserName(pw->pw_name, &pwname_size); It looks like the second argument is supposed to be a pointer and probably returns back the length actually used (if it follows the pattern of other win32 calls) It's something like: BOOL GetUserName( LPTSTR lpBuffer,// address of name buffer LPDWORD nSize // address of size of name buffer ); ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
Re: [PATCHES] pg_id.c windows fix
Can you tell me what Win32 compile environment can't handle a sizeof() as a function parameter? ! GetUserName(pw->pw_name, sizeof(pw->pw_name)-1); Does casting to DWORD help? --- Andrew Dunstan wrote: > Here's a patch for pg_id.c that lets it compile cleanly and run on Windows. > > cheers > > andrew > > Index: src/bin/pg_id/pg_id.c > === > RCS file: /projects/cvsroot/pgsql-server/src/bin/pg_id/pg_id.c,v > retrieving revision 1.22.2.1 > diff -c -w -r1.22.2.1 pg_id.c > *** src/bin/pg_id/pg_id.c 7 Sep 2003 04:37:04 - 1.22.2.1 > --- src/bin/pg_id/pg_id.c 4 Oct 2003 13:33:30 - > *** > *** 38,43 > --- 38,44 > char pw_name[128]; > } pass_win32; > struct passwd_win32 *pw = &pass_win32; > + DWORD pwname_size = sizeof(pass_win32.pw_name) - 1; > > pw->pw_uid = 1; > #endif > *** > *** 113,119 > exit(1); > } > > ! GetUserName(pw->pw_name, sizeof(pw->pw_name)-1); > #endif > > if (!limit_user_info) > --- 114,120 > exit(1); > } > > ! GetUserName(pw->pw_name, &pwname_size); > #endif > > if (!limit_user_info) -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster