home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Misc / c / Validation < prev   
Encoding:
Text File  |  1993-05-11  |  1.8 KB  |  55 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Misc.Validation.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.01 (12 Dec 1992)
  14.     Purpose: Scanning of validation strings for various fields
  15. */
  16.  
  17. #include "Core.h"
  18.  
  19.  
  20. extern int Validation_ScanString(char *string, char tag)
  21. {
  22.   register int  index;
  23.   register char trytag;
  24.  
  25.   if ((int) string <= 0 || string[0] < 32)  /* Invalid pointer/NULL string   */
  26.     return(0);
  27.  
  28.   if (tag >= 'a' && tag <= 'z')
  29.     tag &= 0xdf;                            /* Force to uppercase to compare */
  30.  
  31.   index = -1;
  32.   while (TRUE)
  33.   {
  34.     if (string[++index] < 32)               /* End of string-still not found */
  35.       return(0);
  36.  
  37.     if (string[index] >= 'a' && string[index] <= 'z')
  38.       trytag = string[index] & 0xdf;
  39.     else
  40.       trytag = string[index];               /* Force to uppercase to compare */
  41.  
  42.     if (trytag == tag)
  43.     {
  44.       if (string[index + 1] < 32)
  45.         return(0);                         /* No chars following tag!        */
  46.       else
  47.         return(index + 1);                 /* Found, so return index         */
  48.     }
  49.  
  50.     while (string[index] != ';')            /* Scan for ';' - item seperator */
  51.       if (string[++index] < 32)                                 /* not found */
  52.         return(0);
  53.   }
  54. }
  55.