int CKXDialog::on_command(int wParam, int lParam) { switch(wParam) { case IDg_INFO: manager->launch(LAUNCH_INFO); return 1; case IDg_MINI: SendMessage(WM_SYSCOMMAND,SC_MINIMIZE); return 1; case IDg_CARDNAME: { manager->change_device(-2,this); return 1; } case IDg_SAVE_SETTINGS: manager->save_settings(SETTINGS_GUI,NULL,get_flag()|KX_SAVED_NO_VERSION|KX_SAVED_NO_CARDNAME); select_device(); return 1; case IDg_LOAD_SETTINGS: manager->restore_settings(SETTINGS_GUI,NULL,get_flag()|KX_SAVED_NO_VERSION|KX_SAVED_NO_CARDNAME); select_device(); return 1; } return kDialog::on_command(wParam,lParam); }
static int decode_arg (int * i, int argc, char ** argv) { char * p; char * tmp; unsigned long fl; switch (argv[*i][0]) { case '-': for (p = &argv[*i][1]; *p; p++) { if (*p == 'R') { recursive = 1; continue; } if (*p == 'V') { verbose = 1; continue; } if (*p == 'v') { (*i)++; if (*i >= argc) usage (); version = strtol (argv[*i], &tmp, 0); if (*tmp) { com_err (program_name, 0, _("bad version - %s\n"), argv[*i]); usage (); } set_version = 1; continue; } if ((fl = get_flag(*p)) == 0) usage(); rf |= fl; rem = 1; } break; case '+': add = 1; for (p = &argv[*i][1]; *p; p++) { if ((fl = get_flag(*p)) == 0) usage(); af |= fl; } break; case '=': set = 1; for (p = &argv[*i][1]; *p; p++) { if ((fl = get_flag(*p)) == 0) usage(); sf |= fl; } break; default: return EOF; break; } return 1; }
void hitachi_lcd_service(void){ if(NewCustomSymbolFlags){ set_flag(CGRAMUsed); static uint8_t DataByteNumber = 0, CustomSymbolNumber = 0; if(get_flag(CGRAMAddrSet)){ hitachi_lcd_write_data(*(CustomSymbol[CustomSymbolNumber] + DataByteNumber)); if(++DataByteNumber > 7){ bit_clr(NewCustomSymbolFlags, CustomSymbolNumber); clr_flag(CGRAMAddrSet); DataByteNumber = 0; CustomSymbolNumber = 0; } } else { while(!(NewCustomSymbolFlags & (1<<CustomSymbolNumber))) CustomSymbolNumber++; hitachi_lcd_set_address(CGRAM_ADDR(CustomSymbolNumber*8)); set_flag(CGRAMAddrSet); } } else { if(get_flag(CGRAMUsed)){ clr_flag(CGRAMUsed); clr_flag(DRAMAddrSet); CharNumber = 0; hitachi_lcd_set_address(DRAM_ADDR(0x00)); } else { switch(CharNumber){ case CHAR_IN_ROW: if(get_flag(DRAMAddrSet)){ clr_flag(DRAMAddrSet); hitachi_lcd_write_data(pLcdBuffer[CharNumber]); CharNumber++; } else { set_flag(DRAMAddrSet); hitachi_lcd_set_address(DRAM_ADDR(0x40)); } break; case CHAR_ON_LCD: if(get_flag(DRAMAddrSet)){ clr_flag(DRAMAddrSet); CharNumber = 0; hitachi_lcd_write_data(pLcdBuffer[CharNumber]); CharNumber++; } else { set_flag(DRAMAddrSet); hitachi_lcd_set_address(DRAM_ADDR(0x00)); } break; default: hitachi_lcd_write_data(pLcdBuffer[CharNumber]); CharNumber++; break; } } } }
/*----------------------------------------------------------------------------------------*/ void wdial_deselect( WDIALOG *wd, int16 obj, int16 close ) { if (get_flag(wd->tree, obj, EXIT) && !get_flag(wd->tree, obj, TOUCHEXIT) ) { set_state(wd->tree, obj, SELECTED, FALSE); if (!close) { redraw_wdobj(wd, obj); } } }
void dict_set(Dict* d, void* key, void* value) { assert(d != NULL); if (dict_query(d, key, NULL)){ set(d, key, value, d->data, d->alloc_size); } if ((d->size + 1) * 2 >= d->alloc_size){ // Expand buckets uint64 new_size = map_prime(2*(d->size+1)); void* new_data = mem_calloc(new_size * d->total_size); // Rehash each old bucket into new buckets for (uint64 i = 0; i < d->alloc_size; i++){ Flag* p_flag = get_flag(d, d->data, i); if (*p_flag == BUCKET_FULL){ void* old_key = get_key(d, d->data, i); void* old_value = get_value(d, d->data, i); set(d, old_key, old_value, new_data, new_size); } } // Throw away old stuff mem_free(d->data); d->alloc_size = new_size; d->data = new_data; } d->size++; set(d, key, value, d->data, d->alloc_size); }
bool dict_query(Dict* d, void* key, void* value) { uint64 hash = d->hash_func(key); for (uint64 idx = 0; idx < d->alloc_size; idx++){ // Quadratic probing uint64 place = (hash + idx*idx) % d->alloc_size; Flag* p_flag = get_flag(d, d->data, place); if (*p_flag == BUCKET_EMPTY){ return false; } // Compare keys. void* current_key = get_key(d, d->data, place); if (d->equal_func(key, current_key)){ void* current_value = get_value(d, d->data, place); if (value != NULL) memcpy(value, current_value, d->value_size); return true; } } assert_never(); return false; }
static void init() { int dummy; ENTER; if (!XkbQueryExtension(GDK_DISPLAY(), &dummy, &xkb_event_type, &dummy, &dummy, &dummy)) { ERR("no XKB extension\n"); exit(1); } XSetLocaleModifiers(""); XSetErrorHandler((XErrorHandler) Xerror_handler); dpy = GDK_DISPLAY(); if (chdir(IMGPREFIX)) { ERR("can't chdir to %s\n", IMGPREFIX); exit(1); } if (!(default_flag = get_flag("zz"))) { ERR("can't load default flag image\n"); exit(1); } XkbSelectEventDetails(dpy, XkbUseCoreKbd, XkbStateNotify, XkbAllStateComponentsMask, XkbGroupStateMask); gdk_window_add_filter(NULL, (GdkFilterFunc)filter, NULL); RET(); }
void enc_tile(jxr_t *p, rect_t *tile) { rect_t mb_window[2]; rect_t is_tile_edge; uint32_t mby, mbx; enc_tile_header(p->out, &p->param); //printf("%d, %d, %d, %d\n", tile->left, tile->right, tile->top, tile->bottom); for (mby = tile->top; mby <= tile->bottom; mby++) { for (mbx = tile->left; mbx <= tile->right; mbx++) { //printf("(%3d, %3d)", mbx, mby); check_tile_edge(&is_tile_edge, mbx, mby, tile); calc_rect(mb_window, mbx, mby, p->param.mb_width, p->param.mb_height); //printf("%d, %d, %d, %d\n", mb_window[0].left, mb_window[0].right, mb_window[0].top, mb_window[0].bottom); enc_mb_stage1(p, mb_window, &is_tile_edge, mbx, mby); enc_mb_stage2(p, tile, &is_tile_edge, mbx, mby); //printf("\n"); //if (mbx == 0 && mby == 1) exit(0); } } write_align(&p->out[0]); if (get_flag(p->param.flags, FREQUENCY_MODE_CODESTREAM_FLAG)) { write_align(&p->out[1]); write_align(&p->out[2]); write_align(&p->out[3]); } int mbs = (tile->right - tile->left + 1) * (tile->bottom - tile->top + 1); int tb = get_total_bits(p->out); //printf("|Total : %d[bits]|MBs : %d| %3.2f[bits/MB]|Comp. Ratio %f|\n", tb, mbs, (float)tb/mbs, (float)tb/(mbs*6144)); }
void cycle1 (void) { if (do_cycle1 == 1) { #ifdef PREv19 arb_debug_reg(0x41, 0x00000000); //---------------------------------------------------------------------------------------------------------- // XO Timer if (!get_flag(FLAG_XO_SUB)) { set_flag(FLAG_XO_SUB, 1); // Configure XO // In reality, the XO driver must be properly configured and started arb_debug_reg(0x41, 0x00000001); set_wakeup_timer (100, 0, 1); set_xo_timer (100, 1, 1); mbus_sleep_all(); } //---------------------------------------------------------------------------------------------------------- // End of Testing else { uint32_t temp_val = 0; while (temp_val == 0) { temp_val = *XOT_VAL;} arb_debug_reg(0x41, (0x10 << 24) | temp_val); set_xo_timer (100, 0, 1); arb_debug_reg(0x41, 0x00000002); } #endif } }
void cycle4 (void) { if (do_cycle2 == 1) { arb_debug_reg(0x44, 0x00000000); //---------------------------------------------------------------------------------------------------------- // Go into indefinite sleep if (!get_flag(FLAG_GOCEP_SUB)) { set_flag(FLAG_GOCEP_SUB, 1); arb_debug_reg(0x44, 0x00000001); set_wakeup_timer(5, 0, 1); mbus_sleep_all(); } //---------------------------------------------------------------------------------------------------------- // After wakeup by GOCEP else { if (irq_history == ((0x1 << IRQ_WAKEUP) | (0x1 << IRQ_GOCEP))) { pass (0x1, irq_history); irq_history = 0; disable_all_irq(); } else { fail (0x1, irq_history); disable_all_irq(); } arb_debug_reg(0x44, 0x00000002); } } }
int main() { // Initialization Sequence if (!get_flag(FLAG_ENUM)) { initialization(); mbus_sleep_all(); while(1); } // Display cycle number for debugging purpose arb_debug_reg(0x20, cyc_num); // Enable IRQs irq_handled = 0; *NVIC_ISER = (0x1 << IRQ_GOCEP) | (0x1 << IRQ_WAKEUP); // Wait until the IRQ has been handled, then go to sleep while (1) { if (irq_handled) { cyc_num++; mbus_sleep_all(); break; } } //Never Quit (should not come here.) while(1){ arb_debug_reg(0xFF, 0xDEADBEEF); asm("nop;"); } return 1; }
int my_printf(const char *format, ...) { va_list list; int i; int chars_written; va_start(list, format); i = 0; chars_written = 0; while (format[i] != 0) { if (format[i] == '%') { get_opt_flag((char*)format, &i, &chars_written); get_width((char*)format, &i, &chars_written); get_precision((char*)format, &i, &chars_written); get_flag((char*)format, &i, &chars_written, &list); } else chars_written += my_putchar(format[i]); i++; } va_end(list); return (chars_written); }
void g1_path_object_class::unoccupy_location() { if (get_flag(MAP_OCCUPIED)) { g1_object_class::unoccupy_location(); g1_path_object_list.find_and_unlink(this); } }
/* Pyarnometer */ void write_pyano(pyano_data data){ check_create_query_buffer(); if( get_flag(NOT_USE_ADDR_FLAG) ) { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO pyano_data (sens_id, intens) VALUES (get_first_id(%d),%d)",PYANO, data.absrad); } else { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO pyano_data (sens_id, intens) VALUES (get_sensor_id(%d,%d),%d)",PYANO, data.address, data.absrad); } pg_insert(query_buffer); }
std::string toString() { std::stringstream ss; ss << "Height sample:" << std::endl << "\ttype: " << type << std::endl << "\th: " << h << std::endl << "\tdh: " << dh << std::endl << "\tdx: " << dx << " dy: " << dy << std::endl << "\tu: " << u << " v: " << v << std::endl << "\tflag_0: " << get_flag(0) << " flag_1: " << get_flag(1) << " flag_2: " << get_flag(2) << " flag_3: " << get_flag(3) << std::endl << "\tnsl_0: " << neighbor_slab_indices[0] << " nsl_1: " << neighbor_slab_indices[1] << " nsl_2: " << neighbor_slab_indices[2] << " nsl_2: " << neighbor_slab_indices[3] << std::endl << "\tnd_0: " << neighbor_distances[1] << " nd_1: " << neighbor_distances[1] << " nd_2: " << neighbor_distances[2] << " nd_3: " << neighbor_distances[3] << std::endl << "\tvertex-idx: " << vertex_index << " sec. vertex-idx: " << secondary_vertex_index << std::endl; return ss.str(); }
/* Regensensor */ void write_regen(regen_data data){ check_create_query_buffer(); if( get_flag(NOT_USE_ADDR_FLAG) ) { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO regen_data (sens_id, count) VALUES (get_first_id(%d),%d)",REGEN, data.counter); } else { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO regen_data (sens_id, count) VALUES (get_sensor_id(%d,%d),%d)",REGEN, data.address, data.counter); } pg_insert(query_buffer); }
/* Helligkeitssensor */ void write_helli(helli_data data){ check_create_query_buffer(); if( get_flag(NOT_USE_ADDR_FLAG) ) { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO helli_data (sens_id, bight) VALUES (get_first_id(%d),%d)",HELLI, data.abslum); } else { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO helli_data (sens_id, bight) VALUES (get_sensor_id(%d,%d),%d)",HELLI, data.address, data.abslum); } pg_insert(query_buffer); }
/* Windsensor */ void write_winds(winds_data data){ check_create_query_buffer(); if( get_flag(NOT_USE_ADDR_FLAG) ) { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO winds_data (sens_id, geschw, schwank, richt) VALUES (get_first_id(%d),%d,%d,%d)",WINDS, data.geschw, data.schwank, data.richt); } else { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO winds_data (sens_id, geschw, schwank, richt) VALUES (get_sensor_id(%d,%d),%d,%d,%d)",WINDS, data.address, data.geschw, data.schwank, data.richt); } pg_insert(query_buffer); }
/* 'besserer' Außensensor */ void write_auss2(auss2_data data){ check_create_query_buffer(); if( get_flag(NOT_USE_ADDR_FLAG) ) { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO auss2_data (sens_id, \"temp\", hum) VALUES (get_first_id(%d),%d,%d)",AUSS2, data.temp, data.hum); } else { snprintf(query_buffer, QUERY_BUFFERSIZE, "INSERT INTO auss2_data (sens_id, \"temp\", hum) VALUES (get_sensor_id(%d,%d),%d,%d)",AUSS2, data.address, data.temp, data.hum); } pg_insert(query_buffer); }
/* Wertkonvertierungen fuer den Regensensor (ein Zaehlschritt = 370ml/m^2)*/ static regen_data process_regen(time_t timestamp, u_char address, u_char *buffer){ regen_data data; /* Datenstruktur */ int new_rain_count = 0; /* Neuer Zaehlerstand */ int now_rain_count = 0; /* Delta-Zaehlerstand */ data.timestamp = timestamp; /* Zeitstempel */ data.address = address; /* Addresse */ new_rain_count = ((buffer[2] & 0x1F) << 7) | remove_msb(buffer[3]); /* Niederschlagszaehler */ if (get_flag(NOT_USE_ADDR_FLAG)) address = 0; if(last_rain_count[address%16] == -1) /* Nach Programmstart Zaehler initialisieren */ last_rain_count[address%16] = new_rain_count; now_rain_count = new_rain_count - last_rain_count[address%16]; /* neuen Niederschlag berechnen */ if(now_rain_count < 0){ /* Wenn Integerueberlauf im Sensor */ now_rain_count = (0x3FFF - last_rain_count[address%16]) + new_rain_count; /* Dann letzten gemessenen Wert vom Max-Integer-Wert abziehen und neuen Zaehlwert dazurechnen */ DEBUGOUT1("Integer-Ueberlauf\n"); } data.counter = (now_rain_count * 370); /* Ein Zaehlschritt entspricht 370ml/m^2, also aenderung mit 370 multiplizieren und zuweisen */ last_rain_count[address%16] = new_rain_count; /* Zaehler neu setzen */ DEBUGOUT2("Regensensor an Addresse %i\n", data.address); DEBUGOUT3("Zaehler: %d Differenz: %d\n", new_rain_count,now_rain_count); DEBUGOUT2("Niederschlag: %dml/m^2\n", data.counter); #ifndef NO_LOGING if(get_flag(LOG_DATA_FLAG)){ check_log_buffer(); sprintf(prepend_type_address(REGEN,address), "Rain: %dml/m^2",data.counter); log_data(timestamp, log_buffer); } #endif return data; }
// Block send moves, once CNN finish evaluation. // If done is set, don't send anything. BOOL ExLocalServerSendMove(void *ctx, MMove *move) { Exchanger *ex = (Exchanger *)ctx; if (move->seq == 0) return FALSE; while (! ex->done) { unsigned char flag = get_flag(ex); if (flag & (1 << SIG_RESTART)) break; if (PipeWrite(&ex->channels[PIPE_MOVE], ARGP(move)) == 0) { ex->move_sent ++; return TRUE; } } return FALSE; }
static void set_pseudogram(char *pseudogram, struct pseudo_header *psh, struct tcphdr *header, int len, struct ip *ip_header, char *device) { t_flag *spoof = get_flag("spoof"); psh->source_address = (spoof && spoof->value) ? inet_addr(spoof->value) : inet_addr(device); psh->dest_address = ip_header->ip_dst.s_addr; psh->placeholder = 0; psh->protocol = IPPROTO_TCP; psh->length = htons(sizeof(struct tcphdr)); ft_memset(pseudogram, 0, len); ft_memcpy(pseudogram, psh, sizeof(struct pseudo_header)); ft_memcpy(pseudogram + sizeof(struct pseudo_header), header, sizeof(struct tcphdr)); }
/* looks up corrsct flag image for every language group and replaces * default_flag image when it is found. * Flag is derived from xkb symbolic name, that looks something like that * pc(pc105)+us+ru(phonetic):2+il(phonetic):3+group(shifts_toggle)+group(switch) * * Run 'xlsatoms | grep pc' to see your value. */ static void get_group_flags(XkbDescRec *kbd_desc_ptr) { char *symbols, *tmp, *tok; GdkPixbuf *flag; int no; ENTER; if (XkbGetNames(dpy, XkbSymbolsNameMask, kbd_desc_ptr) != Success) { ERR("XkbGetNames failed.\n"); RET(); } if (kbd_desc_ptr->names->symbols == None || (symbols = XGetAtomName(dpy, kbd_desc_ptr->names->symbols)) == NULL) { ERR("Can't get group symbol names\n"); RET(); } DBG("symbols=%s\n", symbols); for (tok = strtok(symbols, "+"); tok; tok = strtok(NULL, "+")) { DBG("tok=%s\n", tok); /* find group symbolic name (like en, us or ru) and group number */ tmp = strchr(tok, ':'); if (tmp) { if (sscanf(tmp+1, "%d", &no) != 1) { ERR("can't read group number in <%s> token\n", tok); goto out; } no--; } else { no = 0; } if (no < 0 || no >= ngroups) { ERR("Group number %d is out of range 1..%d in token <%s>\n", no, ngroups, tok); goto out; } for (tmp = tok; isalpha(*tmp); tmp++); *tmp = 0; /* if we have flag with same name, then replace default image. * otherwise do nothing */ if ((flag = get_flag(tok))) group[no].flag = flag; DBG("sym %s flag %sfound \n", tok, flag ? "" : "NOT "); } out: XFree(symbols); }
/* * Find an appropriate hostile faction for the given monster. */ u32b get_hostile_faction(monster_type *m_ptr, u32b hostile_to, u32b default_faction) { u32b faction = m_ptr->faction; monster_race *r_ptr = &r_info[m_ptr->r_idx]; monster_ego *re_ptr = &re_info[m_ptr->ego]; if (get_faction_friendliness(hostile_to, faction) < 0) return faction; if (has_flag(m_ptr, FLAG_FACTION)) { faction = get_flag(m_ptr, FLAG_FACTION); if (get_faction_friendliness(hostile_to, faction) < 0) return faction; } if (m_ptr->ego != 0 && has_flag(r_ptr, FLAG_FACTION)) { faction = get_flag(re_ptr, FLAG_FACTION); if (get_faction_friendliness(hostile_to, faction) < 0) return faction; } if (has_flag(r_ptr, FLAG_FACTION)) { faction = get_flag(r_ptr, FLAG_FACTION); if (get_faction_friendliness(hostile_to, faction) < 0) return faction; } return default_faction; }
unsigned int fixmempool_free(fixmempool_t *mempool,void *pointer) { size_t pointer_offset = address_to_offset(mempool,pointer); if((void *)mempool->array <= pointer && (pointer-(void *)mempool->array)%mempool->element_size == 0 && pointer_offset < mempool->size && get_flag(mempool,pointer_offset)){ mempool->release_function(pointer); ((freelist_t *)pointer)->next = mempool->freelist; mempool->freelist = pointer; unset_flag(mempool,pointer_offset); return FIXMEMPOOL_SUCCESS; } else{ return FIXMEMPOOL_INVALID_POINTER; } }
// Send ack for any unusual signal received. BOOL ExLocalServerSendAckIfNecessary(void *ctx) { Exchanger *ex = (Exchanger *)ctx; // Clear the flag. unsigned char flag = get_flag(ex); // If the flag is not zero before cleanup, we need to send an ack (so that the client know we have received it). BOOL clean_flag = FALSE; BOOL send_ack = TRUE; if (flag != 0) { if (flag & (1 << SIG_RESTART)) { // Clean up the message queues. int num_discarded = 0; MBoard mboard; while (PipeRead(&ex->channels[PIPE_BOARD], ARG(mboard)) == 0) num_discarded ++; printf("#Board Discarded = %d\n", num_discarded); clean_flag = TRUE; } else if (flag & (1 << SIG_FINISHSOON)) { clean_flag = TRUE; // Do not need to send ack for FINISHSOON (No one is going to receive it). send_ack = FALSE; } } if (clean_flag) { printf("Summary: Board received = %d, Move sent = %d\n", ex->board_received, ex->move_sent); ex->board_received = 0; ex->move_sent = 0; // All states are resumed, then we clear the flag. (If we clear the flag before that, sendmove and receiveboard might run before the stats are reset). __sync_fetch_and_and(&ex->ctrl_flag, 0); // Send message. if (send_ack) { MCtrl mctrl; mctrl.code = SIG_ACK; while (! ex->done) { if (PipeWrite(&ex->channels[PIPE_S2C], ARG(mctrl)) == 0) { printf("Ack sent with previous flag = %d\n", flag); // Sent. return TRUE; } } } } // Not sent. return FALSE; }
void fixmempool_release(fixmempool_t *mempool) { if(mempool){ if(mempool->release_function != DEFAULT_RELEASE_FUNCTION){ size_t counter = 0; while(counter != mempool->free_offset){ if(get_flag(mempool,counter)){ release_by_offset(mempool,counter); } counter++; } } free(mempool->array); free(mempool->flags); free(mempool); } }
int main() { irq_history = 0; // Enable Wake-Up/Soft-Reset/GOCEP IRQs *NVIC_ISER = (0x1 << IRQ_WAKEUP) | (0x1 << IRQ_SOFT_RESET) | (0x1 << IRQ_GOCEP); // Initialization Sequence if (!get_flag(FLAG_ENUM)) { initialization(); } arb_debug_reg(0x20, cyc_num); // Testing Sequence if (cyc_num == 0) cycle0(); else if (cyc_num == 1) cycle1(); else if (cyc_num == 2) cycle2(); else if (cyc_num == 3) cycle3(); else if (cyc_num == 4) cycle4(); else if (cyc_num == 5) cycle5(); else if (cyc_num == 6) cycle6(); else if (cyc_num == 7) cycle7(); else if (cyc_num == 8) cycle8(); else if (cyc_num == 9) cycle9(); else if (cyc_num == 10) cycle10(); else if (cyc_num == 11) cycle11(); else cyc_num = 999; arb_debug_reg(0x2F, cyc_num); // Sleep/Wakeup OR Terminate operation if (cyc_num == 999) *REG_CHIP_ID = 0xFFFFFF; // This will stop the verilog sim. else { cyc_num++; set_wakeup_timer(5, 1, 1); mbus_sleep_all(); } while(1){ //Never Quit (should not come here.) arb_debug_reg(0xFF, 0xDEADBEEF); asm("nop;"); } return 1; }
int do_resume(int argc, char *argv[]) { const char *resume_file = CONFIG_PM_STD_PARTITION; const char *resume_arg; resume_arg = get_arg(argc, argv, "resume="); resume_file = resume_arg ? resume_arg : resume_file; /* No resume device specified */ if (!resume_file[0]) return 0; /* Fix: we either should consider reverting the device back to ordinary swap, or (better) put that code into swapon */ /* Noresume requested */ if (get_flag(argc, argv, "noresume")) return 0; return resume(resume_file); }
int main(int argc, char** argv) { char* arg_flags[] = {"o", "t"}; set_flags_with_args(arg_flags, 2); parse_flags(argv+1, argc-1); char* flag = get_flag("o"); if (flag == 0) { puts("not passed"); } else if (flag == (char*)1) { puts("flag triggered"); } else { printf("flag value: %s\n", flag); } return 0; }