void main (int argc, char* argv[]) { struct param parms; struct input in; int t,iter,i=0; int pos = 0; double h = 0.00025; float var_parms[6]; float parm; t = atoi(argv[1]); FILE *parmfile = fopen(argv[2],"r"); while(fscanf(parmfile,"%f\n",&parm) != EOF) { var_parms[i] = parm; printf("%f\n",var_parms[i]); i++; } setparms(&parms,var_parms); in.T_load = 0; fd = fopen("model_data","w"); motor_eq(t,&in,&parms,h); return; }
int CKTXSerialPortCtrl::OpenCom(int iPort,int iBraudrate/*=115200*/,int iByteSize/*=8*/,int iParity/*=0*/ ,int iStopBits/*=1*/,int iContorl/*=0*/) { CMyMutex::CAutoLock lock(m_mutex); if(ERR_KEY != m_iFD) return KTX_SUCCESS; if(0==(iPort&0xFF)) return KTX_ERR; char csDevPath[100]={0}; if(iPort&0x0F00) sprintf(csDevPath,"/dev/ttyUSB%d",(iPort&0xFF)-1); else if(iPort&0xF000) sprintf(csDevPath,"/dev/ttySNX%d",(iPort&0xFF)-1); else sprintf(csDevPath,"/dev/ttyS%d",iPort-1); int iRet = KTX_ERR; m_iFD = open(csDevPath,O_RDWR|O_NOCTTY|O_NDELAY); if(m_iFD<0) return iRet; if(fcntl(m_iFD,F_SETFL,0)<0) { CloseCom(); return iRet; } setparms(m_iFD, iBraudrate, iParity, iByteSize, iStopBits, iContorl, iContorl); // SetSerialPort(m_iFD,iBraudrate,iByteSize,iParity,iStopBits,iContorl); return KTX_SUCCESS; }
char *infotocap(char *value, int *err) { char args[4]; char *savevalue; *err = 0; if (strchr(value, '%') == NULLPTR) return (value); setparms(); savevalue = value; while (*value) if (*value != '%') *newvalue++ = *value++; else if (lookat(value, "%p*%d", args)) { if (checkparms(args[0])) goto dobyhand; (void) strcpy(newvalue, "%d"); newvalue += 2; value += 5; } else if (lookat(value, "%p*%02d", args)) { if (checkparms(args[0])) goto dobyhand; (void) strcpy(newvalue, "%2"); newvalue += 2; value += 7; } else if (lookat(value, "%p*%03d", args)) { if (checkparms(args[0])) goto dobyhand; (void) strcpy(newvalue, "%3"); newvalue += 2; value += 7; } else if (lookat(value, "%p*%2.2d", args)) { if (checkparms(args[0])) goto dobyhand; (void) strcpy(newvalue, "%2"); newvalue += 2; value += 8; } else if (lookat(value, "%p*%3.3d", args)) { if (checkparms(args[0])) goto dobyhand; (void) strcpy(newvalue, "%3"); newvalue += 2; value += 8; } else if (lookat(value, "%p*%c", args)) { if (checkparms(args[0])) goto dobyhand; (void) strcpy(newvalue, "%."); newvalue += 2; value += 5; } else if (lookat(value, "%p*%'*'%+%c", args)) { if (checkparms(args[0])) goto dobyhand; (void) sprintf(newvalue, "%%+%c", args[1]); newvalue += 3; value += 11; } else if (lookat(value, "%i", args)) { (void) strcpy(newvalue, "%i"); newvalue += 2; value += 2; } else if (lookat(value, "%%", args)) { (void) strcpy(newvalue, "%%"); newvalue += 2; value += 2; } else if (lookat(value, "p*%'*'%>%+%p*%'*'%+%;", args)) { if (args[0] != args[2]) goto dobyhand; if (checkparms(args[0])) goto dobyhand; (void) sprintf(newvalue, "%%>%c%c", args[1], args[3]); newvalue += 2; value += 21; } else goto dobyhand; *newvalue = '\0'; return (&_newvalue[BYHANDMSGLEN]); dobyhand: (void) strcpy(&_newvalue[BYHANDMSGLEN], savevalue); *err = 1; return (_newvalue); }
int main(int argc, char **argv) { char word[MAXWORDSIZE]; char cmd[MAXWORDSIZE]; /* string to hold a command */ char fname[MAXWORDSIZE]; /* name of input file */ PAGENO i; int goOn; int k; setparms(); /* reads the pagesize and the number of ptrs/postigs_record */ dbopen(); /* opens or creates the three files (btree, postings, text) */ goOn = TRUE; while (goOn) { printf("\n\t*** These are your commands .........\n"); printf("\t\"C\" to scan the tree\n"); printf("\t\"i\" to insert\n"); printf("\t\"p\" to print a btree page\n"); printf("\t\"s\" to search, and print the key\n"); printf("\t\"S\" to search, and print the key, posting list pairs\n"); printf("\t\">\" to print k successors\n"); printf("\t\"<\" to print k predecessors\n"); printf("\t\"T\" to print the btree in inorder format\n"); printf("\t\"#\" to reset and print stats\n"); printf("\t\"x\" to exit\n"); /* printf("\"d\" to display statistics, \"c\" to clear them,\n"); */ scanf("%s", cmd); assert(strlen(cmd) < MAXWORDSIZE); switch (cmd[0]) { case 'C': printf("\n*** Scanning... \n"); scanTree(&printOcc); break; case 'i': printf("\tgive input file name: "); scanf("%s", fname); assert(strlen(fname) < MAXWORDSIZE); printf("\n*** Inserting %s\n", fname); insert(fname); break; case 's': printf("enter search-word: "); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); printf("\n*** Searching for word %s \n", word); search(word, FALSE); break; case 'S': printf("enter search-word: "); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); printf("\n*** Searching for word %s \n", word); search(word, TRUE); break; case 'p': printf("pagenumber=?\n"); scanf("%s", cmd); assert(strlen(cmd) < MAXWORDSIZE); i = (PAGENO) atoi(cmd); printPage(i, fpbtree); break; case '>': printf("word=?\n"); scanf("%s", word); printf("k=?\n"); scanf("%d", &k); get_successors(word, k, NULL); break; case '<': printf("word=?\n"); scanf("%s", word); printf("k=?\n"); scanf("%d", &k); get_predecessors(word, k, NULL); break; case 'T': printf("\n*** Printing tree in order .........\n"); PrintTreeInOrder(ROOT, 0); break; case '#': printf("\n"); printFetchPageCnt(); printf("\n...reseted FetchPage counter\n"); break; case 'x': printf("\n*** Exiting .........\n"); goOn = FALSE; break; default: printf("\n*** Illegal command \"%s\"\n", cmd); break; } } dbclose(); return (0); }
int main(int argc, char **argv) { char word[MAXWORDSIZE]; char result[MAXWORDSIZE]; char temp[MAXWORDSIZE]; char cmd[MAXWORDSIZE]; /* string to hold a command */ char fname[MAXWORDSIZE]; /* name of input file */ PAGENO i; int goOn; // int k; setparms(); /* reads the pagesize and the number of ptrs/postigs_record */ dbopen(); /* opens or creates the three files (btree, postings, text) */ goOn = TRUE; while (goOn) { printf("\n\t*** These are your commands .........\n"); printf("\t\"C\" to scan the tree\n"); printf("\t\"i\" to insert\n"); printf("\t\"p\" to print a btree page\n"); printf("\t\"s\" to search, and print the key\n"); printf("\t\"S\" to search, and print the key, posting list pairs\n"); printf("\t\"]\" to print next key without given prefix\n"); printf("\t\"[\" to print previous key without given prefix\n"); printf("\t\"T\" to print the btree in inorder format\n"); printf("\t\"#\" to reset and print stats\n"); printf("\t\"x\" to exit\n"); /* printf("\"d\" to display statistics, \"c\" to clear them,\n"); */ scanf("%s", cmd); assert(strlen(cmd) < MAXWORDSIZE); switch (cmd[0]) { case 'C': printf("\n*** Scanning... \n"); scanTree(&printOcc); break; case 'i': printf("\tgive input file name: "); scanf("%s", fname); assert(strlen(fname) < MAXWORDSIZE); printf("\n*** Inserting %s\n", fname); insert(fname); break; case 's': printf("enter search-word: "); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); printf("\n*** Searching for word %s \n", word); search(word, FALSE); break; case 'S': printf("enter search-word: "); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); printf("\n*** Searching for word %s \n", word); search(word, TRUE); break; case 'p': printf("pagenumber=?\n"); scanf("%s", cmd); assert(strlen(cmd) < MAXWORDSIZE); i = (PAGENO) atoi(cmd); printPage(i, fpbtree); break; case ']': printf("word=?\n"); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); strcpy(temp, word);; get_rightbracket(word, result); printf("Right bracket of %s:\n%s\n", temp,result); break; case '[': printf("word=?\n"); scanf("%s", word); assert(strlen(word) < MAXWORDSIZE); // strcpy(temp, word);; get_leftbracket(word, result); printf("Left bracket of %s:\n%s\n", word,result); break; break; case 'T': printf("\n*** Printing tree in order .........\n"); PrintTreeInOrder(ROOT, 0); break; case '#': printf("\n*** #of reads on B-tree: %d", countPageFetch); countPageFetch = 0; break; case 'x': printf("\n*** Exiting .........\n"); goOn = FALSE; break; default: printf("\n*** Illegal command \"%s\"\n", cmd); break; } } dbclose(); return (0); }