Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

search_xml.c File Reference


Detailed Description

Persistance for searches and filters in XML format.

Author:
Richard Eckart
Date:
2002-2003

#include "gui.h"
#include <libxml/tree.h>
#include <libxml/parser.h>
#include "filter_core.h"
#include "search_xml.h"
#include "settings.h"
#include "search.h"
#include "if/gui_property_priv.h"
#include "if/gnet_property.h"
#include "if/bridge/ui2c.h"
#include "lib/getdate.h"
#include "lib/glib-missing.h"
#include "lib/tm.h"
#include "lib/utf8.h"
#include "lib/override.h"

Data Structures

struct  node_parser

Defines

#define GLOBAL_PRE   0
#define GLOBAL_POST   1
#define TO_BOOL(v)   ((v) != 0 ? TRUE : FALSE)

Typedefs

typedef node_parser node_parser_t

Functions

 RCSID ("$Id:search_xml.c, v 1.39 2005/11/27 04:37:45 cbiere Exp $")
void dump_ruleset (GList *ruleset)
void dump_filter (filter_t *filter)
void parse_xml (xmlNodePtr xmlnode, gpointer user_data)
void builtin_to_xml (xmlNodePtr)
void search_to_xml (xmlNodePtr, search_t *)
void filter_to_xml (xmlNodePtr, filter_t *)
void rule_to_xml (xmlNodePtr, rule_t *)
void xml_to_builtin (xmlNodePtr, gpointer)
void xml_to_search (xmlNodePtr, gpointer)
void xml_to_filter (xmlNodePtr, gpointer)
void xml_to_text_rule (xmlNodePtr, gpointer)
void xml_to_ip_rule (xmlNodePtr, gpointer)
void xml_to_size_rule (xmlNodePtr, gpointer)
void xml_to_jump_rule (xmlNodePtr, gpointer)
void xml_to_sha1_rule (xmlNodePtr, gpointer)
void xml_to_flag_rule (xmlNodePtr, gpointer)
void xml_to_state_rule (xmlNodePtr, gpointer)
guint16 get_rule_flags_from_xml (xmlNodePtr)
xmlAttrPtr xml_prop_printf (xmlNodePtr node, const gchar *name, const char *fmt,...) G_GNUC_PRINTF(3
 A wrapper to set use xmlSetProp() through a printf-like interface.

gchar * xml_get_string (xmlNode *node, const gchar *id)
 Get rid of the obnoxious (xmlChar *).

const xmlChar * string_to_xmlChar (const gchar *p)
xmlNodePtr xml_new_empty_child (xmlNodePtr parent, const gchar *name)
guint64 parse_number (const gchar *buf, gint *error)
 A wrapper around parse_uint64.

gpointer parse_target (const gchar *buf, gint *error)
 A wrapper around parse_uint64.

gpointer target_new_id (gboolean do_reset)
 Returns the next available target ID.

void target_map_reset (void)
 Resets the target ID counter and frees target_map if it was created.

const gchar * target_to_string (filter_t *target)
 Creates a string representation of a ``target''.

xmlAttrPtr xml_prop_set (xmlNodePtr node, const gchar *name, const char *value)
 A wrapper around xmlSetProp() to get rid of (xmlChar *).

void search_store_xml (void)
 Store pending searches.

gboolean search_retrieve_xml (void)
 Retrieve search list and restart searches.


Variables

GList * filters
GList * filters_current
const gchar NODE_BUILTIN [] = "BuiltIn"
const gchar NODE_SEARCH [] = "Search"
const gchar NODE_FILTER [] = "Filter"
const gchar NODE_RULE_TEXT [] = "TextRule"
const gchar NODE_RULE_IP [] = "IpRule"
const gchar NODE_RULE_SIZE [] = "SizeRule"
const gchar NODE_RULE_JUMP [] = "JumpRule"
const gchar NODE_RULE_SHA1 [] = "SHA1Rule"
const gchar NODE_RULE_FLAG [] = "FlagRule"
const gchar NODE_RULE_STATE [] = "StateRule"
const gchar TAG_BUILTIN_SHOW_UID [] = "ShowUID"
const gchar TAG_BUILTIN_DROP_UID [] = "DropUID"
const gchar TAG_BUILTIN_DOWNLOAD_UID [] = "DownloadUID"
const gchar TAG_BUILTIN_NODOWNLOAD_UID [] = "NoDownloadUID"
const gchar TAG_BUILTIN_RETURN_UID [] = "ReturnUID"
const gchar TAG_FILTER_NAME [] = "Name"
const gchar TAG_FILTER_GLOBAL [] = "Global"
const gchar TAG_FILTER_UID [] = "UID"
const gchar TAG_FILTER_ACTIVE [] = "Active"
const gchar TAG_SEARCH_QUERY [] = "Query"
const gchar TAG_SEARCH_ENABLED [] = "Enabled"
const gchar TAG_SEARCH_SPEED [] = "Speed"
const gchar TAG_SEARCH_PASSIVE [] = "Passive"
const gchar TAG_SEARCH_REISSUE_TIMEOUT [] = "ReissueTimeout"
const gchar TAG_SEARCH_CREATE_TIME [] = "CreateTime"
const gchar TAG_SEARCH_LIFETIME [] = "LifeTime"
const gchar TAG_SEARCH_SORT_COL [] = "SortCol"
const gchar TAG_SEARCH_SORT_ORDER [] = "SortOrder"
const gchar TAG_RULE_TEXT_CASE [] = "Case"
const gchar TAG_RULE_TEXT_MATCH [] = "Match"
const gchar TAG_RULE_TEXT_TYPE [] = "Type"
const gchar TAG_RULE_IP_ADDR [] = "Address"
const gchar TAG_RULE_IP_MASK [] = "Netmask"
const gchar TAG_RULE_SIZE_LOWER [] = "Lower"
const gchar TAG_RULE_SIZE_UPPER [] = "Upper"
const gchar TAG_RULE_SHA1_HASH [] = "Hash"
const gchar TAG_RULE_SHA1_FILENAME [] = "OriginalFilename"
const gchar TAG_RULE_NEGATE [] = "Negate"
const gchar TAG_RULE_ACTIVE [] = "Active"
const gchar TAG_RULE_SOFT [] = "Soft"
const gchar TAG_RULE_TARGET [] = "Target"
const gchar TAG_RULE_FLAG_BUSY [] = "Busy"
const gchar TAG_RULE_FLAG_PUSH [] = "Push"
const gchar TAG_RULE_FLAG_STABLE [] = "Stable"
const gchar TAG_RULE_STATE_DISPLAY [] = "Display"
const gchar TAG_RULE_STATE_DOWNLOAD [] = "Download"
const gchar search_file_xml [] = "searches.xml"
const gchar search_file_xml_new [] = "searches.xml.new"
const gchar search_file_xml_old [] = "searches.xml.orig"
GHashTable * target_map = NULL
GHashTable * id_map = NULL
node_parser_t parser_map []


Define Documentation

#define GLOBAL_POST   1
 

#define GLOBAL_PRE   0
 

#define TO_BOOL v   )     ((v) != 0 ? TRUE : FALSE)
 


Typedef Documentation

typedef struct node_parser node_parser_t
 


Function Documentation

void builtin_to_xml xmlNodePtr   )  [static]
 

void dump_filter filter_t filter  ) 
 

void dump_ruleset GList *  ruleset  ) 
 

void filter_to_xml xmlNodePtr  ,
filter_t
[static]
 

guint16 get_rule_flags_from_xml xmlNodePtr   )  [static]
 

guint64 parse_number const gchar *  buf,
gint *  error
[static]
 

A wrapper around parse_uint64.

It's a little stricter, so that trailing characters enforce an error. It accepts base 10 (decimal) only. On failure *error will be set to a non-zero "errno" value.

Parameters:
buf the string to parse.
error an int variable which will indicate success or failure.
Returns:
On success, the parsed value is returned.

gpointer parse_target const gchar *  buf,
gint *  error
[static]
 

A wrapper around parse_uint64.

It's a little stricter, so that trailing characters enforce an error. It accepts base 16 (decimal) only. On failure *error will be set to a non-zero "errno" value. The value is casted to a pointer.

Parameters:
buf the string to parse.
error an int variable which will indicate success or failure.
Returns:
On success, the parsed value is returned as a pointer.

void parse_xml xmlNodePtr  xmlnode,
gpointer  user_data
[static]
 

RCSID "$Id:search_xml.  c,
v 1.39 2005/11/27 04:37:45 cbiere Exp $" 
 

void rule_to_xml xmlNodePtr  ,
rule_t
[static]
 

gboolean search_retrieve_xml void   ) 
 

Retrieve search list and restart searches.

This is the new xml version. The searches are normally retrieved from ~/.gtk-gnutella/searches.xml.

void search_store_xml void   ) 
 

Store pending searches.

void search_to_xml xmlNodePtr  ,
search_t * 
[static]
 

const xmlChar* string_to_xmlChar const gchar *  p  )  [inline, static]
 

void target_map_reset void   )  [static]
 

Resets the target ID counter and frees target_map if it was created.

gpointer target_new_id gboolean  do_reset  )  [static]
 

Returns the next available target ID.

Parameters:
do_reset if TRUE, the ID counter is reset to an initial value.
Returns:
a 32-bit integer stuffed into a pointer

const gchar* target_to_string filter_t target  )  [static]
 

Creates a string representation of a ``target''.

Parameters:
target a filter target
Returns:
a static buffer holding the string representation

gchar* xml_get_string xmlNode *  node,
const gchar *  id
[inline, static]
 

Get rid of the obnoxious (xmlChar *).

xmlNodePtr xml_new_empty_child xmlNodePtr  parent,
const gchar *  name
[inline, static]
 

xmlAttrPtr xml_prop_printf xmlNodePtr  node,
const gchar *  name,
const char *  fmt,
... 
[static]
 

A wrapper to set use xmlSetProp() through a printf-like interface.

The length of the created string is limited to 4096 byte and truncation occurs if this limit is exceeded. For mere strings or longer values use xml_prop_set() instead.

Parameters:
node the node
name the attribute name
fmt the format string
Returns:
the result of xmlSetProp().

xmlAttrPtr xml_prop_set xmlNodePtr  node,
const gchar *  name,
const char *  value
[inline, static]
 

A wrapper around xmlSetProp() to get rid of (xmlChar *).

Parameters:
node the node
name the attribute name
value an UTF-8 encoded string
Returns:
the result of xmlSetProp().

void xml_to_builtin xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_filter xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_flag_rule xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_ip_rule xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_jump_rule xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_search xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_sha1_rule xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_size_rule xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_state_rule xmlNodePtr  ,
gpointer 
[static]
 

void xml_to_text_rule xmlNodePtr  ,
gpointer 
[static]
 


Variable Documentation

GList* filters
 

GList* filters_current
 

GHashTable* id_map = NULL [static]
 

const gchar NODE_BUILTIN[] = "BuiltIn" [static]
 

const gchar NODE_FILTER[] = "Filter" [static]
 

const gchar NODE_RULE_FLAG[] = "FlagRule" [static]
 

const gchar NODE_RULE_IP[] = "IpRule" [static]
 

const gchar NODE_RULE_JUMP[] = "JumpRule" [static]
 

const gchar NODE_RULE_SHA1[] = "SHA1Rule" [static]
 

const gchar NODE_RULE_SIZE[] = "SizeRule" [static]
 

const gchar NODE_RULE_STATE[] = "StateRule" [static]
 

const gchar NODE_RULE_TEXT[] = "TextRule" [static]
 

const gchar NODE_SEARCH[] = "Search" [static]
 

node_parser_t parser_map[] [static]
 

Initial value:

 {
    { NODE_BUILTIN,     xml_to_builtin },
    { NODE_SEARCH,      xml_to_search },
    { NODE_FILTER,      xml_to_filter },
    { NODE_RULE_TEXT,   xml_to_text_rule },
    { NODE_RULE_IP,     xml_to_ip_rule },
    { NODE_RULE_SIZE,   xml_to_size_rule },
    { NODE_RULE_JUMP,   xml_to_jump_rule },
    { NODE_RULE_SHA1,   xml_to_sha1_rule },
    { NODE_RULE_FLAG,   xml_to_flag_rule },
    { NODE_RULE_STATE,  xml_to_state_rule },
    { NULL, NULL }
}

const gchar search_file_xml[] = "searches.xml" [static]
 

const gchar search_file_xml_new[] = "searches.xml.new" [static]
 

const gchar search_file_xml_old[] = "searches.xml.orig" [static]
 

const gchar TAG_BUILTIN_DOWNLOAD_UID[] = "DownloadUID" [static]
 

const gchar TAG_BUILTIN_DROP_UID[] = "DropUID" [static]
 

const gchar TAG_BUILTIN_NODOWNLOAD_UID[] = "NoDownloadUID" [static]
 

const gchar TAG_BUILTIN_RETURN_UID[] = "ReturnUID" [static]
 

const gchar TAG_BUILTIN_SHOW_UID[] = "ShowUID" [static]
 

const gchar TAG_FILTER_ACTIVE[] = "Active" [static]
 

const gchar TAG_FILTER_GLOBAL[] = "Global" [static]
 

const gchar TAG_FILTER_NAME[] = "Name" [static]
 

const gchar TAG_FILTER_UID[] = "UID" [static]
 

const gchar TAG_RULE_ACTIVE[] = "Active" [static]
 

const gchar TAG_RULE_FLAG_BUSY[] = "Busy" [static]
 

const gchar TAG_RULE_FLAG_PUSH[] = "Push" [static]
 

const gchar TAG_RULE_FLAG_STABLE[] = "Stable" [static]
 

const gchar TAG_RULE_IP_ADDR[] = "Address" [static]
 

const gchar TAG_RULE_IP_MASK[] = "Netmask" [static]
 

const gchar TAG_RULE_NEGATE[] = "Negate" [static]
 

const gchar TAG_RULE_SHA1_FILENAME[] = "OriginalFilename" [static]
 

const gchar TAG_RULE_SHA1_HASH[] = "Hash" [static]
 

const gchar TAG_RULE_SIZE_LOWER[] = "Lower" [static]
 

const gchar TAG_RULE_SIZE_UPPER[] = "Upper" [static]
 

const gchar TAG_RULE_SOFT[] = "Soft" [static]
 

const gchar TAG_RULE_STATE_DISPLAY[] = "Display" [static]
 

const gchar TAG_RULE_STATE_DOWNLOAD[] = "Download" [static]
 

const gchar TAG_RULE_TARGET[] = "Target" [static]
 

const gchar TAG_RULE_TEXT_CASE[] = "Case" [static]
 

const gchar TAG_RULE_TEXT_MATCH[] = "Match" [static]
 

const gchar TAG_RULE_TEXT_TYPE[] = "Type" [static]
 

const gchar TAG_SEARCH_CREATE_TIME[] = "CreateTime" [static]
 

const gchar TAG_SEARCH_ENABLED[] = "Enabled" [static]
 

const gchar TAG_SEARCH_LIFETIME[] = "LifeTime" [static]
 

const gchar TAG_SEARCH_PASSIVE[] = "Passive" [static]
 

const gchar TAG_SEARCH_QUERY[] = "Query" [static]
 

const gchar TAG_SEARCH_REISSUE_TIMEOUT[] = "ReissueTimeout" [static]
 

const gchar TAG_SEARCH_SORT_COL[] = "SortCol" [static]
 

const gchar TAG_SEARCH_SORT_ORDER[] = "SortOrder" [static]
 

const gchar TAG_SEARCH_SPEED[] = "Speed" [static]
 

GHashTable* target_map = NULL [static]
 


Generated on Sun Feb 12 10:50:07 2006 for Gtk-Gnutella by doxygen 1.3.6