#include "prolog.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <alloca.h>
#include "servdef.h"
#include "database.h"
#include "errors.h"
Include dependency graph for dblib.c:
Go to the source code of this file.
Defines | |
#define | LOINT(l) ((int)(l)) |
#define | HIINT(l) ((int)(((SINT32)(l) >> 16) & 0xFFFF)) |
Functions | |
unsigned int | HexToDec (char *str) |
void | BytesToHex (BYTE *b, char *s, int n) |
void | HexToBytes (char *s, BYTE *b, int nibs) |
char * | strtrm (char *s) |
int | GetDataBaseSize (char *filename) |
int | csvNameServerFillPortOffset (char *po) |
int | csvNameServerFillHAddr (char *ip) |
int | GetNameServerAddress (void) |
int | findcol (char *str, char *tag) |
int | getColumnStr (int col, char *str, char *buf, int bufsiz) |
char * | colptr (int col, char *str) |
int | namcmp (char *name, char *str, int col, int limit) |
EXPORT void | csvStdInit (struct CSVDBStruct *db) |
EXPORT int | csvStdIterator (struct CSVDBStruct *db) |
EXPORT void | csvStdExit (struct CSVDBStruct *db) |
EXPORT int | csvAssignValue (void *ptr, int fmt, int siz, char *str) |
EXPORT int | csvReadFile (char *path, char *file, CSVDB *db, void **target) |
EXPORT int | csvGetValue (void *ptr, int fmt, int siz, char *str) |
EXPORT int | csvWriteFile (char *path, char *file, CSVDB *db) |
Variables | |
RPCFecStruct * | RPCFec = NULL |
RPCFecStruct * | NameServer = NULL |
int | numNameServers = 0 |
CSVCOLUMN | csvNameServerColumns [] |
CSVDB | csvNameServerDb |
int | gotNameServerAddress = 0 |
dblib contains functions which can be used to access CVS files and extract fields.
It also contains some string and conversion utilities.
Definition in file dblib.c.
void BytesToHex | ( | BYTE * | b, | |
char * | s, | |||
int | n | |||
) |
Definition at line 29 of file dblib.c.
References strrev().
Referenced by csvGetValue(), csvNameServerFillHAddr(), and GetAddressFromNameServer().
00030 { 00031 int v; 00032 00033 while (n--) 00034 { 00035 *s++ = (v = (*b&0xf0)>>4) < 10 ? '0' + v : 'A' + v - 10; 00036 *s++ = (v = *b++&0xf) < 10 ? '0' + v : 'A' + v - 10; 00037 } 00038 *s = 0; 00039 strrev(s); 00040 return; 00041 }
Here is the call graph for this function:
Here is the caller graph for this function:
char* colptr | ( | int | col, | |
char * | str | |||
) |
Definition at line 473 of file dblib.c.
References getColumnStr().
00474 { 00475 static char buf[128]; 00476 buf[0] = 0; 00477 getColumnStr(col,str,buf,128); 00478 return buf; 00479 }
Here is the call graph for this function:
EXPORT int csvAssignValue | ( | void * | ptr, | |
int | fmt, | |||
int | siz, | |||
char * | str | |||
) |
Definition at line 605 of file dblib.c.
References argument_list_error, BYTE, CF_BYTE, CF_DOUBLE, CF_FLOAT, CF_LONG, CF_NULL, CF_SHORT, CF_TEXT, HexToBytes(), illegal_format, and SINT32.
Referenced by csvReadFile().
00606 { 00607 char *pstr = str; 00608 if (ptr == NULL) return 0; /* intentionally not assigned */ 00609 if (str == NULL) return argument_list_error; 00610 if (fmt != CF_TEXT && fmt != CF_NULL && strlen(str) == 0) pstr = "0"; 00611 switch (fmt) 00612 { 00613 case CF_NULL: break; 00614 case CF_TEXT: if (siz == 0) *(char *)ptr = 0; else strncpy((char *)ptr,pstr,siz); break; 00615 case CF_BYTE: 00616 if (siz > 1) HexToBytes(pstr,(BYTE *)ptr,siz); 00617 else *(BYTE *)ptr = (BYTE)atoi(pstr); 00618 break; 00619 case CF_SHORT: *(short *)ptr = (short)strtol(pstr,NULL,0); break; 00620 case CF_LONG: *(SINT32 *)ptr = strtol(pstr,NULL,0); break; 00621 case CF_FLOAT: *(float *)ptr = (float)strtod(pstr,NULL); break; 00622 case CF_DOUBLE: *(double *)ptr = strtod(pstr,NULL); break; 00623 default: return illegal_format; 00624 } 00625 return 0; 00626 }
Here is the call graph for this function:
Here is the caller graph for this function:
EXPORT int csvGetValue | ( | void * | ptr, | |
int | fmt, | |||
int | siz, | |||
char * | str | |||
) |
Definition at line 723 of file dblib.c.
References argument_list_error, BYTE, BytesToHex(), CF_BYTE, CF_DOUBLE, CF_FLOAT, CF_LONG, CF_SHORT, CF_TEXT, illegal_format, and SINT32.
00724 { 00725 if (ptr == NULL) return 0; /* intentionally not assigned */ 00726 if (str == NULL) return argument_list_error; 00727 switch (fmt) 00728 { 00729 case CF_TEXT: strncpy(str,(char *)ptr,siz); break; 00730 case CF_BYTE: BytesToHex((BYTE *)ptr,str,siz); break; 00731 case CF_SHORT: sprintf(str,"%d",*(short *)ptr); break; 00732 # ifdef MSDOS 00733 case CF_LONG: sprintf(str,"%ld",*(SINT32 *)ptr); break; 00734 # else 00735 case CF_LONG: sprintf(str,"%d",*(SINT32 *)ptr); break; 00736 # endif 00737 case CF_FLOAT: sprintf(str,"%g",*(float *)ptr); break; 00738 case CF_DOUBLE: sprintf(str,"%g",*(double *)ptr); break; 00739 default: return illegal_format; 00740 } 00741 return 0; 00742 }
Here is the call graph for this function:
int csvNameServerFillHAddr | ( | char * | ip | ) |
Definition at line 232 of file dblib.c.
References BytesToHex(), CSVDBStruct::cnt, csvNameServerDb, dbglog(), DWORD, NameServer, and NGdebug.
00233 { 00234 char str1[32],str2[32]; 00235 DWORD haddr = inet_addr(ip); 00236 memcpy(NameServer[csvNameServerDb.cnt].IPh_addr,&haddr,4); 00237 if (NGdebug) 00238 { 00239 BytesToHex(NameServer[csvNameServerDb.cnt].Network,str1,4); 00240 BytesToHex(NameServer[csvNameServerDb.cnt].Node,str2,6); 00241 dbglog("Using Name Server %s [%s %s %s]", 00242 NameServer[csvNameServerDb.cnt].Name, 00243 str1,str2, 00244 NameServer[csvNameServerDb.cnt].IP); 00245 } 00246 return 0; 00247 }
Here is the call graph for this function:
int csvNameServerFillPortOffset | ( | char * | po | ) |
Definition at line 249 of file dblib.c.
References BYTE, CSVDBStruct::cnt, csvNameServerDb, NameServer, RPCFecStruct::Port, and RPCFecStruct::PortOffset.
00250 { 00251 int poff = atoi(po); 00252 NameServer[csvNameServerDb.cnt].Port[0] = poff&0xff; 00253 NameServer[csvNameServerDb.cnt].Port[1] = (poff>>8)&0xff; 00254 NameServer[csvNameServerDb.cnt].PortOffset = (BYTE)poff; 00255 return 0; 00256 }
EXPORT int csvReadFile | ( | char * | path, | |
char * | file, | |||
CSVDB * | db, | |||
void ** | target | |||
) |
Definition at line 654 of file dblib.c.
References argument_list_error, BYTE, ccerr, csvAssignValue(), erlst, feclog(), findcol(), getColumnStr(), GetDataBaseSize(), CSVDBStruct::ini, no_such_file, CSVDBStruct::siz, strtrm(), CSVDBStruct::tgt, TRUE, and ttyoutput().
Referenced by getAlarmInfoTable(), GetAlarmWatchTable(), GetAliasTable(), getCASUserName(), getFecName(), GetNameServerAddress(), and getRegisteredUsers().
00655 { 00656 FILE *fp=NULL; 00657 int i,cc=0,done=0; 00658 char *c,str[256],hdr[256],scratch[80],fn[128]; 00659 00660 if (file == NULL) return argument_list_error; 00661 if (path == NULL) strncpy(fn,file,128); else sprintf(fn,"%s%s",path,file); 00662 /* find database size => effectively the number of rows */ 00663 if ((db->siz=GetDataBaseSize(fn)) < 0) ccerr(-db->siz); 00664 /* was a pre-allocated target passed ? */ 00665 if (target != NULL) db->tgt = (BYTE *)*target; 00666 /* call init routine if there */ 00667 if (db->ini != NULL) db->ini(db); 00668 /* either the target was pre-allocated or the initializer allocated it */ 00669 if (target != NULL) *target = db->tgt; 00670 /* read through */ 00671 if ((fp=fopen(fn,"r")) == NULL) ccerr(no_such_file); 00672 while (fgets(str,255,fp) != NULL) 00673 { 00674 strtrm(str); 00675 if (strlen(str) == 0) continue; /* carraige return */ 00676 if (strchr("%;#\n",str[0]) != NULL) continue; /* comment line */ 00677 if (!done) 00678 { 00679 strncpy(hdr,str,255); 00680 for (i=0; i<db->ncols; i++) db->col[i].pos = findcol(hdr,db->col[i].nam); 00681 done = TRUE; 00682 continue; 00683 } 00684 for (i=0; i<db->ncols; i++) 00685 { 00686 if (db->col[i].pos < 0) 00687 { 00688 c = db->col[i].def; 00689 } 00690 else 00691 { 00692 getColumnStr(db->col[i].pos,str,scratch,64); scratch[64] = 0; 00693 c = scratch; 00694 } 00695 /* assign value to structure location */ 00696 cc = csvAssignValue(db->col[i].ptr,db->col[i].fmt,db->col[i].siz,c); 00697 if (cc) 00698 { 00699 sprintf(str,"column %s entry %d : %s\n",db->col[i].nam,i,erlst[cc]); 00700 feclog(str); ttyoutput(str); 00701 ccerr(cc); 00702 } 00703 /* call action function if there */ 00704 if (db->col[i].fcn != NULL) if (db->col[i].fcn(c) != 0) break; 00705 } 00706 /* call iterator if there */ 00707 if (db->itr != NULL) if (db->itr(db) != 0) break; 00708 } 00709 /* call end routine if there */ 00710 if (db->exi != NULL) db->exi(db); 00711 err: 00712 if (fp) fclose(fp); 00713 return cc; 00714 }
Here is the call graph for this function:
Here is the caller graph for this function:
EXPORT void csvStdExit | ( | struct CSVDBStruct * | db | ) |
Definition at line 593 of file dblib.c.
References CSVDBStruct::col, CSVDBStruct::ncols, CSVCOLUMN::ptr, CSVCOLUMN::start, and CSVDBStruct::tgt_siz.
00594 { 00595 int i; 00596 if (db == NULL || db->tgt_siz <= 0) return; 00597 for (i=0; i<db->ncols; i++) db->col[i].ptr = db->col[i].start; 00598 }
EXPORT void csvStdInit | ( | struct CSVDBStruct * | db | ) |
Definition at line 546 of file dblib.c.
References BYTE, CSVDBStruct::cnt, CSVDBStruct::col, CSVDBStruct::ncols, CSVCOLUMN::ptr, CSVDBStruct::siz, CSVCOLUMN::start, SystemCalloc, SystemFree, CSVDBStruct::tgt, and CSVDBStruct::tgt_siz.
00547 { 00548 int i; 00549 if (db == NULL || db->tgt_siz <= 0) return; 00550 db->cnt = 0; 00551 if (db->tgt != NULL) SystemFree(db->tgt); 00552 db->tgt = (BYTE *)SystemCalloc(db->siz,db->tgt_siz); 00553 for (i=0; i<db->ncols; i++) 00554 { 00555 db->col[i].start = db->col[i].ptr; /* reset via csvStdExit() */ 00556 /* set the ptr to the container addr plus the original offset */ 00557 db->col[i].ptr = db->tgt + (size_t)db->col[i].start; 00558 } 00559 }
EXPORT int csvStdIterator | ( | struct CSVDBStruct * | db | ) |
Definition at line 571 of file dblib.c.
References CF_NULL, CSVDBStruct::cnt, CSVDBStruct::col, CSVCOLUMN::fmt, CSVDBStruct::ncols, CSVCOLUMN::ptr, and CSVDBStruct::tgt_siz.
00572 { 00573 int i; 00574 if (db == NULL || db->tgt_siz <= 0) return -1; /* don't iterate */ 00575 for (i=0; i<db->ncols; i++) if (db->col[i].fmt != CF_NULL) db->col[i].ptr += db->tgt_siz; 00576 db->cnt++; 00577 return 0; 00578 }
EXPORT int csvWriteFile | ( | char * | path, | |
char * | file, | |||
CSVDB * | db | |||
) |
Definition at line 750 of file dblib.c.
References argument_list_error, ccerr, CSVDBStruct::col, file_error, CSVCOLUMN::nam, CSVDBStruct::ncols, CSVCOLUMN::ptr, CSVCOLUMN::start, CSVDBStruct::tgt, and CSVDBStruct::tgt_siz.
00751 { 00752 FILE *fp=NULL; 00753 int i,j,cc=0; 00754 char str[256],scratch[64],fn[128]; 00755 00756 if (file == NULL) return argument_list_error; 00757 if (path == NULL) strncpy(fn,file,128); else sprintf(fn,"%s%s",path,file); 00758 if ((fp=fopen(fn,"w")) == NULL) ccerr(file_error); 00759 for (i=0,str[0]=0; i<db->ncols; i++) 00760 { 00761 strcat(str,db->col[i].nam); 00762 if (i<db->ncols-1) strcat(str,","); 00763 if (db->tgt_siz > 0) /* return pointers to start position */ 00764 { 00765 db->col[i].ptr = db->tgt + (size_t)db->col[i].start; 00766 } 00767 } 00768 strcat(str,"\n"); 00769 fwrite(str,strlen(str),1,fp); 00770 for (j=0; j<db->siz; j++) 00771 { 00772 str[0] = 0; 00773 for (i=0; i<db->ncols; i++) 00774 { 00775 csvGetValue(db->col[i].ptr,db->col[i].fmt,db->col[i].siz,scratch); 00776 strcat(str,scratch); 00777 if (i<db->ncols-1) strcat(str,","); 00778 } 00779 strcat(str,"\n"); 00780 fwrite(str,strlen(str),1,fp); 00781 /* call iterator if there */ 00782 if (db->itr != NULL) if (db->itr(db) != 0) break; 00783 } 00784 /* call end routine if there */ 00785 if (db->exi != NULL) db->exi(db); 00786 err: 00787 if (fp != NULL) fclose(fp); 00788 return cc; 00789 }
int findcol | ( | char * | str, | |
char * | tag | |||
) |
Definition at line 332 of file dblib.c.
Referenced by csvReadFile(), GetAddressFromNameFile(), GetEqpModuleNames(), GetEqpPropertyList(), getIPControlNets(), getRegisteredExports(), LoadHistoryInformation(), and restorePropertyValues().
00333 { 00334 char tagAlt0[96],tagAlt1[96],tagAlt2[96],altc=0,brkc=0; 00335 char *c; 00336 int len,i,k; 00337 00338 if (str == NULL || tag == NULL) return -1; 00339 /* effect a string-insensitive compare */ 00340 strncpy(tagAlt0,tag,96); 00341 strupr(tagAlt0); 00342 if ((c=strchr(tagAlt0,' ')) != NULL) 00343 { 00344 brkc = ' '; 00345 altc = '_'; 00346 } 00347 else if ((c=strchr(tagAlt0,'_')) != NULL) 00348 { 00349 brkc = '_'; 00350 altc = ' '; 00351 } 00352 if (brkc != 0) /* prepare alternates */ 00353 { 00354 for (i=0,k=0; i<(int)strlen(tagAlt0) && i<95; i++) 00355 { 00356 if (tagAlt0[i] != brkc) 00357 { 00358 tagAlt1[i] = tagAlt0[i]; 00359 tagAlt2[k++] = tagAlt0[i]; 00360 } 00361 else /* tagAlt0[i] == brkc */ 00362 { 00363 tagAlt1[i] = altc; 00364 } 00365 } 00366 tagAlt1[i] = 0; tagAlt2[k] = 0; 00367 } 00368 for (i=0,c=str; strlen(c); i++,c++) 00369 { 00370 while (*c == '\"') { c = strchr(++c,'\"'); if (c++ == NULL) return -1; } 00371 while (isspace(*c) != 0) c++; 00372 strupr(c); 00373 len = (int)strcspn(c,",\n"); while (isspace(c[len-1]) != 0) len--; 00374 if (!strncmp(c,tagAlt0,MAX(len,(int)strlen(tagAlt0)))) return i; 00375 if (brkc != 0) 00376 { 00377 if (!strncmp(c,tagAlt1,MAX(len,(int)strlen(tagAlt1)))) return i; 00378 if (!strncmp(c,tagAlt2,MAX(len,(int)strlen(tagAlt2)))) return i; 00379 } 00380 if ((c=strpbrk(c,",\n")) == NULL) return -1; 00381 } 00382 return -1; 00383 }
Here is the call graph for this function:
Here is the caller graph for this function:
int getColumnStr | ( | int | col, | |
char * | str, | |||
char * | buf, | |||
int | bufsiz | |||
) |
Definition at line 399 of file dblib.c.
References argument_list_error, ccerr, erlst, FALSE, feclog(), no_such_column, string_expected, and TRUE.
Referenced by colptr(), csvReadFile(), GetAddressFromNameFile(), GetEqpModuleNames(), GetEqpPropertyList(), getIPControlNets(), getRegisteredExports(), LoadHistoryInformation(), namcmp(), and restorePropertyValues().
00400 { 00401 int colcnt=0, cc = 0; 00402 char *c; 00403 int sslen, FindEndOfString = FALSE; 00404 00405 if (str == NULL || buf == NULL) ccerr(argument_list_error); 00406 00407 /* find column position 'col' (count the non-embedded commas) : */ 00408 /* c points to current position in string; DO NOT scan past the string length !*/ 00409 for (c=str; strlen(c) > 0 && colcnt < col; c++) 00410 { 00411 /* scan through the string ... */ 00412 if (FindEndOfString) 00413 { 00414 /* jump ahead to it */ 00415 if ((c=strchr(c,'\"')) == NULL) ccerr(string_expected); 00416 FindEndOfString = FALSE; /* found it */ 00417 } 00418 else 00419 { 00420 if (*c == ',') colcnt++; 00421 else if (*c == '\"') FindEndOfString = TRUE; /* quoted string */ 00422 } 00423 } 00424 00425 /* did we jump out because strlen(c) == 0 ? */ 00426 if (colcnt < col) ccerr(no_such_column); 00427 00428 while (isspace(*c) != 0) c++; /* trim leading spaces */ 00429 if (*c == '\"') 00430 { 00431 c++; /* if quoted, jump over initial quote */ 00432 sslen = (int)strcspn(c,"\""); /* length up to the next \" */ 00433 } 00434 else 00435 { 00436 sslen = (int)strcspn(c,",\n"); /* length up to the next , or \n */ 00437 } 00438 while (sslen > 0 && isspace(c[sslen-1]) != 0) sslen--; /* Strip trailing spaces */ 00439 if (sslen > bufsiz) 00440 { 00441 /* sslen longer than expected; write log message and continue anyway */ 00442 feclog("sub string \"%s\" too long (%d vs %d)",c,sslen,bufsiz); 00443 sslen = bufsiz; 00444 } 00445 strncpy(buf,c,sslen); /* Copy sub-string to buffer */ 00446 if (sslen < bufsiz) buf[sslen] = 0; /* add \0 if there's room */ 00447 00448 err: 00449 if (cc) 00450 { 00451 c = str == NULL ? "<null string>" : str; 00452 feclog("csv: column %d in %s -> %s",col,c,erlst[cc]); 00453 } 00454 return cc; 00455 }
Here is the call graph for this function:
Here is the caller graph for this function:
int GetDataBaseSize | ( | char * | filename | ) |
Definition at line 155 of file dblib.c.
References argument_list_error, no_such_file, and strtrm().
Referenced by csvReadFile(), GetAllocSizesFromNameFile(), GetEqpPropertyList(), getIPControlNets(), and LoadHistoryInformation().
00156 { 00157 char str[256]; 00158 int line = -1; 00159 FILE *fp; 00160 00161 if (filename == NULL || strlen(filename) == 0) return -argument_list_error; 00162 if ((fp=fopen(filename,"r")) == NULL) return -no_such_file; 00163 while (fgets(str,255,fp) != NULL) /* scan file */ 00164 { 00165 strtrm(str); 00166 if (strlen(str) == 0) continue; /* carriage return */ 00167 if (strchr("%;#",str[0])) continue; /* comment line(s) */ 00168 line++; 00169 } 00170 fclose(fp); 00171 return line; 00172 }
Here is the call graph for this function:
Here is the caller graph for this function:
int GetNameServerAddress | ( | void | ) |
Definition at line 286 of file dblib.c.
References BYTE, ControlDBpath, CSHOSTS_FILE, csvNameServerDb, csvReadFile(), erlst, feclog(), FS_DELIMITER, NameServer, SetNameServerAddress(), and CSVDBStruct::siz.
Referenced by GetAllocSizesFromNameServer(), and sndRegisteredExports().
00287 { 00288 # ifdef FS_DELIMITER 00289 int i; 00290 # endif 00291 int cc; 00292 short tmpPortOffset; 00293 char *ptr; 00294 00295 if ((ptr=getenv("TINE_ENS")) != NULL || (ptr=getenv("CONTROLENS")) != NULL) 00296 SetNameServerAddress(ptr); 00297 if (gotNameServerAddress) return 0; 00298 ControlDBpath[0] = 0; 00299 if ((ptr=getenv("TINE_HOME")) != NULL || (ptr=getenv("CONTROLDB")) != NULL) 00300 strcpy(ControlDBpath,ptr); 00301 # ifdef FS_DELIMITER 00302 if (((i=(int)strlen(ControlDBpath)) > 0) && 00303 (ControlDBpath[i-1] != FS_DELIMITER)) /* no delimiter ! */ 00304 { 00305 ControlDBpath[i] = FS_DELIMITER; ControlDBpath[i+1] = 0; 00306 } 00307 # endif 00308 feclog("TINE HOME : [%s]",ControlDBpath); 00309 numNameServers = 0; 00310 csvNameServerColumns[3].ptr = (BYTE *)&tmpPortOffset; 00311 if ((cc=csvReadFile(ControlDBpath,CSHOSTS_FILE,&csvNameServerDb,(void **)&NameServer)) == 0) 00312 { 00313 gotNameServerAddress = 1; 00314 numNameServers = csvNameServerDb.siz; 00315 } 00316 else 00317 { 00318 feclog("name server address unresolved : %s",erlst[cc]); 00319 } 00320 return cc; 00321 }
Here is the call graph for this function:
Here is the caller graph for this function:
void HexToBytes | ( | char * | s, | |
BYTE * | b, | |||
int | nibs | |||
) |
Definition at line 56 of file dblib.c.
References strrev().
Referenced by csvAssignValue(), and GetAddressFromNameFile().
00057 { 00058 char buf[20]; 00059 int l,i; 00060 00061 if ((l=(int)strlen(s)) < nibs) 00062 { 00063 strrev(s); strncat(s,"000000000000",nibs-l); 00064 strrev(s); 00065 } 00066 for (i=0; i<nibs/2; i++) 00067 { 00068 strncpy(buf,&s[i*2],2); buf[2] = 0; 00069 b[i] = (unsigned char)strtol(buf,NULL,16); 00070 } 00071 }
Here is the call graph for this function:
Here is the caller graph for this function:
unsigned int HexToDec | ( | char * | str | ) |
Definition at line 72 of file dblib.c.
00073 { 00074 int i,d; 00075 unsigned int off,value; 00076 00077 off=1;value=0; 00078 for (i=(int)strlen(str)-1;i>=0;i--) 00079 { 00080 if (str[i]>='A') d=str[i]-'A'+10;else d=str[i]-'0'; 00081 value=value+off*d; 00082 off=off*16; 00083 } 00084 return value; 00085 }
int namcmp | ( | char * | name, | |
char * | str, | |||
int | col, | |||
int | limit | |||
) |
Definition at line 495 of file dblib.c.
References getColumnStr(), and MAX.
Referenced by GetAddressFromNameFile().
00496 { 00497 int n; 00498 char *scratch; 00499 # if defined(VXWORKS) 00500 /* VxWorks does not understand alloca() */ 00501 char scratchBuffer[516]; 00502 if (limit < 0 || limit > 512) return -1; 00503 scratch = scratchBuffer; 00504 # else 00505 if (limit < 0) return -1; 00506 if ((scratch=(char *)alloca(limit)) == NULL) return -1; /* practically impossible */ 00507 # endif 00508 getColumnStr(col,str,scratch,limit); 00509 n = MAX(limit,(int)strcspn(scratch,",\n")); 00510 return strncmp(name,scratch,n); 00511 }
Here is the call graph for this function:
Here is the caller graph for this function:
char* strtrm | ( | char * | s | ) |
Definition at line 122 of file dblib.c.
Referenced by csvReadFile(), GetAddressFromNameFile(), GetDataBaseSize(), GetEqpModuleNames(), GetEqpPropertyList(), getIPControlNets(), getRegisteredExports(), LoadHistoryInformation(), and restorePropertyValues().
00123 { 00124 char *start, *end; 00125 unsigned int len; 00126 00127 if (s == NULL) return s; /* NULL given, give it back */ 00128 if ((len=(int)strlen(s)) == 0) return s; /* empty string given, give it back */ 00129 /* find first non-whitespace */ 00130 for (start=s; isspace(*start) && len > 0; start++, len--); 00131 /* find last non-whitespace */ 00132 for (end=start+len-1; isspace(*end) && len > 0; end--, len--) *end = 0; 00133 /* Move to the left */ 00134 memmove(s, start, len + 1); 00135 /* return a pointer to the modified string as a curtesy */ 00136 return s; 00137 }
Here is the caller graph for this function:
Initial value:
{ { "FEC_NAME","",0,CF_TEXT,FEC_NAME_SIZE,(BYTE *)OFFSETIN(RPCFecStruct,Name),NULL,0 }, { "FEC_NETWORK","0",0,CF_BYTE,8,(BYTE *)OFFSETIN(RPCFecStruct,Network),NULL,0 }, { "FEC_NODE","0",0,CF_BYTE,12,(BYTE *)OFFSETIN(RPCFecStruct,Node),NULL,0 }, { "PORT_OFFSET","0",0,CF_NULL,1,NULL,csvNameServerFillPortOffset,0 }, { "IP_ADDR","",0,CF_TEXT,16,(BYTE *)OFFSETIN(RPCFecStruct,IP),csvNameServerFillHAddr,0 }, }
Initial value:
{ csvNameServerColumns, sizeof(csvNameServerColumns)/sizeof(csvNameServerColumns[0]), 0, csvStdInit, csvStdIterator, csvStdExit, 0, NULL, sizeof(RPCFecStruct) }
Definition at line 219 of file dblib.c.
Referenced by csvNameServerFillHAddr(), csvNameServerFillPortOffset(), and GetNameServerAddress().
int gotNameServerAddress = 0 |
Definition at line 265 of file dblib.c.
Referenced by FindNameServerOnNetwork(), and SetNameServerAddress().
RPCFecStruct* NameServer = NULL |
Definition at line 198 of file dblib.c.
Referenced by csvNameServerFillHAddr(), csvNameServerFillPortOffset(), FindNameServerOnNetwork(), GetAllocSizesFromNameServer(), GetNameServerAddress(), initFecTable(), SetNameServerAddress(), ToggleNameServer(), and tUDPCall().
int numNameServers = 0 |
Definition at line 208 of file dblib.c.
Referenced by FindNameServerOnNetwork(), GetAddressFromNameServer(), SetNameServerAddress(), and ToggleNameServer().
RPCFecStruct* RPCFec = NULL |
Definition at line 186 of file dblib.c.
Referenced by AddIdleConnection(), appendAddressToCache(), CheckConnections(), closeIPClients(), closeIPConnectionToFec(), connectTCP(), consumeData(), doUDPConsumer(), ExecLinkEx(), fillinFecName(), fillinTagName(), GetAddressFromNameFile(), GetAddressFromNameServer(), getConnectionEntry(), getIncomingFecIndex(), initFecTable(), isUnixSocket(), locateFecName(), locateTagName(), outputConnectionList(), outputConnectionStats(), PrepSubBuffer(), RemoveIdleConnection(), SendSubBuffer(), ToggleNameServer(), and tUDPCall().