22fdfd8f1603d93d4e51581c194c37597512bcba
* $Id: etc.c,v 1.5 1993/12/04 00:52:55 jkh Exp $
* Report a nonfatal error.
(void)fprintf(stderr
, "%s: ", progname
);
(void)vfprintf(stderr
, fmt
, ap
);
(void)fprintf(stderr
, "\n");
(void)fprintf(stderr
, "%s: ", progname
);
(void)vfprintf(stderr
, fmt
, ap
);
(void)fprintf(stderr
, "\n");
* Return a newly-allocated string whose contents concatenate
* the strings S1, S2, S3.
const char *s1
, *s2
, *s3
;
register int len1
= strlen (s1
),
register char *result
= (char *) xmalloc (len1
+ len2
+ len3
+ 1);
strcpy (result
+ len1
, s2
);
strcpy (result
+ len1
+ len2
, s3
);
result
[len1
+ len2
+ len3
] = 0;
/* Parse the string ARG using scanf format FORMAT, and return the result.
If it does not parse, report fatal error
generating the error message using format string ERROR and ARG as arg. */
parse(arg
, format
, error
)
char *arg
, *format
, *error
;
if (1 != sscanf (arg
, format
, &x
))
/* Like malloc but get fatal error if memory is exhausted. */
register void *result
= (void *)malloc (size
);
fatal ("virtual memory exhausted", 0);
/* Like realloc but get fatal error if memory is exhausted. */
result
= (void *)malloc (size
);
result
= (void *)realloc (ptr
, size
);
fatal ("virtual memory exhausted", 0);
* Output COUNT*ELTSIZE bytes of data at BUF to the descriptor DESC.
mywrite (buf
, count
, eltsize
, desc
)
register int bytes
= count
* eltsize
;
val
= write (desc
, buf
, bytes
);
* Output PADDING zero-bytes to descriptor OUTDESC.
* PADDING may be negative; in that case, do nothing.
padfile (padding
, outdesc
)
buf
= (char *) alloca (padding
);
mywrite (buf
, padding
, 1, outdesc
);