Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../usr/include/json-c
File: printbuf.h
/*
[0] Fix | Delete
* $Id: printbuf.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
[1] Fix | Delete
*
[2] Fix | Delete
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
[3] Fix | Delete
* Michael Clark <michael@metaparadigm.com>
[4] Fix | Delete
*
[5] Fix | Delete
* This library is free software; you can redistribute it and/or modify
[6] Fix | Delete
* it under the terms of the MIT license. See COPYING for details.
[7] Fix | Delete
*
[8] Fix | Delete
*
[9] Fix | Delete
* Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.
[10] Fix | Delete
* The copyrights to the contents of this file are licensed under the MIT License
[11] Fix | Delete
* (http://www.opensource.org/licenses/mit-license.php)
[12] Fix | Delete
*/
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* @file
[16] Fix | Delete
* @brief Internal string buffer handing. Unless you're writing a
[17] Fix | Delete
* json_object_to_json_string_fn implementation for use with
[18] Fix | Delete
* json_object_set_serializer() direct use of this is not
[19] Fix | Delete
* recommended.
[20] Fix | Delete
*/
[21] Fix | Delete
#ifndef _printbuf_h_
[22] Fix | Delete
#define _printbuf_h_
[23] Fix | Delete
[24] Fix | Delete
#ifdef __cplusplus
[25] Fix | Delete
extern "C" {
[26] Fix | Delete
#endif
[27] Fix | Delete
[28] Fix | Delete
struct printbuf {
[29] Fix | Delete
char *buf;
[30] Fix | Delete
int bpos;
[31] Fix | Delete
int size;
[32] Fix | Delete
};
[33] Fix | Delete
typedef struct printbuf printbuf;
[34] Fix | Delete
[35] Fix | Delete
extern struct printbuf*
[36] Fix | Delete
printbuf_new(void);
[37] Fix | Delete
[38] Fix | Delete
/* As an optimization, printbuf_memappend_fast() is defined as a macro
[39] Fix | Delete
* that handles copying data if the buffer is large enough; otherwise
[40] Fix | Delete
* it invokes printbuf_memappend() which performs the heavy
[41] Fix | Delete
* lifting of realloc()ing the buffer and copying data.
[42] Fix | Delete
*
[43] Fix | Delete
* Your code should not use printbuf_memappend() directly unless it
[44] Fix | Delete
* checks the return code. Use printbuf_memappend_fast() instead.
[45] Fix | Delete
*/
[46] Fix | Delete
extern int
[47] Fix | Delete
printbuf_memappend(struct printbuf *p, const char *buf, int size);
[48] Fix | Delete
[49] Fix | Delete
#define printbuf_memappend_fast(p, bufptr, bufsize) \
[50] Fix | Delete
do { \
[51] Fix | Delete
if ((p->size - p->bpos) > bufsize) { \
[52] Fix | Delete
memcpy(p->buf + p->bpos, (bufptr), bufsize); \
[53] Fix | Delete
p->bpos += bufsize; \
[54] Fix | Delete
p->buf[p->bpos]= '\0'; \
[55] Fix | Delete
} else { printbuf_memappend(p, (bufptr), bufsize); } \
[56] Fix | Delete
} while (0)
[57] Fix | Delete
[58] Fix | Delete
#define printbuf_length(p) ((p)->bpos)
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Results in a compile error if the argument is not a string literal.
[62] Fix | Delete
*/
[63] Fix | Delete
#define _printbuf_check_literal(mystr) ("" mystr)
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* This is an optimization wrapper around printbuf_memappend() that is useful
[67] Fix | Delete
* for appending string literals. Since the size of string constants is known
[68] Fix | Delete
* at compile time, using this macro can avoid a costly strlen() call. This is
[69] Fix | Delete
* especially helpful when a constant string must be appended many times. If
[70] Fix | Delete
* you got here because of a compilation error caused by passing something
[71] Fix | Delete
* other than a string literal, use printbuf_memappend_fast() in conjunction
[72] Fix | Delete
* with strlen().
[73] Fix | Delete
*
[74] Fix | Delete
* See also:
[75] Fix | Delete
* printbuf_memappend_fast()
[76] Fix | Delete
* printbuf_memappend()
[77] Fix | Delete
* sprintbuf()
[78] Fix | Delete
*/
[79] Fix | Delete
#define printbuf_strappend(pb, str) \
[80] Fix | Delete
printbuf_memappend ((pb), _printbuf_check_literal(str), sizeof(str) - 1)
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* Set len bytes of the buffer to charvalue, starting at offset offset.
[84] Fix | Delete
* Similar to calling memset(x, charvalue, len);
[85] Fix | Delete
*
[86] Fix | Delete
* The memory allocated for the buffer is extended as necessary.
[87] Fix | Delete
*
[88] Fix | Delete
* If offset is -1, this starts at the end of the current data in the buffer.
[89] Fix | Delete
*/
[90] Fix | Delete
extern int
[91] Fix | Delete
printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len);
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Formatted print to printbuf.
[95] Fix | Delete
*
[96] Fix | Delete
* This function is the most expensive of the available functions for appending
[97] Fix | Delete
* string data to a printbuf and should be used only where convenience is more
[98] Fix | Delete
* important than speed. Avoid using this function in high performance code or
[99] Fix | Delete
* tight loops; in these scenarios, consider using snprintf() with a static
[100] Fix | Delete
* buffer in conjunction with one of the printbuf_*append() functions.
[101] Fix | Delete
*
[102] Fix | Delete
* See also:
[103] Fix | Delete
* printbuf_memappend_fast()
[104] Fix | Delete
* printbuf_memappend()
[105] Fix | Delete
* printbuf_strappend()
[106] Fix | Delete
*/
[107] Fix | Delete
extern int
[108] Fix | Delete
sprintbuf(struct printbuf *p, const char *msg, ...);
[109] Fix | Delete
[110] Fix | Delete
extern void
[111] Fix | Delete
printbuf_reset(struct printbuf *p);
[112] Fix | Delete
[113] Fix | Delete
extern void
[114] Fix | Delete
printbuf_free(struct printbuf *p);
[115] Fix | Delete
[116] Fix | Delete
#ifdef __cplusplus
[117] Fix | Delete
}
[118] Fix | Delete
#endif
[119] Fix | Delete
[120] Fix | Delete
#endif
[121] Fix | Delete
[122] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function