Path: blob/master/3rdparty/libjasper/jasper/jas_tvp.h
16337 views
/*1* Copyright (c) 2001-2002 Michael David Adams.2* All rights reserved.3*/45/* __START_OF_JASPER_LICENSE__6*7* JasPer License Version 2.08*9* Copyright (c) 2001-2006 Michael David Adams10* Copyright (c) 1999-2000 Image Power, Inc.11* Copyright (c) 1999-2000 The University of British Columbia12*13* All rights reserved.14*15* Permission is hereby granted, free of charge, to any person (the16* "User") obtaining a copy of this software and associated documentation17* files (the "Software"), to deal in the Software without restriction,18* including without limitation the rights to use, copy, modify, merge,19* publish, distribute, and/or sell copies of the Software, and to permit20* persons to whom the Software is furnished to do so, subject to the21* following conditions:22*23* 1. The above copyright notices and this permission notice (which24* includes the disclaimer below) shall be included in all copies or25* substantial portions of the Software.26*27* 2. The name of a copyright holder shall not be used to endorse or28* promote products derived from the Software without specific prior29* written permission.30*31* THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS32* LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER33* THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS34* "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING35* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A36* PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO37* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL38* INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING39* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,40* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION41* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE42* PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE43* THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.44* EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS45* BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL46* PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS47* GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE48* ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE49* IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL50* SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,51* AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL52* SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH53* THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,54* PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH55* RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY56* EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.57*58* __END_OF_JASPER_LICENSE__59*/6061/*62* Tag/Value Parser63*64* $Id: jas_tvp.h,v 1.2 2008-05-26 09:41:51 vp153 Exp $65*/6667#ifndef JAS_TVP_H68#define JAS_TVP_H6970/******************************************************************************\71* Includes.72\******************************************************************************/7374#include <jasper/jas_config.h>7576#ifdef __cplusplus77extern "C" {78#endif7980/******************************************************************************\81* Types.82\******************************************************************************/8384/* Tag information type. */8586typedef struct {8788int id;89/* The ID for the tag. */9091char *name;92/* The name of the tag. */9394} jas_taginfo_t;9596/* Tag-value parser type. */9798typedef struct {99100char *buf;101/* The parsing buffer. */102103char *tag;104/* The current tag name. */105106char *val;107/* The current value. */108109char *pos;110/* The current position in the parsing buffer. */111112} jas_tvparser_t;113114/******************************************************************************\115* Tag information functions.116\******************************************************************************/117118/* Lookup a tag by name. */119jas_taginfo_t *jas_taginfos_lookup(jas_taginfo_t *taginfos, const char *name);120121/* This function returns a pointer to the specified taginfo object if it122exists (i.e., the pointer is nonnull); otherwise, a pointer to a dummy123object is returned. This is useful in some situations to avoid checking124for a null pointer. */125jas_taginfo_t *jas_taginfo_nonull(jas_taginfo_t *taginfo);126127/******************************************************************************\128* Tag-value parser functions.129\******************************************************************************/130131/* Create a tag-value parser for the specified string. */132jas_tvparser_t *jas_tvparser_create(const char *s);133134/* Destroy a tag-value parser. */135void jas_tvparser_destroy(jas_tvparser_t *tvparser);136137/* Get the next tag-value pair. */138int jas_tvparser_next(jas_tvparser_t *tvparser);139140/* Get the tag name for the current tag-value pair. */141char *jas_tvparser_gettag(jas_tvparser_t *tvparser);142143/* Get the value for the current tag-value pair. */144char *jas_tvparser_getval(jas_tvparser_t *tvparser);145146#ifdef __cplusplus147}148#endif149150#endif151152153