static status RedrawAreaLabel(Label lb, Area a) { int x, y, w, h; Elevation z = lb->elevation; int preview = (lb->status == NAME_preview && notNil(lb->message)); initialiseDeviceGraphical(lb, &x, &y, &w, &h); if ( notNil(z) ) r_3d_box(x, y, w, h, 0, z, !preview); x += valInt(lb->border); y += valInt(lb->border); w -= 2*valInt(lb->border); h -= 2*valInt(lb->border); if ( lb->wrap == NAME_clip ) d_clip(x, y, w, h); if ( instanceOfObject(lb->selection, ClassCharArray) ) { String s = &((CharArray)lb->selection)->data; if ( notNil(z) ) x += valInt(getExFont(lb->font))/2; if ( lb->wrap == NAME_clip ) { LocalString(buf, s->iswide, s->size+1); str_one_line(buf, s); s = buf; } str_label(s, 0, lb->font, x, y, w, h, NAME_left, NAME_top, lb->active == ON ? 0 : LABEL_INACTIVE); } else /*if ( instanceOfObject(lb->selection, ClassImage) )*/ { Image image = (Image) lb->selection; r_image(image, 0, 0, x, y, w, h, ON); } if ( lb->wrap == NAME_clip ) d_clip_done(); if ( preview && isNil(z) ) r_complement(x, y, w, h); return RedrawAreaGraphical(lb, a); }
static status RedrawAreaSlider(Slider s, Area a) { int x, y, w, h; int ny, vx, vy, lx, ly, sx, sy, hx, hy; int vv; int bw = (s->look == NAME_x ? BAR_WIDTH : OL_BOX_WIDTH); float lv = convert_value(s->low); float hv = convert_value(s->high); float dv = convert_value(s->displayed_value); int lflags = (s->active == ON ? 0 : LABEL_INACTIVE); if ( dv < lv ) dv = lv; else if ( dv > hv ) dv = hv; if ( hv > lv ) vv = rfloat(((float) (valInt(s->width) - bw) * (dv - lv)) / (hv - lv)); else vv = 0; initialiseDeviceGraphical(s, &x, &y, &w, &h); NormaliseArea(x, y, w, h); r_thickness(valInt(s->pen)); r_dash(s->texture); compute_slider(s, &ny, &vx, &vy, &lx, &ly, &sx, &sy, &hx, &hy); r_clear(x, y, w, h); if ( s->show_label == ON ) { int ex = valInt(getExFont(s->label_font)); RedrawLabelDialogItem(s, accelerator_code(s->accelerator), x, y+ny, vx-ex, 0, s->label_format, NAME_top, lflags); } if ( s->look == NAME_motif ) { int by = y+sy+(SLIDER_HEIGHT-OL_BAR_HEIGHT)/2; int ex = x + sx + valInt(s->width); Elevation z = getClassVariableValueObject(s, NAME_elevation); r_3d_box(x+sx, by, vv, OL_BAR_HEIGHT, 0, z, FALSE); r_3d_box(x+sx+vv+bw, by, ex-(x+sx+vv+bw), OL_BAR_HEIGHT, 0, z, FALSE); r_3d_box(x+sx+vv, y+sy, bw, SLIDER_HEIGHT, 0, z, TRUE); } else if ( s->look == NAME_openLook ) { int by = y+sy+(SLIDER_HEIGHT-OL_BAR_HEIGHT)/2; int ly2 = by+OL_BAR_HEIGHT-1; int ex = x + sx + valInt(s->width); r_fill(x+sx, by+1, 1, OL_BAR_HEIGHT-2, BLACK_IMAGE); r_fill(x+sx+1, by, vv-2, OL_BAR_HEIGHT, BLACK_IMAGE); r_line(x+sx+1+vv+bw, by, ex-2, by); r_line(x+sx+1+vv+bw, ly2, ex-2, ly2); r_line(ex-1, by+1, ex-1, ly2-1); r_shadow_box(x+sx+vv, y+sy, bw, SLIDER_HEIGHT, 0, 1, NIL); } else { r_fill(x+sx, y+sy, vv, SLIDER_HEIGHT, GREY50_IMAGE); r_box(x+sx, y+sy, valInt(s->width), SLIDER_HEIGHT, 0, NIL); r_fill(x+sx+vv, y+sy, bw, SLIDER_HEIGHT, BLACK_IMAGE); } if ( s->show_value == ON ) { char buf[100]; string str; buf[0] = '['; format_value(s, &buf[1], s->displayed_value); strcat(buf, "]"); str_set_ascii(&str, buf); str_label(&str, 0, s->value_font, x+vx, y+vy, 0, 0, NAME_left, NAME_top, lflags); format_value(s, buf, s->low); str_set_ascii(&str, buf); str_label(&str, 0, s->value_font, x+lx, y+ly, 0, 0, NAME_left, NAME_top, lflags); format_value(s, buf, s->high); str_set_ascii(&str, buf); str_label(&str, 0, s->value_font, x+hx, y+hy, 0, 0, NAME_left, NAME_top, lflags); } return RedrawAreaGraphical(s, a); }
static char* get_filename( conf_t *conf, knot_db_txn_t *txn, const knot_dname_t *zone, const char *name) { assert(name); const char *end = name + strlen(name); char out[1024] = ""; do { // Search for a formatter. const char *pos = strchr(name, '%'); // If no formatter, copy the rest of the name. if (pos == NULL) { if (strlcat(out, name, sizeof(out)) >= sizeof(out)) { CONF_LOG_ZONE(LOG_WARNING, zone, "too long zonefile name"); return NULL; } break; } // Copy constant block. char *block = strndup(name, pos - name); if (block == NULL || strlcat(out, block, sizeof(out)) >= sizeof(out)) { CONF_LOG_ZONE(LOG_WARNING, zone, "too long zonefile name"); return NULL; } free(block); // Move name pointer behind the formatter. name = pos + 2; char buff[512] = ""; uint8_t idx1, idx2; bool failed = false; const char type = *(pos + 1); switch (type) { case '%': strlcat(buff, "%", sizeof(buff)); break; case 'c': if (get_index(&name, end, &idx1, &idx2) != KNOT_EOK || str_char(zone, buff, sizeof(buff), idx1, idx2) != KNOT_EOK) { failed = true; } break; case 'l': if (get_index(&name, end, &idx1, NULL) != KNOT_EOK || str_label(zone, buff, sizeof(buff), idx1) != KNOT_EOK) { failed = true; } break; case 's': if (str_zone(zone, buff, sizeof(buff)) != KNOT_EOK) { failed = true; } break; case '\0': CONF_LOG_ZONE(LOG_WARNING, zone, "ignoring missing " "trailing zonefile formatter"); continue; default: CONF_LOG_ZONE(LOG_WARNING, zone, "ignoring zonefile " "formatter '%%%c'", type); continue; } if (failed) { CONF_LOG_ZONE(LOG_WARNING, zone, "failed to process " "zonefile formatter '%%%c'", type); return NULL; } if (strlcat(out, buff, sizeof(out)) >= sizeof(out)) { CONF_LOG_ZONE(LOG_WARNING, zone, "too long zonefile name"); return NULL; } } while (name < end); // Use storage prefix if not absolute path. if (out[0] == '/') { return strdup(out); } else { conf_val_t val = conf_zone_get_txn(conf, txn, C_STORAGE, zone); char *storage = conf_abs_path(&val, NULL); if (storage == NULL) { return NULL; } char *abs = sprintf_alloc("%s/%s", storage, out); free(storage); return abs; } }