home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / or / or_up_bnds.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-18  |  1.5 KB  |  76 lines

  1. /* or_up_bnds.c: routine to check length of O/R components fit in with standards */
  2.  
  3. # ifndef lint
  4. static char Rcsid[] = "@(#)$Header: /xtel/pp/pp-beta/Lib/or/RCS/or_up_bnds.c,v 6.0 1991/12/18 20:23:08 jpo Rel $";
  5. # endif
  6.  
  7. /*
  8.  * $Header: /xtel/pp/pp-beta/Lib/or/RCS/or_up_bnds.c,v 6.0 1991/12/18 20:23:08 jpo Rel $
  9.  *
  10.  * $Log: or_up_bnds.c,v $
  11.  * Revision 6.0  1991/12/18  20:23:08  jpo
  12.  * Release 6.0
  13.  *
  14.  */
  15.  
  16. #include "or.h"
  17.  
  18. static int get_ub(or, ubs)
  19. OR_ptr    or;
  20. OR_upperbound    *ubs;
  21. {
  22.     int    i;
  23.     
  24.     for (i = 0; ubs[i].or_type != 0; i++) {
  25.         if (ubs[i].or_type == or->or_type)
  26.             return ubs[i].or_upperbound;
  27.     }
  28.     return 0;
  29. }
  30.  
  31. int or_check_upper (or, ubs)
  32. OR_ptr    or;
  33. OR_upperbound    *ubs;
  34. {
  35.     int    ub;
  36.  
  37.     if (or == NULLOR)
  38.         return NOTOK;
  39.  
  40.     if ((ub = get_ub(or, ubs)) != -1) {
  41.         if (ub == 0) {
  42.             (void) or_lose("Illegal x400 O/R component '%s'",
  43.                 or_type2name(or->or_type));
  44.             return NOTOK;
  45.         }
  46.         if (ub < (int) strlen(or->or_value)) {
  47.             (void) or_lose ("Exceeds the upperbound on length of '%s' components (%d chars)",
  48.                  or_type2name(or->or_type),
  49.                  ub);
  50.             return NOTOK;
  51.         }
  52.     }
  53.  
  54.     if (or->or_type == OR_DD &&
  55.         (int) strlen (or->or_ddname) > OR_UB_DDA_TYPE) {
  56.         (void) or_lose("'%s' exceeds the upperbound on length of domain defined types (%d chars)",
  57.             or->or_ddname, OR_UB_DDA_TYPE);
  58.         return NOTOK;
  59.     }
  60.  
  61.     return OK;
  62. }
  63.  
  64. int or_chk_ubs (or, ubs)
  65. OR_ptr    or;
  66. OR_upperbound    *ubs;
  67. {
  68.  
  69.     while (or != NULLOR) {
  70.         if (or_check_upper(or, ubs) == NOTOK)
  71.             return NOTOK;
  72.         or = or->or_next;
  73.     }
  74.     return OK;
  75. }
  76.