int example_setfont () { const char **vars = (const char **)set_str_add (set_str_add((void **)NULL, "configuration_services_setfont_font"), "lat2-12"); char *res = apply_variables ("tty_max=$(cat /etc/einit/subsystems.d/tty.xml | egrep -c 'tty[0-9]-regular'); tty_list=$(seq 1 ${tty_max}); if [ -d /dev/vc ]; then tty_dev=/dev/vc/; else tty_dev=/dev/tty; fi; for tty_num in ${tty_list}; do setfont ${configuration_services_setfont_font} -C ${tty_dev}${tty_num}; done", vars); const char *expected_result = "tty_max=$(cat /etc/einit/subsystems.d/tty.xml | egrep -c 'tty[0-9]-regular'); tty_list=$(seq 1 ${tty_max}); if [ -d /dev/vc ]; then tty_dev=/dev/vc/; else tty_dev=/dev/tty; fi; for tty_num in ${tty_list}; do setfont lat2-12 -C ${tty_dev}${tty_num}; done"; char test_failed = 0; if (!strmatch (res, expected_result)) { test_failed = 1; fprintf (stdout, "setfont example failed:\n expected result:\n\"%s\"\n actual result:\n\"%s\"\n", expected_result, res); } efree (vars); efree (res); return test_failed; }
int example_half_simple_start () { const char **vars = (const char **)set_str_add(set_str_add((void **)NULL, "simple"), "start"); char *res = apply_variables ("${simple}${half}", vars); const char *expected_result = "start${half}"; char test_failed = 0; if (!strmatch (res, expected_result)) { test_failed = 1; fprintf (stdout, "setfont example failed:\n expected result:\n\"%s\"\n actual result:\n\"%s\"\n", expected_result, res); } efree (vars); efree (res); return test_failed; }
int linux_kernel_modules_load (char **modules) { if (!modules) return status_failed; pthread_t **threads = NULL; char *modprobe_command = cfg_getstring ("configuration-command-modprobe/with-env", 0); uint32_t i = 0; for (; modules[i]; i++) if (strcmp ("", modules[i])) { const char *tpldata[] = { "module", modules[i], NULL }; char *applied = apply_variables (modprobe_command, tpldata); if (applied) { notice (4, "loading kernel module: %s", modules[i]); if (modules[i+1]) { pthread_t *threadid = emalloc (sizeof (pthread_t)); if (ethread_create (threadid, NULL, (void *(*)(void *))linux_kernel_modules_load_exec, applied)) { linux_kernel_modules_load_exec (applied); } else { threads = (pthread_t **)setadd ((void **)threads, threadid, SET_NOALLOC); } } else { linux_kernel_modules_load_exec (applied); } } } free (modules); if (threads) { int i = 0; for (; threads[i]; i++) { pthread_join (*(threads[i]), NULL); free (threads[i]); } free (threads); } return status_ok; }