202
#define die(format, args...) (die) ("%s: " format, __func__ , ##args)
202
#define die_0(format) (die) ("%s: " format, __func__)
203
#define die_1(format, a) (die) ("%s: " format, __func__, (a))
204
#define die_2(format, a, b) (die) ("%s: " format, __func__, (a),(b))
205
#define die_3(format, a, b, c) (die) ("%s: " format, __func__, (a),(b),(c))
205
208
err (const char *format, ...)
292
295
if (pending_len >= nleft)
293
die ("received line too large");
296
die_0 ("received line too large");
294
297
memcpy (buf, pending, pending_len);
318
die ("reading fd %d failed: %s", fd, strerror (errno));
321
die_2 ("reading fd %d failed: %s", fd, strerror (errno));
320
die ("received incomplete line on fd %d", fd);
323
die_1 ("received incomplete line on fd %d", fd);
381
384
size_t n = strlen (line);
384
die ("line too long for Assuan protocol");
387
die_0 ("line too long for Assuan protocol");
385
388
strcpy (buffer, line);
386
389
if (!n || buffer[n-1] != '\n')
387
390
buffer[n++] = '\n';
389
392
if (writen (fd, buffer, n))
390
die ("sending line (\"%s\") to %d failed: %s", buffer, fd,
393
die_3 ("sending line (\"%s\") to %d failed: %s", buffer, fd,
391
394
strerror (errno));
406
409
if (pipe (rp) < 0)
407
die ("pipe creation failed: %s", strerror (errno));
410
die_1 ("pipe creation failed: %s", strerror (errno));
408
411
if (pipe (wp) < 0)
409
die ("pipe creation failed: %s", strerror (errno));
412
die_1 ("pipe creation failed: %s", strerror (errno));
418
die_0 ("fork failed");
427
430
if (wp[0] != STDIN_FILENO)
429
432
if (dup2 (wp[0], STDIN_FILENO) == -1)
430
die ("dup2 failed in child: %s", strerror (errno));
433
die_1 ("dup2 failed in child: %s", strerror (errno));
433
436
if (rp[1] != STDOUT_FILENO)
435
438
if (dup2 (rp[1], STDOUT_FILENO) == -1)
436
die ("dup2 failed in child: %s", strerror (errno));
439
die_1 ("dup2 failed in child: %s", strerror (errno));
439
442
if (!opt_verbose)
441
444
int fd = open ("/dev/null", O_WRONLY);
443
die ("can't open `/dev/null': %s", strerror (errno));
446
die_1 ("can't open `/dev/null': %s", strerror (errno));
444
447
if (dup2 (fd, STDERR_FILENO) == -1)
445
die ("dup2 failed in child: %s", strerror (errno));
448
die_1 ("dup2 failed in child: %s", strerror (errno));
451
454
execl (pgmname, arg0, "--server", NULL);
452
die ("exec failed for `%s': %s", pgmname, strerror (errno));
455
die_2 ("exec failed for `%s': %s", pgmname, strerror (errno));
724
727
while (recv_type != LINE_OK && recv_type != LINE_ERR);
725
728
if (recv_type != LINE_OK)
726
die ("expected OK but got `%s'", recv_line);
729
die_1 ("expected OK but got `%s'", recv_line);
745
748
while (recv_type != LINE_OK && recv_type != LINE_ERR);
746
749
if (recv_type != LINE_ERR)
747
die ("expected ERR but got `%s'", recv_line);
750
die_1 ("expected ERR but got `%s'", recv_line);
755
758
if (!*assign_to || !*arg)
756
die ("syntax error: count-status requires an argument and a variable");
759
die_0 ("syntax error: count-status requires an argument and a variable");
758
761
for (p=arg; *p && !spacep (p); p++)
762
765
for (*p++ = 0; spacep (p); p++)
765
die ("cmpfiles: syntax error");
768
die_0 ("cmpfiles: syntax error");
767
770
set_type_var (assign_to, arg, VARTYPE_COUNTER);
777
780
fd = open (arg, O_RDONLY);
778
781
while (fd == -1 && errno == EINTR);
780
die ("error opening `%s': %s", arg, strerror (errno));
783
die_2 ("error opening `%s': %s", arg, strerror (errno));
782
785
sprintf (numbuf, "%d", fd);
783
786
set_type_var (assign_to, numbuf, VARTYPE_FD);
793
796
fd = open (arg, O_WRONLY|O_CREAT|O_TRUNC, 0666);
794
797
while (fd == -1 && errno == EINTR);
796
die ("error creating `%s': %s", arg, strerror (errno));
799
die_2 ("error creating `%s': %s", arg, strerror (errno));
798
801
sprintf (numbuf, "%d", fd);
799
802
set_type_var (assign_to, numbuf, VARTYPE_FD);
1003
1006
if (!cmdtbl[i].name)
1005
1008
if (!assign_to)
1006
die ("invalid statement `%s'\n", stmt);
1009
die_1 ("invalid statement `%s'\n", stmt);
1008
1011
*save_p = save_c;
1009
1012
set_var (assign_to, stmt);
1079
1082
p = strchr (buffer,'\n');
1081
die ("incomplete script line");
1084
die_0 ("incomplete script line");
1083
1086
if (interpreter (buffer))