[uClibc]pppd 2.4.1 + pppoe

Andrew Ip aip at cwlinux.com
Thu Mar 14 17:17:45 UTC 2002


Hi,

	I have got this patch which should fix the error() problem.  Please take
a look.  Thanks.

-Andrew

On Mon, Mar 04, 2002 at 01:26:47PM -0700, Erik Andersen wrote:
> On Mon Mar 04, 2002 at 01:08:19PM -0700, Erik wrote:
> > It looks to be trivial to implement though -- something like the
> > following should do (entirely untested):
> 
> err.  Lets try that again (still entirely untested):
> 
> extern void error (int status, int errnum, const char *format, ...)
> {
>     va_list p;
>     va_start(p, format);
>     vfprintf(stderr, format, p);
>     va_end(p);
>     if (errnum != 0) {
> 	fprintf(stderr, ": %s\n, strerror(errnum));
>     } else {
> 	fprintf(stderr, "\n");
>     }
>     if (status != 0) {
> 	exit(status);
>     }
> }
> 

-- 
Andrew Ip
Email:  aip at cwlinux.com
Tel:    (852) 2542 2046
Fax:    (852) 2542 2046
Mobile: (852) 9201 9866

Cwlinux Limited
18B Tower 1 Tern Centre,
237 Queen's Road Central,
Hong Kong.

For my public pgp key, please obtain it from http://www.keyserver.net/en.
-------------- next part --------------
diff -Nur uClibc/include/error.h uClibc.error/include/error.h
--- uClibc/include/error.h	Thu Jan  1 08:00:00 1970
+++ uClibc.error/include/error.h	Fri Mar 15 00:16:36 2002
@@ -0,0 +1,77 @@
+/* Declaration for error-reporting function
+   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+
+   This file is part of the GNU C Library.  Its master source is NOT part of
+   the C library, however.  The master source lives in /gd/gnu/lib.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _ERROR_H
+#define _ERROR_H 1
+
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
+#  define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#  define __format__ format
+#  define __printf__ printf
+# endif
+#endif
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+#if defined (__STDC__) && __STDC__
+
+/* Print a message with `fprintf (stderr, FORMAT, ...)';
+   if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
+   If STATUS is nonzero, terminate the program with `exit (STATUS)'.  */
+
+extern void error (int status, int errnum, const char *format, ...)
+     __attribute__ ((__format__ (__printf__, 3, 4)));
+
+extern void error_at_line (int status, int errnum, const char *fname,
+			   unsigned int lineno, const char *format, ...)
+     __attribute__ ((__format__ (__printf__, 5, 6)));
+
+/* If NULL, error will flush stdout, then print on stderr the program
+   name, a colon and a space.  Otherwise, error will call this
+   function without parameters instead.  */
+extern void (*error_print_progname) (void);
+
+#else
+void error ();
+void error_at_line ();
+extern void (*error_print_progname) ();
+#endif
+
+/* This variable is incremented each time `error' is called.  */
+extern unsigned int error_message_count;
+
+/* Sometimes we want to have at most one error per line.  This
+   variable controls whether this mode is selected or not.  */
+extern int error_one_per_line;
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* error.h */
diff -Nur uClibc/libc/misc/Makefile uClibc.error/libc/misc/Makefile
--- uClibc/libc/misc/Makefile	Wed Dec 19 23:52:49 2001
+++ uClibc.error/libc/misc/Makefile	Fri Mar 15 00:14:31 2002
@@ -26,7 +26,7 @@
 
 
 DIRS = assert ctype dirent file fnmatch glob internals lsearch \
-       mntent syslog time utmp tsearch locale regex sysvipc
+       mntent syslog time utmp tsearch locale regex sysvipc error
 
 all: libc.a
 
diff -Nur uClibc/libc/misc/error/Makefile uClibc.error/libc/misc/error/Makefile
--- uClibc/libc/misc/error/Makefile	Thu Jan  1 08:00:00 1970
+++ uClibc.error/libc/misc/error/Makefile	Fri Mar 15 00:12:45 2002
@@ -0,0 +1,44 @@
+# Makefile for uClibc
+#
+# Copyright (C) 2000 by Lineo, inc.
+# Copyright (C) 2000,2001 Erik Andersen <andersen at uclibc.org>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library General Public License as published by the Free
+# Software Foundation; either version 2 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Derived in part from the Linux-8086 C library, the GNU C Library, and several
+# other sundry sources.  Files within this library are copyright by their
+# respective copyright holders.
+
+TOPDIR=../../../
+include $(TOPDIR)Rules.mak
+
+CSRC=error.c
+COBJS=$(patsubst %.c,%.o, $(CSRC))
+OBJS=$(COBJS)
+
+all: $(OBJS) $(LIBC)
+
+$(LIBC): ar-target
+
+ar-target: $(OBJS)
+	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
+
+$(COBJS): %.o : %.c
+	$(CC) $(CFLAGS) -c $< -o $@
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
+clean:
+	rm -f *.[oa] *~ core
+
diff -Nur uClibc/libc/misc/error/error.c uClibc.error/libc/misc/error/error.c
--- uClibc/libc/misc/error/error.c	Thu Jan  1 08:00:00 1970
+++ uClibc.error/libc/misc/error/error.c	Fri Mar 15 01:09:31 2002
@@ -0,0 +1,101 @@
+/* Error handler for noninteractive utilities
+   Copyright (C) 1990-1998, 2000, 2001 Free Software Foundation, Inc.
+
+   This file is part of the GNU C Library.  Its master source is NOT part of
+   the C library, however.  The master source lives in /gd/gnu/lib.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* Written by David MacKenzie <djm at gnu.ai.mit.edu>.  */
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#define VA_START(args, lastarg) va_start(args, lastarg)
+
+#include <stdlib.h>
+#include <string.h>
+#include "error.h"
+
+
+/* This variable is incremented each time `error' is called.  */
+unsigned int error_message_count;
+
+void
+error (int status, int errnum, const char *message, ...)
+{
+  va_list args;
+
+  fflush (stdout);
+
+  VA_START (args, message);
+  vfprintf (stderr, message, args);
+  va_end (args);
+  ++error_message_count;
+  if (errnum)
+    {
+      fprintf (stderr, ": %s", strerror (errnum));
+    }
+  putc ('\n', stderr);
+  fflush (stderr);
+  if (status)
+    exit (status);
+}
+
+/* Sometimes we want to have at most one error per line.  This
+   variable controls whether this mode is selected or not.  */
+int error_one_per_line;
+
+void
+error_at_line (int status, int errnum, const char *file_name,
+	       unsigned int line_number, const char *message, ...)
+{
+  va_list args;
+
+  if (error_one_per_line)
+    {
+      static const char *old_file_name;
+      static unsigned int old_line_number;
+
+      if (old_line_number == line_number &&
+	  (file_name == old_file_name || !strcmp (old_file_name, file_name)))
+	/* Simply return and print nothing.  */
+	return;
+
+      old_file_name = file_name;
+      old_line_number = line_number;
+    }
+
+  fflush (stdout);
+
+  if (file_name != NULL)
+    fprintf (stderr, "%s:%d: ", file_name, line_number);
+
+  VA_START (args, message);
+  vfprintf (stderr, message, args);
+  va_end (args);
+
+  ++error_message_count;
+  if (errnum)
+    {
+      fprintf (stderr, ": %s", strerror (errnum));
+    }
+  putc ('\n', stderr);
+  fflush (stderr);
+  if (status)
+    exit (status);
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20020315/d3492483/attachment.pgp 


More information about the uClibc mailing list