diff options
Diffstat (limited to 'src/interfaces')
-rw-r--r-- | src/interfaces/ecpg/preproc/ecpg.c | 18 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-lobj.c | 16 | ||||
-rw-r--r-- | src/interfaces/odbc/gpps.c | 32 | ||||
-rw-r--r-- | src/interfaces/odbc/misc.c | 48 |
4 files changed, 39 insertions, 75 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.c b/src/interfaces/ecpg/preproc/ecpg.c index 1cc00dbcc7c..f6db59bec74 100644 --- a/src/interfaces/ecpg/preproc/ecpg.c +++ b/src/interfaces/ecpg/preproc/ecpg.c @@ -66,11 +66,7 @@ main(int argc, char *const argv[]) switch (c) { case 'o': -#ifndef __CYGWIN32__ - yyout = fopen(optarg, "w"); -#else - yyout = fopen(optarg, "wb"); -#endif + yyout = fopen(optarg, PG_BINARY_W); if (yyout == NULL) perror(optarg); else @@ -147,11 +143,7 @@ main(int argc, char *const argv[]) ptr2ext[1] = 'c'; ptr2ext[2] = '\0'; -#ifndef __CYGWIN32__ - yyout = fopen(output_filename, "w"); -#else - yyout = fopen(output_filename, "wb"); -#endif + yyout = fopen(output_filename, PG_BINARY_W); if (yyout == NULL) { perror(output_filename); @@ -161,11 +153,7 @@ main(int argc, char *const argv[]) } } -#ifndef __CYGWIN32__ - yyin = fopen(input_filename, "r"); -#else - yyin = fopen(input_filename, "rb"); -#endif + yyin = fopen(input_filename, PG_BINARY_R); if (yyin == NULL) perror(argv[fnr]); else diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 23b9ffb09c0..859a383c710 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.29 2000/04/12 17:17:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.30 2000/06/02 15:57:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -391,11 +391,7 @@ lo_import(PGconn *conn, const char *filename) /* * open the file to be read in */ -#ifndef __CYGWIN32__ - fd = open(filename, O_RDONLY, 0666); -#else - fd = open(filename, O_RDONLY | O_BINARY, 0666); -#endif + fd = open(filename, O_RDONLY | PG_BINARY, 0666); if (fd < 0) { /* error */ printfPQExpBuffer(&conn->errorMessage, @@ -474,11 +470,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename) /* * open the file to be written to */ -#ifndef __CYGWIN32__ - fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0666); -#else - fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666); -#endif + fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY, 0666); if (fd < 0) { /* error */ printfPQExpBuffer(&conn->errorMessage, @@ -544,7 +536,7 @@ lo_initialize(PGconn *conn) * ---------------- */ res = PQexec(conn, "select proname, oid from pg_proc \ - where proname = 'lo_open' \ + where proname = 'lo_open' \ or proname = 'lo_close' \ or proname = 'lo_creat' \ or proname = 'lo_unlink' \ diff --git a/src/interfaces/odbc/gpps.c b/src/interfaces/odbc/gpps.c index c1675fd7b4b..55c22c3dd2f 100644 --- a/src/interfaces/odbc/gpps.c +++ b/src/interfaces/odbc/gpps.c @@ -59,7 +59,7 @@ GetPrivateProfileString(char *theSection, /* section name */ BOOL aSectionFound = FALSE; BOOL aKeyFound = FALSE; int j = 0; - + j = strlen(theIniFileName) + 1; ptr = (char*)getpwuid(getuid()); /* get user info */ @@ -92,21 +92,13 @@ GetPrivateProfileString(char *theSection, /* section name */ /* This code makes it so that a file in the users home dir * overrides a the "default" file as passed in */ -#ifndef __CYGWIN32__ - aFile = (FILE*)(buf ? fopen(buf, "r") : NULL); -#else - aFile = (FILE*)(buf ? fopen(buf, "rb") : NULL); -#endif + aFile = (FILE*)(buf ? fopen(buf, PG_BINARY_R) : NULL); if(!aFile) { sprintf(buf,"%s",theIniFileName); -#ifndef __CYGWIN32__ - aFile = (FILE*)(buf ? fopen(buf, "r") : NULL); -#else - aFile = (FILE*)(buf ? fopen(buf, "rb") : NULL); -#endif + aFile = (FILE*)(buf ? fopen(buf, PG_BINARY_R) : NULL); } - + aLength = (theDefault == NULL) ? 0 : strlen(theDefault); if(theReturnBufferLength == 0 || theReturnBuffer == NULL) @@ -145,7 +137,7 @@ GetPrivateProfileString(char *theSection, /* section name */ case ';': /* comment line */ continue; break; - + case '[': /* section marker */ if( (aString = strchr(aLine, ']')) ) @@ -173,7 +165,7 @@ GetPrivateProfileString(char *theSection, /* section name */ if(aSectionFound) { /* try to match requested key */ - + if( (aString = aValue = strchr(aLine, '=')) ) { *aValue = '\0'; @@ -220,7 +212,7 @@ GetPrivateProfileString(char *theSection, /* section name */ /* remove trailing blanks from aValue if any */ aString = aValue + aLength - 1; - + while(--aString > aValue && *aString == ' ') { *aString = '\0'; @@ -333,9 +325,9 @@ WritePrivateProfileString(char *theSection, /* section name */ BOOL aSectionFound = FALSE; BOOL keyFound = FALSE; int j = 0; - + /* If this isn't correct processing we'll change it later */ - if(theSection == NULL || theKey == NULL || theBuffer == NULL || + if(theSection == NULL || theKey == NULL || theBuffer == NULL || theIniFileName == NULL) return 0; aLength = strlen(theBuffer); @@ -380,7 +372,7 @@ WritePrivateProfileString(char *theSection, /* section name */ if(!aFile) return 0; } - + aLength = strlen(theBuffer); /* We have to search for theKey, because if it already */ @@ -401,7 +393,7 @@ WritePrivateProfileString(char *theSection, /* section name */ case ';': /* comment line */ continue; break; - + case '[': /* section marker */ if( (aString = strchr(aLine, ']')) ) @@ -425,7 +417,7 @@ WritePrivateProfileString(char *theSection, /* section name */ if(aSectionFound) { /* try to match requested key */ - + if( (aString = aValue = strchr(aLine, '=')) ) { *aValue = '\0'; diff --git a/src/interfaces/odbc/misc.c b/src/interfaces/odbc/misc.c index 9c3c009b60c..5d0a19c375e 100644 --- a/src/interfaces/odbc/misc.c +++ b/src/interfaces/odbc/misc.c @@ -68,11 +68,7 @@ mylog(char * fmt, ...) if (! LOGFP) { generate_filename(MYLOGDIR,MYLOGFILE,filebuf); -#ifndef __CYGWIN32__ - LOGFP = fopen(filebuf, "w"); -#else - LOGFP = fopen(filebuf, "wb"); -#endif + LOGFP = fopen(filebuf, PG_BINARY_W); globals.mylogFP = LOGFP; setbuf(LOGFP, NULL); } @@ -100,11 +96,7 @@ qlog(char * fmt, ...) if (! LOGFP) { generate_filename(QLOGDIR,QLOGFILE,filebuf); -#ifndef __CYGWIN32__ - LOGFP = fopen(filebuf, "w"); -#else - LOGFP = fopen(filebuf, "wb"); -#endif + LOGFP = fopen(filebuf, PG_BINARY_W); globals.qlogFP = LOGFP; setbuf(LOGFP, NULL); } @@ -136,9 +128,9 @@ qlog(char * fmt, ...) #include <sql.h> #endif - + /* returns STRCPY_FAIL, STRCPY_TRUNCATED, or #bytes copied (not including null term) */ -int +int my_strcpy(char *dst, int dst_len, char *src, int src_len) { if (dst_len <= 0) @@ -146,7 +138,7 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len) if (src_len == SQL_NULL_DATA) { dst[0] = '\0'; - return STRCPY_NULL; + return STRCPY_NULL; } else if (src_len == SQL_NTS) src_len = strlen(src); @@ -154,12 +146,12 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len) if (src_len <= 0) return STRCPY_FAIL; - else { + else { if (src_len < dst_len) { memcpy(dst, src, src_len); dst[src_len] = '\0'; } - else { + else { memcpy(dst, src, dst_len-1); dst[dst_len-1] = '\0'; /* truncated */ return STRCPY_TRUNCATED; @@ -184,7 +176,7 @@ int i; if (len == SQL_NULL_DATA) { dst[0] = '\0'; return NULL; - } + } else if (len == SQL_NTS) len = strlen(src) + 1; @@ -208,7 +200,7 @@ make_string(char *s, int len, char *buf) int length; char *str; - if(s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) { + if(s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) { length = (len > 0) ? len : strlen(s); if (buf) { @@ -216,11 +208,11 @@ char *str; return buf; } - str = malloc(length + 1); + str = malloc(length + 1); if ( ! str) return NULL; - strncpy_null(str, s, length+1); + strncpy_null(str, s, length+1); return str; } @@ -235,7 +227,7 @@ char * my_strcat(char *buf, char *fmt, char *s, int len) { - if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) { + if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0))) { int length = (len > 0) ? len : strlen(s); int pos = strlen(buf); @@ -248,14 +240,14 @@ my_strcat(char *buf, char *fmt, char *s, int len) void remove_newlines(char *string) { - unsigned int i; - - for(i=0; i < strlen(string); i++) { - if((string[i] == '\n') || - (string[i] == '\r')) { - string[i] = ' '; - } - } + unsigned int i; + + for(i=0; i < strlen(string); i++) { + if((string[i] == '\n') || + (string[i] == '\r')) { + string[i] = ' '; + } + } } char * |