![]() |
![]()
| ![]() |
![]()
NAMEmetalink_parse_update, metalink_parse_final, metalink_parser_context_new, metalink_parser_context_delete - Parse Metalink file and create metalink_t object. SYNOPSIS#include <metalink/metalink.h> metalink_error_t
metalink_parse_update(metalink_parser_context_t *ctx,
const char *buf, size_t len);
metalink_parser_context_t* metalink_parser_context_new();
DESCRIPTIONThese functions provide a push interface for parsing Metalink XML files. Before calling metalink_parse_update() and metalink_parse_final(), metalink_parse_context_t has to be created by metalink_parser_context_new(). In each call of metalink_parse_update(), len bytes of buf are processed. At the last piece of data, call metalink_parse_final() to get metalink_t(3) structure as a result. Giving 0 as len is permitted. metalink_parse_final() calls metalink_parser_context_delete() internally to deallocate the memory for passed metalink_parser_context_t. Therefore you don't have to call metlaink_parser_context_delete() if you call metalink_parse_final(). Otherwise call metalink_parser_context_delete() to free the allocated resource. You don't have to allocate memory for metalink_t(3) structure. metalink_parse_final() takes the pointer of metalink_t(3) pointer and allocates memory for that pointer. The caller must free the memory allocated for metalink_t(3) structure using metalink_delete(3) if it is no longer used. RETURN VALUEmetalink_parse_update(), metalink_parse_final() return 0 for success. When error occurred, non-zero value error code is returned. If error occurred, metalink_parse_final() does not allocate memory for metalink_t. The error codes are described in metalink_error.h. In case of success, metalink_parser_context_new() allocates memory for metalink_parser_context_t() and returns the pointer to it. In case of failure, metalink_parser_context_new() returns NULL. metalink_parser_context_delete() returns no value. EXAMPLE#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <string.h> #include <unistd.h> #include <metalink/metalink.h> int main(int argc, char** argv) { SEE ALSOmetalink_delete(3), metalink_parse_file(3), metalink_t(3)
|