libksba  1.6.0
About: KSBA is a library to make the tasks of working with X.509 certificates, CMS data and related objects more easy.
  Fossies Dox: libksba-1.6.0.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

writer.c File Reference
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include "util.h"
#include "ksba.h"
#include "writer.h"
#include "asn1-func.h"
#include "ber-help.h"
Include dependency graph for writer.c:

Go to the source code of this file.

Functions

gpg_error_t _ksba_writer_new (ksba_writer_t *r_w)
 
void _ksba_writer_release (ksba_writer_t w)
 
gpg_error_t ksba_writer_set_release_notify (ksba_writer_t w, void(*notify)(void *, ksba_writer_t), void *notify_value)
 
int _ksba_writer_error (ksba_writer_t w)
 
unsigned long _ksba_writer_tell (ksba_writer_t w)
 
gpg_error_t _ksba_writer_set_fd (ksba_writer_t w, int fd)
 
gpg_error_t _ksba_writer_set_file (ksba_writer_t w, FILE *fp)
 
gpg_error_t _ksba_writer_set_cb (ksba_writer_t w, int(*cb)(void *, const void *, size_t), void *cb_value)
 
gpg_error_t _ksba_writer_set_mem (ksba_writer_t w, size_t initial_size)
 
const void * _ksba_writer_get_mem (ksba_writer_t w, size_t *nbytes)
 
void * _ksba_writer_snatch_mem (ksba_writer_t w, size_t *nbytes)
 
gpg_error_t _ksba_writer_set_filter (ksba_writer_t w, gpg_error_t(*filter)(void *, const void *, size_t, size_t *, void *, size_t, size_t *), void *filter_arg)
 
static gpg_error_t do_writer_write (ksba_writer_t w, const void *buffer, size_t length)
 
gpg_error_t _ksba_writer_write (ksba_writer_t w, const void *buffer, size_t length)
 
gpg_error_t _ksba_writer_write_octet_string (ksba_writer_t w, const void *buffer, size_t length, int flush)
 

Function Documentation

◆ _ksba_writer_error()

int _ksba_writer_error ( ksba_writer_t  w)

Definition at line 106 of file writer.c.

References ksba_writer_s::error, GPG_ERR_INV_VALUE, and gpg_error.

◆ _ksba_writer_get_mem()

const void* _ksba_writer_get_mem ( ksba_writer_t  w,
size_t *  nbytes 
)

◆ _ksba_writer_new()

gpg_error_t _ksba_writer_new ( ksba_writer_t r_w)

ksba_writer_new:

Create a new but uninitialized ksba_writer_t Object. Using this write object in unitialized state does always return an error.

Return value: ksba_writer_t object or an error code.

Definition at line 53 of file writer.c.

References xtrycalloc.

◆ _ksba_writer_release()

void _ksba_writer_release ( ksba_writer_t  w)

ksba_writer_release: @w: Writer Object (or NULL)

Release this object

Definition at line 70 of file writer.c.

References ksba_writer_s::buffer, ksba_writer_s::mem, ksba_writer_s::notify_cb, ksba_writer_s::notify_cb_value, ksba_writer_s::type, ksba_writer_s::u, WRITER_TYPE_MEM, and xfree.

◆ _ksba_writer_set_cb()

gpg_error_t _ksba_writer_set_cb ( ksba_writer_t  w,
int(*)(void *, const void *, size_t)  cb,
void *  cb_value 
)

ksba_writer_set_cb: @w: Writer object @cb: Callback function @cb_value: Value passed to the callback function

Initialize the writer object with a callback function. This callback function is defined as: <literal> typedef int (*cb) (void *cb_value, const void *buffer, size_t count); </literal>

The callback is expected to process all @count bytes from @buffer @count should not be 0 and @buffer should not be NULL The callback should return 0 on success or an KSBA_xxx error code.

Return value: 0 on success or an error code

Definition at line 189 of file writer.c.

References ksba_writer_s::cb, ksba_writer_s::error, ksba_writer_s::fnc, GPG_ERR_INV_VALUE, gpg_error, ksba_writer_s::type, ksba_writer_s::u, ksba_writer_s::value, and WRITER_TYPE_CB.

◆ _ksba_writer_set_fd()

gpg_error_t _ksba_writer_set_fd ( ksba_writer_t  w,
int  fd 
)

ksba_writer_set_fd: @w: Writer object @fd: file descriptor

Initialize the Writer object with a file descriptor, so that write operations on this object are excuted on this file descriptor.

Return value:

Definition at line 129 of file writer.c.

References ksba_writer_s::error, ksba_writer_s::fd, GPG_ERR_INV_VALUE, gpg_error, ksba_writer_s::type, ksba_writer_s::u, and WRITER_TYPE_FD.

◆ _ksba_writer_set_file()

gpg_error_t _ksba_writer_set_file ( ksba_writer_t  w,
FILE *  fp 
)

ksba_writer_set_file: @w: Writer object @fp: file pointer

Initialize the Writer object with a stdio file pointer, so that write operations on this object are excuted on this stream

Return value:

Definition at line 154 of file writer.c.

References ksba_writer_s::error, ksba_writer_s::file, GPG_ERR_INV_VALUE, gpg_error, ksba_writer_s::type, ksba_writer_s::u, and WRITER_TYPE_FILE.

◆ _ksba_writer_set_filter()

gpg_error_t _ksba_writer_set_filter ( ksba_writer_t  w,
gpg_error_t(*)(void *, const void *, size_t, size_t *, void *, size_t, size_t *)  filter,
void *  filter_arg 
)

◆ _ksba_writer_set_mem()

◆ _ksba_writer_snatch_mem()

void* _ksba_writer_snatch_mem ( ksba_writer_t  w,
size_t *  nbytes 
)

◆ _ksba_writer_tell()

unsigned long _ksba_writer_tell ( ksba_writer_t  w)

Definition at line 112 of file writer.c.

References ksba_writer_s::nwritten.

◆ _ksba_writer_write()

gpg_error_t _ksba_writer_write ( ksba_writer_t  w,
const void *  buffer,
size_t  length 
)

ksba_writer_write: @w: Writer object @buffer: A buffer with the data to be written @length: The length of this buffer

Write @length bytes from @buffer.

Return value: 0 on success or an error code

Definition at line 376 of file writer.c.

References do_writer_write(), ksba_writer_s::filter, ksba_writer_s::filter_arg, GPG_ERR_BUG, GPG_ERR_INV_VALUE, and gpg_error.

◆ _ksba_writer_write_octet_string()

gpg_error_t _ksba_writer_write_octet_string ( ksba_writer_t  w,
const void *  buffer,
size_t  length,
int  flush 
)

◆ do_writer_write()

◆ ksba_writer_set_release_notify()

gpg_error_t ksba_writer_set_release_notify ( ksba_writer_t  w,
void(*)(void *, ksba_writer_t notify,
void *  notify_value 
)