fred-mod-eppd
Classes | Macros | Typedefs | Functions
/build/mod-eppd-2.21.0/epp_parser.c File Reference
#include "epp_common.h"
#include "epp_parser.h"
#include "epp_xmlcommon.h"
#include "xml-in-out-log.h"
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <apr.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
#include <libxml/xmlschemas.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
Include dependency graph for epp_parser.c:

Classes

struct  cmd_hash_item_t
 

Macros

#define HASH_SIZE_CMD   30
 
#define XML_IN_ENC   "UTF-8"
 
#define XERR_OK   0
 
#define XERR_LIBXML   1
 
#define XERR_ALLOC   2
 
#define XERR_CONSTR   3
 
#define CHK_XERR(_var, _label)
 
#define RESET_XERR(_var)   ((_var) = XERR_OK)
 
#define TEXT_CONTENT(_xpathObj, _i)
 

Typedefs

typedef struct cmd_hash_item_t cmd_hash_item
 

Functions

int read_epp_dnskey (void *pool, xmlXPathContextPtr xpathCtx, epp_dnskey *key)
 
int parse_boolean (char *str)
 
void * epp_parser_init (const char *url_schema)
 
void epp_parser_init_cleanup (void *schema)
 
void epp_parser_request_cleanup (void *cdata_arg)
 
parser_status epp_parse_command (epp_context *epp_ctx, int loggedin, void *schema, const char *request, unsigned bytes, epp_command_data **cdata_arg, const eppd_server_xml_conf *xml_schema, epp_red_command_type *cmd_type)
 

Detailed Description

Component for parsing EPP requests in form of xml documents.

The product is a data structure which contains data from xml document. This file also contains routine which handles deallocation of this structure. Currently the component is based on libxml library.

Macro Definition Documentation

#define HASH_SIZE_CMD   30

Size of hash table used for hashing command names. The size is tradeof between size of hash table and lookup speed, it should be less than 255 since hash value is unsigned char.

#define TEXT_CONTENT (   _xpathObj,
  _i 
)
Value:
( \
(char*)((xmlXPathNodeSetItem((_xpathObj)->nodesetval, (_i))->xmlChildrenNode) \
? (xmlXPathNodeSetItem((_xpathObj)->nodesetval, (_i)) \
->xmlChildrenNode) \
->content \
: NULL))

Get text content of an element.

You have to copy the string from returned pointer if you want to manipulate with string. Note that if element is empty (e.g.

the child of this element is not empty string but NULL. This makes macro a bit more complicated.

#define XML_IN_ENC   "UTF-8"

Encoding for input xml in epp_command_data structure

Function Documentation

parser_status epp_parse_command ( epp_context epp_ctx,
int  loggedin,
void *  schema,
const char *  request,
unsigned  bytes,
epp_command_data **  cdata,
const eppd_server_xml_conf xml_schema,
epp_red_command_type cmd_type 
)

This is the main workhorse of parser component. It's task is to parse request and get data saved in structure.

Parameters
epp_ctxEpp context (pool, connection and session id).
loggedinTrue if client is logged in.
schemaParsed xml schema used for validation.
requestRequest to be processed.
bytesLength of the request.
cdataOutput of parsing stage (xml data converted to structure).
cmd_typeOutput of commnad type (used also by logging)
Returns
Status of parsing.
void* epp_parser_init ( const char *  url_schema)

This routine initializes libxml's parser, hash table for command recognition and parses xml schema, which is returned.

Parameters
url_schemaXML schema location.
Returns
Parsed xml schema.
void epp_parser_init_cleanup ( void *  schema)

This will cleanup command hash table, libxml's parser and release parsed xml schema.

Parameters
schemaParsed xml schema.
void epp_parser_request_cleanup ( void *  cdata_arg)

This will cleanup xpath context and parsed document tree.

Parameters
cdata_argcdata structure containing items to be cleaned up.
int read_epp_dnskey ( void *  pool,
xmlXPathContextPtr  xpathCtx,
epp_dnskey key 
)

Read DNSKEY information from xml into epp_dnskey structure

Parameters
poolPool for allocating memory
xpathCtxXML parsing context
keyDNSKEY structure filled with data
Returns
1 on success, 0 on failure (goto error in other functions