/* Creates the html form with the table. */ void RemoteHomeWifi::createTableWithForm(const char* title, const char* action) { outputString += F("<FORM action='"); concatString(action); outputString += F("' method='GET'><table><tr><th colspan='2'>"); concatString(title); outputString += F("</th></tr>"); }
END_TEST START_TEST(concatString2) { #line 70 char* str1; char* str2; char* str3; char* expected; char* observed; char* test; test = "beginning middle end"; str1 = getSubString(test, 0, 9); str2 = getSubString(test, 10, 15); str3 = getSubString(test, 16, 19); expected = "beginning middle end"; char* half; half = concatString(str1, str2); observed = concatString(half, str3); fail_unless(strcmp(expected,observed) == 0, "not equal strings"); fail_unless(stringLength(test) == 20, "fail"); }
/* Creates the label and text box withing the html table form. */ void RemoteHomeWifi::createTextBoxTableRow(const char* title, const char* action, char* value, const char* maxSize) { outputString += F("<tr><td>"); concatString(title); outputString += F("</td><td><input name='"); concatString(action); outputString += F("' type='text' maxSize='"); concatString(maxSize); outputString += F("' value='"); outputString += value; outputString += F("'/></td></tr>"); }
int main(void) { JavaVMInitArgs vmargs; JavaVM *vm; void *env; JavaVMOption myoptions[1]; /* set up libtool/libltdl dlopen emulation */ LTDL_SET_PRELOADED_SYMBOLS(); myoptions[0].optionString = concatString("-Xbootclasspath:", getenv("BOOTCLASSPATH")); vmargs.version = JNI_VERSION_1_2; if (JNI_GetDefaultJavaVMInitArgs (&vmargs) < 0) { fprintf(stderr, " Cannot retrieve default arguments\n"); return 1; } vmargs.nOptions = 1; vmargs.options = myoptions; if (JNI_CreateJavaVM (&vm, &env, &vmargs) < 0) { fprintf(stderr, " Cannot create the Java VM\n"); return 1; } (*vm)->DestroyJavaVM(vm); return 0; }
char * serializeInt(int v , int spacesToFix , HeapHandler hh){ char * result = intToString(v , hh); while((int)strlen(result) <spacesToFix) result = concatString("0" , result , hh); return result; }
int main(int argc, char const *argv[]) { string * hello = newString("hello"); string * world = newString(" world"); string * helloWorld = concatString(hello, world); string * vide = newString(NULL); string * empty = newString(NULL); string * coucou = appendString(helloWorld, "!\n" ); printString(stdout, hello); printString(stdout, coucou); string * total = concatString(coucou, vide); string * total2 = concatString(empty, total); destroyString(total2); return 0; }
pStr cpw_localhost_fontpath( void ) { pStr path; char buf[4096]; path = null; /* GetWindowsDirectory( buf, 4096 ); */ setString( &path, buf ); concatString( &path, "\\fonts\\" ); return path; }
void printBoard(int **board) { int intSize = sizeof(int); int numRows = (sizeof(board) / intSize) + 1; char *underscors = "----"; char *conUnderscors = ""; for(int i=0; i<numRows; i++) { conUnderscors = concatString(conUnderscors,underscors); } // we need to add one last underscore char *underscor = "-"; conUnderscors = concatString(conUnderscors, underscor); printf("%s\n", conUnderscors); for(int row=0; row<numRows; row++) { printf("|"); int numCols = (sizeof(board[row]) / intSize) + 1; for (int col=0; col<=numCols; col++) { if (col == numCols) { printf("\n%s\n", conUnderscors); } else { switch(board[row][col]) { case 0: printf(" |"); continue; case PLAYER_ONE_VAL: printf(" %s |", PLAYER_ONE); continue; case PLAYER_TWO_VAL: printf(" %s |", PLAYER_TWO); continue; default: printf(" |"); } } } } }
END_TEST START_TEST(concatString1) { #line 57 char* str1; char* str2; char* expected; char* observed; str1 = "var "; str2 = "var"; expected = "var var"; observed = concatString(str1, str2); fail_unless(strcmp(expected,observed) == 0, "not equal strings"); }
int cpytuple(buffer *b,char *tuple,FILE *p){ int o; int count = 0; int jj = 0; int tTam = 0; //variais de controle char *bh = NULL; bh = aloca(bh); union c_double vdouble; union c_int vint; for(o = 0;o<tamanho;o++){ if(vr[jj].tipo == 'S'){ if(tTam == 0){ tTam = vr[jj].tam; } if(tTam != vr[jj].tam){ //copia uma string de tamanho definido tTam = vr[jj].tam; fread(bh,sizeof(char),vr[jj].tam,p); o = (vr[jj].tam + o) - 1; count = count + vr[jj].tam; concatString(tuple,bh,o - vr[jj].tam +1); bh = aloca(bh); } else{ //copia string fread(bh,sizeof(char),vr[jj].tam,p); o = (vr[jj].tam + o) -1; count = count + vr[jj].tam; concatString(tuple,bh, o - vr[jj].tam +1); bh = aloca(bh); } } else if(vr[jj].tipo == 'D'){ double k; //copia do arquivo um dado double if(tTam != vr[jj].tam) tTam = vr[jj].tam; fread(&k,sizeof(double),1,p); vdouble.numd = k; cpyvar(tuple,vdouble.cnumd,o,sizeof(double)); o = (vr[jj].tam + o) - 1; count = count + vr[jj].tam; } else{ int l; //copia um dado tipo int if(tTam != vr[jj].tam) tTam = vr[jj].tam; fread(&l,sizeof(int),1,p); vint.num = l; cpyvar(tuple,vint.cnum,o,sizeof(int)); o = (vr[jj].tam + o) - 1; count = count + vr[jj].tam; } if(count >=vr[jj].tam-1){ jj++; count = 0; } } free(bh); if(cpytoBuffer(b,tuple) == 0) return 0; return -1; }
//main processing function // controlling flow for collecting data // from each alignment int processline(string line) { // variable definition stringList columns, deletions, insertions, mismatchList; string softclippedHead, softclippedTail; numList baseCounter, deletionBaseCounter, insertionBaseCounter, mismatchBaseCounter; numList headClippedBaseCounter, tailClippedBaseCounter; string chrom, id, sequence,quality; string deletionsString, insertionString, clippedString; string XGfield = "A", NMfield, MDfield; int numberOfMismatch, numberOfGapExtention; string cigarString, MDline, cigarLine; int i, seqlength, headClipped = 0, tailClipped = 0; double averageQualityScore, head5Qual, end5Qual; columns = split(line,'\t'); chrom = columns[2]; // only collect data from aligned reads if (chrom != "*") { //define columns id = columns[0]; cigarString = columns[5]; sequence = columns[9]; quality = columns[10]; seqlength = sequence.length(); baseCounter = getBaseCount(sequence); // collect base content averageQualityScore = averageQual(quality); // whole sequence quality head5Qual = averageQual(quality.substr(0,5)); // first 5 base quality end5Qual = averageQual(quality.substr(seqlength-5,5)); //end 5 base quality //define extra field // for XG, NM and MD findField(columns, XGfield, NMfield, MDfield); //get field item numberOfMismatch = atoi(extractField(NMfield).c_str()); if (XGfield.at(0) == 'X') { numberOfGapExtention = atoi(extractField(XGfield).c_str()); } else { numberOfGapExtention = 0; } // creating a line using MDfield MDline = processMD(MDfield, deletions); cigarLine = processCigar(cigarString, headClipped, tailClipped); mismatchList = insertionAndMismatch(cigarLine, MDline, sequence, insertions, softclippedHead, softclippedTail, id, numberOfMismatch); mismatchBaseCounter = getMismatchCount(mismatchList); int sumOfMismatch = std::accumulate(mismatchBaseCounter.begin(), mismatchBaseCounter.end(), 0); //count deletion and insertion deletionsString = concatString(deletions); insertionString = concatString(insertions); deletionBaseCounter = getBaseCount(deletionsString); insertionBaseCounter = getBaseCount(insertionString); headClippedBaseCounter = getBaseCount(softclippedHead); tailClippedBaseCounter = getBaseCount(softclippedTail); //assertions for verifying program assert (softclippedTail.length() == tailClipped); assert (softclippedHead.length() == headClipped); assert(accumulate(baseCounter.begin(),baseCounter.end(),0) == seqlength); //assert(sumOfMismatch + numberOfGapExtention == numberOfMismatch); // print out result cout << id << "\t"; //print out base counts printBase(baseCounter) ; cout << averageQualityScore << "\t" << head5Qual << "\t" << end5Qual << "\t"; cout << numberOfGapExtention << "\t" << numberOfMismatch - numberOfGapExtention << "\t"; //print mismatch // AtoC, AtoT, AtoG, CtoA, CtoT, CtoG, GtoA, GtoT, GtoC, TtoA,TtoC, TtoG printBase(mismatchBaseCounter); // print out deletion printBase(deletionBaseCounter) ; printBase(insertionBaseCounter) ; cout << headClipped << "\t" << tailClipped << "\t"; printBase(headClippedBaseCounter); printBase(tailClippedBaseCounter); cout << seqlength; cout << '\n'; } return 0; }
//write character string into newly created file //returns number of bytes written int Write_File(int inode_number, int offset, char* to_write, int bytes) { //make sure inode is valid file to read from Inode curNode = Inode_Read(inode_number); if ((curNode.Inode_Number == -1) || (curNode.Flag != 1)) { printf("Error, Inode is invalid\n"); return -1; } //inode is not a valid file/is not open //make sure we're adding onto the end of the file if (offset != curNode.File_Size) { printf("Error, writing to an invalid offset\n"); return -1; } //trying to write to an invalid offset //make sure we have enough space to write the string int endBlock = curNode.End_Block; if (endBlock == -1) { Super_block curSuper = Superblock_Read(); endBlock = curSuper.next_free_block; } int totalBytes = bytes; //total number of bytes if ((curNode.File_Size % 512) != 0) //look at existing block space { totalBytes += curNode.File_Size % 512; totalBytes -= 512; } endBlock += totalBytes / 512; //additional full blocks needed if ((totalBytes % 512) != 0) {endBlock++;} //overflow into next block if (endBlock > 8191) { printf("Error, not enough memory for file\n"); return -1; } //we don't have enough blocks //if this is a new file, set up inode with next free block int curBlock = curNode.End_Block; int bytesWritten = 0; totalBytes = bytes; Super_block curSuper = Superblock_Read(); if (curBlock == -1) { curBlock = curSuper.next_free_block++; Superblock_Write(curSuper); curNode.Start_Block = curBlock; Inode_Write(inode_number, curNode); } //fill up last file block if it is not full yet if ((curNode.File_Size % 512) != 0) { int curLength = curNode.File_Size % 512; int fillLength = 512 - curLength; if (bytes < fillLength) {fillLength = bytes;} int totalLength = curLength + fillLength; char curString[totalLength]; if (Block_Read(curBlock, curLength, curString) != curLength) { printf("Error, could not read block\n"); return -1; } //error filling up block if (concatString(curString, to_write, curLength, fillLength) != fillLength) { printf("Error, could not copy string portion\n"); return -1; } //error filling up block if (Block_Write(curBlock, totalLength, curString) != totalLength) { printf("Error, could not write to block\n"); return -1; } //error writing to block to_write += fillLength; bytesWritten += fillLength; curNode.File_Size += bytesWritten; if (bytesWritten != bytes) { curBlock = curSuper.next_free_block++; Superblock_Write(curSuper); } } int bytesLeft = bytes - bytesWritten; int totalBytesWritten = bytesWritten; while(bytesLeft) { bytesWritten = Block_Write(curBlock, (bytesLeft > 512 ? 512:bytesLeft), to_write); if(bytesWritten == 0) { printf("Error, could not write to block\n"); return -1; } bytesLeft -= bytesWritten; to_write += bytesWritten; totalBytesWritten += bytesWritten; curNode.File_Size += bytesWritten; if (bytesLeft) { curBlock = curSuper.next_free_block++; Superblock_Write(curSuper); } } curNode.End_Block = curBlock; Inode_Write(inode_number, curNode); return totalBytesWritten; }