void getConfidenceForTicketType(LPFIELDSRESULTS lpFieldsResults, int *lpcnfM, int *lpcnfP){ char *resultsStr = lpFieldsResults->result; int cM, maxcM, cP, maxcP; int i; int iStart, iStop; resultTmp[0] = 0; cand2Tmp[0] = 0; i = 0; maxcM = 0; maxcP = 0; while(1){ if(getLine(resultsStr, i, &iStart, &iStop) < 0) break; // printLine(resultsStr, iStart, iStop); cM = matchToString(resultsStr, iStart, iStop, "MEGA"); // printf("---cM= %d\n", cM); if(cM > maxcM) maxcM = cM; cP = matchToString(resultsStr, iStart, iStop, "POWER"); // printf("---cP= %d\n", cP); if(cP > maxcP) maxcP = cP; i++; } *lpcnfM = maxcM; *lpcnfP = maxcP; }
int matchDayPower(char *resultsStr, int iStart, int iStop){ int match = 0; int ccF = 0; int ccT = 0; int ccD = 0; int i; ccF = matchToString(resultsStr, iStart, iStop, "SAT"); ccT = matchToString(resultsStr, iStart, iStop, "WED"); if(ccF<ccT) ccF = ccT; ccD = 0; for(i=iStart;i<iStop;i++){ if(resultsStr[i] >= '0' && resultsStr[i] <= '9') ccD++; } if(ccF >1 && ccD > 3) match = 1; return match; }
int matchDayMegaA(char *resultsStr, int iStart, int iStop){ // int match = 0; int ccF = 0; int ccT = 0; // int ccD = 0; // int i; ccF = matchToString(resultsStr, iStart, iStop, "FRI"); ccT = matchToString(resultsStr, iStart, iStop, "TUE"); //printf("M-------ccF= %d, ccT= %d\n", ccF, ccT); if(ccF<ccT) ccF = ccT; // ccD = 0; // for(i=iStart;i<iStop;i++){ // if(resultsStr[i] >= '0' && resultsStr[i] <= '9') ccD++; // } // if(ccF >1 && ccD > 3) match = 1; // if(ccF >1 ) match = 1; return ccF; }
static char * iniOptionValueToString (CompDisplay *d, CompOptionValue *value, CompOptionType type) { char tmp[MAX_OPTION_LENGTH]; tmp[0] = '\0'; switch (type) { case CompOptionTypeBool: case CompOptionTypeInt: snprintf(tmp, 256, "%i", (int)value->i); break; case CompOptionTypeFloat: snprintf(tmp, 256, "%f", value->f); break; case CompOptionTypeString: snprintf (tmp, MAX_OPTION_LENGTH, "%s", strdup (value->s)); break; case CompOptionTypeColor: snprintf (tmp, 10, "%s", colorToString (value->c)); break; case CompOptionTypeKey: return keyActionToString (d, &value->action); break; case CompOptionTypeButton: return buttonActionToString (d, &value->action); break; case CompOptionTypeEdge: return edgeMaskToString (value->action.edgeMask); break; case CompOptionTypeBell: snprintf (tmp, 256, "%i", (int) value->action.bell); break; case CompOptionTypeMatch: { char *s = matchToString (&value->match); snprintf (tmp, MAX_OPTION_LENGTH, "%s", s); free(s); } break; default: break; } return strdup (tmp); }
void createPlierField(LPTICKETRESULTS ticketResults, int n){ FIELDSRESULTS fieldsResults = ticketResults->fieldsResults[n]; char *resultsStr = fieldsResults.result; int cM, maxcM, cP, maxcP, lineM, lineP; int i; int iStart, iStop, line; int ccYes, ccNo, maxYes, maxNo; resultTmp[0] = 0; cand2Tmp[0] = 0; i = 0; maxcM = 0; maxcP = 0; lineM = -1; lineP = -1; while(1){ if(getLine(resultsStr, i, &iStart, &iStop) < 0) break; // printLine(resultsStr, iStart, iStop); cM = matchToString(resultsStr, iStart, iStop, "MEGA"); // printf("---cM= %d\n", cM); if(cM > maxcM) {maxcM = cM;lineM = i;} cP = matchToString(resultsStr, iStart, iStop, "POWER"); // printf("---cP= %d\n", cP); if(cP > maxcP) {maxcP = cP;lineP = i;} i++; } line = -1; ccYes = 0; ccNo = 0; if(maxcM > maxcP && lineM >= 0) line = lineM; if(maxcP > maxcM && lineP >= 0) line = lineP; // printf("---maxcM= %d, lineM= %d, maxcP= %d, lineP= %d, line= %d\n", maxcM, lineM, maxcP, lineP, line); maxYes = 0; maxNo = 0; if(line >= 0) { if(getLine(resultsStr, line, &iStart, &iStop) >= 0) { //printLine(resultsStr, iStart, iStop); ccYes = matchToStringEnd(resultsStr, iStart, iStop, "YES"); ccNo = matchToStringEnd(resultsStr, iStart, iStop, "NO"); // printf("---ccYes= %d, ccNo= %d\n", ccYes, ccNo); } }else{ i = 0; while(1){ if(getLine(resultsStr, i, &iStart, &iStop) < 0) break; ccYes = matchToStringEnd(resultsStr, iStart, iStop, "YES"); // printf("---i = %d, ccYes= %d\n", i, ccYes); if(ccYes > maxYes) maxYes = ccYes; ccNo = matchToStringEnd(resultsStr, iStart, iStop, "NO"); // printf("---i = %d, ccNo= %d\n", i, ccNo); if(ccNo > maxNo) maxNo = ccNo; // printf("---i = %d, maxYes= %d, maxNo= %d\n", i, maxYes, maxNo); i++; } ccYes = maxYes; ccNo = maxNo; } // printf("---ccYes= %d, ccNo= %d\n", ccYes, ccNo); {int nIdx = NUMFIELDS_RESULTS-1; strcpy(ticketResults->fieldsResults[nIdx].name, "PLAYER"); strcpy(ticketResults->fieldsResults[nIdx].result, "???"); if(ccYes > ccNo) { strcpy(ticketResults->fieldsResults[nIdx].result, "YES"); } if(ccYes < ccNo) { strcpy(ticketResults->fieldsResults[nIdx].result, "NO"); } for(i=0;i<strlen(ticketResults->fieldsResults[nIdx].result);i++){ ticketResults->fieldsResults[nIdx].flConf[i] = 100; } } }
static QString kconfigValueToString (CompObject *object, CompOptionType type, CompOptionValue *value) { QString str; switch (type) { case CompOptionTypeBool: str = QString::number (value->b ? TRUE : FALSE); break; case CompOptionTypeFloat: str = QString::number (value->f); break; case CompOptionTypeString: str = QString (value->s); break; case CompOptionTypeColor: { char *color; color = colorToString (value->c); if (color) { str = QString (color); free (color); } } break; case CompOptionTypeKey: { char *action = NULL; while (object && object->type != COMP_OBJECT_TYPE_DISPLAY) object = object->parent; if (object) action = keyActionToString (GET_CORE_DISPLAY (object), &value->action); if (action) { str = QString (action); free (action); } } break; case CompOptionTypeButton: { char *action = NULL; while (object && object->type != COMP_OBJECT_TYPE_DISPLAY) object = object->parent; if (object) action = buttonActionToString (GET_CORE_DISPLAY (object), &value->action); if (action) { str = QString (action); free (action); } } break; case CompOptionTypeEdge: { char *edge; edge = edgeMaskToString (value->action.edgeMask); if (edge) { str = QString (edge); free (edge); } } break; case CompOptionTypeBell: str = QString::number (value->action.bell ? TRUE : FALSE); break; case CompOptionTypeMatch: { char *match; match = matchToString (&value->match); if (match) { str = QString (match); free (match); } } default: break; } return str; }
static void ccpInitValue (CompObject *object, CCSSettingValue *value, CompOptionValue *from, CCSSettingType type) { switch (type) { case TypeInt: value->value.asInt = from->i; break; case TypeFloat: value->value.asFloat = from->f; break; case TypeBool: value->value.asBool = from->b; break; case TypeColor: { int i; for (i = 0; i < 4; i++) value->value.asColor.array.array[i] = from->c[i]; } break; case TypeString: value->value.asString = strdup (from->s); break; case TypeMatch: value->value.asMatch = matchToString (&from->match); break; case TypeKey: if (from->action.type & CompBindingTypeKey) { CompDisplay *d; while (object && object->type != COMP_OBJECT_TYPE_DISPLAY) object = object->parent; if (!object) return; d = GET_CORE_DISPLAY (object); value->value.asKey.keysym = XKeycodeToKeysym (d->display, from->action.key.keycode, 0); value->value.asKey.keyModMask = from->action.key.modifiers; } else { value->value.asKey.keysym = 0; value->value.asKey.keyModMask = 0; } case TypeButton: if (from->action.type & CompBindingTypeButton) { value->value.asButton.button = from->action.button.button; value->value.asButton.buttonModMask = from->action.button.modifiers; value->value.asButton.edgeMask = 0; } else if (from->action.type & CompBindingTypeEdgeButton) { value->value.asButton.button = from->action.button.button; value->value.asButton.buttonModMask = from->action.button.modifiers; value->value.asButton.edgeMask = from->action.edgeMask; } else { value->value.asButton.button = 0; value->value.asButton.buttonModMask = 0; value->value.asButton.edgeMask = 0; } break; case TypeEdge: value->value.asEdge = from->action.edgeMask; break; case TypeBell: value->value.asBell = from->action.bell; break; default: break; } }
static Bool decorSetDisplayOption (CompPlugin *plugin, CompDisplay *display, const char *name, CompOptionValue *value) { CompOption *o; int index; DECOR_DISPLAY (display); o = compFindOption (dd->opt, NUM_OPTIONS (dd), name, &index); if (!o) return FALSE; switch (index) { case DECOR_DISPLAY_OPTION_COMMAND: if (compSetStringOption (o, value)) { CompScreen *s; for (s = display->screens; s; s = s->next) { DECOR_SCREEN (s); if (!ds->dmWin) runCommand (s, o->value.s); } return TRUE; } break; case DECOR_DISPLAY_OPTION_SHADOW_MATCH: { char *matchString; /* Make sure RGBA matching is always present and disable shadows for RGBA windows by default if the user didn't specify an RGBA match. Reasoning for that is that shadows are desired for some RGBA windows (e.g. rectangular windows that just happen to have an RGBA colormap), while it's absolutely undesired for others (especially shaped ones) ... by enforcing no shadows for RGBA windows by default, we are flexible to user desires while still making sure we don't show ugliness by default */ matchString = matchToString (&value->match); if (matchString) { if (!strstr (matchString, "rgba=")) { CompMatch rgbaMatch; matchInit (&rgbaMatch); matchAddFromString (&rgbaMatch, "rgba=0"); matchAddGroup (&value->match, MATCH_OP_AND_MASK, &rgbaMatch); matchFini (&rgbaMatch); } free (matchString); } } /* fall-through intended */ case DECOR_DISPLAY_OPTION_DECOR_MATCH: if (compSetMatchOption (o, value)) { CompScreen *s; CompWindow *w; for (s = display->screens; s; s = s->next) for (w = s->windows; w; w = w->next) decorWindowUpdate (w, TRUE); } break; default: if (compSetOption (o, value)) return TRUE; break; } return FALSE; }
/* MULTIDPYERROR: only works with one or less displays present */ static char * fuseGetStringFromInode(FuseInode *inode) { CompOption *option; char str[256]; if (!inode->parent) return NULL; option = fuseGetOptionFromInode(inode->parent); if (!option) return NULL; if (inode->flags & FUSE_INODE_FLAG_TRUNC) return strdup(""); if (inode->type & FUSE_INODE_TYPE_TYPE) { return strdup(optionTypeToString(option->type)); } else if (inode->type & (FUSE_INODE_TYPE_VALUE | FUSE_INODE_TYPE_ITEM_VALUE)) { CompOptionValue *value = NULL; CompOptionType type; if (inode->type & FUSE_INODE_TYPE_ITEM_VALUE) { int i; if (sscanf(inode->name, "value%d", &i)) { if (i < option->value.list.nValue) { value = &option->value.list.value[i]; type = option->value.list.type; } } } else { value = &option->value; type = option->type; } if (value) { switch (type) { case CompOptionTypeBool: return strdup(value->b ? "true" : "false"); case CompOptionTypeInt: snprintf(str, 256, "%d", value->i); return strdup(str); case CompOptionTypeFloat: snprintf(str, 256, "%f", value->f); return strdup(str); case CompOptionTypeString: return strdup(value->s); case CompOptionTypeColor: return colorToString(value->c); case CompOptionTypeKey: if (core.displays) return keyActionToString(core.displays, &value->action); case CompOptionTypeButton: if (core.displays) return buttonActionToString(core.displays, &value->action); case CompOptionTypeEdge: return edgeMaskToString(value->action.edgeMask); case CompOptionTypeBell: return strdup(value->action.bell ? "true" : "false"); case CompOptionTypeMatch: return matchToString(&value->match); default: break; } } } else if (inode->type & FUSE_INODE_TYPE_MIN) { if (option->type == CompOptionTypeInt) snprintf(str, 256, "%d", option->rest.i.min); else snprintf(str, 256, "%f", option->rest.f.min); return strdup(str); } else if (inode->type & FUSE_INODE_TYPE_MAX) { if (option->type == CompOptionTypeInt) snprintf(str, 256, "%d", option->rest.i.max); else snprintf(str, 256, "%f", option->rest.f.max); return strdup(str); } else if (inode->type & FUSE_INODE_TYPE_PRECISION) { snprintf(str, 256, "%f", option->rest.f.precision); return strdup(str); } else if (inode->type & FUSE_INODE_TYPE_ITEM_COUNT) { snprintf(str, 256, "%d", option->value.list.nValue); return strdup(str); } else if (inode->type & FUSE_INODE_TYPE_ITEM_TYPE) { return strdup(optionTypeToString(option->value.list.type)); } return NULL; }