BOOL aSectionFound = FALSE;
BOOL aKeyFound = FALSE;
int j = 0;
-
+
j = strlen(theIniFileName) + 1;
ptr = (char*)getpwuid(getuid()); /* get user info */
/* 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)
case ';': /* comment line */
continue;
break;
-
+
case '[': /* section marker */
if( (aString = strchr(aLine, ']')) )
if(aSectionFound)
{
/* try to match requested key */
-
+
if( (aString = aValue = strchr(aLine, '=')) )
{
*aValue = '\0';
/* remove trailing blanks from aValue if any */
aString = aValue + aLength - 1;
-
+
while(--aString > aValue && *aString == ' ')
{
*aString = '\0';
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);
if(!aFile) return 0;
}
-
+
aLength = strlen(theBuffer);
/* We have to search for theKey, because if it already */
case ';': /* comment line */
continue;
break;
-
+
case '[': /* section marker */
if( (aString = strchr(aLine, ']')) )
if(aSectionFound)
{
/* try to match requested key */
-
+
if( (aString = aValue = strchr(aLine, '=')) )
{
*aValue = '\0';
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);
}
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);
}
#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)
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);
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;
if (len == SQL_NULL_DATA) {
dst[0] = '\0';
return NULL;
- }
+ }
else if (len == SQL_NTS)
len = strlen(src) + 1;
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) {
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;
}
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);
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 *