Vec3f ConfigurationManager::find_config_as_point(string key) { vector<string> chunk; string point = find_config_as_string(key); split(point, ',', chunk); assert(chunk.size() == 3 && "Config Error: Points are represented as <floatx> , <floaty> , <floatz>. Spaces will ignored."); string x = chunk[0], y = chunk[1], z = chunk[2]; stripSpaces(x); stripSpaces(y); stripSpaces(z); float fx = (float)atof(x.c_str()), fy = (float)atof(y.c_str()), fz = (float)atof(z.c_str()); return Vec3f(fx, fy, fz); }
//------------------------------------------------------------------------------ // queryRunwayBySubkey() -- find runway record(s) by the key/subkey //------------------------------------------------------------------------------ int AirportLoader::queryRunwayBySubkey(const char* subkey) { // truncate to length of runway key char rwKey[RW_KEY_LEN+1]; lcStrncpy(rwKey,RW_KEY_LEN+1,subkey,RW_KEY_LEN); rwKey[RW_KEY_LEN] = '\0'; stripSpaces(rwKey,RW_KEY_LEN); // Use queryByKey() find the airport queryByKey(rwKey); // keep a pointer to the airport AirportKey* apk = 0; if (nql == 1) apk = static_cast<AirportKey*>(ql[0]); // find all runways that have matching keys nql = 0; if (apk != 0) { int len = static_cast<int>(strlen(rwKey)); for (RunwayKey* rwk = apk->runways; rwk != 0; rwk = rwk->next) { if (strncmp(rwk->key,rwKey,len) == 0) ql[nql++] = rwk; } } // limit number of result records if (qlimit > 0 && nql > qlimit) nql = qlimit; return nql; }
// Takes an input file stream as the input // and and generates a vector of predicates from each the input // and return the vector of predicates vector<Predicate*> Utilities::generatePredicates(ifstream& aInput) { vector<string> stringPredicates; vector<Predicate*> result; string input; getline(aInput, input, '\n'); if(input=="TELL") { getline(aInput, input, '\n'); stringPredicates = splice(input, ';'); } for (int i = 0; i < stringPredicates.size(); i++) { stringPredicates[i] = stripSpaces(stringPredicates[i]); } for (int i = 0; i < stringPredicates.size(); i++) { result.push_back(stringToCompoundPredicates(stringPredicates[i])); } return result; }
static vector<Token> addTokens() { char buf[255]; string line = fgets(buf, 255, stdin); line = stripSpaces(line); SourcePtr source = new Source(line, 0); vector<Token> tokens; tokenize(source, 0, line.length(), tokens); return tokens; }
static void prtOneInstance(char *resName, struct lsbSharedResourceInstance *instance) { #define ONE_LINE 80 int i, len, currentPos = 52; char space52[] = " "; printf ("%-20s%10s%15s ", resName, stripSpaces(instance->totalValue), stripSpaces(instance->rsvValue)); for (i = 0; i < instance->nHosts; i++) { len = strlen(instance->hostList[i]); currentPos = currentPos + len + 1; if (currentPos > ONE_LINE) { printf ("\n%s", space52); currentPos = 52 + len + 1; } printf ("%s ", instance->hostList[i]); } printf("\n"); }
// Initializes the Configuration Manager. Parses the file and stores data. void ConfigurationManager::initializefile(char * filepath) { ifstream conf(filepath, ios::in); string line; int x = 0; vector<string> chunk; if(conf.is_open()) { // cout << "Begin Configuration File Parsing..." << endl; while(conf.good()) { getline(conf,line); if(!(line.length() < 2) && !(line.at(0) == '#')) { // cout << "Parsing line: " << line << endl; chunk.clear(); split(line, '=', chunk); // cout << "Number of Chunks: " << chunk.size() << endl; // Assert. If the configuration file fails, it should fail hard. printf("Chunk size = %d, len = %d (%s)\n", chunk.size(), line.length(), line.c_str()); assert(chunk.size() == 2 && "Config file must have 1 key=value pair per line. All spaces are ignored. Comment with leading # symbol(no spaces before #)."); string key = chunk[0]; string value = chunk[1]; // cout << "Line split by = 1) " << key << " with length :" << key.length() << endl; // cout << "Line split by = 2) " << value << " with length :" << value.length() << endl; stripSpaces(key); stripSpaces(value); // cout << "Line split, trimmed, and stored 1) " << key << " with length : " << key.length() << endl; // cout << "Line split, trimmed, and stored 2) " << value << " with length : " << value.length() << endl; memcpy(&(keytable[x][0]), key.c_str(), key.size()); memcpy(&(valuetable[x][0]), value.c_str(), value.size()); keylen[x] = key.size(); valuelen[x] = value.size(); printf(__FILE__" %d: (k,v) = (%s,%s)\n", __LINE__, &(keytable[x][0]), &(valuetable[x][0])); x++; } } conf.close(); } }
static void interactiveLoop() { setjmp(recovery); string line; while(true) { llvm::errs().flush(); llvm::errs() << "clay>"; char buf[255]; line = fgets(buf, 255, stdin); line = stripSpaces(line); if (line[0] == ':') { replCommand(line.substr(1, line.size() - 1)); } else { eval(line); } } engine->runStaticConstructorsDestructors(true); }
static void interactiveLoop() { setjmp(recovery); linenoiseSetMultiLine(1); linenoiseHistorySetMaxLen(100); char *buf; while ((buf = linenoise("clay> ")) != NULL) { linenoiseHistoryAdd(buf); string line = stripSpaces(buf); if (line[0] == ':') { replCommand(line.substr(1, line.size() - 1)); } else { eval(line); } free(buf); } engine->runStaticConstructorsDestructors(true); }
//------------------------------------------------------------------------------ // findGlideSlope() -- find matching glideslope record //------------------------------------------------------------------------------ void AirportLoader::findGlideSlope(const RunwayKey* rwk, const IlsKey* lk) { // get the runway key without component type int locKeyLen = ILS_KEY_LEN - 1; char locKey[ILS_KEY_LEN]; lcStrncpy(locKey,ILS_KEY_LEN,lk->key,locKeyLen); locKey[locKeyLen] = '\0'; stripSpaces(locKey,locKeyLen); // find glide slope record that matches the localizer key for (IlsKey* ilsk = rwk->ils; ilsk != 0; ilsk = ilsk->next) { if (ilsk->type == Ils::GLIDESLOPE) { if (strncmp(locKey,ilsk->key,locKeyLen) == 0) { ql[nql++] = ilsk; } } } }
void DTD::parseDTDEntity(QString line) { QString name; QString *value; line.replace("\\end", " "); name = line.mid(11); int firstSpace = name.find(' '); name = name.remove(firstSpace, name.length()-firstSpace); value = new QString(line.mid(11+firstSpace)); value->remove(0, value->find("\"")+1); value->remove(value->findRev("\""), value->length()); parseDTDReplace(value); stripSpaces(value); entities.insert(name, value); //kdDebug() << "Entity --- Name: " << name << " --- Value: " << *value << endl; }
Box ConfigurationManager::find_config_as_box(string key) { vector<string> chunk; string box = find_config_as_string(key); split(box, ',', chunk); assert(chunk.size() == 6 && "Config Error: Points are represented as <floatx> , <floaty> , <floatz> , <floatw> , <floath> , <floatl>. Spaces will ignored."); string x = chunk[0], y = chunk[1], z = chunk[2], w = chunk[3], h = chunk[4], l = chunk[5]; stripSpaces(x); stripSpaces(y); stripSpaces(z); stripSpaces(w); stripSpaces(h); stripSpaces(l); float fx = (float)atof(x.c_str()), fy = (float)atof(y.c_str()), fz = (float)atof(z.c_str()), fw = (float)atof(w.c_str()), fh = (float)atof(h.c_str()), fl = (float)atof(l.c_str()); return Box(fx, fy, fz, fw, fh, fl); }
//------------------------------------------------------------------------------ // queryRunwayByIdent() -- find runway record by its identifier (airport_id + // runway end identifier). Therefore, each runway records will respond to two // identifiers: airport_id + high_end_id and airport_id + low_end_id. //------------------------------------------------------------------------------ int AirportLoader::queryRunwayByIdent(const char* id) { // Use queryByKey() find the airport queryByKey(id); // keep a pointer to the airport AirportKey* apk = 0; if (nql == 1) apk = static_cast<AirportKey*>(ql[0]); // find the runway that matches the identifier nql = 0; if (apk != 0) { char rwId[RW_XE_IDENT_LEN+1]; lcStrncpy(rwId,RW_XE_IDENT_LEN+1,&id[AP_KEY_LEN],RW_XE_IDENT_LEN); rwId[RW_XE_IDENT_LEN] = '\0'; fillSpaces(rwId,RW_XE_IDENT_LEN); char rwId2[RW_XE_IDENT_LEN+1]; lcStrncpy(rwId2,RW_XE_IDENT_LEN+1,&id[AP_KEY_LEN],RW_XE_IDENT_LEN); rwId2[RW_XE_IDENT_LEN] = '\0'; stripSpaces(rwId2,RW_XE_IDENT_LEN); for (RunwayKey* rwk = apk->runways; rwk != 0; rwk = rwk->next) { if ( (strncmp( &rwk->key[AP_KEY_LEN], rwId, RW_XE_IDENT_LEN ) == 0) || (strncmp( &rwk->key[AP_KEY_LEN+RW_XE_IDENT_LEN], rwId2, RW_XE_IDENT_LEN ) == 0) ) { ql[nql++] = rwk; } } } // limit number of result records if (qlimit > 0 && nql > qlimit) nql = qlimit; return nql; }
static int makeShareFields(char *hostname, struct lsInfo *lsInfo, char ***nameTable, char ***totalValues, char ***rsvValues, char ***formatTable) { static int first = TRUE; static struct lsbSharedResourceInfo *resourceInfo; static char **namTable; static char **totalTable; static char **rsvTable; static char **fmtTable; static int numRes, nRes; int k, i, j; char *hPtr; int ii, numHosts, found; if (first == TRUE) { TIMEIT(0, (resourceInfo = lsb_sharedresourceinfo (NULL, &numRes, NULL, 0)), "ls_sharedresourceinfo"); if (resourceInfo == NULL) { return (-1); } if ((namTable = (char **) malloc (numRes * sizeof(char *))) == NULL){ lserrno = LSE_MALLOC; return (-1); } if ((totalTable = (char **) malloc (numRes * sizeof(char *))) == NULL){ lserrno = LSE_MALLOC; return (-1); } if ((rsvTable = (char **) malloc (numRes * sizeof(char *))) == NULL){ lserrno = LSE_MALLOC; return (-1); } if ((fmtTable = (char **) malloc (numRes * sizeof(char *))) == NULL){ lserrno = LSE_MALLOC; return (-1); } first = FALSE; } else { for (i = 0; i < nRes; i++) { FREEUP(fmtTable[i]); } } nRes = 0; for (k = 0; k < numRes; k++) { found = FALSE; for (j = 0; j < lsInfo->nRes; j++) { if (strcmp(lsInfo->resTable[j].name, resourceInfo[k].resourceName) == 0) { if ((lsInfo->resTable[j].flags & RESF_SHARED) && (lsInfo->resTable[j].valueType & LS_NUMERIC)) { found = TRUE; break; } break; } } if (!found) { continue; } namTable[nRes] = resourceInfo[k].resourceName; found = FALSE; for (i = 0; i < resourceInfo[k].nInstances; i++) { numHosts = resourceInfo[k].instances[i].nHosts; for (ii = 0; ii < numHosts; ii++) { hPtr = resourceInfo[k].instances[i].hostList[ii]; if (strcmp(hPtr, hostname) == 0) { totalTable[nRes] = resourceInfo[k].instances[i].totalValue; rsvTable[nRes] = resourceInfo[k].instances[i].rsvValue; found = TRUE; break; } } if (found == TRUE) { break; } } if (found == FALSE) { totalTable[nRes] = "-"; rsvTable[nRes] = "-"; } nRes++; } if (nRes) { j = 0; for (i = 0; i < nRes; i++) { char fmt[16]; int lens, tmplens; lens = strlen( namTable[i] ); tmplens = strlen( stripSpaces(totalTable[i]) ); if( lens < tmplens ) lens = tmplens; tmplens = strlen( stripSpaces(rsvTable[i]) ); if( lens < tmplens ) lens = tmplens; sprintf(fmt, "%s%ld%s", "%", (long)(lens + 1), "s"); fmtTable[j++] = putstr_(fmt); } } *nameTable = namTable; *totalValues = totalTable; *rsvValues = rsvTable; *formatTable = fmtTable; return (nRes); }
static int makeFields(struct hostInfoEnt *host, char *loadval[], char **dispindex, int option) { int j, id, nf, index; char *sp; char tmpfield[MAXFIELDSIZE]; char fmtField[MAXFIELDSIZE]; char firstFmt[MAXFIELDSIZE]; float real, avail, load; nf = 0; for(j=0; dispindex[j] && j < host->nIdx; j++, nf++) { int newIndexLen; id = nameToFmt(dispindex[j]); if (id == DEFAULT_FMT) newIndexLen = strlen(dispindex[j]); real = getLoad(dispindex[j], host->realLoad, &index); avail = getLoad(dispindex[j], host->load, &index); if (option == TRUE) load = avail; else { real = getLoad(dispindex[j], host->realLoad, &index); load = (avail >= real)? (avail - real):(real - avail); } if (load >= INFINIT_LOAD) sp = "- "; else { if (option == TRUE && (host->hStatus & HOST_STAT_BUSY) && (LSB_ISBUSYON (host->busySched, index) || LSB_ISBUSYON (host->busyStop, index))) { strcpy(firstFmt, fmt[id].busy); sprintf(fmtField, "%s%s",firstFmt, fmt[id].normFmt); sprintf(tmpfield, fmtField, load * fmt[id].scale); } else { strcpy(firstFmt, fmt[id].ok); sprintf(fmtField, "%s%s", firstFmt, fmt[id].normFmt); sprintf(tmpfield, fmtField, load * fmt[id].scale); } sp = stripSpaces(tmpfield); if (strlen(sp) > fmt[id].dispLen) { if (load > 1024) sprintf(fmtField, "%s%s", firstFmt, fmt[id].expFmt); else sprintf(fmtField, "%s%s", firstFmt, fmt[id].normFmt); if ((load > 1024) && ((!strcmp(fmt[id].name,"mem")) || (!strcmp(fmt[id].name,"tmp")) || (!strcmp(fmt[id].name,"swp")))) sprintf(tmpfield,fmtField,(load*fmt[id].scale)/1024); else sprintf(tmpfield,fmtField, (load * fmt[id].scale)); } sp = stripSpaces(tmpfield); } if (id == DEFAULT_FMT && newIndexLen >= 7){ char newFmt[10]; sprintf(newFmt, " %s%d%s", "%", newIndexLen, "s"); sprintf(loadval[j], newFmt, sp); } else sprintf(loadval[j], fmt[id].hdr, sp); } return(nf); }
/** stripString: strips spaces and the new line characters * from a string * @param c - String to strip */ void stripString(char * c) { stripSpaces(c); stripEndSpace(c); }
ai::UnicodeString createNameFromInput() { char enterNum[30] = ""; //This will hold what the user enters in the box //char fullColorName[256] = ""; //This will hold the full color name in the form "PANTONE #### U" //Get the number from the text box and store in enterNum sADMItem->GetText(ghEditTextItemRef, enterNum, 30); bool isAllNumbers = TRUE; //Make it all lowercase for (int i=0; i<30; i++) { if ( enterNum[i] == '\0' ) { break; } if ( isalpha(enterNum[i]) ) { enterNum[i] = tolower(enterNum[i]); } } //Strip out any spaces stripSpaces(enterNum); //Check each character in the string to see if its all numbers for (int i=0; i<30; i++) { if ( enterNum[i] == '\0' ) { break; } if ( isAllNumbers) { if ( !isdigit(enterNum[i]) ) { isAllNumbers = FALSE; } } } if ( isAllNumbers ) { //If its all numbers, then we have to check for a few special colors if ( strcmp(enterNum, "12") == 0 || strcmp(enterNum, "012") == 0 ) { return makeColorName("Yellow 012"); } if ( strcmp(enterNum, "21") == 0 || strcmp(enterNum, "021") == 0 ) { return makeColorName("Orange 021"); } if ( strcmp(enterNum, "32") == 0 || strcmp(enterNum, "032") == 0 ) { return makeColorName("Red 032"); } if ( strcmp(enterNum, "72") == 0 || strcmp(enterNum, "072") == 0 ) { return makeColorName("Blue 072"); } //If the number is between 100 and 8321 we can probably use it how it is and just make sure its a valid color if ( atoi(enterNum) >= 100 && atoi(enterNum) <= 8312) { return makeColorName(enterNum); } } else { //If theres characters there, we have to determine which color it is if ( strcmp(enterNum, "black") == 0 || strcmp(enterNum, "k") == 0 || strcmp(enterNum, "blk") == 0 ) { return makeColorName("Black"); } if ( strcmp(enterNum, "cg1") == 0 || strcmp(enterNum, "coolgray1") == 0 ) { return makeColorName("Cool Gray 1"); } if ( strcmp(enterNum, "cg2") == 0 || strcmp(enterNum, "coolgray2") == 0 ) { return makeColorName("Cool Gray 2"); } if ( strcmp(enterNum, "cg3") == 0 || strcmp(enterNum, "coolgray3") == 0 ) { return makeColorName("Cool Gray 3"); } if ( strcmp(enterNum, "cg4") == 0 || strcmp(enterNum, "coolgray4") == 0 ) { return makeColorName("Cool Gray 4"); } if ( strcmp(enterNum, "cg5") == 0 || strcmp(enterNum, "coolgray5") == 0 ) { return makeColorName("Cool Gray 5"); } if ( strcmp(enterNum, "cg6") == 0 || strcmp(enterNum, "coolgray6") == 0 ) { return makeColorName("Cool Gray 6"); } if ( strcmp(enterNum, "cg7") == 0 || strcmp(enterNum, "coolgray7") == 0 ) { return makeColorName("Cool Gray 7"); } if ( strcmp(enterNum, "cg8") == 0 || strcmp(enterNum, "coolgray8") == 0 ) { return makeColorName("Cool Gray 8"); } if ( strcmp(enterNum, "cg9") == 0 || strcmp(enterNum, "coolgray9") == 0 ) { return makeColorName("Cool Gray 9"); } if ( strcmp(enterNum, "cg10") == 0 || strcmp(enterNum, "coolgray10") == 0 ) { return makeColorName("Cool Gray 10"); } if ( strcmp(enterNum, "cg11") == 0 || strcmp(enterNum, "coolgray11") == 0 ) { return makeColorName("Cool Gray 11"); } if ( strcmp(enterNum, "green") == 0 || strcmp(enterNum, "grn") == 0 ) { return makeColorName("Green"); } if ( strcmp(enterNum, "orange") == 0 || strcmp(enterNum, "org") == 0 ) { return makeColorName("Orange 021"); } if ( strcmp(enterNum, "processblack") == 0 || strcmp(enterNum, "pbk") == 0 || strcmp(enterNum, "procblack") == 0) { return makeColorName("Process Black"); } if ( strcmp(enterNum, "processblue") == 0 || strcmp(enterNum, "pbl") == 0 || strcmp(enterNum, "procblue") == 0 ) { return makeColorName("Process Blue"); } if ( strcmp(enterNum, "processcyan") == 0 || strcmp(enterNum, "pc") == 0 || strcmp(enterNum, "proccyan") == 0 ) { return makeColorName("Process Cyan"); } if ( strcmp(enterNum, "processmagenta") == 0 || strcmp(enterNum, "pm") == 0 || strcmp(enterNum, "procmag") == 0) { return makeColorName("Process Magenta"); } if ( strcmp(enterNum, "processyellow") == 0 || strcmp(enterNum, "py") == 0 || strcmp(enterNum, "procyel") == 0 ) { return makeColorName("Process Yellow"); } if ( strcmp(enterNum, "purple") == 0 || strcmp(enterNum, "pur") == 0 ) { return makeColorName("Purple"); } if ( strcmp(enterNum, "reflexblue") == 0 || strcmp(enterNum, "rbl") == 0 || strcmp(enterNum, "refblue") == 0 || strcmp(enterNum, "reflex") == 0 || strcmp(enterNum, "ref") == 0 ) { return makeColorName("Reflex Blue"); } if ( strcmp(enterNum, "rhodamine") == 0 || strcmp(enterNum, "rho") == 0 ) { return makeColorName("Rhodamine Red"); } if ( strcmp(enterNum, "rubine") == 0 || strcmp(enterNum, "rub") == 0 ) { return makeColorName("Rubine Red"); } if ( strcmp(enterNum, "violet") == 0 || strcmp(enterNum, "vlt") == 0 ) { return makeColorName("Violet"); } if ( strcmp(enterNum, "wg1") == 0 || strcmp(enterNum, "warmgray1") == 0 ) { return makeColorName("Warm Gray 1"); } if ( strcmp(enterNum, "wg2") == 0 || strcmp(enterNum, "warmgray2") == 0 ) { return makeColorName("Warm Gray 2"); } if ( strcmp(enterNum, "wg3") == 0 || strcmp(enterNum, "warmgray3") == 0 ) { return makeColorName("Warm Gray 3"); } if ( strcmp(enterNum, "wg4") == 0 || strcmp(enterNum, "warmgray4") == 0 ) { return makeColorName("Warm Gray 4"); } if ( strcmp(enterNum, "wg5") == 0 || strcmp(enterNum, "warmgray5") == 0 ) { return makeColorName("Warm Gray 5"); } if ( strcmp(enterNum, "wg6") == 0 || strcmp(enterNum, "warmgray6") == 0 ) { return makeColorName("Warm Gray 6"); } if ( strcmp(enterNum, "wg7") == 0 || strcmp(enterNum, "warmgray7") == 0 ) { return makeColorName("Warm Gray 7"); } if ( strcmp(enterNum, "wg8") == 0 || strcmp(enterNum, "warmgray8") == 0 ) { return makeColorName("Warm Gray 8"); } if ( strcmp(enterNum, "wg9") == 0 || strcmp(enterNum, "warmgray9") == 0 ) { return makeColorName("Warm Gray 9"); } if ( strcmp(enterNum, "wg10") == 0 || strcmp(enterNum, "warmgray10") == 0 ) { return makeColorName("Warm Gray 10"); } if ( strcmp(enterNum, "wg11") == 0 || strcmp(enterNum, "warmgray11") == 0 ) { return makeColorName("Warm Gray 11"); } if ( strcmp(enterNum, "warmred") == 0 || strcmp(enterNum, "wred") == 0 ) { return makeColorName("Warm Red"); } if ( strcmp(enterNum, "yellow") == 0 || strcmp(enterNum, "yel") == 0 ) { return makeColorName("Yellow"); } if ( strcmp(enterNum, "thermo") == 0 ) { return makeColorName("1767"); } if ( strcmp(enterNum, "backer") == 0 ) { return makeColorName("431"); } //If they're asking for MICR ink we need to create Process Black and rename it if ( strcmp(enterNum, "magblack") == 0 || strcmp(enterNum, "micr") == 0 ) { return makeColorName("MICR"); } } return (ai::UnicodeString) "0"; }
static void print_long(struct hostInfo *hostInfo) { int i; float *li; char *sp; static char first = TRUE; static char line[132]; static char newFmt[10]; int newIndexLen, retVal; static char **indxnames; char **shareNames, **shareValues, **formats; char strbuf1[30],strbuf2[30],strbuf3[30]; if (first) { char tmpbuf[MAXLSFNAMELEN]; int fmtid; if(!(fmt=(struct indexFmt *) malloc((hostInfo->numIndx+2)*sizeof (struct indexFmt)))) { lserrno=LSE_MALLOC; ls_perror("print_long"); exit(-1); } for (i=0; i<NBUILTINDEX+2; i++) fmt[i]=fmt1[i]; TIMEIT(0, (indxnames = ls_indexnames(NULL)), "ls_indexnames"); if (indxnames == NULL) { ls_perror("ls_indexnames"); exit(-1); } for(i=0; indxnames[i]; i++) { if (i > MEM) fmtid = MEM + 1; else fmtid = i; if ((fmtid == MEM +1) && (newIndexLen = strlen(indxnames[i])) >= 7) { sprintf(newFmt, "%s%d%s", "%", newIndexLen+1, "s"); sprintf(tmpbuf, newFmt, indxnames[i]); } else sprintf(tmpbuf, fmt[fmtid].hdr, indxnames[i]); strcat(line, tmpbuf); } first = FALSE; } printf("\n%s: %s\n", _i18n_msg_get(ls_catd,NL_SETN, 1601, "HOST_NAME"), /* catgets 1601 */ hostInfo->hostName); { char *buf1, *buf2, *buf3, *buf4, *buf5, *buf6, *buf7, *buf8, *buf9, *buf10; buf1 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1602, "type")); /* catgets 1602 */ buf2 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1603, "model")); /* catgets 1603 */ buf3 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1604, "cpuf")); /* catgets 1604 */ buf4 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1605, "ncpus")); /* catgets 1605 */ buf5 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1606, "ndisks")); /* catgets 1606 */ buf6 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1607, "maxmem")); /* catgets 1607 */ buf7 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1608, "maxswp")); /* catgets 1608 */ buf8 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1609, "maxtmp")); /* catgets 1609 */ buf9 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1610, "rexpri")); /* catgets 1610 */ buf10= putstr_(_i18n_msg_get(ls_catd,NL_SETN,1611, "server")); /* catgets 1611 */ printf("%-10.10s %11.11s %5.5s %5.5s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s\n", buf1, buf2, buf3, buf4, buf5, buf6, buf7, buf8, buf9, buf10); FREEUP(buf1); FREEUP(buf2); FREEUP(buf3); FREEUP(buf4); FREEUP(buf5); FREEUP(buf6); FREEUP(buf7); FREEUP(buf8); FREEUP(buf9); FREEUP(buf10); } if (hostInfo->isServer) { sprintf(strbuf1,"%-10s",hostInfo->hostType);strbuf1[10]='\0'; sprintf(strbuf2,"%11s",hostInfo->hostModel);strbuf2[11]='\0'; sprintf(strbuf3,"%5.1f",hostInfo->cpuFactor);strbuf3[5]='\0'; printf("%-10s %11s %5s ",strbuf1,strbuf2,strbuf3); if (hostInfo->maxCpus > 0) printf("%5d %6d %5dM %5dM %5dM %6d %6s\n", hostInfo->maxCpus, hostInfo->nDisks, hostInfo->maxMem, hostInfo->maxSwap, hostInfo->maxTmp, hostInfo->rexPriority, I18N_Yes); else printf("%5s %6s %6s %6s %6s %6d %6s\n", "-", "-", "-", "-", "-", hostInfo->rexPriority, I18N_Yes); /* catgets 1612 */ } else { sprintf(strbuf1,"%-10s",hostInfo->hostType);strbuf1[10]='\0'; sprintf(strbuf2,"%11s",hostInfo->hostModel);strbuf2[11]='\0'; sprintf(strbuf3,"%5.1f",hostInfo->cpuFactor);strbuf3[5]='\0'; printf("%-10s %11s %5s ",strbuf1,strbuf2,strbuf3); printf("%5s %6s %6s %6s %6s %6s %6s\n", "-", "-", "-", "-", "-", "-", I18N_No); /* catgets 1613 */ } if (sharedResConfigured_ == TRUE) { if ((retVal = makeShareField(hostInfo->hostName, TRUE, &shareNames, &shareValues, &formats)) > 0) { for (i = 0; i < retVal; i++) { printf(formats[i], shareNames[i]); } printf("\n"); for (i = 0; i < retVal; i++) { printf(formats[i], shareValues[i]); } printf("\n"); } } printf("\n"); printf("%s: ", _i18n_msg_get(ls_catd,NL_SETN,1614, "RESOURCES")); /* catgets 1614 */ if (hostInfo->nRes) { int first = TRUE; for (i=0; i < hostInfo->nRes; i++) { if (! first) printf(" "); else printf("("); printf("%s", hostInfo->resources[i]); first = FALSE; } printf(")\n"); } else { printf("%s\n", _i18n_msg_get(ls_catd,NL_SETN,1615, "Not defined")); /* catgets 1615 */ } printf("%s: ", _i18n_msg_get(ls_catd,NL_SETN,1616, "RUN_WINDOWS")); /* catgets 1616 */ if (hostInfo->isServer) { if (strcmp(hostInfo->windows, "-") == 0) fputs( _i18n_msg_get(ls_catd,NL_SETN,1617, " (always open)\n"), /* catgets 1617 */ stdout); else printf("%s\n", hostInfo->windows); } else { printf(_i18n_msg_get(ls_catd,NL_SETN,1618, "Not applicable for client-only host\n")); /* catgets 1618 */ } if (! hostInfo->isServer) { printf("\n"); return; } printf("\n"); printf(_i18n_msg_get(ls_catd,NL_SETN,1626, "LOAD_THRESHOLDS:")); /* catgets 1626 */ printf("\n%s\n",line); li = hostInfo->busyThreshold; for(i=0; indxnames[i]; i++) { char tmpfield[MAXLSFNAMELEN]; int id; if (i > MEM) id = MEM + 1; else id = i; if (fabs(li[i]) >= (double) INFINIT_LOAD) sp = "-"; else { sprintf(tmpfield, fmt[id].ok, li[i] * fmt[id].scale); sp = stripSpaces(tmpfield); } if ((id == MEM + 1) && (newIndexLen = strlen (indxnames[i])) >= 7 ){ sprintf(newFmt, "%s%d%s", "%", newIndexLen+1, "s"); printf(newFmt, sp); } else printf(fmt[id].hdr, sp); } printf("\n"); }
void DTD::parseTagAttributeValues(const QString &name, QString *value) { AttributeList *attributes = new AttributeList(); QStringList attrLines = QStringList::split("\\end",*value); QStringList::Iterator lineIt = attrLines.begin(); while (lineIt != attrLines.end()) //iterate through the attribute lines { //split the attribute line QStringList all = QStringList::split(" ", *lineIt); QStringList::Iterator it = all.begin(); while(it != all.end()) { Attribute *attr = new Attribute(); attr->name = *it; //kdDebug() << "Inserting for tag " << name << ": " << *it << endl; ++it; QString values = *it; //list of possible values if ( values.startsWith("(") && values.endsWith(")") ) { values.remove(0,1); values.remove(values.length()-1,1); attr->values = QStringList::split("|", values); QString s = (attr->values[0]+attr->values[1]).lower(); stripSpaces(&s); if ((s == "truefalse") || (s == "falsetrue")) { attr->type = "check"; } else { attr->type = "list"; } } else { attr->values = values; attr->type = "input"; } //kdDebug() << " --- values: " << *it << endl; if (it != all.end()) { ++it; QString s=*it; if (s.startsWith("\"") && s.endsWith("\"") && it!=all.end()) { s.remove(0,1); s.remove(s.length()-1,1); attr->defaultValue = s; } if (s.startsWith("#") && it != all.end()) { s.remove(0,1); attr->status = s.lower(); } if (*it == "#FIXED" && it != all.end()) { ++it; attr->values.append(*it); } } if (it != all.end()) { ++it; } attributes->append(attr); } ++lineIt; } tagAttributes.insert(name, attributes); }
int makewideFields(struct hostLoad *host, char *loadval[], char **dispindex) { int j, id, nf; static char first = TRUE; char *sp; char tmpfield[MAXFIELDSIZE]; char fmtField[MAXFIELDSIZE]; char firstFmt[MAXFIELDSIZE]; if (first) { first = FALSE; for (j=0; j < num_loadindex;j++) loadval[j] = malloc(MAXFIELDSIZE); if (loadval[j-1] == NULL) fprintf(stderr, I18N_FUNC_FAIL ,"makeFields", "malloc" ); } nf = 0; for(j=0; dispindex[j]; j++, nf++) { int newIndexLen; id = nameToFmt(dispindex[j]); if (id == DEFAULT_FMT) newIndexLen = strlen(dispindex[j]); if (host->li[j] >= INFINIT_LOAD) sp = "-"; else { if (LS_ISBUSYON(host->status, j)) { strcpy(firstFmt, widefmt[id].busy); sprintf(fmtField, "%s%s",firstFmt, widefmt[id].normFmt); sprintf(tmpfield, fmtField, host->li[j] * widefmt[id].scale); } else { strcpy(firstFmt, widefmt[id].ok); sprintf(fmtField, "%s%s", firstFmt, widefmt[id].normFmt); sprintf(tmpfield, fmtField, host->li[j] * widefmt[id].scale); } sp = stripSpaces(tmpfield); if (strlen(sp) > widefmt[id].dispLen) { if (host->li[j] > 1024) sprintf(fmtField, "%s%s", firstFmt, widefmt[id].expFmt); else sprintf(fmtField, "%s%s", firstFmt, widefmt[id].normFmt); if ((host->li[j] > 1024) && ((!strcmp(widefmt[id].name,"mem")) || (!strcmp(widefmt[id].name,"tmp")) || (!strcmp(widefmt[id].name,"swp")))) sprintf(tmpfield,fmtField,(host->li[j]*widefmt[id].scale)/1024); else sprintf(tmpfield,fmtField, (host->li[j] * widefmt[id].scale)); } sp = stripSpaces(tmpfield); } if (id == DEFAULT_FMT && newIndexLen >= 7){ char newFmt[10]; int len; sprintf(newFmt, "%s%d%s", "%", newIndexLen+1, "s"); len = (newIndexLen+1) > strlen(sp) ? (newIndexLen+1): strlen(sp); loadval[j] = realloc(loadval[j], len+1); sprintf(loadval[j], newFmt, sp); } else sprintf(loadval[j], widefmt[id].hdr, sp); } return(nf); }