1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-01 21:31:19 +03:00

Remove NT-specific file open defines by defining our own open macros for

"rb" and "wb".
This commit is contained in:
Bruce Momjian
2000-06-02 15:57:44 +00:00
parent bf1c8f2b3b
commit cc2b5e5815
28 changed files with 590 additions and 348 deletions

View File

@@ -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';

View File

@@ -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;
unsigned int i;
for(i=0; i < strlen(string); i++) {
if((string[i] == '\n') ||
(string[i] == '\r')) {
string[i] = ' ';
}
}
for(i=0; i < strlen(string); i++) {
if((string[i] == '\n') ||
(string[i] == '\r')) {
string[i] = ' ';
}
}
}
char *