* w32/*: Remove TABs from the source code.

I know whitespace commits are annoying, but having these TABs is
causing me to miss things when I search through the code.  This
doesn't try to change the w32 code to meet GNU coding standards.
This commit is contained in:
Paul Smith 2013-11-27 19:43:33 -05:00
parent 889303cdfe
commit a4937bc897
8 changed files with 1166 additions and 1166 deletions

View file

@ -27,180 +27,180 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
DIR* DIR*
opendir(const char* pDirName) opendir(const char* pDirName)
{ {
struct stat sb; struct stat sb;
DIR* pDir; DIR* pDir;
char* pEndDirName; char* pEndDirName;
int nBufferLen; int nBufferLen;
/* sanity checks */ /* sanity checks */
if (!pDirName) { if (!pDirName) {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
} }
if (stat(pDirName, &sb) != 0) { if (stat(pDirName, &sb) != 0) {
errno = ENOENT; errno = ENOENT;
return NULL; return NULL;
} }
if ((sb.st_mode & S_IFMT) != S_IFDIR) { if ((sb.st_mode & S_IFMT) != S_IFDIR) {
errno = ENOTDIR; errno = ENOTDIR;
return NULL; return NULL;
} }
/* allocate a DIR structure to return */ /* allocate a DIR structure to return */
pDir = (DIR *) malloc(sizeof (DIR)); pDir = (DIR *) malloc(sizeof (DIR));
if (!pDir) if (!pDir)
return NULL; return NULL;
/* input directory name length */ /* input directory name length */
nBufferLen = strlen(pDirName); nBufferLen = strlen(pDirName);
/* copy input directory name to DIR buffer */ /* copy input directory name to DIR buffer */
strcpy(pDir->dir_pDirectoryName, pDirName); strcpy(pDir->dir_pDirectoryName, pDirName);
/* point to end of the copied directory name */ /* point to end of the copied directory name */
pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1]; pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1];
/* if directory name did not end in '/' or '\', add '/' */ /* if directory name did not end in '/' or '\', add '/' */
if ((*pEndDirName != '/') && (*pEndDirName != '\\')) { if ((*pEndDirName != '/') && (*pEndDirName != '\\')) {
pEndDirName++; pEndDirName++;
*pEndDirName = '/'; *pEndDirName = '/';
} }
/* now append the wildcard character to the buffer */ /* now append the wildcard character to the buffer */
pEndDirName++; pEndDirName++;
*pEndDirName = '*'; *pEndDirName = '*';
pEndDirName++; pEndDirName++;
*pEndDirName = '\0'; *pEndDirName = '\0';
/* other values defaulted */ /* other values defaulted */
pDir->dir_nNumFiles = 0; pDir->dir_nNumFiles = 0;
pDir->dir_hDirHandle = INVALID_HANDLE_VALUE; pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
pDir->dir_ulCookie = __DIRENT_COOKIE; pDir->dir_ulCookie = __DIRENT_COOKIE;
return pDir; return pDir;
} }
void void
closedir(DIR *pDir) closedir(DIR *pDir)
{ {
/* got a valid pointer? */ /* got a valid pointer? */
if (!pDir) { if (!pDir) {
errno = EINVAL; errno = EINVAL;
return; return;
} }
/* sanity check that this is a DIR pointer */ /* sanity check that this is a DIR pointer */
if (pDir->dir_ulCookie != __DIRENT_COOKIE) { if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
errno = EINVAL; errno = EINVAL;
return; return;
} }
/* close the WINDOWS32 directory handle */ /* close the WINDOWS32 directory handle */
if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE) if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
FindClose(pDir->dir_hDirHandle); FindClose(pDir->dir_hDirHandle);
free(pDir); free(pDir);
return; return;
} }
struct dirent * struct dirent *
readdir(DIR* pDir) readdir(DIR* pDir)
{ {
WIN32_FIND_DATA wfdFindData; WIN32_FIND_DATA wfdFindData;
if (!pDir) { if (!pDir) {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
} }
/* sanity check that this is a DIR pointer */ /* sanity check that this is a DIR pointer */
if (pDir->dir_ulCookie != __DIRENT_COOKIE) { if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
errno = EINVAL; errno = EINVAL;
return NULL; return NULL;
} }
if (pDir->dir_nNumFiles == 0) { if (pDir->dir_nNumFiles == 0) {
pDir->dir_hDirHandle = FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData); pDir->dir_hDirHandle = FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData);
if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE) if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE)
return NULL; return NULL;
} else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData)) } else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData))
return NULL; return NULL;
/* bump count for next call to readdir() or telldir() */ /* bump count for next call to readdir() or telldir() */
pDir->dir_nNumFiles++; pDir->dir_nNumFiles++;
/* fill in struct dirent values */ /* fill in struct dirent values */
pDir->dir_sdReturn.d_ino = (ino_t)-1; pDir->dir_sdReturn.d_ino = (ino_t)-1;
strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName); strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
return &pDir->dir_sdReturn; return &pDir->dir_sdReturn;
} }
void void
rewinddir(DIR* pDir) rewinddir(DIR* pDir)
{ {
if (!pDir) { if (!pDir) {
errno = EINVAL; errno = EINVAL;
return; return;
} }
/* sanity check that this is a DIR pointer */ /* sanity check that this is a DIR pointer */
if (pDir->dir_ulCookie != __DIRENT_COOKIE) { if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
errno = EINVAL; errno = EINVAL;
return; return;
} }
/* close the WINDOWS32 directory handle */ /* close the WINDOWS32 directory handle */
if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE) if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
if (!FindClose(pDir->dir_hDirHandle)) if (!FindClose(pDir->dir_hDirHandle))
errno = EBADF; errno = EBADF;
/* reset members which control readdir() */ /* reset members which control readdir() */
pDir->dir_hDirHandle = INVALID_HANDLE_VALUE; pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
pDir->dir_nNumFiles = 0; pDir->dir_nNumFiles = 0;
return; return;
} }
int int
telldir(DIR* pDir) telldir(DIR* pDir)
{ {
if (!pDir) { if (!pDir) {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
/* sanity check that this is a DIR pointer */ /* sanity check that this is a DIR pointer */
if (pDir->dir_ulCookie != __DIRENT_COOKIE) { if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
/* return number of times readdir() called */ /* return number of times readdir() called */
return pDir->dir_nNumFiles; return pDir->dir_nNumFiles;
} }
void void
seekdir(DIR* pDir, long nPosition) seekdir(DIR* pDir, long nPosition)
{ {
if (!pDir) if (!pDir)
return; return;
/* sanity check that this is a DIR pointer */ /* sanity check that this is a DIR pointer */
if (pDir->dir_ulCookie != __DIRENT_COOKIE) if (pDir->dir_ulCookie != __DIRENT_COOKIE)
return; return;
/* go back to beginning of directory */ /* go back to beginning of directory */
rewinddir(pDir); rewinddir(pDir);
/* loop until we have found position we care about */ /* loop until we have found position we care about */
for (--nPosition; nPosition && readdir(pDir); nPosition--); for (--nPosition; nPosition && readdir(pDir); nPosition--);
/* flag invalid nPosition value */ /* flag invalid nPosition value */
if (nPosition) if (nPosition)
errno = EINVAL; errno = EINVAL;
return; return;
} }

View file

@ -36,16 +36,16 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
struct dirent struct dirent
{ {
ino_t d_ino; /* unused - no equivalent on WINDOWS32 */ ino_t d_ino; /* unused - no equivalent on WINDOWS32 */
char d_name[NAME_MAX+1]; char d_name[NAME_MAX+1];
}; };
typedef struct dir_struct { typedef struct dir_struct {
ULONG dir_ulCookie; ULONG dir_ulCookie;
HANDLE dir_hDirHandle; HANDLE dir_hDirHandle;
DWORD dir_nNumFiles; DWORD dir_nNumFiles;
char dir_pDirectoryName[NAME_MAX+1]; char dir_pDirectoryName[NAME_MAX+1];
struct dirent dir_sdReturn; struct dirent dir_sdReturn;
} DIR; } DIR;
DIR *opendir(const char *); DIR *opendir(const char *);

View file

@ -32,17 +32,17 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
EXTERN_DECL(HANDLE process_init, (VOID_DECL)); EXTERN_DECL(HANDLE process_init, (VOID_DECL));
EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth, EXTERN_DECL(HANDLE process_init_fd, (HANDLE stdinh, HANDLE stdouth,
HANDLE stderrh)); HANDLE stderrh));
EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp, EXTERN_DECL(long process_begin, (HANDLE proc, char **argv, char **envp,
char *exec_path, char *as_user)); char *exec_path, char *as_user));
EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data, EXTERN_DECL(long process_pipe_io, (HANDLE proc, char *stdin_data,
int stdin_data_len)); int stdin_data_len));
EXTERN_DECL(long process_file_io, (HANDLE proc)); EXTERN_DECL(long process_file_io, (HANDLE proc));
EXTERN_DECL(void process_cleanup, (HANDLE proc)); EXTERN_DECL(void process_cleanup, (HANDLE proc));
EXTERN_DECL(HANDLE process_wait_for_any, (int block, DWORD* pdwWaitStatus)); EXTERN_DECL(HANDLE process_wait_for_any, (int block, DWORD* pdwWaitStatus));
EXTERN_DECL(void process_register, (HANDLE proc)); EXTERN_DECL(void process_register, (HANDLE proc));
EXTERN_DECL(HANDLE process_easy, (char** argv, char** env, EXTERN_DECL(HANDLE process_easy, (char** argv, char** env,
int outfd, int errfd)); int outfd, int errfd));
EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal)); EXTERN_DECL(BOOL process_kill, (HANDLE proc, int signal));
EXTERN_DECL(int process_used_slots, (VOID_DECL)); EXTERN_DECL(int process_used_slots, (VOID_DECL));

View file

@ -27,15 +27,15 @@ convert_vpath_to_windows32(char *Path, char to_delim)
{ {
char *etok; /* token separator for old Path */ char *etok; /* token separator for old Path */
/* /*
* Convert all spaces to delimiters. Note that pathnames which * Convert all spaces to delimiters. Note that pathnames which
* contain blanks get trounced here. Use 8.3 format as a workaround. * contain blanks get trounced here. Use 8.3 format as a workaround.
*/ */
for (etok = Path; etok && *etok; etok++) for (etok = Path; etok && *etok; etok++)
if (isblank ((unsigned char) *etok)) if (isblank ((unsigned char) *etok))
*etok = to_delim; *etok = to_delim;
return (convert_Path_to_windows32(Path, to_delim)); return (convert_Path_to_windows32(Path, to_delim));
} }
/* /*
@ -79,7 +79,7 @@ convert_Path_to_windows32(char *Path, char to_delim)
if (etok) { if (etok) {
*etok = to_delim; *etok = to_delim;
p = ++etok; p = ++etok;
} else } else
p += strlen(p); p += strlen(p);
} else { } else {
/* found another one, no drive letter */ /* found another one, no drive letter */
@ -114,14 +114,14 @@ w32ify(const char *filename, int resolve)
char * char *
getcwd_fs(char* buf, int len) getcwd_fs(char* buf, int len)
{ {
char *p = getcwd(buf, len); char *p = getcwd(buf, len);
if (p) { if (p) {
char *q = w32ify(buf, 0); char *q = w32ify(buf, 0);
strncpy(buf, q, len); strncpy(buf, q, len);
} }
return p; return p;
} }
#ifdef unused #ifdef unused

View file

@ -24,59 +24,59 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* /*
* Description: Convert a NULL string terminated UNIX environment block to * Description: Convert a NULL string terminated UNIX environment block to
* an environment block suitable for a windows32 system call * an environment block suitable for a windows32 system call
* *
* Returns: TRUE= success, FALSE=fail * Returns: TRUE= success, FALSE=fail
* *
* Notes/Dependencies: the environment block is sorted in case-insensitive * Notes/Dependencies: the environment block is sorted in case-insensitive
* order, is double-null terminated, and is a char *, not a char ** * order, is double-null terminated, and is a char *, not a char **
*/ */
int _cdecl compare(const void *a1, const void *a2) int _cdecl compare(const void *a1, const void *a2)
{ {
return _stricoll(*((char**)a1),*((char**)a2)); return _stricoll(*((char**)a1),*((char**)a2));
} }
bool_t bool_t
arr2envblk(char **arr, char **envblk_out) arr2envblk(char **arr, char **envblk_out)
{ {
char **tmp; char **tmp;
int size_needed; int size_needed;
int arrcnt; int arrcnt;
char *ptr; char *ptr;
arrcnt = 0; arrcnt = 0;
while (arr[arrcnt]) { while (arr[arrcnt]) {
arrcnt++; arrcnt++;
} }
tmp = (char**) calloc(arrcnt + 1, sizeof(char *)); tmp = (char**) calloc(arrcnt + 1, sizeof(char *));
if (!tmp) { if (!tmp) {
return FALSE; return FALSE;
} }
arrcnt = 0; arrcnt = 0;
size_needed = 0; size_needed = 0;
while (arr[arrcnt]) { while (arr[arrcnt]) {
tmp[arrcnt] = arr[arrcnt]; tmp[arrcnt] = arr[arrcnt];
size_needed += strlen(arr[arrcnt]) + 1; size_needed += strlen(arr[arrcnt]) + 1;
arrcnt++; arrcnt++;
} }
size_needed++; size_needed++;
qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare); qsort((void *) tmp, (size_t) arrcnt, sizeof (char*), compare);
ptr = *envblk_out = calloc(size_needed, 1); ptr = *envblk_out = calloc(size_needed, 1);
if (!ptr) { if (!ptr) {
free(tmp); free(tmp);
return FALSE; return FALSE;
} }
arrcnt = 0; arrcnt = 0;
while (tmp[arrcnt]) { while (tmp[arrcnt]) {
strcpy(ptr, tmp[arrcnt]); strcpy(ptr, tmp[arrcnt]);
ptr += strlen(tmp[arrcnt]) + 1; ptr += strlen(tmp[arrcnt]) + 1;
arrcnt++; arrcnt++;
} }
free(tmp); free(tmp);
return TRUE; return TRUE;
} }

View file

@ -19,10 +19,10 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
typedef int bool_t; typedef int bool_t;
#define E_SCALL 101 #define E_SCALL 101
#define E_IO 102 #define E_IO 102
#define E_NO_MEM 103 #define E_NO_MEM 103
#define E_FORK 104 #define E_FORK 104
extern bool_t arr2envblk(char **arr, char **envblk_out); extern bool_t arr2envblk(char **arr, char **envblk_out);

File diff suppressed because it is too large Load diff

View file

@ -45,41 +45,41 @@ map_windows32_error_to_string (DWORD ercode) {
* the corresponding GCC qualifier is '__thread'.) * the corresponding GCC qualifier is '__thread'.)
*/ */
static char szMessageBuffer[128]; static char szMessageBuffer[128];
/* Fill message buffer with a default message in /* Fill message buffer with a default message in
* case FormatMessage fails * case FormatMessage fails
*/ */
wsprintf (szMessageBuffer, "Error %ld\n", ercode); wsprintf (szMessageBuffer, "Error %ld\n", ercode);
/* /*
* Special code for winsock error handling. * Special code for winsock error handling.
*/ */
if (ercode > WSABASEERR) { if (ercode > WSABASEERR) {
#if 0 #if 0
HMODULE hModule = GetModuleHandle("wsock32"); HMODULE hModule = GetModuleHandle("wsock32");
if (hModule != NULL) { if (hModule != NULL) {
FormatMessage(FORMAT_MESSAGE_FROM_HMODULE, FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
hModule, hModule,
ercode, ercode,
LANG_NEUTRAL, LANG_NEUTRAL,
szMessageBuffer, szMessageBuffer,
sizeof(szMessageBuffer), sizeof(szMessageBuffer),
NULL); NULL);
FreeLibrary(hModule); FreeLibrary(hModule);
} }
#else #else
O (fatal, NILF, szMessageBuffer); O (fatal, NILF, szMessageBuffer);
#endif #endif
} else { } else {
/* /*
* Default system message handling * Default system message handling
*/ */
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL, NULL,
ercode, ercode,
LANG_NEUTRAL, LANG_NEUTRAL,
szMessageBuffer, szMessageBuffer,
sizeof(szMessageBuffer), sizeof(szMessageBuffer),
NULL); NULL);
} }
return szMessageBuffer; return szMessageBuffer;
} }