
3 changed files with 7 additions and 93 deletions
@ -1,85 +0,0 @@ |
|||
/*
|
|||
utils.c - common utilities for debian-installer |
|||
Author - David Kimdon |
|||
|
|||
Copyright (C) 2000-2002 David Kimdon <dwhedon@debian.org> |
|||
|
|||
This program is free software; you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation; either version 2 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
This program is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with this program; if not, write to the Free Software |
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
|
|||
*/ |
|||
|
|||
|
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdarg.h> |
|||
#include <stdlib.h> |
|||
#include <sys/types.h> |
|||
#include <sys/stat.h> |
|||
#include <unistd.h> |
|||
#include <syslog.h> |
|||
|
|||
|
|||
#define MAXLINE 512 |
|||
|
|||
int |
|||
execlog (const char *incmd) |
|||
{ |
|||
FILE *output; |
|||
char cmd[strlen (incmd) + 6]; |
|||
char line[MAXLINE]; |
|||
strcpy (cmd, incmd); |
|||
|
|||
openlog ("installer", LOG_PID | LOG_PERROR, LOG_USER); |
|||
syslog (LOG_DEBUG, "running cmd '%s'", cmd); |
|||
|
|||
/* FIXME: this can cause the shell command if there's redirection
|
|||
already in the passed string */ |
|||
strcat (cmd, " 2>&1"); |
|||
output = popen (cmd, "r"); |
|||
while (fgets (line, MAXLINE, output) != NULL) |
|||
{ |
|||
syslog (LOG_DEBUG, line); |
|||
} |
|||
closelog (); |
|||
/* FIXME we aren't getting the return value from the actual command
|
|||
executed, not sure how to do that cleanly */ |
|||
return (pclose (output)); |
|||
} |
|||
|
|||
|
|||
int |
|||
check_dir (const char *dirname) |
|||
{ |
|||
struct stat check; |
|||
if (stat (dirname, &check) == -1) |
|||
return -1; |
|||
else |
|||
return S_ISDIR (check.st_mode); |
|||
} |
|||
|
|||
|
|||
int |
|||
snprintfcat (char *str, size_t size, const char *format, ...) |
|||
{ |
|||
va_list ap; |
|||
int retval; |
|||
size_t len = strlen (str); |
|||
|
|||
va_start (ap, format); |
|||
retval = vsnprintf (str + len, size - len, format, ap); |
|||
va_end (ap); |
|||
|
|||
return retval; |
|||
} |
@ -1,8 +0,0 @@ |
|||
#ifndef __UTILS_H__ |
|||
#define __UTILS_H__ |
|||
|
|||
int execlog (char *); |
|||
int check_dir (char *); |
|||
int snprintfcat (char *str, size_t size, const char *format, ...); |
|||
|
|||
#endif /* __UTILS_H__ */ |
Loading…
Reference in new issue