// ========================================================================== // METHOD rhnsource::getdesc // ========================================================================== string *rhnsource::getdesc (const statstring &id) { returnclass (string) res retain; bool gotsummary = false; value infoargs; infoargs.newval() = "/bin/rpm"; infoargs.newval() = "-qi"; infoargs.newval() = id; systemprocess infop (infoargs, true); infop.run(); while (! infop.eof()) { string line = infop.gets(); if (line.strlen() && (!gotsummary) && (line.strncmp ("Summary : ", 14) == 0)) { line = line.mid (14); res = line; gotsummary = true; } } infop.serialize(); return &res; }
// ========================================================================== // METHOD aptsource::getdesc // ========================================================================== string *aptsource::getdesc (const statstring &id) { returnclass (string) res retain; bool gotsummary = false; value infoargs; infoargs.newval() = "/usr/bin/apt-cache"; infoargs.newval() = "show"; infoargs.newval() = id; systemprocess infop (infoargs, true); infop.run(); APP->log (log::info, "apt-src", "Getting description: %S", id.str()); while (! infop.eof()) { string line = infop.gets(); if (line.strlen() && (!gotsummary) && (line.strncmp ("Description:", 12) == 0)) { line = line.mid (13); res = line; gotsummary = true; } } infop.serialize(); return &res; }
// ========================================================================== // METHOD yumsource::getlist // ========================================================================== const value &yumsource::list (void) { value list; value infoargs; string name, summary; list = getlist(); if (! list.count()) { cache = list; return cache; } APP->log (log::info, "yum-src", "Getting descriptions"); infoargs.newval() = "/usr/bin/yum"; infoargs.newval() = "-C"; infoargs.newval() = "info"; infoargs.newval() = "available"; foreach (update, list) { infoargs.newval() = update.id(); } systemprocess infop (infoargs, true); infop.run(); while (! infop.eof()) { string line = infop.gets(); if (line.strlen()) { if (line.strncmp ("Name :", 8) == 0) { line = line.mid (9); name = line; } else if (line.strncmp ("Summary:", 8) == 0) { line = line.mid (9); list[name]["description"] = line; } } } infop.serialize(); resolvealldeps (list); cache = list; cache.saveshox (PATH_CACHEFILE); return cache; }
int DbInfo::parse(std::string& info) { InfoParser infop(info); addr = infop.pop(); port = infop.pop(); db = infop.pop(); user = infop.pop(); passwd = infop.pop(); return 0; }
//* Asklang is now a special plugin loaded before all others plugins *// int ask_language() { void *handle; void *(*infop) (void); char *ptr = g_strdup_printf("%s/%s", PLUGINDIR, "asklang.so"); if ((handle = dlopen(ptr, RTLD_NOW)) == NULL) { fprintf(stderr, "%s", dlerror()); FREE(ptr); return(1); } FREE(ptr); if ((infop = dlsym(handle, "info")) == NULL) { fprintf(stderr, "%s", dlerror()); return(1); } plugin_t *pluginlang = infop(); pluginlang->handle = handle; GtkWidget *pBoite = gtk_dialog_new_with_buttons("Language selection (default : en_US)", NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK,GTK_RESPONSE_OK, NULL); gtk_widget_set_size_request (pBoite, 800, 600); gtk_window_set_deletable ( GTK_WINDOW ( pBoite ), FALSE ); GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (g_strdup_printf("%s/headlogo.png", IMAGEDIR), NULL); if(!pixbuf) { fprintf(stdout, "error message: can't load images/headlogo.png\n"); } else { /* Set it as icon window */ gtk_window_set_icon(GTK_WINDOW (pBoite),pixbuf); } g_object_unref(pixbuf); GtkWidget *langtab = pluginlang->load_gtk_widget(); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(pBoite)->vbox), langtab, TRUE, TRUE, 5); gtk_widget_show_all(GTK_DIALOG(pBoite)->vbox); gtk_dialog_run(GTK_DIALOG(pBoite)); pluginlang->run(&config); gtk_widget_destroy(pBoite); return 0; }
//* Open a file plugin and add it into list *// int fwife_add_plugins(char *filename) { void *handle; void *(*infop) (void); if ((handle = dlopen(filename, RTLD_NOW)) == NULL) { fprintf(stderr, "%s", dlerror()); return(1); } if ((infop = dlsym(handle, "info")) == NULL) { fprintf(stderr, "%s", dlerror()); return(1); } plugin_t *plugin = infop(); plugin->handle = handle; plugin_list = g_list_append(plugin_list, plugin); return(0); }