Porting to SunOS 5.8:

- More #includes Linux doesn't seem to need
- Don't do unsetenv() on SunOS
- Use a replacement asprintf() in case the OS doesn't support it
It now compiles properly under SunOS.
This commit is contained in:
Guus Sliepen 2000-11-08 00:10:50 +00:00
parent 56bd0864e4
commit f8f1007bf4
4 changed files with 40 additions and 6 deletions

View file

@ -21,11 +21,13 @@
#include <sys/types.h>
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include "config.h"
#include <utils.h>
#include <syslog.h>
#include <xalloc.h>
volatile int (cp_line[]) = {0, 0, 0, 0, 0, 0, 0, 0};
volatile char (*cp_file[]) = {"?", "?", "?", "?", "?", "?", "?", "?"};
@ -72,3 +74,32 @@ void cp_trace()
cp_file[cp_index], cp_line[cp_index]
);
}
#ifndef HAVE_ASPRINTF
int asprintf(char **buf, const char *fmt, ...)
{
int status;
va_list ap;
int len;
len = 4096;
*buf = xmalloc(len);
va_start(ap, fmt);
status = vsnprintf (*buf, len, fmt, ap);
va_end (ap);
if(status >= 0)
*buf = xrealloc(*buf, status);
if(status > len-1)
{
len = status;
va_start(ap, fmt);
status = vsnprintf (*buf, len, fmt, ap);
va_end (ap);
}
return status;
}
#endif