libUPnP 1.14.19
strintmap.h
1/*******************************************************************************
2 *
3 * Copyright (c) 2000-2003 Intel Corporation
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * - Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * - Neither name of Intel Corporation nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 ******************************************************************************/
31
32#ifndef GENLIB_UTIL_STRINTMAP_H
33#define GENLIB_UTIL_STRINTMAP_H
34
35#include "upnputil.h"
36#include <stdlib.h>
37
38/* Util to map from a string to an integer and vice versa */
39
40typedef struct /* str_int_entry */
41{
42 const char *name; /* a value in string form */
43 int id; /* same value in integer form */
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/************************************************************************
51 * Function : map_str_to_int
52 *
53 * Parameters :
54 * IN const char* name ; string containing the name to be matched
55 * IN size_t name_len ; size of the string to be matched
56 * IN str_int_entry* table ; table of entries that need to be
57 * matched.
58 * IN int num_entries ; number of entries in the table that need
59 * to be searched.
60 * IN int case_sensitive ; whether the case should be case
61 * sensitive or not
62 *
63 * Description : Match the given name with names from the entries in the
64 * table. Returns the index of the table when the entry is found.
65 *
66 * Return : int ;
67 * index - On Success
68 * -1 - On failure
69 *
70 * Note :
71 ************************************************************************/
72int map_str_to_int(const char *name,
73 size_t name_len,
74 str_int_entry *table,
75 int num_entries,
76 int case_sensitive);
77
78/************************************************************************
79 * Function : map_int_to_str
80 *
81 * Parameters :
82 * IN int id ; ID to be matched
83 * IN str_int_entry* table ; table of entries that need to be
84 * matched.
85 * IN int num_entries ; number of entries in the table that need
86 * to be searched.
87 *
88 * Description : Returns the index from the table where the id matches
89 * the entry from the table.
90 *
91 * Return : int ;
92 *
93 * Note :
94 ************************************************************************/
95int map_int_to_str(int id, str_int_entry *table, int num_entries);
96
97#ifdef __cplusplus
98} /* extern C */
99#endif
100
101#endif /* GENLIB_UTIL_STRINTMAP_H */
Definition strintmap.h:41