static int chkdbl(struct facets *fp,char *s,int n) { int ok=1,nan=s_tokcmpn("NaN",s,n)==0; double d=atodn(s,n); if(fp->set&(1<<FCT_MIN_EXCLUSIVE)) ok=ok&&!nan&&d>atod(fp->minExclusive); if(fp->set&(1<<FCT_MIN_INCLUSIVE)) ok=ok&&!nan&&d>=atod(fp->minInclusive); if(fp->set&(1<<FCT_MAX_INCLUSIVE)) ok=ok&&!nan&&d<=atod(fp->maxInclusive); if(fp->set&(1<<FCT_MAX_EXCLUSIVE)) ok=ok&&!nan&&d<atod(fp->maxExclusive); return ok; }
int main(int argc, char* argv[]) { bfs::path featureFile(argv[1]); bfs::path expressionFile(argv[2]); double estimatedReadLength = atod(argv[3]); double kmersPerRead = atod(argv[4]); uint64_t mappedKmers = atol(argv[5]); uint32_t mappedKmers = atoi(argv[6]); bfs::path outputFile(argv[7]); size_t numThreads = atoi(argv[8]); performBiasCorrection(featureFile, expressionFile, estimatedReadLength, kmersPerRead, mappedKmers, merLen, outputFile, numThreads); }
double XmlObject::GetNodeValueAsDouble(Poco::XML::Node *pNode) { double value = -1; if (pNode != 0) { try { value = atod(pNode->getNodeValue().c_str()); } catch (Poco::Exception) { } } return value; }
int main(int argc, char **argv) { int a, op, b, c; if(argc!=4) { fprintf(stderr, "usage: calc <number> [+|-|*|/] <number>\n"); exit(1); } a = atod(argv[1]); op = argv[2][0]; b = atod(argv[3]); switch(op) { case '+': c = a + b; break; case '-': c = a - b; break; case '*': c = a * b; break; case '/': c = a / b; break; default: assert(0); } printf("%d %c %d = %d\n", a, op, b, c); return 0; }
static int gen_create_mn_disk_wwn(dev_info_t *devi) { struct driver_minor_data *dmdp; int instance = ddi_get_instance(devi); char *address = ddi_get_name_addr(devi); int target, lun; if (address[0] >= '0' && address[0] <= '9' && strchr(address, ',')) { target = atod(address); address = strchr(address, ','); lun = atod(++address); } else { /* this hack is for rm_stale_link() testing */ target = 10; lun = 5; } if (ddi_prop_create(DDI_DEV_T_NONE, devi, DDI_PROP_CANSLEEP, "target", (caddr_t)&target, sizeof (int)) != DDI_PROP_SUCCESS) { return (DDI_FAILURE); } if (ddi_prop_create(DDI_DEV_T_NONE, devi, DDI_PROP_CANSLEEP, "lun", (caddr_t)&lun, sizeof (int)) != DDI_PROP_SUCCESS) { return (DDI_FAILURE); } for (dmdp = disk_minor_data; dmdp->name != NULL; dmdp++) { if (ddi_create_minor_node(devi, dmdp->name, dmdp->type, (INST_TO_MINOR(instance)) | dmdp->minor, DDI_NT_BLOCK_WWN, NULL) != DDI_SUCCESS) { return (DDI_FAILURE); } } return (DDI_SUCCESS); }
/* Input a number as decimal digits - returns value entered */ long decIn(void) { char input[40]; int num; int tmp; register int i; i = 0; num = 0; if (sgets (input)) /* grab a line */ { atod(input[i++], &num); /* Convert MSD to decimal */ while(isdec(input[i]) && input[i]) /* Get next decimal digit */ { num *= 10; /* Make room for next digit */ atod(input[i++], &tmp); num += tmp; /* Add it in */ } } return (num); }
unsigned long atolong(char *data, unsigned long *retLong) { unsigned char cycleCount = 0; unsigned char digit; *retLong = 0; while ((digit = atod(*data)) != 0xff) { *retLong *= 10; *retLong += digit; data++; cycleCount++; } return cycleCount; }
int atoi(const char *source, int *status) { /* * parses a c-string and interprets the contents as integer */ unsigned int base = 10, num = 0, i = 0; int digit; *status = 1; while(source[i]) { digit = atod(source[i]); if (digit > base || digit < 0) { *status = 0; break; } num = num * base + digit; ++i; } return num; }
// evaluate word->tokstr. // NOTE: word->type and word->tokstr must be set. void forth_eval_word(ForthInterp *interp, ForthWord *word) { if (word->tokstr.str == NULL) return; if (word->type == WORD_DIGIT) { if (! word->digitval.is_set) { ASSERT(interp, word->tokstr.str != NULL); char *err = NULL; digit_t d = atod(word->tokstr.str, 10, &err); if (err != NULL) { fprintf(stderr, "%s: ", word->tokstr.str); forth_die(interp, "atod", FORTH_ERR_CONVERT_FAILED); } word_set_digit(word, d); forth_debugf(interp, "eval: %s -> %f\n", word->tokstr.str, word->digitval.digit); } } else if (word->type == WORD_STRING) { if (word->strval.str == NULL) { size_t len = strlen(word->tokstr.str); char str[len + 1]; // evaluated string. // empty string. if (STREQ(word->tokstr.str, "\"\"")) { word_set_str(word, ""); return; } char *begin, *end, *cur_srch_pos; // set inside double quotes cur_srch_pos = begin = word->tokstr.str + 1; end = word->tokstr.str + word->tokstr.len - 2; // remember null byte. // original code from parser.c while (1) { end = strchr(cur_srch_pos, '"'); /* not found '"' */ if (end == NULL) { // process can't reach this block // because parser checks this when parsing. forth_die(interp, "forth_eval_word", FORTH_ERR_UNCLOSED_STR); } /* found it */ else if (*(end - 1) != '\\') { // if not escaped string. strncpy(str, begin, end - begin); str[end - begin] = '\0'; word_set_str_copy(word, str); return; } /* found but it was escaped. search again. */ else { // TODO escape sequence. cur_srch_pos = end; } } } } else if (word->type == WORD_FUNC) { forth_error(interp, "tried to convert word func to string.", FORTH_ERR_CONVERT_FAILED); // no strict? (in Perl) // word_set_str_copy(word, WORD_FUNC_STR); } else if (word->type == WORD_UNDEF) { forth_error(interp, "tried to convert undefined word to string.", FORTH_ERR_CONVERT_FAILED); // no strict? (in Perl) // word_set_str_copy(word, ""); } else { // never reach this block ASSERT(interp, 0); } }
bool cSetup::Parse(const char *Name, const char *Value) { if (!strcasecmp(Name, "OSDLanguage")) { strn0cpy(OSDLanguage, Value, sizeof(OSDLanguage)); I18nSetLocale(OSDLanguage); } else if (!strcasecmp(Name, "OSDSkin")) Utf8Strn0Cpy(OSDSkin, Value, MaxSkinName); else if (!strcasecmp(Name, "OSDTheme")) Utf8Strn0Cpy(OSDTheme, Value, MaxThemeName); else if (!strcasecmp(Name, "PrimaryDVB")) PrimaryDVB = atoi(Value); else if (!strcasecmp(Name, "ShowInfoOnChSwitch")) ShowInfoOnChSwitch = atoi(Value); else if (!strcasecmp(Name, "TimeoutRequChInfo")) TimeoutRequChInfo = atoi(Value); else if (!strcasecmp(Name, "MenuScrollPage")) MenuScrollPage = atoi(Value); else if (!strcasecmp(Name, "MenuScrollWrap")) MenuScrollWrap = atoi(Value); else if (!strcasecmp(Name, "MenuKeyCloses")) MenuKeyCloses = atoi(Value); else if (!strcasecmp(Name, "MarkInstantRecord")) MarkInstantRecord = atoi(Value); else if (!strcasecmp(Name, "NameInstantRecord")) Utf8Strn0Cpy(NameInstantRecord, Value, sizeof(NameInstantRecord)); else if (!strcasecmp(Name, "InstantRecordTime")) InstantRecordTime = atoi(Value); else if (!strcasecmp(Name, "LnbSLOF")) LnbSLOF = atoi(Value); else if (!strcasecmp(Name, "LnbFrequLo")) LnbFrequLo = atoi(Value); else if (!strcasecmp(Name, "LnbFrequHi")) LnbFrequHi = atoi(Value); else if (!strcasecmp(Name, "DiSEqC")) DiSEqC = atoi(Value); else if (!strcasecmp(Name, "SetSystemTime")) SetSystemTime = atoi(Value); else if (!strcasecmp(Name, "TimeSource")) TimeSource = cSource::FromString(Value); else if (!strcasecmp(Name, "TimeTransponder")) TimeTransponder = atoi(Value); else if (!strcasecmp(Name, "StandardCompliance")) StandardCompliance = atoi(Value); else if (!strcasecmp(Name, "MarginStart")) MarginStart = atoi(Value); else if (!strcasecmp(Name, "MarginStop")) MarginStop = atoi(Value); else if (!strcasecmp(Name, "AudioLanguages")) return ParseLanguages(Value, AudioLanguages); else if (!strcasecmp(Name, "DisplaySubtitles")) DisplaySubtitles = atoi(Value); else if (!strcasecmp(Name, "SubtitleLanguages")) return ParseLanguages(Value, SubtitleLanguages); else if (!strcasecmp(Name, "SubtitleOffset")) SubtitleOffset = atoi(Value); else if (!strcasecmp(Name, "SubtitleFgTransparency")) SubtitleFgTransparency = atoi(Value); else if (!strcasecmp(Name, "SubtitleBgTransparency")) SubtitleBgTransparency = atoi(Value); else if (!strcasecmp(Name, "EPGLanguages")) return ParseLanguages(Value, EPGLanguages); else if (!strcasecmp(Name, "EPGScanTimeout")) EPGScanTimeout = atoi(Value); else if (!strcasecmp(Name, "EPGBugfixLevel")) EPGBugfixLevel = atoi(Value); else if (!strcasecmp(Name, "EPGLinger")) EPGLinger = atoi(Value); else if (!strcasecmp(Name, "SVDRPTimeout")) SVDRPTimeout = atoi(Value); else if (!strcasecmp(Name, "ZapTimeout")) ZapTimeout = atoi(Value); else if (!strcasecmp(Name, "ChannelEntryTimeout")) ChannelEntryTimeout= atoi(Value); else if (!strcasecmp(Name, "RcRepeatDelay")) RcRepeatDelay = atoi(Value); else if (!strcasecmp(Name, "RcRepeatDelta")) RcRepeatDelta = atoi(Value); else if (!strcasecmp(Name, "DefaultPriority")) DefaultPriority = atoi(Value); else if (!strcasecmp(Name, "DefaultLifetime")) DefaultLifetime = atoi(Value); else if (!strcasecmp(Name, "PauseKeyHandling")) PauseKeyHandling = atoi(Value); else if (!strcasecmp(Name, "PausePriority")) PausePriority = atoi(Value); else if (!strcasecmp(Name, "PauseLifetime")) PauseLifetime = atoi(Value); else if (!strcasecmp(Name, "UseSubtitle")) UseSubtitle = atoi(Value); else if (!strcasecmp(Name, "UseVps")) UseVps = atoi(Value); else if (!strcasecmp(Name, "VpsMargin")) VpsMargin = atoi(Value); else if (!strcasecmp(Name, "RecordingDirs")) RecordingDirs = atoi(Value); else if (!strcasecmp(Name, "FoldersInTimerMenu")) FoldersInTimerMenu = atoi(Value); else if (!strcasecmp(Name, "AlwaysSortFoldersFirst")) AlwaysSortFoldersFirst = atoi(Value); else if (!strcasecmp(Name, "NumberKeysForChars")) NumberKeysForChars = atoi(Value); else if (!strcasecmp(Name, "ColorKey0")) ColorKey0 = atoi(Value); else if (!strcasecmp(Name, "ColorKey1")) ColorKey1 = atoi(Value); else if (!strcasecmp(Name, "ColorKey2")) ColorKey2 = atoi(Value); else if (!strcasecmp(Name, "ColorKey3")) ColorKey3 = atoi(Value); else if (!strcasecmp(Name, "VideoDisplayFormat")) VideoDisplayFormat = atoi(Value); else if (!strcasecmp(Name, "VideoFormat")) VideoFormat = atoi(Value); else if (!strcasecmp(Name, "UpdateChannels")) UpdateChannels = atoi(Value); else if (!strcasecmp(Name, "UseDolbyDigital")) UseDolbyDigital = atoi(Value); else if (!strcasecmp(Name, "ChannelInfoPos")) ChannelInfoPos = atoi(Value); else if (!strcasecmp(Name, "ChannelInfoTime")) ChannelInfoTime = atoi(Value); else if (!strcasecmp(Name, "OSDLeftP")) OSDLeftP = atod(Value); else if (!strcasecmp(Name, "OSDTopP")) OSDTopP = atod(Value); else if (!strcasecmp(Name, "OSDWidthP")) { OSDWidthP = atod(Value); ChkDoublePlausibility(OSDWidthP, 0.87); } else if (!strcasecmp(Name, "OSDHeightP")) { OSDHeightP = atod(Value); ChkDoublePlausibility(OSDHeightP, 0.84); } else if (!strcasecmp(Name, "OSDLeft")) OSDLeft = atoi(Value); else if (!strcasecmp(Name, "OSDTop")) OSDTop = atoi(Value); else if (!strcasecmp(Name, "OSDWidth")) { OSDWidth = atoi(Value); OSDWidth &= ~0x07; } // OSD width must be a multiple of 8 else if (!strcasecmp(Name, "OSDHeight")) OSDHeight = atoi(Value); else if (!strcasecmp(Name, "OSDAspect")) OSDAspect = atod(Value); else if (!strcasecmp(Name, "OSDMessageTime")) OSDMessageTime = atoi(Value); else if (!strcasecmp(Name, "UseSmallFont")) UseSmallFont = atoi(Value); else if (!strcasecmp(Name, "AntiAlias")) AntiAlias = atoi(Value); else if (!strcasecmp(Name, "FontOsd")) Utf8Strn0Cpy(FontOsd, Value, MAXFONTNAME); else if (!strcasecmp(Name, "FontSml")) Utf8Strn0Cpy(FontSml, Value, MAXFONTNAME); else if (!strcasecmp(Name, "FontFix")) Utf8Strn0Cpy(FontFix, Value, MAXFONTNAME); else if (!strcasecmp(Name, "FontOsdSizeP")) { FontOsdSizeP = atod(Value); ChkDoublePlausibility(FontOsdSizeP, 0.038); } else if (!strcasecmp(Name, "FontSmlSizeP")) { FontSmlSizeP = atod(Value); ChkDoublePlausibility(FontSmlSizeP, 0.035); } else if (!strcasecmp(Name, "FontFixSizeP")) { FontFixSizeP = atod(Value); ChkDoublePlausibility(FontFixSizeP, 0.031); } else if (!strcasecmp(Name, "FontOsdSize")) FontOsdSize = atoi(Value); else if (!strcasecmp(Name, "FontSmlSize")) FontSmlSize = atoi(Value); else if (!strcasecmp(Name, "FontFixSize")) FontFixSize = atoi(Value); else if (!strcasecmp(Name, "MaxVideoFileSize")) MaxVideoFileSize = atoi(Value); else if (!strcasecmp(Name, "SplitEditedFiles")) SplitEditedFiles = atoi(Value); else if (!strcasecmp(Name, "DelTimeshiftRec")) DelTimeshiftRec = atoi(Value); else if (!strcasecmp(Name, "MinEventTimeout")) MinEventTimeout = atoi(Value); else if (!strcasecmp(Name, "MinUserInactivity")) MinUserInactivity = atoi(Value); else if (!strcasecmp(Name, "NextWakeupTime")) NextWakeupTime = atoi(Value); else if (!strcasecmp(Name, "MultiSpeedMode")) MultiSpeedMode = atoi(Value); else if (!strcasecmp(Name, "ShowReplayMode")) ShowReplayMode = atoi(Value); else if (!strcasecmp(Name, "ShowRemainingTime")) ShowRemainingTime = atoi(Value); else if (!strcasecmp(Name, "ProgressDisplayTime")) ProgressDisplayTime= atoi(Value); else if (!strcasecmp(Name, "PauseOnMarkSet")) PauseOnMarkSet = atoi(Value); else if (!strcasecmp(Name, "ResumeID")) ResumeID = atoi(Value); else if (!strcasecmp(Name, "CurrentChannel")) CurrentChannel = atoi(Value); else if (!strcasecmp(Name, "CurrentVolume")) CurrentVolume = atoi(Value); else if (!strcasecmp(Name, "CurrentDolby")) CurrentDolby = atoi(Value); else if (!strcasecmp(Name, "InitialChannel")) InitialChannel = Value; else if (!strcasecmp(Name, "InitialVolume")) InitialVolume = atoi(Value); else if (!strcasecmp(Name, "DeviceBondings")) DeviceBondings = Value; else if (!strcasecmp(Name, "ChannelsWrap")) ChannelsWrap = atoi(Value); else if (!strcasecmp(Name, "ShowChannelNamesWithSource")) ShowChannelNamesWithSource = atoi(Value); else if (!strcasecmp(Name, "EmergencyExit")) EmergencyExit = atoi(Value); else if (!strcasecmp(Name, "LastReplayed")) cReplayControl::SetRecording(Value); else return false; return true; }
/************************************************************************** * Function Name: BOOL hexRead(CHAR *pHexFile, HEX_DATA *pHexData) *************************************************************************** * Summary: * Read the hex data and information, check the format of the hex file * * Parameters: * CHAR *pHexFile -- Filename of the CYACD file. * HEX_DATA *pHexData -- Hex data pointer. * * Return: * TRUE -- Success * FALSE -- Failure (HEX format error) **************************************************************************/ BOOL hexRead(CHAR *pHexFile, HEX_DATA *pHexData) { DWORD i; FILE *fp; CHAR lineBuf[150]; WORD rowAddr, pageAddr; BYTE rowLength, rowMode; BYTE lineCheckSum; /* open the hex file */ if ((fp = fopen(pHexFile, "r")) == NULL) { return FALSE; } /* Initialize data to 0, to avoid checksum problem */ for (i=0; i<0x10000; i++) { pHexData->hexData[i] = 0xff; } for (i=0; i<0x80; i++) { pHexData->securityData[i] = 0; } pHexData->hexChecksum = 0; /* Start reading data */ pageAddr = 0; while(fgets(lineBuf, 150, fp) != NULL) { /* Check array ID */ if (lineBuf[0] != ':') { return FALSE; } /* Get the row length */ rowLength = atod(lineBuf[1])*16 + atod(lineBuf[2]); /* Get line data */ rowAddr = atod(lineBuf[3])*4096 + atod(lineBuf[4])* 256 + atod(lineBuf[5])*16 + atod(lineBuf[6]); rowMode = atod(lineBuf[7])*16 + atod(lineBuf[8]); lineCheckSum = 0; lineCheckSum += atod(lineBuf[1])*16 + atod(lineBuf[2]); lineCheckSum += atod(lineBuf[3])*16 + atod(lineBuf[4]); lineCheckSum += atod(lineBuf[5])*16 + atod(lineBuf[6]); lineCheckSum += atod(lineBuf[7])*16 + atod(lineBuf[8]); for (i=0; i<rowLength; i++) { lineBuf[i] = atod(lineBuf[i*2+9])*16 + atod(lineBuf[i*2+10]); lineCheckSum += lineBuf[i]; switch (pageAddr) { case 0x0000: if (rowMode == 0x00) { pHexData->hexData[rowAddr+i] = lineBuf[i]; } break; case 0x0010: if (rowMode == 0x00) { pHexData->securityData[rowAddr+i] = lineBuf[i]; } break; case 0x0020: if (rowMode == 0x00) { pHexData->hexChecksum = pHexData->hexChecksum *256; pHexData->hexChecksum += (BYTE)lineBuf[i]; } break; default: break; } } lineCheckSum += atod(lineBuf[rowLength*2+9])*16 + atod(lineBuf[rowLength*2+10]); if (lineCheckSum != 0) { return FALSE; } if (rowMode == 0x04) { pageAddr = atod(lineBuf[9])*4096 + atod(lineBuf[10])* 256 + atod(lineBuf[11])*16 + atod(lineBuf[12]); } else if (rowMode == 0x01) { break; } } fclose(fp); return TRUE; }
/** * Main function. Initializes and starts the game */ int spitm() {listP mao1,mao2,pl11,pl12,pl13,pl14,pl21,pl22,pl23,pl24; int stock1[stk],stock2[stk],baralho[(num*2)-2],pc1[sz],pc2[sz],pc3[sz]; mao1=mao2=pl11=pl12=pl13=pl14=pl21=pl22=pl23=pl24=NULL; int vencedor=0,turno=1,o,d,i=0,n=0,x=(LINES/2),y=(COLS/2); initscr(); cbreak(); keypad(stdscr,TRUE); noecho(); start_color(); init_pair(1,COLOR_WHITE,COLOR_GREEN); init_pair(2,COLOR_RED,COLOR_GREEN); bkgd(COLOR_PAIR(1)); attron(COLOR_PAIR(2)); limpa(pc1,13); limpa(pc2,13); limpa(pc3,13); shuff(baralho); atoa(baralho,stock1,20); atoa(baralho,stock2,20); mao1=atod(baralho,mao1,5); mao2=atod(baralho,mao2,5); while(!i) { if(stock1[0] > stock2[0]) { turno=1;i++; };break; if(stock1[0] < stock2[0]) { turno=2; i++; };break; barStk(stock1,stk); barStk(stock2,stk); }; while(vencedor==0) { while(elemN(mao1)<5) mao1=atod(baralho,mao1,1); while(turno==1) { clear(); mostrac(mao1,pl11, pl12,pl13, pl14, mao2, pl21, pl22, pl23,pl24, pc1, pc2, pc3, stock1, stock2,turno); echo(); mvprintw(22,0,"Insira origem(1-10) e destino (1-7):__ __"); mvscanw(22,36," %d %d",&o,&d); if(o>0 && o<6) { if(d==1) { if (showi(mao1,elemN(mao1)-o) == topAr(pc1)+1) { dtoa(mao1,elemN(mao1)-o,pc1); }; }; if(d==2) { if (showi(mao1,elemN(mao1)-o) == topAr(pc2)+1) { dtoa(mao1,elemN(mao1)-o,pc2); }; }; if(d==3) { if (showi(mao1,elemN(mao1)-o) == topAr(pc3)+1) { dtoa(mao1,elemN(mao1)-o,pc3); }; }; if(d==4) { pl11=poe(pl11,showi(mao1,elemN(mao1)-o)); if(elemN(mao1) == o) { mao1=rmUlt(mao1);turno=2; } else { rmI(mao1,elemN(mao1)-(o)); turno=2; }; }; if(d==5) { pl12=poe(pl12,showi(mao1,elemN(mao1)-o)); if(elemN(mao1) == o) { mao1=rmUlt(mao1); turno=2; } else { rmI(mao1,elemN(mao1)-(o)); turno=2; }; }; if(d==6) { pl13=poe(pl13,showi(mao1,elemN(mao1)-o)); if(elemN(mao1) == o) { mao1=rmUlt(mao1); turno=2; } else { rmI(mao1,elemN(mao1)-(o)); turno=2; }; }; if(d==7) { pl14=poe(pl14,showi(mao1,elemN(mao1)-o)); if(elemN(mao1) == o) { mao1=rmUlt(mao1); turno=2; } else { rmI(mao1,elemN(mao1)-(o)); turno=2; }; }; }; //end if(o>0 && o<6) if(o==10) { if(d==1){ if (topAr(stock1) == topAr(pc1)+1) { addAe(stock1,pc1); }; }; if(d==2) { if (topAr(stock1) == topAr(pc2)+1) { addAe(stock1,pc2); }; }; if(d==3) { if (topAr(stock1) == topAr(pc3)+1) { addAe(stock1,pc3); }; }; }; if(o>5 && o< 10) { if(o==6 && d==1 && (elemN(pl11)!=0)) { if (showi(pl11,elemN(pl11)-o) == topAr(pc1)+1) { dtoa(pl11,elemN(pl11)-1,pc1); }; }; if(o==7 && d==1 && (elemN(pl12)!=0)) { if (showi(pl12,elemN(pl12)-o) == topAr(pc1)+1) { dtoa(pl12,elemN(pl12)-1,pc1); }; }; if(o==8 && d==1 && (elemN(pl13)!=0)) { if (showi(pl13,elemN(pl13)-o) == topAr(pc1)+1) { dtoa(pl13,elemN(pl13)-1,pc1); }; }; if(o==9 && d==1 && (elemN(pl14)!=0)) { if (showi(pl14,elemN(pl14)-o) == topAr(pc1)+1) { dtoa(pl14,elemN(pl14)-1,pc1); }; }; if(o==6 && d==2 && (elemN(pl11)!=0)) { if (showi(pl11,elemN(pl11)-o) == topAr(pc2)+1) { dtoa(pl11,elemN(pl11)-1,pc2); }; }; if(o==7 && d==2 && (elemN(pl12)!=0)) { if (showi(pl12,elemN(pl12)-o) == topAr(pc2)+1) { dtoa(pl12,elemN(pl12)-1,pc2); }; }; if(o==8 && d==2 && (elemN(pl13)!=0)) { if (showi(pl13,elemN(pl13)-o) == topAr(pc2)+1) { dtoa(pl13,elemN(pl13)-1,pc2); }; }; if(o==9 && d==2 && (elemN(pl14)!=0)) { if (showi(pl14,elemN(pl14)-o) == topAr(pc2)+1) { dtoa(pl14,elemN(pl14)-1,pc2); }; }; if(o==6 && d==3 && (elemN(pl11)!=0)) { if (showi(pl11,elemN(pl11)-o) == topAr(pc3)+1) { dtoa(pl11,elemN(pl11)-1,pc3); }; }; if(o==7 && d==3 && (elemN(pl12)!=0)) { if (showi(pl12,elemN(pl12)-o) == topAr(pc3)+1) { dtoa(pl12,elemN(pl12)-1,pc3); }; }; if(o==8 && d==3 && (elemN(pl13)!=0)) { if (showi(pl13,elemN(pl13)-o) == topAr(pc3)+1) { dtoa(pl13,elemN(pl13)-1,pc3); }; }; if(o==9 && d==3 && (elemN(pl14)!=0)) { if (showi(pl14,elemN(pl14)-o) == topAr(pc3)+1) { dtoa(pl14,elemN(pl14)-1,pc3); }; }; };//end if(o>5 && o< 10) }; //end while(turno==1) n=0; while ((stock1[n]==0) && (n<stk)) { n++; }; // Winner is player 1 if (stock1[n] == 0) { vencedor=1; turno=1; } // Tie if(baralho[num*2-3]==0) { vencedor=3; }; // Clean central stack if(pc1[0]==13) { atoa(pc1,baralho,13); }; if(pc2[0]==13) { atoa(pc2,baralho,13); }; if(pc3[0]==13) { atoa(pc3,baralho,13); }; // fill hand 2 while(elemN(mao2)<5) { mao2=atod(baralho,mao2,1); }; while(turno==2) { clear(); mostrac(mao1,pl11, pl12,pl13, pl14, mao2, pl21, pl22, pl23,pl24, pc1, pc2, pc3, stock1, stock2,turno); echo(); mvprintw(22,0,"Insira origem(1-10) e destino (1-7):__ __"); mvscanw(22,36,"%d %d",&o,&d); if(o>0 && o<6) { if(d==1) { if (showi(mao2,elemN(mao2)-o) == topAr(pc1)+1) { dtoa(mao2,elemN(mao2)-o,pc1);}; }; if(d==2) { if (showi(mao2,elemN(mao2)-o) == topAr(pc2)+1) { dtoa(mao2,elemN(mao2)-o,pc2); }; }; if(d==3) { if (showi(mao2,elemN(mao2)-o) == topAr(pc3)+1) { dtoa(mao2,elemN(mao2)-o,pc3); }; }; if(d==4) { pl21=poe(pl21,showi(mao2,elemN(mao2)-o)); if(elemN(mao2) == o) { mao2=rmUlt(mao2);turno=1; } else { rmI(mao2,elemN(mao2)-(o)); turno=1; }; }; if(d==5) { pl22=poe(pl22,showi(mao2,elemN(mao2)-o)); if(elemN(mao2) == o) { mao2=rmUlt(mao2); turno=1; } else { rmI(mao2,elemN(mao2)-(o)); turno=1; }; }; if(d==6) { pl23=poe(pl23,showi(mao2,elemN(mao2)-o)); if(elemN(mao2) == o) { mao2=rmUlt(mao2); turno=1; } else { rmI(mao2,elemN(mao2)-(o)); turno=1; }; }; if(d==7) { pl24=poe(pl24,showi(mao2,elemN(mao2)-o)); if(elemN(mao2) == o) { mao2=rmUlt(mao2); turno=1; } else { rmI(mao2,elemN(mao2)-(o)); turno=1; } }; }; if(o==10) { if(d==1){ if (topAr(stock2) == topAr(pc1)+1) { addAe(stock2,pc1); }; }; if(d==2) { if (topAr(stock2) == topAr(pc2)+1) { addAe(stock2,pc2); }; }; if(d==3) { if (topAr(stock2) == topAr(pc3)+1) { addAe(stock2,pc3); }; }; }; if(o>5 && o< 10) { if(o==6 && d==1 && (elemN(pl21)!=0)) { if (showi(pl21,elemN(pl21)-o) == topAr(pc1)+1) { dtoa(pl21,elemN(pl21)-1,pc1); }; }; if(o==7 && d==1 && (elemN(pl22)!=0)) { if (showi(pl22,elemN(pl22)-o) == topAr(pc1)+1) { dtoa(pl22,elemN(pl22)-1,pc1); }; }; if(o==8 && d==1 && (elemN(pl23)!=0)) { if (showi(pl23,elemN(pl23)-o) == topAr(pc1)+1) { dtoa(pl23,elemN(pl23)-1,pc1); }; }; if(o==9 && d==1 && (elemN(pl24)!=0)) { if (showi(pl24,elemN(pl24)-o) == topAr(pc1)+1) { dtoa(pl24,elemN(pl24)-1,pc1); }; }; if(o==6 && d==2 && (elemN(pl21)!=0)) { if (showi(pl21,elemN(pl21)-o) == topAr(pc2)+1) { dtoa(pl21,elemN(pl21)-1,pc2); }; }; if(o==7 && d==2 && (elemN(pl22)!=0)) { if (showi(pl22,elemN(pl22)-o) == topAr(pc2)+1) { dtoa(pl22,elemN(pl22)-1,pc2); }; }; if(o==8 && d==2 && (elemN(pl23)!=0)) { if (showi(pl23,elemN(pl23)-o) == topAr(pc2)+1) { dtoa(pl23,elemN(pl23)-1,pc2); }; }; if(o==9 && d==2 && (elemN(pl24)!=0)) { if (showi(pl24,elemN(pl24)-o) == topAr(pc2)+1) { dtoa(pl24,elemN(pl24)-1,pc2); }; }; if(o==6 && d==3 && (elemN(pl21)!=0)) { if (showi(pl21,elemN(pl21)-o) == topAr(pc3)+1) { dtoa(pl21,elemN(pl21)-1,pc3); }; }; if(o==7 && d==3 && (elemN(pl22)!=0)) { if (showi(pl22,elemN(pl22)-o) == topAr(pc3)+1) { dtoa(pl22,elemN(pl22)-1,pc3); }; }; if(o==8 && d==3 && (elemN(pl23)!=0)) { if (showi(pl23,elemN(pl23)-o) == topAr(pc3)+1) { dtoa(pl23,elemN(pl23)-1,pc3); }; }; if(o==9 && d==3 && (elemN(pl24)!=0)) { if (showi(pl24,elemN(pl24)-o) == topAr(pc3)+1) { dtoa(pl24,elemN(pl24)-1,pc3); }; }; }; }; n=0; while ((stock2[n]==0) && (n<stk)) { n++; }; // Winner is player 2 if (stock2[n] == 0) { vencedor=1; turno=1; } // Tie if(baralho[num*2-3]==0) { vencedor=3; }; // Clean central stack if(pc1[0]==13) { atoa(pc1,baralho,13); }; if(pc2[0]==13) { atoa(pc2,baralho,13); }; if(pc3[0]==13) { atoa(pc3,baralho,13); }; }; if((vencedor==1)||(vencedor==2)) { clear(); mvprintw(x-1,y-10,"+------------------------------------+"); mvprintw(x,y-10,"|O jogador %d vence! |",vencedor); mvprintw(x+1,y-10,"+------------------------------------+"); getch(); } else { clear(); mvprintw(x-1,y-10,"+------------------------------------+"); mvprintw(x,y-10,"|Empate, não há vencedores. |"); mvprintw(x+1,y-10,"+------------------------------------+"); getch(); }; endwin(); bkgd(COLOR_PAIR(2)); return 0; }
void read_config (void) { char line[80]; char *pToken; char *pLine; unsigned j; // first set defaults for (j=0; j < NUM_TOKENS; j++) { switch (config_lookup[j].type) { case TYPE_INT: { int32_t *pVal = config_lookup[j].pValue; *pVal = config_lookup[j].val_i; break; } case TYPE_DOUBLE: { double *pVal = config_lookup[j].pValue; *pVal = config_lookup[j].val_d; break; } } } /* initialize SPI for SDCard */ spi_init(); /* access to "config.txt" file on SDCard */ FATFS fs; /* Work area (file system object) for logical drive */ FIL file; /* file object */ FRESULT res; /* FatFs function common result code */ /* Register a work area for logical drive 0 */ res = f_mount(0, &fs); if(res) debug("Err mount fs\n"); /* Open config.txt file */ res = f_open(&file, "config.txt", FA_OPEN_EXISTING | FA_READ); if (res) debug("File config.txt not found\n"); else { bool found; pLine = f_gets(line, sizeof(line), &file); /* read one line */ while (pLine) { pToken = get_token (pLine); if (pToken && *pToken != '#') { found = false; for (j=0; (j < NUM_TOKENS) && !found; j++) { if (stricmp (pToken, config_lookup[j].name) == 0) { found = true; pToken = get_token (NULL); if (pToken && (*pToken == '=')) { // get value pToken = get_token (NULL); if (pToken) { switch (config_lookup[j].type) { case TYPE_INT: { int32_t *pVal = config_lookup[j].pValue; *pVal = atoi (pToken); break; } case TYPE_DOUBLE: { double *pVal = config_lookup[j].pValue; *pVal = atod(pToken); break; } } // debug //sersendf ("Found: %s = %d\r\n", config_lookup[j].name, *config_lookup[j].pValue); } else sersendf ("Missing value for %s\r\n", config_lookup[j].name); } else sersendf ("Expected '='%s\r\n", line); } } if (!found) sersendf ("Unknown config: %s\r\n", pToken); } pLine = f_gets(line, sizeof(line), &file); /* read next line */ } /* Close config.txt file */ res = f_close(&file); if (res) debug("Error closing config.txt\n"); } // //read_gcode_file ("autoexec.g"); res = f_open(&file, "autoexec.g", FA_OPEN_EXISTING | FA_READ); if (res == FR_OK) { tLineBuffer line_buf; pLine = f_gets(line_buf.data, sizeof(line_buf.data), &file); /* read one line */ while (pLine) { line_buf.len = strlen(pLine); gcode_parse_line (&line_buf); pLine = f_gets(line_buf.data, sizeof(line_buf.data), &file); /* read next line */ } /* Close file */ res = f_close(&file); if (res) debug("Error closing autoexec.g\n"); } // /* Initialize using values read from "config.txt" file */ gcode_parse_init(); }
static int dblcmpn(char *val,char *s,char n) { double d1,d2; return s_tokcmpn(val,s,n)==0?0 : s_tokcmpn(val,"NaN",3)==0||s_tokcmpn("NaN",s,n)==0?1 : (d1=atod(val),d2=atodn(s,n),d1<d2?-1:d1>d2?1:0); }
void CRegDlg::TestOK() { //执行了什么操作 1,删除项 2,新建项 3,删除键 4, 新建键 5,编辑键 if(how==1){ while(m_tree.GetChildItem(SelectNode)!=NULL) { m_tree.DeleteItem(m_tree.GetChildItem(SelectNode)); //删除 会产生 OnSelchangingTree事件 *** } m_tree.DeleteItem(SelectNode); how=0; }else if(how==2) { m_tree.InsertItem(Path,1,1,SelectNode,0);//插入子键名称 m_tree.Expand(SelectNode,TVE_EXPAND); Path=""; }else if(how==3){ m_list.DeleteItem(index); index=0; }else if(how==4){ int nitem; DWORD d; char ValueDate[256]; CString value; ZeroMemory(ValueDate,256); switch(type){ case MREG_SZ: //加了字串 nitem=m_list.InsertItem(0,Key,0); m_list.SetItemText(nitem,1,"REG_SZ"); m_list.SetItemText(nitem,2,Value); break; case MREG_DWORD: //加了DWORD d=atod(Value.GetBuffer(0)); //Value.ReleaseBuffer(); value.Format("0x%x",d); sprintf(ValueDate," (%wd)",d); value+=" "; value+=ValueDate; nitem=m_list.InsertItem(0,Key,1); m_list.SetItemText(nitem,1,"REG_DWORD"); m_list.SetItemText(nitem,2,value); break; case MREG_EXPAND_SZ: nitem=m_list.InsertItem(0,Key,0); m_list.SetItemText(nitem,1,"REG_EXPAND_SZ"); m_list.SetItemText(nitem,2,Value); break; default: break; } }else if(how==5){ int nitem; DWORD d; char ValueDate[256]; CString value; ZeroMemory(ValueDate,256); switch(type){ case MREG_SZ: //加了字串 m_list.SetItemText(index,2,Value); break; case MREG_DWORD: //加了DWORD d=atod(Value.GetBuffer(0)); //Value.ReleaseBuffer(); value.Format("0x%x",d); sprintf(ValueDate," (%wd)",d); value+=" "; value+=ValueDate; m_list.SetItemText(index,2,value); break; case MREG_EXPAND_SZ: m_list.SetItemText(index,2,Value); break; default: break; } } how=0; }
noreturn int main(rargc, rargv) { TWO_ARGS_REQUIRED_F; printf("%.5f\n", cosh(atod(argv[1]))); fast_exit(EXIT_SUCCESS); }