bool try_pk (string family, int size, int dpi, int dsize, tex_font_metric& tfm, font_glyphs& pk) { // cout << "Try pk " << family << size << " at " << dpi << " dpi\n"; #ifdef USE_FREETYPE // Substitute by True Type font ? int tt_size= size<333? size: (size+50)/100; int tt_dpi = size<333? dpi : (size * dpi) / (100 * tt_size); string tt_name= tt_find_name (family, tt_size); if (tt_name != "") { if (font_glyphs::instances -> contains (tt_name)) pk= font_glyphs (tt_name); else pk= tt_font_glyphs (tt_name, tt_size, tt_dpi); return true; } #endif // USE_FREETYPE // Open regular pk font string name_pk= family * as_string (size) * "." * as_string (dpi) * "pk"; if (font_glyphs::instances -> contains (name_pk)) { pk = font_glyphs (name_pk); return true; } if (dsize == 0) { int old_size= size; size= tfm->size; dpi = mag (dpi, old_size, size); } string size_name (dsize==0? string (""): as_string (size)); string name (family * size_name * "." * as_string (dpi) * "pk"); if (DEBUG_STD) debug_fonts << "Open pk " << name << "\n"; url u= resolve_tex (name); if (is_none (u)) { if (exists (url ("$TEXMACS_HOME_PATH/fonts/error", name))) { if (DEBUG_STD) debug_fonts << "Error during " << name << " loading\n"; return false; } if (get_setting ("MAKEPK") != "false") { system_wait ("Generating font file", name); make_tex_pk (family * size_name, dpi, as_int (get_setting ("DPI"))); system_wait (""); u= resolve_tex (name); if (is_none (u)) { reset_pk_path (); u= resolve_tex (name); } } if (is_none (u)) { save_string (url ("$TEXMACS_HOME_PATH/fonts/error", name), ""); if (DEBUG_STD) debug_fonts << "Error during " << name << " loading\n"; return false; } } pk = font_glyphs (tm_new<pk_font_glyphs_rep> (name_pk, tm_new<pk_loader> (u, tfm, dpi))); return true; }
void make_tex_tfm (string name) { string s; int r= 0; if (get_setting ("MAKETFM") == "MakeTeXTFM") { s= "MakeTeXTFM " * name; if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n"; r= system (s); } if (get_setting ("MAKETFM") == "mktextfm") { url tfm_dir ("$TEXMACS_HOME_PATH/fonts/tfm"); s= "mktextfm " * string ("--destdir ") * as_string (tfm_dir) * " " * name; if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n"; r= system (s); string superfluous= name * ".600pk"; if (ends (name, ".tfm")) superfluous= name (0, N(name)-4) * ".600pk"; remove (tfm_dir * superfluous); } if (get_setting ("MAKETFM") == "maketfm"){ if (name(N(name) - 4, N(name)) == ".tfm") name = name (0, N(name) - 4); s = "maketfm --dest-dir \"" * get_env("$TEXMACS_HOME_PATH") * "\\fonts\\tfm\" " * name; if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n"; r= system (s); } if (r) cout << "TeXmacs] system command failed: " << s << "\n"; }
cloud_storage_account cloud_storage_account::parse_devstore_settings(std::map<utility::string_t, utility::string_t> settings) { utility::string_t devstore; utility::string_t devstore_proxy_uri; if (get_setting(settings, use_development_storage_setting_string, devstore)) { if (devstore != use_development_storage_setting_value) { throw std::invalid_argument(utility::conversions::to_utf8string(use_development_storage_setting_string)); } web::http::uri proxy_uri; if (get_setting(settings, development_storage_proxy_uri_setting_string, devstore_proxy_uri)) { proxy_uri = web::http::uri(devstore_proxy_uri); } if (settings.empty()) { return get_development_storage_account(proxy_uri); } } return cloud_storage_account(); }
/* * stress_sem() * stress system by POSIX sem ops */ static int stress_sem(const args_t *args) { uint64_t semaphore_posix_procs = DEFAULT_SEMAPHORE_PROCS; uint64_t i; bool created = false; pthread_args_t p_args; if (!get_setting("sem-procs", &semaphore_posix_procs)) { if (g_opt_flags & OPT_FLAGS_MAXIMIZE) semaphore_posix_procs = MAX_SEMAPHORE_PROCS; if (g_opt_flags & OPT_FLAGS_MINIMIZE) semaphore_posix_procs = MIN_SEMAPHORE_PROCS; } /* create a semaphore */ if (sem_init(&sem, 0, 1) < 0) { pr_err("semaphore init (POSIX) failed: errno=%d: " "(%s)\n", errno, strerror(errno)); return EXIT_FAILURE; } (void)memset(pthreads, 0, sizeof(pthreads)); (void)memset(p_ret, 0, sizeof(p_ret)); for (i = 0; i < semaphore_posix_procs; i++) { p_args.args = args; p_args.data = NULL; p_ret[i] = pthread_create(&pthreads[i], NULL, semaphore_posix_thrash, (void *)&p_args); if ((p_ret[i]) && (p_ret[i] != EAGAIN)) { pr_fail_errno("pthread create", p_ret[i]); break; } if (!g_keep_stressing_flag) break; created = true; } if (!created) { pr_inf("%s: could not create any pthreads\n", args->name); return EXIT_NO_RESOURCE; } /* Wait for termination */ while (keep_stressing()) (void)shim_usleep(100000); for (i = 0; i < semaphore_posix_procs; i++) { int ret; if (p_ret[i]) continue; ret = pthread_join(pthreads[i], NULL); (void)ret; } (void)sem_destroy(&sem); return EXIT_SUCCESS; }
void process_responses(DeviceInfo info, MYSQL *mysql) { MYSQL_RES *mysql_res; MYSQL_ROW mysql_row; int notification_res; string query = string("SELECT notifications.command, responses.parameters, responses.id ") + string("FROM responses, notifications ") + string("WHERE responses.event_id=") + inttostr(info.event_id) + " " + string("AND responses.notification_id=notifications.id AND notifications.disabled = 0"); mysql_res = db_query(mysql, &info, query); for (uint i = 0; i < mysql_num_rows(mysql_res); i++) { mysql_row = mysql_fetch_row(mysql_res); info.response_id = strtoint(mysql_row[2]); string command = string(mysql_row[0]) + " " + string(mysql_row[1]); command = expand_parameters(info, command); if (command[0] != '/') command = get_setting(setPathLibexec) + "/" + command; debuglogger(DEBUG_RESPONSE, LEVEL_INFO, &info, "Running Response: " + command); notification_res = system(command.c_str()); } } // end process_responses()
void reset_tfm_path (bool rehash) { (void) rehash; // if (rehash && (get_setting ("TEXHASH") == "true")) system ("texhash"); string tfm= get_setting ("TFM"); the_tfm_path= url_here () | search_sub_dirs ("$TEXMACS_HOME_PATH/fonts/tfm") | search_sub_dirs ("$TEXMACS_PATH/fonts/tfm") | "$TEX_TFM_PATH" | (tfm == ""? url_none (): tfm); if ((get_setting ("MAKETFM") != "false") || (get_setting ("TEXHASH") == "true")) if (get_setting ("KPSEWHICH") != "true") the_tfm_path= the_tfm_path | get_kpsepath ("tfm"); the_tfm_path= expand (factor (the_tfm_path)); }
void reset_pk_path (bool rehash) { (void) rehash; // if (rehash && (get_setting ("TEXHASH") == "true")) system ("texhash"); string pk= get_setting ("PK"); the_pk_path= url_here () | search_sub_dirs ("$TEXMACS_HOME_PATH/fonts/pk") | search_sub_dirs ("$TEXMACS_PATH/fonts/pk") | "$TEX_PK_PATH" | (pk == ""? url_none (): pk); if ((get_setting ("MAKEPK") != "false") || (get_setting ("TEXHASH") == "true")) if (get_setting ("KPSEWHICH") != "true") the_pk_path= the_pk_path | get_kpsepath ("pk"); the_pk_path= expand (factor (the_pk_path)); }
int save_rpm(int no_of_binaries, char ** binaries) { char rpmdir[BLOCK_SIZE]; char directory[BLOCK_SIZE]; char commandstr[BLOCK_SIZE]; int retval=0; /* create the rpmpackage directory */ get_setting("directory", directory); sprintf(rpmdir,"%s%c%s", directory, DIRECTORY_SEPARATOR, RPM_SUBDIR); if (directory_exists(rpmdir)==0) { sprintf(commandstr,"%s %s",COMMAND_MKDIR,rpmdir); retval = system(commandstr); } save_spec(directory, rpmdir, no_of_binaries, binaries); save_script(directory); /* import the Debian changelog into the spec file */ debian_changelog_to_spec(directory); return retval; }
/* * Check if the software can run on the hardware */ static int parse_hw_compatibility(config_t *cfg, struct swupdate_cfg *swcfg) { const config_setting_t *setting, *hw; int count, i; const char *s; struct hw_type *hwrev; setting = get_setting(cfg, "hardware-compatibility", swcfg); if (setting == NULL) { ERROR("HW compatibility not found\n"); return -1; } count = config_setting_length(setting); for(i = 0; i < count; ++i) { hw = config_setting_get_elem(setting, i); s = config_setting_get_string(hw); if (!s) continue; hwrev = (struct hw_type *)calloc(1, sizeof(struct hw_type)); if (!hwrev) { ERROR("No memory: malloc failed\n"); return -1; } strncpy(hwrev->revision, s, sizeof(hwrev->revision)); LIST_INSERT_HEAD(&swcfg->hardware, hwrev, next); TRACE("Accepted Hw Revision : %s", hwrev->revision); } return 0; }
void dict_del(dict *d, void *k) { unsigned int hash, idx; setting *s = get_setting(); dict_entry *entry, *prev = NULL; hash = DICT_HASH(d, k); idx = hash % d->cap; entry = d->entries[idx]; while(entry) { if(d->opts->key_compare(entry->key, k) == 0) { if(prev) prev->bulk_next = entry->bulk_next; if(entry == d->head && entry == d->tail) { d->head = NULL; d->tail = NULL; } else if(entry == d->head) { d->head = entry->next; } else if(entry == d->tail) { d->tail = entry->prev; } else { entry->prev->next = entry->next; entry->next->prev = entry->prev; } DICT_VALUE_FREE(d, entry->value); DICT_KEY_FREE(d, entry->key); s->free(entry); d->entries[idx] = NULL; break; } prev = entry; entry = entry->bulk_next; } }
void dict_replace(dict *d, void *k, void *v) { unsigned int hash, idx; dict_entry *entry; setting *s = get_setting(); if(d->size >= d->cap) dict_rehash(d, d->cap * 2); hash = DICT_HASH(d, k); idx = hash % d->cap; entry = _dict_find(d, idx, k); if(entry) { DICT_VALUE_FREE(d, entry->value); DICT_KEY_FREE(d, entry->key); entry->key = k; entry->value = v; return; } entry = s->malloc(sizeof(struct dict_entry)); memset(entry, 0, sizeof(struct dict_entry)); entry->bulk_next = d->entries[idx]; d->entries[idx] = entry; entry->key = k; entry->value = v; if(d->head == NULL) { d->tail = d->head = entry; } else { d->tail->next = entry; entry->prev = d->tail; d->tail = entry; } d->size++; }
void tfsignature_init(void) { const char *tmp = get_setting("SIGNATURE"); if (tmp) tfsignature_hdr = tmp; debug("signature header line is \"%s\"\n", tfsignature_hdr); tmp = get_setting("SIGNATURE_MISSING"); if (!tmp) tmp = "error"; if (strcmp(tmp, "move") == 0) { tfsignature_nosig_ignore = 1; debug("will silently move mails with missing signature\n"); } else if (strcmp(tmp, "error") != 0) { debug("invalid signature_missing setting '%s', ignoring\n", tmp); } }
cstr cstr_extend(cstr s, size_t add) { setting *setting = get_setting(); cstrhdr *csh = CSTR_HDR(s); size_t used = CSTR_HDR_USED(csh); if((csh->cap - used) >= add) return s; csh->cap = (used + add)*2; csh = setting->realloc((void*)csh, csh->cap + CSTRHLEN + 1); return (cstr)csh->buf; }
cstr cstr_create(size_t len) { setting *setting = get_setting(); char *c = setting->malloc(len + CSTRHLEN + 1); cstrhdr *csh = (cstrhdr*)c; csh->cap = len; csh->len = 0; csh->buf[0] = 0; return (cstr)csh->buf; }
/* * stress_timer * stress timers */ static int stress_timer(const args_t *args) { struct sigevent sev; struct itimerspec timer; sigset_t mask; uint64_t timer_freq = DEFAULT_TIMER_FREQ; (void)sigemptyset(&mask); (void)sigaddset(&mask, SIGINT); (void)sigprocmask(SIG_SETMASK, &mask, NULL); max_ops = args->max_ops; start = time_now(); if (!get_setting("timer-freq", &timer_freq)) { if (g_opt_flags & OPT_FLAGS_MAXIMIZE) timer_freq = MAX_TIMER_FREQ; if (g_opt_flags & OPT_FLAGS_MINIMIZE) timer_freq = MIN_TIMER_FREQ; } rate_ns = timer_freq ? 1000000000.0 / timer_freq : 1000000000.0; if (stress_sighandler(args->name, SIGRTMIN, stress_timer_handler, NULL) < 0) return EXIT_FAILURE; sev.sigev_notify = SIGEV_SIGNAL; sev.sigev_signo = SIGRTMIN; sev.sigev_value.sival_ptr = &timerid; if (timer_create(CLOCK_REALTIME, &sev, &timerid) < 0) { pr_fail_err("timer_create"); return EXIT_FAILURE; } stress_timer_set(&timer); if (timer_settime(timerid, 0, &timer, NULL) < 0) { pr_fail_err("timer_settime"); return EXIT_FAILURE; } do { struct timespec req; req.tv_sec = 0; req.tv_nsec = 10000000; (void)nanosleep(&req, NULL); set_counter(args, timer_counter); } while (keep_stressing()); if (timer_delete(timerid) < 0) { pr_fail_err("timer_delete"); return EXIT_FAILURE; } pr_dbg("%s: %" PRIu64 " timer overruns (instance %" PRIu32 ")\n", args->name, overruns, args->instance); return EXIT_SUCCESS; }
static url resolve_tfm (url name) { if (get_setting ("KPSEWHICH") == "true") { string which= kpsewhich (as_string (name)); if ((which!="") && exists (url_system (which))) return url_system (which); // cout << "Missed " << name << "\n"; } return resolve (the_tfm_path * name); }
bool quick_screen_quick(int button_enter) { struct gui_quickscreen qs; bool oldshuffle = global_settings.playlist_shuffle; int oldrepeat = global_settings.repeat_mode; bool usb = false; if (global_settings.shortcuts_replaces_qs) return do_shortcut_menu(NULL); qs.items[QUICKSCREEN_TOP] = get_setting(global_settings.qs_items[QUICKSCREEN_TOP], NULL); qs.items[QUICKSCREEN_LEFT] = get_setting(global_settings.qs_items[QUICKSCREEN_LEFT], find_setting(&global_settings.playlist_shuffle, NULL)); qs.items[QUICKSCREEN_RIGHT] = get_setting(global_settings.qs_items[QUICKSCREEN_RIGHT], find_setting(&global_settings.repeat_mode, NULL)); qs.items[QUICKSCREEN_BOTTOM] = get_setting(global_settings.qs_items[QUICKSCREEN_BOTTOM], NULL); qs.callback = NULL; if (gui_syncquickscreen_run(&qs, button_enter, &usb)) { settings_save(); settings_apply(false); /* make sure repeat/shuffle/any other nasty ones get updated */ if ( oldrepeat != global_settings.repeat_mode && (audio_status() & AUDIO_STATUS_PLAY) ) { audio_flush_and_reload_tracks(); } if (oldshuffle != global_settings.playlist_shuffle && audio_status() & AUDIO_STATUS_PLAY) { replaygain_update(); if (global_settings.playlist_shuffle) playlist_randomise(NULL, current_tick, true); else playlist_sort(NULL, true); } } return usb; }
bool quick_screen_quick(int button_enter) { struct gui_quickscreen qs; bool oldshuffle = global_settings.playlist_shuffle; int oldrepeat = global_settings.repeat_mode; qs.items[QUICKSCREEN_TOP] = get_setting(global_settings.qs_items[QUICKSCREEN_TOP], find_setting(&global_settings.party_mode, NULL)); qs.items[QUICKSCREEN_LEFT] = get_setting(global_settings.qs_items[QUICKSCREEN_LEFT], find_setting(&global_settings.playlist_shuffle, NULL)); qs.items[QUICKSCREEN_RIGHT] = get_setting(global_settings.qs_items[QUICKSCREEN_RIGHT], find_setting(&global_settings.repeat_mode, NULL)); qs.items[QUICKSCREEN_BOTTOM] = get_setting(global_settings.qs_items[QUICKSCREEN_BOTTOM], find_setting(&global_settings.dirfilter, NULL)); qs.callback = NULL; if (gui_syncquickscreen_run(&qs, button_enter)) { settings_save(); settings_apply(false); /* make sure repeat/shuffle/any other nasty ones get updated */ if ( oldrepeat != global_settings.repeat_mode && (audio_status() & AUDIO_STATUS_PLAY) ) { audio_flush_and_reload_tracks(); } if (oldshuffle != global_settings.playlist_shuffle && audio_status() & AUDIO_STATUS_PLAY) { #if CONFIG_CODEC == SWCODEC dsp_set_replaygain(); #endif if (global_settings.playlist_shuffle) playlist_randomise(NULL, current_tick, true); else playlist_sort(NULL, true); } } return(0); }
/* * stress_splice * stress copying of /dev/zero to /dev/null */ static int stress_splice(const args_t *args) { int fd_in, fd_out, fds[2]; size_t splice_bytes = DEFAULT_SPLICE_BYTES; if (!get_setting("splice-bytes", &splice_bytes)) { if (g_opt_flags & OPT_FLAGS_MAXIMIZE) splice_bytes = MAX_SPLICE_BYTES; if (g_opt_flags & OPT_FLAGS_MINIMIZE) splice_bytes = MIN_SPLICE_BYTES; } splice_bytes /= args->num_instances; if (splice_bytes < MIN_SPLICE_BYTES) splice_bytes = MIN_SPLICE_BYTES; if (pipe(fds) < 0) { pr_fail_err("pipe"); return EXIT_FAILURE; } if ((fd_in = open("/dev/zero", O_RDONLY)) < 0) { (void)close(fds[0]); (void)close(fds[1]); pr_fail_err("open"); return EXIT_FAILURE; } if ((fd_out = open("/dev/null", O_WRONLY)) < 0) { (void)close(fd_in); (void)close(fds[0]); (void)close(fds[1]); pr_fail_err("open"); return EXIT_FAILURE; } do { ssize_t ret; ret = splice(fd_in, NULL, fds[1], NULL, splice_bytes, SPLICE_F_MOVE); if (ret < 0) break; ret = splice(fds[0], NULL, fd_out, NULL, splice_bytes, SPLICE_F_MOVE); if (ret < 0) break; inc_counter(args); } while (keep_stressing()); (void)close(fd_out); (void)close(fd_in); (void)close(fds[0]); (void)close(fds[1]); return EXIT_SUCCESS; }
/* * stress_lsearch() * stress lsearch */ static int stress_lsearch(const args_t *args) { int32_t *data, *root; size_t i, max; uint64_t lsearch_size = DEFAULT_LSEARCH_SIZE; if (!get_setting("lsearch-size", &lsearch_size)) { if (g_opt_flags & OPT_FLAGS_MAXIMIZE) lsearch_size = MAX_LSEARCH_SIZE; if (g_opt_flags & OPT_FLAGS_MINIMIZE) lsearch_size = MIN_LSEARCH_SIZE; } max = (size_t)lsearch_size; if ((data = calloc(max, sizeof(*data))) == NULL) { pr_fail_dbg("malloc"); return EXIT_NO_RESOURCE; } if ((root = calloc(max, sizeof(*data))) == NULL) { free(data); pr_fail_dbg("malloc"); return EXIT_NO_RESOURCE; } do { size_t n = 0; /* Step #1, populate with data */ for (i = 0; g_keep_stressing_flag && i < max; i++) { void *ptr; data[i] = ((mwc32() & 0xfff) << 20) ^ i; ptr = lsearch(&data[i], root, &n, sizeof(*data), cmp); (void)ptr; } /* Step #2, find */ for (i = 0; g_keep_stressing_flag && i < n; i++) { int32_t *result; result = lfind(&data[i], root, &n, sizeof(*data), cmp); if (g_opt_flags & OPT_FLAGS_VERIFY) { if (result == NULL) pr_fail("%s: element %zu could not be found\n", args->name, i); else if (*result != data[i]) pr_fail("%s: element %zu found %" PRIu32 ", expecting %" PRIu32 "\n", args->name, i, *result, data[i]); } } inc_counter(args); } while (keep_stressing()); free(root); free(data); return EXIT_SUCCESS; }
static url resolve_pfb (url name) { #ifndef OS_WIN32 // The kpsewhich from MikTeX is bugged for pfb fonts if (get_setting ("KPSEWHICH") == "true") { string which= kpsewhich (as_string (name)); if ((which!="") && exists (url_system (which))) return url_system (which); // cout << "Missed " << name << "\n"; } #endif return resolve (the_pfb_path * name); }
void reset_pfb_path () { string pfb= get_setting ("PFB"); the_pfb_path= url_here () | search_sub_dirs ("$TEXMACS_HOME_PATH/fonts/type1") | search_sub_dirs ("$TEXMACS_PATH/fonts/type1") | "$TEX_PFB_PATH" | (pfb == ""? url_none (): url_system (pfb)); the_pfb_path= expand (factor (the_pfb_path)); }
cloud_storage_account cloud_storage_account::parse_explicit_settings(std::map<utility::string_t, utility::string_t> settings) { utility::string_t blob_endpoint; utility::string_t queue_endpoint; utility::string_t table_endpoint; get_setting(settings, blob_endpoint_setting_string, blob_endpoint); get_setting(settings, queue_endpoint_setting_string, queue_endpoint); get_setting(settings, table_endpoint_setting_string, table_endpoint); storage_credentials credentials(get_credentials(settings)); if (settings.empty() && (!blob_endpoint.empty() || !queue_endpoint.empty() || !table_endpoint.empty())) { return cloud_storage_account(credentials, blob_endpoint.empty() ? storage_uri() : storage_uri(web::http::uri(blob_endpoint)), queue_endpoint.empty() ? storage_uri() : storage_uri(web::http::uri(queue_endpoint)), table_endpoint.empty() ? storage_uri() : storage_uri(web::http::uri(table_endpoint))); } return cloud_storage_account(); }
bool load_tex_tfm (string family, int size, int dsize, tex_font_metric& tfm) { string var= "tfm:" * family * as_string (size); if (is_cached ("font_cache.scm", var)) if (try_tfm (family, as_int (cache_get ("font_cache.scm", var)->label), size, tfm, false)) return true; if (get_setting ("MAKETFM") != "false") if (load_tex_tfm (family, size ,dsize, tfm, false)) return true; return load_tex_tfm (family, size ,dsize, tfm, true); }
void make_tex_pk (string name, int dpi, int design_dpi) { string s; int r= 0; if (get_setting ("MAKEPK") == "MakeTeXPK") { s="MakeTeXPK " * name * " " * as_string (dpi) * " " * as_string (design_dpi) * " " * as_string (dpi) * "/" * as_string (design_dpi) * " localfont"; if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n"; r= system (s); } if (get_setting ("MAKEPK") == "mktexpk") { url pk_dir ("$TEXMACS_HOME_PATH/fonts/pk"); s="mktexpk " * string ("--dpi ") * as_string (dpi) * " " * string ("--bdpi ") * as_string (design_dpi) * " " * string ("--mag ") * as_string (dpi) *"/"* as_string (design_dpi) * " " * string ("--destdir ") * as_string (pk_dir) * " " * name; if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n"; r= system (s); } if (get_setting ("MAKEPK") == "makepk") { #ifdef OS_WIN32 s = "makepk --dest-dir \"" * get_env("$TEXMACS_HOME_PATH") * "\\fonts\\pk\" " * name * " " * as_string(dpi) * " " * as_string(design_dpi) * " " * as_string(dpi) * "%//" * as_string(design_dpi); #else s = "makepk --dest-dir \"" * get_env("$TEXMACS_HOME_PATH") * "\\fonts\\pk\" " * name * " " * as_string(dpi) * " " * as_string(design_dpi) * " " * as_string(dpi) * "/" * as_string(design_dpi); #endif if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n"; r= system (s); } if (r) cout << "TeXmacs] system command failed: " << s << "\n"; }
storage_credentials get_credentials(std::map<utility::string_t, utility::string_t>& settings) { utility::string_t account_name; utility::string_t account_key; utility::string_t shared_access_signature; get_setting(settings, account_name_setting_string, account_name); get_setting(settings, account_key_setting_string, account_key); get_setting(settings, shared_access_signature_setting_string, shared_access_signature); if (!account_name.empty() && !account_key.empty() && shared_access_signature.empty()) { return storage_credentials(account_name, account_key); } if (account_name.empty() && account_key.empty() && !shared_access_signature.empty()) { return storage_credentials(shared_access_signature); } return storage_credentials(); }
bool_t settings_handle_message_received(CommChannel_t chan, CommMessage_t *msg) { Type_t type; uint8_t id; bool_t ret = TRUE; switch (msg->msgid) { case MESSAGE_ID_GET_SETTING: id = MESSAGE_GET_SETTING_GET_FROM_BUFFER_id(msg->payload); ret = get_setting(chan, id); break; case MESSAGE_ID_SETTING_UINT8: case MESSAGE_ID_SETTING_INT32: case MESSAGE_ID_SETTING_FLOAT: { float f; uint8_t u8; int32_t i32; id = MESSAGE_SETTING_UINT8_GET_FROM_BUFFER_id(msg->payload); type = (Type_t)MESSAGE_SETTING_UINT8_GET_FROM_BUFFER_type(msg->payload); switch (type) { case TYPE_UINT8: u8 = MESSAGE_SETTING_UINT8_GET_FROM_BUFFER_value(msg->payload); ret = set_setting_u8(id, u8); break; case TYPE_FLOAT: f = MESSAGE_SETTING_FLOAT_GET_FROM_BUFFER_value(msg->payload); ret = set_setting_float(id, f); break; case TYPE_INT32: i32 = MESSAGE_SETTING_INT32_GET_FROM_BUFFER_value(msg->payload); ret = set_setting_i32(id, i32); break; default: ret = FALSE; break; } break; } default: ret = FALSE; break; } return ret; }
void dict_move(dict *d, dict *s) { dict_entry *entry, *next; setting *setting = get_setting(); entry = s->head; while(entry) { dict_replace(d, entry->key, entry->value); next = entry->next; setting->free(entry); entry = next; } if(s->entries) setting->free(s->entries); memset(s, 0, sizeof(struct dict)); }
void usage(char *arg) { printf("usage: '%s'\t [ -q | --quiet ]", arg); printf(" [ -v | --verbose ] [ -g | --globbing ] \n"); printf(" \t\t [ -c | --config FILE ]"); printf(" [ -e | --execute COMMAND ] \n"); printf(" \t\t [ -s | --script FILE ]"); printf("[ -ne | --noexit ] [ -nc | --noconfig ]\n"); printf(" \t\t [ -a | --alias ] "); printf("[ -na | --noalias ] [ -nl | --nolsaftercd ]\n"); printf("\n"); printf("for more help, run '%s' and type 'help'\n", arg); if (get_setting("@exit?")) { exit(0); } }
void dict_free(dict *d) { dict_entry *entry, *next; setting *s = get_setting(); entry = d->head; while(entry) { DICT_KEY_FREE(d, entry->key); DICT_VALUE_FREE(d, entry->value); next = entry->next; s->free(entry); entry = next; } if(d->entries) s->free(d->entries); s->free(d); }