void generate_interpolate_save(adv_conf* context, const adv_generate_interpolate_set* interpolate) { unsigned i; conf_remove(context, "", "device_video_format"); for(i=0;i<interpolate->mac;++i) { char buffer[1024]; out_generate_interpolate(buffer, sizeof(buffer), &interpolate->map[i]); conf_string_set(context, "", "device_video_format", buffer); } }
/* Save the list of video mode */ void crtc_container_save(adv_conf* context, adv_crtc_container* cc) { adv_crtc_container_iterator i; conf_remove(context, "", "device_video_modeline"); crtc_container_iterator_begin(&i, cc); while (!crtc_container_iterator_is_end(&i)) { char buffer[1024]; crtc_print(buffer, sizeof(buffer), crtc_container_iterator_get(&i)); conf_string_set(context, "", "device_video_modeline", buffer); crtc_container_iterator_next(&i); } }
void gtf_clear(adv_conf* context) { conf_remove(context, "", "device_video_gtf"); }
void generate_interpolate_clear(adv_conf* context) { conf_remove(context, "", "device_video_format"); }
adv_error monitor_conversion_legacy(adv_conf* context) { char buffer[1024]; adv_error p_error; adv_error h_error; adv_error v_error; const char* p; const char* h; const char* v; char* ps; char* hs; char* vs; char c; int pi,hi,vi; /* LEGACY support of old device_video_p/h/vclock format */ p_error = conf_string_section_get(context, "", "device_video_pclock", &p); h_error = conf_string_section_get(context, "", "device_video_hclock", &h); v_error = conf_string_section_get(context, "", "device_video_vclock", &v); /* check if all are missing */ if (p_error != 0 && h_error != 0 && v_error != 0) return 0; /* partially missing */ if (p_error != 0 || h_error != 0 || v_error != 0) { error_set("Missing options 'device_video_p/h/vclock'"); return -1; } buffer[0] = 0; ps = strdup(p); hs = strdup(h); vs = strdup(v); /* set the new format */ pi = 0; sskip(&pi, ps, " "); while (ps[pi]) { const char* pt; pt = stoken(&c, &pi, ps, ",", " "); hi = 0; sskip(&hi, hs, " "); while (hs[hi]) { const char* ht; ht = stoken(&c, &hi, hs, ",", " "); vi = 0; sskip(&vi, vs, " "); while (vs[vi]) { const char* vt; vt = stoken(&c, &vi, vs, ",", " "); if (*buffer != 0) sncat(buffer, sizeof(buffer), " ; "); sncatf(buffer, sizeof(buffer), "%s / %s / %s", pt, ht, vt); sskip(&vi, vs, " "); } sskip(&hi, hs, " "); } sskip(&pi, ps, " "); } free(ps); free(hs); free(vs); conf_string_set(context, "", "device_video_clock", buffer); /* remove the old copy */ conf_remove(context, "", "device_video_pclock"); conf_remove(context, "", "device_video_hclock"); conf_remove(context, "", "device_video_vclock"); return 0; }
void crtc_container_clear(adv_conf* context) { conf_remove(context, "", "device_video_modeline"); }
/* * Call the configuration API. * XXX Error handling! How to do multi-line transactions? */ static void ui_config(char *cmd) { struct conf_list *vlist; struct conf_list_node *vnode; char subcmd[201], section[201], tag[201], value[201], tmp[201]; char *v, *nv; int trans = 0, items, skip = 0, ret; FILE *fp; if (sscanf(cmd, "C %200s", subcmd) != 1) goto fail; if (strcasecmp(subcmd, "get") == 0) { if (sscanf(cmd, "C %*s [%200[^]]]:%200s", section, tag) != 2) goto fail; v = conf_get_str(section, tag); fp = ui_open_result(); if (fp) { if (v) fprintf(fp, "%s\n", v); fclose(fp); } LOG_DBG((LOG_UI, 30, "ui_config: \"%s\"", cmd)); return; } trans = conf_begin(); if (strcasecmp(subcmd, "set") == 0) { items = sscanf(cmd, "C %*s [%200[^]]]:%200[^=]=%200s %200s", section, tag, value, tmp); if (!(items == 3 || items == 4)) goto fail; conf_set(trans, section, tag, value, items == 4 ? 1 : 0, 0); if (strcasecmp(section, "Phase 2") == 0 && (strcasecmp(tag, "Connections") == 0 || strcasecmp(tag, "Passive-connections") == 0)) ui_conn_reinit(); } else if (strcasecmp(subcmd, "add") == 0) { items = sscanf(cmd, "C %*s [%200[^]]]:%200[^=]=%200s %200s", section, tag, value, tmp); if (!(items == 3 || items == 4)) goto fail; v = conf_get_str(section, tag); if (!v) conf_set(trans, section, tag, value, 1, 0); else { vlist = conf_get_list(section, tag); if (vlist) { for (vnode = TAILQ_FIRST(&vlist->fields); vnode; vnode = TAILQ_NEXT(vnode, link)) { if (strcmp(vnode->field, value) == 0) { skip = 1; break; } } conf_free_list(vlist); } /* Add the new value to the end of the 'v' list. */ if (skip == 0) { if (asprintf(&nv, v[strlen(v) - 1] == ',' ? "%s%s" : "%s,%s", v, value) == -1) { log_error("ui_config: malloc() failed"); if (trans) conf_end(trans, 0); return; } conf_set(trans, section, tag, nv, 1, 0); free(nv); } } if (strcasecmp(section, "Phase 2") == 0 && (strcasecmp(tag, "Connections") == 0 || strcasecmp(tag, "Passive-connections") == 0)) ui_conn_reinit(); } else if (strcasecmp(subcmd, "rmv") == 0) { items = sscanf(cmd, "C %*s [%200[^]]]:%200[^=]=%200s %200s", section, tag, value, tmp); if (!(items == 3 || items == 4)) goto fail; vlist = conf_get_list(section, tag); if (vlist) { nv = v = NULL; for (vnode = TAILQ_FIRST(&vlist->fields); vnode; vnode = TAILQ_NEXT(vnode, link)) { if (strcmp(vnode->field, value) == 0) continue; ret = v ? asprintf(&nv, "%s,%s", v, vnode->field) : asprintf(&nv, "%s", vnode->field); free(v); if (ret == -1) { log_error("ui_config: malloc() failed"); if (trans) conf_end(trans, 0); return; } v = nv; } conf_free_list(vlist); if (nv) { conf_set(trans, section, tag, nv, 1, 0); free(nv); } else { conf_remove(trans, section, tag); } } if (strcasecmp(section, "Phase 2") == 0 && (strcasecmp(tag, "Connections") == 0 || strcasecmp(tag, "Passive-connections") == 0)) ui_conn_reinit(); } else if (strcasecmp(subcmd, "rm") == 0) { if (sscanf(cmd, "C %*s [%200[^]]]:%200s", section, tag) != 2) goto fail; conf_remove(trans, section, tag); } else if (strcasecmp(subcmd, "rms") == 0) { if (sscanf(cmd, "C %*s [%200[^]]]", section) != 1) goto fail; conf_remove_section(trans, section); } else goto fail; LOG_DBG((LOG_UI, 30, "ui_config: \"%s\"", cmd)); conf_end(trans, 1); return; fail: if (trans) conf_end(trans, 0); log_print("ui_config: command \"%s\" malformed", cmd); }