/*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* fbc_keywds - Command line keyword look-up
*/
#include <stdio.h> /* fprintf(), fputs() */
#include <string.h> /* strlen(), strncasecmp() */
#include "fbc_error.h" /* Error reporting */
#include "fbc_keywds.h" /* Command line keyword look-up */
/*
* fbc_search_keywds()
*
* Given a table of recognized keywords and a user-submitted keyword
* string, search the table for a matching keyword. The search is
* case insensitive and unique abbreviations are accepted. Keyword
* table entries must be of uniform length and begin with a (char *)
* pointer to the keyword string.
*/
int
void *keywd_table, /* Table of recognized keywords */
int table_ent_len, /* Keyword table entry length */
const char * const keywd, /* Keyword string to look up */
const void **match_ent_ptr) /* Returned ptr to matching entry */
{
/*
* No matching keyword found yet
*/
*match_ent_ptr = NULL;
/*
* Examine each entry in the keyword table for a match
*/
for (table_ent_ptr = keywd_table;
*(char **)table_ent_ptr != NULL;
(void *)((char *)table_ent_ptr + table_ent_len)) {
if ((keywd_len <= table_keywd_len) &&
== 0)) {
if (*match_ent_ptr != NULL) {
}
if (keywd_len == table_keywd_len) {
return (FBC_SUCCESS); /* Exact match */
}
}
}
/*
* Return with a table entry for a unique abbreviation or with an error
*/
return (error_code);
} /* fbc_search_keywds() */
/*
* fbc_print_matching_keywds()
*
* Given a table of recognized keywords and an ambiguous keyword
* abbreviation (as flagged by fbc_search_keywds()), display on
* stderr all of the keywords in the table that match the
* abbreviation. Keyword table entries must be of uniform length and
* begin with a (char *) pointer to the keyword string.
*/
void
void *keywd_table, /* Table of recognized keywords */
int table_ent_len, /* Keyword table entry length */
const char * const keywd) /* Ambiguous keyword abbreviation */
{
/*
* Examine each entry in the keyword table for a match
*/
for (table_ent_ptr = keywd_table;
*(char **)table_ent_ptr != NULL;
(void *)((char *)table_ent_ptr + table_ent_len)) {
if ((keywd_len <= table_keywd_len) &&
== 0)) {
}
}
} /* fbc_print_matching_keywds() */
/* End of fbc_keywds.c */