Kannel: Open Source WAP and SMS gateway  svn-r5335
ota_compiler.h File Reference
#include "gwlib/gwlib.h"

Go to the source code of this file.

Functions

int ota_compile (Octstr *ota_doc, Octstr *charset, Octstr **ota_binary)
 

Function Documentation

◆ ota_compile()

int ota_compile ( Octstr ota_doc,
Octstr charset,
Octstr **  ota_binary 
)

Definition at line 473 of file ota_compiler.c.

References charset, error(), octstr_create, octstr_destroy(), octstr_get_cstr, octstr_len(), octstr_shrink_blanks(), octstr_strip_blanks(), parse_document(), set_charset(), simple_binary_create(), simple_binary_destroy(), simple_binary_output(), and size.

Referenced by main(), and ota_pack_message().

474 {
475  simple_binary_t *otabxml;
476  int ret;
477  xmlDocPtr pDoc;
478  size_t size;
479  char *ota_c_text;
480 
481  *ota_binary = octstr_create("");
482  otabxml = simple_binary_create();
483 
484  octstr_strip_blanks(ota_doc);
485  octstr_shrink_blanks(ota_doc);
486  set_charset(ota_doc, charset);
487  size = octstr_len(ota_doc);
488  ota_c_text = octstr_get_cstr(ota_doc);
489  pDoc = xmlParseMemory(ota_c_text, size);
490 
491  ret = 0;
492  if (pDoc) {
493  ret = parse_document(pDoc, charset, &otabxml);
494  simple_binary_output(*ota_binary, otabxml);
495  xmlFreeDoc(pDoc);
496  } else {
497  xmlFreeDoc(pDoc);
498  octstr_destroy(*ota_binary);
499  simple_binary_destroy(otabxml);
500  error(0, "OTA: No document to parse. Probably an error in OTA source");
501  return -1;
502  }
503 
504  simple_binary_destroy(otabxml);
505 
506  return ret;
507 }
void error(int err, const char *fmt,...)
Definition: log.c:648
int size
Definition: wsasm.c:84
void octstr_strip_blanks(Octstr *text)
Definition: octstr.c:1346
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
Octstr * charset
Definition: test_ota.c:68
void simple_binary_destroy(simple_binary_t *binary)
Definition: xml_shared.c:298
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
#define octstr_create(cstr)
Definition: octstr.h:125
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
void simple_binary_output(Octstr *os, simple_binary_t *binary)
Definition: xml_shared.c:311
static int parse_document(xmlDocPtr document, Octstr *charset, simple_binary_t **ota_binary)
Definition: ota_compiler.c:518
void set_charset(Octstr *document, Octstr *charset)
Definition: xml_shared.c:111
simple_binary_t * simple_binary_create(void)
Definition: xml_shared.c:284
void octstr_shrink_blanks(Octstr *text)
Definition: octstr.c:1433
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.