home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume8 / libhoward / part08 / smpdtl.c < prev    next >
C/C++ Source or Header  |  1989-10-01  |  2KB  |  74 lines

  1. /*
  2.  * smpdtl - look up character in digit table
  3.  */
  4.  
  5. #ifndef lint
  6. static char _cpyrgt[] = "Copyright 1989 Howard Lee Gayle";
  7. #endif lint
  8.  
  9. /*
  10.  * This program is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License version 1,
  12.  * as published by the Free Software Foundation.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <howard/port.h>
  26. #include <howard/version.h>
  27.  
  28. MODVER ("@(#)$Header: smpdtl.c,v 1.6 89/08/14 17:37:31 howard Exp $");
  29.  
  30. #include <errno.h>
  31. #include <string.h>
  32. #include <howard/registers.i>
  33. #include <howard/simultipre.i>
  34. #include <howard/smp.h>
  35.  
  36. PUBLIC int smpdtl (c, dt)
  37. R2 rcharT  c;  /* Character to look up.*/
  38. R3 bStrT  *dt; /* Digit table.*/
  39.  
  40. /* Function:
  41.  *    Search digit table dt for character c.
  42.  * Algorithm:
  43.  *    Linear search.
  44.  * Returns:
  45.  *    Index into dt on success, -1 on error.
  46.  * Notes:
  47.  *    
  48.  */
  49. {
  50. R1 bStrT *p; /* Steps through dt.*/
  51.  
  52. for (p = dt; (NULBSTR != *p) && (NULCSTR == strchr ((cStrT) *p, c)); ++p)
  53.    ;
  54. return ((NULBSTR == *p) ? -1 : p - dt);
  55. }
  56.  
  57. #ifdef TEST
  58. #include <howard/usage.h>
  59.  
  60. MAINVER ("@(#)$Header: smpdtl.c,v 1.6 89/08/14 17:37:31 howard Exp $");
  61. USAGE ("");
  62.  
  63. #include <howard/malf.h>
  64.  
  65. PUBLIC int main ()
  66. {
  67. malf1 ("Testing done in a2smp");
  68.  
  69. #ifdef lint
  70. return (SUCCESS);
  71. #endif
  72. }
  73. #endif
  74.