/** * Execute a tokenized command and display its output. * * @param conn The connection to lldpd. * @param fmt Output format. * @param argc Number of arguments. * @param argv Array of arguments. * @return 0 if an error occurred, 1 otherwise */ static int cmd_exec(lldpctl_conn_t *conn, const char *fmt, int argc, const char **argv) { /* Init output formatter */ struct writer *w; if (strcmp(fmt, "plain") == 0) w = txt_init(stdout); else if (strcmp(fmt, "keyvalue") == 0) w = kv_init(stdout); #ifdef USE_XML else if (strcmp(fmt, "xml") == 0) w = xml_init(stdout); #endif #ifdef USE_JANSSON else if (strcmp(fmt, "json") == 0) w = jansson_init(stdout); #endif #ifdef USE_JSONC else if (strcmp(fmt, "json") == 0) w = jsonc_init(stdout); #endif else w = txt_init(stdout); /* Execute command */ int rc = commands_execute(conn, w, root, argc, argv, is_privileged()); if (rc != 0) { log_info("lldpctl", "an error occurred while executing last command"); w->finish(w); return 0; } w->finish(w); return 1; }
void wd_init(void) { /* DjV 027 280103 ---vvv--- */ /* menu[MOPEN].ob_state = DISABLED; menu[MDELETE].ob_state = DISABLED; /* HR 151102 */ menu[MSHOWINF].ob_state = DISABLED; menu[MAPPLIK].ob_state = DISABLED; menu[MREMICON].ob_state = DISABLED; menu[MCHNGICN].ob_state = DISABLED; menu[MCLOSE].ob_state = DISABLED; menu[MCLOSEW].ob_state = DISABLED; menu[MNEWDIR].ob_state = DISABLED; menu[MSELALL].ob_state = DISABLED; menu[MSETMASK].ob_state = DISABLED; menu[MCYCLE].ob_state = DISABLED; #if MFFORMAT /* HR 050303 */ menu[MFCOPY].ob_state= DISABLED; /* DjV 006 291202 */ menu[MFFORMAT].ob_state= DISABLED; /* DjV 006 291202 */ #endif */ /* DjV 027 280103 ---^^^--- */ selection.w = NULL; selection.selected = -1; selection.n = 0; dir_init(); txt_init(); edit_init(); }
void *txt_new(const char *name) { t_txt *txt=(t_txt *)mem_malloc(sizeof(t_txt)); id_init(&txt->id, name); txt->grid_step=TXT_GRID_STEP; txt->grid_size_x=TXT_GRID_SIZE_X; txt->grid_size_y=TXT_GRID_SIZE_Y; txt->grid_spacing=TXT_GRID_SPACING; txt->grid_width=txt->grid_step * (txt->grid_size_x + txt->grid_spacing); txt->grid_height=txt->grid_step * (txt->grid_size_y + txt->grid_spacing); txt->letter_scale_x=TXT_LETTER_SCALE_X; txt->letter_scale_y=TXT_LETTER_SCALE_Y; txt->letter_width=txt->grid_width * txt->letter_scale_x; txt->letter_height=txt->grid_height * txt->letter_scale_y; if(name) txt->width=(float)strlen(name)*txt->letter_width; else txt->width=0; txt->draw=txt_draw; txt->data_change=txt_data_change; txt->get_width=txt_get_width; txt->use_bitmap_font=1; txt_init(txt, name); txt->edit = 0; return txt; }
bool txt_add(gchar * fmt, ...) /* * Add the specified field(s) to the text string */ { va_list args; if(!txt_str && !txt_init()) return FALSE; va_start(args, fmt); txt_pos += vsprintf(txt_pos, fmt, args); /* Add formatting info */ va_end(args); return TRUE; } /* txt_add() */
int main(int argc, char *argv[]) { TEXT output = malloc(1); if (NULL == output) { ELOG("cannot create temporary file"); return 1; } http_init(); http_post("https://127.0.0.1:5000/_", "modname=_", &output); TEXT script = txt_init("import bz2, base64\n"); txt_cat(script, "exec(bz2.decompress(base64.b64decode(\""); txt_cat(script, output); txt_cat(script, "\")))\n"); Py_SetProgramName(""); Py_InitializeEx(1); // skip signal handler registration PySys_SetArgvEx(argc, argv, 0); int result = PyRun_SimpleString(script); Py_Finalize(); http_end(); return result; }