home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lynx2.8.1dev.10.tar.gz / lynx2.8.1dev.10.tar / lynx2-8 / src / LYrcFile.c < prev    next >
C/C++ Source or Header  |  1998-05-02  |  28KB  |  901 lines

  1. #include <HTUtils.h>
  2. #include <tcp.h>
  3. #include <HTFTP.h>
  4. #include <LYUtils.h>
  5. #include <LYrcFile.h>
  6. #include <LYStrings.h>
  7. #include <LYGlobalDefs.h>
  8. #include <LYCharSets.h>
  9. #include <LYBookmark.h>
  10.  
  11. #include <LYLeaks.h>
  12.  
  13. PUBLIC void read_rc NOPARAMS
  14. {
  15.     char line_buffer[256];
  16.     char rcfile[256];
  17.     FILE *fp;
  18.     char *cp, *cp2;
  19.     int number_sign;
  20.     char MBM_line[256];
  21.     int  MBM_counter;
  22.     char *MBM_cp2, *MBM_cp1;
  23.     int  MBM_i2;
  24.  
  25.     /*
  26.      *  Make an RC file name.
  27.      */
  28. #ifdef DJGPP
  29.     sprintf(rcfile, "%s/lynx.rc", Home_Dir());
  30. #else
  31. #ifdef VMS
  32.     sprintf(rcfile, "sys$login:.lynxrc");
  33. #else
  34.     sprintf(rcfile, "%s/.lynxrc", Home_Dir());
  35. #endif /* VMS */
  36. #endif /* DJGPP */
  37.  
  38.     /*
  39.      *  Open the RC file for reading.
  40.      */
  41.     if ((fp = fopen(rcfile, "r")) == NULL) {
  42.     return;
  43.     }
  44.  
  45.     /*
  46.      *  Process the entries.
  47.      */
  48.     while (fgets(line_buffer, 256, fp) != NULL) {
  49.     /*
  50.      *  Remove the /n from the end of the line.
  51.      */
  52.     if (line_buffer[0] && line_buffer[strlen(line_buffer)-1] == '\n')
  53.         line_buffer[strlen(line_buffer)-1] = '\0';
  54.  
  55.     /*
  56.      *  Remove any trailing white space.
  57.      */
  58.     LYTrimTrailing(line_buffer);
  59.  
  60.     /*
  61.      *  Skip any comment or blank lines.
  62.      */
  63.     if (line_buffer[0] == '\0' || line_buffer[0] == '#')
  64.         continue;
  65.  
  66.     /*
  67.      *  Find the line position of the number sign if there is one.
  68.      */
  69.     if ((cp = (char *)strchr(line_buffer, '#')) == NULL)
  70.         number_sign = 999;
  71.     else
  72.         number_sign = cp - line_buffer;
  73.  
  74.     /*
  75.      *  File editor.
  76.      */
  77.     if (!system_editor &&
  78.         (cp = LYstrstr(line_buffer, "file_editor")) != NULL &&
  79.         cp-line_buffer < number_sign) {
  80.  
  81.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  82.         cp = cp2 + 1;
  83.         cp = LYSkipBlanks(cp);
  84.         StrAllocCopy(editor, cp);
  85.  
  86.     /*
  87.      *  Default bookmark file.
  88.      */
  89.     } else if ((cp = LYstrstr(line_buffer, "bookmark_file")) != NULL &&
  90.             cp-line_buffer < number_sign) {
  91.  
  92.         if ((cp2 = (char *)strchr(cp,'=')) != NULL)
  93.         cp = cp2 + 1;
  94.         cp = LYSkipBlanks(cp);
  95.  
  96.         /*
  97.          *  Since this is the "Default Bookmark File", we save it
  98.          *  as a globals, and as the first MBM_A_subbookmark entry.
  99.          */
  100.         StrAllocCopy(bookmark_page, cp);
  101.         StrAllocCopy(BookmarkPage, cp);
  102.         StrAllocCopy(MBM_A_subbookmark[0], cp);
  103.         StrAllocCopy(MBM_A_subdescript[0], MULTIBOOKMARKS_DEFAULT);
  104.  
  105.     /*
  106.      *  Multiple (sub)bookmark support settings.
  107.      */
  108.     } else if ((cp = LYstrstr(line_buffer, "sub_bookmarks")) != NULL &&
  109.            cp-line_buffer < number_sign) {
  110.  
  111.        if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  112.         cp = (cp2 + 1);
  113.        cp = LYSkipBlanks(cp);
  114.        if (!strncasecomp(cp, "standard", 8)) {
  115.           LYMultiBookmarks = TRUE;
  116.           LYMBMAdvanced = FALSE;
  117.        } else if (!strncasecomp(cp, "advanced", 8)) {
  118.           LYMultiBookmarks = TRUE;
  119.           LYMBMAdvanced = TRUE;
  120.        } else {
  121.           LYMultiBookmarks = FALSE;
  122.        }
  123.  
  124.     /*
  125.      *  Multiple (sub)bookmark definitions and descriptions.
  126.      */
  127.     } else if ((cp = LYstrstr(line_buffer, "multi_bookmark")) != NULL &&
  128.            cp-line_buffer < number_sign) {
  129.  
  130.         /*
  131.          *  Found the root, now cycle through all the
  132.          *    possible spaces and match specific ones.
  133.          */
  134.         for (MBM_counter = 1;
  135.          MBM_counter <= MBM_V_MAXFILES; MBM_counter++) {
  136.         sprintf(MBM_line, "multi_bookmark%c", (MBM_counter + 'A'));
  137.  
  138.         if ((cp = LYstrstr(line_buffer, MBM_line)) != NULL &&
  139.             cp-line_buffer < number_sign) {
  140.             if ((MBM_cp1 = (char *)strchr(cp, '=')) == NULL) {
  141.             break;
  142.             } else {
  143.             if ((MBM_cp2 = (char *)strchr(cp, ',')) == NULL) {
  144.                 break;
  145.             } else {
  146.                 MBM_i2 = 0;
  147.                 /*
  148.                  *  skip over the '='.
  149.                  */
  150.                 MBM_cp1++;
  151.                 while (MBM_cp1 && MBM_cp1 != MBM_cp2) {
  152.                 /*
  153.                  *  Skip spaces.
  154.                  */
  155.                 if (isspace(*MBM_cp1)) {
  156.                     MBM_cp1++;
  157.                     continue;
  158.                 } else {
  159.                     MBM_line[MBM_i2++] = *MBM_cp1++;
  160.                 }
  161.                 }
  162.                 MBM_line[MBM_i2++] = '\0';
  163.  
  164.                 StrAllocCopy(MBM_A_subbookmark[MBM_counter],
  165.                      MBM_line);
  166.  
  167.                 /*
  168.                  *  Now get the description ',' and ->.
  169.                  */
  170.                 MBM_cp1 = (char *)strchr(cp, ',');
  171.  
  172.                 MBM_i2 = 0;
  173.                 /*
  174.                  *  Skip over the ','.
  175.                  */
  176.                 MBM_cp1++;
  177.                 /*
  178.                  *  Eat spaces in front of description.
  179.                  */
  180.                 MBM_cp1 = LYSkipBlanks(MBM_cp1);
  181.                 while (*MBM_cp1)
  182.                 MBM_line[MBM_i2++] = *MBM_cp1++;
  183.                 MBM_line[MBM_i2++] = '\0';
  184.  
  185.                 StrAllocCopy(MBM_A_subdescript[MBM_counter],
  186.                      MBM_line);
  187.  
  188.                 break;
  189.             }
  190.             }
  191.         }
  192.         }
  193.  
  194.     /*
  195.      * FTP/file sorting method.
  196.      */
  197.     } else if ((cp = LYstrstr(line_buffer,
  198.                   "file_sorting_method")) != NULL &&
  199.            cp-line_buffer < number_sign) {
  200.  
  201.        if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  202.         cp = cp2 + 1;
  203.        cp = LYSkipBlanks(cp);
  204.        if (!strncasecomp(cp, "BY_FILENAME", 11))
  205.         HTfileSortMethod = FILE_BY_NAME;
  206.        else if (!strncasecomp(cp, "BY_TYPE", 7))
  207.         HTfileSortMethod = FILE_BY_TYPE;
  208.        else if (!strncasecomp(cp, "BY_SIZE", 7))
  209.         HTfileSortMethod = FILE_BY_SIZE;
  210.        else if (!strncasecomp(cp, "BY_DATE", 7))
  211.         HTfileSortMethod = FILE_BY_DATE;
  212.  
  213.     /*
  214.      *  Personal mail address.
  215.      */
  216.     } else if ((cp = LYstrstr(line_buffer,
  217.                   "personal_mail_address")) != NULL &&
  218.            cp-line_buffer < number_sign) {
  219.  
  220.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  221.         cp = cp2 + 1;
  222.         cp = LYSkipBlanks(cp);
  223.         StrAllocCopy(personal_mail_address, cp);
  224.  
  225.     /*
  226.      *  Searching type.
  227.      */
  228.     } else if ((cp = LYstrstr(line_buffer,
  229.                   "case_sensitive_searching")) != NULL &&
  230.            cp-line_buffer < number_sign) {
  231.  
  232.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  233.         cp = cp2 + 1;
  234.         cp = LYSkipBlanks(cp);
  235.         if (!strncasecomp(cp, "on", 2))
  236.         case_sensitive = TRUE;
  237.         else
  238.         case_sensitive = FALSE;
  239.  
  240.     /*
  241.      *  Character set.
  242.      */
  243.     } else if ((cp = LYstrstr(line_buffer, "character_set")) != NULL &&
  244.            cp-line_buffer < number_sign) {
  245.  
  246.         int i = 0;
  247.  
  248.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  249.         cp = cp2 + 1;
  250.         cp = LYSkipBlanks(cp);
  251.         for (; LYchar_set_names[i]; i++) {
  252.         if (!strncmp(cp, LYchar_set_names[i], strlen(cp))) {
  253.             current_char_set=i;
  254.             HTMLSetRawModeDefault(i);
  255.             break;
  256.         }
  257.         }
  258.  
  259.     /*
  260.      *  Preferred language.
  261.      */
  262.     } else if ((cp = LYstrstr(line_buffer,
  263.                   "preferred_language")) != NULL &&
  264.            cp-line_buffer < number_sign) {
  265.  
  266.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  267.         cp = cp2 + 1;
  268.         cp = LYSkipBlanks(cp);
  269.         StrAllocCopy(language, cp);
  270.  
  271.     /*
  272.      *  Preferred charset.
  273.      */
  274.     } else if ((cp = LYstrstr(line_buffer,
  275.                   "preferred_charset")) != NULL &&
  276.            cp-line_buffer < number_sign) {
  277.  
  278.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  279.         cp = cp2 + 1;
  280.         cp = LYSkipBlanks(cp);
  281.         StrAllocCopy(pref_charset, cp);
  282.  
  283.     /*
  284.      * VI keys.
  285.      */
  286.     } else if ((cp = LYstrstr(line_buffer, "vi_keys")) != NULL &&
  287.            cp-line_buffer < number_sign) {
  288.  
  289.         if ((cp2 = (char * )strchr(cp, '=')) != NULL)
  290.         cp = cp2 + 1;
  291.         cp = LYSkipBlanks(cp);
  292.         if (!strncasecomp(cp, "on", 2))
  293.         vi_keys = TRUE;
  294.         else
  295.         vi_keys = FALSE;
  296.  
  297.     /*
  298.      *  EMACS keys.
  299.      */
  300.     } else if ((cp = LYstrstr(line_buffer, "emacs_keys")) != NULL &&
  301.            cp-line_buffer < number_sign) {
  302.  
  303.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  304.         cp = cp2 + 1;
  305.         cp = LYSkipBlanks(cp);
  306.         if (!strncasecomp(cp, "on", 2))
  307.         emacs_keys = TRUE;
  308.         else
  309.         emacs_keys=FALSE;
  310.  
  311.     /*
  312.      *  Show dot files.
  313.      */
  314.     } else if ((cp = LYstrstr(line_buffer, "show_dotfiles")) != NULL &&
  315.            cp-line_buffer < number_sign) {
  316.  
  317.         if ((cp2 = (char * )strchr(cp, '=')) != NULL)
  318.         cp = cp2 + 1;
  319.         cp = LYSkipBlanks(cp);
  320.         if (!strncasecomp(cp, "on", 2))
  321.         show_dotfiles = TRUE;
  322.         else
  323.         show_dotfiles = FALSE;
  324.  
  325.     /*
  326.      *  Show color.
  327.      */
  328.     } else if ((cp = LYstrstr(line_buffer, "show_color")) != NULL &&
  329.            cp-line_buffer < number_sign) {
  330.  
  331.         if ((cp2 = (char * )strchr(cp, '=')) != NULL)
  332.         cp = cp2 + 1;
  333.         cp = LYSkipBlanks(cp);
  334.         if (!strncasecomp(cp, "always", 6)) {
  335.         LYrcShowColor = SHOW_COLOR_ALWAYS;
  336. #if defined(USE_SLANG) || defined(COLOR_CURSES)
  337.         if (LYShowColor != SHOW_COLOR_NEVER)
  338.             LYShowColor = SHOW_COLOR_ALWAYS;
  339. #endif /* USE_SLANG || COLOR_CURSES */
  340.         } else if (!strncasecomp(cp, "never", 5)) {
  341.         LYrcShowColor = SHOW_COLOR_NEVER;
  342. #if defined(COLOR_CURSES)
  343.         if (LYShowColor == SHOW_COLOR_ON)
  344.             LYShowColor = SHOW_COLOR_OFF;
  345. #endif /* COLOR_CURSES */
  346.         }
  347.  
  348.     /*
  349.      *  Select popups.
  350.      */
  351.     } else if ((cp = LYstrstr(line_buffer, "select_popups")) != NULL &&
  352.            cp-line_buffer < number_sign) {
  353.  
  354.         if ((cp2 = (char * )strchr(cp, '=')) != NULL)
  355.         cp = cp2 + 1;
  356.         cp = LYSkipBlanks(cp);
  357.         if (!strncasecomp(cp, "off", 3))
  358.         LYSelectPopups = FALSE;
  359.         else
  360.         LYSelectPopups = TRUE;
  361.  
  362.     /*
  363.      *  Show cursor.
  364.      */
  365.     } else if ((cp = LYstrstr(line_buffer, "show_cursor")) != NULL &&
  366.            cp-line_buffer < number_sign) {
  367.  
  368.         if ((cp2 = (char * )strchr(cp, '=')) != NULL)
  369.         cp = cp2 + 1;
  370.         cp = LYSkipBlanks(cp);
  371.         if (!strncasecomp(cp, "off", 3))
  372.         LYShowCursor = FALSE;
  373.         else
  374.         LYShowCursor = TRUE;
  375.  
  376.     /*
  377.      *  Keypad mode.
  378.      */
  379.     } else if ((cp = LYstrstr(line_buffer, "keypad_mode")) != NULL &&
  380.            cp-line_buffer < number_sign) {
  381.  
  382.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  383.         cp = cp2 + 1;
  384.         cp = LYSkipBlanks(cp);
  385.         if (LYstrstr(cp, "LINKS_ARE_NUMBERED"))
  386.         keypad_mode = LINKS_ARE_NUMBERED;
  387.         else if (LYstrstr(cp, "LINKS_AND_FORM_FIELDS_ARE_NUMBERED"))
  388.         keypad_mode = LINKS_AND_FORM_FIELDS_ARE_NUMBERED;
  389.         else
  390.         keypad_mode = NUMBERS_AS_ARROWS;
  391.  
  392.     /*
  393.      *  Linedit mode.
  394.      */
  395.     } else if ((cp = LYstrstr(line_buffer, "lineedit_mode")) != NULL &&
  396.            cp-line_buffer < number_sign) {
  397.  
  398.         int i = 0;
  399.  
  400.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  401.         cp = cp2 + 1;
  402.         cp = LYSkipBlanks(cp);
  403.         for (; LYLineeditNames[i]; i++) {
  404.         if (!strncmp(cp, LYLineeditNames[i], strlen(cp))) {
  405.             current_lineedit = i;
  406.             break;
  407.         }
  408.         }
  409.  
  410. #ifdef DIRED_SUPPORT
  411.     /*
  412.      *  List directory style.
  413.      */
  414.     } else if ((cp = LYstrstr(line_buffer, "dir_list_style")) != NULL &&
  415.            cp-line_buffer < number_sign) {
  416.  
  417.         if ((cp2 = (char *)strchr(cp,'=')) != NULL)
  418.         cp = cp2 + 1;
  419.         cp = LYSkipBlanks(cp);
  420.         if (LYstrstr(cp, "FILES_FIRST") != NULL) {
  421.         dir_list_style = FILES_FIRST;
  422.         } else if (LYstrstr(cp,"DIRECTORIES_FIRST") != NULL) {
  423.         dir_list_style = 0;
  424.         } else {
  425.         dir_list_style = MIXED_STYLE;
  426.         }
  427. #endif /* DIRED_SUPPORT */
  428.  
  429.     /*
  430.      *  User mode.
  431.      */
  432.     } else if ((cp = LYstrstr(line_buffer, "user_mode")) != NULL &&
  433.            cp-line_buffer < number_sign) {
  434.  
  435.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  436.         cp = cp2 + 1;
  437.         cp = LYSkipBlanks(cp);
  438.         if (LYstrstr(cp, "ADVANCED") != NULL) {
  439.         user_mode = ADVANCED_MODE;
  440.         } else if (LYstrstr(cp,"INTERMEDIATE") != NULL) {
  441.         user_mode = INTERMEDIATE_MODE;
  442.         } else {
  443.         user_mode = NOVICE_MODE;
  444.         }
  445.  
  446. #ifdef ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS
  447.     /*
  448.      *  Local execution mode - all links.
  449.      */
  450.     } else if ((cp = LYstrstr(line_buffer,
  451.                   "run_all_execution_links")) != NULL &&
  452.            cp-line_buffer < number_sign) {
  453.  
  454.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  455.         cp = cp2 + 1;
  456.         cp = LYSkipBlanks(cp);
  457.         if (!strncasecomp(cp, "on", 2))
  458.         local_exec = TRUE;
  459.          else
  460.         local_exec = FALSE;
  461.  
  462.     /*
  463.      *  Local execution mode - only links in local files.
  464.      */
  465.     } else if ((cp = LYstrstr(line_buffer,
  466.             "run_execution_links_on_local_files")) != NULL &&
  467.            cp-line_buffer < number_sign) {
  468.  
  469.         if ((cp2 = (char *)strchr(cp, '=')) != NULL)
  470.         cp = cp2 + 1;
  471.         cp = LYSkipBlanks(cp);
  472.         if (!strncasecomp(cp, "on", 2))
  473.         local_exec_on_local_files = TRUE;
  474.         else
  475.         local_exec_on_local_files=FALSE;
  476. #endif /* ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS */
  477.  
  478.     } /* end of if */
  479.  
  480.     } /* end of while */
  481.  
  482.     fclose(fp);
  483. } /* big end */
  484.  
  485. PUBLIC int save_rc NOPARAMS
  486. {
  487.     char rcfile[256];
  488.     FILE *fp;
  489.     int i;
  490.     int MBM_c;
  491.  
  492.     /*
  493.      *  Make a name.
  494.      */
  495. #ifdef DJGPP
  496.     sprintf(rcfile, "%s/lynx.rc", Home_Dir());
  497. #else
  498. #ifdef VMS
  499.     sprintf(rcfile, "sys$login:.lynxrc");
  500. #else
  501.     sprintf(rcfile, "%s/.lynxrc", Home_Dir());
  502. #endif /* VMS */
  503. #endif /* DJGPP */
  504.  
  505.     /*
  506.      *  Open the file for write.
  507.      */
  508. #if defined(__DJGPP__) || defined(_WINDOWS)
  509.     _fmode = O_TEXT;
  510. #endif /* __DJGPP__  or _WINDOWS */
  511.     if ((fp = LYNewTxtFile(rcfile)) == NULL) {
  512.     return FALSE;
  513.     }
  514.  
  515.     /*
  516.      *  Header.
  517.      */
  518.     fprintf(fp, "# Lynx User Defaults File\n#\n\
  519. # This file contains options saved from the Lynx Options Screen (normally\n\
  520. # with the '>' key).  There is normally no need to edit this file manually,\n\
  521. # since the defaults here can be controlled from the Options Screen, and the\n\
  522. # next time options are saved from the Options Screen this file will be\n\
  523. # completely rewritten.  You have been warned...\n\
  524. # If you are looking for the general configuration file - it is normally\n\
  525. # called lynx.cfg, and it has different content and a different format.\n\
  526. # It is not this file.\n\n");
  527.  
  528.     /*
  529.      *  File editor
  530.      */
  531.     fprintf(fp, "\
  532. # file_editor specifies the editor to be invoked when editing local files\n\
  533. # or sending mail.  If no editor is specified, then file editing is disabled\n\
  534. # unless it is activated from the command line, and the built-in line editor\n\
  535. # will be used for sending mail.\n");
  536.     fprintf(fp, "file_editor=%s\n\n", (editor ? editor : ""));
  537.  
  538.     /*
  539.      *  Default bookmark file.
  540.      */
  541.     fprintf(fp, "\
  542. # bookmark_file specifies the name and location of the default bookmark\n\
  543. # file into which the user can paste links for easy access at a later\n\
  544. # date.\n");
  545.     fprintf(fp, "bookmark_file=%s\n\n", (bookmark_page ? bookmark_page : ""));
  546.  
  547.     /*
  548.      *  Multiple (sub)bookmark support settings.
  549.      */
  550.     fprintf(fp, "\
  551. # If sub_bookmarks is not turned \"off\", and multiple bookmarks have\n\
  552. # been defined (see below), then all bookmark operations will first\n\
  553. # prompt the user to select an active sub-bookmark file.  If the default\n\
  554. # Lynx bookmark_file is defined (see above), it will be used as the\n\
  555. # default selection.  When this option is set to \"advanced\", and the\n\
  556. # user mode is advanced, the 'v'iew bookmark command will invoke a\n\
  557. # statusline prompt instead of the menu seen in novice and intermediate\n\
  558. # user modes.  When this option is set to \"standard\", the menu will be\n\
  559. # presented regardless of user mode.\n");
  560.     fprintf(fp, "sub_bookmarks=%s\n\n", (LYMultiBookmarks ?
  561.                        (LYMBMAdvanced ?
  562.                            "advanced" : "standard")
  563.                               : "off"));
  564.  
  565.     /*
  566.      *  Multiple (sub)bookmark definitions and descriptions.
  567.      */
  568.     fprintf(fp, "\
  569. # The following allow you to define sub-bookmark files and descriptions.\n\
  570. # The format is multi_bookmark<capital_letter>=<filename>,<description>\n\
  571. # Up to 26 bookmark files (for the English capital letters) are allowed.\n\
  572. # We start with \"multi_bookmarkB\" since 'A' is the default (see above).\n");
  573.     for (MBM_c = 1; MBM_c <= MBM_V_MAXFILES; MBM_c++)
  574.        fprintf(fp, "multi_bookmark%c=%s%s%s\n",
  575.            (MBM_c + 'A'),
  576.            (MBM_A_subbookmark[MBM_c] ?
  577.             MBM_A_subbookmark[MBM_c] : ""),
  578.            (MBM_A_subbookmark[MBM_c] ?
  579.                      "," : ""),
  580.            (MBM_A_subdescript[MBM_c] ?
  581.             MBM_A_subdescript[MBM_c] : ""));
  582.     fprintf(fp, "\n");
  583.  
  584.     /*
  585.      *  FTP/file sorting method.
  586.      */
  587.     fprintf(fp, "\
  588. # The file_sorting_method specifies which value to sort on when viewing\n\
  589. # file lists such as FTP directories.  The options are:\n\
  590. #    BY_FILENAME -- sorts on the name of the file\n\
  591. #    BY_TYPE     -- sorts on the type of the file\n\
  592. #    BY_SIZE     -- sorts on the size of the file\n\
  593. #    BY_DATE     -- sorts on the date of the file\n");
  594.     fprintf(fp, "file_sorting_method=%s\n\n",
  595.         (HTfileSortMethod == FILE_BY_NAME ? "BY_FILENAME"
  596.                           :
  597.         (HTfileSortMethod == FILE_BY_SIZE ? "BY_SIZE"
  598.                           :
  599.         (HTfileSortMethod == FILE_BY_TYPE ? "BY_TYPE"
  600.                           : "BY_DATE"))));
  601.  
  602.     /*
  603.      *  Personal mail address.
  604.      */
  605.     fprintf(fp, "\
  606. # personal_mail_address specifies your personal mail address.  The\n\
  607. # address will be sent during HTTP file transfers for authorization and\n\
  608. # logging purposes, and for mailed comments.\n\
  609. # If you do not want this information given out, set the NO_FROM_HEADER\n\
  610. # to TRUE in lynx.cfg, or use the -nofrom command line switch.  You also\n\
  611. # could leave this field blank, but then you won't have it included in\n\
  612. # your mailed comments.\n");
  613.     fprintf(fp, "personal_mail_address=%s\n\n",
  614.         (personal_mail_address ? personal_mail_address : ""));
  615.  
  616.     /*
  617.      *  Searching type.
  618.      */
  619.     fprintf(fp, "\
  620. # If case_sensitive_searching is \"on\" then when the user invokes a search\n\
  621. # using the 's' or '/' keys, the search performed will be case sensitive\n\
  622. # instead of case INsensitive.  The default is usually \"off\".\n");
  623.     fprintf(fp, "case_sensitive_searching=%s\n\n",
  624.         (case_sensitive ? "on" : "off"));
  625.  
  626.     /*
  627.      *  Character set.
  628.      */
  629.     fprintf(fp, "\
  630. # The character_set definition controls the representation of 8 bit\n\
  631. # characters for your terminal.  If 8 bit characters do not show up\n\
  632. # correctly on your screen you may try changing to a different 8 bit\n\
  633. # set or using the 7 bit character approximations.\n\
  634. # Current valid characters sets are:\n");
  635.     for (i = 0; LYchar_set_names[i]; i++)
  636.     fprintf(fp, "#    %s\n", LYchar_set_names[i]);
  637.     fprintf(fp, "character_set=%s\n\n", LYchar_set_names[current_char_set]);
  638.  
  639.  
  640.     /*
  641.      *  Preferred language.
  642.      */
  643.     fprintf(fp, "\
  644. # preferred_language specifies the language in MIME notation (e.g., en,\n\
  645. # fr, may be a comma-separated list in decreasing preference)\n\
  646. # which Lynx will indicate you prefer in requests to http servers.\n\
  647. # If a file in that language is available, the server will send it.\n\
  648. # Otherwise, the server will send the file in it's default language.\n");
  649.     fprintf(fp, "preferred_language=%s\n\n", (language ? language : ""));
  650.  
  651.     /*
  652.      *  Preferred charset.
  653.      */
  654.     fprintf(fp, "\
  655. # preferred_charset specifies the character set in MIME notation (e.g.,\n\
  656. # ISO-8859-2, ISO-8859-5) which Lynx will indicate you prefer in requests\n\
  657. # to http servers using an Accept-Charset header.  The value should NOT\n\
  658. # include ISO-8859-1 or US-ASCII, since those values are always assumed\n\
  659. # by default.  May be a comma-separated list.\n\
  660. # If a file in that character set is available, the server will send it.\n\
  661. # If no Accept-Charset header is present, the default is that any\n\
  662. # character set is acceptable.  If an Accept-Charset header is present,\n\
  663. # and if the server cannot send a response which is acceptable\n\
  664. # according to the Accept-Charset header, then the server SHOULD send\n\
  665. # an error response, though the sending of an unacceptable response\n\
  666. # is also allowed.\n");
  667.     fprintf(fp, "preferred_charset=%s\n\n",
  668.         (pref_charset ? pref_charset : ""));
  669.  
  670.     /*
  671.      *  Show color.
  672.      */
  673.     if (LYChosenShowColor != SHOW_COLOR_UNKNOWN) {
  674.     fprintf(fp, "\
  675. # show_color specifies how to set the color mode at startup.  A value of\n\
  676. # \"never\" will force color mode off (treat the terminal as monochrome)\n\
  677. # at startup even if the terminal appears to be color capable.  A value of\n\
  678. # \"always\" will force color mode on even if the terminal appears to be\n\
  679. # monochrome, if this is supported by the library used to build lynx.\n\
  680. # A value of \"default\" will yield the behavior of assuming\n\
  681. # a monochrome terminal unless color capability is inferred at startup\n\
  682. # based on the terminal type, or the -color command line switch is used, or\n\
  683. # the COLORTERM environment variable is set. The default behavior always is\n\
  684. # used in anonymous accounts or if the \"option_save\" restriction is set.\n\
  685. # The effect of the saved value can be overridden via\n\
  686. # the -color and -nocolor command line switches.\n\
  687. # The mode set at startup can be changed via the \"show color\" option in\n\
  688. # the 'o'ptions menu.  If the option settings are saved, the \"on\" and\n\
  689. # \"off\" \"show color\" settings will be treated as \"default\".\n");
  690.      fprintf(fp, "show_color=%s\n\n",
  691.          ((LYChosenShowColor == SHOW_COLOR_NEVER  ? "never"  :
  692.            (LYChosenShowColor == SHOW_COLOR_ALWAYS ? "always" :
  693.                               "default"))));
  694.     }
  695.  
  696.     /*
  697.      *  VI keys.
  698.      */
  699.     fprintf(fp, "\
  700. # If vi_keys is set to \"on\", then the normal VI movement keys:\n\
  701. #   j = down    k = up\n\
  702. #   h = left    l = right\n\
  703. # will be enabled.  These keys are only lower case.\n\
  704. # Capital 'H', 'J' and 'K will still activate help, jump shortcuts,\n\
  705. # and the keymap display, respectively.\n");
  706.      fprintf(fp, "vi_keys=%s\n\n", (vi_keys ? "on" : "off"));
  707.  
  708.     /*
  709.      *  EMACS keys.
  710.      */
  711.     fprintf(fp, "\
  712. # If emacs_keys is to \"on\" then the normal EMACS movement keys:\n\
  713. #   ^N = down    ^P = up\n\
  714. #   ^B = left    ^F = right\n\
  715. # will be enabled.\n");
  716.     fprintf(fp, "emacs_keys=%s\n\n", (emacs_keys ? "on" : "off"));
  717.  
  718.     /*
  719.      *  Show dot files.
  720.      */
  721.     fprintf(fp, "\
  722. # show_dotfiles specifies that the directory listing should include\n\
  723. # \"hidden\" (dot) files/directories.  If set \"on\", this will be\n\
  724. # honored only if enabled via userdefs.h and/or lynx.cfg, and not\n\
  725. # restricted via a command line switch.  If display of hidden files\n\
  726. # is disabled, creation of such files via Lynx also is disabled.\n");
  727.     fprintf(fp, "show_dotfiles=%s\n\n", (show_dotfiles ? "on" : "off"));
  728.  
  729.     /*
  730.      *  Select popups.
  731.      */
  732.     fprintf(fp, "\
  733. # select_popups specifies whether the OPTIONs in a SELECT block which\n\
  734. # lacks a MULTIPLE attribute are presented as a vertical list of radio\n\
  735. # buttons or via a popup menu.  Note that if the MULTIPLE attribute is\n\
  736. # present in the SELECT start tag, Lynx always will create a vertical list\n\
  737. # of checkboxes for the OPTIONs.  A value of \"on\" will set popup menus\n\
  738. # as the default while a value of \"off\" will set use of radio boxes.\n\
  739. # The default can be overridden via the -popup command line toggle.\n");
  740.     fprintf(fp, "select_popups=%s\n\n", (LYSelectPopups ? "on" : "off"));
  741.  
  742.     /*
  743.      *  Show cursor.
  744.      */
  745.     fprintf(fp, "\
  746. # show_cursor specifies whether to 'hide' the cursor to the right (and\n\
  747. # bottom, if possible) of the screen, or to place it to the left of the\n\
  748. # current link in documents, or current option in select popup windows.\n\
  749. # Positioning the cursor to the left of the current link or option is\n\
  750. # helpful for speech or braille interfaces, and when the terminal is\n\
  751. # one which does not distingish the current link based on highlighting\n\
  752. # or color.  A value of \"on\" will set positioning to the left as the\n\
  753. # default while a value of \"off\" will set 'hiding' of the cursor.\n\
  754. # The default can be overridden via the -show_cursor command line toggle.\n");
  755.     fprintf(fp, "show_cursor=%s\n\n", (LYShowCursor ? "on" : "off"));
  756.  
  757.     /*
  758.      *  Keypad mode.
  759.      */
  760.     fprintf(fp, "\
  761. # If keypad_mode is set to \"NUMBERS_AS_ARROWS\", then the numbers on\n\
  762. # your keypad when the numlock is on will act as arrow keys:\n\
  763. #             8 = Up Arrow\n\
  764. #   4 = Left Arrow    6 = Right Arrow\n\
  765. #             2 = Down Arrow\n\
  766. # and the corresponding keyboard numbers will act as arrow keys,\n\
  767. # regardless of whether numlock is on.\n");
  768.     fprintf(fp, "\
  769. # If keypad_mode is set to \"LINKS_ARE_NUMBERED\", then numbers will\n\
  770. # appear next to each link and numbers are used to select links.\n");
  771.     fprintf(fp, "\
  772. # If keypad_mode is set to \"LINKS_AND_FORM_FIELDS_ARE_NUMBERED\", then\n\
  773. # numbers will appear next to each link and visible form input field.\n\
  774. # Numbers are used to select links, or to move the \"current link\" to a\n\
  775. # form input field or button.  In addition, options in popup menus are\n\
  776. # indexed so that the user may type an option number to select an option in\n\
  777. # a popup menu, even if the option isn't visible on the screen.  Reference\n\
  778. # lists and output from the list command also enumerate form inputs.\n");
  779.     fprintf(fp, "\
  780. # NOTE: Some fixed format documents may look disfigured when\n\
  781. # \"LINKS_ARE_NUMBERED\" or \"LINKS_AND_FORM_FIELDS_ARE_NUMBERED\" are\n\
  782. # enabled.\n");
  783.     fprintf(fp, "keypad_mode=%s\n\n",
  784.         ((keypad_mode == NUMBERS_AS_ARROWS) ?  "NUMBERS_AS_ARROWS" :
  785.            ((keypad_mode == LINKS_ARE_NUMBERED) ? "LINKS_ARE_NUMBERED" :
  786.                       "LINKS_AND_FORM_FIELDS_ARE_NUMBERED")));
  787.  
  788.     /*
  789.      *  Lineedit mode.
  790.      */
  791.     fprintf(fp, "\
  792. # linedit_mode specifies the key binding used for inputting strings in\n\
  793. # prompts and forms.  If lineedit_mode is set to \"Default Binding\" then\n\
  794. # the following control characters are used for moving and deleting:\n\
  795. #\n\
  796. #              Prev  Next       Enter = Accept input\n\
  797. #    Move char: <-    ->        ^G    = Cancel input\n\
  798. #    Move word: ^P    ^N        ^U    = Erase line\n\
  799. #  Delete char: ^H    ^R        ^A    = Beginning of line\n\
  800. #  Delete word: ^B    ^F        ^E    = End of line\n\
  801. #\n\
  802. # Current lineedit modes are:\n");
  803.     {
  804.     char **bindings = LYLineeditNames;
  805.     while (*bindings) {
  806.         fprintf(fp, "#    %s\n", *bindings);
  807.         bindings++;
  808.     }
  809.     }
  810.     fprintf(fp, "lineedit_mode=%s\n\n", LYLineeditNames[current_lineedit]);
  811.  
  812. #ifdef DIRED_SUPPORT
  813.     /*
  814.      *  List directory style.
  815.      */
  816.     fprintf(fp, "\
  817. # dir_list_styles specifies the directory list style under DIRED_SUPPORT\n\
  818. # (if implemented).  The default is \"MIXED_STYLE\", which sorts both\n\
  819. # files and directories together.  \"FILES_FIRST\" lists files first and\n\
  820. # \"DIRECTORIES_FIRST\" lists directories first.\n");
  821.     fprintf(fp, "dir_list_style=%s\n\n",
  822.         (dir_list_style==FILES_FIRST ? "FILES_FIRST"
  823.                          :
  824.         (dir_list_style==MIXED_STYLE ? "MIXED_STYLE"
  825.                          : "DIRECTORIES_FIRST")));
  826. #endif /* DIRED_SUPPORT */
  827.  
  828.     /*
  829.      *  User mode.
  830.      */
  831.     fprintf(fp, "\
  832. # user_mode specifies the users level of knowledge with Lynx.  The\n\
  833. # default is \"NOVICE\" which displays two extra lines of help at the\n\
  834. # bottom of the screen to aid the user in learning the basic Lynx\n\
  835. # commands.  Set user_mode to \"INTERMEDIATE\" to turn off the extra info.\n\
  836. # Use \"ADVANCED\" to see the URL of the currently selected link at the\n\
  837. # bottom of the screen.\n");
  838.     fprintf(fp, "user_mode=%s\n\n",
  839.         (user_mode == NOVICE_MODE ? "NOVICE" :
  840.              (user_mode == ADVANCED_MODE ?
  841.                       "ADVANCED" : "INTERMEDIATE")));
  842.  
  843. #if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
  844.     /*
  845.      *  Local execution mode - all links.
  846.      */
  847.     fprintf(fp, "\
  848. # If run_all_execution_links is set \"on\" then all local exection links\n\
  849. # will be executed when they are selected.\n\
  850. #\n\
  851. # WARNING - This is potentially VERY dangerous.  Since you may view\n\
  852. #           information that is written by unknown and untrusted sources\n\
  853. #           there exists the possibility that Trojan horse links could be\n\
  854. #           written.  Trojan horse links could be written to erase files\n\
  855. #           or compromise security.  This should only be set to \"on\" if\n\
  856. #           you are viewing trusted source information.\n");
  857.     fprintf(fp, "run_all_execution_links=%s\n\n",
  858.         (local_exec ? "on" : "off"));
  859.  
  860.     /*
  861.      *  Local execution mode - only links in local files.
  862.      */
  863.     fprintf(fp, "\
  864. # If run_execution_links_on_local_files is set \"on\" then all local\n\
  865. # execution links that are found in LOCAL files will be executed when they\n\
  866. # are selected.  This is different from run_all_execution_links in that\n\
  867. # only files that reside on the local system will have execution link\n\
  868. # permissions.\n\
  869. #\n\
  870. # WARNING - This is potentially dangerous.  Since you may view\n\
  871. #           information that is written by unknown and untrusted sources\n\
  872. #           there exists the possibility that Trojan horse links could be\n\
  873. #           written.  Trojan horse links could be written to erase files\n\
  874. #           or compromise security.  This should only be set to \"on\" if\n\
  875. #           you are viewing trusted source information.\n");
  876.     fprintf(fp, "run_execution_links_on_local_files=%s\n\n",
  877.         (local_exec_on_local_files ? "on" : "off"));
  878. #endif /* defined(EXEC_LINKS) || defined(EXEC_SCRIPTS) */
  879.  
  880.     /*
  881.      *  Close the RC file.
  882.      */
  883.     fclose(fp);
  884. #if defined(__DJGPP__) || defined(_WINDOWS)
  885.     _fmode = O_BINARY;
  886. #endif /* __DJGPP__ or _WINDOWS */
  887.  
  888. #ifdef VMS
  889.     /*
  890.      *  Get rid of any copies of the .lynxrc file that VMS creates.
  891.      */
  892.     while (remove("sys$login:.lynxrc;-1") == 0) ;
  893.     /*
  894.      *  Reset version number.
  895.      */
  896.     rename("sys$login:.lynxrc", "sys$login:.lynxrc;1");
  897. #endif /* VMS */
  898.  
  899.    return TRUE;
  900. }
  901.