-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxstring.h
More file actions
35 lines (27 loc) · 1.01 KB
/
xstring.h
File metadata and controls
35 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* xstring public C API
* by Chip Salzenberg <chip@pobox.com>
*/
#ifndef XSTRING_H
#define XSTRING_H
#include <lua.h>
#ifdef _cplusplus
extern "C" {
#endif
typedef struct xsbuf {
unsigned refs;
const char *data;
size_t size;
} xsbuf_t;
xsbuf_t * xsbuf_new(const char *data, size_t size);
xsbuf_t * xsbuf_use(xsbuf_t *b); /* xsbuf's refcount ++ */
void xsbuf_discard(xsbuf_t *b); /* xsbuf's refcount -- */
void xsbuf_kill(xsbuf_t *b); /* "those data are gone" */
int xsbuf_valid(xsbuf_t *b); /* "are the data still there?" */
int xstring_new(lua_State *L, xsbuf_t *b); /* 0=fail 1=ok */
xsbuf_t * xstring_toxsbuf(lua_State *L, int n); /* does not throw */
const char * xstring_toaddr(lua_State *L, int n, size_t *l); /* does not throw */
const char * xstring_check(lua_State *L, int n, size_t *l); /* throws */
#ifdef _cplusplus
} /* extern "C" */
#endif
#endif /* XSTRING_H */