diff options
| author | Bruce Momjian <bruce@momjian.us> | 2003-09-07 03:43:57 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2003-09-07 03:43:57 +0000 |
| commit | 4b407f6c3cd7584c308fcd75fd8d2a094a4e8dd1 (patch) | |
| tree | cf14f1a883879e481b944acf5159c54ed3dab9a4 /src/bin/pg_id | |
| parent | 7703e55c32e82e2485272596ec5ee6ac1695e42d (diff) | |
| download | postgresql-4b407f6c3cd7584c308fcd75fd8d2a094a4e8dd1.tar.gz | |
Changes for MinGW/WIN32:
o allow configure to see include/port/win32 include files
o add matching Win32 accept() prototype
o allow pg_id to compile with native Win32 API
o fix invalide mbvalidate() function calls (existing bug)
o allow /scripts to compile with native Win32 API
o add win32.c to Win32 compiles (already in *.mak files)
Diffstat (limited to 'src/bin/pg_id')
| -rw-r--r-- | src/bin/pg_id/pg_id.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/bin/pg_id/pg_id.c b/src/bin/pg_id/pg_id.c index 739c47a27a..743bc3d42f 100644 --- a/src/bin/pg_id/pg_id.c +++ b/src/bin/pg_id/pg_id.c @@ -6,7 +6,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.23 2003/09/06 01:41:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.24 2003/09/07 03:43:53 momjian Exp $ */ #include "postgres_fe.h" @@ -28,10 +28,19 @@ main(int argc, char *argv[]) use_real_uid_flag = 0, limit_user_info = 0; const char *username = NULL; - + extern int optind; +#ifndef WIN32 struct passwd *pw; +#else + struct passwd_win32 + { + int pw_uid; + char pw_name[128]; + } pass_win32; + struct passwd_win32 *pw = &pass_win32; - extern int optind; + pw->pw_uid = 1; +#endif while ((c = getopt(argc, argv, "nru")) != -1) { @@ -47,13 +56,24 @@ main(int argc, char *argv[]) limit_user_info = 1; break; default: +#ifndef WIN32 fprintf(stderr, "Usage: %s [-n] [-r] [-u] [username]\n", argv[0]); +#else + fprintf(stderr, "Usage: %s [-n] [-r] [-u]\n", argv[0]); +#endif exit(1); } } if (argc - optind >= 1) +#ifndef WIN32 username = argv[optind]; +#else + { + fprintf(stderr, "%s: specifying a username is not supported on this platform\n", argv[0]); + exit(1); + } +#endif if (name_only_flag && !limit_user_info) { @@ -66,7 +86,7 @@ main(int argc, char *argv[]) exit(1); } - +#ifndef WIN32 if (username) { pw = getpwnam(username); @@ -86,6 +106,15 @@ main(int argc, char *argv[]) perror(argv[0]); exit(1); } +#else + if (!use_real_uid_flag) + { + fprintf(stderr, "%s: -r must be used on this platform\n", argv[0]); + exit(1); + } + + GetUserName(pw->pw_name, sizeof(pw->pw_name)-1); +#endif if (!limit_user_info) printf("uid=%d(%s)\n", (int) pw->pw_uid, pw->pw_name); |
