From owner-freebsd-ports-bugs@FreeBSD.ORG Thu Jul 15 10:50:24 2004 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3CDAD16A4CE for ; Thu, 15 Jul 2004 10:50:24 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2598843D49 for ; Thu, 15 Jul 2004 10:50:24 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i6FAoOlV031443 for ; Thu, 15 Jul 2004 10:50:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i6FAoOBV031442; Thu, 15 Jul 2004 10:50:24 GMT (envelope-from gnats) Resent-Date: Thu, 15 Jul 2004 10:50:24 GMT Resent-Message-Id: <200407151050.i6FAoOBV031442@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Samy Al Bahra Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0A39F16A4CE for ; Thu, 15 Jul 2004 10:50:06 +0000 (GMT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 03A3043D5D for ; Thu, 15 Jul 2004 10:50:06 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i6FAo54l016573 for ; Thu, 15 Jul 2004 10:50:05 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.11/8.12.11/Submit) id i6FAo57I016572; Thu, 15 Jul 2004 10:50:05 GMT (envelope-from nobody) Message-Id: <200407151050.i6FAo57I016572@www.freebsd.org> Date: Thu, 15 Jul 2004 10:50:05 GMT From: Samy Al Bahra To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Subject: ports/69091: [Fix] mbone/imm does not build on FreeBSD X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2004 10:50:24 -0000 >Number: 69091 >Category: ports >Synopsis: [Fix] mbone/imm does not build on FreeBSD >Confidential: no >Severity: critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jul 15 10:50:23 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Samy Al Bahra >Release: FreeBSD 5.2-CURRENT >Organization: Kerneled >Environment: >Description: The mbone/imm port does not build on FreeBSD due to it's ancient varargs.h usage. This fix provides a full solution by providing a stdargs.h alternative to the routines requiring this functionality. >How-To-Repeat: Build unpatched mbone/imm port on FreeBSD. >Fix: Add the following file (patch-src::utils.c) to the files/ folder of the port as an additional patch. The patch may also be found here: http://samy.kerneled.org/patches/imm-patch.diff >Release-Note: >Audit-Trail: >Unformatted: >>>>>>>>>>>>>>> Begin patch >>>>>>>>>>>> --- src/utils.c.orig Thu Jul 15 12:37:25 2004 +++ src/utils.c Thu Jul 15 13:36:09 2004 @@ -20,7 +20,7 @@ * These notices must be retained in any copies of any part of this software. ******************************************************************************/ #include -#include +#include #include #include #ifdef __NetBSD__ @@ -40,47 +40,118 @@ /*----------------------------------------------------------------------------*/ -void warn( va_alist ) -va_dcl +/* Allocate memory for format string buffers */ +int +vfsalloc(char *fmt, va_list ap) { - va_list args; - char *fmt; + char *s; + int i, n = 0, len = 0; - va_start( args ); - fmt = va_arg( args, char * ); - fprintf( stderr, "Warning: " ); - vfprintf( stderr, fmt, args ); - va_end( args ); + if (!fmt) + return 0; + + s = strchr(fmt, '%'); + + while (s) { + ++s; + ++n; + + switch (*s) { + case 'd': + i = va_arg(ap, int); + len += 1 + sizeof(int)<<1; + break; + case 's': + len += strlen(va_arg(ap, char *)); + break; + } + s = strchr(s, '%'); + } + + len += strlen(fmt) - (2 * n); + + return len; +} + +void warn( char *fmt, ... ) +{ + va_list ap; + char *buf, *s; + int len; + + if (!fmt) + return; + + va_start(ap, fmt); + if (!(len = vfsalloc(fmt, ap))) + return; + va_end(ap); + + if (!(buf = malloc(len))) + return; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + + fprintf(stderr, "Warning: %s\n", buf); + free(buf); } /*----------------------------------------------------------------------------*/ -void die( va_alist ) -va_dcl +void die(char *fmt, ... ) { - va_list args; - char *fmt; + va_list ap; + char *buf, *s; + int len; + + if (!fmt) + return; + + va_start(ap, fmt); + if (!(len = vfsalloc(fmt, ap))) + return; + va_end(ap); + + if (!(buf = malloc(len))) + return; - va_start( args ); - fmt = va_arg( args, char * ); - fprintf( stderr, "Error: " ); - vfprintf( stderr, fmt, args ); - exit( 1 ); + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + + fprintf(stderr, "Error: %s\n", buf); + free(buf); + exit(1); } /*----------------------------------------------------------------------------*/ -void fatal( va_alist ) -va_dcl +void fatal(char *fmt, ... ) { - va_list args; - char *fmt; + va_list ap; + char *buf, *s; + int len; + + if (!fmt) + return; - va_start( args ); - fmt = va_arg( args, char * ); - fprintf( stderr, "Internal Error: " ); - vfprintf( stderr, fmt, args ); - exit( 2 ); + va_start(ap, fmt); + if (!(len = vfsalloc(fmt, ap))) + return; + va_end(ap); + + if (!(buf = malloc(len))) + return; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + + fprintf(stderr, "Internal error: %s\n", buf); + free(buf); + exit(2); } /*----------------------------------------------------------------------------*/ @@ -142,21 +213,34 @@ /*----------------------------------------------------------------------------*/ -void mailmessage( va_alist ) -va_dcl +void mailmessage(char *fmt, ... ) { - va_list args; - char *fmt; + va_list ap; + char *buf, s; + int len; FILE *popen(), *fp; char cmdline[80]; if (whome == NULL) whome = getlogin(); sprintf(cmdline,"%s %s",mailprog,whome); fp = popen(cmdline,"w"); - va_start( args ); - fmt = va_arg( args, char * ); - fprintf( fp, "MNM Warning: " ); - vfprintf( fp, fmt, args ); - va_end( args ); + + if (!fmt) + return; + + va_start(ap, fmt); + if (!(len = vfsalloc(fmt, ap))) + return; + va_end(ap); + + if (!(buf = malloc(len))) + return; + + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + + fprintf(fp, "MNM Warning: %s", buf); + free(buf); pclose(fp); }