home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / GLEN / IS.ZIP / IS_INPUT.C < prev    next >
C/C++ Source or Header  |  1988-10-26  |  1KB  |  39 lines

  1. /*
  2. ** is-input.c source file for 'input' functions of IS
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include "is.h"
  9. #define INBUFF 81
  10.  
  11. int is_input(char *fun, char *ret_str)
  12. {
  13.    char buffer[INBUFF];                        /* place to store input     */
  14.    static char prompt[INBUFF] = {"\0"};        /* place to store prompt    */
  15.    char *pbeg = 0, *pend = 0;                  /* prompt begin, prompt end */
  16.    char *pr = prompt;
  17.    char *instring;
  18.  
  19.    /* extract prompt from fun (if any) */
  20.    if((pbeg = strchr(fun, '(')) != NULL)       /* if there's a left paren  */
  21.    {
  22.        if((pend = strrchr(fun, ')')) != NULL)  /* and a right paren        */
  23.        {
  24.            ++pbeg;                         /* copy what's inside to prompt */
  25.            --pend;
  26.            while(pbeg <= pend)
  27.                *pr++ = *pbeg++;
  28.            *pr = '\0';
  29.            printf("\n%s", prompt);                     /* and show prompt  */
  30.        }
  31.    }
  32.    ret_str = gets(ret_str);
  33.    if(ret_str == NULL)
  34.        return(BAD);
  35.    ret_str = strlwr(ret_str);
  36.    return(OK);
  37. }
  38.  
  39.