tf5-5.0beta8/.git/
tf5-5.0beta8/.git/info/
tf5-5.0beta8/.git/logs/
tf5-5.0beta8/.git/logs/refs/heads/
tf5-5.0beta8/.git/objects/00/
tf5-5.0beta8/.git/objects/01/
tf5-5.0beta8/.git/objects/04/
tf5-5.0beta8/.git/objects/05/
tf5-5.0beta8/.git/objects/07/
tf5-5.0beta8/.git/objects/09/
tf5-5.0beta8/.git/objects/0a/
tf5-5.0beta8/.git/objects/0c/
tf5-5.0beta8/.git/objects/0e/
tf5-5.0beta8/.git/objects/12/
tf5-5.0beta8/.git/objects/13/
tf5-5.0beta8/.git/objects/14/
tf5-5.0beta8/.git/objects/16/
tf5-5.0beta8/.git/objects/17/
tf5-5.0beta8/.git/objects/19/
tf5-5.0beta8/.git/objects/1c/
tf5-5.0beta8/.git/objects/1d/
tf5-5.0beta8/.git/objects/1e/
tf5-5.0beta8/.git/objects/1f/
tf5-5.0beta8/.git/objects/20/
tf5-5.0beta8/.git/objects/21/
tf5-5.0beta8/.git/objects/23/
tf5-5.0beta8/.git/objects/27/
tf5-5.0beta8/.git/objects/29/
tf5-5.0beta8/.git/objects/2a/
tf5-5.0beta8/.git/objects/2b/
tf5-5.0beta8/.git/objects/2f/
tf5-5.0beta8/.git/objects/30/
tf5-5.0beta8/.git/objects/33/
tf5-5.0beta8/.git/objects/34/
tf5-5.0beta8/.git/objects/35/
tf5-5.0beta8/.git/objects/39/
tf5-5.0beta8/.git/objects/3c/
tf5-5.0beta8/.git/objects/3d/
tf5-5.0beta8/.git/objects/3f/
tf5-5.0beta8/.git/objects/40/
tf5-5.0beta8/.git/objects/41/
tf5-5.0beta8/.git/objects/42/
tf5-5.0beta8/.git/objects/44/
tf5-5.0beta8/.git/objects/46/
tf5-5.0beta8/.git/objects/47/
tf5-5.0beta8/.git/objects/48/
tf5-5.0beta8/.git/objects/4a/
tf5-5.0beta8/.git/objects/4d/
tf5-5.0beta8/.git/objects/4f/
tf5-5.0beta8/.git/objects/53/
tf5-5.0beta8/.git/objects/54/
tf5-5.0beta8/.git/objects/58/
tf5-5.0beta8/.git/objects/5b/
tf5-5.0beta8/.git/objects/5c/
tf5-5.0beta8/.git/objects/5e/
tf5-5.0beta8/.git/objects/5f/
tf5-5.0beta8/.git/objects/60/
tf5-5.0beta8/.git/objects/61/
tf5-5.0beta8/.git/objects/62/
tf5-5.0beta8/.git/objects/63/
tf5-5.0beta8/.git/objects/66/
tf5-5.0beta8/.git/objects/67/
tf5-5.0beta8/.git/objects/6c/
tf5-5.0beta8/.git/objects/6e/
tf5-5.0beta8/.git/objects/72/
tf5-5.0beta8/.git/objects/73/
tf5-5.0beta8/.git/objects/75/
tf5-5.0beta8/.git/objects/77/
tf5-5.0beta8/.git/objects/7a/
tf5-5.0beta8/.git/objects/7b/
tf5-5.0beta8/.git/objects/7c/
tf5-5.0beta8/.git/objects/7e/
tf5-5.0beta8/.git/objects/7f/
tf5-5.0beta8/.git/objects/81/
tf5-5.0beta8/.git/objects/84/
tf5-5.0beta8/.git/objects/86/
tf5-5.0beta8/.git/objects/87/
tf5-5.0beta8/.git/objects/88/
tf5-5.0beta8/.git/objects/8b/
tf5-5.0beta8/.git/objects/8c/
tf5-5.0beta8/.git/objects/8f/
tf5-5.0beta8/.git/objects/91/
tf5-5.0beta8/.git/objects/93/
tf5-5.0beta8/.git/objects/96/
tf5-5.0beta8/.git/objects/97/
tf5-5.0beta8/.git/objects/99/
tf5-5.0beta8/.git/objects/9a/
tf5-5.0beta8/.git/objects/9b/
tf5-5.0beta8/.git/objects/9c/
tf5-5.0beta8/.git/objects/9d/
tf5-5.0beta8/.git/objects/9e/
tf5-5.0beta8/.git/objects/a1/
tf5-5.0beta8/.git/objects/a3/
tf5-5.0beta8/.git/objects/a4/
tf5-5.0beta8/.git/objects/a6/
tf5-5.0beta8/.git/objects/a7/
tf5-5.0beta8/.git/objects/a8/
tf5-5.0beta8/.git/objects/a9/
tf5-5.0beta8/.git/objects/ab/
tf5-5.0beta8/.git/objects/ac/
tf5-5.0beta8/.git/objects/ae/
tf5-5.0beta8/.git/objects/b1/
tf5-5.0beta8/.git/objects/b2/
tf5-5.0beta8/.git/objects/b3/
tf5-5.0beta8/.git/objects/b7/
tf5-5.0beta8/.git/objects/b9/
tf5-5.0beta8/.git/objects/bb/
tf5-5.0beta8/.git/objects/bc/
tf5-5.0beta8/.git/objects/bd/
tf5-5.0beta8/.git/objects/bf/
tf5-5.0beta8/.git/objects/c0/
tf5-5.0beta8/.git/objects/c1/
tf5-5.0beta8/.git/objects/c2/
tf5-5.0beta8/.git/objects/c3/
tf5-5.0beta8/.git/objects/c5/
tf5-5.0beta8/.git/objects/c7/
tf5-5.0beta8/.git/objects/ca/
tf5-5.0beta8/.git/objects/ce/
tf5-5.0beta8/.git/objects/d1/
tf5-5.0beta8/.git/objects/d3/
tf5-5.0beta8/.git/objects/d4/
tf5-5.0beta8/.git/objects/d5/
tf5-5.0beta8/.git/objects/d8/
tf5-5.0beta8/.git/objects/d9/
tf5-5.0beta8/.git/objects/dc/
tf5-5.0beta8/.git/objects/dd/
tf5-5.0beta8/.git/objects/e1/
tf5-5.0beta8/.git/objects/e4/
tf5-5.0beta8/.git/objects/e5/
tf5-5.0beta8/.git/objects/e6/
tf5-5.0beta8/.git/objects/e7/
tf5-5.0beta8/.git/objects/e8/
tf5-5.0beta8/.git/objects/ea/
tf5-5.0beta8/.git/objects/eb/
tf5-5.0beta8/.git/objects/ed/
tf5-5.0beta8/.git/objects/ee/
tf5-5.0beta8/.git/objects/ef/
tf5-5.0beta8/.git/objects/f0/
tf5-5.0beta8/.git/objects/f4/
tf5-5.0beta8/.git/objects/f5/
tf5-5.0beta8/.git/objects/f6/
tf5-5.0beta8/.git/objects/f8/
tf5-5.0beta8/.git/objects/f9/
tf5-5.0beta8/.git/objects/fa/
tf5-5.0beta8/.git/objects/fb/
tf5-5.0beta8/.git/objects/fc/
tf5-5.0beta8/.git/objects/fd/
tf5-5.0beta8/.git/refs/heads/
tf5-5.0beta8/.git/refs/tags/
tf5-5.0beta8/autom4te.cache/
tf5-5.0beta8/macos/
tf5-5.0beta8/unix/
tf5-5.0beta8/win32/
/*************************************************************************
 *  TinyFugue - programmable mud client
 *  Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2004, 2005, 2006-2007 Ken Keys
 *
 *  TinyFugue (aka "tf") is protected under the terms of the GNU
 *  General Public License.  See the file "COPYING" for details.
 ************************************************************************/
/* $Id: dstring.h,v 35004.37 2007/01/13 23:12:39 kkeys Exp $ */

#ifndef DSTRING_H
#define DSTRING_H

#define ALLOCSIZE		(32L)

typedef struct String {
    char *data;			/* pointer to space holding text */
    int len;			/* length of actual data (not counting NUL) */
    int size;			/* length allocated */
    short links;		/* number of pointers to this structure */
    unsigned int static_struct: 1;	/* is struct static (not automatic)? */
    unsigned int dynamic_struct: 1;	/* was struct malloc'd? */
    unsigned int dynamic_data: 1;	/* was data malloc'd? */
    /* unsigned dynamic_charattrs:1; */	/* charattrs is always dynamic */
    unsigned int resizable: 1;		/* can data be resized? */
    attr_t attrs;		/* whole-line attributes */
    cattr_t *charattrs;		/* per-character attributes */
    struct timeval time;	/* timestamp */
#if USE_MMALLOC		/* don't waste the space if not using mmalloc */
    void *md;			/* mmalloc descriptor */
#endif
    const char *file;
    int line;
} String, Stringp[1];

/* A conString is a String with const *data and *charattrs. */
typedef struct conString {
    const char *data;		/* pointer to space holding text */
    int len;			/* length of actual data (not counting NUL) */
    int size;			/* length allocated */
    short links;		/* number of pointers to this structure */
    unsigned int static_struct: 1;	/* is struct static (not automatic)? */
    unsigned int dynamic_struct: 1;	/* was struct malloc'd? */
    unsigned int dynamic_data: 1;	/* was data malloc'd? */
    /* unsigned dynamic_charattrs:1; */	/* charattrs is always dynamic */
    unsigned int resizable: 1;		/* can data be resized? */
    attr_t attrs;		/* whole-line attributes */
    const cattr_t *charattrs;	/* per-character attributes */
    struct timeval time;	/* timestamp */
#if USE_MMALLOC		/* don't waste the space if not using mmalloc */
    void *md;			/* mmalloc descriptor */
#endif
    const char *file;
    int line;
} conString;

/* safely cast String* to conString* */
static inline conString *CS(String *s) { return (conString*)s; }

#if USE_MMALLOC
# define MD_INIT	NULL,
#else
# define MD_INIT	/* blank */
#endif

#define STRING_LITERAL_ATTR(data, attrs) \
    { (data), sizeof(data)-1, sizeof(data), 1, 1,0,0,0, \
	attrs, NULL, { -1, -1 }, MD_INIT __FILE__, __LINE__ }
#define STRING_LITERAL(data) STRING_LITERAL_ATTR(data, 0)
#define STRING_NULL \
    { NULL, 0, 0, 1, 1,0,0,0, \
	0, NULL, { -1, -1 }, MD_INIT __FILE__, __LINE__ }

/* AUTO_BUFFER: The structure is allocated automatically in a function's
 * (file's) scope; if it is used, it must be Stringfree()'d before
 * before function (program) exit, and it it safe to Stringfree() even if
 * it wasn't used.  Its data may be modifed and resized.
 */
# define AUTO_BUFFER(name) \
     Stringp (name) = {{ NULL, 0, 0, 1, 0,0,1,1, \
	0, NULL, { -1, -1 }, MD_INIT __FILE__, __LINE__ }}

/* STATIC_BUFFER: The structure has static storage, and its data is allocated
 * the first time it's needed, but not freed, and reused after that to save
 * time.  It never needs to be Stringfree()'d.  Its data may be
 * modified and resized.  Not reentrant-safe.
 */
#define STATIC_BUFFER_INIT \
    {{ NULL, 0, 0, 1, 1,0,1,1, 0, NULL, { -1,-1 }, MD_INIT __FILE__, __LINE__ }}
#define STATIC_BUFFER(name) \
    static Stringp (name) = STATIC_BUFFER_INIT

/* STATIC_STRING: The structure and data have static storage.  It can never
 * be modified or resized.
 */
#define STATIC_STRING(name, sl, attrs) \
    static conString (name)[1] = \
        {{ (sl), sizeof(sl)-1, sizeof(sl), 1, 1,0,0,0, \
	    (attrs), NULL, {-1,-1}, MD_INIT __FILE__, __LINE__ }}


/* String*init() sets links=1 to indicate the implicit ownership by whoever
 * created the structure.
 */
#define Stringdup(src) \
    SStringcpy(Stringnew(NULL, -1, 0), (src))
#define Stringodup(src, start) \
    SStringocat(Stringnew(NULL, -1, 0), (src), (start))
#define StringnewM(data, len, attrs, arena) \
    dSinit(NULL, (data), (len), (attrs), (arena), __FILE__, __LINE__)
#define Stringnew(data, len, attrs) \
    StringnewM(data, len, attrs, NULL)
#define Stringinit(str) \
    ((void)(dSinit((str), NULL, 0, 0, NULL, __FILE__, __LINE__)->links++))
#define Stringninit(str, size) \
    ((void)(dSinit((str), NULL, (size), 0, NULL, __FILE__, __LINE__)->links++))
#define Stringzero(str)		Stringninit((str), 0)

#define Stringfree(str)		Stringfree_fl(str, __FILE__, __LINE__)
#define Stringfree_fl(str, file, line) \
    do { \
	String *temp = (str);  /* must evaluate str exactly once */ \
	if (--temp->links <= 0) dSfree(temp, (file), (line)); \
    } while (0)

#define conStringfree(str)	conStringfree_fl(str, __FILE__, __LINE__)
#define conStringfree_fl(str, file, line) \
    do { \
	conString *temp = (str);  /* must evaluate str exactly once */ \
	if (--temp->links <= 0) dSfree((String*)temp, (file), (line)); \
    } while (0)

#define Stringadd(str, c)	dSadd((str), (c), __FILE__, __LINE__)
#define Stringnadd(str, c, n)	dSnadd((str), (c), (n), __FILE__, __LINE__)
#define Stringtrunc(str, n)	dStrunc((str), (n), __FILE__, __LINE__)
#define Stringcpy(dst, src)	dScpy((dst), (src), __FILE__, __LINE__)
#define SStringcpy(dst, src)	dSScpy((dst), (src), __FILE__, __LINE__)
#define Stringncpy(dst, src, n)	dSncpy((dst), (src), (n), __FILE__, __LINE__)
#define Stringcat(dst, src)	dScat((dst), (src), __FILE__, __LINE__)
#define Stringncat(dst, src, n)	dSncat((dst), (src), (n), __FILE__, __LINE__)
#define Stringfncat(dst, src, n) dSfncat((dst), (src), (n), __FILE__, __LINE__)

/* the following macros use -1 instead of src->len so src isn't evaled twice */
#define SStringcat(dst, src) \
	dSSoncat((dst), (src), 0, -1, __FILE__, __LINE__)
#define SStringncat(dst, src, len) \
	dSSoncat((dst), (src), 0, (len), __FILE__, __LINE__)
#define SStringocat(dst, src, start) \
	dSSoncat((dst), (src), (start), -1, __FILE__,__LINE__)
#define SStringoncat(dst, src, start, len) \
	dSSoncat((dst), (src), (start), (len), __FILE__, __LINE__)

#define FL	const char *file, int line

extern String *dSinit  (String *str, const char *data, int len,
               attr_t attrs, void *arena, FL);
extern void    dSfree  (String *str, FL);  /* call via Stringfree() */
extern String *dSadd   (String *str, int c, FL);
extern String *dSnadd  (String *str, int c, int n, FL);
extern String *dStrunc (String *str, int n, FL);
extern String *dScpy   (String *dest, const char *src, FL);
extern String *dSScpy  (String *dest, const conString *src, FL);
extern String *dSncpy  (String *dest, const char *src, int n, FL);
extern String *dScat   (String *dest, const char *src, FL);
extern String *dSSoncat(String *dest, const conString *src, int start, int len, FL);
extern String *dSncat  (String *dest, const char *src, int n, FL);
extern String *dSfncat (String *dest, const char *src, int n, FL);
extern String *Stringstriptrail(String *str);
extern int Stringcmp(const conString *s, const conString *t);

extern void check_charattrs(String *str, int n, cattr_t attrs,
    const char *file, int line);
extern void extend_charattrs(String *str, int oldlen, cattr_t attrs);

#if USE_DMALLOC
extern void free_dstring(void);
#endif


extern conString blankline[1];

#undef FL

#endif /* DSTRING_H */