resource_lists_parser.h

00001 /* 
00002  * Copyright (C) 2005 iptelorg GmbH
00003  *
00004  * This file is part of ser, a free SIP server.
00005  *
00006  * ser is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * For a license to use the ser software under conditions
00012  * other than those described here, or to purchase support for this
00013  * software, please contact iptel.org by e-mail at the following addresses:
00014  *    info@iptel.org
00015  *
00016  * ser is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  */
00025 
00026 #ifndef __RESOURCE_LISTS_PARSER_H
00027 #define __RESOURCE_LISTS_PARSER_H
00028 
00029 #include <xcap/xml_utils.h>
00030 #include <cds/memory.h>
00031 
00032 typedef struct _display_name_t {
00033         SEQUENCE_ABLE(struct _display_name_t)
00034         char *name;
00035         char *lang;
00036 } display_name_t;
00037 
00038 typedef struct {
00039         char *uri;
00040         SEQUENCE(display_name_t) display_names;
00041 } entry_t;
00042 
00043 typedef struct {
00044         char *anchor;
00045         /* SEQUENCE(display_name_t) display_names; */
00046 } external_t;
00047 
00048 typedef struct {
00049         char *ref;
00050         /* SEQUENCE(display_name_t) display_names; */
00051 } entry_ref_t;
00052 
00053 typedef enum { 
00054         lct_list,
00055         lct_entry,
00056         lct_entry_ref,
00057         lct_external
00058 } list_content_type_t;
00059 
00060 struct _list_t;
00061 
00062 typedef struct _list_content_t {
00063         SEQUENCE_ABLE(struct _list_content_t)
00064                 
00065         list_content_type_t type;
00066         union {
00067                 struct _list_t *list;
00068                 entry_t *entry;
00069                 entry_ref_t *entry_ref;
00070                 external_t *external;
00071         } u;
00072 } list_content_t;
00073 
00074 typedef struct _list_t {
00075         SEQUENCE_ABLE(struct _list_t)
00076                 
00077 /*      entry_t *entries;*/
00078         char *display_name;
00079         
00080         SEQUENCE(list_content_t) content;
00081         
00082         char *name;
00083 } list_t;
00084 
00085 typedef struct {
00086         /* list_t *lists; */
00087         SEQUENCE(list_t) lists;
00088         
00089 } resource_lists_t;
00090 
00091 int parse_resource_lists_xml(const char *data, int data_len, resource_lists_t **dst);
00092 int parse_list_xml(const char *data, int data_len, list_t **dst);
00093 int parse_as_list_content_xml(const char *data, int data_len, list_t **dst);
00094 int parse_entry_xml(const char *data, int data_len, entry_t **dst);
00095 void free_resource_lists(resource_lists_t *rl);
00096 void free_list(list_t *l);
00097 void free_entry(entry_t *e);
00098 void free_display_names(display_name_t *sequence_first);
00099 
00100 /* if read_content_only set then the root element need not to be a list element
00101  * it may be whatever, but content is parsed as if it is list (useful for reading
00102  * resource-list as list */
00103 int read_list(xmlNode *list_node, list_t **dst, int read_content_only);
00104 
00105 #endif