home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / top2src.zip / PROFILE.C < prev    next >
C/C++ Source or Header  |  2000-07-13  |  31KB  |  725 lines

  1. /******************************************************************************
  2. PROFILE.C    User profile editor.
  3.  
  4.     Copyright 1993 - 2000 Paul J. Sidorsky
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License, version 2, as
  8.     published by the Free Software Foundation.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19. This module implements the user profile editor.  Most of its size is due to the
  20. various menus, and the displays and key handling associated with them.
  21. ******************************************************************************/
  22.  
  23. #include "top.h"
  24.  
  25. /* Macro to quickly get the language item name of the different action
  26.    types. */
  27. #define typstring(xxxx) xxxx == 0 ? "Normal" : "TalkType"
  28.  
  29. /* profile_editor() - User profile editor.
  30.    Parameters:  None.
  31.    Returns:  Nothing.
  32. */
  33. void profile_editor(void)
  34. {
  35. /* Keypress holder, counter, personal action change flag, e/xmessage change
  36.    flag, preferences change flag, new password entered okay flag. */
  37. XINT key, d, pac = 0, msgchg = 0, prefchg = 0, pwok;
  38. /* Temporary input buffer. */
  39. char tmp[256]; // Dynam with MAXSTRLEN!
  40. /* Password entry buffer, password confirmation buffer, menu option buffer,
  41.    number of menu options. */
  42. char ptmp1[20], ptmp2[20], optstr[50], opcount;
  43.  
  44. top_output(OUT_SCREEN, getlang("ProfEditPrefix"));
  45.  
  46. /* The keys used in the editor are taken from language items.  The sysop
  47.    may change the keys.  Each key has a specific character number inside
  48.    its particular language item. */
  49.  
  50. /* Main menu loop. */
  51. do
  52.     {
  53.     opcount = 0;
  54.     top_output(OUT_SCREEN, getlang("ProfMainPrefix"));
  55.     if (cfg.allowactions)
  56.         top_output(OUT_SCREEN, getlang("ProfMainPersAct"));
  57. /*    top_output(OUT_SCREEN, getlang("ProfMainDesc"));*/
  58.     if (cfg.allowsexchange &&
  59.         user.security >= cfg.sexchangesec)
  60.         top_output(OUT_SCREEN, getlang("ProfMainGender"));
  61.     if (cfg.allowhandlechange &&
  62.         user.security >= cfg.handlechgsec)
  63.         top_output(OUT_SCREEN, getlang("ProfMainHandle"));
  64.     if (cfg.allowexmessages &&
  65.         user.security >= cfg.exmsgchangesec)
  66.         top_output(OUT_SCREEN, getlang("ProfMainEXMsg"));
  67.     top_output(OUT_SCREEN, getlang("ProfMainPref"));
  68.     top_output(OUT_SCREEN, getlang("ProfMainPW"));
  69.     top_output(OUT_SCREEN, getlang("ProfMainQuit"));
  70.  
  71.     top_output(OUT_SCREEN, getlang("ProfMainPrompt"));
  72.  
  73.     strcpy(outbuf, top_output(OUT_STRING, getlang("ProfMainKeys")));
  74.     memset(optstr, 0, 50);
  75.  
  76.     /* Enable the option keys that are always available. */
  77.     optstr[opcount++] = outbuf[1];
  78.     optstr[opcount++] = outbuf[5];
  79.     optstr[opcount++] = outbuf[6];
  80.     optstr[opcount++] = outbuf[7];
  81.  
  82.     /* Add other options based on how the sysop has configured TOP. */
  83.     if (cfg.allowactions)
  84.         optstr[opcount++] = outbuf[0];
  85.     if (cfg.allowsexchange &&
  86.         user.security >= cfg.sexchangesec)
  87.         optstr[opcount++] = outbuf[2];
  88.     if (cfg.allowhandlechange &&
  89.         user.security >= cfg.handlechgsec)
  90.         optstr[opcount++] = outbuf[3];
  91.     if (cfg.allowexmessages &&
  92.         user.security >= cfg.exmsgchangesec)
  93.         optstr[opcount++] = outbuf[4];
  94.  
  95.     key = od_get_answer(optstr);
  96.     sprintf(outbuf, "%c", key);
  97.     top_output(OUT_SCREEN, getlang("ProfMainShowKey"), outbuf);
  98.  
  99.     pac = 0; msgchg = 0; prefchg = 0;
  100.     /* Personal action editor. */
  101.     if (key == getlangchar("ProfMainKeys", 0))
  102.         {
  103.         /* Personal action editor loop. */
  104.         do
  105.             {
  106.             top_output(OUT_SCREEN, getlang("ProfPActHeader"));
  107.             /* Display the four personal actions. */
  108.             for (d = 0; d < 4; d++)
  109.                 {
  110.                 itoa(d + 1, outnum[0], 10);
  111.                 top_output(OUT_SCREEN, getlang("ProfPActNumber"),
  112.                            outnum[0]);
  113.                 top_output(OUT_SCREEN, getlang("ProfPActVerbType"),
  114.                            user.persact[d].verb,
  115.                            getlang(typstring(user.persact[d].type)));
  116.                 top_output(OUT_SCREEN, getlang("ProfPActResponse"),
  117.                           user.persact[d].response);
  118.                 top_output(OUT_SCREEN, getlang("ProfPActSingular"),
  119.                           user.persact[d].singular);
  120.                 top_output(OUT_SCREEN, getlang("ProfPActPlural"),
  121.                           user.persact[d].plural);
  122.                 }
  123.             top_output(OUT_SCREEN, getlang("ProfPActPrompt"));
  124.             key = od_get_answer(getlang("ProfPActKeys"));
  125.             /* Clear action. */
  126.             if (key == getlangchar("ProfPActKeys", 0))
  127.                 {
  128.                 top_output(OUT_SCREEN, getlang("ProfClearAction"));
  129.                 top_output(OUT_SCREEN, getlang("ProfClActNumPrompt"));
  130.                 key = od_get_answer("1234");
  131.                 d = key - '1';
  132.                 itoa(d + 1, outnum[0], 10);
  133.                 top_output(OUT_SCREEN, getlang("ProfClActShowNum"),
  134.                            outnum[0]);
  135.                 top_output(OUT_SCREEN, getlang("ProfClActOKPrompt"),
  136.                            outnum[0]);
  137.                 /* Confirm, defaulting to no. */
  138.                 key = od_get_answer(top_output(OUT_STRING,
  139.                                     getlang("YesNoKeys")));
  140.                 if (key == getlangchar("YesNoKeys", 0))
  141.                     {
  142.                     top_output(OUT_SCREEN, getlang("Yes"));
  143.                     memset(&user.persact[d], 0,
  144.                            sizeof(struct pers_act_typ));
  145.                     save_user_data(user_rec_num, &user);
  146.                     actptrs[0][d]->data.responselen = 0;
  147.                     actptrs[0][d]->data.singularlen = 0;
  148.                     actptrs[0][d]->data.plurallen = 0;
  149.                     // Errchecking bigtime!
  150.                     actptrs[0][d]->ptrs.responsetext =
  151.                         realloc(actptrs[0][d]->ptrs.responsetext,
  152.                                 1);
  153.                     actptrs[0][d]->ptrs.singulartext =
  154.                         realloc(actptrs[0][d]->ptrs.singulartext,
  155.                                 1);
  156.                     actptrs[0][d]->ptrs.pluraltext =
  157.                         realloc(actptrs[0][d]->ptrs.pluraltext,
  158.                                 1);
  159.                     actptrs[0][d]->ptrs.responsetext[0] = '\0';
  160.                     actptrs[0][d]->ptrs.singulartext[0] = '\0';
  161.                     actptrs[0][d]->ptrs.pluraltext[0] = '\0';
  162.                     actptrs[0][d]->data.verb[0] = '\0';
  163.                     actptrs[0][d]->data.type = 0;
  164.                     pac = 1;
  165.                     top_output(OUT_SCREEN, getlang("ProfClActCleared"),
  166.                                outnum[0]);
  167.                     }
  168.                 else
  169.                     {
  170.                     top_output(OUT_SCREEN, getlang("No"));
  171.                     }
  172.                 key = '\0';
  173.                 }
  174.             /* Edit action. */
  175.             if (key == getlangchar("ProfPActKeys", 1))
  176.                 {
  177.                 top_output(OUT_SCREEN, getlang("ProfEditAction"));
  178.                 top_output(OUT_SCREEN, getlang("ProfEdActNumPrompt"));
  179.                 key = od_get_answer("1234");
  180.                 d = key - '1';
  181.                 sprintf(outbuf, "%c", key);
  182.                 top_output(OUT_SCREEN, getlang("ProfEdActShowNum"),
  183.                            outbuf);
  184.                 /* Main action editor loop. */
  185.                 do
  186.                     {
  187.                     itoa(d + 1, outnum[0], 10);
  188.                     top_output(OUT_SCREEN, getlang("ProfEdActHeader"),
  189.                                outnum[0]);
  190.  
  191.                     top_output(OUT_SCREEN, getlang("ProfEdActCurSet"));
  192.  
  193.                     top_output(OUT_SCREEN, getlang("ProfPActVerbType"),
  194.                                user.persact[d].verb,
  195.                                getlang(typstring(user.persact[d].type)));
  196.                     top_output(OUT_SCREEN, getlang("ProfPActResponse"),
  197.                               user.persact[d].response);
  198.                     top_output(OUT_SCREEN, getlang("ProfPActSingular"),
  199.                               user.persact[d].singular);
  200.                     top_output(OUT_SCREEN, getlang("ProfPActPlural"),
  201.                               user.persact[d].plural);
  202.  
  203.                     top_output(OUT_SCREEN, getlang("ProfEdActPrefix"));
  204.  
  205.                     top_output(OUT_SCREEN, getlang("ProfEdActType"));
  206.                     top_output(OUT_SCREEN, getlang("ProfEdActVerb"));
  207.                     top_output(OUT_SCREEN, getlang("ProfEdActResponse"));
  208.                     top_output(OUT_SCREEN, getlang("ProfEdActSingular"));
  209.                     top_output(OUT_SCREEN, getlang("ProfEdActPlural"));
  210.  
  211.                     top_output(OUT_SCREEN, getlang("ProfEdActHelp"));
  212.                     top_output(OUT_SCREEN, getlang("ProfEdActQuit"));
  213.  
  214.                     top_output(OUT_SCREEN, getlang("ProfEdActPrompt"));
  215.  
  216.                     key = od_get_answer(getlang("ProfEdActKeys"));
  217.                     sprintf(outbuf, "%c", key);
  218.                     top_output(OUT_SCREEN, getlang("ProfEdActShowKey"),
  219.                                outbuf);
  220.  
  221.                     /* Action type. */
  222.                     if (key == getlangchar("ProfEdActKeys", 0))
  223.                         {
  224.                         top_output(OUT_SCREEN,
  225.                                    getlang("ProfEdActEdCurType"),
  226.                                    getlang(typstring(user.persact[d].type)));
  227.                         top_output(OUT_SCREEN,
  228.                                    getlang("ProfEdActEdTPrompt"));
  229.                         key = od_get_answer(getlang("ProfEdActEdTypKeys"));
  230.                         if (key == getlangchar("ProfEdActEdTypKeys", 0))
  231.                             user.persact[d].type = 0;
  232.                         if (key == getlangchar("ProfEdActEdTypKeys", 1))
  233.                             user.persact[d].type = 1;
  234.                         top_output(OUT_SCREEN, getlang("ProfEdActEdNewType"),
  235.                                    getlang(typstring(user.persact[d].type)));
  236.                         save_user_data(user_rec_num, &user);
  237.                         pac = 1;
  238.                         key = '\0';
  239.                         }
  240.                     /* Action verb. */
  241.                     if (key == getlangchar("ProfEdActKeys", 1))
  242.                         {
  243.                         do
  244.                             {
  245.                             top_output(OUT_SCREEN,
  246.                                        getlang("ProfEdActEdCurVerb"),
  247.                                        user.persact[d].verb);
  248.                             top_output(OUT_SCREEN,
  249.                                        getlang("ProfEdActEdVPrompt"));
  250.                             od_input_str(tmp, 10, '!',
  251.                                          MAXASCII);
  252.                             }
  253.                         while(censorinput(tmp));
  254.  
  255.                         if (tmp[0])
  256.                             {
  257.                             trim_string(user.persact[d].verb,
  258.                                         tmp, 0);
  259.                             save_user_data(user_rec_num, &user);
  260.                             pac = 1;
  261.                             }
  262.                         }
  263.                     /* Action response text. */
  264.                     if (key == getlangchar("ProfEdActKeys", 2))
  265.                         {
  266.                         do
  267.                             {
  268.                             top_output(OUT_SCREEN,
  269.                                        getlang("ProfEdActEdCurResp"),
  270.                                        user.persact[d].response);
  271.                             top_output(OUT_SCREEN,
  272.                                        getlang("ProfEdActEdRPrompt"));
  273.                             od_input_str(tmp, 60, ' ',
  274.                                          MAXASCII);
  275.                             }
  276.                         while(censorinput(tmp));
  277.                         if (tmp[0])
  278.                             {
  279.                             trim_string(user.persact[d].response,
  280.                                         tmp, 0);
  281.                             save_user_data(user_rec_num, &user);
  282.                             pac = 1;
  283.                             }
  284.                         }
  285.                     /* Singular action text. */
  286.                     if (key == getlangchar("ProfEdActKeys", 3))
  287.                         {
  288.                         do
  289.                             {
  290.                             top_output(OUT_SCREEN,
  291.                                        getlang("ProfEdActEdCurSing"),
  292.                                        user.persact[d].singular);
  293.                             top_output(OUT_SCREEN,
  294.                                        getlang("ProfEdActEdSPrompt"));
  295.                             od_input_str(tmp, 60, ' ',
  296.                                          MAXASCII);
  297.                             }
  298.                         while(censorinput(tmp));
  299.  
  300.                         if (tmp[0])
  301.                             {
  302.                             /* %m is required to prevent user malice. */
  303.                             if (strstr(tmp, "%m") ||
  304.                                 strstr(tmp, "%M"))
  305.                                 {
  306.                                 trim_string(user.persact[d].singular,
  307.                                             tmp, 0);
  308.                                 save_user_data(user_rec_num, &user);
  309.                                 pac = 1;
  310.                                 }
  311.                             else
  312.                                 {
  313.                                 top_output(OUT_SCREEN,
  314.                                            getlang("ProfEdActEdBadSing"));
  315.                                 }
  316.                             }
  317.                         }
  318.                     /* Plural action text. */
  319.                     if (key == getlangchar("ProfEdActKeys", 4))
  320.                         {
  321.                         do
  322.                             {
  323.                             top_output(OUT_SCREEN,
  324.                                        getlang("ProfEdActEdCurPlur"),
  325.                                        user.persact[d].plural);
  326.                             top_output(OUT_SCREEN,
  327.                                        getlang("ProfEdActEdPPrompt"));
  328.                             od_input_str(tmp, 60, ' ',
  329.                                          MAXASCII);
  330.                             }
  331.                         while(censorinput(tmp));
  332.  
  333.                         if (tmp[0])
  334.                             {
  335.                             /* %m is required to prevent user malice. */
  336.                             if (strstr(tmp, "%m") ||
  337.                                 strstr(tmp, "%M"))
  338.                                 {
  339.                                 trim_string(user.persact[d].plural,
  340.                                             tmp, 0);
  341.                                 save_user_data(user_rec_num, &user);
  342.                                 pac = 1;
  343.                                 }
  344.                             else
  345.                                 {
  346.                                 top_output(OUT_SCREEN,
  347.                                            getlang("ProfEdActEdBadPlur"));
  348.                                 }
  349.                             }
  350.                         }
  351.                     /* Action editor help. */
  352.                     if (key == getlangchar("ProfEdActKeys", 5))
  353.                         {
  354.                         top_output(OUT_SCREEN, getlang("ProfEdActEdHlpPref"));
  355.                         show_file("PERSHELP", SCRN_WAITKEY);
  356.                         }
  357.                     }
  358.                 /* Loop until the main action editor quit key is pressed. */
  359.                 while(key != getlangchar("ProfEdActKeys", 6));
  360.                 key = '\0';
  361.                 actptrs[0][d]->data.responselen =
  362.                     strlen(user.persact[d].response);
  363.                 actptrs[0][d]->data.singularlen =
  364.                     strlen(user.persact[d].singular);
  365.                 actptrs[0][d]->data.plurallen =
  366.                     strlen(user.persact[d].plural);
  367.                 // Errchecking bigtime!
  368.                 actptrs[0][d]->ptrs.responsetext =
  369.                     realloc(actptrs[0][d]->ptrs.responsetext,
  370.                             actptrs[0][d]->data.responselen + 1);
  371.                 actptrs[0][d]->ptrs.singulartext =
  372.                     realloc(actptrs[0][d]->ptrs.singulartext,
  373.                             actptrs[0][d]->data.singularlen + 1);
  374.                 actptrs[0][d]->ptrs.pluraltext =
  375.                     realloc(actptrs[0][d]->ptrs.pluraltext,
  376.                             actptrs[0][d]->data.plurallen + 1);
  377.                 strcpy(actptrs[0][d]->ptrs.responsetext,
  378.                        user.persact[d].response);
  379.                 strcpy(actptrs[0][d]->ptrs.singulartext,
  380.                        user.persact[d].singular);
  381.                 strcpy(actptrs[0][d]->ptrs.pluraltext,
  382.                        user.persact[d].plural);
  383.                 strcpy(actptrs[0][d]->data.verb,
  384.                        user.persact[d].verb);
  385.                 actptrs[0][d]->data.type =
  386.                     user.persact[d].type;
  387.                 }
  388.             }
  389.         /* Loop until the action editor quit key is pressed. */
  390.         while(key != getlangchar("ProfPActKeys", 2));
  391.         top_output(OUT_SCREEN, getlang("ProfEdActQuitMsg"));
  392.         key = '\0';
  393.         }
  394. /* Change description, no longer used since the implementation of the
  395.    biography feture. */
  396. /*    if (key == getlangchar("ProfMainKeys", 1))
  397.         {
  398.         top_output(OUT_SCREEN, getlang("ProfEdDescPrompt"));
  399.  
  400.         od_input_str(tmp, 60, ' ', MAXASCII);
  401.  
  402.         if (tmp[0] != '\0')
  403.             {
  404.             trim_string(user.description, tmp, 0);
  405.             save_user_data(user_rec_num, &user);
  406.             }
  407.         }*/
  408.     /* Change gender. */
  409.     if (key == getlangchar("ProfMainKeys", 2))
  410.         {
  411.         top_output(OUT_SCREEN, getlang("ProfEdSexPrompt"));
  412.         od_control.user_sex = od_get_answer(getlang("ProfEdSexKeys"));
  413.         if (od_control.user_sex == getlangchar("ProfEdSexKeys", 1))
  414.             {
  415.             strcpy(tmp, top_output(OUT_STRINGNF, getlang("Female")));
  416.             top_output(OUT_SCREEN, getlang("Female"));
  417.             top_output(OUT_SCREEN, getlang("ProfEdSexSuffix"));
  418.             user.gender = 1;
  419.             }
  420.         if (od_control.user_sex == getlangchar("ProfEdSexKeys", 0))
  421.             {
  422.             strcpy(tmp, top_output(OUT_STRINGNF, getlang("Male")));
  423.             top_output(OUT_SCREEN, getlang("Male"));
  424.             top_output(OUT_SCREEN, getlang("ProfEdSexSuffix"));
  425.             user.gender = 0;
  426.             }
  427.         curchannel = cmiprevchan;
  428.         dispatch_message(MSG_SEXCHG, tmp, -1, 0, 0);
  429.         curchannel = BUSYCHANNEL;
  430.  
  431.         node->gender = user.gender;
  432.  
  433.         save_node_data(od_control.od_node, node);
  434.         save_user_data(user_rec_num, &user);
  435.         }
  436.     /* Change handle. */
  437.     if (key == getlangchar("ProfMainKeys", 3))
  438.         {
  439.         do
  440.             {
  441.             top_output(OUT_SCREEN, getlang("ProfEdHandlePrompt"));
  442.             od_input_str(tmp, 30, ' ', MAXASCII);
  443.             }
  444.         while(censorinput(tmp));
  445.  
  446.         trim_string(tmp, tmp, 0);
  447.         fixname(tmp, tmp);
  448.  
  449.         if (tmp[0] != '\0')
  450.             {
  451.             if (check_dupe_handles(tmp))
  452.                 {
  453.                 top_output(OUT_SCREEN, getlang("HandleInUse"));
  454.                 }
  455.             else
  456.                 {
  457.                 fixname(user.handle, tmp);
  458.                 fixname(handles[od_control.od_node].string, tmp);
  459.                 curchannel = cmiprevchan;
  460.                 dispatch_message(MSG_HANDLECHG, tmp, -1, 0, 0);
  461.                 curchannel = BUSYCHANNEL;
  462.                 save_user_data(user_rec_num, &user);
  463.                 od_log_write(top_output(OUT_STRING,
  464.                                         getlang("LogChangedHandle"),
  465.                                         user.handle));
  466.  
  467.                 fixname(node->handle, tmp);
  468.  
  469.                 save_node_data(od_control.od_node, node);
  470.                 }
  471.             }
  472.         }
  473.     /* Change entry/exit message(s). */
  474.     if (key == getlangchar("ProfMainKeys", 4))
  475.         {
  476.         /* E/xmessage editor loop. */
  477.         do
  478.             {
  479.             top_output(OUT_SCREEN, getlang("ProfEdEXMsgPrefix"));
  480.  
  481.             top_output(OUT_SCREEN, getlang("ProfEdEXMsgCurEMsg"),
  482.                        user.emessage);
  483.             top_output(OUT_SCREEN, getlang("ProfEdEXMsgCurXMsg"),
  484.                        user.xmessage);
  485.  
  486.             top_output(OUT_SCREEN, getlang("ProfEdEXMsgEMsg"));
  487.             top_output(OUT_SCREEN, getlang("ProfEdEXMsgXMsg"));
  488.             top_output(OUT_SCREEN, getlang("ProfEdEXMsgQuit"));
  489.  
  490.             top_output(OUT_SCREEN, getlang("ProfEdEXMsgPrompt"));
  491.  
  492.             key = od_get_answer(getlang("ProfEdEXMsgKeys"));
  493.             sprintf(outbuf, "%c", key);
  494.             top_output(OUT_SCREEN, getlang("ProfEdEXMsgShowKey"), outbuf);
  495.  
  496.             /* Change entry message. */
  497.             if (key == getlangchar("ProfEdEXMsgKeys", 0))
  498.                 {
  499.                 do
  500.                     {
  501.                     top_output(OUT_SCREEN, getlang("ProfEdEXMEdCurEnt"),
  502.                                user.emessage);
  503.                     top_output(OUT_SCREEN, getlang("ProfEdEXMEdEPrompt"));
  504.                     od_input_str(tmp, 80, ' ',
  505.                                  MAXASCII);
  506.                     }
  507.                 while(censorinput(tmp));
  508.  
  509.                 trim_string(user.emessage, tmp, 0);
  510.                 save_user_data(user_rec_num, &user);
  511.                 msgchg = 1;
  512.                 }
  513.             /* Change exit message. */
  514.             if (key == getlangchar("ProfEdEXMsgKeys", 1))
  515.                 {
  516.                 do
  517.                     {
  518.                     top_output(OUT_SCREEN, getlang("ProfEdEXMEdCurExit"),
  519.                                user.xmessage);
  520.                     top_output(OUT_SCREEN, getlang("ProfEdEXMEdXPrompt"));
  521.                     od_input_str(tmp, 80, ' ',
  522.                                  MAXASCII);
  523.                     }
  524.                 while(censorinput(tmp));
  525.                 trim_string(user.xmessage, tmp, 0);
  526.                 save_user_data(user_rec_num, &user);
  527.                 msgchg = 1;
  528.                 }
  529.             }
  530.         /* Loop until the e/xmessage editor quit key is pressed. */
  531.         while(key != getlangchar("ProfEdEXMsgKeys", 2));
  532.         key = '\0';
  533.         top_output(OUT_SCREEN, getlang("ProfEdEXMsgSuffix"));
  534.         }
  535.     /* Edit user preferences. */
  536.     if (key == getlangchar("ProfMainKeys", 5))
  537.         {
  538.         /* Preference editor loop. */
  539.         do
  540.             {
  541.             top_output(OUT_SCREEN, getlang("ProfEdPrefPrefix"));
  542.  
  543.             top_output(OUT_SCREEN, getlang("ProfEdPrefActEcho"),
  544.                        getlang(user.pref1 & PREF1_ECHOACTIONS ?
  545.                                "On" : "Off"));
  546.             top_output(OUT_SCREEN, getlang("ProfEdPrefTActEcho"),
  547.                        getlang(user.pref1 & PREF1_ECHOTALKTYP ?
  548.                                "On" : "Off"));
  549.             top_output(OUT_SCREEN, getlang("ProfEdPrefTMsgEcho"),
  550.                        getlang(user.pref1 & PREF1_ECHOTALKMSG ?
  551.                                "On" : "Off"));
  552.             top_output(OUT_SCREEN, getlang("ProfEdPrefMsgSent"),
  553.                        getlang(user.pref1 & PREF1_MSGSENT ?
  554.                                "On" : "Off"));
  555.             top_output(OUT_SCREEN, getlang("ProfEdPrefGAEcho"),
  556.                        getlang(user.pref1 & PREF1_ECHOGA ?
  557.                                "On" : "Off"));
  558.             top_output(OUT_SCREEN, getlang("ProfEdPrefTTSent"),
  559.                        getlang(user.pref1 & PREF1_TALKMSGSENT ?
  560.                                "On" : "Off"));
  561.             top_output(OUT_SCREEN, getlang("ProfEdPrefDualWin"),
  562.                        getlang(user.pref1 & PREF1_DUALWINDOW ?
  563.                                "On" : "Off"));
  564.             top_output(OUT_SCREEN, getlang("ProfEdPrefBlockTxt"),
  565.                        getlang(user.pref1 & PREF1_BLKWHILETYP ?
  566.                                "On" : "Off"));
  567.             top_output(OUT_SCREEN, getlang("ProfEdPrefListed"),
  568.                        getlang(user.pref2 & PREF2_CHANLISTED ?
  569.                                "On" : "Off"));
  570.             top_output(OUT_SCREEN, getlang("ProfEdPrefEchoOwn"),
  571.                        getlang(user.pref2 & PREF2_ECHOOWNTEXT ?
  572.                                "On" : "Off"));
  573.             top_output(OUT_SCREEN, getlang("ProfEdPrefActions"),
  574.                        getlang(user.pref2 & PREF2_ACTIONSOFF ?
  575.                                "On" : "Off"));
  576.             top_output(OUT_SCREEN, getlang("ProfEdPrefQuit"));
  577.  
  578.             top_output(OUT_SCREEN, getlang("ProfEdPrefPrompt"));
  579.  
  580.             key = od_get_answer(getlang("ProfEdPrefKeys"));
  581.             sprintf(outbuf, "%c", key);
  582.             top_output(OUT_SCREEN, getlang("ProfEdPrefShowKey"), outbuf);
  583.  
  584.             /* The various preferences are covered in TOP.H and TOP.CFG. */
  585.  
  586.             if (key == getlangchar("ProfEdPrefKeys", 0))
  587.                 {
  588.                 user.pref1 ^= PREF1_ECHOACTIONS;
  589.                 prefchg = 1;
  590.                 }
  591.             if (key == getlangchar("ProfEdPrefKeys", 1))
  592.                 {
  593.                 user.pref1 ^= PREF1_ECHOTALKTYP;
  594.                 prefchg = 1;
  595.                 }
  596.             if (key == getlangchar("ProfEdPrefKeys", 2))
  597.                 {
  598.                 user.pref1 ^= PREF1_ECHOTALKMSG;
  599.                 prefchg = 1;
  600.                 }
  601.             if (key == getlangchar("ProfEdPrefKeys", 3))
  602.                 {
  603.                 user.pref1 ^= PREF1_MSGSENT;
  604.                 prefchg = 1;
  605.                 }
  606.             if (key == getlangchar("ProfEdPrefKeys", 4))
  607.                 {
  608.                 user.pref1 ^= PREF1_ECHOGA;
  609.                 prefchg = 1;
  610.                 }
  611.             if (key == getlangchar("ProfEdPrefKeys", 5))
  612.                 {
  613.                 user.pref1 ^= PREF1_TALKMSGSENT;
  614.                 prefchg = 1;
  615.                 }
  616.             if (key == getlangchar("ProfEdPrefKeys", 6))
  617.                 {
  618.                 if (!od_control.user_ansi/* &&
  619.                     !od_control.user_avatar*/)
  620.                     {
  621.                     top_output(OUT_SCREEN,
  622.                                getlang("DualWindowNoGfx"));
  623.                     }
  624.                 else
  625.                     {
  626.                     user.pref1 ^= PREF1_DUALWINDOW;
  627.                     prefchg = 1;
  628.                     }
  629.                 }
  630.             if (key == getlangchar("ProfEdPrefKeys", 7))
  631.                 {
  632.                 user.pref1 ^= PREF1_BLKWHILETYP;
  633.                 prefchg = 1;
  634.                 }
  635.             if (key == getlangchar("ProfEdPrefKeys", 8))
  636.                 {
  637.                 user.pref2 ^= PREF2_CHANLISTED;
  638.                 prefchg = 1;
  639.                 node->channellisted =
  640.                     (user.pref2 & PREF2_CHANLISTED);
  641.                 save_node_data(od_control.od_node, node);
  642.                 }
  643.             if (key == getlangchar("ProfEdPrefKeys", 9))
  644.                 {
  645.                 user.pref2 ^= PREF2_ECHOOWNTEXT;
  646.                 prefchg = 1;
  647.                 }
  648.             if (key == getlangchar("ProfEdPrefKeys", 10))
  649.                 {
  650.                 user.pref2 ^= PREF2_ACTIONSOFF;
  651.                 prefchg = 1;
  652.                 }
  653.             }
  654.         /* Loop until the preference editor quit key is pressed. */
  655.         while(key != getlangchar("ProfEdPrefKeys", 11));
  656.         key = '\0';
  657.         /* Save the user data if preferences were changed. */
  658.         if (prefchg)
  659.             {
  660.             save_user_data(user_rec_num, &user);
  661.             }
  662.         top_output(OUT_SCREEN, getlang("ProfEdPrefSuffix"));
  663.         }
  664.     /* Change TOP password. */
  665.     if (key == getlangchar("ProfMainKeys", 6))
  666.         {
  667.         char entryok = 1;
  668.  
  669.         /* Verify the current password if one exists. */
  670.         if (user.password[0])
  671.             {
  672.             top_output(OUT_SCREEN, getlang("ProfEdPWCurPrompt"));
  673.             get_password(ptmp1, 15);
  674.             if (stricmp(user.password, ptmp1))
  675.                 {
  676.                 top_output(OUT_SCREEN, getlang("ProfEdPWBadPW"));
  677.                 entryok = 0;
  678.                 }
  679.             }
  680.         if (entryok)
  681.             {
  682.             pwok = 0;
  683.             top_output(OUT_SCREEN, getlang("ProfEdPWNewPrompt"));
  684.             get_password(ptmp1, 15);
  685.             top_output(OUT_SCREEN, getlang("ProfEdPWConfPrompt"));
  686.             get_password(ptmp2, 15);
  687.             if (stricmp(ptmp1, ptmp2))
  688.                 {
  689.                 top_output(OUT_SCREEN, getlang("ProfEdPWNoMatch"));
  690.                 pwok = 0;
  691.                 }
  692.             else
  693.                 {
  694.                 pwok = 1;
  695.                 }
  696.             top_output(OUT_SCREEN, getlang("ProfEDPWSuffix"));
  697.             if (pwok)
  698.                 {
  699.                 strcpy(user.password, strupr(ptmp1));
  700.                 save_user_data(user_rec_num, &user);
  701.                 }
  702.             }
  703.         }
  704.     if (pac)
  705.         {
  706.         curchannel = cmiprevchan;
  707.         dispatch_message(MSG_PERACTCHG, "\0", -1, 0, 0);
  708.         curchannel = BUSYCHANNEL;
  709.         }
  710.     if (msgchg)
  711.         {
  712.         curchannel = cmiprevchan;
  713.         dispatch_message(MSG_EXMSGCHG, "\0", -1, 0, 0);
  714.         curchannel = BUSYCHANNEL;
  715.         }
  716.     }
  717. /* Loop until the profile editor quit key is pressed. */
  718. while(key != getlangchar("ProfMainKeys", 7));
  719.  
  720. top_output(OUT_SCREEN, getlang("ProfEditSuffix"));
  721.  
  722. return;
  723. }
  724.  
  725.