From: <brg...@us...> - 2011-10-22 07:34:33
|
Revision: 417 http://ggnfs.svn.sourceforge.net/ggnfs/?rev=417&view=rev Author: brgladman Date: 2011-10-22 07:34:27 +0000 (Sat, 22 Oct 2011) Log Message: ----------- add files needed for the experimental siever Added Paths: ----------- trunk/build.vc10/alloca.h trunk/build.vc10/asprintf.c trunk/build.vc10/asprintf.h trunk/build.vc10/vasprintf.c Added: trunk/build.vc10/alloca.h =================================================================== --- trunk/build.vc10/alloca.h (rev 0) +++ trunk/build.vc10/alloca.h 2011-10-22 07:34:27 UTC (rev 417) @@ -0,0 +1,7 @@ + +#ifndef ALLOCA_H +#define ALLOCA_H + +#define alloca _alloca + +#endif \ No newline at end of file Added: trunk/build.vc10/asprintf.c =================================================================== --- trunk/build.vc10/asprintf.c (rev 0) +++ trunk/build.vc10/asprintf.c 2011-10-22 07:34:27 UTC (rev 417) @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2007, The xFTPd Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the xFTPd Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * * Redistributions of this project or parts of this project in any form + * must retain the following aknowledgment: + * "This product includes software developed by the xFTPd Project. + * http://www.xftpd.com/ - http://www.xftpd.org/" + * + * THIS SOFTWARE IS PROVIDED BY THE xFTPd PROJECT ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE xFTPd PROJECT BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +/* MinGW lacks asprintf */ + +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> + +int vasprintf(char **strp, const char *fmt, va_list ap) +{ + FILE *dev_null; + int arg_len; + + dev_null = fopen("nul", "w"); + arg_len = vfprintf(dev_null, fmt, ap); + if(arg_len != -1) { + *strp = (char *)malloc((size_t)arg_len + 1); + arg_len = vsprintf(*strp, fmt, ap); + } else *strp = NULL; + fclose(dev_null); + return arg_len; +} + +int asprintf(char **strp, const char *fmt, ...) +{ + int result; + + va_list args; + va_start(args, fmt); + result = vasprintf(strp, fmt, args); + va_end(args); + return result; +} Added: trunk/build.vc10/asprintf.h =================================================================== --- trunk/build.vc10/asprintf.h (rev 0) +++ trunk/build.vc10/asprintf.h 2011-10-22 07:34:27 UTC (rev 417) @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2007, The xFTPd Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the xFTPd Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * * Redistributions of this project or parts of this project in any form + * must retain the following aknowledgment: + * "This product includes software developed by the xFTPd Project. + * http://www.xftpd.com/ - http://www.xftpd.org/" + * + * THIS SOFTWARE IS PROVIDED BY THE xFTPd PROJECT ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE xFTPd PROJECT BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* MinGW lacks asprintf */ + +#ifndef __ASPRINTF_H +#define __ASPRINTF_H + +#include <windows.h> + +int asprintf(char **ret, const char *fmt, ...); +int vasprintf(char **strp, const char *fmt, va_list ap); + +char *bprintf(const char *fmt, ...); + +#endif /* __ASPRINTF_H */ Added: trunk/build.vc10/vasprintf.c =================================================================== --- trunk/build.vc10/vasprintf.c (rev 0) +++ trunk/build.vc10/vasprintf.c 2011-10-22 07:34:27 UTC (rev 417) @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2004 Darren Tucker. + * + * Based originally on asprintf.c from OpenBSD: + * Copyright (c) 1997 Todd C. Miller <Tod...@co...> + * + * 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. + */ + +#ifndef HAVE_VASPRINTF + +#include <errno.h> +#include <stdarg.h> +#include <stdlib.h> + +#ifndef VA_COPY +# ifdef HAVE_VA_COPY +# define VA_COPY(dest, src) va_copy(dest, src) +# else +# ifdef HAVE___VA_COPY +# define VA_COPY(dest, src) __va_copy(dest, src) +# else +# define VA_COPY(dest, src) (dest) = (src) +# endif +# endif +#endif + +#define INIT_SZ 128 + +int vasprintf(char **str, const char *fmt, va_list ap) +{ + int ret = -1; + va_list ap2; + char *string, *newstr; + size_t len; + + VA_COPY(ap2, ap); + if ((string = malloc(INIT_SZ)) == NULL) + goto fail; + + ret = vsnprintf(string, INIT_SZ, fmt, ap2); + if (ret >= 0 && ret < INIT_SZ) { /* succeeded with initial alloc */ + *str = string; + } else if (ret == INT_MAX) { /* shouldn't happen */ + goto fail; + } else { /* bigger than initial, realloc allowing for nul */ + len = (size_t)ret + 1; + if ((newstr = realloc(string, len)) == NULL) { + free(string); + goto fail; + } else { + va_end(ap2); + VA_COPY(ap2, ap); + ret = vsnprintf(newstr, len, fmt, ap2); + if (ret >= 0 && (size_t)ret < len) { + *str = newstr; + } else { /* failed with realloc'ed string, give up */ + free(newstr); + goto fail; + } + } + } + va_end(ap2); + return (ret); + +fail: + *str = NULL; + errno = ENOMEM; + va_end(ap2); + return (-1); +} +#endif + +#ifndef HAVE_ASPRINTF +int asprintf(char **str, const char *fmt, ...) +{ + va_list ap; + int ret; + + *str = NULL; + va_start(ap, fmt); + ret = vasprintf(str, fmt, ap); + va_end(ap); + + return ret; +} +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |