* Adapted by Kern Sibbald to Bacula June 2003
*/
/*
- Copyright (C) 2000-2003 Kern Sibbald and John Walker
+ Copyright (C) 2000-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
*/
-
+#ifndef HAVE_WIN32
#include "bacula.h"
#if defined(HAVE_PCREPOSIX)
# include <pcreposix.h>
int n;
int bytes;
- if (format == NULL || ap == NULL)
+ if (format == NULL)
return -1;
bytes = 0;
while (*format != '\0') {
int n;
var_mvsnprintf_cb_t ctx;
- if (format == NULL || ap == NULL)
+ if (format == NULL)
return -1;
if (buffer != NULL && bufsize == 0)
return -1;
static int
expand_isoct(
- char c)
+ int c)
{
if (c >= '0' && c <= '7')
return 1;
expand_octal(
const char **src, char **dst, const char *end)
{
- unsigned char c;
+ int c;
if (end - *src < 3)
return VAR_ERR_INCOMPLETE_OCTAL;
static int
expand_ishex(
- char c)
+ int c)
{
if ((c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
expand_simple_hex(
const char **src, char **dst, const char *end)
{
- unsigned char c = 0;
+ int c = 0;
if (end - *src < 2)
return VAR_ERR_INCOMPLETE_HEX;
if (**src >= '0' && **src <= '9')
c = **src - '0';
- else if (c >= 'a' && c <= 'f')
+ else if (**src >= 'a' && **src <= 'f')
c = **src - 'a' + 10;
- else if (c >= 'A' && c <= 'F')
+ else if (**src >= 'A' && **src <= 'F')
c = **src - 'A' + 10;
c = c << 4;
else if (**src >= 'A' && **src <= 'F')
c += **src - 'A' + 10;
- **dst = (char) c;
+ **dst = (char)c;
(*dst)++;
return VAR_OK;
}
goto error_return;
if (rc > 0) {
p += rc;
- if (!tokenbuf_append
- (result, tmp.begin, tmp.end - tmp.begin)) {
+ if (!tokenbuf_merge(result, &tmp)) {
rc = VAR_ERR_OUT_OF_MEMORY;
goto error_return;
}
goto error_return;
if (rc > 0) {
p += rc;
- if (!tokenbuf_append
- (result, tmp.begin, tmp.end - tmp.begin)) {
+ if (!tokenbuf_merge(result, &tmp)) {
rc = VAR_ERR_OUT_OF_MEMORY;
goto error_return;
}
return rc;
}
/* append replace string */
- if (!tokenbuf_append(&tmp, myreplace.begin, myreplace.end - myreplace.begin)) {
+ if (!tokenbuf_merge(&tmp, &myreplace)) {
regfree(&preg);
tokenbuf_free(&tmp);
tokenbuf_free(&mydata);
if (i > 0) {
i = i / (fill->end - fill->begin);
while (i > 0) {
- if (!tokenbuf_append(&result, fill->begin, fill->end - fill->begin)) {
+ if (!tokenbuf_merge(&result, fill)) {
tokenbuf_free(&result);
return VAR_ERR_OUT_OF_MEMORY;
}
tokenbuf_free(&result);
return VAR_ERR_OUT_OF_MEMORY;
}
- if (!tokenbuf_append(&result, data->begin, data->end - data->begin)) {
+ if (!tokenbuf_merge(&result, data)) {
tokenbuf_free(&result);
return VAR_ERR_OUT_OF_MEMORY;
}
/* create the prefix */
i = i / (fill->end - fill->begin);
while (i > 0) {
- if (!tokenbuf_append(&result, fill->begin, fill->end - fill->begin)) {
+ if (!tokenbuf_merge(&result, fill)) {
tokenbuf_free(&result);
return VAR_ERR_OUT_OF_MEMORY;
}
return VAR_ERR_OUT_OF_MEMORY;
}
/* append the actual data string */
- if (!tokenbuf_append(&result, data->begin, data->end - data->begin)) {
+ if (!tokenbuf_merge(&result, data)) {
tokenbuf_free(&result);
return VAR_ERR_OUT_OF_MEMORY;
}
i = width - (result.end - result.begin);
i = i / (fill->end - fill->begin);
while (i > 0) {
- if (!tokenbuf_append(&result, fill->begin, fill->end - fill->begin)) {
+ if (!tokenbuf_merge(&result, fill)) {
tokenbuf_free(&result);
return VAR_ERR_OUT_OF_MEMORY;
}
arg_ptr, arg_len,
val_ptr, val_len,
&out_ptr, &out_len, &out_size);
- if (rc < 0)
+ if (rc < 0) {
+ if (arg_ptr != NULL)
+ free((void *)arg_ptr);
goto error_return;
+ }
tokenbuf_free(data);
tokenbuf_set(data, out_ptr, out_ptr+out_len, out_size);
}
+ if (arg_ptr != NULL)
+ free((void *)arg_ptr);
break;
}
default:
const char *fmt, va_list ap)
{
var_rc_t rc;
- va_list apbak;
char *cpBuf;
- int nBuf;
+ int nBuf = 5000;
/* argument sanity checks */
if (var == NULL || dst_ptr == NULL || fmt == NULL)
return VAR_RC(VAR_ERR_INVALID_ARGUMENT);
- /* determine formatting buffer length */
- apbak = ap;
- nBuf = var_mvsnprintf(NULL, 0, fmt, ap);
- ap = apbak;
- if (nBuf == -1)
- return VAR_RC(VAR_ERR_FORMATTING_FAILURE);
-
/* perform formatting */
if ((cpBuf = (char *)malloc(nBuf+1)) == NULL)
return VAR_RC(VAR_ERR_OUT_OF_MEMORY);
}
return str;
}
+#endif