home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XDEV_117.ZIP / XCONF3.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-18  |  9.5 KB  |  401 lines

  1. #include "msgg.h"
  2. #include "twindow.h"
  3. #include "keys.h"
  4. #include "scrntitl.h"
  5.  
  6. /* You can #define FASTWINDOWS to speed up the window library, but you'll
  7.    have to ensure that you write *only* to the top window */
  8.  
  9. /* Function prototypes */
  10.  
  11. char * pascal saytime (struct time *a);
  12. char * lstrip (char *a);
  13. void readconfig (void);
  14. void configure(void);
  15. void saveconfig(void);
  16. void newuserr(void);
  17. void bbs(void);
  18. void matrix(void);
  19. void setdefaults(void);
  20. void prompts(void);
  21. void miscel(void);
  22. void paths(void);
  23. void prepare_config(void);
  24. int prompt1(void);
  25. int prompt2(void);
  26. int prompt3(void);
  27. int addbackslash(char *,int);
  28. char * rstrip(char *);
  29. void quit(void);
  30. void quitnosave(void);
  31. void quitsave(void);
  32. int elevell(char *,int);
  33. int shltype(char *,int);
  34. int yesorno(char *,int);
  35. void fboardd(void);
  36. void mboardd(void);
  37. void params(void);
  38. void printscreen(void);
  39. void jumptodos(void);
  40. int window1(void);
  41. int window2(void);
  42. int window3(void);
  43. int window4(void);
  44.  
  45. extern char msk78[];
  46. extern char mskdate[];
  47. extern char mskphone[];
  48. #define msk35 msk78+43
  49. #define mskcit "_______________________"
  50. #define mskzip "_____"
  51. #define mskst "__"
  52. #define msk1 msk78+77
  53. #define msk3 msk35+32
  54. #define msk6 msk35+29
  55. #define msk47 msk78+31
  56. #define msk63 msk78+15
  57. #define msk15 msk78+63
  58. #define msk58 msk78+20
  59. #define msk46 msk78+32
  60.  
  61. /* Global variables */
  62.  
  63. extern struct _config conf;   /* System configuration read from CONFIG.BBS */
  64. extern struct _user newuser;
  65. extern struct _logconfig logconf;
  66. extern char   nonstop;
  67.  
  68.  
  69.  
  70. int window1 (void)
  71.  
  72.  
  73. {
  74.  
  75.     WINDOW *wnd;
  76.     FIELD *fld;
  77.     char length[4];
  78.     char width[4];
  79.     char credit[7];
  80.     int exitcode;
  81.  
  82.     sprintf(length,"%-hu",newuser.length);
  83.     sprintf(width,"%-hu",newuser.width);
  84.     sprintf(credit,"%-u",newuser.credit);
  85.  
  86.     wnd=establish_window(2,4,10,52);
  87.     set_border(wnd,2);
  88.     set_title(wnd," NewUser Defaults--Window #1 ");
  89.     set_colors(wnd,ALL,BLUE,WHITE,BRIGHT);
  90.     set_colors(wnd,ACCENT,WHITE,BLACK,DIM);
  91.     display_window(wnd);
  92.     wprompt(wnd,2,1,"Name:");
  93.     wprompt(wnd,2,2,"Handle:");
  94.     wprompt(wnd,2,3,"City:");
  95.     wprompt(wnd,37,3,"State:");
  96.     wprompt(wnd,2,4,"Zip:");
  97.     wprompt(wnd,21,4,"Phone1:");
  98.     wprompt(wnd,21,5,"Phone2:");
  99.     wprompt(wnd,2,6,"Length:");
  100.     wprompt(wnd,15,6,"Width:");
  101.     wprompt(wnd,27,6,"Credit:");
  102.     init_template(wnd);
  103.     fld=establish_field(wnd,11,1,msk35,newuser.name,'a');
  104.     field_window(fld,"name    ",40,1);
  105.     fld=establish_field(wnd,11,2,msk35,newuser.handle,'a');
  106.     field_window(fld,"handle    ",40,2);
  107.     fld=establish_field(wnd,11,3,mskcit,newuser.city,'a');
  108.     field_window(fld,"city    ",40,3);
  109.     fld=establish_field(wnd,44,3,mskst,newuser.state,'A');
  110.     field_window(fld,"state    ",40,3);
  111.     fld=establish_field(wnd,11,4,mskzip,newuser.zip,'Z');
  112.     field_window(fld,"zip      ",40,4);
  113.     fld=establish_field(wnd,31,4,mskphone,newuser.phone1,'N');
  114.     field_window(fld,"phone1    ",44,4);
  115.     fld=establish_field(wnd,31,5,mskphone,newuser.phone2,'N');
  116.     field_window(fld,"phone2    ",44,5);
  117.     fld=establish_field(wnd,10,6,mskst,length,'N');
  118.     field_window(fld,"length    ",40,5);
  119.     fld=establish_field(wnd,22,6,mskst,width,'N');
  120.     field_window(fld,"width     ",42,5);
  121.     fld=establish_field(wnd,35,6,mskzip,credit,'N');
  122.     field_window(fld,"credit    ",44,6);
  123.     prep_template(wnd);
  124.     exitcode=data_entry(wnd);
  125.     delete_window(wnd);
  126.  
  127.     newuser.length=(char)atoi(length);
  128.     newuser.width=(char)atoi(width);
  129.     newuser.credit=atoi(credit);
  130.     return (exitcode);
  131.  
  132. }
  133.  
  134.  
  135. int window2 (void)
  136.  
  137.  
  138. {
  139.  
  140.     WINDOW *wnd;
  141.     FIELD *fld;
  142.     char stats[10][7];
  143.     int register x;
  144.     char temp[32];
  145.     int exitcode;
  146.  
  147.     for (x=0;x<10;x++) {
  148.         sprintf(stats[x],"%-u",newuser.stat[x]);
  149.         stats[x][6]=0;
  150.     }
  151.     wnd=establish_window(4,5,14,33);
  152.     set_border(wnd,1);
  153.     set_title(wnd," NewUser Defaults--Window #2 ");
  154.     set_colors(wnd,ALL,BLUE,WHITE,BRIGHT);
  155.     set_colors(wnd,ACCENT,WHITE,BLACK,DIM);
  156.     display_window(wnd);
  157.     for (x=0;x<10;x++) {
  158.         sprintf(temp,"Security Level #%d:",x);
  159.         wprompt(wnd,2,x+1,temp);
  160.     }
  161.     init_template(wnd);
  162.     for (x=0;x<10;x++) {
  163.         fld=establish_field(wnd,22,x+1,mskzip,stats[x],'N');
  164.         switch (x) {
  165.           case 0:  field_window(fld,"stat0   ",34,x+2);
  166.                    break;
  167.           case 1:  field_window(fld,"stat1   ",34,x+1);
  168.                    break;
  169.           default: field_window(fld,"stat    ",34,x+3);
  170.         }
  171.     }
  172.     prep_template(wnd);
  173.     exitcode=data_entry(wnd);
  174.     delete_window(wnd);
  175.     for (x=0;x<10;x++) {
  176.         newuser.stat[x]=(word)atoi(stats[x]);
  177.     }
  178.     return (exitcode);
  179. }
  180.  
  181.  
  182. int window3(void)
  183.  
  184. {
  185.  
  186.     WINDOW *wnd;
  187.     FIELD *fld;
  188.     char callsperday[7];
  189.     char timepercall[7];
  190.     char totaltime[7];
  191.     int exitcode;
  192.  
  193.     sprintf(callsperday,"%-u",newuser.callsperday);
  194.     sprintf(timepercall,"%-u",newuser.timepercall);
  195.     sprintf(totaltime,"%-u",newuser.totaltime);
  196.  
  197.     wnd=establish_window(5,6,7,33);
  198.     set_border(wnd,3);
  199.     set_title(wnd," NewUser Defaults--Window #3 ");
  200.     set_colors(wnd,ALL,BLUE,WHITE,BRIGHT);
  201.     set_colors(wnd,ACCENT,WHITE,BLACK,DIM);
  202.  
  203.     display_window(wnd);
  204.  
  205.     wprompt(wnd,2,1,"Calls per day:");
  206.     wprompt(wnd,2,2,"Time per call:");
  207.     wprompt(wnd,2,3,"Total time per day:");
  208.  
  209.     init_template(wnd);
  210.  
  211.     fld=establish_field(wnd,22,1,mskzip,callsperday,'N');
  212.     field_window(fld,"calls   ",34,2);
  213.     fld=establish_field(wnd,22,2,mskzip,timepercall,'N');
  214.     field_window(fld,"time    ",34,3);
  215.     fld=establish_field(wnd,22,3,mskzip,totaltime,'N');
  216.     field_window(fld,"total   ",34,4);
  217.  
  218.     prep_template(wnd);
  219.     exitcode=data_entry(wnd);
  220.     delete_window(wnd);
  221.  
  222.     newuser.callsperday=(word)atoi(callsperday);
  223.     newuser.timepercall=(word)atoi(timepercall);
  224.     newuser.totaltime=(word)atoi(totaltime);
  225.     return (exitcode);
  226.  
  227. }
  228.  
  229.  
  230.  
  231. int window4(void)
  232.  
  233. {
  234.  
  235.     WINDOW *wnd;
  236.     WINDOW *instruct;
  237.     FIELD *fld;
  238.     char attr[13][2];
  239.     int register x;
  240.     int exitcode;
  241.     char cold[2];
  242.  
  243.     instruct=establish_window(40,4,3,35);
  244.     set_border(instruct,2);
  245.     set_title(instruct,"Toggles");
  246.     set_colors(instruct,ALL,MAGENTA,BLACK,DIM);
  247.     set_colors(instruct,ACCENT,MAGENTA,WHITE,BRIGHT);
  248.     display_window(instruct);
  249.     wprintf(instruct," [X] to set, [Space] to reset ");
  250.  
  251.     wnd=establish_window(5,3,17,34);
  252.     set_border(wnd,3);
  253.     set_title(wnd," NewUser Defaults--Window #4 ");
  254.     set_colors(wnd,ALL,BLUE,WHITE,BRIGHT);
  255.     set_colors(wnd,ACCENT,WHITE,BLACK,DIM);
  256.  
  257.     display_window(wnd);
  258.  
  259.     wprintf(wnd,"      NewUser Attributes:");
  260.     wprompt(wnd,2,2,"Expert Mode:");
  261.     wprompt(wnd,2,3,"Ignore Hours:");
  262.     wprompt(wnd,2,4,"Ignore Ratio:");
  263.     wprompt(wnd,2,5,"Never Kill:");
  264.     wprompt(wnd,2,6,"Deleted:");
  265.     wprompt(wnd,2,7,"Reliable Connect:");
  266.     wprompt(wnd,2,8,"Twit:");
  267.     wprompt(wnd,2,9,"ANSI cursor menus:");
  268.     wprompt(wnd,2,10,"Special flag:");
  269.     wprompt(wnd,2,11,"General flag #1:");
  270.     wprompt(wnd,2,12,"General flag #2:");
  271.     wprompt(wnd,2,13,"General flag #3:");
  272.     wprompt(wnd,2,14,"Cold Input:");
  273.  
  274.     init_template(wnd);
  275.  
  276.     for (x=0;x<12;x++) {
  277.         fld=establish_field(wnd,22,x+2,msk1,attr[x],'O');
  278.         field_window(fld,"attributes",43,6+x);
  279.     }
  280.     fld=establish_field(wnd,22,14,msk1,cold,'O');
  281.     field_window(fld,"coldinput ",43,6);
  282.  
  283.     prep_template(wnd);
  284.  
  285.     for (x=0;x<12;x++) attr[x][1]=0;
  286.     *attr[0]=newuser.expert ? 'X' : '-';
  287.     *attr[1]=newuser.ignorehrs ? 'X' : '-';
  288.     *attr[2]=newuser.ignorerat ? 'X' : '-';
  289.     *attr[3]=newuser.nokill ? 'X' : '-';
  290.     *attr[4]=newuser.deleted ? 'X' : '-';
  291.     *attr[5]=newuser.arq ? 'X' : '-';
  292.     *attr[6]=newuser.twit ? 'X' : '-';
  293.     *attr[7]=newuser.ansimenus ? '-' : 'X';
  294.     *attr[8]=newuser.commodore ? 'X' : '-';
  295.     *attr[9]=newuser.gen1 ? 'X' : '-';
  296.     *attr[10]=newuser.gen2 ? 'X' : '-';
  297.     *attr[11]=newuser.gen3 ? 'X' : '-';
  298.     if(newuser.cold) strcpy(cold,"X");
  299.     else strcpy(cold,"-");
  300.  
  301.     exitcode=data_entry(wnd);
  302.     delete_window(wnd);
  303.  
  304.     newuser.expert   =*attr[0]=='X';
  305.     newuser.ignorehrs=*attr[1]=='X';
  306.     newuser.ignorerat=*attr[2]=='X';
  307.     newuser.nokill   =*attr[3]=='X';
  308.     newuser.deleted  =*attr[4]=='X';
  309.     newuser.arq      =*attr[5]=='X';
  310.     newuser.twit     =*attr[6]=='X';
  311.     newuser.ansimenus=*attr[7]=='-';
  312.     newuser.commodore=*attr[8]=='X';
  313.     newuser.gen1     =*attr[9]=='X';
  314.     newuser.gen2     =*attr[10]=='X';
  315.     newuser.gen3     =*attr[11]=='X';
  316.     newuser.cold     =*cold=='X';
  317.     newuser.graphics=0;
  318.     newuser.hiok=0;
  319.  
  320.     delete_window(instruct);
  321.     return (exitcode);
  322.  
  323. }
  324.  
  325.  
  326.  
  327. char * lstrip (char *a)
  328.  
  329. {
  330.   while ((strlen(a)) && (*a==' ')) memmove (a,(a+1),strlen(a));
  331.   return (a);
  332. }
  333.  
  334.  
  335.  
  336. void pascal print_clock (void) {
  337.  
  338.     int x;
  339.     int y;
  340.     struct time dos_time;
  341.     static struct time hold_time;
  342.  
  343.     gettime(&dos_time);
  344.     if (dos_time.ti_sec==hold_time.ti_sec) return;
  345.     x=wherex();
  346.     y=wherey();
  347.     gotoxy(71,25);
  348.     gettime(&hold_time);
  349.     textbackground(7);
  350.     textcolor(0);
  351.     cputs(saytime(&dos_time));
  352.     textcolor(7);
  353.     textbackground(0);
  354.     gotoxy(x,y);
  355. }
  356.  
  357.  
  358. char * pascal saytime (struct time *a) {
  359.  
  360. static char xtime[9];
  361.  
  362.  sprintf(xtime,"%02u:%02u:%02u",a->ti_hour,a->ti_min,a->ti_sec);
  363.  return(xtime);
  364. }
  365.  
  366.  
  367.  
  368. char * pascal fgetsx (char *str,int num,int handle) {
  369.  
  370.     static char *p;
  371.     static long pos;
  372.     static int x;
  373.  
  374.     if (eof(handle)) {
  375.         *str=0;
  376.         return NULL;
  377.     }
  378.     pos=tell(handle);
  379.     x=_read(handle,str,num-1);
  380.     if (x<1) {
  381.         *str=0;
  382.         return NULL;
  383.     }
  384.     str[x]=0;
  385.     p=str;
  386.     while(*p && *p!='\r' && *p!='\n') p++;
  387.     if(!*p) return str;
  388.     if(*p=='\r') {
  389.         *p='\n';
  390.         if (p[1]=='\n') {
  391.             p++;
  392.             *p=0;
  393.         }
  394.     }
  395.     p++;
  396.     *p=0;
  397.     lseek(handle,pos+((long)((word)p-(word)str)),SEEK_SET);
  398.     return str;
  399. }
  400.  
  401.