int NodeCollection_printToFile(char* file_path, char* title, NodeCollection* nc){ int success = 0; if(NodeCollection_isValid(nc)){ FILE* file = fopen(file_path,"a+"); if(file){ char ts[64]; writeTimestamp(ts); fprintf(file, "%s: %s\n",title, ts); int k; for (k = 0 ; k < nc->nodeCount ; k++){ fprintf(file ,"%d \t - %d \t %f \t %f \t %d \t %d \t %d \t %d \t %d \t %d \n", k, nc->nodes[k].nodeID, nc->nodes[k].lat, nc->nodes[k].lon, nc->nodes[k].coordRange, nc->nodes[k].ipAddr, nc->nodes[k].port, nc->nodes[k].radac_ip, nc->nodes[k].radac_port, nc->nodes[k].timeStamp ); } fprintf(file, "\n"); success = 1; fclose(file); } } else { success = 0; } return success; };
int main(void) { int numOfThreads = 5; int i; int count = 0; char* data = readFileAsString("data.in"); count = countCommas(data) + 1; int chunkCount = initArrayAndChuckTbl(count); splitStringIntoArray(data, sortArray, count); pthread_barrier_init(&sortSync, NULL, numOfThreads + 1); pthread_t threads[numOfThreads]; writeTimestamp(); printf("Create %d threads\n", numOfThreads); for (i = 0; i < numOfThreads; i++) { pthread_create(&threads[i], NULL, sorting_thread, (void *)i); } pthread_barrier_wait(&sortSync); puts("All Threads Done"); puts("\nStart of merge\n"); merge(chunkCount); puts("End of merge\n"); return EXIT_SUCCESS; }
void MessageEncoder::writeProperties(const Properties& msg) { size_t fields(optimise ? optimisable(msg) : 13); if (fields) { void* token = startList32(&qpid::amqp::message::PROPERTIES); if (msg.hasMessageId()) writeString(msg.getMessageId()); else writeNull(); if (msg.hasUserId()) writeBinary(msg.getUserId()); else if (fields > 1) writeNull(); if (msg.hasTo()) writeString(msg.getTo()); else if (fields > 2) writeNull(); if (msg.hasSubject()) writeString(msg.getSubject()); else if (fields > 3) writeNull(); if (msg.hasReplyTo()) writeString(msg.getReplyTo()); else if (fields > 4) writeNull(); if (msg.hasCorrelationId()) writeString(msg.getCorrelationId()); else if (fields > 5) writeNull(); if (msg.hasContentType()) writeSymbol(msg.getContentType()); else if (fields > 6) writeNull(); if (msg.hasContentEncoding()) writeSymbol(msg.getContentEncoding()); else if (fields > 7) writeNull(); if (msg.hasAbsoluteExpiryTime()) writeTimestamp(msg.getAbsoluteExpiryTime()); else if (fields > 8) writeNull(); if (msg.hasCreationTime()) writeTimestamp(msg.getCreationTime()); else if (fields > 9) writeNull(); if (msg.hasGroupId()) writeString(msg.getGroupId()); else if (fields > 10) writeNull(); if (msg.hasGroupSequence()) writeUInt(msg.getGroupSequence()); else if (fields > 11) writeNull(); if (msg.hasReplyToGroupId()) writeString(msg.getReplyToGroupId()); else if (fields > 12) writeNull(); endList32(fields, token); } }
void VBIDecoder::flushPage(Timestamp& endTS) { if (*fileName != 0) { if (startTimestamp.base < endTS.base) { fprintf(fpxml, "<spu start="); writeTimestamp((double)startTimestamp); fprintf(fpxml, " end="); writeTimestamp((double)endTS); fprintf(fpxml, " image=\"%s\"", fileName); fprintf(fpxml, " xoffset=\"%d\"", xOffset); fprintf(fpxml, " yoffset=\"%d\"", yOffset); fprintf(fpxml, ">\n<!--\n"); fwrite(textBuf, textBytes, 1, fpxml); fprintf(fpxml, "\n--></spu>\n"); if (ferror(fpxml)) { fflush(fplog); fprintf(stderr, "Error writing XML file\n"); fflush(stderr); exit(1); } if (verbose) fflush(fpxml); } else if (verbose) { fprintf(fplog, "Ignoring file=%s start(%.4f) >= end(%.4f)\n", fileName, (double)startTimestamp, (double)endTS); fflush(fplog); } *fileName = 0; } }
void *sorting_thread(void *threadNumber) { int thread_num = (int)(threadNumber); printf("Thread %d starting\n", thread_num); chuck_data_t* chuck = getNextChuck(); while (chuck != NULL) { writeTimestamp(); printf("Thread %d starts work on chuck %d\n", thread_num, chuck->chuckNumber); char* fileName = (char*) calloc (sizeof(char), 15); sprintf(fileName, "chuck%d", chuck->chuckNumber); crapSort((int*)(sortArray + 1024*chuck->chuckNumber), 1024); writeCDF((int*)(sortArray + 1024*chuck->chuckNumber), 1024, fileName); chuck = getNextChuck(); } pthread_barrier_wait(&sortSync); pthread_exit(NULL); }
void MfConnection::fetchPlaybackRequest() { QDataStream socketStream(socket); QString feedbackName; socketStream >> feedbackName; if (socketStream.status() != QDataStream::Ok) { terminate(); return; } if (timeStamping()) { writeTimestamp("daemon_play"); } if (!session->feedbackHash.contains(feedbackName)) { // Feedback not found, do nothing return; } session->feedbackHash.value(feedbackName)->emitPlay(getTimestamp()); }
RDCart::~RDCart() { if(metadata_changed) { writeTimestamp(); } }