123456789101112131415161718192021222324252627282930313233343536373839404142 |
- /*====================================================================*
- *
- * signed lookup (char const * name, struct _code_ const list [], size_t size);
- *
- * symbol.h
- *
- * search a name list and return the associated name; return the
- * corresponding code on success or -1 on failure; the search is
- * case insensitive;
- *
- * Motley Tools by Charles Maier;
- * Copyright (c) 2001-2006 by Charles Maier Associates;
- * Licensed under the Internet Software Consortium License;
- *
- *--------------------------------------------------------------------*/
- #ifndef LOOKUP_SOURCE
- #define LOOKUP_SOURCE
- #include <unistd.h>
- #include <string.h>
- #include "../tools/symbol.h"
- signed lookup (char const * name, struct _code_ const list [], size_t size)
- {
- struct _code_ const * item = list;
- if ((name) && (*name)) while ((unsigned)(item - list) < size)
- {
- if (!strcasecmp (item->name, name))
- {
- return (item->code);
- }
- item++;
- }
- return (-1);
- }
- #endif
|