home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* XBBS SOURCE CODE copyright (c) 1990 by M. Kimes */
- /* All Rights Reserved */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the in the file LICENSE.XBS. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* XBBS LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES */
- /* AT THE ADDRESS LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO USE */
- /* THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING */
- /* AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH */
- /* M. KIMES */
- /* */
- /* */
- /* You can contact M. Kimes at the following address: */
- /* */
- /* M. Kimes 1:380/16.0@FidoNet */
- /* 542 Merrick (318)222-3455 data */
- /* Shreveport, LA 71104 */
- /* */
- /* */
- /* Please feel free to contact me at any time to share your comments about */
- /* my software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
- /********************************************************************/
- /* XBBS 'named help' module */
- /********************************************************************/
-
- #include "msg.h"
- #include "xext.h"
- #include "awindow.h"
-
- #define HBG WHITE
- #define HFG BLACK
- #define HINT DIM
-
- #define TRUE 1
- #define FALSE 0
-
- static int h,w;
- static int hx=9,hy=9;
-
-
- void pascal gethline(char *lineh,int helpfp);
-
-
- int pascal find_help (char *hn,char *topic,char usewindow) { /* Filename, topic name */
-
- char ln[81];
- char helpnm[81];
- char *p,*pp;
- int helpfp,count,xx,yy,i;
- char temppause,mmore,foundhelp=0;
- long pos;
- WINDOW *wnd;
-
- helpfp=oopen(hn,O_RDONLY | O_BINARY | O_DENYNONE);
- if(helpfp==-1) {
- return -1;
- }
- gethline(ln,helpfp);
- while(!eof(helpfp)) {
- if (!strncmp(ln,"<end>",5)) {
- cclose(helpfp);
- return -1;
- }
- if (*ln == '<') {
- p=&ln[1];
- pp=helpnm;
- *pp=0;
- while(*p && *p!='>') {
- *pp=*p;
- pp++;
- p++;
- }
- *pp=0;
- lstrip(helpnm);
- if(!stricmp(helpnm,topic)) {
- foundhelp++;
- break; /* Found our topic */
- }
- }
- gethline(ln,helpfp);
- }
- temppause=pauser;
- pauser=0;
- if(usewindow) {
- if(eof(helpfp)) return 0;
- pos=tell(helpfp);
- h=3;
- w=18;
- gethline(ln,helpfp);
- if(*ln=='<') return 0;
- while (*ln!='<') {
- h++;
- w=max(w,strlen(ln)+2);
- gethline(ln,helpfp);
- }
- lseek(helpfp,pos,SEEK_SET);
- curr_cursor(&xx,&yy);
- wnd=establish_window(hx,hy,h,w);
- set_title(wnd," Help! ");
- set_colors(wnd,ALL,HBG,HFG,HINT);
- display_window(wnd);
- for(i=0;i<h-3;i++) {
- gethline(ln,helpfp);
- wprintf(wnd,ln);
- }
- wprintf(wnd," <<Continue>>");
- genin(1,0,1,1,ANYNOECHO);
- delete_window(wnd);
- gprintf(0,"\x1b[%d;%dH",yy+1,xx+1);
- cclose(helpfp);
- return 1;
- }
- count=0;
- while(!eof(helpfp)) {
- gethline(ln,helpfp);
- if(*ln=='<') break;
- printm(convertstring(ln));
- count++;
- if(count>=(int)(user.length-2)) {
- count=0;
- say_prompt(18);
- fossil(FLUSHOUT,0);
- fossil(PURGEIN,0);
- mmore = *genin(1,0,1,1,YESNOM);
- say_prompt(276);
- if (mmore == 'N') {
- printm ("\n");
- goto EndIt;
- }
- }
- }
- if(count) hitreturn();
- EndIt:
- pauser=0;
- if(!foundhelp && !count) {
- if(!usewindow) say_prompt(1);
- else {
- curr_cursor(&xx,&yy);
- _anymsg(" Sorry... "," No help available on that topic ");
- genin(1,0,1,1,ANYNOECHO);
- gprintf(0,"\x1b[%d;%dH",yy+1,xx+1);
- }
- }
- pauser=temppause;
- cclose(helpfp);
- return count;
- }
-
-
- static void pascal gethline(char *lineh,int helpfp) {
-
- if(fgetsx(lineh,81,helpfp)==NULL)
- strcpy(lineh,"<end>");
- }
-