home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / XNHELP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.4 KB  |  164 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. /* XBBS 'named help' module                                         */
  33. /********************************************************************/
  34.  
  35. #include "msg.h"
  36. #include "xext.h"
  37. #include "awindow.h"
  38.  
  39. #define HBG WHITE
  40. #define HFG BLACK
  41. #define HINT DIM
  42.  
  43. #define TRUE  1
  44. #define FALSE 0
  45.  
  46.  static int h,w;
  47.  static int hx=9,hy=9;
  48.  
  49.  
  50. void pascal gethline(char *lineh,int helpfp);
  51.  
  52.  
  53. int pascal find_help (char *hn,char *topic,char usewindow) {  /* Filename, topic name */
  54.  
  55.   char ln[81];
  56.   char helpnm[81];
  57.   char *p,*pp;
  58.   int helpfp,count,xx,yy,i;
  59.   char temppause,mmore,foundhelp=0;
  60.   long pos;
  61.   WINDOW *wnd;
  62.  
  63.   helpfp=oopen(hn,O_RDONLY | O_BINARY | O_DENYNONE);
  64.   if(helpfp==-1) {
  65.     return -1;
  66.   }
  67.   gethline(ln,helpfp);
  68.   while(!eof(helpfp)) {
  69.     if (!strncmp(ln,"<end>",5)) {
  70.         cclose(helpfp);
  71.         return -1;
  72.     }
  73.     if (*ln == '<') {
  74.         p=&ln[1];
  75.         pp=helpnm;
  76.         *pp=0;
  77.         while(*p && *p!='>') {
  78.             *pp=*p;
  79.             pp++;
  80.             p++;
  81.         }
  82.         *pp=0;
  83.         lstrip(helpnm);
  84.         if(!stricmp(helpnm,topic)) {
  85.             foundhelp++;
  86.             break;    /* Found our topic */
  87.         }
  88.     }
  89.     gethline(ln,helpfp);
  90.   }
  91.   temppause=pauser;
  92.   pauser=0;
  93.   if(usewindow) {
  94.         if(eof(helpfp)) return 0;
  95.         pos=tell(helpfp);
  96.         h=3;
  97.         w=18;
  98.         gethline(ln,helpfp);
  99.         if(*ln=='<') return 0;
  100.         while (*ln!='<') {
  101.           h++;
  102.           w=max(w,strlen(ln)+2);
  103.           gethline(ln,helpfp);
  104.         }
  105.         lseek(helpfp,pos,SEEK_SET);
  106.         curr_cursor(&xx,&yy);
  107.         wnd=establish_window(hx,hy,h,w);
  108.         set_title(wnd," Help! ");
  109.         set_colors(wnd,ALL,HBG,HFG,HINT);
  110.         display_window(wnd);
  111.         for(i=0;i<h-3;i++) {
  112.           gethline(ln,helpfp);
  113.           wprintf(wnd,ln);
  114.         }
  115.         wprintf(wnd," <<Continue>>");
  116.         genin(1,0,1,1,ANYNOECHO);
  117.         delete_window(wnd);
  118.         gprintf(0,"\x1b[%d;%dH",yy+1,xx+1);
  119.         cclose(helpfp);
  120.         return 1;
  121.   }
  122.   count=0;
  123.   while(!eof(helpfp)) {
  124.       gethline(ln,helpfp);
  125.       if(*ln=='<') break;
  126.       printm(convertstring(ln));
  127.       count++;
  128.       if(count>=(int)(user.length-2)) {
  129.         count=0;
  130.         say_prompt(18);
  131.         fossil(FLUSHOUT,0);
  132.         fossil(PURGEIN,0);
  133.         mmore = *genin(1,0,1,1,YESNOM);
  134.         say_prompt(276);
  135.         if (mmore == 'N') {
  136.            printm ("\n");
  137.            goto EndIt;
  138.         }
  139.       }
  140.   }
  141.   if(count) hitreturn();
  142. EndIt:
  143.   pauser=0;
  144.   if(!foundhelp && !count) {
  145.     if(!usewindow) say_prompt(1);
  146.     else {
  147.         curr_cursor(&xx,&yy);
  148.         _anymsg(" Sorry... "," No help available on that topic ");
  149.         genin(1,0,1,1,ANYNOECHO);
  150.         gprintf(0,"\x1b[%d;%dH",yy+1,xx+1);
  151.     }
  152.   }
  153.   pauser=temppause;
  154.   cclose(helpfp);
  155.   return count;
  156. }
  157.  
  158.  
  159. static void pascal gethline(char *lineh,int helpfp) {
  160.  
  161.   if(fgetsx(lineh,81,helpfp)==NULL)
  162.     strcpy(lineh,"<end>");
  163. }
  164.