diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2013-10-31 13:00:35 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2013-10-31 13:00:35 +0000 |
| commit | c92d635ad3fef3b2b8c44c4639ad0fd7c00ff20b (patch) | |
| tree | aedc92cd31cac1107753d1fa2f607d3f13c5d2f0 /usr.sbin/pkg_install/lib/exec.c | |
| parent | 8cf0e328019e6926f6dd3d52d5ebc7989c42d791 (diff) | |
Notes
Diffstat (limited to 'usr.sbin/pkg_install/lib/exec.c')
| -rw-r--r-- | usr.sbin/pkg_install/lib/exec.c | 110 |
1 files changed, 0 insertions, 110 deletions
diff --git a/usr.sbin/pkg_install/lib/exec.c b/usr.sbin/pkg_install/lib/exec.c deleted file mode 100644 index c0b4ac329978..000000000000 --- a/usr.sbin/pkg_install/lib/exec.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * FreeBSD install - a package for the installation and maintenance - * of non-core utilities. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Jordan K. Hubbard - * 18 July 1993 - * - * Miscellaneous system routines. - * - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include "lib.h" -#include <err.h> - -/* - * Unusual system() substitute. Accepts format string and args, - * builds and executes command. Returns exit code. - */ - -int -vsystem(const char *fmt, ...) -{ - va_list args; - char *cmd; - long maxargs; - int ret; - - maxargs = sysconf(_SC_ARG_MAX); - maxargs -= 32; /* some slop for the sh -c */ - cmd = malloc(maxargs); - if (!cmd) { - warnx("vsystem can't alloc arg space"); - return 1; - } - - va_start(args, fmt); - if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) { - warnx("vsystem args are too long"); - va_end(args); - return 1; - } -#ifdef DEBUG -printf("Executing %s\n", cmd); -#endif - ret = system(cmd); - va_end(args); - free(cmd); - return ret; -} - -char * -vpipe(const char *fmt, ...) -{ - FILE *fp; - char *cmd, *rp; - long maxargs; - va_list args; - - rp = malloc(MAXPATHLEN); - if (!rp) { - warnx("vpipe can't alloc buffer space"); - return NULL; - } - maxargs = sysconf(_SC_ARG_MAX); - maxargs -= 32; /* some slop for the sh -c */ - cmd = alloca(maxargs); - if (!cmd) { - warnx("vpipe can't alloc arg space"); - return NULL; - } - - va_start(args, fmt); - if (vsnprintf(cmd, maxargs, fmt, args) > maxargs) { - warnx("vsystem args are too long"); - va_end(args); - return NULL; - } -#ifdef DEBUG - fprintf(stderr, "Executing %s\n", cmd); -#endif - fflush(NULL); - fp = popen(cmd, "r"); - if (fp == NULL) { - warnx("popen() failed"); - va_end(args); - return NULL; - } - get_string(rp, MAXPATHLEN, fp); -#ifdef DEBUG - fprintf(stderr, "Returned %s\n", rp); -#endif - va_end(args); - if (pclose(fp) || (strlen(rp) == 0)) { - free(rp); - return NULL; - } - return rp; -} |
