void locateClientByName(BYTE *pName, BOOL8 *pblF, CLIENT_t **ptC) { *ptC = NULL; *pblF = FALSE_B8; INT32 i; for (i=0; i<MAX_CONNECT_CLIENT; i++) { if (patClient[i].eState == eCLIENT_STATE_NONE) { continue; } if (StrICmp(pName,(BYTE *)patClient[i].aName)) { // found, return if (i == 0) *pblF = TRUE_B8; *ptC = &patClient[i]; return; } } // NOT found, check F-Name if (StrICmp((BYTE *)m_confs.aFName, pName)) { *pblF = TRUE_B8; } return; }
void TestStrICmp(void) { int iResult; iResult = StrICmp("Hello", "hello"); AssertInt(0, iResult); iResult = StrICmp("", NULL); AssertInt(1, iResult); iResult = StrICmp(NULL, ""); AssertInt(-1, iResult); iResult = StrICmp(NULL, NULL); AssertInt(0, iResult); iResult = StrICmp("", ""); AssertInt(0, iResult); iResult = StrICmp("ABC", "XYZ"); AssertInt(-23, iResult); iResult = StrICmp("xyz", "abc"); AssertInt(23, iResult); iResult = StrICmp("abc", "abcd"); AssertInt(-1, iResult); iResult = StrICmp("abcd", "abc"); AssertInt(1, iResult); }
int FindInstances(const char *processName, DWORD *pids) { int found = 0; // Include all processes in the snapshot // th32ProcessID is ignored HANDLE snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (snapShot == INVALID_HANDLE_VALUE) { return found; } PROCESSENTRY32 processEntry; processEntry.dwSize = sizeof(PROCESSENTRY32); ZeroMemory(&processEntry.cntUsage, sizeof(PROCESSENTRY32) - sizeof(DWORD)); if (Process32First(snapShot, &processEntry)) { do { if (StrICmp(GetBaseName(processEntry.szExeFile), processName)) { pids[found] = processEntry.th32ProcessID; ++found; } } while (Process32Next(snapShot, &processEntry)); } CloseHandle(snapShot); return found; }
inline INT CharTraits<CharType>::StrICmp( CONST CharType* A, CONST CharType* B ) { SIZE_T N = Length(A); if (Length(B) < N) N = Length(B); return StrICmp(A,B,N); }
BOOL CNamesIndexedSorterSource::IsSmallerThan(CNamesIndexedSorterSource* pcOther) { int iResult; if (mpcCurrent->IsEmpty()) { return FALSE; } else { if (pcOther == NULL) { return TRUE; } iResult = StrICmp(mpcCurrent->Name(), pcOther->mpcCurrent->Name()); if (iResult < 0) { return TRUE; } else { return FALSE; } } }
BOOL CChars::EqualsIgnoreCase(const char* szString) { if (StrICmp(Text(), szString) == 0) { return TRUE; } return FALSE; }
VOID WriteSetup() { int n = sizeof(setupparameters)/sizeof(SETUPPARAMETERS); SETUPPARAMETERS *sp; MesPrint(" The setup parameters are:"); for ( sp = setupparameters; n > 0; n--, sp++ ) { switch(sp->type){ case NUMERICALVALUE: MesPrint(" %s: %l",sp->parameter,sp->value); break; case PATHVALUE: if ( StrICmp(sp->parameter,(UBYTE *)"path") == 0 && AM.Path ) { MesPrint(" %s: '%s'",sp->parameter,(UBYTE *)(AM.Path)); break; } if ( StrICmp(sp->parameter,(UBYTE *)"incdir") == 0 && AM.IncDir ) { MesPrint(" %s: '%s'",sp->parameter,(UBYTE *)(AM.IncDir)); break; } case STRINGVALUE: if ( StrICmp(sp->parameter,(UBYTE *)"tempdir") == 0 && AM.TempDir ) { MesPrint(" %s: '%s'",sp->parameter,(UBYTE *)(AM.TempDir)); } else if ( StrICmp(sp->parameter,(UBYTE *)"tempsortdir") == 0 && AM.TempSortDir ) { MesPrint(" %s: '%s'",sp->parameter,(UBYTE *)(AM.TempSortDir)); } else { MesPrint(" %s: '%s'",sp->parameter,(UBYTE *)(sp->value)); } break; case ONOFFVALUE: if ( sp->value == 0 ) MesPrint(" %s: OFF",sp->parameter); else if ( sp->value == 1 ) MesPrint(" %s: ON",sp->parameter); break; case DEFINEVALUE: /* MesPrint(" %s: '%s'",sp->parameter,(UBYTE *)(sp->value)); */ break; } } AC.SetupFlag = 0; }
SETUPPARAMETERS *GetSetupPar(UBYTE *s) { int hi, med, lo, i; lo = 0; hi = sizeof(setupparameters)/sizeof(SETUPPARAMETERS); do { med = ( hi + lo ) / 2; i = StrICmp(s,(UBYTE *)setupparameters[med].parameter); if ( i == 0 ) return(setupparameters+med); if ( i < 0 ) hi = med-1; else lo = med+1; } while ( hi >= lo ); return(0); }
BOOL CDurableFileController::Init(char* szDirectory, char* szRewriteDirectory) { CChars szStart; CChars szRewrite; CFileUtil cFileUtil; if (StrEmpty(szDirectory)) { return gcLogger.Error2(__METHOD__, " Controller directory must be supplied.", NULL); } mbDurable = FALSE; if (!StrEmpty(szRewriteDirectory)) { mbDurable = TRUE; } if (mbDurable && (StrICmp(szDirectory, szRewriteDirectory) == 0)) { return gcLogger.Error2(__METHOD__, " Controller directory and rewrite directory must be different.", NULL); } mszDirectory.Init(szDirectory); szStart.Init(szDirectory); cFileUtil.AppendToPath(&szStart, "Mark1.Write"); if (szRewriteDirectory && mbDurable) { mszRewriteDirectory.Init(szRewriteDirectory); szRewrite.Init(szRewriteDirectory); } else { mszRewriteDirectory.Init(); szRewrite.Init(szDirectory); } cFileUtil.AppendToPath(&szRewrite, "Mark2.Rewrite"); mcDurableSet.Init(szStart.Text(), szRewrite.Text()); szRewrite.Kill(); szStart.Kill(); return TRUE; }
BOOL PrivateAssertString(char* szExpected, char* szActual, BOOL bTestCase, int iLine, char* szFile) { if ((szExpected == NULL) && (szActual == NULL)) { return Pass(); } else if (szActual == NULL) { return Fail(szExpected, "** NULL **", iLine, szFile); } else { if (bTestCase) { if (strcmp(szExpected, szActual) != 0) { return Fail(szExpected, szActual, iLine, szFile); } else { return Pass(); } } else { if (StrICmp(szExpected, szActual) != 0) { return Fail(szExpected, szActual, iLine, szFile); } else { return Pass(); } } } }
int DetectCheats(const char **names, int n, DWORD *pids) { int found = 0; HANDLE snapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (snapShot == INVALID_HANDLE_VALUE) { return found; } PROCESSENTRY32 processEntry; processEntry.dwSize = sizeof(PROCESSENTRY32); ZeroMemory(&processEntry.cntUsage, sizeof(PROCESSENTRY32) - sizeof(DWORD)); if (Process32First(snapShot, &processEntry)) { do { int i; for (i = 0; i < n; ++i) { if (!StrICmp(GetBaseName(processEntry.szExeFile), names[i])) { continue; } else { pids[found] = processEntry.th32ProcessID; ++found; DebugOutput(names[i]); break; } } } while (Process32Next(snapShot, &processEntry)); } CloseHandle(snapShot); return found; }
Boolean LIBCALL VastToCn3D(WWWInfoPtr www_info) { FILE *pFile = NULL; FILE *pIn = NULL; Char pcBuf[100], pcLine[256], giBuf[20], URL[200]; CharPtr pcTest, pcL1 = NULL, Name, www_arg; Int4 GetGi, Fid, Fsid, iFileExists = 0, indx; BiostrucAnnotSetPtr pbsa = NULL; BiostrucAnnotSetPtr pbsaShort = NULL; BiostrucFeatureSetPtr pbsfs = NULL; BiostrucFeaturePtr pbsf = NULL; BiostrucResidueGraphSetPtr stdDictionary; ValNodePtr pvnFids = NULL, pvnFid = NULL; Int2 iTest = 0, iPDB = 0, iColor; AsnIoPtr aip = NULL; Byte bRender; Char *IPAddress = getenv("REMOTE_HOST"); Int4 NumLabels, iMMDBId; ValNode * pbsidThis; BiostrucPtr pbsMaster, pbsSlave, pbsSlaveHead = NULL, pbsSlaveTail, pbsTemp; Char szName[5], chain[2]; Char * szTemp; SeqAnnotPtr psaAlignHead = NULL, psaAlignTail; SeqAlignPtr salpHead, salpTail; SeqIdPtr sip; DenseSegPtr dsp; BioseqPtr bsp; SeqEntryPtr sep; char str [52]; NcbiMimeAsn1Ptr pvnNcbi; BiostrucAlignPtr pbsaStruct; AsnIoPtr paiFile, aipr; Boolean is_network; Int4 uid, uidmaster = 0; Int2 retcode = 3; CharPtr JobID = NULL, pcPass; Char AsnPath[PATH_MAX]; Char AsnName[10]; Int2 ret, complexity; Int4 iFidCount = 0; Boolean Chain; /* SeqAsnLoad(); objmmdb1AsnLoad(); objmmdb2AsnLoad(); objmmdb3AsnLoad(); SeqAlignAsnLoad(); objmimeAsnLoad(); */ if ((indx = WWWFindName(www_info, "uid")) < 0) { printf("Content-type: text/html\n\n"); printf("<h3>No accession (PDB ID) was input - nothing to report.</h3>\n"); return 0; } www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) GetGi = (Int4) atoi(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Non-numeric MMDB-id input - no results.</h3>\n"); return 0; } /* vsid and pass are to look at alignments from VAST Search */ if ((indx = WWWFindName(www_info, "vsid")) >= 0) { www_arg = WWWGetValueByIndex(www_info, indx); JobID = StringSave(www_arg); if ((indx = WWWFindName(www_info, "pass")) < 0) { printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<h2>VAST SEARCH</h2>\n"); printf("<h3>Password required.</h3>\n"); return 0; } else { www_arg = WWWGetValueByIndex(www_info, indx); pcPass = StringSave(www_arg); if ((ret = Check_VastSearch_Password(pcPass, JobID)) != 1) { if (ret == 2) return 0; printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<h2>VAST SEARCH</h2>\n"); printf("<h3>Incorrect password.</h3>\n"); return 0; } } } if ((indx = WWWFindName(www_info, "hit")) < 0) { printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<br>\n<h2>No alignment was selected!</h2>\n"); printf("<h3>Please click on up to 5 boxes in the leftmost column of the table.</h3>\n"); return 0; } /* loop over all the "hit" values in the list */ NumLabels = WWWGetNumEntries(www_info); for (indx = 0; indx < NumLabels; indx++) { Name = WWWGetNameByIndex(www_info, indx); if (StrICmp(Name, "hit") == 0) { www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) Fid = (Int4) atol(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Non-numeric slave alignment code - no results.</h3>\n"); return 0; } if (++iFidCount > 5) break; pvnFid = ValNodeAddInt(&pvnFids, 0, Fid); } } if ((indx = WWWFindName(www_info, "chaindom")) < 0) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>No feature set ID (master alignment code) - nothing to report.</h3>\n"); return 0; } www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) Fsid = (Int4) atoi(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Non-numeric master alignment code - no results.</h3>\n"); return 0; } if ((indx = WWWFindName(www_info, "chn_complexity")) < 0) Chain = TRUE; else { www_arg = WWWGetValueByIndex(www_info, indx); complexity =(Int2)atoi(www_arg); if (complexity) Chain = TRUE; else Chain = FALSE; } if ((indx = WWWFindName(www_info, "atm_complexity")) < 0) /* select alpha Carbons only by default */ complexity = ONECOORDRES; else { www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) complexity = (Int2) atoi(www_arg); else complexity = ONECOORDRES; } if ((complexity != ONECOORDRES) && (complexity != ONECOORDATOM)) /* bizarre value, but default to alpha-Carbons only */ complexity = ONECOORDRES; /* action == 0 indicates MIME; action == 1 is text; action == 2 is save */ if ((indx = WWWFindName(www_info, "action")) < 0) iPDB = 0; else { www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) iPDB = (Int4) atoi(www_arg); else iPDB = 0; } if (VASTInit() != TRUE) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Can't find VAST data on server.\n"); printf("Contact [email protected]</h3>\n"); return 0; } OpenMMDBAPI((POWER_VIEW /* ^ FETCH_ENTREZ */), NULL); pbsa = LocalGetFeatureSet(GetGi, Fsid, JobID); if (pbsa == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>No master alignment record exists for %ld.</h3>\n", (long) GetGi); return 0; } if (iFidCount == 1) pbsaShort = BiostrucAnnotSetGetByFid(pbsa, Fid, Fsid); else pbsaShort = PruneBiostrucAnnotHits(pbsa, Fsid, pvnFids); if (pbsaShort == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Can't find alignment record.</h3>\n"); return 0; } if (MMDBInit() == FALSE) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>MMDBInit failed.</h3>\n"); return 0; } pbsfs = pbsaShort->features; pbsaStruct = BiostrucAlignNew(); if (pbsfs) { pbsf = pbsfs->features; szTemp = pbsf->name; szName[0] = szTemp[0]; szName[1] = szTemp[1]; szName[2] = szTemp[2]; szName[3] = szTemp[3]; szName[4] = '\0'; } if (JobID == NULL) pbsMaster = FetchBiostrucPDB(szName, complexity, 1); else { AsnName[0]='\0'; StringCpy(AsnName, "/b"); StringCat(AsnName, szName); AsnPath[0]='\0'; StringCpy(AsnPath, VSPATH); StringCat(AsnPath, JobID); StringCat(AsnPath, AsnName); pbsMaster = FetchBS(AsnPath, 0, complexity, 1, POWER_VIEW); } if (pbsMaster == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3> Unable to load master structure.</h3>\n"); return 0; } /* Load in Standard Dictionary to make sequences - Ken */ aipr = NULL; aipr = AsnIoOpen("bstdt", "rb"); if (aipr == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Can't find standard dictionary.</h3>\n"); return 0; } stdDictionary = BiostrucResidueGraphSetAsnRead(aipr, NULL); AsnIoFlush(aipr); aipr = AsnIoClose(aipr); /* retrieve the bioseq for master and put in ValNode */ sep = (SeqEntryPtr) MakeBioseqs(pbsMaster, stdDictionary); if ( sep == NULL ) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to get SeqEntry.</h3>\n"); return 0; } ValNodeLink(&(pbsaStruct->sequences), sep); /* PruneBiostruc if Aligned Chain Options has been chosen */ if (Chain) { if (szTemp[4] != ' ') { chain[0] = szTemp[4]; chain[1] = '\0'; pbsTemp = (BiostrucPtr)PruneBiostruc(pbsMaster, chain); pbsMaster = NULL; pbsMaster = pbsTemp; } } /* Make a linked list of Biostrucs of the slave structures*/ while (pbsf) { szTemp = pbsf->name; szName[0] = szTemp[7]; szName[1] = szTemp[8]; szName[2] = szTemp[9]; szName[3] = szTemp[10]; szName[4] = '\0'; if (!pbsSlaveHead) { pbsSlaveHead = FetchBiostrucPDB(szName, complexity, 1); if (!pbsSlaveHead) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3> Unable to load slave structure.</h3>\n"); return 0; } /* Make Bioseq for Slaves */ sep = (SeqEntryPtr) MakeBioseqs(pbsSlaveHead, stdDictionary); if ( sep == NULL ) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to get SeqEntry.</h3>\n"); return 0; } ValNodeLink(&(pbsaStruct->sequences), sep); /* PruneBiostruc if Aligned Chain Options has been chosen */ if (Chain) { if (szTemp[11] != ' ') { chain[0] = szTemp[11]; chain[1] = '\0'; pbsTemp = (BiostrucPtr)PruneBiostruc(pbsSlaveHead, chain); pbsSlaveHead = NULL; pbsSlaveHead = pbsTemp; } } pbsSlaveTail = pbsSlaveHead; } else { pbsSlave = FetchBiostrucPDB(szName, complexity, 1); if (!pbsSlave) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3> Unable to load slave structure.</h3>\n"); return 0; } /* Make Bioseq for Slaves */ sep = (SeqEntryPtr) MakeBioseqs(pbsSlave, stdDictionary); if ( sep == NULL ) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to get SeqEntry.</h3>\n"); return 0; } ValNodeLink(&(pbsaStruct->sequences), sep); /* PruneBiostruc if Aligned Chain Options has been chosen */ if (Chain) { if (szTemp[11] != ' ') { chain[0] = szTemp[11]; chain[1] = '\0'; pbsTemp = (BiostrucPtr)PruneBiostruc(pbsSlave, chain); pbsSlave = NULL; pbsSlave = pbsTemp; } } pbsSlaveTail->next = pbsSlave; pbsSlaveTail = pbsSlaveTail->next; pbsSlaveTail->next = NULL; } pbsf = pbsf->next; } /* Make a linked list of sequence alignments of master and slaves */ pbsf=pbsfs->features; while (pbsf) { if (!psaAlignHead) { psaAlignHead = fnPBSFtoPSA (pbsf); /* get the sequence alignments */ if (psaAlignHead == NULL || psaAlignHead->data == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to create SeqAnnot.</h3>\n"); return 0; } salpHead = (SeqAlignPtr)(psaAlignHead->data); salpTail = salpHead; } else { psaAlignTail = fnPBSFtoPSA (pbsf); salpTail->next = (SeqAlignPtr)(psaAlignTail->data); if (psaAlignTail == NULL || psaAlignTail->data == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to create SeqAnnot.</h3>\n"); return 0; } salpTail = salpTail->next; salpTail->next = NULL; } pbsf = pbsf->next; } pbsaStruct->master = pbsMaster; pbsaStruct->slaves = pbsSlaveHead; pbsaStruct->alignments = pbsaShort; pbsaStruct->seqalign = psaAlignHead; pvnNcbi = ValNodeNew(NULL); pvnNcbi->choice = NcbiMimeAsn1_alignstruc; pvnNcbi->data.ptrvalue = pbsaStruct; pvnNcbi = (NcbiMimeAsn1Ptr) CheckId(pvnNcbi, JobID); /* to check identity, yanli */ OutputFile = stdout; if (iPDB == 0) /* cn3d MIME */ printf ("Content-type: chemical/ncbi-asn1-binary\n\n"); else if (iPDB == 1) { /* "See File" */ printf ("Content-type: text/html\n\n"); printf ("<HTML><body><pre>\n"); } else /* "Save File" */ printf ("Content-type: application/octet-stream\n\n"); if (iPDB != 1) paiFile = AsnIoNew(ASNIO_BIN_OUT, stdout, NULL, NULL, NULL); else paiFile = AsnIoNew(ASNIO_TEXT_OUT, stdout, NULL, NULL, NULL); NcbiMimeAsn1AsnWrite(pvnNcbi, paiFile, NULL); AsnIoFlush(paiFile); AsnIoClose(paiFile); CloseMMDBAPI(); MMDBFini(); VASTFini(); return 0; } /* end of VastToCn3D */
TRISTATE CFileFinder::FindFiles(char* szInDirectory, BOOL bDirs, char* szInName, char* szExtension) { DIR* pDIR; struct dirent* pDirEnt; char szFindName[MAX_PATH]; char szTemp[MAX_PATH]; BOOL bValid; char szDirectory[MAX_PATH]; char szFile[MAX_PATH]; char* szFileExtension; int iStatus; struct stat sBuffer; BOOL bDir; CFileUtil cFileUtil; if (!cFileUtil.FullPath(szDirectory, szInDirectory, MAX_PATH)) { return TRIERROR; } pDIR = opendir(szDirectory); if (pDIR == NULL) { return TRITRUE; } pDirEnt = readdir(pDIR); while (pDirEnt != NULL) { bValid = TRUE; sprintf(szTemp, "%s%s%s", szDirectory, FILE_SEPARATOR, pDirEnt->d_name); iStatus = stat(szTemp, &sBuffer); if (iStatus == -1) { printf("%s: %s\n", strerror(errno), szTemp); return TRIERROR; } bDir = S_ISDIR(sBuffer.st_mode); if (bDir) //Directory { if (bDirs) { if (szInName != NULL) { strcpy(szFile, pDirEnt->d_name); RemoveExtension(szFile); if (StrIStr(szFile, szInName) == NULL) { bValid = FALSE; } } else { bValid = FALSE; } } } else { if (!bDirs) { if (szExtension != NULL) { szFileExtension = FindExtension(pDirEnt->d_name); szFileExtension++; if (StrICmp(szFileExtension, szExtension) != 0) { bValid = FALSE; } } if (szInName != NULL) { strcpy(szFile, pDirEnt->d_name); RemoveExtension(szFile); if (StrIStr(szFile, szInName) == NULL) { bValid = FALSE; } } } else { bValid = FALSE; } } if (bValid) { mcFiles.Add(szTemp, 0); } pDirEnt = readdir(pDIR); } closedir(pDIR); return TRITRUE; }
int AllocSetups() { SETUPPARAMETERS *sp; LONG LargeSize, SmallSize, SmallEsize, TermsInSmall, IOsize; int MaxPatches, MaxFpatches, error = 0, i, size; UBYTE *s; #ifndef WITHPTHREADS int j; #endif sp = GetSetupPar((UBYTE *)"threads"); if ( sp->value > 0 ) AM.totalnumberofthreads = sp->value+1; AM.OutBuffer = (UBYTE *)Malloc1(AM.OutBufSize+1,"OutputBuffer"); AP.PreAssignStack =(LONG *)Malloc1(AP.MaxPreAssignLevel*sizeof(LONG *),"PreAssignStack"); for ( i = 0; i < AP.MaxPreAssignLevel; i++ ) AP.PreAssignStack[i] = 0; AC.iBuffer = (UBYTE *)Malloc1(AC.iBufferSize+1,"statement buffer"); AC.iStop = AC.iBuffer + AC.iBufferSize-2; AP.preStart = (UBYTE *)Malloc1(AP.pSize,"instruction buffer"); AP.preStop = AP.preStart + AP.pSize - 3; /* AP.PreIfStack is already allocated in StartPrepro(), but to be sure we "if" the freeing */ if ( AP.PreIfStack ) M_free(AP.PreIfStack,"PreIfStack"); AP.PreIfStack = (int *)Malloc1(AP.MaxPreIfLevel*sizeof(int), "Preprocessor if stack"); AP.PreIfStack[0] = EXECUTINGIF; sp = GetSetupPar((UBYTE *)"insidefirst"); AM.ginsidefirst = AC.minsidefirst = AC.insidefirst = sp->value; /* We need to consider eliminating this variable */ sp = GetSetupPar((UBYTE *)"maxtermsize"); AM.MaxTer = sp->value*sizeof(WORD); if ( AM.MaxTer < 200*(LONG)(sizeof(WORD)) ) AM.MaxTer = 200*(LONG)(sizeof(WORD)); if ( AM.MaxTer > MAXPOSITIVE - 200*(LONG)(sizeof(WORD)) ) AM.MaxTer = MAXPOSITIVE - 200*(LONG)(sizeof(WORD)); AM.MaxTer /= (LONG)sizeof(WORD); AM.MaxTer *= (LONG)sizeof(WORD); /* Allocate workspace. */ sp = GetSetupPar((UBYTE *)"workspace"); AM.WorkSize = sp->value; #ifdef WITHPTHREADS #else AT.WorkSpace = (WORD *)Malloc1(AM.WorkSize*sizeof(WORD),(char *)(sp->parameter)); AT.WorkTop = AT.WorkSpace + AM.WorkSize; AT.WorkPointer = AT.WorkSpace; #endif /* Fixed indices */ sp = GetSetupPar((UBYTE *)"constindex"); if ( ( sp->value+100+5*WILDOFFSET ) > MAXPOSITIVE ) { MesPrint("Setting of %s in setupfile too large","constindex"); AM.OffsetIndex = MAXPOSITIVE - 5*WILDOFFSET - 100; MesPrint("value corrected to maximum allowed: %d",AM.OffsetIndex); } else AM.OffsetIndex = sp->value + 1; AC.FixIndices = (WORD *)Malloc1((AM.OffsetIndex)*sizeof(WORD),(char *)(sp->parameter)); AM.WilInd = AM.OffsetIndex + WILDOFFSET; AM.DumInd = AM.OffsetIndex + 2*WILDOFFSET; AM.IndDum = AM.DumInd + WILDOFFSET; #ifndef WITHPTHREADS AR.CurDum = AN.IndDum = AM.IndDum; #endif AM.mTraceDum = AM.IndDum + 2*WILDOFFSET; sp = GetSetupPar((UBYTE *)"parentheses"); AM.MaxParLevel = sp->value+1; AC.tokenarglevel = (WORD *)Malloc1((sp->value+1)*sizeof(WORD),(char *)(sp->parameter)); /* Space during calculations */ sp = GetSetupPar((UBYTE *)"maxnumbersize"); /* size = ( sp->value + 11 ) & (-4); AM.MaxTal = size - 2; if ( AM.MaxTal > (AM.MaxTer/sizeof(WORD)-2)/2 ) AM.MaxTal = (AM.MaxTer/sizeof(WORD)-2)/2; if ( AM.MaxTal < (AM.MaxTer/sizeof(WORD)-2)/4 ) AM.MaxTal = (AM.MaxTer/sizeof(WORD)-2)/4; */ /* There is too much confusion about MaxTal cq maxnumbersize. It seems better to fix it at its maximum value. This way we only worry about maxtermsize. This can be understood better by the 'innocent' user. */ if ( sp->value == 0 ) { AM.MaxTal = (AM.MaxTer/sizeof(WORD)-2)/2; } else { size = ( sp->value + 11 ) & (-4); AM.MaxTal = size - 2; if ( (size_t)AM.MaxTal > (size_t)((AM.MaxTer/sizeof(WORD)-2)/2) ) AM.MaxTal = (AM.MaxTer/sizeof(WORD)-2)/2; } AM.MaxTal &= -sizeof(WORD)*2; sp->value = AM.MaxTal; AC.cmod = (UWORD *)Malloc1(AM.MaxTal*4*sizeof(UWORD),(char *)(sp->parameter)); AM.gcmod = AC.cmod + AM.MaxTal; AC.powmod = AM.gcmod + AM.MaxTal; AM.gpowmod = AC.powmod + AM.MaxTal; /* The IO buffers for the input and output expressions. Fscr[2] will be assigned in a later stage for hiding expressions from the regular action. That will make the program faster. */ sp = GetSetupPar((UBYTE *)"scratchsize"); AM.ScratSize = sp->value/sizeof(WORD); if ( AM.ScratSize < 4*AM.MaxTer ) AM.ScratSize = 4*AM.MaxTer; AM.HideSize = AM.ScratSize; sp = GetSetupPar((UBYTE *)"hidesize"); if ( sp->value > 0 ) { AM.HideSize = sp->value/sizeof(WORD); if ( AM.HideSize < 4*AM.MaxTer ) AM.HideSize = 4*AM.MaxTer; } sp = GetSetupPar((UBYTE *)"factorizationcache"); AM.fbuffersize = sp->value; #ifdef WITHPTHREADS sp = GetSetupPar((UBYTE *)"threadscratchsize"); AM.ThreadScratSize = sp->value/sizeof(WORD); sp = GetSetupPar((UBYTE *)"threadscratchoutsize"); AM.ThreadScratOutSize = sp->value/sizeof(WORD); #endif #ifndef WITHPTHREADS for ( j = 0; j < 2; j++ ) { WORD *ScratchBuf; ScratchBuf = (WORD *)Malloc1(AM.ScratSize*sizeof(WORD),"scratchsize"); AR.Fscr[j].POsize = AM.ScratSize * sizeof(WORD); AR.Fscr[j].POfull = AR.Fscr[j].POfill = AR.Fscr[j].PObuffer = ScratchBuf; AR.Fscr[j].POstop = AR.Fscr[j].PObuffer + AM.ScratSize; PUTZERO(AR.Fscr[j].POposition); } AR.Fscr[2].PObuffer = 0; #endif sp = GetSetupPar((UBYTE *)"threadbucketsize"); AC.ThreadBucketSize = AM.gThreadBucketSize = AM.ggThreadBucketSize = sp->value; sp = GetSetupPar((UBYTE *)"threadloadbalancing"); AC.ThreadBalancing = AM.gThreadBalancing = AM.ggThreadBalancing = sp->value; sp = GetSetupPar((UBYTE *)"threadsortfilesynch"); AC.ThreadSortFileSynch = AM.gThreadSortFileSynch = AM.ggThreadSortFileSynch = sp->value; /* The size for shared memory window for oneside MPI2 communications */ sp = GetSetupPar((UBYTE *)"shmwinsize"); AM.shmWinSize = sp->value/sizeof(WORD); if ( AM.shmWinSize < 4*AM.MaxTer ) AM.shmWinSize = 4*AM.MaxTer; /* The sort buffer */ sp = GetSetupPar((UBYTE *)"smallsize"); SmallSize = sp->value; sp = GetSetupPar((UBYTE *)"smallextension"); SmallEsize = sp->value; sp = GetSetupPar((UBYTE *)"largesize"); LargeSize = sp->value; sp = GetSetupPar((UBYTE *)"termsinsmall"); TermsInSmall = sp->value; sp = GetSetupPar((UBYTE *)"largepatches"); MaxPatches = sp->value; sp = GetSetupPar((UBYTE *)"filepatches"); MaxFpatches = sp->value; sp = GetSetupPar((UBYTE *)"sortiosize"); IOsize = sp->value; if ( IOsize < AM.MaxTer ) { IOsize = AM.MaxTer; sp->value = IOsize; } #ifndef WITHPTHREADS #ifdef WITHZLIB for ( j = 0; j < 2; j++ ) { AR.Fscr[j].ziosize = IOsize; } #endif #endif AM.S0 = 0; AM.S0 = AllocSort(LargeSize,SmallSize,SmallEsize,TermsInSmall ,MaxPatches,MaxFpatches,IOsize); #ifdef WITHZLIB AM.S0->file.ziosize = IOsize; #ifndef WITHPTHREADS AR.FoStage4[0].ziosize = IOsize; AR.FoStage4[1].ziosize = IOsize; AT.S0 = AM.S0; #endif #else #ifndef WITHPTHREADS AT.S0 = AM.S0; #endif #endif #ifndef WITHPTHREADS AR.FoStage4[0].POsize = ((IOsize+sizeof(WORD)-1)/sizeof(WORD))*sizeof(WORD); AR.FoStage4[1].POsize = ((IOsize+sizeof(WORD)-1)/sizeof(WORD))*sizeof(WORD); #endif sp = GetSetupPar((UBYTE *)"subsmallsize"); AM.SSmallSize = sp->value; sp = GetSetupPar((UBYTE *)"subsmallextension"); AM.SSmallEsize = sp->value; sp = GetSetupPar((UBYTE *)"sublargesize"); AM.SLargeSize = sp->value; sp = GetSetupPar((UBYTE *)"subtermsinsmall"); AM.STermsInSmall = sp->value; sp = GetSetupPar((UBYTE *)"sublargepatches"); AM.SMaxPatches = sp->value; sp = GetSetupPar((UBYTE *)"subfilepatches"); AM.SMaxFpatches = sp->value; sp = GetSetupPar((UBYTE *)"subsortiosize"); AM.SIOsize = sp->value; sp = GetSetupPar((UBYTE *)"spectatorsize"); AM.SpectatorSize = sp->value; /* The next code is just for the moment (26-jan-1997) because we have the new parts combined with the old. Once the old parts are gone from the program, we can eliminate this code too. */ sp = GetSetupPar((UBYTE *)"functionlevels"); AM.maxFlevels = sp->value + 1; #ifdef WITHPTHREADS #else AT.Nest = (NESTING)Malloc1((LONG)sizeof(struct NeStInG)*AM.maxFlevels,"functionlevels"); AT.NestStop = AT.Nest + AM.maxFlevels; AT.NestPoin = AT.Nest; #endif sp = GetSetupPar((UBYTE *)"maxwildcards"); AM.MaxWildcards = sp->value; #ifdef WITHPTHREADS #else AT.WildMask = (WORD *)Malloc1((LONG)AM.MaxWildcards*sizeof(WORD),"maxwildcards"); #endif sp = GetSetupPar((UBYTE *)"compresssize"); if ( sp->value < 2*AM.MaxTer ) sp->value = 2*AM.MaxTer; AM.CompressSize = sp->value; #ifndef WITHPTHREADS AR.CompressBuffer = (WORD *)Malloc1((AM.CompressSize+10)*sizeof(WORD),"compresssize"); AR.CompressPointer = AR.CompressBuffer; AR.ComprTop = AR.CompressBuffer + AM.CompressSize; #endif sp = GetSetupPar((UBYTE *)"bracketindexsize"); if ( sp->value < 20*AM.MaxTer ) sp->value = 20*AM.MaxTer; AM.MaxBracketBufferSize = sp->value/sizeof(WORD); sp = GetSetupPar((UBYTE *)"dotchar"); AO.FortDotChar = ((UBYTE *)(sp->value))[0]; sp = GetSetupPar((UBYTE *)"commentchar"); AP.cComChar = AP.ComChar = ((UBYTE *)(sp->value))[0]; sp = GetSetupPar((UBYTE *)"procedureextension"); /* Check validity first. */ s = (UBYTE *)(sp->value); if ( FG.cTable[*s] != 0 ) { MesPrint(" Illegal string for procedure extension %s",(UBYTE *)sp->value); error = -2; } else { s++; while ( *s ) { if ( *s == ' ' || *s == '\t' || *s == '\n' ) { MesPrint(" Illegal string for procedure extension %s",(UBYTE *)sp->value); error = -2; break; } s++; } } AP.cprocedureExtension = strDup1((UBYTE *)(sp->value),"procedureExtension"); AP.procedureExtension = strDup1(AP.cprocedureExtension,"procedureExtension"); sp = GetSetupPar((UBYTE *)"totalsize"); if ( sp->value != 2 ) AM.PrintTotalSize = sp->value; sp = GetSetupPar((UBYTE *)"continuationlines"); AM.FortranCont = sp->value; if ( AM.FortranCont <= 0 ) AM.FortranCont = 1; sp = GetSetupPar((UBYTE *)"oldorder"); AM.OldOrderFlag = sp->value; sp = GetSetupPar((UBYTE *)"resettimeonclear"); AM.resetTimeOnClear = sp->value; sp = GetSetupPar((UBYTE *)"nospacesinnumbers"); AO.NoSpacesInNumbers = AM.gNoSpacesInNumbers = AM.ggNoSpacesInNumbers = sp->value; sp = GetSetupPar((UBYTE *)"indentspace"); AO.IndentSpace = AM.gIndentSpace = AM.ggIndentSpace = sp->value; sp = GetSetupPar((UBYTE *)"nwritestatistics"); AC.StatsFlag = AM.gStatsFlag = AM.ggStatsFlag = 1-sp->value; sp = GetSetupPar((UBYTE *)"nwritefinalstatistics"); AC.FinalStats = AM.gFinalStats = AM.ggFinalStats = 1-sp->value; sp = GetSetupPar((UBYTE *)"nwritethreadstatistics"); AC.ThreadStats = AM.gThreadStats = AM.ggThreadStats = 1-sp->value; sp = GetSetupPar((UBYTE *)"nwriteprocessstatistics"); AC.ProcessStats = AM.gProcessStats = AM.ggProcessStats = 1-sp->value; sp = GetSetupPar((UBYTE *)"oldparallelstatistics"); AC.OldParallelStats = AM.gOldParallelStats = AM.ggOldParallelStats = sp->value; sp = GetSetupPar((UBYTE *)"oldfactarg"); AC.OldFactArgFlag = AM.gOldFactArgFlag = AM.ggOldFactArgFlag = sp->value; sp = GetSetupPar((UBYTE *)"oldgcd"); AC.OldGCDflag = AM.gOldGCDflag = AM.ggOldGCDflag = sp->value; sp = GetSetupPar((UBYTE *)"wtimestats"); if ( sp->value == 2 ) sp->value = AM.ggWTimeStatsFlag; AC.WTimeStatsFlag = AM.gWTimeStatsFlag = AM.ggWTimeStatsFlag = sp->value; sp = GetSetupPar((UBYTE *)"sorttype"); if ( StrICmp((UBYTE *)"lowfirst",(UBYTE *)sp->value) == 0 ) { AC.lSortType = SORTLOWFIRST; } else if ( StrICmp((UBYTE *)"highfirst",(UBYTE *)sp->value) == 0 ) { AC.lSortType = SORTHIGHFIRST; } else { MesPrint(" Illegal SortType specification: %s",(UBYTE *)sp->value); error = -2; } sp = GetSetupPar((UBYTE *)"processbucketsize"); AM.hProcessBucketSize = AM.gProcessBucketSize = AC.ProcessBucketSize = AC.mProcessBucketSize = sp->value; /* The store caches (code installed 15-aug-2006 JV) */ sp = GetSetupPar((UBYTE *)"numstorecaches"); AM.NumStoreCaches = sp->value; sp = GetSetupPar((UBYTE *)"sizestorecache"); AM.SizeStoreCache = sp->value; #ifndef WITHPTHREADS /* Install the store caches (15-aug-2006 JV) Note that in the case of PTHREADS this is done in InitializeOneThread */ AT.StoreCache = AT.StoreCacheAlloc = 0; if ( AM.NumStoreCaches > 0 ) { STORECACHE sa, sb; size = sizeof(struct StOrEcAcHe)+AM.SizeStoreCache; size = ((size-1)/sizeof(size_t)+1)*sizeof(size_t); AT.StoreCacheAlloc = (STORECACHE)Malloc1(size*AM.NumStoreCaches,"StoreCaches"); AT.StoreCache = AT.StoreCacheAlloc; sa = AT.StoreCache; for ( j = 0; j < AM.NumStoreCaches; j++ ) { sb = (STORECACHE)(VOID *)((UBYTE *)sa+size); if ( j == AM.NumStoreCaches-1 ) { sa->next = 0; } else { sa->next = sb; } SETBASEPOSITION(sa->position,-1); SETBASEPOSITION(sa->toppos,-1); sa = sb; } } #endif /* And now some order sensitive things */ if ( AM.Path == 0 ) { sp = GetSetupPar((UBYTE *)"path"); AM.Path = strDup1((UBYTE *)(sp->value),"path"); } if ( AM.IncDir == 0 ) { sp = GetSetupPar((UBYTE *)"incdir"); AM.IncDir = strDup1((UBYTE *)(sp->value),"incdir"); } /* if ( AM.TempDir == 0 ) { sp = GetSetupPar((UBYTE *)"tempdir"); AM.TempDir = strDup1((UBYTE *)(sp->value),"tempdir"); } */ return(error); }
int CChars::CompareIgnoreCase(CChars* szOther) { return StrICmp(Text(), szOther->Text()); }
int ProcessOption(UBYTE *s1, UBYTE *s2, int filetype) { SETUPPARAMETERS *sp; int n, giveback = 0, error = 0; UBYTE *s, *t, *s2ret; LONG x; sp = GetSetupPar(s1); if ( sp ) { /* We check now whether there are `' variables to be looked up in the environment. This is new (30-may-2008). This is only allowed in s2. */ restart:; { UBYTE *s3,*s4,*s5,*s6, c, *start; int n1,n2,n3; s = s2; while ( *s ) { if ( *s == '\\' ) s += 2; else if ( *s == '`' ) { start = s; s++; while ( *s && *s != '\'' ) { if ( *s == '\\' ) s++; s++; } if ( *s == 0 ) { MesPrint("%s: Illegal use of ` character for parameter %s" ,proop1[filetype],s1); return(1); } c = *s; *s = 0; s3 = (UBYTE *)getenv((char *)(start+1)); if ( s3 == 0 ) { MesPrint("%s: Cannot find environment variable %s for parameter %s" ,proop1[filetype],start+1,s1); return(1); } *s = c; s++; n1 = start - s2; s4 = s3; n2 = 0; while ( *s4 ) { if ( *s4 == '\\' ) { s4++; n2++; } s4++; n2++; } s4 = s; n3 = 0; while ( *s4 ) { if ( *s4 == '\\' ) { s4++; n3++; } s4++; n3++; } s4 = (UBYTE *)Malloc1((n1+n2+n3+1)*sizeof(UBYTE),"environment in setup"); s5 = s2; s6 = s4; while ( n1-- > 0 ) *s6++ = *s5++; s5 = s3; while ( n2-- > 0 ) *s6++ = *s5++; s5 = s; while ( n3-- > 0 ) *s6++ = *s5++; *s6 = 0; if ( giveback ) M_free(s2,"environment in setup"); s2 = s4; giveback = 1; goto restart; } else s++; } } n = sp->type; s2ret = s2; switch ( n ) { case NUMERICALVALUE: ParseNumber(x,s2); if ( *s2 == 'K' ) { x = x * 1000; s2++; } else if ( *s2 == 'M' ) { x = x * 1000000; s2++; } else if ( *s2 == 'G' ) { x = x * 1000000000; s2++; } else if ( *s2 == 'T' ) { x = x * 1000000000000; s2++; } if ( *s2 && *s2 != ' ' && *s2 != '\t' ) { MesPrint("%s: Numerical value expected for parameter %s" ,proop1[filetype],s1); error = 1; break; } sp->value = x; sp->flags = USEDFLAG; break; case STRINGVALUE: if ( StrICmp(s1,(UBYTE *)"tempsortdir") == 0 ) AM.havesortdir = 1; s = s2; t = s2; while ( *s ) { if ( *s == ' ' || *s == '\t' ) break; if ( *s == '\\' ) s++; *t++ = *s++; } *t = 0; if ( sp->flags == USEDFLAG && sp->value != 0 ) M_free((VOID *)(sp->value),"Process option"); sp->value = (LONG)strDup1(s2,"Process option"); sp->flags = USEDFLAG; break; case PATHVALUE: if ( StrICmp(s1,(UBYTE *)"incdir") == 0 ) { AM.IncDir = 0; } else if ( StrICmp(s1,(UBYTE *)"path") == 0 ) { if ( AM.Path ) M_free(AM.Path,"path"); AM.Path = 0; } else { MesPrint("Setups: %s not yet implemented",s1); error = 1; break; } if ( sp->flags == USEDFLAG && sp->value != 0 ) M_free((VOID *)(sp->value),"Process option"); sp->value = (LONG)strDup1(s2,"Process option"); sp->flags = USEDFLAG; break; case ONOFFVALUE: if ( tolower(*s2) == 'o' && tolower(s2[1]) == 'n' && ( s2[2] == 0 || s2[2] == ' ' || s2[2] == '\t' ) ) sp->value = 1; else if ( tolower(*s2) == 'o' && tolower(s2[1]) == 'f' && tolower(s2[2]) == 'f' && ( s2[3] == 0 || s2[3] == ' ' || s2[3] == '\t' ) ) sp->value = 0; else { MesPrint("%s: Unrecognized option for parameter %s: %s" ,proop1[filetype],s1,s2); error = 1; break; } sp->flags = USEDFLAG; break; case DEFINEVALUE: /* if ( sp->value ) M_free((UBYTE *)(sp->value),"Process option"); sp->value = (LONG)strDup1(s2,"Process option"); */ if ( TheDefine(s2,2) ) error = 1; break; default: Error1("Error in setupparameter table for:",s1); error = 1; break; } } else { MesPrint("%s: Keyword not recognized: %s",proop1[filetype],s1); error = 1; } if ( giveback ) M_free(s2ret,"environment in setup"); return(error); }
void handle_request_NOTIFY(CLIENT_t *ptC, CONN_SESSION *ptSession) { CONN_SESSION *ptResp; BYTE *pbMsg; do { // each NOTIFY message will be considered to KEEP-ALIVE message. ptC->n32TimeGotKA = time( (time_t *)NULL ); // if state already inactive | x | x ..., then we need resume media plane. if (ptC->eState == eCLIENT_STATE_INACTIVE) { ptC->eState = eCLIENT_STATE_CONNECTED; // resume media plane sdp_process_type_t eClientType = (ptC == &patClient[0]) ? SDP_F : SDP_C; data_plane_suspend(eClientType, ptC->tMedia, SUSPEND_OFF); } // keep-alive NOTIFY. simply break-out. if (0 == ptSession->bMap[EVENT_SEQ_NUM]) { break; } BYTE *pbEvName = &ptSession->tEvent.bName[0]; BYTE *pbEvParams = NULL; // get name & params { BYTE bLocation = 0; while(pbEvName[bLocation] != '\0') { bLocation++; if (pbEvName[bLocation] == ' ') { pbEvName[bLocation++] = '\0'; pbEvParams = &pbEvName[bLocation]; break; } } } // client request for self-state //if (StrICmp(ptSession->tEvent.bName, (BYTE *)"logon-state")) { if (StrICmp(pbEvName, (BYTE *)"logon-state")) { BYTE *pbMsg = &ptSession->bBody[0]; WriteString(&pbMsg, (BYTE *)"State: ", MAX_BODY_LTH); WriteString(&pbMsg, abClientState[ptC->eState], MAX_BODY_LTH); //&pbMsg++ = '\0'; ptSession->wBdyLth = pbMsg - &ptSession->bBody[0]; break; } // F request for C-list //else if (StrICmp(ptSession->tEvent.bName, (BYTE *)"listener-list")) { else if (StrICmp(pbEvName, (BYTE *)"listener-list")) { BYTE *pbMsg = &ptSession->bBody[0]; BYTE i; BYTE bString[COMMEN_LTH]; if (ptC != &patClient[0]) { /* requirement update: C CAN request F'state, F CAN request C state-list. */ WriteString(&pbMsg, (BYTE *)"1:", COMMEN_LTH); WriteString(&pbMsg, (BYTE *)&patClient[0].aName[0], USER_LTH); if ('\0' != patClient[0].aID[0]) { WriteString(&pbMsg, (BYTE *)"<", 2); WriteString(&pbMsg, (BYTE *)&patClient[0].aID[0], USER_LTH); WriteString(&pbMsg, (BYTE *)">", 2); } *pbMsg++ = ':'; WriteString(&pbMsg, (BYTE *)inet_ntoa( *((struct in_addr *)&patClient[0].tAddrRemoteSignal.ip_addr) ), HOST_NAME_LTH); *pbMsg++ = '\r'; *pbMsg++ = '\n'; ptSession->wBdyLth = pbMsg - &ptSession->bBody[0]; break; } // Now, F request C-list. if (!pbEvParams) { // only get total number BYTE bCnt = 0; for (i=1; i<MAX_CONNECT_CLIENT; i++) { if (patClient[i].eState == eCLIENT_STATE_NONE) { continue; } bCnt++; } // format as: // Total: xx WriteString(&pbMsg, (BYTE *)"Total: ", 8); sprintf((char*)bString, "%d", bCnt); WriteString(&pbMsg, &bString[0], COMMEN_LTH); *pbMsg++ = '\r'; *pbMsg++ = '\n'; } else { // get No.x detail info BYTE bIndex = atoi((const char*)pbEvParams); if ( (bIndex < 1) || (bIndex >= MAX_CONNECT_CLIENT)) { bIndex = 1; // No.0 is F self. } BYTE bCnt = 0; BOOL8 blFound = FALSE_B8; for (i=1; i<MAX_CONNECT_CLIENT; i++) { if (patClient[i].eState == eCLIENT_STATE_NONE) { continue; } if (++bCnt < bIndex) { continue; } // found blFound = TRUE_B8; break; } if (blFound) { // format as: "slot-No.:Name<ID>:IP" // OR: format as: "index-No.:Name<ID>:IP" sprintf((char*)bString, "%d", i); WriteString(&pbMsg, &bString[0], COMMEN_LTH); *pbMsg++ = ':'; WriteString(&pbMsg, (BYTE *)&patClient[i].aName[0], USER_LTH); if ('\0' != patClient[i].aID[0]) { WriteString(&pbMsg, (BYTE *)"<", 2); WriteString(&pbMsg, (BYTE *)&patClient[i].aID[0], USER_LTH); WriteString(&pbMsg, (BYTE *)">", 2); } *pbMsg++ = ':'; WriteString(&pbMsg, (BYTE *)inet_ntoa( *((struct in_addr *)&patClient[i].tAddrRemoteSignal.ip_addr) ), HOST_NAME_LTH); *pbMsg++ = '\r'; *pbMsg++ = '\n'; } else { // index error, return sendMgrResponse(&ptC->tAddrRemoteSignal, ptSession, 400, reinterpret_cast<const unsigned char *>("Index not found.")); return; } } ptSession->wBdyLth = pbMsg - &ptSession->bBody[0]; break; } else { // NOT supported event. sendMgrResponse(&ptC->tAddrRemoteSignal, ptSession, 400, reinterpret_cast<const unsigned char *>("Unknown event type.")); return; } } while(0); // send out response ptResp = ptSession; memset(&ptResp->bMap[0], 0, sizeof(ptResp->bMap)); ptResp->bMap[CALLID_SEQ_NUM] = 1; ptResp->bMap[CSEQ_SEQ_NUM] = 1; // content-length: Automatic done. // // send response to peer. sendResponse(&ptC->tAddrRemoteSignal, ptResp, 200, reinterpret_cast<const unsigned char *>("OK")); return; }
int CChars::CompareIgnoreCase(const char* szOther) { return StrICmp(Text(), szOther); }