0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Typedefs | Functions
fmemopen.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
Include dependency graph for fmemopen.c:

Go to the source code of this file.

Classes

struct  fmem
 

Typedefs

typedef struct fmem fmem_t
 

Functions

static int readfn (void *handler, char *buf, int size)
 
static int writefn (void *handler, const char *buf, int size)
 
static fpos_t seekfn (void *handler, fpos_t offset, int whence)
 
static int closefn (void *handler)
 
FILE * fmemopen (void *buf, size_t size, const char *mode)
 A BSD port of the fmemopen Linux method using funopen. More...
 

Typedef Documentation

typedef struct fmem fmem_t

Definition at line 28 of file fmemopen.c.

Function Documentation

static int closefn ( void *  handler)
static

Definition at line 89 of file fmemopen.c.

FILE* fmemopen ( void *  buf,
size_t  size,
const char *  mode 
)

A BSD port of the fmemopen Linux method using funopen.

man docs for fmemopen: http://linux.die.net/man/3/fmemopen

man docs for funopen: https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html

This method is ported from ingenuitas' python-tesseract project.

You must call fclose on the returned file pointer or memory will be leaked.

Parameters
bufThe data that will be used to back the FILE* methods. Must be at least size bytes.
sizeThe size of the buf data.
modeThe permitted stream operation modes.
Returns
A pointer that can be used in the fread/fwrite/fseek/fclose family of methods. If a failure occurred NULL will be returned.

Definition at line 94 of file fmemopen.c.

static int readfn ( void *  handler,
char *  buf,
int  size 
)
static

Definition at line 30 of file fmemopen.c.

static fpos_t seekfn ( void *  handler,
fpos_t  offset,
int  whence 
)
static

Definition at line 56 of file fmemopen.c.

static int writefn ( void *  handler,
const char *  buf,
int  size 
)
static

Definition at line 43 of file fmemopen.c.