Ticket #1769: bug.c

File bug.c, 829 bytes (added by alexander@…, 19 years ago)

Modified bug reporter

Line 
1/* Simple event recorder */
2#define _GNU_SOURCE
3#include <sys/types.h>
4#include <sys/stat.h>
5#include <fcntl.h>
6#include <unistd.h>
7#include <stdlib.h>
8#include <argz.h>
9int main(int argc, char * argv[])
10{
11 char * envar;
12 char * envz;
13 size_t len;
14 int bug;
15 bug = open("/dev/bug", O_WRONLY | O_APPEND);
16 if (bug == -1)
17 return 0;
18
19 /* Ignore everything USB-related to avoid spamming the list */
20 envar = getenv("PHYSDEVPATH");
21 if (envar && strstr(envar, "usb"))
22 return 0;
23 envar = getenv("DEVPATH");
24 if (envar && strstr(envar, "usb"))
25 return 0;
26
27 setenv("_SEPARATOR", "--------------------------------------", 1);
28 argz_create(environ, &envz, &len);
29 argz_stringify(envz, len, '\n');
30 envz[len-1]='\n';
31 write(bug, envz, len);
32 close(bug);
33 free(envz);
34 return 0;
35}