home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / network / amigaelm.lzh / getline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-16  |  17.6 KB  |  655 lines

  1. #include "prefs.h"
  2. #ifdef LATTICE
  3. #include <dos.h>
  4. #endif
  5. #ifdef DICE
  6. #include <libraries/dos.h>
  7. #endif
  8.  
  9.  
  10.  
  11. Prototype BOOL getline(FILE *,char *,long *);
  12. Prototype void removeCR(char *);
  13. Prototype long read_home_box(void);
  14. Prototype BOOL get_config_entries(void);
  15. Prototype char *firstnwsp(char *);
  16.  
  17.  
  18.  
  19. struct FlagItem {
  20.   char *MsgID;
  21.   StatusFlag Stat;
  22. };
  23.  
  24.  
  25.  
  26. long
  27. read_home_box(void)
  28. {
  29.     FILE *fp;
  30.     struct MailItem *I;
  31.     char Line[MAX_LINELENGTH];
  32.     register char *ptr;
  33.     char **last_data = NULL;
  34.     register int i,c;
  35.     long len,pos;
  36.     BOOL InHeader = FALSE;
  37.     static BOOL FirstAccess = TRUE;
  38.     static struct FlagItem *flgs;
  39.     struct MailItem *act=NULL,*last;
  40.     static int OldMaxArticle = 0;
  41.     char TitleString[1024];
  42.  
  43. #ifdef DEBUG
  44.       fprintf(stderr,"read_home_box: %s\n",FolderName);
  45. #endif
  46.  
  47.     if (FirstAccess) {
  48. #ifdef DEBUG
  49.       fprintf(stderr," first attempt to read folder\n");
  50. #endif
  51.       OldMaxArticle = 0;
  52.       FirstAccess = FALSE;
  53.       flgs = NULL;
  54.     }
  55.     else {
  56. #ifdef DEBUG
  57.       fprintf(stderr," keep old msg-ids");
  58. #endif
  59.       if (flgs) {
  60. #ifdef DEBUG
  61.         fprintf(stderr,", clear old");
  62. #endif
  63.         for(i=0;i<OldMaxArticle;i++) {
  64.           if (flgs[i].MsgID)
  65.             free(flgs[i].MsgID);
  66.         }
  67.         free(flgs);
  68. #ifdef DEBUG
  69.         fprintf(stderr," (ok)");
  70. #endif
  71.       }
  72.       if (flgs=malloc(MaxArticle*sizeof(struct FlagItem))) {
  73. #ifdef DEBUG
  74.         fprintf(stderr,", save new");
  75. #endif
  76.         OldMaxArticle = MaxArticle;
  77.         for(i=0;i<MaxArticle;i++) {
  78.           I = i_th(i+1);
  79.           if (flgs[i].MsgID = malloc(strlen(I->MessageID)+1)) {
  80.             strcpy(flgs[i].MsgID,I->MessageID);
  81.             flgs[i].Stat = I->Status;
  82.           }
  83.         }
  84. #ifdef DEBUG
  85.         fprintf(stderr," (ok)");
  86. #endif
  87.       }
  88. #ifdef DEBUG
  89.       fprintf(stderr,"\n");
  90. #endif
  91.     }
  92.  
  93.     /* free mailbox */
  94.     while(MailList) {
  95. #ifdef DEBUG
  96.       fprintf(stderr,"Freeing one old mailbox item...");
  97. #endif
  98.       I = MailList;
  99.       MailList = MailList->next;
  100.       free(I);
  101. #ifdef DEBUG
  102.       fprintf(stderr,"ok.\n");
  103. #endif
  104.     }
  105.  
  106.     MaxArticle=0;
  107.  
  108.     if ((fp=OpenHomeBox())==NULL)
  109.         return(0L);
  110.  
  111.     while (getline(fp,Line,&pos)) {
  112. #ifdef DEBUG
  113. /*      fprintf(stderr," line: %s\n",Line);*/
  114. #endif
  115.       if (InHeader) {
  116.         act->TotalLines++;
  117.         if (!act->From && !strnicmp(Line,"From:",5)) {
  118.             ptr = delete_wspaces_begin(Line+5);
  119.             delete_wspaces_end(ptr);
  120.             act->FromName = parse_arpa_from(ptr);
  121.             if (act->From = strdup(ptr))
  122.               last_data = &act->From;
  123.             else
  124.               last_data = NULL;
  125.         }
  126.         else if (!act->MessageID && !strnicmp(Line,"Message-Id:",11)) {
  127.             ptr = delete_wspaces_begin(Line+11);
  128.             delete_wspaces_end(ptr);
  129.             if (act->MessageID = strdup(ptr))
  130.               last_data = &act->MessageID;
  131.             else
  132.               last_data = NULL;
  133.         }
  134.         else if (!act->Cc && !strnicmp(Line,"Cc:",3)) {
  135.             ptr = delete_wspaces_begin(Line+3);
  136.             delete_wspaces_end(ptr);
  137.             if (act->Cc=strdup(ptr))
  138.               last_data = &act->Cc;
  139.             else
  140.               last_data = NULL;
  141.         }
  142.         else if (!act->Bcc && !strnicmp(Line,"Bcc:",4)) {
  143.             ptr = delete_wspaces_begin(Line+4);
  144.             delete_wspaces_end(ptr);
  145.             if (act->Bcc=strdup(ptr))
  146.               last_data = &act->Bcc;
  147.             else
  148.               last_data = NULL;
  149.         }
  150.         else if (!act->Date && !strnicmp(Line,"Date:",5)) {
  151.             register char *p;
  152.             ptr = delete_wspaces_begin(Line+5);
  153.             delete_wspaces_end(ptr);
  154.             if (*ptr<'0' || *ptr>'9') {           /* if exists name of day, */
  155.               while (*ptr!=' ')                   /* skip it */
  156.                 ptr++;
  157.             }
  158.             while (*ptr==' ')                     /* skip spaces */
  159.               ptr++;
  160.             p=ptr;
  161.             while (*p!=' ')                       /* skip day */
  162.               p++;
  163.             while (*p==' ')                       /* skip spaces */
  164.               p++;
  165.             while (*p!=' ')                       /* skip month */
  166.               p++;
  167.             *p='\0';
  168.             if (act->Date=malloc(strlen(ptr)+1)) {
  169.               strcpy(act->Date,ptr);
  170.               if (act->Date[2]==' ') {    /* e.g. "13 Aug" */
  171.                 act->Date[2]=act->Date[5];
  172.                 act->Date[5]=act->Date[1];
  173.                 act->Date[1]=act->Date[4];
  174.                 act->Date[4]=act->Date[0];
  175.                 act->Date[0]=act->Date[3];
  176.                 act->Date[3]=' ';
  177.               }
  178.               else if (act->Date[1]==' ') {    /* e.g. "7 Sep" */
  179.                 act->Date[1]=act->Date[3];
  180.                 act->Date[3]=act->Date[0];
  181.                 act->Date[0]=act->Date[2];
  182.                 act->Date[2]=act->Date[4];
  183.                 act->Date[4]=act->Date[3];
  184.                 act->Date[3]=' ';
  185.               }
  186.             }
  187.             last_data = NULL;
  188.         }
  189.         else if (!act->RR_To && !strnicmp(Line,"Return-Receipt-To:",18)) {
  190.             ptr = delete_wspaces_begin(Line+18);
  191.             delete_wspaces_end(ptr);
  192.             if (act->RR_To=strdup(ptr))
  193.               last_data = &act->RR_To;
  194.             else
  195.               last_data = NULL;
  196.         }
  197.         else if (!act->RV_To && !strnicmp(Line,"Return-View-To:",15)) {
  198.             ptr = delete_wspaces_begin(Line+15);
  199.             delete_wspaces_end(ptr);
  200.             if (act->RV_To=strdup(ptr))
  201.               last_data = &act->RV_To;
  202.             else
  203.               last_data = NULL;
  204.         }
  205.         else if (!act->To && !strnicmp(Line,"To:",3)) {
  206.             ptr = delete_wspaces_begin(Line+3);
  207.             delete_wspaces_end(ptr);
  208.             act->ToName = parse_arpa_from(ptr);
  209.             if (act->To=strdup(ptr))
  210.               last_data = &act->To;
  211.             else
  212.               last_data = NULL;
  213.         }
  214.         else if (!act->ReplyTo && !strnicmp(Line,"Reply-To:",9)) {
  215.             ptr = delete_wspaces_begin(Line+9);
  216.             delete_wspaces_end(ptr);
  217.             if (act->ReplyTo=strdup(ptr))
  218.               last_data = &act->ReplyTo;
  219.             else
  220.               last_data = NULL;
  221.         }
  222.         else if (!act->Subject && !strnicmp(Line,"Subject:",8)) {
  223.             ptr = delete_wspaces_begin(Line+8);
  224.             delete_wspaces_end(ptr);
  225.             if (act->Subject=strdup(ptr))
  226.               last_data = &act->Subject;
  227.             else
  228.               last_data = NULL;
  229.         }
  230.         else if (!strnicmp(Line,"Priority:",9)) {
  231.             act->Urgent = 1;
  232.             last_data = NULL;
  233.         }
  234.         else if (!strnicmp(Line,"X-Status:",9)) {
  235.             while (c=*ptr++) {
  236.                 switch (c) {
  237.                     case 'O' :act->Status |= OLD;       break;
  238.                     case 'R' :act->Status |= READ;      break;
  239.                     case 'L' :act->Status |= LOGGED;    break;
  240.                     case 'A' :act->Status |= ANSWERED;  break;
  241.                     case 'F' :act->Status |= FORWARDED; break;
  242.                     case 'B' :act->Status |= BOUNCED;   break;
  243.                 }
  244.             }
  245.             last_data = NULL;
  246.             act->OldStatus = act->Status;
  247.         }
  248.         else if (last_data && strlen(Line) && (Line[0]==' ' || Line[0]=='\t')) {
  249.             ptr = delete_wspaces_end(Line+1);
  250.             *last_data = realloc(*last_data,strlen(ptr)+3+strlen(*last_data));
  251.             strcat(*last_data,"\n\t");
  252.             strcat(*last_data,ptr);
  253.         }
  254.         else if (!strlen(Line)) {
  255.           act->TextStart=ftell(fp);
  256.           InHeader = FALSE;
  257.           last_data = NULL;
  258.         }
  259.         else
  260.           last_data = NULL;
  261.       }
  262.       else {
  263.         if (!strncmp(Line,"From ",5)) {
  264.           last_data = NULL;
  265.           InHeader = TRUE;
  266.           MaxArticle++;
  267.  
  268.           last = act;
  269.           if (!(act=malloc(sizeof(struct MailItem))))
  270.             clean_exit(20);
  271.  
  272.           setmem(act,sizeof(struct MailItem),0);
  273.  
  274.           if (ReverseSorting) {
  275.             act->next = MailList;
  276.             MailList = act;
  277.           }
  278.           else {
  279.             if (last)
  280.               last->next = act;
  281.             if (!MailList)
  282.               MailList = act;
  283.           }
  284.  
  285.           act->SignatureStart=0;
  286.           act->ArtikelStart=pos;
  287.           if (last) {
  288. #ifdef DEBUG
  289.       fprintf(stderr,"Aha, (MaxArticle>1): pos=%ld, MaxArt=%d\n",pos,MaxArticle);
  290. #endif
  291. #ifdef DEBUG
  292.             I = i_th(MaxArticle-1);
  293.             if (I!=last)
  294.               fprintf(stderr,"Komisch, (I!=last) [%s,%s]\n",I->From,last->From);
  295. #endif
  296.             last->ArtikelEnd=pos-1;
  297.             if (last->SignatureStart==0)
  298.               last->SignatureStart=last->ArtikelEnd;
  299. #ifdef DEBUG
  300.             fprintf(stderr,"I->ArtikelEnd[%d]=%ld (%ld)\n",MaxArticle-1,I->ArtikelEnd,last->ArtikelEnd);
  301. #endif
  302.           }
  303.           act->TextStart=pos;
  304.           act->TotalLines++;
  305.  
  306.           sprintf(TitleString,"Reading in %s, message: %d",FolderName,MaxArticle);
  307.           SetScreenTitle(TitleString);
  308.         }
  309.         else if (!strcmp(Line,"-- ")) {     /* signature found  */
  310.           act->SignatureStart=pos;
  311.           act->Lines++;
  312.           act->TotalLines++;
  313.         }
  314.         else {
  315.           act->Lines++;
  316.           act->TotalLines++;
  317.         }
  318.       }
  319.     } /* while (getline)  */
  320.  
  321. #ifdef DEBUG
  322.       fprintf(stderr," closing act");
  323. #endif
  324.  
  325.     fseek(fp,0L,2);  /* An das Ende positionieren */
  326.     len=ftell(fp);
  327.     act->ArtikelEnd=len-1;
  328.     if (act->SignatureStart==0)
  329.       act->SignatureStart=act->ArtikelEnd;
  330.     CloseHomeBox(fp);
  331.  
  332. /*
  333.     if (ReverseSorting) {
  334.       for(i=0;i<(MaxArticle/2);i++) {
  335.         I = Incoming[i];
  336.         Incoming[i] = Incoming[MaxArticle-i-1];
  337.         Incoming[MaxArticle-i-1] = I;
  338.       }
  339.     }
  340. */
  341.  
  342. #ifdef DEBUG
  343.     fprintf(stderr," compare old and new message-ids\n");
  344. #endif
  345.     for(I=MailList;I;I=I->next) {
  346.       for(i=0;i<OldMaxArticle;i++) {
  347.         if (flgs[i].MsgID && I->MessageID) {
  348.           if (strcmp(flgs[i].MsgID,I->MessageID)==0) {
  349.             I->Status = flgs[i].Stat;
  350.           }
  351.         }
  352.       }
  353.     }
  354.  
  355. #ifdef DEBUG
  356.     fprintf(stderr,"Checking mailbox contents:\n");
  357.     for(I=MailList;I;I=I->next) {
  358.       fprintf(stderr,"  %s (%ld, %ld, %ld, %ld - %ld, %ld)\n",I->From,
  359.         I->ArtikelStart,I->TextStart,I->SignatureStart,I->ArtikelEnd,I->Lines,I->TotalLines);
  360.     }
  361. #endif
  362.  
  363. #ifdef DEBUG
  364.       fprintf(stderr," got %d message(s) from folder %s (%ld)\n",MaxArticle,FolderName,len);
  365. #endif
  366.     return(len);
  367. }
  368.  
  369.  
  370.  
  371. BOOL
  372. get_config_entries(void)
  373. {
  374.     FILE *fp;
  375.     char *ptr;
  376.     char line[MAX_LINELENGTH];
  377.  
  378.     if (getenv("Pager")) {
  379.       strcpy(line,getenv("Pager"));
  380.       if (strlen(line))
  381.         Pager = strdup(line);
  382.     }
  383.  
  384.     if (getenv("Editor")) {
  385.       strcpy(line,getenv("Editor"));
  386.       if (strlen(line))
  387.         MailEditor = strdup(line);
  388.     }
  389.  
  390.     if (getenv("Shell")) {
  391.       strcpy(line,getenv("Shell"));
  392.       if (strlen(line))
  393.         Shell = strdup(line);
  394.     }
  395.  
  396.     if (getenv("RealName")) {
  397.       strcpy(line,getenv("RealName"));
  398.       if (strlen(line))
  399.         RealName = strdup(line);
  400.     }
  401.  
  402.     if (getenv("HostName")) {
  403.       strcpy(line,getenv("HostName"));
  404.       if (strlen(line))
  405.         HostName = strdup(line);
  406.     }
  407.  
  408.     if (getenv("DomainName")) {
  409.       strcpy(line,getenv("DomainName"));
  410.       if (strlen(line))
  411.         DomainName = strdup(line);
  412.     }
  413.  
  414.     if (!UserName && getenv("UserName")) {
  415.       strcpy(line,getenv("UserName"));
  416.       if (strlen(line))
  417.         UserName = strdup(line);
  418.     }
  419.  
  420.     if (!(fp=fopen(UULIB_CONFIG,"r"))) {
  421.       fprintf(stderr,"elm: cannot open %s\n",UULIB_CONFIG);
  422.       return(FALSE);
  423.     }
  424.  
  425.     while(fgets(line,MAX_LINELENGTH-1,fp)) {
  426.       removeCR(line);
  427.  
  428.       ptr=firstnwsp(line);
  429.       ptr = delete_wspaces_begin(ptr);
  430.       delete_wspaces_end(ptr);
  431.  
  432.       if (strlen(ptr)>=2 && *ptr=='"' && lastch(ptr)=='"') {
  433.         ptr++;
  434.         ptr[strlen(ptr)-1] = '\0';
  435.       }
  436.  
  437.       if (strlen(ptr)) {
  438.         if (!strnicmp(line,"UserName",8)) {
  439.           if (!UserName)         /* if not already set */
  440.             UserName = strdup(ptr);
  441.         }
  442.         else if (!strnicmp(line,"NodeName",8)) {
  443.           if (!HostName)         /* if not already set */
  444.             HostName = strdup(ptr);
  445.         }
  446.         else if (!strnicmp(line,"DomainName",10))
  447.           if (!DomainName)       /* if not already set */
  448.             DomainName = strdup(ptr);
  449.       }
  450.     }
  451.     fclose(fp);
  452.  
  453.     if (!UserName || !HostName || !DomainName) {
  454.       fprintf(stderr,"elm: %s incomplete\n",UULIB_CONFIG);
  455.       return FALSE;
  456.     }
  457.  
  458.     strcpy(line,UULIB);
  459.     strcat(line,UserName);
  460.     strcat(line,ELM_RC);
  461.     if (!(fp=fopen(line,"r"))) {
  462.       strcpy(line,UULIB);
  463.       strcat(line,ELM_RC);
  464.       if (!(fp=fopen(line,"r"))) {
  465.         fprintf(stderr,"elm: cannot open %s\n",ELM_RC);
  466.         return(FALSE);
  467.       }
  468.     }
  469.  
  470.     while(fgets(line,MAX_LINELENGTH-1,fp)) {
  471.       removeCR(line);
  472.  
  473.       ptr=firstnwsp(line);
  474.       ptr = delete_wspaces_begin(ptr);
  475.       delete_wspaces_end(ptr);
  476.  
  477.       if (strlen(ptr)>=2 && *ptr=='"' && lastch(ptr)=='"') {
  478.         ptr++;
  479.         ptr[strlen(ptr)-1] = '\0';
  480.       }
  481.  
  482.       if (strlen(ptr)) {
  483.         if (!strnicmp(line,"Screen-Width",12))
  484.           Screen_Width = atoi(ptr);
  485.  
  486.         else if (!strnicmp(line,"Screen-Height",13))
  487.           Screen_Height = atoi(ptr);
  488.  
  489.         else if (!strnicmp(line,"Screen-Interlace",16))
  490.           Screen_Interlace = (!strnicmp(ptr,"Yes",3));
  491.  
  492.         else if (!strnicmp(line,"AnswerReturnReceipt",19))
  493.           ReturnReceipt = (!strnicmp(ptr,"Yes",3));
  494.  
  495.         else if (!strnicmp(line,"AnswerReturnView",16))
  496.           ReturnView = (!strnicmp(ptr,"Yes",3));
  497.  
  498.         else if (!strnicmp(line,"RequestReturnReceipt",20))
  499.           WantReturn = (!strnicmp(ptr,"Yes",3));
  500.  
  501.         else if (!strnicmp(line,"RequestReturnView",17))
  502.           WantView = (!strnicmp(ptr,"Yes",3));
  503.  
  504.         else if (!strnicmp(line,"ShowFullHeader",14))
  505.           ShowHeader = (!strnicmp(ptr,"Yes",3));
  506.  
  507.         else if (!strnicmp(line,"ShowSignature",13))
  508.           ShowSig = (!strnicmp(ptr,"Yes",3));
  509.  
  510.         else if (!strnicmp(line,"AlwaysKeep",10))
  511.           AlwaysKeep = (!strnicmp(ptr,"Yes",3));
  512.  
  513.         else if (!strnicmp(line,"AlwaysDelete",12))
  514.           AlwaysDelete = (!strnicmp(ptr,"Yes",3));
  515.  
  516.         else if (!strnicmp(line,"KeepBackup",10))
  517.           KeepBackup = (!strnicmp(ptr,"Yes",3));
  518.  
  519.         else if (!strnicmp(line,"SendmailVersion",15)) {
  520.           if (!strnicmp(ptr,"Feulner",7))
  521.             SendmailVersion = SM_FEULNER;
  522.           else if (!strnicmp(ptr,"Dillon",6))
  523.             SendmailVersion = SM_DILLON;
  524.           else
  525.             SendmailVersion = SM_OTHER;
  526.         }
  527.         else if (!strnicmp(line,"ReceivedFolder",14))
  528.           ReceivedFolder = strdup(ptr);
  529.  
  530.         else if (!strnicmp(line,"SentArchive",11))
  531.           SentArchive = strdup(ptr);
  532.  
  533.         else if (!strnicmp(line,"Editor",6)) {
  534.           if (MailEditor) free(MailEditor);
  535.           MailEditor = strdup(ptr);
  536.         }
  537.         else if (!strnicmp(line,"FullName",8)) {
  538.           if (RealName) free(RealName);
  539.           RealName = strdup(ptr);
  540.         }
  541.         else if (!strnicmp(line,"ReplyIntroduction",17))
  542.           ReplyIntro = strdup(ptr);
  543.  
  544.         else if (!strnicmp(line,"ForwardIntroduction",19))
  545.           ForwardIntro = strdup(ptr);
  546.  
  547.         else if (!strnicmp(line,"PrefixString",12))
  548.           PrefixString = strdup(ptr);
  549.  
  550.         else if (!strnicmp(line,"Color",5))
  551.           ColorData = strdup(ptr);
  552.  
  553.         else if (!strnicmp(line,"Buffers",7)) {
  554.           FileBufferSize = atol(ptr);
  555.           if (FileBufferSize<1024L)
  556.             FileBufferSize = 1024L;
  557.         }
  558.         else if (!strnicmp(line,"StdFontName",11))
  559.           StdFontName = strdup(ptr);
  560.  
  561.         else if (!strnicmp(line,"StdFontSize",11))
  562.           StdFontSize = atoi(ptr);
  563.  
  564.         else if (!strnicmp(line,"PagerFontName",13))
  565.           PagerFontName = strdup(ptr);
  566.  
  567.         else if (!strnicmp(line,"PagerFontSize",13))
  568.           PagerFontSize = atoi(ptr);
  569.  
  570.         else if (!strnicmp(line,"IntuiFontName",13))
  571.           IntuiFontName = strdup(ptr);
  572.  
  573.         else if (!strnicmp(line,"IntuiFontSize",13))
  574.           IntuiFontSize = atoi(ptr);
  575.  
  576.         else if (!strnicmp(line,"Pager",5)) {
  577.           if (Pager) free(Pager);
  578.           if (stricmp(ptr,"builtin"))
  579.             Pager = strdup(ptr);
  580.           else
  581.             Pager = NULL;
  582.         }
  583.         else if (!strnicmp(line,"UseOwnScreen",12))
  584.           UseOwnScreen = (!strnicmp(ptr,"Yes",3));
  585.  
  586.         else if (!strnicmp(line,"ShanghaiWindows",15))
  587.           ShanghaiWindows = (!strnicmp(ptr,"Yes",3));
  588.  
  589.         else if (!strnicmp(line,"ReverseSorting",14))
  590.           ReverseSorting = (!strnicmp(ptr,"Yes",3));
  591.  
  592.         else if (!strnicmp(line,"WorkbenchToFront",16))
  593.           WBToFront = (!strnicmp(ptr,"Yes",3));
  594.  
  595.         else if (!strnicmp(line,"UseCmdClearKludge",17))
  596.           UseCmdClearKludge = (!strnicmp(ptr,"Yes",3));
  597.  
  598.         else if (!strnicmp(line,"PubScreenName",13))
  599.           PubScreenName = strdup(ptr);
  600.  
  601.         else if (!strnicmp(line,"Shell",5)) {
  602.           if (Shell) free(Shell);
  603.           Shell = strdup(ptr);
  604.         }
  605.         else if (!strnicmp(line,"PipeDefault",11))
  606.           PipeDefault = strdup(ptr);
  607.  
  608.       }
  609.     }
  610.     fclose(fp);
  611.  
  612.     if (!SendmailVersion || !PrefixString || !RealName || !ReceivedFolder) {
  613.       fprintf(stderr,"elm: %s incomplete\n",ELM_RC);
  614.       return FALSE;
  615.     }
  616.  
  617.     return TRUE;
  618. }
  619.  
  620.  
  621.  
  622. char *
  623. firstnwsp(char *s)
  624. {
  625.     while(*s!='\0' && *s!=' ' && *s!='\t')
  626.         s++;
  627.     while((*s != '\0') && (*s == ' ' || *s == '\t'))
  628.         s++;
  629.     return s;
  630. }
  631.  
  632.  
  633.  
  634. BOOL
  635. getline(FILE *fp,char *s,long *p)
  636. {
  637.   *p=ftell(fp);
  638.   s[MAX_LINELENGTH-1] = '\n';
  639.   if (fgets(s,MAX_LINELENGTH-1,fp)) {
  640.     *strchr(s,'\n')='\0';
  641.     return(TRUE);
  642.   }
  643.   return(FALSE);
  644. }
  645.  
  646.  
  647.  
  648. void
  649. removeCR(char *s)
  650. {
  651.   if (s=strchr(s,'\n'))
  652.     *s='\0';
  653. }
  654.  
  655.