int my_optn_e_min(char *buffer) { int cote; int i; cote = 0; i = check_start(buffer); while (buffer[i] != '\0') { if (buffer[i] == 34 && buffer[i - 1] != 92 && cote == 0) cote = 1; else if (buffer[i] == 34 && buffer[i - 1] != 92 && cote == 1) cote = 0; else { if (cote == 0) { if (buffer[i] == 92) i++; write(1, &buffer[i], 1); } else write(1, &buffer[i], 1); } i++; } return (0); }
int epur_fct(char *str, t_epur *e) { while (str[e->i] == ' ' && str[e->i] != '\0') e->i++; while (str[e->i] != '\0') { while ((str[e->i] == ' ' && str[e->i + 1] == ' ') || (str[e->i] == '\t' && str[e->i + 1] == '\t')) e->i++; if ((e->tmp = epur_single(str, e)) != NULL) { e->tmp[e->k] = str[e->i]; e->k++; e->i++; } else return (-1); e->tmp[e->k] = '\0'; } e->tmp = check_end(str, e); if (check_start(e->tmp) == -1 || epur_end(str) == -1) return (-1); else return (1); }
static void profile_stop(lua_State *L) { check_start(L); lua_setcallhook(L, NULL); // disable hook free_array(get_metadata_array(L), STACK_INDEX); lua_unref(L, META_REF); // Remove the old reference (new block of memory). PROFILE_INIT = false; }
int main(int argv, char** argc) { check_init(); check_start("clib -- libdatrie -- trie"); test_trie_tree_states(); test_datrie_states(); test_datrie(); check_end(); check_close(); return 0; }
int check_map(char *str, t_infos *infos, t_list **rooms) { if (check_ants(str, infos) == 1) return (1); else if (check_start(str, infos) == 1 && infos->ok != 2) return (1); else if (check_end(str, infos) == 1 && infos->ok != 2) return (1); else if(check_pos(str, rooms, infos) == 1) return (1); else if(check_tubes(str, infos, rooms) == 1) return (1); return (0); }
/* check_for_state_msg(int) Checks if element at current location is a state message. Currently, only positive integers state messages are supported. Accepts: index where to start searching for state message. Returns: integer that reflects state, if one is found; otherwise, NO_MATCH is returned. */ int RestServer::check_for_state_msg(int _start) { // check that current start location is not a div character _start = check_start(_start); if (_start == NO_MATCH || _start > request.length-1) return NO_MATCH; // search for end position of current element and adjust as required int end_index = next_element(_start); if (end_index == NO_MATCH) end_index = request.length - 1; else end_index -= 1; // move end index to location before the division character // try to convert current element into a number by calling request.to_i method int new_num = request.to_i(_start, end_index); return new_num; }
int check_room(t_lem_env *env, char *s) { if (is_link(s) && env->fonction[env->r.state + 1](env, s)) return (ft_add_state(env)); if (ft_strcmp("##start", s) == 0 && check_start(env, s)) return (1); if (ft_strcmp("##end", s) == 0 && check_end(env, s)) return (1); if (is_room(s) && add_room(env, s)) { env->r.nbline += add_file(env, s); return (1); } return (ft_error(env, 1)); }
int main(int argc, char **argv) { t_env e; if ((e.key = ftok(argv[0], 'a')) < 0) { perror("ftok"); exit(1); } // printf("e.key : %d\n", e.key); if (argc == 2) { init_env(&e, argv[1]); while (1) { printf("ICI\n"); op_sem_proberen(&e); printf("LA\n"); // printf("heya\n"); if ((*((int*)(e.addr + sizeof(int)))) == 0) { check_start(&e); op_sem_verhogen(&e); continue ; } printf("hey0\n"); test_print(&e); if (check_elim(&e)) player_lost(&e); msg_read(&e); printf("hey1\n"); begin_turn(&e); op_sem_verhogen(&e); if ((*((int*)(e.addr + sizeof(int)))) == 1 && check_victory(&e)) { printf("VICTOIRRRRRRRRE team : %d\n", e.team); kill_player(&e); } printf("leader : %d\n", e.leader); usleep(500000); } } else printf("Usage : %s [team]\n", argv[0]); return (0); }
/* next_element(int) Looks for the next restful service element by searching for element division characters specified in the the div_chars array. Accepts: index where to start searching for next element within the request. Returns: index position of the next div element if one is found, otherwise, returns NO_MATCH. */ int RestServer::next_element(int _start) { _start = check_start(_start); if (_start == NO_MATCH) return NO_MATCH; // if (_start >= request.length) return NO_MATCH; int match_index = NO_MATCH; // loop through each element of div_chars array to search for a match in the request for (int i = 0; i < DIV_ELEMENTS; i ++ ) { int new_index = request.find(div_chars[i], _start); // if match is found then update the match_index if... if (new_index != NO_MATCH) { // ... match_index equals NO_MATCH, or new_index is smaller then match_index if (match_index == NO_MATCH || (new_index < match_index)) match_index = new_index; } } return match_index; }
static void profile_show_text(lua_State *L) { check_start(L); // Spent runtime so far. float total_spent = calc_elapsed_time(PROFILE_START_TIME, clock()); // Lua args lua_Object lobj = lua_getparam(L, 1); char *breakln = lua_isstring(L, lobj) ? lua_getstring(L, lobj) : "\n"; lobj = lua_getparam(L, 2); char *offsetc = lua_isstring(L, lobj) ? lua_getstring(L, lobj) : "\t"; Meta **array = get_metadata_array(L); render_text(L, array, STACK_INDEX - 1, offsetc, breakln); printf("TOTAL TIME SPENT: %.3f%s", total_spent, breakln); }
/* service_match(int, int, int) Checks the element at the current location in the request message against one of the available services on the Arduino. If a SET service is matched then this method also attempts to read a service state. Accepts: an integer that identifies whether the service type being checked is a get service (0), or a set service (1); the position of the specific service to be checked within the get or set services arrays; and, the position of the current element within the request char array. Returns: returns location of the next element within the request, if a service is found; otherwise, returns NO_MATCH */ int RestServer::service_match(int _r_index, int _start_pos) { // check that start pos is not a div char, and that it is smaller than the request's length _start_pos = check_start(_start_pos); if (_start_pos == NO_MATCH) return NO_MATCH; int match_index = NO_MATCH; // get current resource name and try to match to current request element match_index = request.match_string(const_cast<char *>(resources[_r_index].service->getName()), _start_pos); if (match_index != NO_MATCH) { resources[_r_index].get = true; if (resources[_r_index].service->isUpdateable()) { if (request_type == POST_REQUESTS || ((server_options & POST_WITH_GET) != 0)) { match_index = state_match(_r_index, (match_index + 1)); } } } return match_index; }
int main(int argc, char **argv) { setup(); /* Start off with something obscene */ switch_tests(220000 / 60); start = time(NULL); for(;;) { if (check_start()) break; printf(" \r"); do_frame(); running_stats(); check_switch(); } stats(); return 0; }
int main(int argc, char *argv[]) { printf("---KallistiOS PVR Modifier Example (with textures)---\n"); printf("Use the DPAD to move the modifier square around (it starts at "); printf("(320, 240))\n"); printf("Press Start to exit.\n"); srand(time(NULL)); pvr_init(&pvr_params); setup(); /* Go as long as the user hasn't pressed start on controller 1. */ while(!check_start()) { do_frame(); } pvr_mem_free(txr1); pvr_mem_free(txr2); return 0; }
/* CALL FUNCTION HOOK */ static void callhook(lua_State *L, lua_Function func, char *file, int line) { check_start(L); Meta **array = get_metadata_array(L); if (!array) return; // check if exists (call profile_stop ?) if (STACK_INDEX > MEM_BLOCKSIZE - 1) { // Reached memory limit, relocated to double. int blocksize = MEM_BLOCKSIZE * 2; array = realloc(array, blocksize * sizeof(Meta **)); if (array) { lua_unref(L, META_REF); // Remove the old reference (new block of memory). lua_pushuserdata(L, array); // Saves the new reference. META_REF = lua_ref(L, 1); MEM_BLOCKSIZE = blocksize; // Updates the size of the memory block. } else { lua_error(L, "profiler: out of memory!"); return; // suppress inspect } } char *func_name; char *func_scope; if (lua_isfunction(L, func)) { func_scope = lua_getobjname(L, func, &func_name); Meta *meta = (Meta *) malloc(sizeof(Meta)); meta->fun_name = func_name ? func_name : "unnamed"; if (func_scope && strlen(func_scope) > 0) { meta->fun_scope = func_scope; } else { meta->fun_scope = "unknown"; } meta->func_file = file ? file : "unnamed"; meta->stack_level = STACK_SIZE; meta->line = line; Children *children = (Children *) malloc(sizeof(Children)); meta->children = children; children->index = 0; children->list = NULL; children->size = 20; Measure *measure = (Measure *) malloc(sizeof(Measure)); measure->begin = clock(); meta->measure = measure; stack_record.meta = meta; push(&stack, stack_record); if (STACK_SIZE == 0) { array[STACK_INDEX] = meta; STACK_INDEX++; } STACK_SIZE++; } else if (STACK_SIZE > 0) { STACK_RECORD top_record = pop(&stack); STACK_RECORD *new_record = next(&stack); Meta *meta = top_record.meta; meta->measure->end = clock(); meta->measure->time_spent = calc_time_spent(meta->measure); if (new_record != NULL && meta->measure->time_spent >= PROFILE_RECORD_TIME) { Meta *_meta = new_record->meta; if (!_meta->children->list) { // already allocated ? _meta->children->list = (Meta **) malloc(_meta->children->size * sizeof(Meta **)); if (!_meta->children->list) lua_error(L, "out of memory"); } if (_meta->children->index > _meta->children->size - 1) { _meta->children->size *= 2; // more _meta->children->list = (Meta **) realloc(_meta->children->list, _meta->children->size * sizeof(Meta **)); if (!_meta->children->list) lua_error(L, "out of memory"); } _meta->children->list[_meta->children->index] = meta; _meta->children->index++; } STACK_SIZE--; } }