|
Revision 2, 1.9 kB
(checked in by nextime, 2 years ago)
|
Initial import, branching from morphix svn
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
#ifdef HAVE_CONFIG_H |
|---|
| 16 |
# include <config.h> |
|---|
| 17 |
#endif |
|---|
| 18 |
#ifdef FISTGEN |
|---|
| 19 |
# include "fist_mini_fo.h" |
|---|
| 20 |
#endif |
|---|
| 21 |
#include "fist.h" |
|---|
| 22 |
#include "mini_fo.h" |
|---|
| 23 |
|
|---|
| 24 |
#include <sys/ioctl.h> |
|---|
| 25 |
#include <fcntl.h> |
|---|
| 26 |
#include <stdlib.h> |
|---|
| 27 |
#include <unistd.h> |
|---|
| 28 |
#include <string.h> |
|---|
| 29 |
#include <stdio.h> |
|---|
| 30 |
|
|---|
| 31 |
static int opt_d = 0; |
|---|
| 32 |
static int optcount; |
|---|
| 33 |
static const char *progname; |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
void |
|---|
| 37 |
usage(void) |
|---|
| 38 |
{ |
|---|
| 39 |
fprintf(stderr, "Usage: %s -d file [val]\n\tto set/get debugging values\n", progname); |
|---|
| 40 |
exit(1); |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
int |
|---|
| 45 |
main(int argc, char *argv[]) |
|---|
| 46 |
{ |
|---|
| 47 |
int fd, ret, val = 0; |
|---|
| 48 |
|
|---|
| 49 |
progname = argv[0]; |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
if (argc < 3) |
|---|
| 53 |
usage(); |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
if (strcmp(argv[1], "-d") == 0) { |
|---|
| 57 |
if (argc > 4) |
|---|
| 58 |
usage(); |
|---|
| 59 |
opt_d++; |
|---|
| 60 |
optcount++; |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
if (!optcount) |
|---|
| 66 |
usage(); |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
fd = open(argv[2], O_RDONLY); |
|---|
| 70 |
if (fd < 0) { |
|---|
| 71 |
perror(argv[2]); |
|---|
| 72 |
exit(1); |
|---|
| 73 |
} |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
if (opt_d) { |
|---|
| 77 |
if (argc == 4) { |
|---|
| 78 |
val = atoi(argv[3]); |
|---|
| 79 |
ret = ioctl(fd, FIST_IOCTL_SET_DEBUG_VALUE, &val); |
|---|
| 80 |
if (ret < 0) { |
|---|
| 81 |
perror("ioctl set"); |
|---|
| 82 |
exit(1); |
|---|
| 83 |
} |
|---|
| 84 |
} else { |
|---|
| 85 |
ret = ioctl(fd, FIST_IOCTL_GET_DEBUG_VALUE, &val); |
|---|
| 86 |
if (ret < 0) { |
|---|
| 87 |
perror("ioctl get"); |
|---|
| 88 |
exit(1); |
|---|
| 89 |
} |
|---|
| 90 |
printf("debug ioctl returned value %d\n", val); |
|---|
| 91 |
} |
|---|
| 92 |
goto out; |
|---|
| 93 |
} |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
out: |
|---|
| 98 |
close(fd); |
|---|
| 99 |
exit(0); |
|---|
| 100 |
} |
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|