/* Jungle Monkey * Copyright (C) 1999-2001 The Regents of the University of Michigan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /** ELF is the Extensible Line Format It looks like this: name attribute2="value1" attribute2 attribute3=4 name2 name3 attribute4 We use it like this in Jungle Monkey: ADD name="/channel/myfile" url="jmftp://blah" UPDATE name="/channel/otherfile" length="23" And we also use it for the search server: SEARCH string="flav" [sent to server] MATCH name="flavor.jpg" url="blah" [received from server] */ #ifndef _ELF_H #define _ELF_H #include typedef struct _ElfNode { gchar* name; GList* attributes; } ElfNode; typedef struct _ElfAttribute { gchar* name; gchar* value; gint length; } ElfAttribute; ElfNode* elf_new (const gchar* name); ElfNode* elf_new_format (const gchar* name, const gchar* format, ...); void elf_delete (ElfNode* node); void elf_delete_list (GList* list); ElfNode* elf_clone (const ElfNode* node); void elf_set_name (ElfNode* node, const char* name); gchar* elf_get_name (ElfNode* node); void elf_set_attribute (ElfNode* node, const gchar* name, const gchar* value); void elf_set_attribute_int (ElfNode* node, const gchar* name, gint value); void elf_set_attribute_bool (ElfNode* node, const gchar* name, gboolean value); void elf_set_attribute_data (ElfNode* node, const gchar* name, const gchar* data, gint length); gchar* elf_get_attribute (const ElfNode* node, const gchar* name); gint elf_get_attribute_int (const ElfNode* node, const gchar* name); gboolean elf_get_attribute_bool (const ElfNode* node, const gchar* name); void elf_get_attribute_data (const ElfNode* node, const gchar* name, gchar** value, gint* length); gboolean elf_has_attribute (const ElfNode* node, const gchar* name); void elf_remove_attribute (ElfNode* node, const gchar* name); ElfNode* elf_read (const gchar* buffer, gint length); ElfNode* elf_read_node (const gchar* buffer, gint length, gint* bytes_read); GList* elf_read_list (const gchar* buffer, gint length); GList* elf_read_list_path (const gchar* path); void elf_write (ElfNode* node, gchar** bufferp, gint* lengthp); void elf_write_list (GList* list, gchar** bufferp, gint* lengthp); void elf_write_list_path (GList* list, const gchar* path); void elf_write_format (gchar** bufferp, gint* lengthp, const gchar* name, const gchar* format, ...); #endif /* _ELF_H */