Example #1
0
scew_reader*
scew_reader_fp_create (FILE *file)
{
    scew_reader *reader = NULL;
    scew_reader_fp *fp_reader = NULL;

    assert (file != NULL);

    fp_reader = calloc (1, sizeof (scew_reader_fp));

    if (fp_reader != NULL)
    {
        fp_reader->file = file;
        fp_reader->closed = SCEW_FALSE;

        /* Create reader */
        reader = scew_reader_create (&file_hooks_, fp_reader);
        if (NULL == reader)
        {
            free (fp_reader);
        }
    }

    return reader;
}
Example #2
0
scew_reader*
scew_reader_buffer_create (XML_Char const *buffer, size_t size)
{
  scew_reader *reader = NULL;
  scew_reader_buffer *buf_reader = NULL;

  assert (buffer != NULL);
  assert (size > 0);

  buf_reader = calloc (1, sizeof (scew_reader_buffer));
  if (buf_reader != NULL)
    {
      buf_reader->buffer = buffer;
      buf_reader->size = size;
      buf_reader->current = 0;

      /* Create reader */
      reader = scew_reader_create (&buffer_hooks_, buf_reader);
      if (NULL == reader)
        {
          free (buf_reader);
        }
    }

  return reader;
}