lookup.c.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. lookup.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='LocalDevices.c.html' title=' LocalDevices.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='mac2pw.c.html' title=' mac2pw.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * signed lookup (char const * name, struct _code_ const list [], size_t size);
  24. *
  25. * symbol.h
  26. *
  27. * search a name list and return the associated name; return the
  28. * corresponding code on success or -1 on failure; the search is
  29. * case insensitive;
  30. *
  31. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  32. * Copyright (c) 2001-2006 by Charles Maier Associates;
  33. * Licensed under the Internet Software Consortium License;
  34. *
  35. *--------------------------------------------------------------------*/
  36. #ifndef LOOKUP_SOURCE
  37. #define LOOKUP_SOURCE
  38. #include &lt;unistd.h&gt;
  39. #include &lt;string.h&gt;
  40. #include &quot;../tools/symbol.h&quot;
  41. signed lookup (char const * name, struct _code_ const list [], size_t size)
  42. {
  43. struct _code_ const * item = list;
  44. if ((name) &amp;&amp; (*name)) while ((unsigned)(item - list) &lt; size)
  45. {
  46. if (!strcasecmp (item-&gt;name, name))
  47. {
  48. return (item-&gt;code);
  49. }
  50. item++;
  51. }
  52. return (-1);
  53. }
  54. #endif
  55. </pre>
  56. <div class='footerlink'>
  57. [<a href='LocalDevices.c.html' title=' LocalDevices.c '>PREV</a>]
  58. [<a href='toolkit.html' title=' Index '>HOME</a>]
  59. [<a href='mac2pw.c.html' title=' mac2pw.c '>NEXT</a>]
  60. </div>
  61. </body>
  62. </html>