Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
e56756e9
Commit
e56756e9
authored
18 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Use Unix line endings instead of DOS ones, per Magnus.
parent
e2fee8cf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/include/port/win32_msvc/dirent.h
+21
-21
21 additions, 21 deletions
src/include/port/win32_msvc/dirent.h
src/port/dirent.c
+108
-108
108 additions, 108 deletions
src/port/dirent.c
src/port/win32error.c
+200
-200
200 additions, 200 deletions
src/port/win32error.c
with
329 additions
and
329 deletions
src/include/port/win32_msvc/dirent.h
+
21
−
21
View file @
e56756e9
/*
* Headers for port/dirent.c, win32 native implementation of dirent functions
*
* $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.
1
2006/06/
07 22:24:45
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
/*
* 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
This diff is collapsed.
Click to expand it.
src/port/dirent.c
+
108
−
108
View file @
e56756e9
/*-------------------------------------------------------------------------
*
* 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.
1
2006/06/
07 22:24:46
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
;
}
/*-------------------------------------------------------------------------
*
* 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
;
}
This diff is collapsed.
Click to expand it.
src/port/win32error.c
+
200
−
200
View file @
e56756e9
/*-------------------------------------------------------------------------
*
* 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.
1
2006/06/
07 22:24
:4
6
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
;
}
/*-------------------------------------------------------------------------
*
* 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
:4
3
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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment