strfuncs.c revision d0e135d5b32855696a9921921315cdb5ba5abc3a
/*
strfuncs.c : String manipulation functions
Copyright (c) 2002 Timo Sirainen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* @UNSAFE: whole file */
#include "lib.h"
#include "printf-upper-bound.h"
#include "strfuncs.h"
#include <stdio.h>
#include <limits.h>
#include <ctype.h>
#define STRCONCAT_BUFSIZE 512
static const char *fix_format_real(const char *fmt, const char *p)
{
const char *errstr;
char *buf;
while (*p != '\0') {
if (*p == '%' && p[1] == 'm') {
}
p += 2;
} else {
/* p + \0 */
alloc += 128;
}
p++;
}
}
return buf;
}
/* replace %m with strerror() */
const char *printf_string_fix_format(const char *fmt)
{
const char *p;
for (p = fmt; *p != '\0'; p++) {
if (*p == '%' && p[1] == 'm')
return fix_format_real(fmt, p);
}
return fmt;
}
{
#ifndef HAVE_VSNPRINTF
char *buf;
#endif
int ret;
t_push();
#ifdef HAVE_VSNPRINTF
#else
#endif
if (len < 0) {
/* some error occured */
len = 0;
ret = -1;
/* too large */
ret = -1;
} else {
ret = 0;
}
#ifndef HAVE_VSNPRINTF
#endif
t_pop();
return ret;
}
{
void *mem;
return NULL;
len++;
len++;
return mem;
}
{
return NULL;
}
{
char *mem;
return mem;
}
{
char *mem;
return NULL;
len = 0;
len++;
return mem;
}
{
char *ret;
return ret;
}
{
char *ret;
if (pool != data_stack_pool)
t_push();
#ifdef HAVE_VSNPRINTF
#else
#endif
if (pool != data_stack_pool)
t_pop();
return ret;
}
{
const char *str;
return NULL;
pos = 0;
do {
*p++ = *str++;
if (p == temp_end) {
/* need more memory */
} else {
/* next string */
}
return temp;
}
{
const char *temp;
char *ret;
else {
}
return ret;
}
{
}
char *t_strdup_noconst(const char *str)
{
}
const char *t_strdup_empty(const char *str)
{
}
{
}
{
}
const char *t_strdup_printf(const char *format, ...)
{
const char *ret;
return ret;
}
{
}
const char *t_strconcat(const char *str1, ...)
{
const char *ret;
return ret;
}
{
const char *p;
for (p = str; *p != '\0'; p++) {
if (*p == cutchar)
return t_strdup_until(str, p);
}
return str;
}
{
return FALSE;
return FALSE;
str++;
}
return TRUE;
}
{
if (dstsize == 0)
return -1;
dstsize--;
}
*dest++ = '\0';
}
{
if (dstsize > 0)
*dest = '\0';
return -1;
}
return 0;
}
const char *file_prefix, const char *file)
{
if (dstsize > 0)
*dest = '\0';
return -1;
}
return 0;
}
{
char *p;
for (p = str; *p != '\0'; p++)
*p = i_toupper(*p);
return str;
}
{
char *p;
for (p = str; *p != '\0'; p++)
*p = i_tolower(*p);
return str;
}
void str_remove_escapes(char *str)
{
char *dest;
}
*dest = '\0';
}
{
const char **array;
char *str;
alloc_len = 32;
while (*str != '\0') {
/* separator found */
sizeof(const char *) *
}
*str = '\0';
}
str++;
}
return array;
}
{
char *buffer;
int pos;
do {
number /= 10;
}