00001 /* 00002 * Copyright (C) 2010-2011 Red Hat, Inc. 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; If not, see <http://www.gnu.org/licenses/>. 00016 * 00017 * Authors: 00018 * Richard W.M. Jones <rjones@redhat.com> 00019 * 00020 * Utility functions to help parse and assemble query strings. 00021 * 00022 * 00023 * !!!NOTE!!!: Taken from libvirt and modified to remove libvirt coupling. 00024 */ 00025 00026 #ifndef _QPARAMS_H_ 00027 # define _QPARAMS_H_ 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 #include "libstoragemgmt/libstoragemgmt_common.h" 00034 00040 # ifndef ATTRIBUTE_SENTINEL 00041 # if __GNUC_PREREQ (4, 0) 00042 # define ATTRIBUTE_SENTINEL __attribute__((__sentinel__)) 00043 # else 00044 # define ATTRIBUTE_SENTINEL 00045 # endif 00046 # endif 00047 00048 00052 struct qparam { 00053 char *name; 00054 char *value; 00055 int ignore; 00056 }; 00057 00061 struct qparam_set { 00062 int n; 00063 int alloc; 00064 struct qparam *p; 00065 }; 00066 00067 /* New parameter set. */ 00068 LSM_DLL_LOCAL struct qparam_set *new_qparam_set (int init_alloc, ...) 00069 ATTRIBUTE_SENTINEL; 00070 00071 /* Appending parameters. */ 00072 LSM_DLL_LOCAL int append_qparams (struct qparam_set *ps, ...) 00073 ATTRIBUTE_SENTINEL; 00074 LSM_DLL_LOCAL int append_qparam (struct qparam_set *ps, 00075 const char *name, const char *value); 00076 00077 00078 /* Parse a query string into a parameter set. */ 00079 LSM_DLL_LOCAL struct qparam_set *qparam_query_parse (const char *query); 00080 00081 LSM_DLL_LOCAL void free_qparam_set (struct qparam_set *ps); 00082 00083 #ifdef __cplusplus 00084 } 00085 #endif 00086 00087 #endif /* _QPARAMS_H_ */