static bp_stmt_t find_label(bp_stmt_t p, char* label) { bp_stmt_t temp; if (!p) return NULL; if ((p->label) != NULL) if ( strcmp(p->label, label) == 0) return (p); switch (p->type) { case BP_IF: case BP_ELSEIF: case BP_WHILE: { temp = find_label(p->e.c.thenstmt, label); if (temp != NULL) return temp; temp = find_label(p->e.c.elsestmt, label); if (temp != NULL) return temp; break; } } return (find_label(p->next, label)); }
int init_conf() { char *val = NULL; struct sockaddr_in s_addr; query_conf *general = NULL; query_conf *conf = NULL; if ((conf = load_configuration(sconf_file)) == NULL) { return -1; } if ((general = find_label(conf, (char*)"socket")) == NULL) { free_configuration(&conf); return -1; } if ((val = get_value_from_label(general, (char*)"synconf_ip")) != NULL) sc.s_ip = inet_atoul(val); printf("ip:%s\n", val); if ((val = get_value_from_label(general, (char*)"synconf_port")) != NULL) sc.s_port = (unsigned short)atoi(val); printf("port:%d\n", sc.s_port); free_configuration(&conf); return 0; }
void deal_all_label_value(query_conf *que, char *item_name) { conf_item *item = NULL; char *res = NULL; if ((que == NULL) || (item_name == NULL)) return; query_conf *mod_option_conf = NULL; query_conf *mod_items_conf = NULL; query_conf *mod_item_label_name = NULL; char *mod_items_path = "mod_items.conf"; if ((mod_items_conf = load_configuration(mod_items_path)) == NULL) { return; } item = que->label_item; while (item != NULL) { if (strcmp(item->item_value, "yes") == 0) { if ((mod_item_label_name = find_label(mod_items_conf, item->item_name)) == NULL) { free_configuration(&mod_items_conf); return; } deal_all_item_value(mod_item_label_name, "null"); } //printf("%s\n", item->item_value); item = item->item_next; } }
void define_common(char *label, int32_t segment, int32_t size, char *special) { union label *lptr; lptr = find_label(label, 1); if (!lptr) return; if ((lptr->defn.is_global & DEFINED_BIT) && (passn == 1 || !(lptr->defn.is_global & COMMON_BIT))) { nasm_error(ERR_NONFATAL, "symbol `%s' redefined", label); return; } lptr->defn.is_global |= DEFINED_BIT|COMMON_BIT; if (!islocalchar(label[0])) { prevlabel = lptr->defn.label; } else { nasm_error(ERR_NONFATAL, "attempt to define a local label as a " "common variable"); return; } lptr->defn.segment = segment; lptr->defn.offset = 0; if (pass0 == 0) return; ofmt->symdef(lptr->defn.label, segment, size, 2, special ? special : lptr->defn.special); ofmt->current_dfmt->debug_deflabel(lptr->defn.label, segment, size, 2, special ? special : lptr->defn.special); }
void define_common (char *label, long segment, long size, char *special, struct ofmt *ofmt, efunc error) { union label *lptr; lptr = find_label (label, 1); if (lptr->defn.is_global & DEFINED_BIT) { error(ERR_NONFATAL, "symbol `%s' redefined", label); return; } lptr->defn.is_global |= DEFINED_BIT; if (label[0] != '.') /* not local, but not special either */ prevlabel = lptr->defn.label; else error(ERR_NONFATAL, "attempt to define a local label as a " "common variable"); lptr->defn.segment = segment; lptr->defn.offset = 0; ofmt->symdef (lptr->defn.label, segment, size, 2, special ? special : lptr->defn.special); ofmt->current_dfmt->debug_deflabel(lptr->defn.label, segment, size, 2, special ? special : lptr->defn.special); }
void declare_as_global (char *label, char *special, efunc error) { union label *lptr; if (islocal(label)) { error(ERR_NONFATAL, "attempt to declare local symbol `%s' as" " global", label); return; } lptr = find_label (label, 1); switch (lptr->defn.is_global & TYPE_MASK) { case NOT_DEFINED_YET: lptr->defn.is_global = GLOBAL_PLACEHOLDER; lptr->defn.special = special ? perm_copy(special, "") : NULL; break; case GLOBAL_PLACEHOLDER: /* already done: silently ignore */ case GLOBAL_SYMBOL: break; case LOCAL_SYMBOL: if (!lptr->defn.is_global & EXTERN_BIT) error(ERR_NONFATAL, "symbol `%s': GLOBAL directive must" " appear before symbol definition", label); break; } }
static int probe_exfat(blkid_probe pr, const struct blkid_idmag *mag) { struct exfat_super_block *sb; struct exfat_entry_label *label; sb = blkid_probe_get_sb(pr, mag, struct exfat_super_block); if (!sb || !CLUSTER_SIZE(sb)) return errno ? -errno : BLKID_PROBE_NONE; label = find_label(pr, sb); if (label) blkid_probe_set_utf8label(pr, label->name, min(label->length * 2, 30), BLKID_ENC_UTF16LE); else if (errno) return -errno; blkid_probe_sprintf_uuid(pr, sb->volume_serial, 4, "%02hhX%02hhX-%02hhX%02hhX", sb->volume_serial[3], sb->volume_serial[2], sb->volume_serial[1], sb->volume_serial[0]); blkid_probe_sprintf_version(pr, "%u.%u", sb->version.vermaj, sb->version.vermin); return BLKID_PROBE_OK; }
void redefine_label (char *label, long segment, long offset, char *special, int is_norm, int isextrn, struct ofmt *ofmt, efunc error) { union label *lptr; /* This routine possibly ought to check for phase errors. Most assemblers * check for phase errors at this point. I don't know whether phase errors * are even possible, nor whether they are checked somewhere else */ (void) segment; /* Don't warn that this parameter is unused */ (void) offset; /* Don't warn that this parameter is unused */ (void) special; /* Don't warn that this parameter is unused */ (void) is_norm; /* Don't warn that this parameter is unused */ (void) isextrn; /* Don't warn that this parameter is unused */ (void) ofmt; /* Don't warn that this parameter is unused */ #ifdef DEBUG if (!strncmp(label, "debugdump", 9)) fprintf(stderr, "debug: redefine_label (%s, %ld, %08lx, %s, %d, %d)\n", label, segment, offset, special, is_norm, isextrn); #endif if (!islocal(label)) { lptr = find_label (label, 1); if (!lptr) error (ERR_PANIC, "can't find label `%s' on pass two", label); if (*label != '.' && lptr->defn.is_norm) prevlabel = lptr->defn.label; } }
void declare_as_global(char *label, char *special) { union label *lptr; if (islocal(label)) { nasm_error(ERR_NONFATAL, "attempt to declare local symbol `%s' as" " global", label); return; } lptr = find_label(label, 1); if (!lptr) return; switch (lptr->defn.is_global & TYPE_MASK) { case NOT_DEFINED_YET: lptr->defn.is_global = GLOBAL_PLACEHOLDER; lptr->defn.special = special ? perm_copy(special) : NULL; break; case GLOBAL_PLACEHOLDER: /* already done: silently ignore */ case GLOBAL_SYMBOL: break; case LOCAL_SYMBOL: if (!(lptr->defn.is_global & EXTERN_BIT)) { nasm_error(ERR_WARNING, "symbol `%s': GLOBAL directive " "after symbol definition is an experimental feature", label); lptr->defn.is_global = GLOBAL_SYMBOL; } break; } }
static VOID display_label_info(CHAR16 *name) { CHAR16 *desc; CHAR16 initrd_name[PATHNAME_MAXLEN]; CHAR16 vmcode_name[PATHNAME_MAXLEN]; CHAR16 options_tmp[CMDLINE_MAXLEN]; CHAR16 options[CMDLINE_MAXLEN]; CHAR16 kname[FILENAME_MAXLEN]; desc = find_description(name); if (desc) { Print(L"desc : %s\n", desc); } initrd_name[0] = vmcode_name[0] = options_tmp[0] = kname[0] = CHAR_NULL; if (find_label(name, kname, options_tmp, initrd_name, vmcode_name) == -1) { StrCpy(kname, name); Print(L"\n"); } subst_vars(options_tmp, options, CMDLINE_MAXLEN); Print(L"cmdline: %s %s\n", kname, options); if (initrd_name[0]) Print(L"initrd : %s\n", initrd_name); if (vmcode_name[0]) Print(L"vmcode : %s\n", vmcode_name); }
static void recursive_eliminate_goto_print_skip(bp_stmt_t p, bp_fun_t fun) { int tmp; bp_stmt_t z; if (!p) return; switch (p->type) { case BP_IF: case BP_ELSEIF: case BP_WHILE: { p->next_then = next_no_skip_goto_skip(p->e.c.thenstmt, fun); recursive_eliminate_goto_print_skip(p->e.c.thenstmt, fun); p->next_else = next_no_skip_goto_skip(p->e.c.elsestmt, fun); recursive_eliminate_goto_print_skip(p->e.c.elsestmt, fun); break; } } if ((p->type) == BP_GOTO) p->next_stmt = next_no_skip_goto_skip(find_label(fun->stmt, p->e.a.label), fun); else p->next_stmt = next_no_skip_goto_skip(p->next_stmt, fun); recursive_eliminate_goto_print_skip(p->next, fun); }
void define_label (char *label, long segment, long offset, char *special, int is_norm, int isextrn, struct ofmt *ofmt, efunc error) { union label *lptr; lptr = find_label (label, 1); if (lptr->defn.is_global & DEFINED_BIT) { error(ERR_NONFATAL, "symbol `%s' redefined", label); return; } lptr->defn.is_global |= DEFINED_BIT; if (isextrn) lptr->defn.is_global |= EXTERN_BIT; if (label[0] != '.' && is_norm) /* not local, but not special either */ prevlabel = lptr->defn.label; else if (label[0] == '.' && label[1] != '.' && !*prevlabel) error(ERR_NONFATAL, "attempt to define a local label before any" " non-local labels"); lptr->defn.segment = segment; lptr->defn.offset = offset; ofmt->symdef (lptr->defn.label, segment, offset, !!(lptr->defn.is_global & GLOBAL_BIT), special ? special : lptr->defn.special); }
static void intern_label(const char *label) { static size_t labels_alloc; if (find_label(label) == INVALID_LABEL) { ENLARGE(g_data.labels, g_data.num_labels + 1, labels_alloc, 2); g_data.labels[g_data.num_labels++] = xstrdup(label); } }
bool is_extern(char *label) { union label *lptr; if (!initialized) return false; lptr = find_label(label, 0); return (lptr && (lptr->defn.is_global & EXTERN_BIT)); }
bool is_extern(const char *label) { union label *lptr; if (!initialized) return false; lptr = find_label(label, false, NULL); return lptr && lptr->defn.type == LBL_EXTERN; }
void define_label_stub (char *label, efunc error) { union label *lptr; if (!islocal(label)) { lptr = find_label (label, 1); if (!lptr) error (ERR_PANIC, "can't find label `%s' on pass two", label); if (*label != '.') prevlabel = lptr->defn.label; } }
int is_extern (char *label) { union label *lptr; if (!initialised) return 0; lptr = find_label (label, 0); if (lptr && (lptr->defn.is_global & EXTERN_BIT)) return 1; else return 0; }
/* Execute a GOTO statement. */ void exec_goto() { char *loc; get_token(); /* get label to go to */ /* find the location of the label */ loc = find_label(bas_token); if(loc[0]=='\0') serror(7); /* label not defined */ else prog=loc; /* start program running at that loc */ }
static condcode test_duplicate( char *name, line_number lineno ) { labelcb * lb; lb = find_label( name ); if( lb == NULL ) { return( omit ); // really new label } if( lb->lineno == lineno ) { return( pos ); // name and lineno match } else { return( neg); // name matches, different lineno } }
int lookup_label (char *label, long *segment, long *offset) { union label *lptr; if (!initialised) return 0; lptr = find_label (label, 0); if (lptr && (lptr->defn.is_global & DEFINED_BIT)) { *segment = lptr->defn.segment; *offset = lptr->defn.offset; return 1; } else return 0; }
/* Execute a GOSUB command. */ void gosub() { char *loc; char zeroc='\0'; get_token(); /* find the label to call */ loc = find_label(bas_token); if( loc[0]=='\0') serror(7); /* label not defined */ else { gpush(prog); /* save place to return to */ prog = loc; /* start program running at that loc */ } }
static bp_stmt_t next_no_skip_goto_skip(bp_stmt_t p, bp_fun_t fun) { int i; bp_stmt_t z; if ( (!p) || (p->visited != 0) ) return NULL; if ((p->label) != NULL) { if (strcmp(p->label, target_label) == 0) return p; if (strcmp(p->label, "endinit") == 0) return p; } p->visited = 1; switch (p->type) { case BP_ASSUME: { if ( (((p->e.c.expr)->token) == BP_CONST) && ((p->e.c.expr)->left)) { z = next_no_skip_goto_skip(p->next, fun); p->visited = 0; return (z); } break; } case BP_GOTO: { z = next_no_skip_goto_skip(find_label(fun->stmt, p->e.a.label), fun); p->visited = 0; return (z); } case BP_PRINT: case BP_SKIP: { z = next_no_skip_goto_skip(p->next_stmt, fun); p->visited = 0; return (z); } } p->visited = 0; return (p); }
bool lookup_label(const char *label, int32_t *segment, int64_t *offset) { union label *lptr; if (!initialized) return false; lptr = find_label(label, false, NULL); if (lptr && lptr->defn.defined) { *segment = lptr->defn.segment; *offset = lptr->defn.offset; return true; } return false; }
bool lookup_label(char *label, int32_t *segment, int64_t *offset) { union label *lptr; if (!initialized) return false; lptr = find_label(label, 0); if (lptr && (lptr->defn.is_global & DEFINED_BIT)) { *segment = lptr->defn.segment; *offset = lptr->defn.offset; return true; } return false; }
void construct_cfg(Block block[], int nr_block, IR instr[], int nr_instr) { for (int idx_blk = 0; idx_blk < nr_block; idx_blk++) { Block *blk = &block[idx_blk]; bool return_flag = false; for (int i = blk->end - 1; i >= blk->start; i--) { if (instr[i].type == IR_RET) { blk->follow = blk->branch = -1; return_flag = true; } } if (return_flag) { continue; } // 默认下落, 存储的是block的下标 blk->follow = idx_blk + 1; blk->branch = idx_blk + 1; // 只需要检查最后一条指令 IR *ir = &instr[blk->end - 1]; // 获取LABEL Operand label; if (is_branch(ir)) { label = ir->rd; } else if (ir->type == IR_JMP) { label = ir->rs; } else { label = NULL; } // 搜索LABEL对应下标 int idx_label = find_label(label, instr, nr_instr); if (idx_label < nr_instr) { LOG("基本块%d找到跳转目标%s", idx_blk, print_operand(label)); blk->branch = instr[idx_label].block; if (ir->type == IR_JMP) { blk->follow = blk->branch; } } } }
int load_proxy_config(const char *config_name, int pmid, int proxy_sign, char value[C_TOTAL][32]) { const static char FLG_PLATFORM_CONF[] = "platform="; int i = 0; int ret = 1; query_conf *pconf = NULL; query_conf *pplatform = NULL; char cfg_path[256] = {0}; char plat_flg[32] = {0}; char *val = NULL; sprintf(cfg_path, "%s/%s", PLATFORM_CONFIG_DIR, config_name); sprintf(plat_flg, "%s%d", FLG_PLATFORM_CONF, pmid); if ((pconf = load_configuration(cfg_path)) == NULL) { //printf("open conf file:%s\n", cfg_path); loginf_out("读取平台配置失败!"); return -1; } if ((pplatform = find_label(pconf, plat_flg)) == NULL) { free_configuration(&pconf); loginf_fmt("没有平台ID为[%d]的配置项", pmid); return -1; } for (i = 0; i < C_TOTAL; ++i) { memset(value[i], 0, sizeof(value[i])); if (proxy_sign == PROXY_AUTH_SERVER && i == L_VIDEOIP) break; if ((val = get_value_from_label(pplatform, m_conf_key[i])) == NULL) { loginf_fmt("缺少配置项\"%s\"", m_conf_key[i]); ret = -1; break; } strcpy(value[i], val); } free_configuration(&pconf); return ret; }
void jit_emit_branch(uint32_t op, char* label) { Label* lbl = find_label(label); if (lbl) { int offset = (lbl->idx - code_idx) - 2; //printf("offset to %s: %d (*4)\r\n",label,offset); if (offset<0) { offset = 0x1000000-(-offset); op|=offset; code[code_idx++] = op; } } else { //printf("! label not found %s, adding unresolved.\r\n",label); jit_labels_unres[unres_labels].name = strdup(label); jit_labels_unres[unres_labels].idx = code_idx; code[code_idx++] = op; unres_labels++; } }
void dfs(char *label) { char *child; char *end; /* arg given by find_label() */ /* if (!label) return ; */ *pos++ = *label; *pos++ = '('; if (*(label + SIZE) == '|') { get_dash_ends(label + SIZE + SIZE); /* one line after dash line */ end = dash.end + SIZE; for (child = dash.start + SIZE; (child = find_label(child)) <= end && child; ++child) { dfs(child); } } *pos++ = ')'; }
int main() { char *val = NULL; char *mod_option_path = "mod_option.conf"; struct sockaddr_in s_addr; query_conf *general = NULL; query_conf *mod_option_conf = NULL; if ((mod_option_conf = load_configuration(mod_option_path)) == NULL) { return -1; } if ((general = find_label(mod_option_conf, (char*)"mod_option")) == NULL) { free_configuration(&mod_option_conf); return -1; } deal_all_label_value(general, "null"); /* if ((val = get_value_from_label(general, (char*)"synconf_ip")) != NULL) __sc.s_ip = inet_atoul(val); printf("ip:%s\n", val); if ((val = get_value_from_label(general, (char*)"synconf_port")) != NULL) __sc.s_port = inet_atoul(val); printf("port:%s\n", val); s_addr.sin_family = AF_INET; s_addr.sin_port = htons(__sc.s_port); s_addr.sin_addr.s_addr = htonl(__sc.s_ip); */ free_configuration(&mod_option_conf); return 0; }
static void add_sample(size_t sample_no, char *sample) { const char *label = strtok(sample, "\t"); if (!label) die("unexpected error"); uint32_t label_no = find_label(label); if (label_no == INVALID_LABEL) die("unexpected error"); g_data.samples_labels[sample_no] = label_no; for (size_t feat_no = 0; feat_no < g_data.num_features; feat_no++) { const char *feat = strtok(NULL, "\t"); if (!feat) die_loc("not enough features (expected %zu, found only %zu), maybe there is an empty field?", g_data.num_features, feat_no); column_add(&g_data.columns[feat_no], sample_no, feat); } if (strtok(NULL, "\t")) die_loc("excess features (expected merely %zu)", g_data.num_features); }