static void cb_quit(GtkWidget *widget, gpointer data) { const char *sel; char dir[MAX_PREF_LEN+2]; int i; jp_logf(JP_LOG_DEBUG, "Quit\n"); sel = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filew)); strncpy(dir, sel, MAX_PREF_LEN); dir[MAX_PREF_LEN]='\0'; i=strlen(dir)-1; if (i<0) i=0; if (dir[i]!='/') { for (i=strlen(dir); i>=0; i--) { if (dir[i]=='/') { dir[i+1]='\0'; break; } } } set_pref(PREF_MEMO_IMPORT_PATH, 0, dir, TRUE); filew = NULL; gtk_widget_destroy(data); }
int install_user_gui(GtkWidget *main_window) { int r; char user[MAX_PREF_LEN]; unsigned long user_id; const char *svalue; long old_user_id; char *old_user; r = dialog_install_user(GTK_WINDOW(main_window), user, MAX_PREF_LEN, &user_id); if (r == DIALOG_SAID_1) { /* Temporarily set the user and user ID */ get_pref(PREF_USER, NULL, &svalue); get_pref(PREF_USER_ID, &old_user_id, NULL); if (svalue) { old_user = strdup(svalue); } else { old_user = strdup(""); } set_pref(PREF_USER, 0, user, FALSE); set_pref(PREF_USER_ID, user_id, NULL, TRUE); jp_logf(JP_LOG_DEBUG, "user is %s\n", user); jp_logf(JP_LOG_DEBUG, "user id is %ld\n", user_id); r = setup_sync(SYNC_NO_PLUGINS | SYNC_INSTALL_USER); jp_logf(JP_LOG_DEBUG, "old user is %s\n", old_user); jp_logf(JP_LOG_DEBUG, "old user id is %ld\n", old_user_id); set_pref(PREF_USER, 0, old_user, FALSE); set_pref(PREF_USER_ID, old_user_id, NULL, TRUE); free(old_user); return r; } return -1; }
int main(int argc, char* argv[]) { #if 0 void debug_oldstructs(); debug_oldstructs(); #endif try{ init_boe(argc, argv); if(!get_bool_pref("GameRunBefore")) cChoiceDlog("welcome").show(); else if(get_bool_pref("GiveIntroHint", true)) tip_of_day(); set_pref("GameRunBefore", true); finished_init = true; if(ae_loading) { finish_load_party(); post_load(); } menu_activate(); restore_cursor(); while(!All_Done) Handle_One_Event(); close_program(); return 0; } catch(std::exception& x) { showFatalError(x.what()); throw; } catch(std::string& x) { showFatalError(x); throw; } catch(...) { showFatalError("An unknown error occurred!"); throw; } }
/* Save working directory for future installs */ static void cb_quit(GtkWidget *widget, gpointer data) { const char *sel; char dir[MAX_PREF_LEN+2]; struct stat statb; int i; jp_logf(JP_LOG_DEBUG, "Quit\n"); sel = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data)); g_strlcpy(dir, sel, MAX_PREF_LEN); if (stat(sel, &statb)) { jp_logf(JP_LOG_WARN, "File selected was not stat-able\n"); } if (S_ISDIR(statb.st_mode)) { /* For directory, add '/' indicator to path */ i = strlen(dir); dir[i]='/', dir[i+1]='\0'; } else { /* Otherwise, strip off filename to find actual directory */ for (i=strlen(dir); i>=0; i--) { if (dir[i]=='/') { dir[i+1]='\0'; break; } } } set_pref(PREF_INSTALL_PATH, 0, dir, TRUE); filew = NULL; gtk_widget_destroy(data); }
/**************************************************************************** * name: doit (PRIVATE) * purpose: Given a URL, go fetch information. * inputs: * - char *url: The URL to fetch. * - char **texthead: Return pointer for the head of the allocated * text block (which may be different than the * return text intended for display). * returns: * The text intended for display (char *). ****************************************************************************/ static char *doit (char *url, char **texthead) { char *msg; int rv; extern char *use_this_url_instead; mo_window *win=current_win; /* Hmmmmmmm... */ if (HTMainText) { free (HTMainText); HTMainText = NULL; } /* Is it April? */ if (IconPix!=IconPixSmall) { /* We aren't small... */ if (strstr(url,"~mag/")) { int tmp=21; tmp_pix=IconPix; IconPix = IconPixTom; logo_count = 0; set_pref(ePIX_COUNT, (void *)&tmp); XmxApplyPixmapToLabelWidget(win->logo, IconPix[0]); } // SAM EASTER } XmxApplyPixmapToLabelWidget(win->logo, IconPix[0]); is_uncompressed=0; rv = HTLoadAbsolute (url); if (rv == 1) { char *txt = hack_htmlsrc (); if (HTMainText) *texthead = HTMainText->htmlSrcHead; else *texthead = NULL; return txt; } else if (rv == -1) { interrupted = 1; *texthead = NULL; return NULL; } /* ** Just because we errored out, doesn't mean there isn't markup to ** look at. For example, an FTP site that doesn't let a user in because ** the maximum number of users has been reached often has a message ** telling about other mirror sites. The failed FTP connection returns ** a message that is taken care of below. */ if (HTMainText) { char *txt = hack_htmlsrc(); *texthead = HTMainText->htmlSrcHead; if (cci_get){ if (txt) return txt; else /* take care of failed local access */ txt = strdup("<H1>ERROR</H1>"); } return txt; } /* Return proper error message if we experienced redirection. */ if (use_this_url_instead) url = use_this_url_instead; msg = (char *)malloc ((strlen (url) + 200) * sizeof (char)); sprintf (msg, "<H1>ERROR</H1> Requested document (URL %s) could not be accessed.<p>The information server either is not accessible or is refusing to serve the document to you.<p>", url); *texthead = msg; securityType=HTAA_UNKNOWN; return msg; }