void throughPutTest(void) { static enum {INIT,LOADING} state = INIT; static whoPacket_t clear = {CLEAR_STATS}, get = {GET_STATS}; switch(state) { case INIT: clear.who.to = testdest; clear.who.from = whoami(); if (sendNormalPacketLink((Byte *)&clear, sizeof(clear), loadLink)) { whoPacket_t *wp = (whoPacket_t *)testPacket; print ("\nstarting throughput test..."); flush(); setPacketHandler(STATS, testResults); state = LOADING; framesOut = packetsInGroup; setTimeout(0, &testLength_to); setTimeout(1 TO_SEC, &sendwait_to); get.who.to = testdest; get.who.from = whoami(); wp->who.to = testdest; wp->who.from = whoami(); } break; case LOADING: if (framesOut) { bool flag; if (loadLink->enableSps) flag = sendSecurePacketLink(testPacket, sizeof(testPacket), loadLink); else flag = sendNormalPacketLink(testPacket, sizeof(testPacket), loadLink); if (flag) { framesOut--; setTimeout(1 TO_SEC, &sendwait_to); } if (checkTimeout(&sendwait_to)) { print ("\n timedout - "); printDec((Long)sinceTimeout(&testLength_to)); print(" ms; giving up throughput test\n"); state = INIT; return; } } else if (sendNormalPacketLink((Byte *)&get, sizeof(get), loadLink)) { state = INIT; print (" done. getting results..."); flush(); return; } break; } activate(throughPutTest); }
int main(int argc, char *argv[]) { int sysnum; if(argc != 2){ fprintf(stderr, "Usage %s <syscall number>\n", argv[0]); exit(1); } sysnum = atoi(argv[1]); if(sysnum < 0){ fprintf(stderr, "Invalid syscall number [%d]\n", sysnum); exit(1); } whoami(); if(syscall(sysnum) == -1) { fprintf(stderr, "Error calling syscall: %s\n", strerror(errno)); exit(1); } whoami(); return 0; }
void JetpackUI::cb_switch_to_saver(Fl_Menu_* o, void* v) { if (!whoami(o)->m_editor->Playable()){ fl_alert("You must place both a hero and a door before you save.\n"); return; } whoami(o)->m_saver->addImage(); whoami(o)->switch_contexts(whoami(o)->m_save_group); }
void ImpressionistUI::cb_swap_view(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc = whoami(o)->getDocument(); unsigned char* tmp = pDoc->m_ucBitmap; pDoc->m_ucBitmap = pDoc->m_ucPainting; pDoc->m_ucPainting = tmp; whoami(o)->m_origView->refresh(); whoami(o)->m_paintView->refresh(); }
//Filter Kernerl用 void ImpressionistUI::cb_filter_kernel(Fl_Menu_* o, void* v) { ImpressionistDoc* pDoc=whoami(o)->getDocument(); if (pDoc->m_ucPainting != NULL) { memcpy( pDoc->m_ucPreviewBackup, pDoc->m_ucPainting, pDoc->m_nPaintWidth * pDoc->m_nPaintHeight * 3 ); whoami(o)->fltDesignUI->show(); } else fl_alert("Must load an image first!"); }
AgpsState* AgpsReleasedState::onRsrcEvent(AgpsRsrcStatus event, void* data) { LOC_LOGD("AgpsReleasedState::onRsrcEvent; event:%d\n", (int)event); if (mStateMachine->hasSubscribers()) { LOC_LOGE("Error: %s subscriber list not empty!!!", whoami()); // I don't know how to recover from it. I am adding this rather // for debugging purpose. } AgpsState* nextState = this; switch (event) { case RSRC_SUBSCRIBE: { // no notification until we get RSRC_GRANTED // but we need to add subscriber to the list mStateMachine->addSubscriber((Subscriber*)data); // request from connecivity service for NIF //The if condition is added so that if the data call setup fails //for DS State Machine, we want to retry in released state. //for AGps State Machine, sendRsrcRequest() will always return success if(!mStateMachine->sendRsrcRequest(GPS_REQUEST_AGPS_DATA_CONN)) { // move the state to PENDING nextState = mPendingState; } } break; case RSRC_UNSUBSCRIBE: { // the list should really be empty, nothing to remove. // but we might as well just tell the client it is // unsubscribed. False tolerance, right? Subscriber* subscriber = (Subscriber*) data; Notification notification(subscriber, event, false); subscriber->notifyRsrcStatus(notification); } // break; case RSRC_GRANTED: case RSRC_RELEASED: case RSRC_DENIED: default: LOC_LOGW("%s: unrecognized event %d", whoami(), event); // no state change. break; } LOC_LOGD("onRsrcEvent, old state %s, new state %s, event %d", whoami(), nextState->whoami(), event); return nextState; }
void ImpressionistUI::cb_filter_kernel(Fl_Menu_* o, void* v) { ImpressionistDoc* pDoc=whoami(o)->getDocument(); // Need to back up the current paint view status // so we can easily preview filters //If no image has been loaded, do not open filter kernel if (pDoc->m_ucPainting != NULL) { memcpy( pDoc->m_ucPreviewBackup, pDoc->m_ucPainting, pDoc->m_nPaintWidth * pDoc->m_nPaintHeight * 3 ); whoami(o)->fltDesignUI->show(); } else fl_alert("Must load an image first!"); }
void main(int argc,char* argv[]){ char* outName; /*申请内存,调用char类型*/ outName = (char*)malloc(sizeof(char)*23); whoami(outName,23); printf("%s\n",outName); }
//--------------------------------- Callback Functions -------------------------------------------- void GraphicalUI::cb_load_scene(Fl_Menu_* o, void* v) { GraphicalUI* pUI=whoami(o); static char* lastFile = 0; char* newfile = fl_file_chooser("Open Scene?", "*.ray", NULL ); if (newfile != NULL) { char buf[256]; if (pUI->raytracer->loadScene(newfile)) { sprintf(buf, "Ray <%s>", newfile); stopTracing(); // terminate the previous rendering } else{ sprintf(buf, "Ray <Not Loaded>"); } pUI->m_mainWindow->label(buf); pUI->m_debuggingWindow->m_debuggingView->setDirty(); if( lastFile != 0 && strcmp(newfile, lastFile) != 0 ) pUI->m_debuggingWindow->m_debuggingView->resetCamera(); pUI->m_debuggingWindow->redraw(); } }
void JetpackUI::cb_clear(Fl_Menu_* o, void* v) { if (fl_ask("Are you sure you want to clear the current level?") == 0) { // NO return; } whoami(o)->m_editor->Clear(); }
void ImpressionistUI::cb_edge_view(Fl_Menu_* o, void* v) { ImpressionistUI *pUI = whoami(o); pUI->m_origView->viewMode = OriginalView::EDGE_MODE; pUI->m_origView->refresh(); }
int main() { char s[30]; whoami(s,30); printf("%s\n",s); return 0; }
//------------------------------------------------------------ // Orig view // Called by the UI when the Original View button is pressed //------------------------------------------------------------ void ImpressionistUI::cb_orig_view(Fl_Menu_* o, void* v) { ImpressionistUI *pUI = whoami(o); //display the orig image pUI->m_origView->viewMode = OriginalView::ORIG_MODE; pUI->m_origView->refresh(); }
void ImpressionistUI::cb_load_dissolve_image(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc = whoami(o)->getDocument(); char* newfile = fl_file_chooser("Open File?", "*.bmp", pDoc->getImageName()); if (newfile != NULL) { pDoc->loadDissolveImage(newfile); } }
void ImpressionistUI::cb_another_view(Fl_Menu_* o, void* v) { ImpressionistUI *pUI = whoami(o); ImpressionistDoc *pDoc = pUI->getDocument(); if (pDoc->m_ucAnother) pUI->m_origView->viewMode = OriginalView::ANOTHER_MODE; pUI->m_origView->refresh(); }
//------------------------------------------------------------------ // Brings up a file chooser and then saves the painted image // This is called by the UI when the save image menu item is chosen //------------------------------------------------------------------ void ImpressionistUI::cb_save_image(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc=whoami(o)->getDocument(); const char* filename = pDoc->m_pUI->fileDialog( Fl_Native_File_Chooser::BROWSE_SAVE_FILE, "PNG Image File (*.png)\t*.png\nJPEG Image File (*.jpg)\t*.jpg"); if(filename) { std::string strFileName = (std::string)filename; std::string ext; int quality = 95; switch(pDoc->m_pUI->m_nativeChooser->filter_value()) { case 0: ext = ".png"; break; case 1: ext = ".jpg"; break; } #ifdef WIN32 char szExt[_MAX_EXT]; _splitpath_s(strFileName.c_str(), NULL,0, NULL,0, NULL, 0, szExt,_MAX_EXT); if (_stricmp(szExt,".jpg") && _stricmp(szExt,".png")) { strFileName += ext; } else ext = szExt; #endif #ifdef __APPLE__ if(!strcasecmp(ext.c_str(),".jpg")) { #else if(!_strcmpi(ext.c_str(),".jpg")) { #endif Dialog2 x(0,0,0,0,"ok"); quality = x.getValue(); } pDoc->saveImage(strFileName.c_str(), ext.c_str(), quality); } } //------------------------------------------------------------- // Brings up the paint dialog // This is called by the UI when the brushes menu item // is chosen //------------------------------------------------------------- void ImpressionistUI::cb_brushes(Fl_Menu_* o, void* v) { whoami(o)->m_brushDialog->show(); }
void ImpressionistUI::cb_undo_canvas(Fl_Menu_* o, void* v) { ImpressionistDoc* pDoc = whoami(o)->getDocument(); unsigned char* m_tmp = pDoc->m_ucPainting; pDoc->m_ucPainting = pDoc->m_ucPainting_Undo; pDoc->m_ucPainting_Undo = m_tmp; pDoc->m_pUI->m_paintView->refresh(); glFlush(); }
//------------------------------------------------------------------ // Brings up a file chooser and then loads the chosen image // This is called by the UI when the load image menu item is chosen //------------------------------------------------------------------ void ImpressionistUI::cb_load_image(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc=whoami(o)->getDocument(); const char* filename = pDoc->m_pUI->fileDialog( Fl_Native_File_Chooser::BROWSE_FILE, "Image File (*.png; *.jpg, *.bmp)\t*.{png,jpg,bmp}"); if(filename) pDoc->loadImage(filename); }
//------------------------------------------------------------------ // Brings up a file chooser and then saves the painted image // This is called by the UI when the save image menu item is chosen //------------------------------------------------------------------ void ImpressionistUI::cb_save_image(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc=whoami(o)->getDocument(); char* newfile = fl_file_chooser("Save File?", "*.bmp", "save.bmp" ); if (newfile != NULL) { pDoc->saveImage(newfile); } }
void GraphicalUI::cb_save_image(Fl_Menu_* o, void* v) { GraphicalUI* pUI=whoami(o); char* savefile = fl_file_chooser("Save Image?", "*.bmp", "save.bmp" ); if (savefile != NULL) { pUI->m_traceGlWindow->saveImage(savefile); } }
//実習 FilterKernel void ImpressionistUI::cb_copy_image_to_canvas(Fl_Menu_* o, void* v) { ImpressionistDoc* pDoc=whoami(o)->getDocument(); if (pDoc->m_ucPainting != NULL) { pDoc->copyImageToCanvas(); } else { fl_alert("Must load an image first!"); } }
void TraceUI::cb_exit(Fl_Menu_* o, void* v) { TraceUI* pUI=whoami(o); // terminate the rendering done=true; pUI->m_traceGlWindow->hide(); pUI->m_mainWindow->hide(); }
void GraphicalUI::cb_exit(Fl_Menu_* o, void* v) { GraphicalUI* pUI=whoami(o); // terminate the rendering stopTracing(); pUI->m_traceGlWindow->hide(); pUI->m_mainWindow->hide(); pUI->m_debuggingWindow->hide(); }
static void make_error (char *s) { char *make_error_name __attribute__((unused)) = "make_error name"; char c __attribute__((unused)); double pi2 __attribute__((unused)) = 2.0 * pi; whoami(s); if (int_und == 0) printf ("%s int_und is zero %d\n", s, int_und); else printf ("%s int_und is not zero\n", s); fflush(stdout); }
void ImpressionistUI::cb_load_dissolve(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc = whoami(o)->getDocument(); if (!pDoc->m_ucBitmap) { fl_alert("Please load a background image first."); return; } char* newfile = fl_file_chooser("Open File?", "*.bmp", pDoc->getImageName()); if (newfile != NULL) { pDoc->loadDissolveImage(newfile); } }
int main(int argc, char **argv) { increment_rank(); whoami("baz"); int n = atoi(argv[1]); printf(argv[1]); if (--n > 0) { char *s; asprintf(&s, "%d", n); execlp("foo", "foo", s, NULL); } return 0; }
//------------------------------------------------------------------ // Brings up a file chooser and then loads the chosen image // This is called by the UI when the load alpha brush menu item is chosen //------------------------------------------------------------------ void ImpressionistUI::cb_load_alpha_brush(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc = whoami(o)->getDocument(); char* newfile = fl_file_chooser("Open File?", "*.bmp", pDoc->getImageName()); if (newfile != NULL) { pDoc->loadAlphaBrush(newfile); } for (int i = 0; i < NUM_BRUSH_TYPE; ++i) { if (brushTypeMenu[i].label() == "Alpha Mapped") brushTypeMenu[i].activate(); } }
int main( int argc, char* argv[] ) { int result = 0; char abuffer[128], ibuffer[128]; if ( argc > 1 ) { getif_debug = atoi(argv[1]); } else { getif_debug = -1; } whoami( abuffer, sizeof(abuffer), ibuffer, sizeof(ibuffer) ); printf( "primary interface %s has address %s\n", ibuffer, abuffer ); return result; }
void GraphicalUI::cb_save_image(Fl_Menu_* o, void* v) { GraphicalUI* pUI=whoami(o); const char* szFileName = pUI->fileDialog(Fl_Native_File_Chooser::BROWSE_SAVE_FILE, "PNG Image File (*.png)\t*.png\nJPEG Image File (*.jpg)\t*.jpg", "Save Image"); if(!szFileName) return; int filetype = pUI->m_nativeChooser->filter_value(); //0: PNG, 1: JPG int quality = 95; if (filetype == 1) { Dialog2 x(0,0,0,0,"ok"); quality = x.getValue(); } pUI->m_traceGlWindow->saveImage(szFileName, filetype == 0 ? ".png" : ".jpg", quality); }
int main(int argc, char* argv[]) { options(argc, argv); MPI_Init(&argc, &argv); whoami(); if (mpi_rank == 0) timestamp("START", NULL); cmpi_init_client(); cmpi_client_code(); MPI_Finalize(); return 0; }