diff --git a/ChangeLog b/ChangeLog index b015c773..5e36233f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Jan 26 18:14:55 CET 2000 Daniel Veillard + + * nanoftp.[ch]: cleanup, comments, API + * debugXML.c : fixed a bug in the cat command + * doc/*: regenerated the docs + Wed Jan 26 16:52:50 CET 2000 Daniel Veillard * nanoftp.[ch] parser.c xmlIO.[ch]: added a Nano FTP implementation diff --git a/debugXML.c b/debugXML.c index 99972ae1..b91fe53e 100644 --- a/debugXML.c +++ b/debugXML.c @@ -673,7 +673,17 @@ xmlShellDir(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, int xmlShellCat(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlNodePtr node2) { - xmlElemDump(stdout, ctxt->doc, node); + if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) { + if (node->type == XML_HTML_DOCUMENT_NODE) + htmlDocDump(stdout, (htmlDocPtr) node); + else + htmlNodeDump(stdout, ctxt->doc, node); + } else { + if (node->type == XML_DOCUMENT_NODE) + xmlDocDump(stdout, (xmlDocPtr) node); + else + xmlElemDump(stdout, ctxt->doc, node); + } printf("\n"); return(0); } diff --git a/doc/gnome-xml.sgml b/doc/gnome-xml.sgml index 1053c85f..1a08f31d 100644 --- a/doc/gnome-xml.sgml +++ b/doc/gnome-xml.sgml @@ -13,6 +13,7 @@ + ]> @@ -82,6 +83,7 @@ &HTMLtree; &xpath; &nanohttp; + &nanoftp; &xmlIO; &parserInternals; &encoding; diff --git a/doc/html/book1.html b/doc/html/book1.html index 1e53fbc0..c5097bff 100644 --- a/doc/html/book1.html +++ b/doc/html/book1.html @@ -163,6 +163,11 @@ HREF="gnome-xml-nanohttp.html" > —
nanoftp
xmlIO
debugXML
Gnome XML Library Reference Manual
<<< Previous PageHomeUpNext Page >>>

debugXML

Name

debugXML —

Synopsis


+
+void        xmlDebugDumpString              (FILE *output,
+                                             const xmlChar *str);
+void        xmlDebugDumpAttr                (FILE *output,
+                                             xmlAttrPtr attr,
+                                             int depth);
+void        xmlDebugDumpAttrList            (FILE *output,
+                                             xmlAttrPtr attr,
+                                             int depth);
+void        xmlDebugDumpOneNode             (FILE *output,
+                                             xmlNodePtr node,
+                                             int depth);
+void        xmlDebugDumpNode                (FILE *output,
+                                             xmlNodePtr node,
+                                             int depth);
+void        xmlDebugDumpNodeList            (FILE *output,
+                                             xmlNodePtr node,
+                                             int depth);
+void        xmlDebugDumpDocumentHead        (FILE *output,
+                                             xmlDocPtr doc);
+void        xmlDebugDumpDocument            (FILE *output,
+                                             xmlDocPtr doc);
+void        xmlDebugDumpEntities            (FILE *output,
+                                             xmlDocPtr doc);
+void        xmlLsOneNode                    (FILE *output,
+                                             xmlNodePtr node);
+char*       (*xmlShellReadlineFunc)         (char *prompt);
+struct      xmlShellCtxt;
+typedef     xmlShellCtxtPtr;
+int         (*xmlShellCmd)                  (xmlShellCtxtPtr ctxt,
+                                             char *arg,
+                                             xmlNodePtr node,
+                                             xmlNodePtr node2);
+void        xmlShell                        (xmlDocPtr doc,
+                                             char *filename,
+                                             xmlShellReadlineFunc input,
+                                             FILE *output);

Description

Details

xmlDebugDumpString ()

void        xmlDebugDumpString              (FILE *output,
+                                             const xmlChar *str);

output : 
str : 


xmlDebugDumpAttr ()

void        xmlDebugDumpAttr                (FILE *output,
+                                             xmlAttrPtr attr,
+                                             int depth);

output : 
attr : 
depth : 


xmlDebugDumpAttrList ()

void        xmlDebugDumpAttrList            (FILE *output,
+                                             xmlAttrPtr attr,
+                                             int depth);

output : 
attr : 
depth : 


xmlDebugDumpOneNode ()

void        xmlDebugDumpOneNode             (FILE *output,
+                                             xmlNodePtr node,
+                                             int depth);

output : 
node : 
depth : 


xmlDebugDumpNode ()

void        xmlDebugDumpNode                (FILE *output,
+                                             xmlNodePtr node,
+                                             int depth);

output : 
node : 
depth : 


xmlDebugDumpNodeList ()

void        xmlDebugDumpNodeList            (FILE *output,
+                                             xmlNodePtr node,
+                                             int depth);

output : 
node : 
depth : 


xmlDebugDumpDocumentHead ()

void        xmlDebugDumpDocumentHead        (FILE *output,
+                                             xmlDocPtr doc);

output : 
doc : 


xmlDebugDumpDocument ()

void        xmlDebugDumpDocument            (FILE *output,
+                                             xmlDocPtr doc);

output : 
doc : 


xmlDebugDumpEntities ()

void        xmlDebugDumpEntities            (FILE *output,
+                                             xmlDocPtr doc);

output : 
doc : 


xmlLsOneNode ()

void        xmlLsOneNode                    (FILE *output,
+                                             xmlNodePtr node);

output : 
node : 


xmlShellReadlineFunc ()

char*       (*xmlShellReadlineFunc)         (char *prompt);

prompt : 
Returns : 


struct xmlShellCtxt

struct xmlShellCtxt {
+    char *filename;
+    xmlDocPtr doc;
+    xmlNodePtr node;
+    xmlXPathContextPtr pctxt;
+    int loaded;
+    FILE *output;
+    xmlShellReadlineFunc input;
+};


xmlShellCtxtPtr

typedef xmlShellCtxt *xmlShellCtxtPtr;


xmlShellCmd ()

int         (*xmlShellCmd)                  (xmlShellCtxtPtr ctxt,
+                                             char *arg,
+                                             xmlNodePtr node,
+                                             xmlNodePtr node2);

ctxt : 
arg : 
node : 
node2 : 
Returns : 


xmlShell ()

void        xmlShell                        (xmlDocPtr doc,
+                                             char *filename,
+                                             xmlShellReadlineFunc input,
+                                             FILE *output);

Implements the XML shell +This allow to load, validate, view, modify and save a document +using a environment similar to a UNIX commandline.

doc : the initial document
filename : the output buffer
input : the line reading function
output : the output FILE*



<<< Previous PageHomeUpNext Page >>>
encodingxmlmemory
\ No newline at end of file diff --git a/doc/html/gnome-xml-encoding.html b/doc/html/gnome-xml-encoding.html new file mode 100644 index 00000000..18c1a4c6 --- /dev/null +++ b/doc/html/gnome-xml-encoding.html @@ -0,0 +1,1145 @@ +encoding
Gnome XML Library Reference Manual
<<< Previous PageHomeUpNext Page >>>

encoding

Name

encoding —

Synopsis


+
+enum        xmlCharEncoding;
+int         (*xmlCharEncodingInputFunc)     (unsigned char *out,
+                                             int outlen,
+                                             unsigned char *in,
+                                             int inlen);
+int         (*xmlCharEncodingOutputFunc)    (unsigned char *out,
+                                             int outlen,
+                                             unsigned char *in,
+                                             int inlen);
+struct      xmlCharEncodingHandler;
+typedef     xmlCharEncodingHandlerPtr;
+void        xmlInitCharEncodingHandlers     (void);
+void        xmlCleanupCharEncodingHandlers  (void);
+void        xmlRegisterCharEncodingHandler  (xmlCharEncodingHandlerPtr handler);
+xmlCharEncoding xmlDetectCharEncoding       (unsigned char *in);
+xmlCharEncoding xmlParseCharEncoding        (const char *name);
+xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler
+                                            (xmlCharEncoding enc);
+xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler
+                                            (const char *name);

Description

Details

enum xmlCharEncoding

typedef enum {
+    XML_CHAR_ENCODING_ERROR=   -1, /* No char encoding detected */
+    XML_CHAR_ENCODING_NONE=	0, /* No char encoding detected */
+    XML_CHAR_ENCODING_UTF8=	1, /* UTF-8 */
+    XML_CHAR_ENCODING_UTF16LE=	2, /* UTF-16 little endian */
+    XML_CHAR_ENCODING_UTF16BE=	3, /* UTF-16 big endian */
+    XML_CHAR_ENCODING_UCS4LE=	4, /* UCS-4 little endian */
+    XML_CHAR_ENCODING_UCS4BE=	5, /* UCS-4 big endian */
+    XML_CHAR_ENCODING_EBCDIC=	6, /* EBCDIC uh! */
+    XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
+    XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
+    XML_CHAR_ENCODING_UCS2=	9, /* UCS-2 */
+    XML_CHAR_ENCODING_8859_1=	10,/* ISO-8859-1 ISO Latin 1 */
+    XML_CHAR_ENCODING_8859_2=	11,/* ISO-8859-2 ISO Latin 2 */
+    XML_CHAR_ENCODING_8859_3=	12,/* ISO-8859-3 */
+    XML_CHAR_ENCODING_8859_4=	13,/* ISO-8859-4 */
+    XML_CHAR_ENCODING_8859_5=	14,/* ISO-8859-5 */
+    XML_CHAR_ENCODING_8859_6=	15,/* ISO-8859-6 */
+    XML_CHAR_ENCODING_8859_7=	16,/* ISO-8859-7 */
+    XML_CHAR_ENCODING_8859_8=	17,/* ISO-8859-8 */
+    XML_CHAR_ENCODING_8859_9=	18,/* ISO-8859-9 */
+    XML_CHAR_ENCODING_2022_JP=  19,/* ISO-2022-JP */
+    XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
+    XML_CHAR_ENCODING_EUC_JP=   21 /* EUC-JP */
+} xmlCharEncoding;


xmlCharEncodingInputFunc ()

int         (*xmlCharEncodingInputFunc)     (unsigned char *out,
+                                             int outlen,
+                                             unsigned char *in,
+                                             int inlen);

out : 
outlen : 
in : 
inlen : 
Returns : 


xmlCharEncodingOutputFunc ()

int         (*xmlCharEncodingOutputFunc)    (unsigned char *out,
+                                             int outlen,
+                                             unsigned char *in,
+                                             int inlen);

out : 
outlen : 
in : 
inlen : 
Returns : 


struct xmlCharEncodingHandler

struct xmlCharEncodingHandler {
+    char                       *name;
+    xmlCharEncodingInputFunc   input;
+    xmlCharEncodingOutputFunc output;
+};


xmlCharEncodingHandlerPtr

typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;


xmlInitCharEncodingHandlers ()

void        xmlInitCharEncodingHandlers     (void);

Initialize the char encoding support, it registers the default +encoding supported. +NOTE: while public, this function usually doesn't need to be called +in normal processing.


xmlCleanupCharEncodingHandlers ()

void        xmlCleanupCharEncodingHandlers  (void);

Cleanup the memory allocated for the char encoding support, it +unregisters all the encoding handlers.


xmlRegisterCharEncodingHandler ()

void        xmlRegisterCharEncodingHandler  (xmlCharEncodingHandlerPtr handler);

Register the char encoding handler, surprizing, isn't it ?

handler : the xmlCharEncodingHandlerPtr handler block


xmlDetectCharEncoding ()

xmlCharEncoding xmlDetectCharEncoding       (unsigned char *in);

Guess the encoding of the entity using the first bytes of the entity content +accordingly of the non-normative appendix F of the XML-1.0 recommendation.

in : a pointer to the first bytes of the XML entity, must be at least +4 bytes long.
Returns :one of the XML_CHAR_ENCODING_... values.


xmlParseCharEncoding ()

xmlCharEncoding xmlParseCharEncoding        (const char *name);

Conpare the string to the known encoding schemes already known. Note +that the comparison is case insensitive accordingly to the section +[XML] 4.3.3 Character Encoding in Entities.

name : the encoding name as parsed, in UTF-8 format (ASCII actually)
Returns :one of the XML_CHAR_ENCODING_... values or XML_CHAR_ENCODING_NONE +if not recognized.


xmlGetCharEncodingHandler ()

xmlCharEncodingHandlerPtr xmlGetCharEncodingHandler
+                                            (xmlCharEncoding enc);

Search in the registrered set the handler able to read/write that encoding.

enc : a string describing the char encoding.
Returns :the handler or NULL if not found


xmlFindCharEncodingHandler ()

xmlCharEncodingHandlerPtr xmlFindCharEncodingHandler
+                                            (const char *name);

name : 
Returns : 



<<< Previous PageHomeUpNext Page >>>
parserInternalsdebugXML
\ No newline at end of file diff --git a/doc/html/gnome-xml-nanoftp.html b/doc/html/gnome-xml-nanoftp.html new file mode 100644 index 00000000..a4692c95 --- /dev/null +++ b/doc/html/gnome-xml-nanoftp.html @@ -0,0 +1,2096 @@ +nanoftp
Gnome XML Library Reference Manual
<<< Previous PageHomeUpNext Page >>>

nanoftp

Name

nanoftp —

Synopsis


+
+void        (*ftpListCallback)              (void *userData,
+                                             const char *filename,
+                                             const char *attrib,
+                                             const char *owner,
+                                             const char *group,
+                                             unsigned long size,
+                                             int links,
+                                             int year,
+                                             const char *month,
+                                             int day,
+                                             int minute);
+void        (*ftpDataCallback)              (void *userData,
+                                             const char *data,
+                                             int len);
+void        xmlNanoFTPInit                  (void);
+void*       xmlNanoFTPNewCtxt               (const char *URL);
+void        xmlNanoFTPFreeCtxt              (void *ctx);
+void*       xmlNanoFTPConnectTo             (const char *server,
+                                             int port);
+void*       xmlNanoFTPOpen                  (const char *URL);
+int         xmlNanoFTPConnect               (void *ctx);
+int         xmlNanoFTPClose                 (void *ctx);
+int         xmlNanoFTPQuit                  (void *ctx);
+int         xmlNanoFTPGetResponse           (void *ctx);
+int         xmlNanoFTPCheckResponse         (void *ctx);
+int         xmlNanoFTPCwd                   (void *ctx,
+                                             char *directory);
+int         xmlNanoFTPGetConnection         (void *ctx);
+int         xmlNanoFTPCloseConnection       (void *ctx);
+int         xmlNanoFTPList                  (void *ctx,
+                                             ftpListCallback callback,
+                                             void *userData,
+                                             char *filename);
+int         xmlNanoFTPGetSocket             (void *ctx,
+                                             const char *filename);
+int         xmlNanoFTPGet                   (void *ctx,
+                                             ftpDataCallback callback,
+                                             void *userData,
+                                             const char *filename);
+int         xmlNanoFTPRead                  (void *ctx,
+                                             void *dest,
+                                             int len);

Description

Details

ftpListCallback ()

void        (*ftpListCallback)              (void *userData,
+                                             const char *filename,
+                                             const char *attrib,
+                                             const char *owner,
+                                             const char *group,
+                                             unsigned long size,
+                                             int links,
+                                             int year,
+                                             const char *month,
+                                             int day,
+                                             int minute);

userData : 
filename : 
attrib : 
owner : 
group : 
size : 
links : 
year : 
month : 
day : 
minute : 


ftpDataCallback ()

void        (*ftpDataCallback)              (void *userData,
+                                             const char *data,
+                                             int len);

userData : 
data : 
len : 


xmlNanoFTPInit ()

void        xmlNanoFTPInit                  (void);

Initialize the FTP handling.


xmlNanoFTPNewCtxt ()

void*       xmlNanoFTPNewCtxt               (const char *URL);

Allocate and initialize a new FTP context.

URL : The URL used to initialize the context


xmlNanoFTPFreeCtxt ()

void        xmlNanoFTPFreeCtxt              (void *ctx);

Frees the context after closing the connection.

ctx : an FTP context


xmlNanoFTPConnectTo ()

void*       xmlNanoFTPConnectTo             (const char *server,
+                                             int port);

Tries to open a control connection to the given server/port

server : an FTP server name
port : 


xmlNanoFTPOpen ()

void*       xmlNanoFTPOpen                  (const char *URL);

Start to fetch the given ftp:// resource

URL : the URL to the resource


xmlNanoFTPConnect ()

int         xmlNanoFTPConnect               (void *ctx);

Tries to open a control connection

ctx : an FTP context
Returns :-1 in case of error, 0 otherwise


xmlNanoFTPClose ()

int         xmlNanoFTPClose                 (void *ctx);

Close the connection and both control and transport

ctx : an FTP context
Returns :-1 incase of error, 0 otherwise


xmlNanoFTPQuit ()

int         xmlNanoFTPQuit                  (void *ctx);

Send a QUIT command to the server

ctx : an FTP context
Returns :-1 in case of error, 0 otherwise


xmlNanoFTPGetResponse ()

int         xmlNanoFTPGetResponse           (void *ctx);

Get the response from the FTP server after a command.

ctx : an FTP context
Returns :the code number


xmlNanoFTPCheckResponse ()

int         xmlNanoFTPCheckResponse         (void *ctx);

Check if there is a response from the FTP server after a command.

ctx : an FTP context
Returns :the code number, or 0


xmlNanoFTPCwd ()

int         xmlNanoFTPCwd                   (void *ctx,
+                                             char *directory);

ctx : 
directory : 
Returns : 


xmlNanoFTPGetConnection ()

int         xmlNanoFTPGetConnection         (void *ctx);

Try to open a data connection to the server. Currently only +passive mode is supported.

ctx : an FTP context
Returns :-1 incase of error, 0 otherwise


xmlNanoFTPCloseConnection ()

int         xmlNanoFTPCloseConnection       (void *ctx);

Close the data connection from the server

ctx : an FTP context
Returns :-1 incase of error, 0 otherwise


xmlNanoFTPList ()

int         xmlNanoFTPList                  (void *ctx,
+                                             ftpListCallback callback,
+                                             void *userData,
+                                             char *filename);

Do a listing on the server. All files info are passed back +in the callbacks.

ctx : an FTP context
callback : the user callback
userData : the user callback data
filename : optional files to list
Returns :-1 incase of error, 0 otherwise


xmlNanoFTPGetSocket ()

int         xmlNanoFTPGetSocket             (void *ctx,
+                                             const char *filename);

Initiate fetch of the given file from the server.

ctx : an FTP context
filename : the file to retrieve
Returns :the socket for the data connection, or <0 in case of error


xmlNanoFTPGet ()

int         xmlNanoFTPGet                   (void *ctx,
+                                             ftpDataCallback callback,
+                                             void *userData,
+                                             const char *filename);

Fetch the given file from the server. All data are passed back +in the callbacks. The last callback has a size of 0 block.

ctx : an FTP context
callback : the user callback
userData : the user callback data
filename : the file to retrieve
Returns :-1 incase of error, 0 otherwise


xmlNanoFTPRead ()

int         xmlNanoFTPRead                  (void *ctx,
+                                             void *dest,
+                                             int len);

This function tries to read len bytes from the existing FTP connection +and saves them in dest. This is a blocking call.

ctx : the FTP context
dest : a buffer
len : the buffer length
Returns :the number of byte read. 0 is an indication of an end of connection. +-1 indicates a parameter error.



<<< Previous PageHomeUpNext Page >>>
nanohttpxmlIO
\ No newline at end of file diff --git a/doc/html/gnome-xml-nanohttp.html b/doc/html/gnome-xml-nanohttp.html index d94b564c..03619d9c 100644 --- a/doc/html/gnome-xml-nanohttp.html +++ b/doc/html/gnome-xml-nanohttp.html @@ -15,8 +15,8 @@ REL="PREVIOUS" TITLE="xpath" HREF="gnome-xml-xpath.html">xmlIOnanoftp

Name

Synopsis

Description

Details























































































xmlIO
Gnome XML Library Reference Manual
<<< Previous PageHomeUpNext Page >>>

xmlIO

Name

xmlIO —

Description

Details

struct xmlParserInputBuffer

struct xmlParserInputBuffer {
+    /* Inputs */
+    FILE          *file;    /* Input on file handler */
+    void*        gzfile;    /* Input on a compressed stream */
+    int              fd;    /* Input on a file descriptor */
+    void        *httpIO;    /* Input from an HTTP stream */
+    void         *ftpIO;    /* Input from an FTP stream */
+    
+    xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
+    
+    xmlBufferPtr buffer;    /* Local buffer encoded in  UTF-8 */
+};


xmlParserInputBufferPtr

typedef xmlParserInputBuffer *xmlParserInputBufferPtr;


xmlAllocParserInputBuffer ()

xmlParserInputBufferPtr xmlAllocParserInputBuffer
+                                            (xmlCharEncoding enc);

Create a buffered parser input for progressive parsing

enc : the charset encoding if known
Returns :the new parser input or NULL


xmlParserInputBufferCreateFilename ()

xmlParserInputBufferPtr xmlParserInputBufferCreateFilename
+                                            (const char *filename,
+                                             xmlCharEncoding enc);

Create a buffered parser input for the progressive parsing of a file +If filename is "-' then we use stdin as the input. +Automatic support for ZLIB/Compress compressed document is provided +by default if found at compile-time.

filename : a C string containing the filename
enc : the charset encoding if known
Returns :the new parser input or NULL


xmlParserInputBufferCreateFile ()

xmlParserInputBufferPtr xmlParserInputBufferCreateFile
+                                            (FILE *file,
+                                             xmlCharEncoding enc);

Create a buffered parser input for the progressive parsing of a FILE * +buffered C I/O

file : a FILE*
enc : the charset encoding if known
Returns :the new parser input or NULL


xmlParserInputBufferCreateFd ()

xmlParserInputBufferPtr xmlParserInputBufferCreateFd
+                                            (int fd,
+                                             xmlCharEncoding enc);

Create a buffered parser input for the progressive parsing for the input +from a file descriptor

fd : a file descriptor number
enc : the charset encoding if known
Returns :the new parser input or NULL


xmlParserInputBufferRead ()

int         xmlParserInputBufferRead        (xmlParserInputBufferPtr in,
+                                             int len);

Refresh the content of the input buffer, the old data are considered +consumed +This routine handle the I18N transcoding to internal UTF-8

in : a buffered parser input
len : indicative value of the amount of chars to read
Returns :the number of chars read and stored in the buffer, or -1 +in case of error.


xmlParserInputBufferGrow ()

int         xmlParserInputBufferGrow        (xmlParserInputBufferPtr in,
+                                             int len);

Grow up the content of the input buffer, the old data are preserved +This routine handle the I18N transcoding to internal UTF-8 +This routine is used when operating the parser in normal (pull) mode +TODO: one should be able to remove one extra copy

in : a buffered parser input
len : indicative value of the amount of chars to read
Returns :the number of chars read and stored in the buffer, or -1 +in case of error.


xmlParserInputBufferPush ()

int         xmlParserInputBufferPush        (xmlParserInputBufferPtr in,
+                                             int len,
+                                             const char *buf);

Push the content of the arry in the input buffer +This routine handle the I18N transcoding to internal UTF-8 +This is used when operating the parser in progressive (push) mode.

in : a buffered parser input
len : the size in bytes of the array.
buf : an char array
Returns :the number of chars read and stored in the buffer, or -1 +in case of error.


xmlFreeParserInputBuffer ()

void        xmlFreeParserInputBuffer        (xmlParserInputBufferPtr in);

Free up the memory used by a buffered parser input

in : a buffered parser input


xmlParserGetDirectory ()

char*       xmlParserGetDirectory           (const char *filename);

filename : 
Returns : 

\ No newline at end of file diff --git a/doc/html/gnome-xml-xmlmemory.html b/doc/html/gnome-xml-xmlmemory.html index 7105c250..a9781b1d 100644 --- a/doc/html/gnome-xml-xmlmemory.html +++ b/doc/html/gnome-xml-xmlmemory.html @@ -103,7 +103,7 @@ ALIGN="right" >

Name

Synopsis

Description

Details
















+ + + + + + + + + + + + + + + + + + + + diff --git a/doc/html/libxml-lib.html b/doc/html/libxml-lib.html new file mode 100644 index 00000000..20f46d75 --- /dev/null +++ b/doc/html/libxml-lib.html @@ -0,0 +1,298 @@ +Libxml Library Reference
Gnome XML Library Reference Manual
<<< Previous PageHome Next Page >>>

Libxml Library Reference

Table of Contents
parser
SAX
tree
entities
valid
xml-error
HTMLparser
HTMLtree
xpath
nanohttp
nanoftp
xmlIO
parserInternals
encoding
debugXML
xmlmemory

This section contains the API reference for libxml. All + the public interfaces are documented here. This reference guide is + build by extracting comments from the code sources.



<<< Previous PageHome Next Page >>>
Libxml Programming Notesparser
\ No newline at end of file diff --git a/doc/html/libxml-notes.html b/doc/html/libxml-notes.html new file mode 100644 index 00000000..985cbef7 --- /dev/null +++ b/doc/html/libxml-notes.html @@ -0,0 +1,209 @@ +Libxml Programming Notes
Gnome XML Library Reference Manual
<<< Previous PageHome Next Page >>>

Libxml Programming Notes

Libxml is an XML toolkit library, it allows to parse, edit + search and write XML documents. There is also an HTML parser front-end + so the same range of tools can be used with HTML input.



<<< Previous PageHome Next Page >>>
Gnome XML Library Reference ManualLibxml Library Reference
\ No newline at end of file diff --git a/include/libxml/nanoftp.h b/include/libxml/nanoftp.h index 799a6fb3..84ee18df 100644 --- a/include/libxml/nanoftp.h +++ b/include/libxml/nanoftp.h @@ -12,24 +12,70 @@ extern "C" { #endif +/** + * ftpListCallback: + * A callback for the xmlNanoFTPList command + */ typedef void (*ftpListCallback) (void *userData, const char *filename, const char* attrib, const char *owner, const char *group, unsigned long size, int links, int year, const char *month, int day, int minute); +/** + * ftpDataCallback: + * A callback for the xmlNanoFTPGet command + */ typedef void (*ftpDataCallback) (void *userData, const char *data, int len); +/* + * Init + */ +void xmlNanoFTPInit (void); -void * xmlNanoFTPConnectTo (const char *hostname, int port); +/* + * Creating/freeing contexts + */ +void * xmlNanoFTPNewCtxt (const char *URL); +void xmlNanoFTPFreeCtxt (void * ctx); +void * xmlNanoFTPConnectTo (const char *server, + int port); +/* + * Opening/closing session connections + */ +void * xmlNanoFTPOpen (const char *URL); +int xmlNanoFTPConnect (void *ctx); int xmlNanoFTPClose (void *ctx); -void * xmlNanoFTPOpen (const char *URL); -int xmlNanoFTPFetch (const char *URL, +int xmlNanoFTPQuit (void *ctx); + + +/* + * Rathern internal commands + */ +int xmlNanoFTPGetResponse (void *ctx); +int xmlNanoFTPCheckResponse (void *ctx); + +/* + * CD/DIR/GET handlers + */ +int xmlNanoFTPCwd (void *ctx, + char *directory); + +int xmlNanoFTPGetConnection (void *ctx); +int xmlNanoFTPCloseConnection(void *ctx); +int xmlNanoFTPList (void *ctx, + ftpListCallback callback, + void *userData, + char *filename); +int xmlNanoFTPGetSocket (void *ctx, + const char *filename); +int xmlNanoFTPGet (void *ctx, + ftpDataCallback callback, + void *userData, const char *filename); int xmlNanoFTPRead (void *ctx, void *dest, int len); -int xmlNanoFTPGet (void *ctxt, ftpDataCallback callback, - void *userData, const char *filename); + #ifdef __cplusplus } #endif diff --git a/nanoftp.c b/nanoftp.c index dd90a3d3..c487c290 100644 --- a/nanoftp.c +++ b/nanoftp.c @@ -1,4 +1,4 @@ -/* +/** * ftp.c: basic handling of an FTP command connection to check for * directory availability. No transfer is needed. * @@ -154,7 +154,7 @@ xmlNanoFTPScanURL(void *ctx, const char *URL) { * Returns an FTP context or NULL in case of error. */ -xmlNanoFTPCtxtPtr +void * xmlNanoFTPNewCtxt(const char *URL) { xmlNanoFTPCtxtPtr ret; @@ -174,13 +174,14 @@ xmlNanoFTPNewCtxt(const char *URL) { /** * xmlNanoFTPFreeCtxt: - * @ctxt: an FTP context + * @ctx: an FTP context * * Frees the context after closing the connection. */ -static void -xmlNanoFTPFreeCtxt(xmlNanoFTPCtxtPtr ctxt) { +void +xmlNanoFTPFreeCtxt(void * ctx) { + xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; if (ctxt == NULL) return; if (ctxt->hostname != NULL) xmlFree(ctxt->hostname); if (ctxt->protocol != NULL) xmlFree(ctxt->protocol); @@ -191,24 +192,27 @@ xmlNanoFTPFreeCtxt(xmlNanoFTPCtxtPtr ctxt) { xmlFree(ctxt); } -/* +/** + * xmlNanoFTPInit: + * * Initialize the FTP handling. */ -void xmlNanoFTPInit(void) { +void +xmlNanoFTPInit(void) { static int done = 0; if (done) return; gethostname(hostname, sizeof(hostname)); done = 1; } -/* +/** * Parsing of the server answer, we just extract the code. * return 0 for errors * +XXX for last line of response * -XXX for response to be continued */ -int +static int xmlNanoFTPParseResponse(void *ctx, char *buf, int len) { int val = 0; @@ -233,12 +237,16 @@ xmlNanoFTPParseResponse(void *ctx, char *buf, int len) { return(val); } -/* +/** + * xmlNanoFTPReadResponse: + * @ctx: an FTP context + * @buf: buffer to read in + * @size: buffer length + * * Read the response from the FTP server after a command. * Returns the code number - * */ -int +static int xmlNanoFTPReadResponse(void *ctx, char *buf, int size) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char *ptr, *end; @@ -290,11 +298,14 @@ get_more: return(res / 100); } -/* +/** + * xmlNanoFTPGetResponse: + * @ctx: an FTP context + * * Get the response from the FTP server after a command. * Returns the code number - * */ + int xmlNanoFTPGetResponse(void *ctx) { char buf[16 * 1024 + 1]; @@ -315,10 +326,14 @@ xmlNanoFTPGetResponse(void *ctx) { return(xmlNanoFTPReadResponse(ctx, buf, 16 * 1024)); } -/* +/** + * xmlNanoFTPCheckResponse: + * @ctx: an FTP context + * * Check if there is a response from the FTP server after a command. * Returns the code number, or 0 */ + int xmlNanoFTPCheckResponse(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; @@ -344,12 +359,12 @@ xmlNanoFTPCheckResponse(void *ctx) { return(xmlNanoFTPReadResponse(ctx, buf, 1024)); } -/* +/** * Send the user authentification */ -int -sendUser(void *ctx) { +static int +xmlNanoFTPSendUser(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[200]; int len; @@ -367,12 +382,12 @@ sendUser(void *ctx) { return(0); } -/* +/** * Send the password authentification */ -int -sendPasswd(void *ctx) { +static int +xmlNanoFTPSendPasswd(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[200]; int len; @@ -390,12 +405,18 @@ sendPasswd(void *ctx) { return(0); } -/* - * Send a QUIT +/** + * xmlNanoFTPQuit: + * @ctx: an FTP context + * + * Send a QUIT command to the server + * + * Returns -1 in case of error, 0 otherwise */ + int -sendQuit(void *ctx) { +xmlNanoFTPQuit(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[200]; int len; @@ -409,8 +430,13 @@ sendQuit(void *ctx) { return(0); } -/* - * Connecting to the server, port 21 by default. +/** + * xmlNanoFTPConnect: + * @ctx: an FTP context + * + * Tries to open a control connection + * + * Returns -1 in case of error, 0 otherwise */ int @@ -496,7 +522,7 @@ xmlNanoFTPConnect(void *ctx) { * | |---------->| W | 4,5 -------->| F | * +---+ +---+------------->+---+ */ - res = sendUser(ctxt); + res = xmlNanoFTPSendUser(ctxt); if (res < 0) { close(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; @@ -517,7 +543,7 @@ xmlNanoFTPConnect(void *ctx) { ctxt->controlFd = -1; return(-1); } - res = sendPasswd(ctxt); + res = xmlNanoFTPSendPasswd(ctxt); if (res < 0) { close(ctxt->controlFd); ctxt->controlFd = -1; ctxt->controlFd = -1; @@ -542,10 +568,17 @@ xmlNanoFTPConnect(void *ctx) { return(0); } -/* - * Connecting to a given server server/port +/** + * xmlNanoFTPConnectTo: + * @server: an FTP server name + * @directory: the port (use 21 if 0) + * + * Tries to open a control connection to the given server/port + * + * Returns and fTP context or NULL if it failed */ + void * xmlNanoFTPConnectTo(const char *server, int port) { xmlNanoFTPCtxtPtr ctxt; @@ -566,8 +599,14 @@ xmlNanoFTPConnectTo(const char *server, int port) { return(ctxt); } -/* - * Check an FTP directory on the server +/** + * xmlNanoFTPGetConnection: + * @ctx: an FTP context + * @directory: a directory on the server + * + * Tries to change the remote directory + * + * Returns -1 incase of error, 1 if CWD worked, 0 if it failed */ int @@ -592,8 +631,6 @@ xmlNanoFTPCwd(void *ctx, char *directory) { if (res < 0) return(res); res = xmlNanoFTPGetResponse(ctxt); if (res == 4) { - close(ctxt->controlFd); ctxt->controlFd = -1; - ctxt->controlFd = -1; return(-1); } if (res == 2) return(1); @@ -603,9 +640,16 @@ xmlNanoFTPCwd(void *ctx, char *directory) { return(0); } -/* - * xmlNanoFTPGetConnection +/** + * xmlNanoFTPGetConnection: + * @ctx: an FTP context + * + * Try to open a data connection to the server. Currently only + * passive mode is supported. + * + * Returns -1 incase of error, 0 otherwise */ + int xmlNanoFTPGetConnection(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; @@ -705,9 +749,15 @@ xmlNanoFTPGetConnection(void *ctx) { } -/* - * xmlNanoFTPCloseConnection +/** + * xmlNanoFTPCloseConnection: + * @ctx: an FTP context + * + * Close the data connection from the server + * + * Returns -1 incase of error, 0 otherwise */ + int xmlNanoFTPCloseConnection(void *ctx) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; @@ -716,15 +766,21 @@ xmlNanoFTPCloseConnection(void *ctx) { close(ctxt->dataFd); ctxt->dataFd = -1; res = xmlNanoFTPGetResponse(ctxt); if (res != 2) { - close(ctxt->dataFd); ctxt->dataFd = -1; close(ctxt->controlFd); ctxt->controlFd = -1; return(-1); } return(0); } -/* - * xmlNanoFTPParseList +/** + * xmlNanoFTPParseList: + * @list: some data listing received from the server + * @callback: the user callback + * @userData: the user callback data + * + * Parse at most one entry from the listing. + * + * Returns -1 incase of error, the lenght of data parsed otherwise */ static int @@ -842,11 +898,22 @@ xmlNanoFTPParseList(const char *list, ftpListCallback callback, void *userData) return(cur - list); } -/* - * xmlNanoFTPList +/** + * xmlNanoFTPList: + * @ctx: an FTP context + * @callback: the user callback + * @userData: the user callback data + * @filename: optional files to list + * + * Do a listing on the server. All files info are passed back + * in the callbacks. + * + * Returns -1 incase of error, 0 otherwise */ + int -xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData) { +xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData, + char *filename) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[4096 + 1]; int len, res; @@ -856,7 +923,10 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData) { ctxt->dataFd = xmlNanoFTPGetConnection(ctxt); - len = snprintf(buf, sizeof(buf), "LIST -L\r\n"); + if (filename != NULL) + len = snprintf(buf, sizeof(buf), "LIST -L %s\r\n", filename); + else + len = snprintf(buf, sizeof(buf), "LIST -L\r\n"); #ifdef DEBUG_FTP printf(buf); #endif @@ -927,10 +997,17 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData) { return(0); } -/* +/** * xmlNanoFTPGetSocket: + * @ctx: an FTP context + * @filename: the file to retrieve + * + * Initiate fetch of the given file from the server. + * + * Returns the socket for the data connection, or <0 in case of error */ + int xmlNanoFTPGetSocket(void *ctx, const char *filename) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; @@ -971,11 +1048,22 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) { return(ctxt->dataFd); } -/* - * xmlNanoFTPList +/** + * xmlNanoFTPGet: + * @ctx: an FTP context + * @callback: the user callback + * @userData: the user callback data + * @filename: the file to retrieve + * + * Fetch the given file from the server. All data are passed back + * in the callbacks. The last callback has a size of 0 block. + * + * Returns -1 incase of error, 0 otherwise */ + int -xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData, const char *filename) { +xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData, + const char *filename) { xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; char buf[4096]; int len = 0, res; @@ -1058,11 +1146,13 @@ xmlNanoFTPRead(void *ctx, void *dest, int len) { return(len); } -/* +/** * xmlNanoFTPOpen: * @URL: the URL to the resource * * Start to fetch the given ftp:// resource + * + * Returns an FTP context, or NULL */ void * @@ -1088,8 +1178,13 @@ xmlNanoFTPOpen(const char *URL) { return(ctxt); } -/* - * Disconnect from the FTP server. +/** + * xmlNanoFTPClose: + * @ctx: an FTP context + * + * Close the connection and both control and transport + * + * Returns -1 incase of error, 0 otherwise */ int @@ -1104,7 +1199,7 @@ xmlNanoFTPClose(void *ctx) { ctxt->dataFd = -1; } if (ctxt->controlFd >= 0) { - sendQuit(ctxt); + xmlNanoFTPQuit(ctxt); close(ctxt->controlFd); ctxt->controlFd = -1; } @@ -1171,7 +1266,7 @@ int main(int argc, char **argv) { } else { fprintf(stderr, "/toto : CWD successful\n"); } - xmlNanoFTPList(ctxt, ftpList, NULL); + xmlNanoFTPList(ctxt, ftpList, NULL, NULL); output = fopen("/tmp/tstdata", "w"); if (output != NULL) { if (xmlNanoFTPGet(ctxt, ftpData, (void *) output, tstfile) < 0) diff --git a/nanoftp.h b/nanoftp.h index 799a6fb3..84ee18df 100644 --- a/nanoftp.h +++ b/nanoftp.h @@ -12,24 +12,70 @@ extern "C" { #endif +/** + * ftpListCallback: + * A callback for the xmlNanoFTPList command + */ typedef void (*ftpListCallback) (void *userData, const char *filename, const char* attrib, const char *owner, const char *group, unsigned long size, int links, int year, const char *month, int day, int minute); +/** + * ftpDataCallback: + * A callback for the xmlNanoFTPGet command + */ typedef void (*ftpDataCallback) (void *userData, const char *data, int len); +/* + * Init + */ +void xmlNanoFTPInit (void); -void * xmlNanoFTPConnectTo (const char *hostname, int port); +/* + * Creating/freeing contexts + */ +void * xmlNanoFTPNewCtxt (const char *URL); +void xmlNanoFTPFreeCtxt (void * ctx); +void * xmlNanoFTPConnectTo (const char *server, + int port); +/* + * Opening/closing session connections + */ +void * xmlNanoFTPOpen (const char *URL); +int xmlNanoFTPConnect (void *ctx); int xmlNanoFTPClose (void *ctx); -void * xmlNanoFTPOpen (const char *URL); -int xmlNanoFTPFetch (const char *URL, +int xmlNanoFTPQuit (void *ctx); + + +/* + * Rathern internal commands + */ +int xmlNanoFTPGetResponse (void *ctx); +int xmlNanoFTPCheckResponse (void *ctx); + +/* + * CD/DIR/GET handlers + */ +int xmlNanoFTPCwd (void *ctx, + char *directory); + +int xmlNanoFTPGetConnection (void *ctx); +int xmlNanoFTPCloseConnection(void *ctx); +int xmlNanoFTPList (void *ctx, + ftpListCallback callback, + void *userData, + char *filename); +int xmlNanoFTPGetSocket (void *ctx, + const char *filename); +int xmlNanoFTPGet (void *ctx, + ftpDataCallback callback, + void *userData, const char *filename); int xmlNanoFTPRead (void *ctx, void *dest, int len); -int xmlNanoFTPGet (void *ctxt, ftpDataCallback callback, - void *userData, const char *filename); + #ifdef __cplusplus } #endif