static void reset_match(match_record_t *match) { make_null(&match->best_key); make_null(&match->match_key); match->priority = match->no_match_priority; }
/* Get the BuildChar and/or BuildGlyph routines from a (base) font. */ int build_gs_font_procs(os_ptr op, build_proc_refs * pbuild) { int ccode, gcode; ref *pBuildChar; ref *pBuildGlyph; check_type(*op, t_dictionary); ccode = dict_find_string(op, "BuildChar", &pBuildChar); gcode = dict_find_string(op, "BuildGlyph", &pBuildGlyph); if (ccode <= 0) { if (gcode <= 0) return_error(e_invalidfont); make_null(&pbuild->BuildChar); } else { check_proc(*pBuildChar); pbuild->BuildChar = *pBuildChar; } if (gcode <= 0) make_null(&pbuild->BuildGlyph); else { check_proc(*pBuildGlyph); pbuild->BuildGlyph = *pBuildGlyph; } return 0; }
static value_object eval_function(char* name, expr_list* args) { expr_list* head = args; value_list* arg_vals = NULL; while (head != NULL) { value_object v = eval_aux(head->expression); arg_vals = append_value(arg_vals, v); head = head->next; } fpl_function fun; symbol_def* symbol = find_symbol(name); if (symbol == NULL) { fprintf(stderr, "Error: function `%s' does not exist\n", name); return make_null(); } if (symbol->type != SYM_FUNCTION) { fprintf(stderr, "Error: `%s' is not a function\n", name); return make_null(); } value_object val = (symbol->function)(arg_vals); return val; }
void func() { void *CallTest = make_null(); int var = 1; void *CommaTest = (var+=2, make_null()); int *CastTest = static_cast<int*>(make_null()); }
int main(){ struct foo hoo; no(1); make_null(&hoo); make_null(&hoo); return 1; }
static value_object get_variable_value(const char* name) { symbol_def* symbol = find_symbol(name); if (symbol == NULL) { fprintf(stderr, "Error: symbol `%s' not found\n", name); return make_null(); } if (symbol->type != SYM_VARIABLE) { fprintf(stderr, "Error: `%s' is not a variable\n", name); return make_null(); } return symbol->value; }
/* Get the additional information for a CIDFontType 0 or 2 CIDFont. */ int cid_font_data_param(os_ptr op, gs_font_cid_data *pdata, ref *pGlyphDirectory) { int code; ref *pgdir; check_type(*op, t_dictionary); if ((code = cid_font_system_info_param(&pdata->CIDSystemInfo, op)) < 0 || (code = dict_int_param(op, "CIDCount", 0, max_int, -1, &pdata->CIDCount)) < 0 ) return code; /* * If the font doesn't have a GlyphDirectory, GDBytes is required. * If it does have a GlyphDirectory, GDBytes may still be needed for * CIDMap: it's up to the client to check this. */ if (dict_find_string(op, "GlyphDirectory", &pgdir) <= 0) { /* Standard CIDFont, require GDBytes. */ make_null(pGlyphDirectory); return dict_int_param(op, "GDBytes", 1, MAX_GDBytes, 0, &pdata->GDBytes); } if (r_has_type(pgdir, t_dictionary) || r_is_array(pgdir)) { /* GlyphDirectory, GDBytes is optional. */ *pGlyphDirectory = *pgdir; code = dict_int_param(op, "GDBytes", 0, MAX_GDBytes, 0, &pdata->GDBytes); return code; } else { return_error(e_typecheck); } }
static value_object eval_aux(expr* node) { if (node == NULL) return make_null(); if (node->type == EXP_ASSIGN) return assign_value(node->left, node->right); value_object left = eval_aux(node->left); value_object right = eval_aux(node->right); switch (node->type) { case EXP_PLUS: return add_values(left, right); case EXP_MINUS: return sub_values(left, right); case EXP_TIMES: return mul_values(left, right); case EXP_DIV: return div_values(left, right); case EXP_INT: return make_int(atoi(node->text)); case EXP_FLOAT: return make_float(to_float64(node->text)); case EXP_NATIVE: return make_native(atof(node->text)); case EXP_CALL: return eval_function(node->text, node->args); case EXP_ID: return get_variable_value(node->text); case EXP_UNMINUS: return negate_value(left); } }
int build_gs_FDArray_font(i_ctx_t *i_ctx_p, ref *op, gs_font_base **ppfont, font_type ftype, gs_memory_type_ptr_t pstype, const build_proc_refs * pbuild) { gs_font_base *pfont; font_data *pdata; int code = build_gs_outline_font(i_ctx_p, op, &pfont, ftype, pstype, pbuild, bf_options_none, build_FDArray_sub_font); static const double bbox[4] = { 0, 0, 0, 0 }; gs_uid uid; if (code < 0) return code; pdata = pfont_data(pfont); /* Fill in members normally set by build_gs_primitive_font. */ make_null(&pdata->CharStrings); /* Fill in members normally set by build_gs_simple_font. */ uid_set_invalid(&uid); init_gs_simple_font(pfont, bbox, &uid); pfont->encoding_index = ENCODING_INDEX_UNKNOWN; pfont->nearest_encoding_index = ENCODING_INDEX_UNKNOWN; /* Fill in members normally set by build_gs_font. */ pfont->key_name = pfont->font_name; *ppfont = pfont; return 0; }
/* or if they are identical. */ void packed_get(const gs_memory_t *mem, const ref_packed * packed, ref * pref) { const ref_packed elt = *packed; uint value = elt & packed_value_mask; switch (elt >> r_packed_type_shift) { default: /* (shouldn't happen) */ make_null(pref); break; case pt_executable_operator: op_index_ref(value, pref); break; case pt_integer: make_int(pref, (int)value + packed_min_intval); break; case pt_literal_name: name_index_ref(mem, value, pref); break; case pt_executable_name: name_index_ref(mem, value, pref); r_set_attrs(pref, a_executable); break; case pt_full_ref: case pt_full_ref + 1: ref_assign(pref, (const ref *)packed); } }
/* The caller guarantees that *op is a dictionary. */ int build_gs_primitive_font(i_ctx_t *i_ctx_p, os_ptr op, gs_font_base ** ppfont, font_type ftype, gs_memory_type_ptr_t pstype, const build_proc_refs * pbuild, build_font_options_t options) { ref *pcharstrings = 0; ref CharStrings; gs_font_base *pfont; font_data *pdata; int code; if (dict_find_string(op, "CharStrings", &pcharstrings) <= 0) { if (!(options & bf_CharStrings_optional)) return_error(e_invalidfont); } else { ref *ignore; if (!r_has_type(pcharstrings, t_dictionary)) return_error(e_invalidfont); if ((options & bf_notdef_required) != 0 && dict_find_string(pcharstrings, ".notdef", &ignore) <= 0 ) return_error(e_invalidfont); /* * Since build_gs_simple_font may resize the dictionary and cause * pointers to become invalid, save CharStrings. */ CharStrings = *pcharstrings; } code = build_gs_outline_font(i_ctx_p, op, ppfont, ftype, pstype, pbuild, options, build_gs_simple_font); if (code != 0) return code; pfont = *ppfont; pdata = pfont_data(pfont); if (pcharstrings) ref_assign(&pdata->CharStrings, &CharStrings); else make_null(&pdata->CharStrings); /* Check that the UniqueIDs match. This is part of the */ /* Adobe protection scheme, but we may as well emulate it. */ if (uid_is_valid(&pfont->UID) && !dict_check_uid_param(op, &pfont->UID) ) uid_set_invalid(&pfont->UID); if (uid_is_valid(&pfont->UID)) { const gs_font *pfont0 = (const gs_font *)pfont; code = gs_font_find_similar(ifont_dir, &pfont0, font_with_same_UID_and_another_metrics); if (code < 0) return code; /* Must not happen. */ if (code) uid_set_invalid(&pfont->UID); } return 0; }
/* Take a key's value from a given dictionary, create [/key any] array, * and store it in $error.errorinfo. * The key must be a permanently allocated C string. */ void gs_errorinfo_put_pair_from_dict(i_ctx_t *i_ctx_p, const ref *op, const char *key) { ref *val, n; if (dict_find_string(op, key, &val) <= 0) { make_null(&n); val = &n; } gs_errorinfo_put_pair(i_ctx_p, key, strlen(key), val); }
void init_sim(int argc, char **argv) { topology_file.open(argv[1], std::ifstream::in); messages_file.open(argv[2], std::ifstream::in); events_file.open(argv[3], std::ifstream::in); topology_file >> node_ct; messages_file >> msg_ct; events_file >> time_ct; events_file >> event_ct; routers.clear(); //creem obiectele de tip Router for(int i = 0; i < node_ct; ++i) routers.push_back( Router(i, node_ct) ); int r1, cost, r2; while( (topology_file >> r1 >> cost >> r2) ) { //anuntam routerele despre vecinii lor directi routers[r1].add_nbrh(r2, cost); routers[r2].add_nbrh(r1, cost); } //std::cout << " [init_sim] sau initilizat " << routers.size() << " routere . . .\n"; //incepem flodarea retelei cu mesaje despre vecini char nbrh_msg[LEN]; for(unsigned int i = 0; i < routers.size(); ++i) { routers[i].table.set_node_no(node_ct); routers[i].topology.set_node_no(node_ct); routers[i].known_tags.clear(); } for(unsigned int i = 0; i < routers.size(); ++i) { make_null(nbrh_msg, LEN); //fiecarui mesaj din prima parte a algoritmului de flodare //ii setam tagul egal cu -id-ul routerului care la pornit //in acest fel mesajele ce contin toti vecini vor avea tagul un numar negativ sau 0 sprintf(nbrh_msg, "%d ", -i); //tag == -i sprintf(nbrh_msg + strlen(nbrh_msg), "%d %d ", i, routers[i].nbrh.size()); for(unsigned int j = 0; j < routers[i].nbrh.size(); ++j) { sprintf(nbrh_msg + strlen(nbrh_msg), "%d %d ", routers[i].nbrh[j], routers[i].get_nbrh_cost(routers[i].nbrh[j])); } for(unsigned int j = 0; j < routers[i].nbrh.size(); ++j) { //cout << "----------------de la " << i << " la " << j << " sa trimis " << nbrh_msg << "\n"; endpoint[i].send_msg(&endpoint[routers[i].nbrh[j]], nbrh_msg, strlen(nbrh_msg), NULL); } } }
/* Finish setscreen. */ static int setscreen_finish(i_ctx_t *i_ctx_p) { gs_screen_install(senum); istate->screen_procs.red = sproc; istate->screen_procs.green = sproc; istate->screen_procs.blue = sproc; istate->screen_procs.gray = sproc; make_null(&istate->halftone); return 0; }
/* * Swap an entry from a higher level dictionary into a base dictionary. * elt[0] is the key, elt[1] is the current value in the Level 2 dictionary * (*pdict2). */ static int swap_entry(i_ctx_t *i_ctx_p, ref elt[2], ref * pdict, ref * pdict2) { ref *pvalue; #ifdef PACIFY_VALGRIND ref old_value = { 0 }; /* current value in *pdict */ #else ref old_value; /* current value in *pdict */ #endif int found = dict_find(pdict, &elt[0], &pvalue); switch (found) { default: /* <0, error */ /* * The only possible error here is a dictfull error, which is * harmless. */ /* fall through */ case 0: /* missing */ make_null(&old_value); break; case 1: /* present */ old_value = *pvalue; } /* * Temporarily flag the dictionaries as local, so that we don't * get invalidaccess errors. (We know that they are both * referenced from systemdict, so they are allowed to reference * local objects even if they are global.) */ { uint space2 = r_space(pdict2); int code; r_set_space(pdict2, avm_local); idict_put(pdict2, &elt[0], &old_value); if (r_has_type(&elt[1], t_null)) { code = idict_undef(pdict, &elt[0]); if (code == gs_error_undefined && r_has_type(&old_value, t_null) ) code = 0; } else { uint space = r_space(pdict); r_set_space(pdict, avm_local); code = idict_put(pdict, &elt[0], &elt[1]); r_set_space(pdict, space); } r_set_space(pdict2, space2); return code; } }
static value_object negate_value(value_object x) { if (x.type == VAL_FLOAT) return make_float(FPL_negate_64(x.float_value)); else if (x.type == VAL_NATIVE) return make_native(- x.native_value); else if (x.type == VAL_INT) return make_int(- x.int_value); else { fprintf(stderr, "Error: trying to negate null\n"); return make_null(); } }
/* * Set up to collect the data for the sampled function. This is used for * those alternate tint transforms that cannot be converted into a * type 4 function. */ static int sampled_data_setup(i_ctx_t *i_ctx_p, gs_function_t *pfn, const ref * pproc, int (*finish_proc)(i_ctx_t *), gs_memory_t * mem) { os_ptr op = osp; gs_sampled_data_enum *penum; int i; gs_function_Sd_params_t * params = (gs_function_Sd_params_t *)&pfn->params; check_estack(estack_storage + 1); /* Verify space on estack */ check_ostack(params->m + O_STACK_PAD); /* and the operand stack */ check_ostack(params->n + O_STACK_PAD); /* * Allocate space for the enumerator data structure. */ penum = gs_sampled_data_enum_alloc(imemory, "zbuildsampledfuntion(params)"); if (penum == NULL) return_error(e_VMerror); /* Initialize data in the enumeration structure */ penum->pfn = pfn; for(i=0; i< params->m; i++) penum->indexes[i] = 0; /* * Save stack depth for checking the correct number of values on stack * after the function, which is being sampled, is called. */ penum->o_stack_depth = ref_stack_count(&o_stack); /* * Note: As previously mentioned, we are putting some spare (unused) stack * space under the input values in case the function unbalances the stack. * It is possible for the function to pop or change values on the stack * outside of the input values. (This has been found to happen with some * proc sets from Adobe.) */ push(O_STACK_PAD); for (i = 0; i < O_STACK_PAD; i++) /* Set space = null */ make_null(op - i); /* Push everything on the estack */ esp += estack_storage; make_op_estack(esp - 2, finish_proc); /* Finish proc onto estack */ sample_proc = *pproc; /* Save function to be sampled */ make_istruct(esp, 0, penum); /* Color cube enumeration structure */ push_op_estack(sampled_data_sample); /* Start sampling data */ return o_push_estack; }
/* Initialize for writing parameters. */ static void ref_param_write_init(iparam_list * plist, const ref * pwanted, gs_ref_memory_t *imem) { gs_param_list_init((gs_param_list *)plist, &ref_write_procs, (gs_memory_t *)imem); plist->ref_memory = imem; if (pwanted == 0) make_null(&plist->u.w.wanted); else plist->u.w.wanted = *pwanted; plist->results = 0; plist->int_keys = false; }
/* Convert strings to executable names for build_proc_refs. */ int build_proc_name_refs(const gs_memory_t *mem, build_proc_refs * pbuild, const char *bcstr, const char *bgstr) { int code; if (!bcstr) make_null(&pbuild->BuildChar); else { if ((code = name_ref(mem, (const byte *)bcstr, strlen(bcstr), &pbuild->BuildChar, 0)) < 0) return code; r_set_attrs(&pbuild->BuildChar, a_executable); } if (!bgstr) make_null(&pbuild->BuildGlyph); else { if ((code = name_ref(mem, (const byte *)bgstr, strlen(bgstr), &pbuild->BuildGlyph, 0)) < 0) return code; r_set_attrs(&pbuild->BuildGlyph, a_executable); } return 0; }
/* <hue> <saturation> <brightness> sethsbcolor - */ static int zsethsbcolor(i_ctx_t *i_ctx_p) { os_ptr op = osp; double par[3]; int code; if ((code = num_params(op, 3, par)) < 0 || (code = gs_sethsbcolor(igs, par[0], par[1], par[2])) < 0 ) return code; make_null(&istate->colorspace.array); pop(3); return 0; }
static value_object div_values(value_object x, value_object y) { value_type common = coerce(&x, &y); if (common == VAL_NULL) { fprintf(stderr, "Error: trying to divide null objects\n"); return make_null(); } else if (common == VAL_FLOAT) return make_float(FPL_division_64(x.float_value, y.float_value)); else if (common == VAL_NATIVE) return make_native(x.native_value / y.native_value); else return make_int(x.int_value / y.int_value); }
/* Get the calling operator for error reporting in %Type32BuildGlyph */ static int zgetshowoperator(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_text_enum_t *osenum = op_show_find(i_ctx_p); push(1); if (osenum == NULL) make_null(op); else { op_proc_t proc; *(void **)&proc = osenum->enum_client_data; make_oper(op, 0, proc); } return 0; }
/* - .currentpagedevice <dict> <bool> */ static int zcurrentpagedevice(i_ctx_t *i_ctx_p) { os_ptr op = osp; gx_device *dev = gs_currentdevice(igs); push(2); if ((*dev_proc(dev, get_page_device))(dev) != 0) { op[-1] = istate->pagedevice; make_true(op); } else { make_null(op - 1); make_false(op); } return 0; }
/* Install the color screen after sampling. */ static int setcolorscreen_finish(i_ctx_t *i_ctx_p) { gx_device_halftone *pdht = r_ptr(esp, gx_device_halftone); int code; pdht->order = pdht->components[0].corder; code = gx_ht_install(igs, r_ptr(esp - 1, gs_halftone), pdht); if (code < 0) return code; memcpy(&istate->screen_procs.red, esp - 5, sizeof(ref) * 4); make_null(&istate->halftone); esp -= 7; setcolorscreen_cleanup(i_ctx_p); return o_pop_estack; }
/* Returns 1 if a glyph presents, 0 if not, <0 if error. */ int cid_to_TT_charcode(const gs_memory_t *mem, const ref *Decoding, const ref *TT_cmap, const ref *SubstNWP, uint nCID, uint *c, ref *src_type, ref *dst_type) { int SubstNWP_length = r_size(SubstNWP), i, code; if (TT_char_code_from_CID_no_subst(mem, Decoding, TT_cmap, nCID, c)) { make_null(src_type); /* Leaving dst_type uninitialized. */ return 1; } for (i = 0; i < SubstNWP_length; i += 5) { ref rb, re, rs; int nb, ne, ns; if ((code = array_get(mem, SubstNWP, i + 1, &rb)) < 0) return code; if ((code = array_get(mem, SubstNWP, i + 2, &re)) < 0) return code; if ((code = array_get(mem, SubstNWP, i + 3, &rs)) < 0) return code; nb = rb.value.intval; ne = re.value.intval; ns = rs.value.intval; if (nCID >= nb && nCID <= ne) if (TT_char_code_from_CID_no_subst(mem, Decoding, TT_cmap, ns + (nCID - nb), c)) { if ((code = array_get(mem, SubstNWP, i + 0, src_type)) < 0) return code; if ((code = array_get(mem, SubstNWP, i + 4, dst_type)) < 0) return code; return 1; } if (nCID >= ns && nCID <= ns + (ne - nb)) if (TT_char_code_from_CID_no_subst(mem, Decoding, TT_cmap, nb + (nCID - ns), c)) { if ((code = array_get(mem, SubstNWP, i + 0, dst_type)) < 0) return code; if ((code = array_get(mem, SubstNWP, i + 4, src_type)) < 0) return code; return 1; } } *c = 0; return 0; }
/* Install the color screen after sampling. */ static int setcolorscreen_finish(i_ctx_t *i_ctx_p) { gx_device_halftone *pdht = r_ptr(esp, gx_device_halftone); int code; pdht->order = pdht->components[0].corder; code = gx_ht_install(igs, r_ptr(esp - 1, gs_halftone), pdht); if (code < 0) return code; istate->screen_procs.red = esp[-5]; istate->screen_procs.green = esp[-4]; istate->screen_procs.blue = esp[-3]; istate->screen_procs.gray = esp[-2]; make_null(&istate->halftone); esp -= 7; setcolorscreen_cleanup(i_ctx_p); return o_pop_estack; }
/* <string> <charstring> .stringbreak <int|null> */ static int zstringbreak(i_ctx_t *i_ctx_p) { os_ptr op = osp; uint i, j; check_read_type(op[-1], t_string); check_read_type(*op, t_string); /* We can't use strpbrk here, because C doesn't allow nulls in strings. */ for (i = 0; i < r_size(op - 1); ++i) for (j = 0; j < r_size(op); ++j) if (op[-1].value.const_bytes[i] == op->value.const_bytes[j]) { make_int(op - 1, i); goto done; } make_null(op - 1); done: pop(1); return 0; }
/* <int> .getiodevice <string|null> */ static int zgetiodevice(i_ctx_t *i_ctx_p) { os_ptr op = osp; gx_io_device *iodev; const byte *dname; check_type(*op, t_integer); if (op->value.intval != (int)op->value.intval) return_error(e_rangecheck); iodev = gs_getiodevice((int)(op->value.intval)); if (iodev == 0) /* index out of range */ return_error(e_rangecheck); dname = (const byte *)iodev->dname; if (dname == 0) make_null(op); else make_const_string(op, a_readonly | avm_foreign, strlen((const char *)dname), dname); return 0; }
/* - gstate <gstate> */ int zgstate(i_ctx_t *i_ctx_p) { os_ptr op = osp; int code = gstate_check_space(i_ctx_p, istate, icurrent_space); igstate_obj *pigo; gs_state *pnew; int_gstate *isp; if (code < 0) return code; pigo = ialloc_struct(igstate_obj, &st_igstate_obj, "gstate"); if (pigo == 0) return_error(e_VMerror); pnew = gs_state_copy(igs, imemory); if (pnew == 0) { ifree_object(pigo, "gstate"); return_error(e_VMerror); } isp = gs_int_gstate(pnew); int_gstate_map_refs(isp, ref_mark_new); push(1); /* * Since igstate_obj isn't a ref, but only contains a ref, save won't * clear its l_new bit automatically, and restore won't set it * automatically; we have to make sure this ref is on the changes chain. */ make_iastruct(op, a_all, pigo); #if 0 /* Bug 689849 "gstate leaks memory" */ make_null(&pigo->gstate); ref_save(op, &pigo->gstate, "gstate"); make_istruct_new(&pigo->gstate, 0, pnew); #else make_istruct(&pigo->gstate, 0, pnew); #endif return 0; }
/* Initialize for reading parameters. */ static int ref_param_read_init(iparam_list * plist, uint count, const ref * ppolicies, bool require_all, gs_ref_memory_t *imem) { gs_param_list_init((gs_param_list *)plist, &ref_read_procs, (gs_memory_t *)imem); plist->ref_memory = imem; if (ppolicies == 0) make_null(&plist->u.r.policies); else plist->u.r.policies = *ppolicies; plist->u.r.require_all = require_all; plist->count = count; plist->results = (int *) gs_alloc_byte_array(plist->memory, count, sizeof(int), "ref_param_read_init"); if (plist->results == 0) return_error(e_VMerror); memset(plist->results, 0, count * sizeof(int)); plist->int_keys = false; return 0; }