/*
 * Copyright (c) 2004-2009, Luiz Otavio O Souza <loos.br@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * $Id: string.h 96 2009-01-20 15:34:19Z loos-br $
 */

#ifndef STRING_H
#define STRING_H

#include <stdlib.h>

#define	STRINGOVER		0x7fffffff
#define	STRING_MIN_LEN		64

#ifndef __INT_MAX
#define __INT_MAX	0x7fff
#endif

typedef struct {
    unsigned char	*s;
    unsigned char	*p;
    __int32_t		a;
    __int32_t		len;
} string;

typedef struct {
    string		**string;
    __int32_t 		len;
} strings;

unsigned char 		*_strchr(register unsigned char *s, int c);
__int32_t		str_cat(string *s, register const unsigned char *p, __int32_t len);
__int32_t		str_len(string *s);
__int32_t		str_cats(string *s, register const unsigned char *p);
__int32_t		str_copy(string *s, register const unsigned char *p, __int32_t len);
__int32_t		str_copys(string *s, register const unsigned char *p);
__int32_t		str_ready(string *s, __int32_t size);
__int32_t		str_get_size(__uint32_t len);
string			*str_alloc(void);
void			str_free(string *s);
void			str_zero(string *s);
void			str_reset(string *s);
void			str_strip(string *s);
void			str_p(string *s);
int			str_cmp(string *str1, string *str2);
int			str_casecmp(string *str1, string *str2);
int			str_ncmp(string *str1, string *str2, __int32_t n);
int			str_ncasecmp(string *str1, string *str2, __int32_t n);

#endif
