JasPer  4.2.4
jas_tvp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2002 Michael David Adams.
3  * All rights reserved.
4  */
5 
6 /* __START_OF_JASPER_LICENSE__
7  *
8  * JasPer License Version 2.0
9  *
10  * Copyright (c) 2001-2006 Michael David Adams
11  * Copyright (c) 1999-2000 Image Power, Inc.
12  * Copyright (c) 1999-2000 The University of British Columbia
13  *
14  * All rights reserved.
15  *
16  * Permission is hereby granted, free of charge, to any person (the
17  * "User") obtaining a copy of this software and associated documentation
18  * files (the "Software"), to deal in the Software without restriction,
19  * including without limitation the rights to use, copy, modify, merge,
20  * publish, distribute, and/or sell copies of the Software, and to permit
21  * persons to whom the Software is furnished to do so, subject to the
22  * following conditions:
23  *
24  * 1. The above copyright notices and this permission notice (which
25  * includes the disclaimer below) shall be included in all copies or
26  * substantial portions of the Software.
27  *
28  * 2. The name of a copyright holder shall not be used to endorse or
29  * promote products derived from the Software without specific prior
30  * written permission.
31  *
32  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
33  * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
34  * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
35  * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
37  * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
38  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
39  * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
40  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
41  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
42  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
43  * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
44  * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
45  * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
46  * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
47  * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
48  * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
49  * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
50  * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
51  * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
52  * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
53  * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
54  * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
55  * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
56  * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
57  * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
58  *
59  * __END_OF_JASPER_LICENSE__
60  */
61 
67 #ifndef JAS_TVP_H
68 #define JAS_TVP_H
69 
70 /******************************************************************************\
71 * Includes.
72 \******************************************************************************/
73 
74 /* The configuration header file should be included first. */
75 #include <jasper/jas_config.h>
76 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif
80 
86 /******************************************************************************\
87 * Types.
88 \******************************************************************************/
89 
94 typedef struct {
95 
96  int id;
97  /* The ID for the tag. */
98 
99  const char *name;
100  /* The name of the tag. */
101 
102 } jas_taginfo_t;
103 
108 typedef struct {
109 
110  char *buf;
111  /* The parsing buffer. */
112 
113  char *tag;
114  /* The current tag name. */
115 
116  const char *val;
117  /* The current value. */
118 
119  char *pos;
120  /* The current position in the parsing buffer. */
121 
123 
124 /******************************************************************************\
125 * Tag information functions.
126 \******************************************************************************/
127 
132 JAS_ATTRIBUTE_PURE
133 JAS_EXPORT
134 const jas_taginfo_t *jas_taginfos_lookup(const jas_taginfo_t *taginfos,
135  const char *name);
136 
147 JAS_ATTRIBUTE_PURE
148 JAS_EXPORT
149 const jas_taginfo_t *jas_taginfo_nonull(const jas_taginfo_t *taginfo);
150 
151 /******************************************************************************\
152 * Tag-value parser functions.
153 \******************************************************************************/
154 
159 JAS_EXPORT
160 jas_tvparser_t *jas_tvparser_create(const char *s);
161 
166 JAS_EXPORT
167 void jas_tvparser_destroy(jas_tvparser_t *tvparser);
168 
173 JAS_EXPORT
174 int jas_tvparser_next(jas_tvparser_t *tvparser);
175 
180 JAS_ATTRIBUTE_PURE
181 JAS_EXPORT
182 const char *jas_tvparser_gettag(const jas_tvparser_t *tvparser);
183 
188 JAS_ATTRIBUTE_PURE
189 JAS_EXPORT
190 const char *jas_tvparser_getval(const jas_tvparser_t *tvparser);
191 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif
JAS_ATTRIBUTE_PURE JAS_EXPORT const char * jas_tvparser_getval(const jas_tvparser_t *tvparser)
Get the value for the current tag-value pair.
Definition: jas_tvp.c:204
JAS_ATTRIBUTE_PURE JAS_EXPORT const jas_taginfo_t * jas_taginfos_lookup(const jas_taginfo_t *taginfos, const char *name)
Lookup a tag by name.
Definition: jas_tvp.c:214
JAS_EXPORT void jas_tvparser_destroy(jas_tvparser_t *tvparser)
Destroy a tag-value parser.
Definition: jas_tvp.c:109
JAS_ATTRIBUTE_PURE JAS_EXPORT const char * jas_tvparser_gettag(const jas_tvparser_t *tvparser)
Get the tag name for the current tag-value pair.
Definition: jas_tvp.c:198
JAS_EXPORT int jas_tvparser_next(jas_tvparser_t *tvparser)
Get the next tag-value pair.
Definition: jas_tvp.c:122
JAS_ATTRIBUTE_PURE JAS_EXPORT const jas_taginfo_t * jas_taginfo_nonull(const jas_taginfo_t *taginfo)
Ensure a nonnull taginfo pointer.
Definition: jas_tvp.c:230
JAS_EXPORT jas_tvparser_t * jas_tvparser_create(const char *s)
Create a tag-value parser for the specified string.
Definition: jas_tvp.c:93
Tag information type.
Definition: jas_tvp.h:94
Tag-value parser type.
Definition: jas_tvp.h:108