/** * dump switch table */ dumpsw(loop_t *loop) { int i,j; data_segment_gdata (); generate_label (loop->body_label); if (loop->test_label != swstp) { j = loop->test_label; while (j < swstp) { gen_def_word (); i = 4; while (i--) { output_number (swstcase[j]); output_byte (','); print_label (swstlab[j++]); if ((i == 0) | (j >= swstp)) { newline (); break; } output_byte (','); } } } gen_def_word (); print_label (loop->cont_label); output_string (",0"); newline (); code_segment_gtext (); }
/** * dump switch table */ void dumpsw(WHILE *ws) { int i,j; data_segment_gdata (); generate_label (ws->body_tab); if (ws->case_test != swstp) { j = ws->case_test; while (j < swstp) { gen_def_word (); i = 4; while (i--) { output_number (swstcase[j]); output_byte (','); print_label (swstlab[j++]); if ((i == 0) | (j >= swstp)) { newline (); break; } output_byte (','); } } } gen_def_word (); print_label (ws->incr_def); output_string (",0"); newline (); code_segment_gtext (); }
/** * evaluate one initializer, add data to table * @param symbol_name * @param type * @param identity * @param dim * @param tag * @return * returns size of initializer, or 0 for none (a null string is size 1) * */ int init(char *symbol_name, int type, int identity, int *dim, TAG_SYMBOL *tag) { int value, n; /* A pointer is initialized as a word holding the address of the struct or string etc that directly follows */ if(identity == POINTER) { int x = getlabel(); gen_def_word(); print_label(x); newline(); print_label(x); output_label_terminator(); newline(); } /* FIXME: may need to distinguish const string v data in future */ if(quoted_string(&n, NULL)) { if((identity == VARIABLE) || !(type & CCHAR)) error("found string: must assign to char pointer or array"); *dim = *dim - n; /* ??? FIXME arrays of char only */ return n; } if (type & CCHAR) gen_def_byte(); else gen_def_word(); if (!number(&value) && !quoted_char(&value)) return 0; *dim = *dim - 1; output_number(value); newline(); return (type & CCHAR) ? 1 : 2; }
void print(Printer& p, Branch_instr const* i) { print(p, "br i1 "); print(p, i->condition()); print(p, ", "); print_label(p, i->when_true()); print(p, ", "); print_label(p, i->when_false()); }
static void print_chip_curr(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { const sensors_subfeature *sf; double val; char *label; struct sensor_subfeature_data sensors[NUM_CURR_SENSORS]; struct sensor_subfeature_data alarms[NUM_CURR_ALARMS]; int sensor_count, alarm_count; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", feature->name); return; } print_label(label, label_size); free(label); sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_CURR_INPUT); if (sf && get_input_value(name, sf, &val) == 0) printf("%+6.2f A ", val); else printf(" N/A "); sensor_count = alarm_count = 0; get_sensor_limit_data(name, feature, current_sensors, sensors, &sensor_count, alarms, &alarm_count); print_limits(sensors, sensor_count, alarms, alarm_count, label_size, "%s = %+6.2f A"); printf("\n"); }
/** * "switch" statement */ doswitch() { loop_t loop; loop_t *ptr; loop.symbol_idx = local_table_index; loop.stack_pointer = stkp; loop.type = WSSWITCH; loop.test_label = swstp; loop.body_label = getlabel (); loop.cont_label = loop.exit_label = getlabel (); addloop (&loop); gen_immediate_a (); print_label (loop.body_label); newline (); gen_push (); needbrack ("("); expression (YES); needbrack (")"); stkp = stkp + INTSIZE; // '?case' will adjust the stack gen_jump_case (); statement (NO); ptr = readswitch (); gen_jump (ptr->exit_label); dumpsw (ptr); generate_label (ptr->exit_label); local_table_index = ptr->symbol_idx; stkp = gen_modify_stack (ptr->stack_pointer); swstp = ptr->test_label; delloop (); }
int main(void) { struct nfct_labelmap *l; l = nfct_labelmap_new("/"); assert(l == NULL); l = nfct_labelmap_new(NULL); if (l) { puts("default connlabel.conf:"); dump_map(l); nfct_labelmap_destroy(l); } else { puts("no default config found"); } l = nfct_labelmap_new("qa-connlabel.conf"); if (!l) l = nfct_labelmap_new("qa/qa-connlabel.conf"); assert(l); puts("qa-connlabel.conf:"); dump_map(l); print_label(l); nfct_labelmap_destroy(l); return 0; }
/** * add new symbol to local table * @param sname * @param identity * @param type * @param offset size in bytes * @param storage_class * @return */ int add_local (char *sname, int identity, int type, int offset, int storage_class) { int k; SYMBOL *symbol; char *buffer_ptr; if ((current_symbol_table_idx = find_locale (sname)) > -1) { return (current_symbol_table_idx); } if (local_table_index >= NUMBER_OF_GLOBALS + NUMBER_OF_LOCALS) { error ("local symbol table overflow"); return (0); } current_symbol_table_idx = local_table_index; symbol = &symbol_table[current_symbol_table_idx]; buffer_ptr = symbol->name; /* FIXME: only copy so many bytes */ while (alphanumeric(*buffer_ptr++ = *sname++)); symbol->identity = identity; symbol->type = type; symbol->storage = storage_class; if (storage_class == LSTATIC) { data_segment_gdata(); print_label(k = getlabel()); output_label_terminator(); gen_def_storage(); output_number(offset); newline(); code_segment_gtext(); offset = k; } symbol->offset = offset; local_table_index++; return (current_symbol_table_idx); }
/** * main - Begin here * * Start from here. * * Return: 0 Success, the program worked * 1 Error, something went wrong */ int main(int argc, char **argv) { unsigned long mnt_flags = 0; int result = 0; ntfs_volume *vol; ntfs_log_set_handler(ntfs_log_handler_outerr); if (!parse_options(argc, argv)) return 1; utils_set_locale(); if (!opts.label) opts.noaction++; vol = utils_mount_volume(opts.device, (opts.noaction ? MS_RDONLY : 0) | (opts.force ? MS_RECOVER : 0)); if (!vol) return 1; if (opts.label) result = change_label(vol, mnt_flags, opts.label, opts.force); else result = print_label(vol, mnt_flags); ntfs_umount(vol, FALSE); return result; }
/** * "switch" statement */ void doswitch(void) { WHILE ws; WHILE *ptr; ws.symbol_idx = local_table_index; ws.stack_pointer = stkp; ws.type = WSSWITCH; ws.case_test = swstp; ws.body_tab = getlabel (); ws.incr_def = ws.while_exit = getlabel (); addwhile (&ws); gen_immediate (); print_label (ws.body_tab); newline (); gen_push (HL_REG); needbrack ("("); expression (YES); needbrack (")"); stkp = stkp + INTSIZE; // '?case' will adjust the stack gen_jump_case (); statement (NO); ptr = readswitch (); gen_jump (ptr->while_exit); dumpsw (ptr); generate_label (ptr->while_exit); local_table_index = ptr->symbol_idx; stkp = gen_modify_stack (ptr->stack_pointer); swstp = ptr->case_test; delwhile (); }
void print_eterm_details(FILE *f, egraph_t *egraph, eterm_t t) { composite_t *c; fputs("--- Term ", f); print_eterm_id(f, t); fputs(" ---\n", f); c = egraph_term_body(egraph, t); if (constant_body(c)) { fputs("constant\n", f); } else if (c == VARIABLE_BODY) { fputs("variable\n", f); } else if (c == NULL) { fputs("deleted\n", f); } else { fputs("body: ", f); print_composite(f, c); fputc('\n', f); } if (c != NULL) { fputs("label: ", f); print_label(f, egraph_term_label(egraph, t)); fputc('\n', f); } }
static void print_chip_energy(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { double val; const sensors_subfeature *sf; char *label; const char *unit; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", feature->name); return; } print_label(label, label_size); free(label); sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_ENERGY_INPUT); if (sf && get_input_value(name, sf, &val) == 0) { scale_value(&val, &unit); printf("%6.2f %sJ", val, unit); } else printf(" N/A"); printf("\n"); }
void print_class_of_occ(FILE *f, egraph_t *egraph, occ_t t) { fputs("class of ", f); print_occurrence(f, t); fputs(": ", f); print_label(f, egraph_label(egraph, t)); fputs(" = {", f); print_list(f, egraph, t); fputs(" }\n", f); }
/** * test the primary register and jump if false to label * @param label the label * @param ft if true jnz is generated, jz otherwise */ void gen_test_jump(int label, int ft) { output_line ("test r1"); if (ft) output_with_tab ("jumpnz "); else output_with_tab ("jumpz "); print_label (label); newline (); }
static void print_chip_power(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { double val; const sensors_subfeature *sf; struct sensor_subfeature_data sensors[6]; struct sensor_subfeature_data alarms[3]; int sensor_count, alarm_count; char *label; const char *unit; int i; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", feature->name); return; } print_label(label, label_size); free(label); sensor_count = alarm_count = 0; /* Power sensors come in 2 flavors: instantaneous and averaged. To keep things simple, we assume that each sensor only implements one flavor. */ sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_POWER_INPUT); get_sensor_limit_data(name, feature, sf ? power_inst_sensors : power_avg_sensors, sensors, ARRAY_SIZE(sensors), &sensor_count, alarms, ARRAY_SIZE(alarms), &alarm_count); /* Add sensors common to both flavors. */ get_sensor_limit_data(name, feature, power_common_sensors, sensors, ARRAY_SIZE(sensors), &sensor_count, alarms, ARRAY_SIZE(alarms), &alarm_count); if (!sf) sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_POWER_AVERAGE); if (sf && get_input_value(name, sf, &val) == 0) { scale_value(&val, &unit); printf("%6.2f %sW ", val, unit); } else printf(" N/A "); for (i = 0; i < sensor_count; i++) scale_value(&sensors[i].value, &sensors[i].unit); print_limits(sensors, sensor_count, alarms, alarm_count, label_size, "%s = %6.2f %sW"); printf("\n"); }
/** * test the primary register and jump if false to label * @param label the label * @param ft if true jnz is generated, jz otherwise */ void gen_test_jump(int label, int ft) { output_line ("mov \ta,h"); output_line ("ora \tl"); if (ft) output_with_tab ("jnz \t"); else output_with_tab ("jz \t"); print_label (label); newline (); }
static void edit_label(struct sun_disklabel *sl, const char *disk, const char *bootpath) { char tmpfil[] = _PATH_TMPFILE; const char *editor; int status; FILE *fp; pid_t pid; pid_t r; int fd; int c; if ((fd = mkstemp(tmpfil)) < 0) err(1, "mkstemp"); if ((fp = fdopen(fd, "w")) == NULL) err(1, "fdopen"); print_label(sl, disk, fp); fflush(fp); for (;;) { if ((pid = fork()) < 0) err(1, "fork"); if (pid == 0) { if ((editor = getenv("EDITOR")) == NULL) editor = _PATH_VI; execlp(editor, editor, tmpfil, (char *)NULL); err(1, "execlp %s", editor); } status = 0; while ((r = wait(&status)) > 0 && r != pid) ; if (WIFEXITED(status)) { if (parse_label(sl, tmpfil) == 0) { fclose(fp); unlink(tmpfil); write_label(sl, disk, bootpath); return; } printf("re-edit the label? [y]: "); fflush(stdout); c = getchar(); if (c != EOF && c != '\n') while (getchar() != '\n') ; if (c == 'n') { fclose(fp); unlink(tmpfil); return; } } } fclose(fp); unlink(tmpfil); return; }
/** * main - Begin here * * Start from here. * * Return: 0 Success, the program worked * 1 Error, something went wrong */ int main(int argc, char **argv) { unsigned long mnt_flags = 0; int result = 0; ntfs_volume *vol; ntfs_log_set_handler(ntfs_log_handler_outerr); result = parse_options(argc, argv); if (result >= 0) return (result); result = 0; utils_set_locale(); if ((opts.label || opts.new_serial) && !opts.noaction && !opts.force && !ntfs_check_if_mounted(opts.device, &mnt_flags) && (mnt_flags & NTFS_MF_MOUNTED)) { ntfs_log_error("Cannot make changes to a mounted device\n"); result = 1; goto abort; } if (!opts.label && !opts.new_serial) opts.noaction++; vol = utils_mount_volume(opts.device, (opts.noaction ? NTFS_MNT_RDONLY : 0) | (opts.force ? NTFS_MNT_RECOVER : 0)); if (!vol) return 1; if (opts.new_serial) { result = set_new_serial(vol); if (result) goto unmount; } else { if (opts.verbose) result = print_serial(vol); } if (opts.label) result = change_label(vol, opts.label); else result = print_label(vol, mnt_flags); unmount : ntfs_umount(vol, FALSE); abort : /* "result" may be a negative reply of a library function */ return (result ? 1 : 0); }
int main (int argc, char ** argv) { if (argc == 2) print_label(argv[1]); else if (argc == 3) change_label(argv[1], argv[2]); else { fprintf(stderr, _("Usage: e2label device [newlabel]\n")); exit(1); } return 0; }
static void print_chip_fan(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { const sensors_subfeature *sf, *sfmin, *sfdiv; double val; char *label; if (!(label = sensors_get_label(name, feature))) { fprintf(stderr, "ERROR: Can't get label of feature %s!\n", feature->name); return; } print_label(label, label_size); free(label); sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_FAN_FAULT); if (sf && get_value(name, sf)) printf(" FAULT"); else { sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_FAN_INPUT); if (sf && get_input_value(name, sf, &val) == 0) printf("%4.0f RPM", val); else printf(" N/A"); } sfmin = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_FAN_MIN); sfdiv = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_FAN_DIV); if (sfmin && sfdiv) printf(" (min = %4.0f RPM, div = %1.0f)", get_value(name, sfmin), get_value(name, sfdiv)); else if (sfmin) printf(" (min = %4.0f RPM)", get_value(name, sfmin)); else if (sfdiv) printf(" (div = %1.0f)", get_value(name, sfdiv)); sf = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_FAN_ALARM); if (sf && get_value(name, sf)) { printf(" ALARM"); } printf("\n"); }
addcase (int val) { int lab; if (swstp == SWSTSZ) error ("too many case labels"); else { swstcase[swstp] = val; swstlab[swstp++] = lab = getlabel (); print_label (lab); output_label_terminator (); newline (); } }
/** * asm - fetch the address of the specified symbol into the primary register * @param sym the symbol name * @return which register pair contains result */ int gen_get_locale(SYMBOL *sym) { if (sym->storage == LSTATIC) { gen_immediate(); print_label(sym->offset); newline(); return HL_REG; } else { gen_immediate(); output_number(sym->offset); output_string("+fp"); newline(); return HL_REG; } }
int constant(int val[]) { if (number (val)) gen_immediate (); else if (quoted_char (val)) gen_immediate (); else if (quoted_string (val)) { gen_immediate (); print_label (litlab); output_byte ('+'); } else return (0); output_number (val[0]); newline (); return (1); }
void print_signature(FILE *f, signature_t *s) { uint32_t i, n; n = tag_arity(s->tag); fputc('[', f); print_kind(f, tag_kind(s->tag)); if (tag_kind(s->tag) == COMPOSITE_LAMBDA) { fprintf(f, "[%"PRId32"]", s->sigma[1]); // print the lambda tag } for (i=0; i<n; i++) { fputc(' ', f); print_label(f, s->sigma[i]); } fputc(']', f); }
static void describe_access(SYMBOL *sym) { if (sym->storage == REGISTER) { output_string("r"); output_number(sym->offset); newline(); return; } output_byte('('); if (sym->storage == LSTATIC) { print_label(sym->offset); } else if (sym->storage == AUTO || sym->storage == DEFAUTO) { output_number(sym->offset); output_string("+fp"); } else output_label_name(sym->name); output_byte(')'); newline(); }
static void print_chip_intrusion(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { char *label; const sensors_subfeature *subfeature; double alarm; subfeature = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_INTRUSION_ALARM); if (!subfeature) return; if ((label = sensors_get_label(name, feature)) && !sensors_get_value(name, subfeature->number, &alarm)) { print_label(label, label_size); printf("%s\n", alarm ? "ALARM" : "OK"); } free(label); }
static void print_chip_beep_enable(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { char *label; const sensors_subfeature *subfeature; double beep_enable; subfeature = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_BEEP_ENABLE); if (!subfeature) return; if ((label = sensors_get_label(name, feature)) && !sensors_get_value(name, subfeature->number, &beep_enable)) { print_label(label, label_size); printf("%s\n", beep_enable ? "enabled" : "disabled"); } free(label); }
static void print_chip_humidity(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { char *label; const sensors_subfeature *subfeature; double humidity; subfeature = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_HUMIDITY_INPUT); if (!subfeature) return; if ((label = sensors_get_label(name, feature)) && !sensors_get_value(name, subfeature->number, &humidity)) { print_label(label, label_size); printf("%6.1f %%RH\n", humidity); } free(label); }
static void print_chip_vid(const sensors_chip_name *name, const sensors_feature *feature, int label_size) { char *label; const sensors_subfeature *subfeature; double vid; subfeature = sensors_get_subfeature(name, feature, SENSORS_SUBFEATURE_VID); if (!subfeature) return; if ((label = sensors_get_label(name, feature)) && !sensors_get_value(name, subfeature->number, &vid)) { print_label(label, label_size); printf("%+6.3f V\n", vid); } free(label); }
/** * dump the literal pool */ void dumplits(void) { int j, k; if (litptr == 0) return; print_label(litlab); output_label_terminator(); k = 0; while (k < litptr) { gen_def_byte(); j = 8; while (j--) { output_number(litq[k++] & 127); if ((j == 0) | (k >= litptr)) { newline(); break; } output_byte(','); } } }