From owner-freebsd-questions Fri Nov 27 22:31:57 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA09726 for freebsd-questions-outgoing; Fri, 27 Nov 1998 22:31:57 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from earth.ipass.net (ns3.ipass.net [198.79.53.11]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA09721 for ; Fri, 27 Nov 1998 22:31:56 -0800 (PST) (envelope-from mmercer@ipass.net) Received: from ipass.net (ts10-30-ppp.ipass.net [208.209.104.30]) by earth.ipass.net (8.8.8/8.8.8) with ESMTP id BAA10540 for ; Sat, 28 Nov 1998 01:31:47 -0500 (EST) Message-ID: <365F98FD.8AED5C78@ipass.net> Date: Sat, 28 Nov 1998 01:32:29 -0500 From: "Michael E. Mercer" X-Mailer: Mozilla 4.5 [en] (X11; U; FreeBSD 2.2.7-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: "freebsd-questions@FreeBSD.ORG" Subject: stdarg.h - weird infinite loop. Content-Type: multipart/mixed; boundary="------------9B527204E4FD4B34191D1EB2" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------9B527204E4FD4B34191D1EB2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit here'a my code...what am I doing wrong? I tried using vsprintf first..it is an infinite loop as well. Notice I included stdarg.h ... va_end has no definition?? Thanks Michael #ifndef _STDARG_H_ #define _STDARG_H_ typedef char *va_list; #define __va_size(type) \ (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) #ifdef __GNUC__ #define va_start(ap, last) \ ((ap) = (va_list)__builtin_next_arg(last)) #else #define va_start(ap, last) \ ((ap) = (va_list)&(last) + __va_size(last)) #endif #define va_arg(ap, type) \ (*(type *)((ap) += __va_size(type), (ap) - __va_size(type))) #define va_end(ap) #endif /* !_STDARG_H_ */ --------------------------------------------------- create_and_print_string ( const int size, ... ) { short rc = 0; char line[2000]; char tmp[50]; char *fmt = NULL; va_list ap; int i = 0; int len = 0; bzero ( line , sizeof ( char ) * 2000 ); va_start(ap, size); fmt = va_arg ( ap , char * ); len = strlen ( fmt ); for ( i = 0; i < len ; i++ ) { switch ( fmt[i] ) { case '%': i++; switch ( fmt[i] ) { case 'd': sprintf( tmp , "%d", va_arg ( ap , int )); strcat ( line , tmp ); break; case 's': sprintf( tmp , "%s", va_arg ( ap , char * )); strcat ( line , tmp ); break; default: sprintf( tmp , "%%%c", fmt[i] ); strcat ( line, tmp ); break; } break; default: sprintf( tmp , "%c", fmt[i] ); strcat ( line , tmp ); break; } } va_end ( ap ); rc = print_string ( line ); return ( rc ); } --------------9B527204E4FD4B34191D1EB2 Content-Type: text/x-vcard; charset=iso-8859-1; name="mmercer.vcf" Content-Transfer-Encoding: base64 Content-Description: Card for Michael E. Mercer Content-Disposition: attachment; filename="mmercer.vcf" YmVnaW46dmNhcmQgCm46TWVyY2VyO01pY2hhZWwKeC1tb3ppbGxhLWh0bWw6RkFMU0UKYWRy Ojs7NDMwOS8xNTE4IFdhdGVyZm9yZCBWYWxsZXkgRHJpdmU7RHVyaGFtO05vcnRoIENhcm9s aW5hOzI3NzEzO1VTQQp2ZXJzaW9uOjIuMQplbWFpbDtpbnRlcm5ldDptbWVyY2VyQGlwYXNz Lm5ldAp4LW1vemlsbGEtY3B0OjswCnRlbDt3b3JrOig5MTkpIDk5MS00NTU1CmZuOk1pY2hh ZWwgTWVyY2VyCmVuZDp2Y2FyZAo= --------------9B527204E4FD4B34191D1EB2-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message