int main(){ srand(time(NULL)); /*Read word from the keyboard using scanf*/ int limit = 40; printf("Enter a phrase, no more than %d characters.\n" , limit); char * input = malloc(sizeof(char)*(limit)); assert(input != 0); char stickyStick[] = "Sticky Capped"; if(fgets(input, limit, stdin)!= NULL) {/*Call sticky*/ int k= 0; for(k = 0; k < 5; k++) { sticky(input); sticky(stickyStick); /*Print the new word*/ printf("%s: %s", stickyStick, input); } } free(input); return 0; }
void LauncherApplication::setBamfApplication(BamfApplication *application) { if (application == NULL) { return; } m_application = application; if (!sticky()) { setDesktopFile(application->desktop_file()); } QObject::connect(application, SIGNAL(ActiveChanged(bool)), this, SIGNAL(activeChanged(bool))); QObject::connect(application, SIGNAL(RunningChanged(bool)), this, SLOT(updateCounterVisible())); /* FIXME: a bug somewhere makes connecting to the Closed() signal not work even though the emit Closed() in bamf-view.cpp is reached. */ /* Connect first the onBamfApplicationClosed slot, then the runningChanged signal, to avoid a race condition when an application is closed. See https://launchpad.net/bugs/634057 */ QObject::connect(application, SIGNAL(RunningChanged(bool)), this, SLOT(onBamfApplicationClosed(bool))); QObject::connect(application, SIGNAL(RunningChanged(bool)), this, SIGNAL(runningChanged(bool))); QObject::connect(application, SIGNAL(UrgentChanged(bool)), this, SIGNAL(urgentChanged(bool))); QObject::connect(application, SIGNAL(WindowAdded(BamfWindow*)), this, SLOT(updateHasVisibleWindow())); QObject::connect(application, SIGNAL(WindowRemoved(BamfWindow*)), this, SLOT(updateHasVisibleWindow())); QObject::connect(application, SIGNAL(WindowAdded(BamfWindow*)), this, SLOT(updateWindowCount())); QObject::connect(application, SIGNAL(WindowRemoved(BamfWindow*)), this, SLOT(updateWindowCount())); connect(application, SIGNAL(ChildAdded(BamfView*)), SLOT(slotChildAdded(BamfView*))); connect(application, SIGNAL(ChildRemoved(BamfView*)), SLOT(slotChildRemoved(BamfView*))); connect(application, SIGNAL(WindowAdded(BamfWindow*)), SLOT(onWindowAdded(BamfWindow*))); updateBamfApplicationDependentProperties(); updateCounterVisible(); }
QString Application::icon() const { if (!m_overrideIconPath.isEmpty()) { return m_overrideIconPath; } if (sticky() && (m_appInfo != NULL)) { GCharPointer ptr(g_icon_to_string(g_app_info_get_icon(m_appInfo.data()))); return QString::fromUtf8(ptr.data()); } if (m_application != NULL) { return m_application->icon(); } if (m_appInfo != NULL) { GCharPointer ptr(g_icon_to_string(g_app_info_get_icon(m_appInfo.data()))); return QString::fromUtf8(ptr.data()); } if (m_snStartupSequence != NULL) { return QString::fromUtf8(sn_startup_sequence_get_icon_name(m_snStartupSequence.data())); } return QString(); }
int main(){ /*Input a word*/ char string[256]; printf("Please enter a single word only using characters a - z: "); scanf("%s",string); /*Call sticky*/ sticky(string); /*Print the new word*/ printf("%s \n",string); return 0; }
int main(){ /*Read word from the keyboard using scanf*/ char word[256]; char *input; input = word; scanf("%s",input); /*Call sticky*/ sticky(input); /*Print the new word*/ printf("%s\n",input); return 0; }
int main(){ /*Read word from the keyboard using scanf*/ char str[31]; printf("please enter a word (30chars Max): "); scanf("%30s",str); /*Call sticky*/ sticky(str); /*Print the new word*/ printf("\n%s\n\n",str); return 0; }
int main(){ /*Read word from the keyboard using scanf*/ char str[50]; printf("Give me a word that is less than 50 chars long: \n"); scanf("%s", str); /*Call sticky*/ sticky(str); /*Print the new word*/ printf("%s", str); return 0; }
int main() { /*Read word from the keyboard using scanf*/ char word[31]; //limit to 30 as stated on piazza printf("Please enter a word up to 30 characters. \n"); scanf("%30s", word); //limit input to 30 with %30s /*Call sticky*/ sticky(word); /*Print the new word*/ printf("%s\n", word); return 0; }
int main(){ char word[MAX_STR]; /*Read word from the keyboard using scanf*/ printf("Please enter a word: "); scanf("%s", word); /*Call sticky*/ sticky(word); /*Print the new word*/ printf("In StudlyCaps: %s\n", word); return 0; }
int main(){ char myString[2048]; // seems legit /*Read word from the keyboard using scanf*/ printf ("Type a single word: "); scanf ( "%s", myString); printf ("You entered the word: \"%s\"\n", myString); /*Call sticky*/ sticky(myString); /*Print the new word*/ printf ("STicKy CaPS your word: \"%s\"\n", myString); return 0; }
void SeqToolBarView::ShowPropertyMenu(const AmTool* tool, BPoint where) { BPopUpMenu* menu = new BPopUpMenu("properties menu"); if (!menu) return; BMessage* msg = new BMessage(PROPERTIES_MSG); if (msg) { msg->AddString("tool_key", tool->Key() ); BMenuItem* item = new BMenuItem("Properties", msg); if (item) { item->SetTarget(this); menu->AddItem(item); } } msg = new BMessage(EDIT_MSG); if (msg) { msg->AddString("tool_key", tool->Key() ); msg->AddString("path", tool->LocalFilePath() ); BMenuItem* item = new BMenuItem("Edit", msg); if (item) { item->SetTarget(this); if (tool->IsReadOnly() ) item->SetEnabled(false); menu->AddItem(item); } } menu->AddSeparatorItem(); msg = new BMessage(REMOVE_FROM_TOOL_BAR_MSG); if (msg) { msg->AddString("tool_key", tool->Key() ); msg->AddPointer("tool_id", tool->Id() ); BMenuItem* item = new BMenuItem("Remove From Tool Bar", msg); if (item) { item->SetTarget(this); menu->AddItem(item); } } menu->SetAsyncAutoDestruct(true); where = ConvertToScreen(where); BRect sticky(where.x-5, where.y-5, where.x+5, where.y+5); menu->Go(where, true, false, sticky, true); }
void idle () { if (isAnimating) { currentTime = timeGetTime(); if ((currentTime - oldTime) > ANIMATION_DELAY) { // move the balls edge(); move(dt); collide(); gravity(dt); sticky(dt); // compute the frame rate oldTime = currentTime; } // notify window it has to be repainted glutPostRedisplay(); } }
QString LauncherApplication::name() const { if (sticky() && (m_appInfo != NULL)) { return QString::fromUtf8(g_app_info_get_name(m_appInfo.data())); } if (m_application != NULL) { return m_application->name(); } if (m_appInfo != NULL) { return QString::fromUtf8(g_app_info_get_name(m_appInfo.data())); } if (m_snStartupSequence != NULL) { return QString::fromUtf8(sn_startup_sequence_get_name(m_snStartupSequence.data())); } return QString(""); }
void Application::setBamfApplication(BamfApplication *application) { if (application == NULL) { return; } m_application = application; if (!sticky()) { setDesktopFile(application->desktop_file()); } QObject::connect(application, SIGNAL(ActiveChanged(bool)), this, SIGNAL(activeChanged(bool))); QObject::connect(application, SIGNAL(RunningChanged(bool)), this, SLOT(updateCounterVisible())); /* FIXME: Signal-slot mappings below were based on the assumption that BamfWindow - Closed() was broken. This was fixed in bamf-qt (see https://bugs.launchpad.net/bamf-qt/+bug/968046), so this code may be revisited as we can now rely on Closed(). */ /* Connect first the onBamfApplicationClosed slot, then the runningChanged signal, to avoid a race condition when an application is closed. See https://launchpad.net/bugs/634057 */ QObject::connect(application, SIGNAL(RunningChanged(bool)), this, SLOT(onBamfApplicationClosed(bool))); QObject::connect(application, SIGNAL(RunningChanged(bool)), this, SIGNAL(runningChanged(bool))); QObject::connect(application, SIGNAL(UrgentChanged(bool)), this, SIGNAL(urgentChanged(bool))); QObject::connect(application, SIGNAL(WindowAdded(BamfWindow*)), this, SLOT(updateHasVisibleWindow())); QObject::connect(application, SIGNAL(WindowRemoved(BamfWindow*)), this, SLOT(updateHasVisibleWindow())); QObject::connect(application, SIGNAL(WindowAdded(BamfWindow*)), this, SLOT(updateWindowCount())); QObject::connect(application, SIGNAL(WindowRemoved(BamfWindow*)), this, SLOT(updateWindowCount())); connect(application, SIGNAL(ChildAdded(BamfView*)), SLOT(slotChildAdded(BamfView*))); connect(application, SIGNAL(ChildRemoved(BamfView*)), SLOT(slotChildRemoved(BamfView*))); connect(application, SIGNAL(WindowAdded(BamfWindow*)), SLOT(onWindowAdded(BamfWindow*))); updateBamfApplicationDependentProperties(); updateCounterVisible(); }
// inteface to various superpixel helpers void mexFunction( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { int f; char action[1024]; f=mxGetString(pr[0],action,1024); nr--; pr++; uint *S = (uint*) mxGetData(pr[0]); int h = (int) mxGetM(pr[0]); int w = (int) mxGetN(pr[0]); if(f) { mexErrMsgTxt("Failed to get action."); } else if(!strcmp(action,"sticky")) { // S = sticky( S, I, E, prm ) float *I = (float*) mxGetData(pr[1]); float *E = (float*) mxGetData(pr[2]); double *prm = (double*) mxGetData(pr[3]); pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL); uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint)); sticky(T,h,w,I,E,prm); relabel(T,h,w); } else if(!strcmp(action,"boundaries")) { // S = boundaries( S, E, add, nThreads ) float *E = (float*) mxGetData(pr[1]); bool add = mxGetScalar(pr[2])>0; uint nThreads = (uint) mxGetScalar(pr[3]); pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL); uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint)); boundaries(T,h,w,E,add,nThreads); } else if(!strcmp(action,"merge")) { // S = merge( S, E, thr ); float *E = (float*) mxGetData(pr[1]); float thr = (float) mxGetScalar(pr[2]); pl[0] = mxCreateNumericMatrix(h,w,mxUINT32_CLASS,mxREAL); uint* T = (uint*) mxGetData(pl[0]); memcpy(T,S,h*w*sizeof(uint)); merge(T,h,w,E,thr); } else if(!strcmp(action,"visualize")) { // V = visualize( S, I, hasBnds ) float *I = (float*) mxGetData(pr[1]); bool hasBnds = mxGetScalar(pr[2])>0; const int dims[3] = {h,w,3}; pl[0] = mxCreateNumericArray(3,dims,mxSINGLE_CLASS,mxREAL); float* V = (float*) mxGetData(pl[0]); visualize(V,S,h,w,I,hasBnds); } else if(!strcmp(action,"affinities")) { // A = affinities( S, E, segs, nThreads ) float *E = (float*) mxGetData(pr[1]); uint8 *segs = (uint8*) mxGetData(pr[2]); uint nThreads = (uint) mxGetScalar(pr[3]); if( mxGetNumberOfDimensions(pr[2])!=5 ) mexErrMsgTxt("invalid input"); uint *dims = (uint*) mxGetDimensions(pr[2]); uint m=0; for( uint x=0; x<w*h; x++ ) m=S[x]>m ? S[x] : m; pl[0] = mxCreateNumericMatrix(m,m,mxSINGLE_CLASS,mxREAL); float *A = (float*) mxGetData(pl[0]); affinities(A,S,h,w,E,segs,dims,nThreads); } else if(!strcmp(action,"edges")) { // E = edges(S,A); float* A = (float*) mxGetData(pr[1]); pl[0] = mxCreateNumericMatrix(h,w,mxSINGLE_CLASS,mxREAL); float *E = (float*) mxGetData(pl[0]); edges(E,S,h,w,A); } else mexErrMsgTxt("Invalid action."); }
void ProfileTable::insert(uint64_t key, const struct geopm_prof_message_s &value) { if (key == 0) { throw Exception("ProfileTable::insert(): zero is not a valid key", GEOPM_ERROR_INVALID, __FILE__, __LINE__); } size_t table_idx = hash(key); int err = pthread_mutex_lock(&(m_table[table_idx].lock)); if (err) { throw Exception("ProfileTable::insert(): pthread_mutex_lock()", err, __FILE__, __LINE__); } bool is_stored = false; for (size_t i = 0; !is_stored && i != M_TABLE_DEPTH_MAX; ++i) { if (m_table[table_idx].key[i] == 0 || (m_table[table_idx].key[i] == key && !sticky(m_table[table_idx].value[i]))) { m_table[table_idx].key[i] = key; m_table[table_idx].value[i] = value; is_stored = true; } } if (!is_stored) { // Overwrite all sequential entry/exit pairs in array and // move others to head of the array, then insert new value. uint64_t *key_ptr = m_table[table_idx].key; uint64_t *key_insert_ptr = m_table[table_idx].key; struct geopm_prof_message_s *value_ptr = m_table[table_idx].value; struct geopm_prof_message_s *value_insert_ptr = m_table[table_idx].value; int i = 0; while (i < M_TABLE_DEPTH_MAX - 1) { if (key_ptr[0] == key_ptr[1] && value_ptr[0].region_id == value_ptr[1].region_id && value_ptr[0].progress == 0.0 && value_ptr[1].progress == 1.0) { key_ptr += 2; value_ptr += 2; i += 2; } else { *key_insert_ptr = *key_ptr; ++key_insert_ptr; *value_insert_ptr = *value_ptr; ++value_insert_ptr; ++key_ptr; ++value_ptr; ++i; } } if (i == M_TABLE_DEPTH_MAX - 1) { *key_insert_ptr = *key_ptr; *value_insert_ptr = *value_ptr; ++key_insert_ptr; ++value_insert_ptr; } if (key_insert_ptr >= m_table[table_idx].key + M_TABLE_DEPTH_MAX - 1) { (void) pthread_mutex_unlock(&(m_table[table_idx].lock)); if (m_table[table_idx].value[0].region_id == GEOPM_REGION_ID_EPOCH) { throw Exception("ProfileTable::insert(): epoch time interval too short.", GEOPM_ERROR_TOO_MANY_COLLISIONS, __FILE__, __LINE__); } throw Exception("ProfileTable::insert(): failed to compact table.", GEOPM_ERROR_TOO_MANY_COLLISIONS, __FILE__, __LINE__); } *key_insert_ptr = key; *value_insert_ptr = value; ++key_insert_ptr; while (key_insert_ptr < m_table[table_idx].key + M_TABLE_DEPTH_MAX) { *key_insert_ptr = 0; ++key_insert_ptr; } } err = pthread_mutex_unlock(&(m_table[table_idx].lock)); if (err) { throw Exception("ProfileTable::insert(): pthread_mutex_unlock()", err, __FILE__, __LINE__); } }