Update.
1999-09-06 Ulrich Drepper <drepper@cygnus.com> * time/ap.c: Removed. It was not used. * time/date.c: Likewise. * sysdeps/unix/nlist.c: Likewise. * sysdeps/generic/nlist.c: Likewise. * sysdeps/generic/varargs.h: Likewise. * stdio-common/scanf11.c: Likewise. * stdio-common/scanf6.c: Likewise. * scripts/=__ify: Likewise. * scripts/printsources: Likewise. * resolv/getnetnamadr.c: Likewise. * posix/id.c: Likewise. * misc/ioctltst.c: Likewise. * misc/nlist.h: Likewise. * math/test-math.h: Likewise. * include/nlist.h: Likewise.
This commit is contained in:
parent
7fcc87f467
commit
39d31947cf
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
1999-09-06 Ulrich Drepper <drepper@cygnus.com>
|
||||
|
||||
* time/ap.c: Removed. It was not used.
|
||||
* time/date.c: Likewise.
|
||||
* sysdeps/unix/nlist.c: Likewise.
|
||||
* sysdeps/generic/nlist.c: Likewise.
|
||||
* sysdeps/generic/varargs.h: Likewise.
|
||||
* stdio-common/scanf11.c: Likewise.
|
||||
* stdio-common/scanf6.c: Likewise.
|
||||
* scripts/=__ify: Likewise.
|
||||
* scripts/printsources: Likewise.
|
||||
* resolv/getnetnamadr.c: Likewise.
|
||||
* posix/id.c: Likewise.
|
||||
* misc/ioctltst.c: Likewise.
|
||||
* misc/nlist.h: Likewise.
|
||||
* math/test-math.h: Likewise.
|
||||
* include/nlist.h: Likewise.
|
||||
|
||||
1999-09-06 Andreas Schwab <schwab@suse.de>
|
||||
|
||||
* time/tzset.c (compute_change): Replace slow loop to compute T by
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include <misc/nlist.h>
|
150
math/test-math.c
150
math/test-math.c
|
@ -1,150 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
void print_trig_stuff __P ((void));
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
const char str[] = "123.456";
|
||||
double x,h,li,lr,a,lrr;
|
||||
|
||||
if (signbit (argc < 1 ? -0.0 : 0.0))
|
||||
/* I don't make this an error for now. --drepper */
|
||||
fputs ("\n*** Your compiler has a bug. Consider upgrading\n\n", stderr);
|
||||
|
||||
x = atof (str);
|
||||
|
||||
printf ("%g %g\n", x, pow (10.0, 3.0));
|
||||
|
||||
x = sinh(2.0);
|
||||
|
||||
printf("sinh(2.0) = %g\n", x);
|
||||
|
||||
x = sinh(3.0);
|
||||
|
||||
printf("sinh(3.0) = %g\n", x);
|
||||
|
||||
h = hypot(2.0,3.0);
|
||||
|
||||
printf("h=%g\n", h);
|
||||
|
||||
a = atan2(3.0, 2.0);
|
||||
|
||||
printf("atan2(3,2) = %g\n", a);
|
||||
|
||||
lr = pow(h,4.0);
|
||||
|
||||
printf("pow(%g,4.0) = %g\n", h, lr);
|
||||
|
||||
lrr = lr;
|
||||
|
||||
li = 4.0 * a;
|
||||
|
||||
lr = lr / exp(a*5.0);
|
||||
|
||||
printf("%g / exp(%g * 5) = %g\n", lrr, a, lr);
|
||||
|
||||
lrr = li;
|
||||
|
||||
li += 5.0 * log(h);
|
||||
|
||||
printf("%g + 5*log(%g) = %g\n", lrr, h, li);
|
||||
|
||||
printf("cos(%g) = %g, sin(%g) = %g\n", li, cos(li), li, sin(li));
|
||||
|
||||
x = drem(10.3435,6.2831852);
|
||||
|
||||
printf("drem(10.3435,6.2831852) = %g\n", x);
|
||||
|
||||
x = drem(-10.3435,6.2831852);
|
||||
|
||||
printf("drem(-10.3435,6.2831852) = %g\n", x);
|
||||
|
||||
x = drem(-10.3435,-6.2831852);
|
||||
|
||||
printf("drem(-10.3435,-6.2831852) = %g\n", x);
|
||||
|
||||
x = drem(10.3435,-6.2831852);
|
||||
|
||||
printf("drem(10.3435,-6.2831852) = %g\n", x);
|
||||
|
||||
|
||||
printf("x%8.6gx\n", .5);
|
||||
printf("x%-8.6gx\n", .5);
|
||||
printf("x%6.6gx\n", .5);
|
||||
|
||||
{
|
||||
double x = atof ("-1e-17-");
|
||||
printf ("%g %c= %g %s!\n",
|
||||
x,
|
||||
x == -1e-17 ? '=' : '!',
|
||||
-1e-17,
|
||||
x == -1e-17 ? "Worked" : "Failed");
|
||||
}
|
||||
|
||||
print_trig_stuff ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const double RAD[5] = { 0, M_PI/2, M_PI, (3*M_PI)/2, 2*M_PI };
|
||||
|
||||
#define PRINT_IT_1_ARG(_func, _arg, _value) \
|
||||
(_value) = (_func) ((_arg)); \
|
||||
if (errno) { \
|
||||
errno = 0; \
|
||||
printf ("%s = ERROR %s\n", #_func, strerror (errno)); \
|
||||
} else \
|
||||
printf ("%s(%g) = %g\n", #_func, _arg, (_value)); \
|
||||
|
||||
#define PRINT_IT_2_ARG(_func, _arg1, _arg2, _value) \
|
||||
(_value) = (_func) ((_arg1),(_arg2)); \
|
||||
if (errno) { \
|
||||
errno = 0; \
|
||||
printf ("%s = ERROR %s\n", #_func, strerror (errno)); \
|
||||
} else \
|
||||
printf ("%s(%g, %g) = %g\n", #_func, _arg1, _arg2, (_value)); \
|
||||
|
||||
void
|
||||
print_trig_stuff(void)
|
||||
{
|
||||
double value, arg1, arg2;
|
||||
int i;
|
||||
|
||||
puts ("\n\nMath Test");
|
||||
|
||||
errno = 0; /* automatically reset on error condition */
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
PRINT_IT_1_ARG (sin, RAD[i], value);
|
||||
PRINT_IT_1_ARG (cos, RAD[i], value);
|
||||
PRINT_IT_1_ARG (tan, RAD[i], value);
|
||||
PRINT_IT_1_ARG (asin, RAD[i], value);
|
||||
PRINT_IT_1_ARG (acos, RAD[i], value);
|
||||
PRINT_IT_1_ARG (atan, RAD[i], value);
|
||||
PRINT_IT_2_ARG (atan2, RAD[i], -RAD[i % 4], value);
|
||||
}
|
||||
|
||||
arg1 = 16;
|
||||
arg2 = 3;
|
||||
PRINT_IT_1_ARG (exp, arg1, value);
|
||||
PRINT_IT_1_ARG (log, arg1, value);
|
||||
PRINT_IT_1_ARG (log10, arg1, value);
|
||||
PRINT_IT_2_ARG (pow, arg1, arg2, value);
|
||||
PRINT_IT_1_ARG (sqrt, arg1, value);
|
||||
PRINT_IT_1_ARG (cbrt, arg1, value);
|
||||
PRINT_IT_2_ARG (hypot, arg1, arg2, value);
|
||||
PRINT_IT_1_ARG (expm1, arg1, value);
|
||||
PRINT_IT_1_ARG (log1p, arg1, value);
|
||||
PRINT_IT_1_ARG (sinh, arg1, value);
|
||||
PRINT_IT_1_ARG (cosh, arg1, value);
|
||||
PRINT_IT_1_ARG (tanh, arg1, value);
|
||||
PRINT_IT_1_ARG (asinh, arg1, value);
|
||||
PRINT_IT_1_ARG (acosh, arg1, value);
|
||||
PRINT_IT_1_ARG (atanh, arg1, value);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/*
|
||||
* open a socket, get the process group information of the socket, and use the
|
||||
* socket to get the network interface configuration list
|
||||
*/
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int sock;
|
||||
int ioctl_result;
|
||||
|
||||
/* get a socket */
|
||||
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (sock < 0)
|
||||
{
|
||||
perror("Cannot create socket");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* use ioctl() to get the process group information */
|
||||
{
|
||||
int get_process_group;
|
||||
|
||||
ioctl_result = ioctl(sock, SIOCGPGRP, (char *) &get_process_group);
|
||||
|
||||
if (ioctl_result < 0)
|
||||
{
|
||||
int my_errno = errno;
|
||||
|
||||
fprintf(stderr, "errno %d ", my_errno);
|
||||
perror("ioctl(get process group)");
|
||||
}
|
||||
}
|
||||
|
||||
/* use ioctl() to get the interface configuration list */
|
||||
{
|
||||
static struct ifconf ifc; /* init to 0 */
|
||||
|
||||
ioctl_result = ioctl(sock, SIOCGIFCONF, (char *) &ifc);
|
||||
|
||||
if (ioctl_result < 0)
|
||||
{
|
||||
int my_errno = errno;
|
||||
|
||||
fprintf(stderr, "errno %d ", my_errno);
|
||||
perror("ioctl(get interface configuration list)");
|
||||
}
|
||||
}
|
||||
}
|
48
misc/nlist.h
48
misc/nlist.h
|
@ -1,48 +0,0 @@
|
|||
/* Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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 _NLIST_H
|
||||
#define _NLIST_H 1
|
||||
|
||||
#include <features.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* Structure describing a symbol-table entry. */
|
||||
struct nlist
|
||||
{
|
||||
char *n_name;
|
||||
unsigned char n_type;
|
||||
char n_other;
|
||||
short int n_desc;
|
||||
unsigned long int n_value;
|
||||
};
|
||||
|
||||
#define N_NLIST_DECLARED
|
||||
#include <a.out.h>
|
||||
|
||||
|
||||
/* Search the executable FILE for symbols matching those in NL,
|
||||
which is terminated by an element with a NULL `n_un.n_name' member,
|
||||
and fill in the elements of NL. */
|
||||
extern int nlist __P ((__const char *__file, struct nlist * __nl));
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* nlist.h */
|
177
posix/id.c
177
posix/id.c
|
@ -1,177 +0,0 @@
|
|||
/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <limits.h>
|
||||
#include <libintl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
static void
|
||||
print_grpname (id, parens)
|
||||
gid_t id;
|
||||
int parens;
|
||||
{
|
||||
const struct group *const g = getgrgid (id);
|
||||
if (g == NULL)
|
||||
{
|
||||
if (parens)
|
||||
return;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, _("Couldn't find name for group %d\n"), id);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (parens)
|
||||
printf ("(%s)", g->gr_name);
|
||||
else
|
||||
puts (g->gr_name);
|
||||
}
|
||||
|
||||
static void
|
||||
print_pwdname (id, parens)
|
||||
uid_t id;
|
||||
int parens;
|
||||
{
|
||||
const struct passwd *const p = getpwuid (id);
|
||||
if (p == NULL)
|
||||
{
|
||||
if (parens)
|
||||
return;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, _("Couldn't find name for user %d\n"), (int) id);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (parens)
|
||||
printf ("(%s)", p->pw_name);
|
||||
else
|
||||
puts (p->pw_name);
|
||||
}
|
||||
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int print_gid = 1, print_uid = 1;
|
||||
int real = 0, name = 0;
|
||||
int error = 0;
|
||||
int c;
|
||||
|
||||
uid_t ruid = getuid (), euid = geteuid ();
|
||||
gid_t rgid = getgid (), egid = getegid ();
|
||||
|
||||
while ((c = getopt (argc, argv, "gurn")) != -1)
|
||||
switch (c)
|
||||
{
|
||||
default:
|
||||
error = 1;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
print_gid = 1;
|
||||
print_uid = 0;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
print_uid = 1;
|
||||
print_gid = 0;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
real = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
name = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (error || argc != optind)
|
||||
{
|
||||
fputs (_("Usage: id [-gurn]\n"), stderr);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (print_uid && !print_gid)
|
||||
{
|
||||
const uid_t uid = real ? ruid : euid;
|
||||
if (name)
|
||||
print_pwdname (uid, 0);
|
||||
else
|
||||
printf ("%d\n", (int) uid);
|
||||
}
|
||||
else if (print_gid && !print_uid)
|
||||
{
|
||||
const gid_t gid = real ? rgid : egid;
|
||||
if (name)
|
||||
print_grpname (gid, 0);
|
||||
else
|
||||
printf ("%d\n", (int) gid);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if NGROUPS_MAX > 0
|
||||
gid_t groups[NGROUPS_MAX];
|
||||
int ngroups;
|
||||
ngroups = getgroups (NGROUPS_MAX, groups);
|
||||
#endif
|
||||
|
||||
printf ("uid=%d", (int) ruid);
|
||||
print_pwdname (ruid, 1);
|
||||
printf (" gid=%d", (int) rgid);
|
||||
print_grpname (rgid, 1);
|
||||
if (euid != ruid)
|
||||
{
|
||||
printf (" euid=%d", (int) euid);
|
||||
print_pwdname (euid, 1);
|
||||
}
|
||||
if (egid != rgid)
|
||||
{
|
||||
printf (" egid=%d", (int) egid);
|
||||
print_grpname (egid, 1);
|
||||
}
|
||||
|
||||
#if NGROUPS > 0
|
||||
if (ngroups > 0)
|
||||
{
|
||||
size_t i;
|
||||
printf (" groups=%d", (int) groups[0]);
|
||||
print_grpname (groups[0], 1);
|
||||
for (i = 1; i < ngroups; ++i)
|
||||
{
|
||||
printf (", %d", (int) groups[i]);
|
||||
print_grpname (groups[i], 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
|
@ -1,286 +0,0 @@
|
|||
/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
|
||||
* Dep. Matematica Universidade de Coimbra, Portugal, Europe
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93";
|
||||
static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef h_errno
|
||||
extern int h_errno;
|
||||
#endif
|
||||
|
||||
#if defined(mips) && defined(SYSTYPE_BSD43) && !defined(errno)
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
struct netent *_getnetbyaddr __P((long net, int type));
|
||||
struct netent *_getnetbyname __P((const char *name));
|
||||
|
||||
#define BYADDR 0
|
||||
#define BYNAME 1
|
||||
#define MAXALIASES 35
|
||||
|
||||
#if PACKETSZ > 1024
|
||||
#define MAXPACKET PACKETSZ
|
||||
#else
|
||||
#define MAXPACKET 1024
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
HEADER hdr;
|
||||
u_char buf[MAXPACKET];
|
||||
} querybuf;
|
||||
|
||||
typedef union {
|
||||
long al;
|
||||
char ac;
|
||||
} align;
|
||||
|
||||
static struct netent *
|
||||
getnetanswer(answer, anslen, net_i)
|
||||
querybuf *answer;
|
||||
int anslen;
|
||||
int net_i;
|
||||
{
|
||||
|
||||
register HEADER *hp;
|
||||
register u_char *cp;
|
||||
register int n;
|
||||
u_char *eom;
|
||||
int type, class, buflen, ancount, qdcount, haveanswer, i, nchar;
|
||||
char aux1[30], aux2[30], ans[30], *in, *st, *pauxt, *bp, **ap,
|
||||
*paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0;
|
||||
static struct netent net_entry;
|
||||
static char *net_aliases[MAXALIASES], netbuf[BUFSIZ+1];
|
||||
|
||||
/*
|
||||
* find first satisfactory answer
|
||||
*
|
||||
* answer --> +------------+ ( MESSAGE )
|
||||
* | Header |
|
||||
* +------------+
|
||||
* | Question | the question for the name server
|
||||
* +------------+
|
||||
* | Answer | RRs answering the question
|
||||
* +------------+
|
||||
* | Authority | RRs pointing toward an authority
|
||||
* | Additional | RRs holding additional information
|
||||
* +------------+
|
||||
*/
|
||||
eom = answer->buf + anslen;
|
||||
hp = &answer->hdr;
|
||||
ancount = ntohs(hp->ancount); /* #/records in the answer section */
|
||||
qdcount = ntohs(hp->qdcount); /* #/entries in the question section */
|
||||
bp = netbuf;
|
||||
buflen = sizeof(netbuf);
|
||||
cp = answer->buf + HFIXEDSZ;
|
||||
if (!qdcount) {
|
||||
if (hp->aa)
|
||||
__set_h_errno (HOST_NOT_FOUND);
|
||||
else
|
||||
__set_h_errno (TRY_AGAIN);
|
||||
return (NULL);
|
||||
}
|
||||
while (qdcount-- > 0)
|
||||
cp += __dn_skipname(cp, eom) + QFIXEDSZ;
|
||||
ap = net_aliases;
|
||||
*ap = NULL;
|
||||
net_entry.n_aliases = net_aliases;
|
||||
haveanswer = 0;
|
||||
while (--ancount >= 0 && cp < eom) {
|
||||
n = dn_expand(answer->buf, eom, cp, bp, buflen);
|
||||
if ((n < 0) || !res_dnok(bp))
|
||||
break;
|
||||
cp += n;
|
||||
ans[0] = '\0';
|
||||
(void)strcpy(&ans[0], bp);
|
||||
GETSHORT(type, cp);
|
||||
GETSHORT(class, cp);
|
||||
cp += INT32SZ; /* TTL */
|
||||
GETSHORT(n, cp);
|
||||
if (class == C_IN && type == T_PTR) {
|
||||
n = dn_expand(answer->buf, eom, cp, bp, buflen);
|
||||
if ((n < 0) || !res_hnok(bp)) {
|
||||
cp += n;
|
||||
return (NULL);
|
||||
}
|
||||
cp += n;
|
||||
*ap++ = bp;
|
||||
bp += strlen(bp) + 1;
|
||||
net_entry.n_addrtype =
|
||||
(class == C_IN) ? AF_INET : AF_UNSPEC;
|
||||
haveanswer++;
|
||||
}
|
||||
}
|
||||
if (haveanswer) {
|
||||
*ap = NULL;
|
||||
switch (net_i) {
|
||||
case BYADDR:
|
||||
net_entry.n_name = *net_entry.n_aliases;
|
||||
net_entry.n_net = 0L;
|
||||
break;
|
||||
case BYNAME:
|
||||
in = *net_entry.n_aliases;
|
||||
net_entry.n_name = &ans[0];
|
||||
aux2[0] = '\0';
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (st = in, nchar = 0;
|
||||
*st != '.';
|
||||
st++, nchar++)
|
||||
;
|
||||
if (nchar != 1 || *in != '0' || flag) {
|
||||
flag = 1;
|
||||
(void)strncpy(paux1,
|
||||
(i==0) ? in : in-1,
|
||||
(i==0) ?nchar : nchar+1);
|
||||
paux1[(i==0) ? nchar : nchar+1] = '\0';
|
||||
pauxt = paux2;
|
||||
paux2 = strcat(paux1, paux2);
|
||||
paux1 = pauxt;
|
||||
}
|
||||
in = ++st;
|
||||
}
|
||||
net_entry.n_net = inet_network(paux2);
|
||||
break;
|
||||
}
|
||||
net_entry.n_aliases++;
|
||||
return (&net_entry);
|
||||
}
|
||||
__set_h_errno (TRY_AGAIN);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
struct netent *
|
||||
getnetbyaddr(net, net_type)
|
||||
register u_long net;
|
||||
register int net_type;
|
||||
{
|
||||
unsigned int netbr[4];
|
||||
int nn, anslen;
|
||||
querybuf buf;
|
||||
char qbuf[MAXDNAME];
|
||||
u_int32_t net2; /* Changed from unsigned long --roland */
|
||||
struct netent *net_entry;
|
||||
|
||||
if (net_type != AF_INET)
|
||||
return (_getnetbyaddr(net, net_type));
|
||||
|
||||
for (nn = 4, net2 = net; net2; net2 >>= 8)
|
||||
netbr[--nn] = net2 & 0xff;
|
||||
switch (nn) {
|
||||
case 3: /* Class A */
|
||||
sprintf(qbuf, "0.0.0.%u.in-addr.arpa", netbr[3]);
|
||||
break;
|
||||
case 2: /* Class B */
|
||||
sprintf(qbuf, "0.0.%u.%u.in-addr.arpa", netbr[3], netbr[2]);
|
||||
break;
|
||||
case 1: /* Class C */
|
||||
sprintf(qbuf, "0.%u.%u.%u.in-addr.arpa", netbr[3], netbr[2],
|
||||
netbr[1]);
|
||||
break;
|
||||
case 0: /* Class D - E */
|
||||
sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", netbr[3], netbr[2],
|
||||
netbr[1], netbr[0]);
|
||||
break;
|
||||
}
|
||||
anslen = res_query(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof(buf));
|
||||
if (anslen < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_query failed\n");
|
||||
#endif
|
||||
if (errno == ECONNREFUSED)
|
||||
return (_getnetbyaddr(net, net_type));
|
||||
return (NULL);
|
||||
}
|
||||
net_entry = getnetanswer(&buf, anslen, BYADDR);
|
||||
if (net_entry) {
|
||||
unsigned u_net = net; /* maybe net should be unsigned ? */
|
||||
|
||||
/* Strip trailing zeros */
|
||||
while ((u_net & 0xff) == 0 && u_net != 0)
|
||||
u_net >>= 8;
|
||||
net_entry->n_net = u_net;
|
||||
return (net_entry);
|
||||
}
|
||||
return (_getnetbyaddr(net, net_type));
|
||||
}
|
||||
|
||||
struct netent *
|
||||
getnetbyname(net)
|
||||
register const char *net;
|
||||
{
|
||||
int anslen;
|
||||
querybuf buf;
|
||||
char qbuf[MAXDNAME];
|
||||
struct netent *net_entry;
|
||||
|
||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
||||
__set_h_errno (NETDB_INTERNAL);
|
||||
return (NULL);
|
||||
}
|
||||
strcpy(&qbuf[0], net);
|
||||
anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof(buf));
|
||||
if (anslen < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("res_query failed\n");
|
||||
#endif
|
||||
if (errno == ECONNREFUSED)
|
||||
return (_getnetbyname(net));
|
||||
return (_getnetbyname(net));
|
||||
}
|
||||
net_entry = getnetanswer(&buf, anslen, BYNAME);
|
||||
if (net_entry)
|
||||
return (net_entry);
|
||||
return (_getnetbyname(net));
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
for func in $*; do
|
||||
for file in `find sysdeps -name "${func}.c"`;
|
||||
do
|
||||
script=/tmp/foo$$;
|
||||
( echo "%s/${func}/__&/g";
|
||||
echo x )>$script ;
|
||||
ex $file <$script ;
|
||||
newfile=`echo $file | sed "s/${func}/__&/"`;
|
||||
mv $file $newfile;
|
||||
echo $newfile;
|
||||
done
|
||||
done
|
|
@ -1,29 +0,0 @@
|
|||
#! /bin/csh -f
|
||||
|
||||
#
|
||||
# Prints all the files given as arguments.
|
||||
# Files that will fit on less than a printed page
|
||||
# are concatenated together. Bigger ones are pr'd.
|
||||
#
|
||||
|
||||
|
||||
set tocat='' topr=''
|
||||
|
||||
foreach file ($*)
|
||||
set lines=`wc -l $file | sed "s/$file//"`
|
||||
if ($lines > 40) then
|
||||
set topr=($topr $file)
|
||||
else
|
||||
set tocat=($tocat $file)
|
||||
endif
|
||||
end
|
||||
|
||||
|
||||
if ("$topr" != '') pr $topr
|
||||
|
||||
if ("$tocat" != '') foreach file ($tocat)
|
||||
echo -n "==================== $file ======================"
|
||||
cat $file
|
||||
end
|
||||
|
||||
exit 0
|
|
@ -1,14 +0,0 @@
|
|||
/* This test comes from ISO C Corrigendum 1. */
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int d1, n1, n2, i;
|
||||
#define NOISE 1234567
|
||||
int d2 = NOISE;
|
||||
|
||||
i = sscanf ("123", "%d%n%n%d", &d1, &n1, &n2, &d2);
|
||||
|
||||
return i != 3 || d1 != 123 || n1 != 3 || n2 != 3 || d2 != NOISE;
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int n = -1;
|
||||
char c = '!';
|
||||
int ret;
|
||||
|
||||
ret = sscanf ("0x", "%i%c", &n, &c);
|
||||
printf ("ret: %d, n: %d, c: %c\n", ret, n, c);
|
||||
if (ret != 2 || n != 0 || c != 'x')
|
||||
abort ();
|
||||
return 0;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <nlist.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* Search the executable FILE for symbols matching those in NL,
|
||||
which is terminated by an element with a NULL `n_un.n_name' member,
|
||||
and fill in the elements of NL. */
|
||||
int
|
||||
nlist (file, nl)
|
||||
const char *file;
|
||||
struct nlist *nl;
|
||||
{
|
||||
if (nl == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
__set_errno (ENOSYS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
stub_warning (nlist)
|
||||
#include <stub-tag.h>
|
|
@ -1,61 +0,0 @@
|
|||
/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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 _VARARGS_H
|
||||
|
||||
#define _VARARGS_H 1
|
||||
#include <features.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#define va_alist __builtin_va_alist
|
||||
#define va_dcl int __builtin_va_alist;
|
||||
#define va_list char *
|
||||
|
||||
#ifdef __sparc__
|
||||
#define va_start(AP) \
|
||||
(__builtin_saveregs (), \
|
||||
AP = ((void *) &__builtin_va_alist))
|
||||
#else
|
||||
#define va_start(AP) AP=(char *) &__builtin_va_alist
|
||||
#endif
|
||||
#define va_end(AP)
|
||||
|
||||
#define __va_rounded_size(TYPE) \
|
||||
(((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
|
||||
|
||||
#define va_arg(AP, TYPE) \
|
||||
(*((TYPE *) (AP += __va_rounded_size (TYPE), \
|
||||
AP - __va_rounded_size (TYPE))))
|
||||
|
||||
#else /* Not GCC. */
|
||||
|
||||
/* Implement varargs on top of our stdarg implementation. */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define va_alist __va_fakearg
|
||||
#define va_dcl int __va_fakearg;
|
||||
|
||||
#undef va_start
|
||||
#define va_start(ap) (__va_start((ap), __va_fakearg), \
|
||||
(ap) -= sizeof(__va_fakearg))
|
||||
|
||||
#endif /* GCC. */
|
||||
|
||||
#endif /* varargs.h */
|
|
@ -1,91 +0,0 @@
|
|||
/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <a.out.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Search the executable FILE for symbols matching those in NL,
|
||||
which is terminated by an element with a NULL `n_un.n_name' member,
|
||||
and fill in the elements of NL. */
|
||||
int
|
||||
nlist (const char *file, struct nlist *nl)
|
||||
{
|
||||
FILE *f;
|
||||
struct exec header;
|
||||
size_t nsymbols;
|
||||
struct nlist *symbols;
|
||||
unsigned long int string_table_size;
|
||||
char *string_table;
|
||||
register size_t i;
|
||||
|
||||
if (nl == NULL)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
f = fopen (file, "r");
|
||||
if (f == NULL)
|
||||
return -1;
|
||||
|
||||
if (fread ((void *) &header, sizeof (header), 1, f) != 1)
|
||||
goto lose;
|
||||
|
||||
if (fseek (f, N_SYMOFF (header), SEEK_SET) != 0)
|
||||
goto lose;
|
||||
|
||||
symbols = (struct nlist *) __alloca (header.a_syms);
|
||||
nsymbols = header.a_syms / sizeof (symbols[0]);
|
||||
|
||||
if (fread ((void *) symbols, sizeof (symbols[0]), nsymbols, f) != nsymbols)
|
||||
goto lose;
|
||||
|
||||
if (fread ((void *) &string_table_size, sizeof (string_table_size), 1, f)
|
||||
!= 1)
|
||||
goto lose;
|
||||
string_table_size -= sizeof (string_table_size);
|
||||
|
||||
string_table = (char *) __alloca (string_table_size);
|
||||
if (fread ((void *) string_table, string_table_size, 1, f) != 1)
|
||||
goto lose;
|
||||
|
||||
for (i = 0; i < nsymbols; ++i)
|
||||
{
|
||||
register struct nlist *nlp;
|
||||
for (nlp = nl; nlp->n_un.n_name != NULL; ++nlp)
|
||||
if (!strcmp (nlp->n_un.n_name,
|
||||
&string_table[symbols[i].n_un.n_strx -
|
||||
sizeof (string_table_size)]))
|
||||
{
|
||||
char *const name = nlp->n_un.n_name;
|
||||
*nlp = symbols[i];
|
||||
nlp->n_un.n_name = name;
|
||||
}
|
||||
}
|
||||
|
||||
(void) fclose (f);
|
||||
return 0;
|
||||
|
||||
lose:;
|
||||
(void) fclose (f);
|
||||
return -1;
|
||||
}
|
45
time/ap.c
45
time/ap.c
|
@ -1,45 +0,0 @@
|
|||
/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <malloc.h>
|
||||
#include <mcheck.h>
|
||||
|
||||
/* Prints the time in the form "hh:mm ?M", where ? is A or P.
|
||||
A simple test for strftime(). */
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
char buf[20];
|
||||
time_t t;
|
||||
|
||||
mcheck (NULL);
|
||||
|
||||
if (argc != 1)
|
||||
fprintf (stderr, "Usage: %s\n", argv[0]);
|
||||
|
||||
t = time ((time_t *) NULL);
|
||||
if (strftime (buf, sizeof (buf), "%I:%M %p", localtime (&t)) == 0)
|
||||
exit (EXIT_FAILURE);
|
||||
|
||||
puts (buf);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
49
time/date.c
49
time/date.c
|
@ -1,49 +0,0 @@
|
|||
/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
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. */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
/* Prints the date in the form "Day Mon dd hh:mm:ss ZZZ yyyy\n".
|
||||
A simple test for localtime and strftime. */
|
||||
int
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
time_t t = time (NULL);
|
||||
struct tm *tp = localtime (&t);
|
||||
char good = tp != NULL;
|
||||
|
||||
if (good)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
good = strftime (buf, sizeof (buf), "%a %b %d %X %Z %Y", tp);
|
||||
if (good)
|
||||
puts (buf);
|
||||
else
|
||||
perror ("strftime");
|
||||
}
|
||||
else
|
||||
perror ("localtime");
|
||||
|
||||
return good ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
Loading…
Reference in a new issue