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

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*   XBBS SOURCE CODE copyright (c) 1990 by M. Kimes                        */
  4. /*   All Rights Reserved                                                    */
  5. /*                                                                          */
  6. /*    For complete details of the licensing restrictions, please refer      */
  7. /*    to the License agreement, which is published in its entirety in       */
  8. /*    the in the file LICENSE.XBS.                                          */
  9. /*                                                                          */
  10. /*    USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE      */
  11. /*    XBBS LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF            */
  12. /*    THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO       */
  13. /*    NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES         */
  14. /*    AT THE ADDRESS LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO USE   */
  15. /*    THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING     */
  16. /*    AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH      */
  17. /*    M. KIMES                                                              */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /* You can contact M. Kimes at the following address:                       */
  21. /*                                                                          */
  22. /* M. Kimes                         1:380/16.0@FidoNet                      */
  23. /* 542 Merrick                      (318)222-3455 data                      */
  24. /* Shreveport, LA  71104                                                    */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* Please feel free to contact me at any time to share your comments about  */
  28. /* my software and/or licensing policies.                                   */
  29. /*                                                                          */
  30. /*--------------------------------------------------------------------------*/
  31.  
  32. #include "msg.h"
  33. #include "xext.h"
  34. #include "awindow.h"
  35. #include "xkeys.h"
  36.  
  37. void pascal do_pause (int tps);
  38.  
  39.  
  40. char * pascal ansi_interface (char *b) {
  41.  
  42.     char a,c;
  43.     char *p;
  44.     int oldx,oldy;
  45.     char tempdisablesub;
  46.  
  47.     tempdisablesub=disablesub;
  48.     disablesub=1;
  49.     curr_cursor(&oldx,&oldy);
  50.     stripcr(b);
  51.     a=(char)atoi(strtok(b,","));
  52.     b=strtok(0,"\n");
  53.     switch ((int)a) {
  54.         case 255:   edit_user(1);
  55.                     break;
  56.         case 254:   other_options(1);
  57.                     break;
  58.         case 1:
  59.         case 2:
  60.         case 3:     error_message(b);
  61.                     do_pause(a-1);
  62.                     break;
  63.         case 4:
  64.         case 5:
  65.         case 6:     any_message(b);
  66.                     do_pause(a-4);
  67.                     break;
  68.         case 7:
  69.         case 8:
  70.         case 9:     p=strtok(b,",");
  71.                     _anymsg(p,strtok(0,"\n"));
  72.                     do_pause(a-7);
  73.                     break;
  74.         case 10:
  75.         case 11:
  76.         case 12:    p=strtok(b,",");
  77.                     find_help(p,strtok(0,"\n"),1);
  78.                     do_pause(a-10);
  79.                     break;
  80.         case 13:    {
  81.  
  82.                      char *pp,*ppp,*pppp;
  83.                      int aa,aaa,aaaa,aaaaa;
  84.  
  85.                      level=0;
  86.                      a=*b-'0';
  87.                      b++;
  88.                      if(a<0 || a>9) break;
  89.                      p=strtok(b,",");
  90.                      pp=strtok(0,",");
  91.                      ppp=strtok(0,",");
  92.                      pppp=strtok(0,",");
  93.                      aa=atoi(strtok(0,","));
  94.                      aaa=atoi(strtok(0,","));
  95.                      aaaa=atoi(strtok(0,","));
  96.                      aaaaa=atoi(strtok(0,","));
  97.                      b=strtok(0,",");
  98.                      if(b)c=*b;
  99.                      else c='a';
  100.                      p=do_input(p,pp,ppp,pppp,aa,aaa,aaaa,aaaaa,c);
  101.                      if(p) {
  102.                          strncpy(variable[a],p,81);
  103.                          variable[a][80]=0;
  104.                      }
  105.                      else level=1;
  106.                      cursor(oldx,oldy);
  107.                      disablesub=tempdisablesub;
  108.                      return p;
  109.                     }
  110.         case 14:    {
  111.  
  112.                      WINDOW *wnd;
  113.                      int temp;
  114.                      int x,y,h,w;
  115. #ifdef DEBUG
  116.  char s[133];
  117. #endif
  118.  
  119.                      x=atoi(strtok(b,","));
  120.                      y=atoi(strtok(0,","));
  121.                      h=atoi(strtok(0,","));
  122.                      w=atoi(strtok(0,","));
  123.                      p=strtok(0,"\n");
  124.                      wnd=establish_screen(x,y,h,w);
  125. #ifdef DEBUG
  126.  sprintf(s," SCROLL=%d HEIGHT=%d WIDTH=%d COL=%d ROW=%d ",SCROLL,HEIGHT,WIDTH,COL,ROW);
  127.  any_message(s);
  128.  sleep(1);
  129.  clear_message();
  130. #endif
  131.                      temp=get_selection(wnd,0,p);
  132.                      delete_window(wnd);
  133.                      printm("\x1b[23;1H");
  134.                      level=temp;
  135.                     }
  136.                     disablesub=tempdisablesub;
  137.                     return NULL;
  138.         case 15:    {
  139.  
  140.                      WINDOW *wnd;
  141.                      FIELD *fld;
  142.                      char temp;
  143.                      int x,y,fore,back;
  144.                      char s[81];
  145.  
  146.                      a=*b-'0';
  147.                      b+=2;
  148.                      if(a<0 || a>9) break;
  149.                      temp=*b;
  150.                      b++;
  151.                      p=strtok(b,",");
  152.                      if(strlen(p)>78) p[77]=0;
  153.                      curr_cursor(&x,&y);
  154.                      if(y>22) {
  155.                         y=22;
  156.                         gprintf(0,"\x1b[%d;%dH\x1b[k",y,x);
  157.                      }
  158.                      wnd=establish_screen(x,y,1,80-x);
  159.                      SCROLL=0;
  160.                      init_template(wnd);
  161.                      strset(s,0);
  162.                      fld=establish_field(wnd,0,0,p,s,temp);
  163.                      prep_template(wnd);
  164.                      temp=(char)data_entry(wnd);
  165.                      if(temp!=ESC && temp!=CTRL_K) {
  166.                         rstrip(s);
  167.                         strcpy(variable[a],s);
  168.                         level=0;
  169.                      }
  170.                      else level=1;
  171.                      delete_window(wnd);
  172.                      printm("\x1b[23;1H");
  173.                     }
  174.                     disablesub=tempdisablesub;
  175.                     return NULL;
  176.     }
  177.     disablesub=tempdisablesub;
  178.     cursor(oldx,oldy);
  179.     return NULL;
  180. }
  181.  
  182.  
  183.  
  184. void pascal do_pause (int tps) {
  185.  
  186.     unsigned long t;
  187.  
  188.     switch (tps) {
  189.         case 0:     t=(unsigned long)get_char();    /* Avoid warning */
  190.                     break;
  191.         case 1:     t=getxbbstime()+120L;
  192.                     while(!inkey() && t>getxbbstime());
  193.                     break;
  194.         default:    sleep(1);
  195.                     break;
  196.     }
  197. }
  198.  
  199.  
  200.  
  201. char * pascal do_input (char *title, char *prompt, char *mask, char *deflt, int fore, int back, int x, int y, char type) {
  202.  
  203.     WINDOW *wnd;
  204.     FIELD *fld;
  205.     int xsize,ysize;
  206.     static char resp[81];
  207.     char returncode;
  208.  
  209.     if(!mask) return NULL;
  210.     if(fore==0 && back==0) {
  211.         fore=WHITE;
  212.         back=BLACK;
  213.     }
  214.     if(!title) title=" Input ";
  215.     if(!prompt) prompt="";
  216.     if(strlen(mask)>78) mask[77]=0;
  217.     strset(resp,0);
  218.     if(deflt) {
  219.         strncpy(resp,deflt,79);
  220.         resp[77]=0;
  221.     }
  222.     ysize=max(strlen(title),strlen(prompt));
  223.     xsize=max(strlen(mask),ysize)+4;
  224.     if(xsize>80)xsize=80;
  225.     ysize=4;
  226.     wnd=establish_window(x,y,ysize,xsize);
  227.     set_title(wnd,title);
  228.     set_colors(wnd,ALL,back,fore,BRIGHT);
  229.     set_colors(wnd,ACCENT,fore,back,DIM);
  230.     set_border(wnd,3);
  231.     display_window(wnd);
  232.     wcursor(wnd,(x<80),0);
  233.     wprintf(wnd,prompt);
  234.     init_template(wnd);
  235.     fld=establish_field(wnd,(x<80),1,mask,resp,type);
  236.     prep_template(wnd);
  237.     returncode=data_entry(wnd);
  238.     delete_window(wnd);
  239.     if(returncode==ESC) return NULL;
  240.     rstrip(resp);
  241.     return resp;
  242. }
  243.  
  244.