Simplify: move dumpcis.c and dumpcisfile.c into main.
This commit is contained in:
parent
e363ea0fab
commit
2bbc3fd5f6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=185114
@ -4,7 +4,7 @@
|
||||
|
||||
PROG= dumpcis
|
||||
MAN= dumpcis.8
|
||||
SRCS= main.c dumpcis.c dumpcisfile.c readcis.c printcis.c
|
||||
SRCS= main.c readcis.c printcis.c
|
||||
WARNS?= 5
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1995 Andrew McRae. 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <pccard/cardinfo.h>
|
||||
#include <pccard/cis.h>
|
||||
#include "readcis.h"
|
||||
|
||||
void
|
||||
dump(unsigned char *p, int sz)
|
||||
{
|
||||
int ad = 0, i;
|
||||
|
||||
while (sz > 0) {
|
||||
printf("%03x: ", ad);
|
||||
for (i = 0; i < ((sz < 16) ? sz : 16); i++)
|
||||
printf(" %02x", p[i]);
|
||||
printf("\n");
|
||||
sz -= 16;
|
||||
p += 16;
|
||||
ad += 16;
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1995 Andrew McRae. 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.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <pccard/cardinfo.h>
|
||||
#include <pccard/cis.h>
|
||||
#include "readcis.h"
|
||||
|
||||
static void
|
||||
scanfile(char *name)
|
||||
{
|
||||
int fd;
|
||||
struct cis *cp;
|
||||
|
||||
fd = open(name, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return;
|
||||
cp = readcis(fd);
|
||||
if (cp) {
|
||||
printf("Configuration data for file %s\n",
|
||||
name);
|
||||
dumpcis(cp);
|
||||
freecis(cp);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int
|
||||
dumpcisfile_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
isdumpcisfile = 1;
|
||||
for (argc--, argv++; argc; argc--, argv++)
|
||||
scanfile(*argv);
|
||||
return 0;
|
||||
}
|
@ -25,10 +25,50 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
int dumpcisfile_main(int, char **);
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "readcis.h"
|
||||
|
||||
void
|
||||
dump(unsigned char *p, int sz)
|
||||
{
|
||||
int ad = 0, i;
|
||||
|
||||
while (sz > 0) {
|
||||
printf("%03x: ", ad);
|
||||
for (i = 0; i < ((sz < 16) ? sz : 16); i++)
|
||||
printf(" %02x", p[i]);
|
||||
printf("\n");
|
||||
sz -= 16;
|
||||
p += 16;
|
||||
ad += 16;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
scanfile(char *name)
|
||||
{
|
||||
int fd;
|
||||
struct cis *cp;
|
||||
|
||||
fd = open(name, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return;
|
||||
cp = readcis(fd);
|
||||
if (cp) {
|
||||
printf("Configuration data for file %s\n",
|
||||
name);
|
||||
dumpcis(cp);
|
||||
freecis(cp);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
return dumpcisfile_main(argc, argv);
|
||||
for (argc--, argv++; argc; argc--, argv++)
|
||||
scanfile(*argv);
|
||||
return 0;
|
||||
}
|
||||
|
@ -144,5 +144,3 @@ struct cis *readcis(int);
|
||||
|
||||
const char *tuple_name(unsigned char);
|
||||
u_int parse_num(int, u_char *, u_char **, int);
|
||||
|
||||
int isdumpcisfile;
|
||||
|
Loading…
Reference in New Issue
Block a user