2 * wiggle - apply rejected patches
4 * Copyright (C) 2003 Neil Brown <neilb@cse.unsw.edu.au>
5 * Copyright (C) 2010-2013 Neil Brown <neilb@suse.de>
6 * Copyright (C) 2014-2020 Neil Brown <neil@brown.name>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program.
23 * Email: <neil@brown.name>
31 char *wiggle_Cmd
= "wiggle";
33 int wiggle_do_trace
= 0;
35 void *wiggle_xmalloc(int size
)
37 void *rv
= malloc(size
);
39 char *msg
= "Failed to allocate memory - aborting\n";
40 write(2, msg
, strlen(msg
));
46 void wiggle_printword(FILE *f
, struct elmnt e
)
49 fprintf(f
, "%.*s", e
.plen
+ e
.prefix
,
53 sscanf(e
.start
+1, "%d %d %d", &a
, &b
, &c
);
54 fprintf(f
, "*** %d,%d **** %d%s", b
, c
, a
, e
.start
+18);
58 void wiggle_die(char *reason
)
60 fprintf(stderr
, "%s: fatal error: %s failure\n", wiggle_Cmd
, reason
);
64 void wiggle_check_dir(char *name
, int fd
)
67 if (fstat(fd
, &st
) != 0) {
68 fprintf(stderr
, "%s: fatal: %s is strange\n", wiggle_Cmd
, name
);
71 if (S_ISDIR(st
.st_mode
)) {
72 fprintf(stderr
, "%s: %s is a directory\n", wiggle_Cmd
, name
);