home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PROCWRKB.ZIP / BENCH1.ZIP / BENCH / IOSUP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-16  |  1.7 KB  |  79 lines

  1. /* ==( bench/iosup.c )== */
  2. /* ----------------------------------------------- */
  3. /* Pro-C  Copyright (C) 1988 - 1990 Vestronix Inc. */
  4. /* Modification to this source is not supported    */
  5. /* by Vestronix Inc.                               */
  6. /*            All Rights Reserved                  */
  7. /* ----------------------------------------------- */
  8. /* Written   VvA     Aug-89                        */
  9. /* Modified  VvA  25-Jun-90  See comments below    */
  10. /* ----------------------------------------------- */
  11. /* %W%  (%H% %T%) */
  12.  
  13. /*
  14.  *  Modifications
  15.  *
  16.  *  25-Jun-90  VvA - added YYMMDD date to ints conversion
  17. */
  18.  
  19. /*  I/O Library  -  General support functions  */
  20.  
  21.  
  22. #include <stdio.h>
  23. #include <bench.h>
  24.  
  25.  
  26. PROTO (void stripright, (char *, int));
  27. PROTO (void date_vals, (char *, int *, int *, int *));
  28. PROTO (int  nummasklen, (char *));
  29.  
  30.  
  31. /*
  32.  *  Strip up to slen trailing spaces
  33. */
  34. void stripright(str, slen)
  35. char *str;
  36. int slen;
  37. {
  38.    int i;
  39.    for (i = slen-1; (i >= 0) && (str[i] == ' ') ; i--)
  40.       str[i]='\0';
  41. }
  42.  
  43.  
  44. /*
  45.  *  Find numerical field length including decimal from format mask
  46. */
  47. int nummasklen(msk)
  48. char *msk;
  49. {
  50.    int n, leng = 0;
  51.  
  52.    for (n = 0; n < strlen(msk); n++)
  53.       if ((msk[n] == 'z') || (msk[n] == 'Z') || (msk[n] == '9') || 
  54.           (msk[n] == '.') || (msk[n] == '$'))
  55.          leng++;
  56.    return(leng);
  57. }
  58.  
  59.  
  60.  
  61. /*
  62. *  Obtain year, month, day values from PRO-C YYMMDD string
  63. */
  64. void date_vals(datstr, nyr, nmo, ndy)
  65. char *datstr;
  66. int *nyr, *nmo, *ndy;
  67. {
  68.     char nstr[3];
  69.  
  70.     nstr[2] = '\0';
  71.     strncpy(nstr, datstr, 2);
  72.     *nyr = atoi(nstr) + 1900;
  73.     strncpy(nstr, &datstr[2], 2);
  74.     *nmo = atoi(nstr);
  75.     strncpy(nstr, &datstr[4], 2);
  76.     *ndy = atoi(nstr);
  77. }
  78.  
  79.