MACSio  0.9
Multi-purpose, Application-Centric, Scalable I/O Proxy App
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
printbuf.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bits.h"
#include "debug.h"
#include "printbuf.h"

Go to the source code of this file.

Functions

static int printbuf_extend (struct printbuf *p, int min_size)
 
struct printbufprintbuf_new (void)
 
int printbuf_memappend (struct printbuf *p, const char *buf, int size)
 
int printbuf_memset (struct printbuf *pb, int offset, int charvalue, int len)
 
static int vasprintf (char **buf, const char *fmt, va_list ap)
 
int sprintbuf (struct printbuf *p, const char *msg,...)
 
void printbuf_reset (struct printbuf *p)
 
void printbuf_free (struct printbuf *p)
 

Function Documentation

static int printbuf_extend ( struct printbuf p,
int  min_size 
)
static

Extend the buffer p so it has a size of at least min_size.

If the current size is large enough, nothing is changed.

Note: this does not check the available space! The caller is responsible for performing those calculations.

Definition at line 58 of file printbuf.c.

struct printbuf* printbuf_new ( void  )

Definition at line 34 of file printbuf.c.

int printbuf_memappend ( struct printbuf p,
const char *  buf,
int  size 
)

Definition at line 79 of file printbuf.c.

int printbuf_memset ( struct printbuf pb,
int  offset,
int  charvalue,
int  len 
)

Set len bytes of the buffer to charvalue, starting at offset offset. Similar to calling memset(x, charvalue, len);

The memory allocated for the buffer is extended as necessary.

If offset is -1, this starts at the end of the current data in the buffer.

Definition at line 91 of file printbuf.c.

static int vasprintf ( char **  buf,
const char *  fmt,
va_list  ap 
)
static

Definition at line 119 of file printbuf.c.

int sprintbuf ( struct printbuf p,
const char *  msg,
  ... 
)

Definition at line 152 of file printbuf.c.

void printbuf_reset ( struct printbuf p)

Definition at line 180 of file printbuf.c.

void printbuf_free ( struct printbuf p)

Definition at line 186 of file printbuf.c.