int register_mappings (const JBDATA * data, struct mapping **in_maps) { int i; /* Register mappings for each component */ l_int32 ncomp = numaGetCount (data->naclass); *in_maps = malloc_guarded (ncomp * sizeof (struct mapping)); struct mapping *maps = *in_maps; for (i = 0; i < ncomp; i++) { maps[i].used = 0; } unsigned char code_point = first_code_point (); int font_num = 0; for (i = 0; i < data->nclass; i++) { l_int32 iclass = i; if (maps[iclass].used) continue; maps[iclass].iclass = iclass; maps[iclass].font_num = font_num; maps[iclass].code_point = code_point; maps[iclass].used = 1; if (code_point == max_code_point ()) { code_point = first_code_point (); font_num++; } else { code_point = next_code_point (code_point); } } printf ("%d fonts\n", font_num + 1); return font_num + 1; }
/* * set_var_value: Given the variable structure and the string representation * of the value, this sets the value in the most verbose and error checking * of manors. It displays the results of the set and executes the function * defined in the var structure */ int set_variable (const char *name, IrcVariable *var, const char *orig_value, int noisy) { char *rest; int changed = 0; unsigned char *value; int retval = 0; if (orig_value) value = LOCAL_COPY(orig_value); else value = NULL; switch (var->type) { case BOOL_VAR: { if (value && *value && (value = next_arg(value, &rest))) { if (do_boolean(value, &(var->data->integer))) { say("Value must be either ON, OFF, or TOGGLE"); retval = -1; } else changed = 1; } break; } case CHAR_VAR: { int codepoint; if (!value || !*value) { var->data->integer = ' '; changed = 1; break; } if ((codepoint = next_code_point((const unsigned char **)&value, 0)) == -1) { say("New value of %s could not be determined", name); retval = -1; break; } if (codepoint_numcolumns(codepoint) != 1) { say("New value of %s must be exactly 1 column wide", name); retval = -1; break; } var->data->integer = codepoint; changed = 1; break; } case INT_VAR: { if (value && *value && (value = next_arg(value, &rest))) { int val; if (!is_number(value)) { say("Value of %s must be numeric!", name); retval = -1; } else if ((val = my_atol(value)) < 0) { say("Value of %s must be a non-negative number", name); retval = -1; } else { var->data->integer = val; changed = 1; } } break; } case STR_VAR: { if (!value) { new_free(&(var->data->string)); changed = 1; } else if (*value) { malloc_strcpy(&(var->data->string), value); changed = 1; } } } if (changed) { if ((var->func || var->script) && !(var->flags & VIF_PENDING)) { var->flags |= VIF_PENDING; if (var->func) (var->func)(var->data); if (var->script) { char *s; int owd = window_display; s = make_string_var_bydata(var->type, (void *)var->data); window_display = 0; call_lambda_command("SET", var->script, s); window_display = owd; new_free(&s); } var->flags &= ~VIF_PENDING; } } if (noisy) show_var_value(name, var, changed); return retval; }