size_t avro_schema_union_size(const avro_schema_t union_schema) { check_param(EINVAL, is_avro_schema(union_schema), "union schema"); check_param(EINVAL, is_avro_union(union_schema), "union schema"); struct avro_union_schema_t *unionp = avro_schema_to_union(union_schema); return unionp->branches->num_entries; }
avro_schema_t avro_schema_link_target(avro_schema_t schema) { check_param(NULL, is_avro_schema(schema), "schema"); check_param(NULL, is_avro_link(schema), "schema"); struct avro_link_schema_t *link = avro_schema_to_link(schema); return link->to; }
int avro_schema_to_json(const avro_schema_t schema, avro_writer_t out) { check_param(EINVAL, is_avro_schema(schema), "schema"); check_param(EINVAL, out, "writer"); int rval; if (is_avro_primitive(schema)) { check(rval, avro_write_str(out, "{\"type\":\"")); } switch (avro_typeof(schema)) { case AVRO_STRING: check(rval, avro_write_str(out, "string")); break; case AVRO_BYTES: check(rval, avro_write_str(out, "bytes")); break; case AVRO_INT32: check(rval, avro_write_str(out, "int")); break; case AVRO_INT64: check(rval, avro_write_str(out, "long")); break; case AVRO_FLOAT: check(rval, avro_write_str(out, "float")); break; case AVRO_DOUBLE: check(rval, avro_write_str(out, "double")); break; case AVRO_BOOLEAN: check(rval, avro_write_str(out, "boolean")); break; case AVRO_NULL: check(rval, avro_write_str(out, "null")); break; case AVRO_RECORD: return write_record(out, avro_schema_to_record(schema)); case AVRO_ENUM: return write_enum(out, avro_schema_to_enum(schema)); case AVRO_FIXED: return write_fixed(out, avro_schema_to_fixed(schema)); case AVRO_MAP: return write_map(out, avro_schema_to_map(schema)); case AVRO_ARRAY: return write_array(out, avro_schema_to_array(schema)); case AVRO_UNION: return write_union(out, avro_schema_to_union(schema)); case AVRO_LINK: return write_link(out, avro_schema_to_link(schema)); } if (is_avro_primitive(schema)) { return avro_write_str(out, "\"}"); } avro_set_error("Unknown schema type"); return EINVAL; }
int32 scriptlib::debug_pre_set_target(lua_State *L) { check_param_count(L, 2); check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 2); card* t_card = *(card**) lua_touserdata(L, 1); card* target = *(card**) lua_touserdata(L, 2); t_card->add_card_target(target); return 0; }
int32 scriptlib::effect_set_operation(lua_State *L) { check_param_count(L, 1); check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_FUNCTION, 2); effect* peffect = *(effect**) lua_touserdata(L, 1); if(peffect->operation) luaL_unref(L, LUA_REGISTRYINDEX, peffect->operation); peffect->operation = interpreter::get_function_handle(L, 2); return 0; }
// seg000:0000 void far pop_main() { // debug only: check that the sequence table deobfuscation did not mess things up #ifdef CHECK_SEQTABLE_MATCHES_ORIGINAL check_seqtable_matches_original(); #endif load_options(); apply_seqtbl_patches(); char sprintf_temp[100]; int i; dathandle = open_dat("PRINCE.DAT", 0); /*video_mode =*/ parse_grmode(); init_timer(60); parse_cmdline_sound(); set_hc_pal(); current_target_surface = rect_sthg(onscreen_surface_, &screen_rect); show_loading(); set_joy_mode(); cheats_enabled = check_param("megahit") != NULL; #ifdef __DEBUG__ cheats_enabled = 1; // debug #endif draw_mode = check_param("draw") != NULL && cheats_enabled; demo_mode = check_param("demo") != NULL; init_copyprot_dialog(); #ifdef USE_REPLAY init_record_replay(); #endif if (cheats_enabled #ifdef USE_REPLAY || recording #endif ) { for (i = 14; i >= 0; --i) { snprintf(sprintf_temp, sizeof(sprintf_temp), "%d", i); if (check_param(sprintf_temp)) { start_level = i; break; } } } init_game_main(); }
t_lenv *core(t_lenv *env, char *line) { char **param; g_bool = 0; param = ft_split_whitespaces(line); if (param[0] && check_param(param[0]) == 0) exec_core(env, param); else if (param[0] && check_param(param[0]) == 1) env = ft_parse(env, param); if (g_bool != 2) print_prompt(); g_bool = 0; return (env); }
/* * ask the user to specify a blocksize */ static format_data_t ask_user_for_blksize(format_data_t params) { char c, str[ERR_LENGTH], buffer[20]; int i, rc; i = params.blksize; do { params.blksize = i; printf("Please enter the blocksize of the formatting [%d]: ", i); if (fgets(buffer, sizeof(buffer), stdin) == NULL) break; rc = sscanf(buffer,"%d%c", ¶ms.blksize, &c); if ((rc == 2) && (c == '\n')) rc = 1; if (rc == -1) rc = 1; /* this happens, if enter is pressed */ if (rc != 1) printf(" -- wrong input, try again.\n"); if (check_param(str, ERR_LENGTH, ¶ms) < 0) { printf(" -- %s\n",str); rc = 0; } } while (rc != 1); return params; }
char *ft_convert_base(char *nbr, char *base_from, char *base_to) { int nb; int nb_tmp; int size; int result; if (check_param(nbr, base_from, base_to) == 1) return (NULL); result = 1; nb = ft_base_ten(nbr, base_from); if (nb == -1) return (nbr); nb_tmp = nb; size = 0; while (result != 0) { nb_tmp = nb_tmp / (int)ft_strlen(base_to); result = nb_tmp; size++; } if ((nbr = (char*)malloc(sizeof(nbr) * (size + 1))) == NULL) return (NULL); ft_base_to(nbr, base_to, nb, size); nbr[size] = '\0'; return (nbr); }
int write_instructions(int fd, int fdwrite) { char *tmp; int size; int i; char *ins; char *param; t_asm *my_asm; i = 2; my_asm = NULL; while ((tmp = get_next_line(fd))) { i++; if (tmp != NULL && tmp[0] != '.' && all_space(tmp) != 0) { tmp = remove_space(tmp); ins = parse_action(tmp, 0); param = parse_action(tmp, 1); ins = remove_all_space(ins); param = remove_all_space(param); if (check_arg(ins) != 1 || check_param(ins, param) != 1) return (error_line(i)); my_asm = add_action(my_asm, ins, param); } } my_asm = my_asm->next; if ((size = instructions_file(fdwrite, my_asm)) == -1 || write_size(fdwrite, size) == -1) return (-1); return (0); }
int32 scriptlib::effect_get_operation(lua_State *L) { check_param_count(L, 1); check_param(L, PARAM_TYPE_EFFECT, 1); effect* peffect = *(effect**) lua_touserdata(L, 1); interpreter::function2value(L, peffect->operation); return 1; }
int32 scriptlib::effect_get_handler(lua_State *L) { check_param_count(L, 1); check_param(L, PARAM_TYPE_EFFECT, 1); effect* peffect = *(effect**) lua_touserdata(L, 1); interpreter::card2value(L, peffect->handler); return 1; }
int32 scriptlib::effect_get_handler_player(lua_State *L) { check_param_count(L, 1); check_param(L, PARAM_TYPE_EFFECT, 1); effect* peffect = *(effect**) lua_touserdata(L, 1); lua_pushinteger(L, peffect->get_handler_player()); return 1; }
void read_coordinates(FILE *fp, int *iatm, int count, int nb_atoms, PROT *prot) { int k; float x,y,z; int iConf; ATOM atom; for (k=0; k<nb_atoms; k++) { fread(&iConf,sizeof(int),1,fp); fread(&x,sizeof(float),1,fp); fread(&y,sizeof(float),1,fp); fread(&z,sizeof(float),1,fp); atom.serial = 0; strcpy(atom.name,prot->res[count].conf[1].atom[iatm[k]].name); atom.altLoc = prot->res[count].conf[1].atom[iatm[k]].altLoc; strcpy(atom.resName,prot->res[count].conf[1].atom[iatm[k]].resName); atom.chainID = prot->res[count].conf[1].atom[iatm[k]].chainID; atom.resSeq = prot->res[count].conf[1].atom[iatm[k]].resSeq; atom.iCode = prot->res[count].conf[1].atom[iatm[k]].iCode; atom.iConf = iConf; atom.xyz.x = x; atom.xyz.y = y; atom.xyz.z = z; atom.rad = prot->res[count].conf[1].atom[iatm[k]].rad; atom.crg = prot->res[count].conf[1].atom[iatm[k]].crg; //strcpy(atom.history,prot->res[count].conf[1].atom[iatm[k]].history); fread(atom.history, sizeof(char), 11, fp); //sprintf(atom.history,"%s","01R000M000");//fixed 03-31/2009 Pascal //printf("Atom History read:%s\n",atom.history); strcpy(atom.confName,atom.resName); strncpy(atom.confName+3,atom.history,2); atom.confName[5] = '\0'; sprintf(atom.confID,"%i",iConf);//length 8 check_param(atom,prot); } };
static int avro_datum_value_get_size(const avro_value_iface_t *iface, const void *vself, size_t *size) { AVRO_UNUSED(iface); const avro_datum_t self = (const avro_datum_t) vself; check_param(EINVAL, self, "datum instance"); if (is_avro_array(self)) { *size = avro_array_size(self); return 0; } if (is_avro_map(self)) { *size = avro_map_size(self); return 0; } if (is_avro_record(self)) { avro_schema_t schema = avro_datum_get_schema(self); *size = avro_schema_record_size(schema); return 0; } avro_set_error("Can only get size of array, map, or record, %d", avro_typeof(self)); return EINVAL; }
int main(int ac, char **av) { t_lst *a; t_lst *b; int i; a = NULL; b = NULL; i = 1; if (ac == 1) ft_putendl("Error. No number."); else { while (av[i]) { if (check_param(av[i]) == -1) { ft_putendl("Error."); exit(0); } a = add_new_number(a, av[i]); i++; } } ft_rra(&a); aff_lst(a); ft_putendl(""); aff_lst(b); ft_putendl(""); return (0); }
static int avro_datum_value_append(const avro_value_iface_t *iface, void *vself, avro_value_t *child_out, size_t *new_index) { AVRO_UNUSED(iface); avro_datum_t self = (avro_datum_t) vself; check_param(EINVAL, self, "datum instance"); if (!is_avro_array(self)) { avro_set_error("Can only append to array"); return EINVAL; } int rval; avro_schema_t array_schema = avro_datum_get_schema(self); avro_schema_t child_schema = avro_schema_array_items(array_schema); avro_datum_t child_datum = avro_datum_from_schema(child_schema); if (child_datum == NULL) { return ENOMEM; } rval = avro_array_append_datum(self, child_datum); avro_datum_decref(child_datum); if (rval != 0) { return rval; } if (new_index != NULL) { *new_index = avro_array_size(self) - 1; } return avro_datum_as_child_value(child_out, child_datum); }
int32 scriptlib::effect_clone(lua_State *L) { check_param_count(L, 1); check_param(L, PARAM_TYPE_EFFECT, 1); effect* peffect = *(effect**) lua_touserdata(L, 1); duel* pduel = peffect->pduel; effect* ceffect = pduel->new_effect(); int32 ref = ceffect->ref_handle; *ceffect = *peffect; ceffect->ref_handle = ref; ceffect->handler = 0; ceffect->effect_owner = PLAYER_NONE; if(peffect->condition) { lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->condition); ceffect->condition = luaL_ref(L, LUA_REGISTRYINDEX); } if(peffect->cost) { lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->cost); ceffect->cost = luaL_ref(L, LUA_REGISTRYINDEX); } if(peffect->target) { lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->target); ceffect->target = luaL_ref(L, LUA_REGISTRYINDEX); } if(peffect->operation) { lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->operation); ceffect->operation = luaL_ref(L, LUA_REGISTRYINDEX); } if(peffect->value && (peffect->flag & EFFECT_FLAG_FUNC_VALUE)) { lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->value); ceffect->value = luaL_ref(L, LUA_REGISTRYINDEX); } interpreter::effect2value(L, ceffect); return 1; }
int avro_schema_union_append(const avro_schema_t union_schema, const avro_schema_t schema) { check_param(EINVAL, is_avro_schema(union_schema), "union schema"); check_param(EINVAL, is_avro_union(union_schema), "union schema"); check_param(EINVAL, is_avro_schema(schema), "schema"); struct avro_union_schema_t *unionp = avro_schema_to_union(union_schema); int new_index = unionp->branches->num_entries; st_insert(unionp->branches, new_index, (st_data_t) schema); const char *name = avro_schema_type_name(schema); st_insert(unionp->branches_byname, (st_data_t) name, (st_data_t) new_index); avro_schema_incref(schema); return 0; }
int32 scriptlib::effect_set_property(lua_State *L) { check_param_count(L, 2); check_param(L, PARAM_TYPE_EFFECT, 1); effect* peffect = *(effect**) lua_touserdata(L, 1); int32 v = lua_tointeger(L, 2); peffect->flag |= v & 0xfffffff0; return 0; }
static int avro_datum_value_set_null(const avro_value_iface_t *iface, void *vself) { AVRO_UNUSED(iface); avro_datum_t self = (avro_datum_t) vself; check_param(EINVAL, is_avro_null(self), "datum instance"); return 0; }
static avro_schema_t avro_datum_value_get_schema(const avro_value_iface_t *iface, const void *vself) { AVRO_UNUSED(iface); const avro_datum_t self = (const avro_datum_t) vself; check_param(NULL, self, "datum instance"); return avro_datum_get_schema(self); }
static int avro_datum_value_reset(const avro_value_iface_t *iface, void *vself) { AVRO_UNUSED(iface); avro_datum_t self = (avro_datum_t) vself; check_param(EINVAL, self, "datum instance"); return avro_datum_reset(self); }
int32 scriptlib::effect_set_range(lua_State *L) { check_param_count(L, 2); check_param(L, PARAM_TYPE_EFFECT, 1); effect* peffect = *(effect**) lua_touserdata(L, 1); int32 v = lua_tointeger(L, 2); peffect->range = v; return 0; }
int32 scriptlib::effect_is_activatable(lua_State *L) { check_param_count(L, 2); check_param(L, PARAM_TYPE_EFFECT, 1); uint32 playerid = lua_tointeger(L, 2); effect* peffect = *(effect**) lua_touserdata(L, 1); lua_pushboolean(L, peffect->is_activateable(playerid, peffect->pduel->game_field->nil_event)); return 1; }
/* thread function */ void * threaded ( void * arg ) { int ret = 0; struct sched_param sp; /* Set priority to a known value */ sp.sched_priority = sched_get_priority_max( SCHED_RR ); ret = pthread_setschedparam( pthread_self(), SCHED_RR, &sp ); if ( ret != 0 ) { UNRESOLVED( ret, "Failed to set thread policy -- need to be root?" ); } /* check the thread attributes have been applied (we only check what is reported, not the real behavior) */ check_param( pthread_self(), SCHED_RR, sp.sched_priority ); /* Now set the priority to an invalid value. */ sp.sched_priority++; ret = pthread_setschedparam( pthread_self(), SCHED_RR, &sp ); if ( ret != 0 ) { /* check the thread attributes have been applied (we only check what is reported, not the real behavior) */ check_param( pthread_self(), SCHED_RR, sp.sched_priority - 1 ); #if VERBOSE > 0 output( "Setting to a wrong priority failed with error %d (%s).\n", ret, strerror( ret ) ); } else { output( "UNTESTED: setting to max prio + 1 did not fail.\n" ); #endif } return NULL; }
int avro_schema_from_json_length(const char *jsontext, size_t length, avro_schema_t *schema) { check_param(EINVAL, jsontext, "JSON text"); check_param(EINVAL, schema, "schema pointer"); json_t *root; json_error_t json_error; root = json_loadb(jsontext, length, 0, &json_error); if (!root) { avro_set_error("Error parsing JSON: %s", json_error.text); return EINVAL; } return avro_schema_from_json_root(root, schema); }
int32 scriptlib::debug_pre_equip(lua_State *L) { check_param_count(L, 2); check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 2); card* equip_card = *(card**) lua_touserdata(L, 1); card* target = *(card**) lua_touserdata(L, 2); if((equip_card->current.location != LOCATION_SZONE) || (target->current.location != LOCATION_MZONE) || (target->current.position & POS_FACEDOWN)) lua_pushboolean(L, 0); else { equip_card->equip(target, FALSE); equip_card->effect_target_cards.insert(target); target->effect_target_owner.insert(equip_card); lua_pushboolean(L, 1); } return 1; }
int32 scriptlib::debug_pre_add_counter(lua_State *L) { check_param_count(L, 2); check_param(L, PARAM_TYPE_CARD, 1); card* pcard = *(card**) lua_touserdata(L, 1); uint32 ctype = lua_tointeger(L, 2); uint32 ccount = lua_tointeger(L, 3); pcard->counters[ctype] += ccount; return 0; }
static int avro_datum_value_set_fixed(const avro_value_iface_t *iface, void *vself, void *buf, size_t size) { AVRO_UNUSED(iface); avro_datum_t self = (avro_datum_t) vself; check_param(EINVAL, self, "datum instance"); return avro_fixed_set(self, (const char *) buf, size); }