]> granicus.if.org Git - postgresql/commitdiff
Use Unix line endings instead of DOS ones, per Magnus.
authorBruce Momjian <bruce@momjian.us>
Mon, 26 Jun 2006 12:59:44 +0000 (12:59 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 26 Jun 2006 12:59:44 +0000 (12:59 +0000)
src/include/port/win32_msvc/dirent.h
src/port/dirent.c
src/port/win32error.c

index 42af9bd219711bc99ce0822f59abfd5cdbb4e3dd..e44a602c3b6ae73bc7e40b90cc21d28c31d86db8 100644 (file)
@@ -1,21 +1,21 @@
-/*\r
- * Headers for port/dirent.c, win32 native implementation of dirent functions\r
- *\r
- * $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.1 2006/06/07 22:24:45 momjian Exp $\r
- */\r
-\r
-#ifndef _WIN32VC_DIRENT_H\r
-#define _WIN32VC_DIRENT_H\r
-struct dirent {\r
-       long d_ino;\r
-       unsigned short d_reclen;\r
-       unsigned short d_namlen;\r
-       char d_name[MAX_PATH];\r
-};\r
-\r
-typedef struct DIR DIR;\r
-\r
-DIR* opendir(const char *);\r
-struct dirent* readdir(DIR *);\r
-int closedir(DIR*);\r
-#endif\r
+/*
+ * Headers for port/dirent.c, win32 native implementation of dirent functions
+ *
+ * $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.2 2006/06/26 12:59:44 momjian Exp $
+ */
+
+#ifndef _WIN32VC_DIRENT_H
+#define _WIN32VC_DIRENT_H
+struct dirent {
+       long d_ino;
+       unsigned short d_reclen;
+       unsigned short d_namlen;
+       char d_name[MAX_PATH];
+};
+
+typedef struct DIR DIR;
+
+DIR* opendir(const char *);
+struct dirent* readdir(DIR *);
+int closedir(DIR*);
+#endif
index 3722db862d5b89ea0d34958688c18dd533a14140..18e8d84f698cf280ccff378766db83a4d6ff300e 100644 (file)
-/*-------------------------------------------------------------------------\r
- *\r
- * dirent.c\r
- *       opendir/readdir/closedir for win32/msvc\r
- *\r
- * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group\r
- * Portions Copyright (c) 1994, Regents of the University of California\r
- *\r
- *\r
- * IDENTIFICATION\r
- *       $PostgreSQL: pgsql/src/port/dirent.c,v 1.1 2006/06/07 22:24:46 momjian Exp $\r
- *\r
- *-------------------------------------------------------------------------\r
- */\r
-\r
-#include "postgres.h"\r
-#include <dirent.h>\r
-\r
-\r
-struct DIR {\r
-       char *dirname;\r
-       struct dirent ret; /* Used to return to caller */\r
-       HANDLE handle;\r
-};\r
-\r
-DIR* opendir(const char *dirname)\r
-{\r
-       DWORD attr;\r
-       DIR *d;\r
-\r
-       /* Make sure it is a directory */\r
-       attr = GetFileAttributes(dirname);\r
-       if (attr == INVALID_FILE_ATTRIBUTES) \r
-       {\r
-               errno = ENOENT;\r
-               return NULL;\r
-       }\r
-       if ((attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)\r
-       {\r
-               errno = ENOTDIR;\r
-               return NULL;\r
-       }\r
-\r
-       d = malloc(sizeof(DIR));\r
-       if (!d)\r
-       {\r
-               errno = ENOMEM;\r
-               return NULL;\r
-       }\r
-       d->dirname = malloc(strlen(dirname)+4);\r
-       if (!d->dirname)\r
-       {\r
-               errno = ENOMEM;\r
-               free(d);\r
-               return NULL;\r
-       }\r
-       strcpy(d->dirname, dirname);\r
-       if (d->dirname[strlen(d->dirname)-1] != '/' &&\r
-           d->dirname[strlen(d->dirname)-1] != '\\')\r
-               strcat(d->dirname,"\\"); /* Append backslash if not already there */\r
-       strcat(d->dirname,"*");          /* Search for entries named anything */\r
-       d->handle = INVALID_HANDLE_VALUE;\r
-       d->ret.d_ino = 0; /* no inodes on win32 */\r
-       d->ret.d_reclen =  0; /* not used on win32 */\r
-\r
-       return d;\r
-}\r
-\r
-struct dirent* readdir(DIR * d)\r
-{\r
-       WIN32_FIND_DATA fd;\r
-\r
-       if (d->handle == INVALID_HANDLE_VALUE)\r
-       {\r
-               d->handle = FindFirstFile(d->dirname, &fd);\r
-               if (d->handle == INVALID_HANDLE_VALUE)\r
-               {\r
-                       errno = ENOENT;\r
-                       return NULL;\r
-               }\r
-       }\r
-       else \r
-       {\r
-               if (!FindNextFile(d->handle, &fd))\r
-               {\r
-                       if (GetLastError() == ERROR_NO_MORE_FILES)\r
-                       {\r
-                               /* No more files, force errno=0 (unlike mingw) */\r
-                               errno = 0;\r
-                               return NULL;\r
-                       }\r
-                       _dosmaperr(GetLastError());\r
-                       return NULL;\r
-               }\r
-       }\r
-       strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */\r
-       d->ret.d_namlen = strlen(d->ret.d_name);\r
-       return &d->ret;\r
-}\r
-\r
-int closedir(DIR *d)\r
-{\r
-       if (d->handle != INVALID_HANDLE_VALUE)\r
-               FindClose(d->handle);\r
-       free(d->dirname);\r
-       free(d);\r
-       return 0;\r
-}\r
+/*-------------------------------------------------------------------------
+ *
+ * dirent.c
+ *       opendir/readdir/closedir for win32/msvc
+ *
+ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ *       $PostgreSQL: pgsql/src/port/dirent.c,v 1.2 2006/06/26 12:58:17 momjian Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+#include <dirent.h>
+
+
+struct DIR {
+       char *dirname;
+       struct dirent ret; /* Used to return to caller */
+       HANDLE handle;
+};
+
+DIR* opendir(const char *dirname)
+{
+       DWORD attr;
+       DIR *d;
+
+       /* Make sure it is a directory */
+       attr = GetFileAttributes(dirname);
+       if (attr == INVALID_FILE_ATTRIBUTES) 
+       {
+               errno = ENOENT;
+               return NULL;
+       }
+       if ((attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
+       {
+               errno = ENOTDIR;
+               return NULL;
+       }
+
+       d = malloc(sizeof(DIR));
+       if (!d)
+       {
+               errno = ENOMEM;
+               return NULL;
+       }
+       d->dirname = malloc(strlen(dirname)+4);
+       if (!d->dirname)
+       {
+               errno = ENOMEM;
+               free(d);
+               return NULL;
+       }
+       strcpy(d->dirname, dirname);
+       if (d->dirname[strlen(d->dirname)-1] != '/' &&
+           d->dirname[strlen(d->dirname)-1] != '\\')
+               strcat(d->dirname,"\\"); /* Append backslash if not already there */
+       strcat(d->dirname,"*");          /* Search for entries named anything */
+       d->handle = INVALID_HANDLE_VALUE;
+       d->ret.d_ino = 0; /* no inodes on win32 */
+       d->ret.d_reclen =  0; /* not used on win32 */
+
+       return d;
+}
+
+struct dirent* readdir(DIR * d)
+{
+       WIN32_FIND_DATA fd;
+
+       if (d->handle == INVALID_HANDLE_VALUE)
+       {
+               d->handle = FindFirstFile(d->dirname, &fd);
+               if (d->handle == INVALID_HANDLE_VALUE)
+               {
+                       errno = ENOENT;
+                       return NULL;
+               }
+       }
+       else 
+       {
+               if (!FindNextFile(d->handle, &fd))
+               {
+                       if (GetLastError() == ERROR_NO_MORE_FILES)
+                       {
+                               /* No more files, force errno=0 (unlike mingw) */
+                               errno = 0;
+                               return NULL;
+                       }
+                       _dosmaperr(GetLastError());
+                       return NULL;
+               }
+       }
+       strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */
+       d->ret.d_namlen = strlen(d->ret.d_name);
+       return &d->ret;
+}
+
+int closedir(DIR *d)
+{
+       if (d->handle != INVALID_HANDLE_VALUE)
+               FindClose(d->handle);
+       free(d->dirname);
+       free(d);
+       return 0;
+}
index 31127b683b01287bbbf7dae648dfc9cf7c6ec5a1..ff6ff83c0485fb9f56d265b90315647465094391 100644 (file)
-/*-------------------------------------------------------------------------\r
- *\r
- * win32error.c\r
- *       Map win32 error codes to errno values\r
- *\r
- * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group\r
- *\r
- * IDENTIFICATION\r
- *       $PostgreSQL: pgsql/src/port/win32error.c,v 1.1 2006/06/07 22:24:46 momjian Exp $\r
- *\r
- *-------------------------------------------------------------------------\r
- */\r
-\r
-#include "postgres.h"\r
-\r
-static const struct\r
-{\r
-       DWORD           winerr;\r
-       int                     doserr;\r
-}      doserrors[] =\r
-\r
-{\r
-       {\r
-               ERROR_INVALID_FUNCTION, EINVAL\r
-       },\r
-       {\r
-               ERROR_FILE_NOT_FOUND, ENOENT\r
-       },\r
-       {\r
-               ERROR_PATH_NOT_FOUND, ENOENT\r
-       },\r
-       {\r
-               ERROR_TOO_MANY_OPEN_FILES, EMFILE\r
-       },\r
-       {\r
-               ERROR_ACCESS_DENIED, EACCES\r
-       },\r
-       {\r
-               ERROR_INVALID_HANDLE, EBADF\r
-       },\r
-       {\r
-               ERROR_ARENA_TRASHED, ENOMEM\r
-       },\r
-       {\r
-               ERROR_NOT_ENOUGH_MEMORY, ENOMEM\r
-       },\r
-       {\r
-               ERROR_INVALID_BLOCK, ENOMEM\r
-       },\r
-       {\r
-               ERROR_BAD_ENVIRONMENT, E2BIG\r
-       },\r
-       {\r
-               ERROR_BAD_FORMAT, ENOEXEC\r
-       },\r
-       {\r
-               ERROR_INVALID_ACCESS, EINVAL\r
-       },\r
-       {\r
-               ERROR_INVALID_DATA, EINVAL\r
-       },\r
-       {\r
-               ERROR_INVALID_DRIVE, ENOENT\r
-       },\r
-       {\r
-               ERROR_CURRENT_DIRECTORY, EACCES\r
-       },\r
-       {\r
-               ERROR_NOT_SAME_DEVICE, EXDEV\r
-       },\r
-       {\r
-               ERROR_NO_MORE_FILES, ENOENT\r
-       },\r
-       {\r
-               ERROR_LOCK_VIOLATION, EACCES\r
-       },\r
-       {\r
-               ERROR_SHARING_VIOLATION, EACCES\r
-       },\r
-       {\r
-               ERROR_BAD_NETPATH, ENOENT\r
-       },\r
-       {\r
-               ERROR_NETWORK_ACCESS_DENIED, EACCES\r
-       },\r
-       {\r
-               ERROR_BAD_NET_NAME, ENOENT\r
-       },\r
-       {\r
-               ERROR_FILE_EXISTS, EEXIST\r
-       },\r
-       {\r
-               ERROR_CANNOT_MAKE, EACCES\r
-       },\r
-       {\r
-               ERROR_FAIL_I24, EACCES\r
-       },\r
-       {\r
-               ERROR_INVALID_PARAMETER, EINVAL\r
-       },\r
-       {\r
-               ERROR_NO_PROC_SLOTS, EAGAIN\r
-       },\r
-       {\r
-               ERROR_DRIVE_LOCKED, EACCES\r
-       },\r
-       {\r
-               ERROR_BROKEN_PIPE, EPIPE\r
-       },\r
-       {\r
-               ERROR_DISK_FULL, ENOSPC\r
-       },\r
-       {\r
-               ERROR_INVALID_TARGET_HANDLE, EBADF\r
-       },\r
-       {\r
-               ERROR_INVALID_HANDLE, EINVAL\r
-       },\r
-       {\r
-               ERROR_WAIT_NO_CHILDREN, ECHILD\r
-       },\r
-       {\r
-               ERROR_CHILD_NOT_COMPLETE, ECHILD\r
-       },\r
-       {\r
-               ERROR_DIRECT_ACCESS_HANDLE, EBADF\r
-       },\r
-       {\r
-               ERROR_NEGATIVE_SEEK, EINVAL\r
-       },\r
-       {\r
-               ERROR_SEEK_ON_DEVICE, EACCES\r
-       },\r
-       {\r
-               ERROR_DIR_NOT_EMPTY, ENOTEMPTY\r
-       },\r
-       {\r
-               ERROR_NOT_LOCKED, EACCES\r
-       },\r
-       {\r
-               ERROR_BAD_PATHNAME, ENOENT\r
-       },\r
-       {\r
-               ERROR_MAX_THRDS_REACHED, EAGAIN\r
-       },\r
-       {\r
-               ERROR_LOCK_FAILED, EACCES\r
-       },\r
-       {\r
-               ERROR_ALREADY_EXISTS, EEXIST\r
-       },\r
-       {\r
-               ERROR_FILENAME_EXCED_RANGE, ENOENT\r
-       },\r
-       {\r
-               ERROR_NESTING_NOT_ALLOWED, EAGAIN\r
-       },\r
-       {\r
-               ERROR_NOT_ENOUGH_QUOTA, ENOMEM\r
-       }\r
-};\r
-\r
-void\r
-_dosmaperr(unsigned long e)\r
-{\r
-       int                     i;\r
-\r
-       if (e == 0)\r
-       {\r
-               errno = 0;\r
-               return;\r
-       }\r
-\r
-       for (i = 0; i < lengthof(doserrors); i++)\r
-       {\r
-               if (doserrors[i].winerr == e)\r
-               {\r
-                       errno = doserrors[i].doserr;\r
-#ifndef FRONTEND\r
-                       ereport(DEBUG5,\r
-                                       (errmsg_internal("mapped win32 error code %lu to %d",\r
-                                                                        e, errno)));\r
-#else\r
-                       fprintf(stderr, _("mapped win32 error code %lu to %d"), e, errno);\r
-#endif\r
-                       return;\r
-               }\r
-       }\r
-\r
-#ifndef FRONTEND\r
-       ereport(LOG,\r
-                       (errmsg_internal("unrecognized win32 error code: %lu",\r
-                                                        e)));\r
-#else\r
-       fprintf(stderr, _("unrecognized win32 error code: %lu"), e);\r
-#endif\r
-\r
-       errno = EINVAL;\r
-       return;\r
-}\r
+/*-------------------------------------------------------------------------
+ *
+ * win32error.c
+ *       Map win32 error codes to errno values
+ *
+ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ *       $PostgreSQL: pgsql/src/port/win32error.c,v 1.2 2006/06/26 12:58:43 momjian Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+
+static const struct
+{
+       DWORD           winerr;
+       int                     doserr;
+}      doserrors[] =
+
+{
+       {
+               ERROR_INVALID_FUNCTION, EINVAL
+       },
+       {
+               ERROR_FILE_NOT_FOUND, ENOENT
+       },
+       {
+               ERROR_PATH_NOT_FOUND, ENOENT
+       },
+       {
+               ERROR_TOO_MANY_OPEN_FILES, EMFILE
+       },
+       {
+               ERROR_ACCESS_DENIED, EACCES
+       },
+       {
+               ERROR_INVALID_HANDLE, EBADF
+       },
+       {
+               ERROR_ARENA_TRASHED, ENOMEM
+       },
+       {
+               ERROR_NOT_ENOUGH_MEMORY, ENOMEM
+       },
+       {
+               ERROR_INVALID_BLOCK, ENOMEM
+       },
+       {
+               ERROR_BAD_ENVIRONMENT, E2BIG
+       },
+       {
+               ERROR_BAD_FORMAT, ENOEXEC
+       },
+       {
+               ERROR_INVALID_ACCESS, EINVAL
+       },
+       {
+               ERROR_INVALID_DATA, EINVAL
+       },
+       {
+               ERROR_INVALID_DRIVE, ENOENT
+       },
+       {
+               ERROR_CURRENT_DIRECTORY, EACCES
+       },
+       {
+               ERROR_NOT_SAME_DEVICE, EXDEV
+       },
+       {
+               ERROR_NO_MORE_FILES, ENOENT
+       },
+       {
+               ERROR_LOCK_VIOLATION, EACCES
+       },
+       {
+               ERROR_SHARING_VIOLATION, EACCES
+       },
+       {
+               ERROR_BAD_NETPATH, ENOENT
+       },
+       {
+               ERROR_NETWORK_ACCESS_DENIED, EACCES
+       },
+       {
+               ERROR_BAD_NET_NAME, ENOENT
+       },
+       {
+               ERROR_FILE_EXISTS, EEXIST
+       },
+       {
+               ERROR_CANNOT_MAKE, EACCES
+       },
+       {
+               ERROR_FAIL_I24, EACCES
+       },
+       {
+               ERROR_INVALID_PARAMETER, EINVAL
+       },
+       {
+               ERROR_NO_PROC_SLOTS, EAGAIN
+       },
+       {
+               ERROR_DRIVE_LOCKED, EACCES
+       },
+       {
+               ERROR_BROKEN_PIPE, EPIPE
+       },
+       {
+               ERROR_DISK_FULL, ENOSPC
+       },
+       {
+               ERROR_INVALID_TARGET_HANDLE, EBADF
+       },
+       {
+               ERROR_INVALID_HANDLE, EINVAL
+       },
+       {
+               ERROR_WAIT_NO_CHILDREN, ECHILD
+       },
+       {
+               ERROR_CHILD_NOT_COMPLETE, ECHILD
+       },
+       {
+               ERROR_DIRECT_ACCESS_HANDLE, EBADF
+       },
+       {
+               ERROR_NEGATIVE_SEEK, EINVAL
+       },
+       {
+               ERROR_SEEK_ON_DEVICE, EACCES
+       },
+       {
+               ERROR_DIR_NOT_EMPTY, ENOTEMPTY
+       },
+       {
+               ERROR_NOT_LOCKED, EACCES
+       },
+       {
+               ERROR_BAD_PATHNAME, ENOENT
+       },
+       {
+               ERROR_MAX_THRDS_REACHED, EAGAIN
+       },
+       {
+               ERROR_LOCK_FAILED, EACCES
+       },
+       {
+               ERROR_ALREADY_EXISTS, EEXIST
+       },
+       {
+               ERROR_FILENAME_EXCED_RANGE, ENOENT
+       },
+       {
+               ERROR_NESTING_NOT_ALLOWED, EAGAIN
+       },
+       {
+               ERROR_NOT_ENOUGH_QUOTA, ENOMEM
+       }
+};
+
+void
+_dosmaperr(unsigned long e)
+{
+       int                     i;
+
+       if (e == 0)
+       {
+               errno = 0;
+               return;
+       }
+
+       for (i = 0; i < lengthof(doserrors); i++)
+       {
+               if (doserrors[i].winerr == e)
+               {
+                       errno = doserrors[i].doserr;
+#ifndef FRONTEND
+                       ereport(DEBUG5,
+                                       (errmsg_internal("mapped win32 error code %lu to %d",
+                                                                        e, errno)));
+#else
+                       fprintf(stderr, _("mapped win32 error code %lu to %d"), e, errno);
+#endif
+                       return;
+               }
+       }
+
+#ifndef FRONTEND
+       ereport(LOG,
+                       (errmsg_internal("unrecognized win32 error code: %lu",
+                                                        e)));
+#else
+       fprintf(stderr, _("unrecognized win32 error code: %lu"), e);
+#endif
+
+       errno = EINVAL;
+       return;
+}