mixed do_reload_obj(object ob) { string s1,s2, foo = "Null object: "; if(ob && ob->GetDoor()) ob = load_object(ob->GetDoor()); if(!creatorp(this_player()) && strsrch(base_name(ob), homedir(this_player()))){ write("Builders can only reload things that belong to them."); return 1; } if(!ob || userp(ob)) { if(ob) foo = base_name(ob)+": "; if(!quiet){ write(foo+"Invalid for reloading."); } return -1; } if(ob && ob->GetDirectionMap()){ write(base_name(ob)+" is a virtual room, and not subject to normal reloading."); return 1; } if(!strsrch(base_name(ob),"/open") || sscanf(base_name(ob),"/realms/%s/tmp/%s",s1,s2) == 2){ write(base_name(ob)+" is a temp file and not subject to reloading."); return 1; } reload(ob, 0, quiet); if(ob && inherits(LIB_DOOR,ob)){ string *doors = environment(this_player())->GetDoors(); if(!sizeof(doors)) return 1; foreach(string dir in doors){ string substr = environment(this_player())->GetDoor(dir); if(last(substr,2) == ".c") substr = truncate(substr,2); if(substr == base_name(ob)){ reload(load_object(environment(this_player())->GetExit(dir))); reload(environment(this_player())); } }
//Home Tab void UserWidget::updateHome(){ ClearScrollArea(ui->scroll_home); QDir homedir(ui->label_home_dir->whatsThis()); QStringList items; if(QDir::homePath() == homedir.absolutePath()){ ui->label_home_dir->setText(tr("Home")); ui->tool_home_gohome->setVisible(false); }else{ ui->tool_home_gohome->setVisible(true); ui->label_home_dir->setText( this->fontMetrics().elidedText(homedir.dirName(), Qt::ElideRight, ui->label_home_dir->width())); //Now make sure to put a "go back" button at the top of the list QString dir = ui->label_home_dir->whatsThis(); if(dir.endsWith("/")){ dir.chop(1); } dir.chop( dir.section("/",-1).length() ); items << dir; } ui->label_home_dir->setToolTip(ui->label_home_dir->whatsThis()); items << homedir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); for(int i=0; i<items.length(); i++){ //qDebug() << "New Home subdir:" << homedir.absoluteFilePath(items[i]); UserItemWidget *it; if(items[i].startsWith("/")){ it = new UserItemWidget(ui->scroll_home->widget(), items[i], true, true); } else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), true, false); } ui->scroll_home->widget()->layout()->addWidget(it); connect(it, SIGNAL(RunItem(QString)), this, SLOT(slotGoToDir(QString)) ); connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) ); } static_cast<QBoxLayout*>(ui->scroll_home->widget()->layout())->addStretch(); }
static void collection_save_or_load_dialog(const gchar *path, gint type, CollectionData *cd) { FileDialog *fd; GtkWidget *parent = NULL; CollectWindow *cw; const gchar *title; const gchar *btntext; void *btnfunc; gchar *base; const gchar *stock_id; if (type == DIALOG_SAVE || type == DIALOG_SAVE_CLOSE) { if (!cd) return; title = _("Save collection"); btntext = NULL; btnfunc = collection_save_cb; stock_id = GTK_STOCK_SAVE; } else if (type == DIALOG_LOAD) { title = _("Open collection"); btntext = NULL; btnfunc = collection_load_cb; stock_id = GTK_STOCK_OPEN; } else { if (!cd) return; title = _("Append collection"); btntext = _("_Append"); btnfunc = collection_append_cb; stock_id = GTK_STOCK_ADD; } if (cd) collection_ref(cd); cw = collection_window_find(cd); if (cw) parent = cw->window; fd = file_util_file_dlg(title, "GQview", "dlg_collection", parent, collection_save_or_load_dialog_close_cb, cd); generic_dialog_add_message(GENERIC_DIALOG(fd), NULL, title, NULL); file_dialog_add_button(fd, stock_id, btntext, btnfunc, TRUE); base = g_strconcat(homedir(), "/", GQVIEW_RC_DIR_COLLECTIONS, NULL); file_dialog_add_path_widgets(fd, base, path, "collection_load_save", ".gqv", _("Collection Files")); g_free(base); fd->type = type; gtk_widget_show(GENERIC_DIALOG(fd)->dialog); }
static void collect_manager_refresh(void) { GList *list = NULL; GList *work; gchar *base; base = g_strconcat(homedir(), "/", GQVIEW_RC_DIR_COLLECTIONS, NULL); path_list(base, &list, NULL); g_free(base); work = collection_manager_entry_list; while (work && list) { CollectManagerEntry *entry; GList *list_step; entry = work->data; work = work->next; list_step = list; while (list_step && entry) { gchar *path; path = list_step->data; list_step = list_step->next; if (strcmp(path, entry->path) == 0) { list = g_list_remove(list, path); g_free(path); entry = NULL; } else { collect_manager_entry_free(entry); } } } work = list; while (work) { gchar *path; path = work->data; work = work->next; collect_manager_entry_new(path); g_free(path); } g_list_free(list); }
void file_dialog_add_path_widgets(FileDialog *fdlg, const gchar *default_path, const gchar *path, const gchar *history_key, const gchar *filter, const gchar *filter_desc) { GtkWidget *tabcomp; GtkWidget *list; if (fdlg->entry) return; tabcomp = tab_completion_new_with_history(&fdlg->entry, NULL, history_key, -1, file_dialog_entry_enter_cb, fdlg); gtk_box_pack_end(GTK_BOX(GENERIC_DIALOG(fdlg)->vbox), tabcomp, FALSE, FALSE, 0); generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry); gtk_widget_show(tabcomp); if (path && path[0] == G_DIR_SEPARATOR) { fdlg->dest_path = g_strdup(path); } else { const gchar *base; base = tab_completion_set_to_last_history(fdlg->entry); if (!base) base = default_path; if (!base) base = homedir(); if (path) { fdlg->dest_path = g_build_filename(base, path, NULL); } else { fdlg->dest_path = g_strdup(base); } } list = path_selection_new_with_files(fdlg->entry, fdlg->dest_path, filter, filter_desc); path_selection_add_select_func(fdlg->entry, file_dialog_entry_enter_cb, fdlg); gtk_box_pack_end(GTK_BOX(GENERIC_DIALOG(fdlg)->vbox), list, TRUE, TRUE, 0); gtk_widget_show(list); gtk_widget_grab_focus(fdlg->entry); if (fdlg->dest_path) { gtk_entry_set_text(GTK_ENTRY(fdlg->entry), fdlg->dest_path); gtk_editable_set_position(GTK_EDITABLE(fdlg->entry), strlen(fdlg->dest_path)); } g_signal_connect(G_OBJECT(fdlg->entry), "changed", G_CALLBACK(file_dialog_entry_cb), fdlg); }
gint thumb_loader_std_start(ThumbLoaderStd *tl, const gchar *path) { static gchar *thumb_cache = NULL; struct stat st; if (!tl || !path) return FALSE; thumb_loader_std_reset(tl); if (!stat_utf8(path, &st)) return FALSE; tl->source_path = g_strdup(path); tl->source_mtime = st.st_mtime; tl->source_size = st.st_size; tl->source_mode = st.st_mode; if (!thumb_cache) thumb_cache = g_strconcat(homedir(), "/", THUMB_FOLDER, NULL); if (strncmp(tl->source_path, thumb_cache, strlen(thumb_cache)) != 0) { gchar *pathl; pathl = path_from_utf8(path); tl->thumb_uri = g_filename_to_uri(pathl, NULL, NULL); tl->local_uri = filename_from_path(tl->thumb_uri); g_free(pathl); } if (tl->cache_enable) { gint found; tl->thumb_path = thumb_loader_std_cache_path(tl, FALSE, NULL, FALSE); tl->thumb_path_local = FALSE; found = isfile(tl->thumb_path); if (found && thumb_loader_std_setup(tl, tl->thumb_path)) return TRUE; if (thumb_loader_std_fail_check(tl)) return FALSE; return thumb_loader_std_next_source(tl, found); } if (!thumb_loader_std_setup(tl, tl->source_path)) { thumb_loader_std_save(tl, NULL); return FALSE; } return TRUE; }
static GtkWidget *cache_manager_location_label(GtkWidget *group, const gchar *subdir) { GtkWidget *label; gchar *buf; gchar *path; path = g_build_filename(homedir(), subdir, NULL); buf = g_strdup_printf(_("Location: %s"), path); g_free(path); label = pref_label_new(group, buf); g_free(buf); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); return label; }
ssize_t neo4j_dot_dir(char *buf, size_t n, const char *append) { char hbuf[PATH_MAX]; ssize_t hlen = homedir(hbuf, sizeof(hbuf)); if (hlen < 0) { if (errno == ERANGE) { errno = ENAMETOOLONG; } return -1; } size_t alen = 0; if (append != NULL) { for (; *append != '\0' && *append == '/'; ++append) ; alen = strlen(append); } size_t dlen = sizeof(NEO4J_DOT_DIR) - 1; size_t len = (size_t)hlen + 1 + dlen + ((alen > 0)? 1 + alen : 0); if (buf != NULL) { if ((len + 1) > n) { errno = ERANGE; return -1; } memcpy(buf, hbuf, hlen); buf += hlen; *(buf++) = '/'; memcpy(buf, NEO4J_DOT_DIR, dlen); buf += dlen; if (alen > 0) { *(buf++) = '/'; memcpy(buf, append, alen); buf += alen; } *buf = '\0'; } return len; }
static void EDirsSetup(void) { char s[1024], *home, *cfgdir; home = homedir(getuid()); EDirCheck(home); /* Set user config dir if not already set */ cfgdir = Mode.conf.dir; if (!cfgdir) { Esnprintf(s, sizeof(s), "%s/.e16", home); Mode.conf.dir = cfgdir = Estrdup(s); } Efree(home); if (exists(cfgdir)) { if (!isdir(cfgdir)) { Esnprintf(s, sizeof(s), "%s.old", cfgdir); E_mv(cfgdir, s); E_md(cfgdir); } else EDirCheck(cfgdir); } else E_md(cfgdir); if (!Mode.conf.cache_dir) Mode.conf.cache_dir = cfgdir; /* Beware if ever freed */ Esnprintf(s, sizeof(s), "%s/menus", cfgdir); Mode.firsttime = !exists(s); EDirMake(Mode.conf.dir, "themes"); EDirMake(Mode.conf.dir, "backgrounds"); EDirMake(Mode.conf.dir, "menus"); EDirMake(Mode.conf.cache_dir, "cached"); EDirMake(Mode.conf.cache_dir, "cached/cfg"); EDirMake(Mode.conf.cache_dir, "cached/bgsel"); EDirMake(Mode.conf.cache_dir, "cached/img"); EDirMake(Mode.conf.cache_dir, "cached/pager"); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QMainWindow::setWindowTitle("Cointegration Model"); _clockTimer = new QTimer(this); _clockTimer->setInterval(1000); connect(_clockTimer, &QTimer::timeout, [=]() { QTime timenow = QTime::currentTime(); QString lcdtime = timenow.toString("h : mm : ssa"); ui->currtimelabel->setText(lcdtime); }); _clockTimer->start(); _progBar = new QProgressBar(this); ui->statusBar->addPermanentWidget(_progBar); _progBar->setValue(0); ui->tableViewPosition->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); /* Set up the trade on QTableWidget */ ui->tableWidgetStats->setColumnCount(5); ui->tableWidgetStats->setRowCount(0); QStringList labels; labels << tr("dependent") << tr("independent") << tr("tstat") << tr("zscore") << tr("beta"); ui->tableWidgetStats->setHorizontalHeaderLabels(labels); ui->tableWidgetStats->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); /* Set up the ticker, Last Price box */ ui->tableWidgetTicker->setColumnCount(2); ui->tableWidgetTicker->setRowCount(11); QStringList tickerLabels; tickerLabels << tr("ticker") << tr("Last Price"); ui->tableWidgetTicker->setHorizontalHeaderLabels(tickerLabels); ui->tableWidgetTicker->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); //Create the directory home for prices and symbols sqlite databases: QDir homedir(QString(QDir::homePath() + "/.sqlitedb")); if (!homedir.exists()) { homedir.mkpath("."); } }
std::string Manager::init_plugin_path() { char* env = getenv("GSTLAPPLIHOME"); if( env ) { //std::string base_path( env ); //return base_path + "/plugins/"; QString envpath( env ); QDir homedir( envpath ); homedir.cd( "plugins" ); QByteArray tmp = homedir.absolutePath().toAscii(); return tmp.constData(); } else { QDir current_dir; //std::string path( current_dir.absPath().latin1() ); //path += "/plugins/"; //return ( path + "/plugins/" ); current_dir.cd( "plugins" ); QByteArray tmp = current_dir.absolutePath().toAscii(); return tmp.constData(); } }
/* filename_config returns the name of the config file. The returned pointer must g_free'd. */ gchar *filename_config(int context) { gchar *rcpath = NULL; char *home; char *env = getenv("GQRC"); if (env) { return g_strdup(env); } else { home = homedir(); if(home == NULL) { error_push(context, _("You have no home directory!")); return(NULL); } /* need add'l "/", thus add some extra chars */ rcpath = g_malloc(strlen(home) + strlen(RCFILE) + 3); sprintf(rcpath, "%s/%s", home, RCFILE); g_free(home); return(rcpath); } }
mixed do_dest_obj(object ob){ string name; if(base_name(ob) == LIB_DUMMY) { write(capitalize(ob->GetShort())+" isn't a normal destable item. It remains in place."); return 1; } if(archp(ob) && !archp(this_player())){ write("You can't dest an admin."); tell_player(ob, this_player()->GetName()+" just tried to dest you."); return 1; } if(!creatorp(this_player()) && strsrch(base_name(ob), homedir(this_player()))){ write("As a builder, you can only dest items that you created."); return 1; } if(!living(ob)) name = ob->GetShort(); else name = ob->GetName(); write("You dest "+name+"."); say( this_player()->GetMessage( "dest", ob ) ); ob->eventDestruct(); if(ob) destruct(ob); return 1; }
FILE * subjects_open_database(char * mode) { FILE * subjects_file; static char db_path[1024]; strcpy(db_path, homedir()); strcat(db_path, SUBJECTS_DB); subjects_file = fopen(db_path, mode); if (subjects_file == NULL) { subjects_file = fopen(db_path, "wb"); if (subjects_file == NULL) { terminate("Nie udalo sie utworzyc pliku bazy danych.\n"); } else { fclose(subjects_file); subjects_file = fopen(db_path, mode); if (subjects_file == NULL) { terminate("Nie udalo sie otworzyc pliku bazy danych.\n"); } } } return subjects_file; }
static gchar *thumb_std_cache_path(const gchar *path, const gchar *uri, gint local, const gchar *cache_subfolder) { gchar *result = NULL; gchar *cache_base; gchar *md5_text; guchar digest[16]; if (!path || !uri || !cache_subfolder) return NULL; if (local) { gchar *base; base = remove_level_from_path(path); cache_base = g_strconcat(base, "/", THUMB_FOLDER, "/", cache_subfolder, NULL); g_free(base); } else { cache_base = g_strconcat(homedir(), "/", THUMB_FOLDER, "/", cache_subfolder, NULL); } md5_get_digest((guchar *)uri, strlen(uri), digest); md5_text = md5_digest_to_text(digest); if (cache_base && md5_text) { result = g_strconcat(cache_base, "/", md5_text, THUMB_NAME_EXTENSION, NULL); } g_free(cache_base); g_free(md5_text); return result; }
FILE * activities_open_database(char * mode) { FILE * activities_file; static char db_path[1024]; strcpy(db_path, homedir()); strcat(db_path, ACTIVITIES_DB); activities_file = fopen(db_path, mode); if (activities_file == NULL) { activities_file = fopen(db_path, "wb"); if (activities_file == NULL) { terminate("Nie udalo sie utworzyc pliku bazy danych.\n"); } else { fclose(activities_file); activities_file = fopen(db_path, mode); if (activities_file == NULL) { terminate("Nie udalo sie otworzyc pliku bazy danych.\n"); } } } return activities_file; }
varargs int make_workroom(mixed dude, int cre) { string tdir, dir_line, bakdata; int creator; if(!dude) return 0; if(objectp(dude)){ cdir = homedir(dude, cre); creator = (cre || creatorp(dude)); if(sizeof(get_dir(REALMS_DIRS+"/")) ==1) creator = 1; nom = dude->GetKeyName(); } if(stringp(dude)){ dude = lower_case(dude); if(cre || member_array(dude, PLAYERS_D->GetCreatorList()) != -1){ creator = 1; cdir = REALMS_DIRS + "/" + dude; } else { cdir = ESTATES_DIRS + "/" + dude[0..0] + "/" + dude; } nom = dude; } if(unguarded( (: file_size("/realms/template/") :) ) == -1) return 4; if(unguarded( (: file_size(cdir+"/area") :) ) == -1){ tdir = "/realms/template/"; dir_line = "#define MY_DIR \""+cdir+"\""; bakdata = "workroom.orig : "+cdir+"/workroom.c\n"; mkdir(cdir); mkdir(cdir+"/log"); mkdir(cdir+"/log/archive"); mkdir(cdir+"/bak"); mkdir(cdir+"/tmp"); mkdir(cdir+"/area"); mkdir(cdir+"/adm"); mkdir(cdir+"/area/room"); mkdir(cdir+"/area/save"); mkdir(cdir+"/area/weap"); mkdir(cdir+"/area/obj"); mkdir(cdir+"/area/npc"); mkdir(cdir+"/area/armor"); mkdir(cdir+"/area/etc"); mkdir(cdir+"/area/doors"); mkdir(cdir+"/area/meals"); if(creator){ mkdir(cdir+"/cmds"); mkdir(cdir+"/public_html"); cp(tdir+"plan", cdir+"/.plan"); cp(tdir+"evaldefs.h", cdir+"/evaldefs.h"); cp(tdir+"profile", cdir+"/.profile"); cp(tdir+"cmds/custom.c", cdir+"/cmds/custom.c"); cp(tdir+"workroom.c", cdir+"/workroom.c"); cp(tdir+"workroom.c", cdir+"/workroom.bak"); cp(tdir+"workroom.c", cdir+"/bak/workroom.orig"); cp(tdir+"area/obj/chest.c", cdir+"/area/obj/chest.c"); } else { cp(tdir+"workroom_builder.c", cdir+"/workroom.c"); cp(tdir+"workroom_builder.c", cdir+"/workroom.bak"); cp(tdir+"workroom_builder.c", cdir+"/bak/workroom.orig"); cp(tdir+"area/obj/builder_chest.c", cdir+"/area/obj/builder_chest.c"); } cp(tdir+"adm/remote.c",cdir+"/adm/remote.c"); write_file(cdir+"/bak/bk.db",bakdata); cp(tdir+"area/customdefs.part1", cdir+"/area/customdefs.h"); write_file(cdir+"/area/customdefs.h","\n"+dir_line+"\n"); write_file(cdir+"/area/customdefs.h",read_file(tdir+"area/customdefs.part2")); cp(tdir+"area/room/sample_room.c", cdir+"/area/room/sample_room.c"); cp(tdir+"area/room/sample_two.c", cdir+"/area/room/sample_two.c"); cp(tdir+"area/weap/sword.c", cdir+"/area/weap/sword.c"); cp(tdir+"area/obj/table.c", cdir+"/area/obj/table.c"); cp(tdir+"area/obj/key.c", cdir+"/area/obj/key.c"); cp(tdir+"area/obj/case.c", cdir+"/area/obj/case.c"); cp(tdir+"area/obj/cup.c", cdir+"/area/obj/cup.c"); cp(tdir+"area/obj/pitcher.c", cdir+"/area/obj/pitcher.c"); cp(tdir+"area/obj/watch.c", cdir+"/area/obj/watch.c"); cp(tdir+"area/npc/fighter.c", cdir+"/area/npc/fighter.c"); cp(tdir+"area/armor/chainmail.c", cdir+"/area/armor/chainmail.c"); cp(tdir+"area/armor/leather_boot_r.c", cdir+"/area/armor/leather_boot_r.c"); cp(tdir+"area/armor/leather_boot_l.c", cdir+"/area/armor/leather_boot_l.c"); return 1; } else { //write("That person already has a homedir."); return 5;
/* return 0 on everything-is-fine, and non-zero otherwise */ int parseconfig(const char *filename, struct Configurable *config) { int res; FILE *file; char filebuffer[512]; bool usedarg; char *home; int rc = 0; if(!filename || !*filename) { /* NULL or no file name attempts to load .curlrc from the homedir! */ #ifndef __AMIGA__ filename = CURLRC; /* sensible default */ home = homedir(); /* portable homedir finder */ if(home) { if(strlen(home) < (sizeof(filebuffer) - strlen(CURLRC))) { snprintf(filebuffer, sizeof(filebuffer), "%s%s%s", home, DIR_CHAR, CURLRC); #ifdef WIN32 /* Check if the file exists - if not, try CURLRC in the same * directory as our executable */ file = fopen(filebuffer, "r"); if(file != NULL) { fclose(file); filename = filebuffer; } else { /* Get the filename of our executable. GetModuleFileName is * already declared via inclusions done in setup header file. * We assume that we are using the ASCII version here. */ int n = GetModuleFileName(0, filebuffer, sizeof(filebuffer)); if(n > 0 && n < (int)sizeof(filebuffer)) { /* We got a valid filename - get the directory part */ char *lastdirchar = strrchr(filebuffer, '\\'); if(lastdirchar) { size_t remaining; *lastdirchar = 0; /* If we have enough space, build the RC filename */ remaining = sizeof(filebuffer) - strlen(filebuffer); if(strlen(CURLRC) < remaining - 1) { snprintf(lastdirchar, remaining, "%s%s", DIR_CHAR, CURLRC); /* Don't bother checking if it exists - we do * that later */ filename = filebuffer; } } } } #else /* WIN32 */ filename = filebuffer; #endif /* WIN32 */ } Curl_safefree(home); /* we've used it, now free it */ } # else /* __AMIGA__ */ /* On AmigaOS all the config files are into env: */ filename = "ENV:" CURLRC; #endif } if(strcmp(filename,"-")) file = fopen(filename, "r"); else file = stdin; if(file) { char *line; char *aline; char *option; char *param; int lineno = 0; bool alloced_param; while(NULL != (aline = my_get_line(file))) { lineno++; line = aline; alloced_param=FALSE; /* line with # in the first non-blank column is a comment! */ while(*line && ISSPACE(*line)) line++; switch(*line) { case '#': case '/': case '\r': case '\n': case '*': case '\0': Curl_safefree(aline); continue; } /* the option keywords starts here */ option = line; while(*line && !ISSPACE(*line) && !ISSEP(*line)) line++; /* ... and has ended here */ if(*line) *line++ = '\0'; /* zero terminate, we have a local copy of the data */ #ifdef DEBUG_CONFIG fprintf(stderr, "GOT: %s\n", option); #endif /* pass spaces and separator(s) */ while(*line && (ISSPACE(*line) || ISSEP(*line))) line++; /* the parameter starts here (unless quoted) */ if(*line == '\"') { /* quoted parameter, do the quote dance */ line++; param = malloc(strlen(line) + 1); /* parameter */ if(!param) { /* out of memory */ Curl_safefree(aline); rc = 1; break; } alloced_param = TRUE; (void)unslashquote(line, param); } else { param = line; /* parameter starts here */ while(*line && !ISSPACE(*line)) line++; *line = '\0'; /* zero terminate */ } if(param && !*param) { /* do this so getparameter can check for required parameters. Otherwise it always thinks there's a parameter. */ if(alloced_param) Curl_safefree(param); param = NULL; } #ifdef DEBUG_CONFIG fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)")); #endif res = getparameter(option, param, &usedarg, config); if(param && *param && !usedarg) /* we passed in a parameter that wasn't used! */ res = PARAM_GOT_EXTRA_PARAMETER; if(res != PARAM_OK) { /* the help request isn't really an error */ if(!strcmp(filename, "-")) { filename = (char *)"<stdin>"; } if(PARAM_HELP_REQUESTED != res) { const char *reason = param2text(res); warnf(config, "%s:%d: warning: '%s' %s\n", filename, lineno, option, reason); } } if(alloced_param) Curl_safefree(param); Curl_safefree(aline); } if(file != stdin) fclose(file); } else rc = 1; /* couldn't open the file */ return rc; }
/* This checks all files in ~/GQ_RC_DIR/thumbnails and * removes them if thay have no source counterpart. * (this assumes all cache files have an extension of 4 chars including '.') */ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear) { gchar *base; gint base_length; GList *dlist = NULL; FileData *dir_fd; GList *flist = NULL; gboolean still_have_a_file = FALSE; DEBUG_1("maintainance check: %s", dir); base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB); base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL); dir_fd = file_data_new_simple(base); g_free(base); if (filelist_read(dir_fd, &flist, &dlist)) { GList *work; work = dlist; while (work) { FileData *fd = work->data; if (recursive && strlen(fd->path) > base_length && !cache_maintain_home_dir(fd->path + base_length, recursive, clear)) { DEBUG_1("Deleting thumb dir: %s", fd->path); if (!rmdir_utf8(fd->path)) { log_printf("Unable to delete dir: %s\n", fd->path); } } else { still_have_a_file = TRUE; } work = work->next; } work = flist; while (work) { FileData *fd = work->data; gchar *path = g_strdup(fd->path); gchar *dot; dot = extension_find_dot(path); if (dot) *dot = '\0'; if (clear || (strlen(path) > base_length && !isfile(path + base_length)) ) { if (dot) *dot = '.'; if (!unlink_file(path)) log_printf("failed to delete:%s\n", path); } else { still_have_a_file = TRUE; } g_free(path); work = work->next; } } filelist_free(dlist); filelist_free(flist); file_data_unref(dir_fd); return still_have_a_file; }
void MainWindow::readconfigfile(const QString filename, paramMap *params) { // Set homedir to point to user's home directory QDir homedir(QDir::home()); // Check to see if .barpi directory exists and // if not, create it. If it exists, cd to .barpi // will work, and skip directory creation. if (!homedir.cd(".barpi")) { homedir.mkdir(".barpi"); homedir.cd(".barpi"); QMessageBox::information(this, tr("Create Directory"), tr(".barpi dir created")); } QString filepath = homedir.path(); filepath.append("/"); filepath.append(filename); QFile conf(filepath); if (!conf.exists()) { QString msg(filepath); msg.append(" does not exist!\n Creating default config file."); QMessageBox::information(this, tr("Create Default Config"), msg); this->createdefaultconfig(filepath); } if (!conf.open(QIODevice::ReadOnly | QIODevice::Text)) { QString msg; msg.append("Cannot open "); msg.append(filename); QMessageBox::critical(this, tr("File Open Error"), msg, QMessageBox::Cancel); return; } const QChar comment('#'); const QChar delimiter('='); QTextStream in(&conf); while (!in.atEnd()) { QString line = in.readLine(); QStringList parts = line.split(QRegExp("\\s+")); int dindex = 0; for (int i = 0; i < parts.size(); i++) { if (parts[i][0] == comment) break; QStringList segments = parts[i].split(delimiter,QString::SkipEmptyParts); if (segments.size() == 2) { params->insert(segments[0],segments[1]); } if (parts[i] == delimiter) { dindex = i; } } if (dindex > 0 && parts.size() > 2) { params->insert(parts[dindex-1],parts[dindex+1]); } } }
/** * Gets the path to the configuration file. This is a virtual method so that * unit tests can override this to present a dummy configuration file. */ std::string WMConfig::get_config_path() const { std::string homedir(std::getenv("HOME")); homedir += "/.config/smallwm"; return homedir; }
/* return 0 on everything-is-fine, and non-zero otherwise */ int parseconfig(const char *filename, struct GlobalConfig *global) { FILE *file; char filebuffer[512]; bool usedarg = FALSE; int rc = 0; struct OperationConfig *operation = global->first; if(!filename || !*filename) { /* NULL or no file name attempts to load .curlrc from the homedir! */ #ifndef __AMIGA__ char *home = homedir(); /* portable homedir finder */ filename = CURLRC; /* sensible default */ if(home) { if(strlen(home) < (sizeof(filebuffer) - strlen(CURLRC))) { msnprintf(filebuffer, sizeof(filebuffer), "%s%s%s", home, DIR_CHAR, CURLRC); #ifdef WIN32 /* Check if the file exists - if not, try CURLRC in the same * directory as our executable */ file = fopen(filebuffer, FOPEN_READTEXT); if(file != NULL) { fclose(file); filename = filebuffer; } else { /* Get the filename of our executable. GetModuleFileName is * already declared via inclusions done in setup header file. * We assume that we are using the ASCII version here. */ int n = GetModuleFileNameA(0, filebuffer, sizeof(filebuffer)); if(n > 0 && n < (int)sizeof(filebuffer)) { /* We got a valid filename - get the directory part */ char *lastdirchar = strrchr(filebuffer, '\\'); if(lastdirchar) { size_t remaining; *lastdirchar = 0; /* If we have enough space, build the RC filename */ remaining = sizeof(filebuffer) - strlen(filebuffer); if(strlen(CURLRC) < remaining - 1) { msnprintf(lastdirchar, remaining, "%s%s", DIR_CHAR, CURLRC); /* Don't bother checking if it exists - we do that later */ filename = filebuffer; } } } } #else /* WIN32 */ filename = filebuffer; #endif /* WIN32 */ } Curl_safefree(home); /* we've used it, now free it */ } # else /* __AMIGA__ */ /* On AmigaOS all the config files are into env: */ filename = "ENV:" CURLRC; #endif } if(strcmp(filename, "-")) file = fopen(filename, FOPEN_READTEXT); else file = stdin; if(file) { char *line; char *aline; char *option; char *param; int lineno = 0; bool dashed_option; while(NULL != (aline = my_get_line(file))) { int res; bool alloced_param = FALSE; lineno++; line = aline; /* line with # in the first non-blank column is a comment! */ while(*line && ISSPACE(*line)) line++; switch(*line) { case '#': case '/': case '\r': case '\n': case '*': case '\0': Curl_safefree(aline); continue; } /* the option keywords starts here */ option = line; /* the option starts with a dash? */ dashed_option = option[0]=='-'?TRUE:FALSE; while(*line && !ISSPACE(*line) && !ISSEP(*line, dashed_option)) line++; /* ... and has ended here */ if(*line) *line++ = '\0'; /* zero terminate, we have a local copy of the data */ #ifdef DEBUG_CONFIG fprintf(stderr, "GOT: %s\n", option); #endif /* pass spaces and separator(s) */ while(*line && (ISSPACE(*line) || ISSEP(*line, dashed_option))) line++; /* the parameter starts here (unless quoted) */ if(*line == '\"') { /* quoted parameter, do the quote dance */ line++; param = malloc(strlen(line) + 1); /* parameter */ if(!param) { /* out of memory */ Curl_safefree(aline); rc = 1; break; } alloced_param = TRUE; (void)unslashquote(line, param); } else { param = line; /* parameter starts here */ while(*line && !ISSPACE(*line)) line++; if(*line) { *line = '\0'; /* zero terminate */ /* to detect mistakes better, see if there's data following */ line++; /* pass all spaces */ while(*line && ISSPACE(*line)) line++; switch(*line) { case '\0': case '\r': case '\n': case '#': /* comment */ break; default: warnf(operation->global, "%s:%d: warning: '%s' uses unquoted " "white space in the line that may cause side-effects!\n", filename, lineno, option); } } if(!*param) /* do this so getparameter can check for required parameters. Otherwise it always thinks there's a parameter. */ param = NULL; } #ifdef DEBUG_CONFIG fprintf(stderr, "PARAM: \"%s\"\n",(param ? param : "(null)")); #endif res = getparameter(option, param, &usedarg, global, operation); if(!res && param && *param && !usedarg) /* we passed in a parameter that wasn't used! */ res = PARAM_GOT_EXTRA_PARAMETER; if(res == PARAM_NEXT_OPERATION) { if(operation->url_list && operation->url_list->url) { /* Allocate the next config */ operation->next = malloc(sizeof(struct OperationConfig)); if(operation->next) { /* Initialise the newly created config */ config_init(operation->next); /* Copy the easy handle */ operation->next->easy = global->easy; /* Set the global config pointer */ operation->next->global = global; /* Update the last operation pointer */ global->last = operation->next; /* Move onto the new config */ operation->next->prev = operation; operation = operation->next; } else res = PARAM_NO_MEM; } } if(res != PARAM_OK && res != PARAM_NEXT_OPERATION) { /* the help request isn't really an error */ if(!strcmp(filename, "-")) { filename = "<stdin>"; } if(res != PARAM_HELP_REQUESTED && res != PARAM_MANUAL_REQUESTED && res != PARAM_VERSION_INFO_REQUESTED && res != PARAM_ENGINES_REQUESTED) { const char *reason = param2text(res); warnf(operation->global, "%s:%d: warning: '%s' %s\n", filename, lineno, option, reason); } } if(alloced_param) Curl_safefree(param); Curl_safefree(aline); } if(file != stdin) fclose(file); } else rc = 1; /* couldn't open the file */ return rc; }
String Get(Key key) { switch(key) { case FILE_EXE: { #if SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_MAC // Executable path can have relative references ("..") depending on // how the app was launched. uint32_t executable_length = 0; _NSGetExecutablePath(NULL, &executable_length); std::string executable_path(executable_length, '\0'); char* executable_path_c = (char*)executable_path.c_str(); int rv = _NSGetExecutablePath(executable_path_c, &executable_length); assert(rv == 0); if ((rv != 0) || (executable_path.empty())) return ""; // _NSGetExecutablePath will return whatever gets execed, so if // the command line is ./foo, you'll get the '.'. We use the // aggressive mode here to handle '..' parts that could interfere // with finding other paths that start from FILE_EXE. return canonicalize(executable_path, true); #elif SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_LINUX // boost::filesystem can't chase symlinks, do it manually const char* selfExe = "/proc/self/exe"; char bin_dir[MAX_PATH + 1]; int bin_dir_size = readlink(selfExe, bin_dir, MAX_PATH); if (bin_dir_size < 0 || bin_dir_size > MAX_PATH) { SILOG(core,fatal,"Couldn't read self symlink to setup dynamic loading paths."); return ""; } bin_dir[bin_dir_size] = 0; return String(bin_dir, bin_dir_size); #elif SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_WINDOWS char system_buffer[MAX_PATH]; system_buffer[0] = 0; GetModuleFileName(NULL, system_buffer, MAX_PATH); return String(system_buffer); #else return ""; #endif } break; case DIR_EXE: { String exe_file = Get(FILE_EXE); if (exe_file.empty()) return ""; boost::filesystem::path exe_file_path(exe_file); return exe_file_path.parent_path().string(); } break; case DIR_EXE_BUNDLE: { #if SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_WINDOWS || SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_LINUX // Windows and Linux don't have bundles return Get(DIR_EXE); #elif SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_MAC // On mac we need to detect that we're in a .app. We assume this // only applies if the binaries are in the standard location, // i.e. foo.app/Contents/MacOS/bar_binary String exe_dir = Get(DIR_EXE); boost::filesystem::path exe_dir_path(exe_dir); // Work our way back up verifying the path names, finally // returning if we actually find the .app. if (exe_dir_path.has_filename() && exe_dir_path.filename() == "MacOS") { exe_dir_path = exe_dir_path.parent_path(); if (exe_dir_path.has_filename() && exe_dir_path.filename() == "Contents") { exe_dir_path = exe_dir_path.parent_path(); if (exe_dir_path.has_filename()) { String app_dir_name = exe_dir_path.filename(); if (app_dir_name.substr(app_dir_name.size()-4, 4) == ".app") return exe_dir_path.parent_path().string(); } } } // Otherwise dump the original return exe_dir; #endif } break; case DIR_CURRENT: { #if SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_MAC || SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_LINUX char system_buffer[MAX_PATH] = ""; if (!getcwd(system_buffer, sizeof(system_buffer))) { return ""; } return String(system_buffer); #elif SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_WINDOWS char system_buffer[MAX_PATH]; system_buffer[0] = 0; DWORD len = ::GetCurrentDirectory(MAX_PATH, system_buffer); if (len == 0 || len > MAX_PATH) return ""; return String(system_buffer); #else return "."; #endif } break; case DIR_USER: { #if SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_LINUX || SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_MAC uid_t uid = getuid(); passwd* pw = getpwuid(uid); if (pw != NULL && pw->pw_dir != NULL) { boost::filesystem::path homedir(pw->pw_dir); if (boost::filesystem::exists(homedir) && boost::filesystem::is_directory(homedir)) return homedir.string(); } #elif SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_WINDOWS char system_buffer[MAX_PATH]; system_buffer[0] = 0; if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, system_buffer))) return ""; std::string appdata_str(system_buffer); boost::filesystem::path user_appdata(appdata_str); user_appdata /= "Sirikata"; if (!boost::filesystem::exists(user_appdata)) boost::filesystem::create_directory(user_appdata); if (boost::filesystem::exists(user_appdata) && boost::filesystem::is_directory(user_appdata)) return user_appdata.string(); #endif // Last resort (and default for unknown platform) is to try to use // the current directory return "."; } break; case DIR_USER_HIDDEN: { #if SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_WINDOWS // On windows there's no difference from the user-specific data directory since that's already hidden. return Get(DIR_USER); #else // We just compute this as an offset from the user directory boost::filesystem::path user_dir(Get(DIR_USER)); user_dir /= ".sirikata"; if (!boost::filesystem::exists(user_dir)) boost::filesystem::create_directory(user_dir); if (boost::filesystem::exists(user_dir) && boost::filesystem::is_directory(user_dir)) return user_dir.string(); #endif return "."; } case DIR_TEMP: { #if SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_LINUX || SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_MAC // On Mac and Linux we try to work under tmp using our own directory boost::filesystem::path tmp_path("/tmp"); if (boost::filesystem::exists(tmp_path) && boost::filesystem::is_directory(tmp_path)) { tmp_path /= "sirikata"; // If it doesn't exist, try creating it if (!boost::filesystem::exists(tmp_path)) boost::filesystem::create_directory(tmp_path); if (boost::filesystem::exists(tmp_path) && boost::filesystem::is_directory(tmp_path)) return tmp_path.string(); } #elif SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_WINDOWS // Windows doesn't seem to suggest a good location for this, so we // put it under the app data directory in its own temp directory boost::filesystem::path sirikata_temp_dir = boost::filesystem::path(Get(DIR_USER_HIDDEN)) / "temp"; if (!boost::filesystem::exists(sirikata_temp_dir)) boost::filesystem::create_directory(sirikata_temp_dir); if (boost::filesystem::exists(sirikata_temp_dir) && boost::filesystem::is_directory(sirikata_temp_dir)) return sirikata_temp_dir.string(); #endif // Last resort (and default for unknown platform) is to try to use // the current directory return "."; } break; case DIR_SYSTEM_CONFIG: { #if SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_LINUX || SIRIKATA_PLATFORM == SIRIKATA_PLATFORM_MAC // This is sirikata specific, so we're looking for more // than just /etc. if (boost::filesystem::exists("/etc") && boost::filesystem::is_directory("/etc") && boost::filesystem::exists("/etc/sirikata") && boost::filesystem::is_directory("/etc/sirikata")) return "/etc/sirikata"; return ""; #else // Other platforms don't have an equivalent? return ""; #endif } break; case RESOURCE: { SILOG(core,fatal,"Can't request RESOURCE without specifiying an in-tree path and path to resource."); assert(key != RESOURCE); return ""; } break; default: return ""; } }
nfsreadlinkres * nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) { static nfsreadlinkres res; uid_t userid = (uid_t) INVALIDID; gid_t groupid = hlfs_gid + 1; /* anything not hlfs_gid */ int retval = 0; char *path_val = NULL; char *username; static uid_t last_uid = (uid_t) INVALIDID; if (eq_fh(argp, &root)) { res.rlr_status = NFSERR_ISDIR; } else if (eq_fh(argp, &slink)) { if (getcreds(rqstp, &userid, &groupid, nfsxprt) < 0) return (nfsreadlinkres *) NULL; clocktime(&slinkfattr.na_atime); res.rlr_status = NFS_OK; if (groupid == hlfs_gid) { res.rlr_u.rlr_data_u = DOTSTRING; } else if (!(res.rlr_u.rlr_data_u = path_val = homedir(userid, groupid))) { /* * parent process (fork in homedir()) continues * processing, by getting a NULL returned as a * "special". Child returns result. */ return NULL; } } else { /* check if asked for user mailbox */ if (getcreds(rqstp, &userid, &groupid, nfsxprt) < 0) { return (nfsreadlinkres *) NULL; } if (groupid == hlfs_gid) { u_int xuserid; memcpy(&xuserid, argp->fh_data, sizeof(xuserid)); userid = xuserid; username = (char *) &argp->fh_data[sizeof(xuserid)]; if (!(res.rlr_u.rlr_data_u = mailbox(userid, username))) return (nfsreadlinkres *) NULL; } else { res.rlr_status = NFSERR_STALE; } } /* print info, but try to avoid repetitions */ if (userid != last_uid) { plog(XLOG_USER, "mailbox for uid=%ld, gid=%ld is %s", (long) userid, (long) groupid, (char *) res.rlr_u.rlr_data_u); last_uid = userid; } /* I don't think it will pass this if -D fork */ if (serverpid == getpid()) return &res; if (!svc_sendreply(nfsxprt, (XDRPROC_T_TYPE) xdr_readlinkres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(nfsxprt); /* * Child exists here. We need to determine which * exist status to return. The exit status * is gathered using wait() and determines * if we returned $HOME/.hlfsspool or $ALTDIR. The parent * needs this info so it can update the lookup table. */ if (path_val && alt_spooldir && STREQ(path_val, alt_spooldir)) retval = 1; /* could not get real home dir (or uid 0 user) */ else retval = 0; /* * If asked for -D nofork, then must return the value, * NOT exit, or else the main hlfsd server exits. * If -D fork (default), then we do want to exit from the process. * Bug: where is that status information being collected? */ if (amuDebug(D_FORK)) exit(retval); else return &res; }
/* ------------------------------------------------------------ MSGLOCAL */ int msglocal ( char *user , char *text ) { static char *eyecatch = "msglocal()"; int fd, i, j; char temp[BUFSIZ], *from; extern char *getenv(); /* first, look for the FIFO in /tmp */ (void) sprintf(temp,"/tmp/%s.msgpipe",user); fd = open(temp,O_WRONLY|O_NDELAY); /* if that didn't work, look in his home directory */ if (fd < 0 && errno == ENOENT) { /* a 'mknod' with 622 perms (writable) might work too */ (void) sprintf(temp,"%s/.msgpipe",homedir(user)); fd = open(temp,O_WRONLY|O_NDELAY); } /* if there's no listener ... */ if (fd < 0 && errno == ENXIO) { /* launch our special application to listen */ fd = open(temp,O_WRONLY|O_NDELAY); /* ... or NOT ... */ } if (fd < 0) return fd; /* who's the message from? */ from = getenv("LOGNAME"); if (*from == 0x00) from = getenv("USER"); /* (we should probably do something a little more secure!) */ j = BUFSIZ; j -= strlen(from); j -= 24; /* leave some room */ j -= strlen(from); j -= 24; /* this is temporary */ /* message text comes first */ i = 0; /* start at the beginning of the buffer */ while (*text != 0x00 && i < j) temp[i++] = *text++; temp[i++] = 0x00; /* environment style strings follow */ text = "MSGTYPE=U"; /* denote that this is a "U msg" */ while (*text != 0x00 && i < j) temp[i++] = *text++; temp[i++] = 0x00; /* who is this user message from? */ text = "MSGFROM="; /* start of that line */ while (*text != 0x00 && i < j) temp[i++] = *text++; while (*from != 0x00 && i < j) temp[i++] = *from++; temp[i++] = 0x00; /* who is this user message to? */ text = "MSGUSER="; /* start of that line */ while (*text != 0x00 && i < j) temp[i++] = *text++; while (*user != 0x00 && i < j) temp[i++] = *user++; temp[i++] = 0x00; /* and one more NULL terminates the environment */ temp[i++] = 0x00; /* send it */ (void) write(fd,temp,i); (void) close(fd); return 0; }
void FLAC_XMMS__init(void) { ConfigFile *cfg; FLAC__uint32 test = 1; is_big_endian_host_ = (*((FLAC__byte*)(&test)))? false : true; flac_cfg.title.tag_override = FALSE; if (flac_cfg.title.tag_format) g_free(flac_cfg.title.tag_format); flac_cfg.title.convert_char_set = FALSE; cfg = xmms_cfg_open_default_file(); /* title */ xmms_cfg_read_boolean(cfg, "flac", "title.tag_override", &flac_cfg.title.tag_override); if(!xmms_cfg_read_string(cfg, "flac", "title.tag_format", &flac_cfg.title.tag_format)) flac_cfg.title.tag_format = g_strdup("%p - %t"); xmms_cfg_read_boolean(cfg, "flac", "title.convert_char_set", &flac_cfg.title.convert_char_set); if(!xmms_cfg_read_string(cfg, "flac", "title.user_char_set", &flac_cfg.title.user_char_set)) flac_cfg.title.user_char_set = FLAC_plugin__charset_get_current(); /* replaygain */ xmms_cfg_read_boolean(cfg, "flac", "output.replaygain.enable", &flac_cfg.output.replaygain.enable); xmms_cfg_read_boolean(cfg, "flac", "output.replaygain.album_mode", &flac_cfg.output.replaygain.album_mode); if(!xmms_cfg_read_int(cfg, "flac", "output.replaygain.preamp", &flac_cfg.output.replaygain.preamp)) flac_cfg.output.replaygain.preamp = 0; xmms_cfg_read_boolean(cfg, "flac", "output.replaygain.hard_limit", &flac_cfg.output.replaygain.hard_limit); xmms_cfg_read_boolean(cfg, "flac", "output.resolution.normal.dither_24_to_16", &flac_cfg.output.resolution.normal.dither_24_to_16); xmms_cfg_read_boolean(cfg, "flac", "output.resolution.replaygain.dither", &flac_cfg.output.resolution.replaygain.dither); if(!xmms_cfg_read_int(cfg, "flac", "output.resolution.replaygain.noise_shaping", &flac_cfg.output.resolution.replaygain.noise_shaping)) flac_cfg.output.resolution.replaygain.noise_shaping = 1; if(!xmms_cfg_read_int(cfg, "flac", "output.resolution.replaygain.bps_out", &flac_cfg.output.resolution.replaygain.bps_out)) flac_cfg.output.resolution.replaygain.bps_out = 16; /* stream */ xmms_cfg_read_int(cfg, "flac", "stream.http_buffer_size", &flac_cfg.stream.http_buffer_size); xmms_cfg_read_int(cfg, "flac", "stream.http_prebuffer", &flac_cfg.stream.http_prebuffer); xmms_cfg_read_boolean(cfg, "flac", "stream.use_proxy", &flac_cfg.stream.use_proxy); if(flac_cfg.stream.proxy_host) g_free(flac_cfg.stream.proxy_host); if(!xmms_cfg_read_string(cfg, "flac", "stream.proxy_host", &flac_cfg.stream.proxy_host)) flac_cfg.stream.proxy_host = g_strdup(""); xmms_cfg_read_int(cfg, "flac", "stream.proxy_port", &flac_cfg.stream.proxy_port); xmms_cfg_read_boolean(cfg, "flac", "stream.proxy_use_auth", &flac_cfg.stream.proxy_use_auth); if(flac_cfg.stream.proxy_user) g_free(flac_cfg.stream.proxy_user); flac_cfg.stream.proxy_user = NULL; xmms_cfg_read_string(cfg, "flac", "stream.proxy_user", &flac_cfg.stream.proxy_user); if(flac_cfg.stream.proxy_pass) g_free(flac_cfg.stream.proxy_pass); flac_cfg.stream.proxy_pass = NULL; xmms_cfg_read_string(cfg, "flac", "stream.proxy_pass", &flac_cfg.stream.proxy_pass); xmms_cfg_read_boolean(cfg, "flac", "stream.save_http_stream", &flac_cfg.stream.save_http_stream); if (flac_cfg.stream.save_http_path) g_free (flac_cfg.stream.save_http_path); if (!xmms_cfg_read_string(cfg, "flac", "stream.save_http_path", &flac_cfg.stream.save_http_path) || ! *flac_cfg.stream.save_http_path) { if (flac_cfg.stream.save_http_path) g_free (flac_cfg.stream.save_http_path); flac_cfg.stream.save_http_path = homedir(); } xmms_cfg_read_boolean(cfg, "flac", "stream.cast_title_streaming", &flac_cfg.stream.cast_title_streaming); xmms_cfg_read_boolean(cfg, "flac", "stream.use_udp_channel", &flac_cfg.stream.use_udp_channel); decoder_ = FLAC__stream_decoder_new(); xmms_cfg_free(cfg); }
static gchar *thumb_loader_std_cache_path(ThumbLoaderStd *tl, gint local, GdkPixbuf *pixbuf, gint fail) { #if 0 gchar *result = NULL; gchar *cache_base; #endif const gchar *folder_size; #if 0 const gchar *uri; gchar *md5_text; guchar digest[16]; #endif gint w, h; if (!tl->source_path || !tl->thumb_uri) return NULL; if (pixbuf) { w = gdk_pixbuf_get_width(pixbuf); h = gdk_pixbuf_get_height(pixbuf); } else { w = tl->requested_width; h = tl->requested_height; } if (fail) { folder_size = THUMB_FOLDER_FAIL; } else if (w > THUMB_SIZE_NORMAL || h > THUMB_SIZE_NORMAL) { folder_size = THUMB_FOLDER_LARGE; } else { folder_size = THUMB_FOLDER_NORMAL; } return thumb_std_cache_path(tl->source_path, (local) ? tl->local_uri : tl->thumb_uri, local, folder_size); #if 0 if (local) { gchar *base; base = remove_level_from_path(tl->source_path); cache_base = g_strconcat(base, "/", THUMB_FOLDER, "/", folder_size, NULL); g_free(base); } else { cache_base = g_strconcat(homedir(), "/", THUMB_FOLDER, "/", folder_size, NULL); } uri = (local) ? tl->local_uri : tl->thumb_uri; md5_get_digest(uri, strlen(uri), digest); md5_text = md5_digest_to_text(digest); if (cache_base && md5_text) { result = g_strconcat(cache_base, "/", md5_text, THUMB_NAME_EXTENSION, NULL); } g_free(cache_base); g_free(md5_text); return result; #endif }