diff --git a/src/tools-source/cmd_wrapper.c b/src/tools-source/cmd_wrapper.c index 37dd4df..1948047 100644 --- a/src/tools-source/cmd_wrapper.c +++ b/src/tools-source/cmd_wrapper.c @@ -1,18 +1,19 @@ /* - * --- T2-COPYRIGHT-NOTE-BEGIN --- + * --- SDE-COPYRIGHT-NOTE-BEGIN --- * This copyright note is auto-generated by ./scripts/Create-CopyPatch. - * - * T2 SDE: misc/tools-source/cmd_wrapper.c + * + * Filename: src/tools-source/cmd_wrapper.c + * Copyright (C) 2013 The OpenSDE Project * Copyright (C) 2004 - 2006 The T2 SDE Project * Copyright (C) 1998 - 2003 Clifford Wolf - * + * * More information can be found in the files COPYING and README. - * + * * 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; version 2 of the License. A copy of the * GNU General Public License can be found in the file COPYING. - * --- T2-COPYRIGHT-NOTE-END --- + * --- SDE-COPYRIGHT-NOTE-END --- * * Generic command wrapper. * @@ -58,6 +59,38 @@ #define VERBOSE_DEBUG 1 int debug=1; +static inline ssize_t write2(int fd, const char *buf, size_t count) +{ + int wc, wt = 0; + while (count > 0) { + wc = write(fd, buf, count); + if (wc > 0) { + wt += wc; + count -= count; + buf += wc; + } else if (wc < 0 && errno != EINTR) { + fprintf(stderr, "cmd_wrapper: write(%d): %s.\n", fd, strerror(errno)); + return wc; + } + } + return wt; +} + +static inline ssize_t read2(int fd, char *buf, size_t count) +{ + ssize_t rc; + +read_retry: + rc = read(fd, buf, count); + if (rc < 0) { + if (errno == EINTR) + goto read_retry; + else + fprintf(stderr, "cmd_wrapper: read(%d): %s.\n", fd, strerror(errno)); + } + return rc; +} + /* * Clean config vars before using them */ @@ -373,8 +406,8 @@ int main(int argc, char ** argv) { /* Create content of input file */ for (c3=0; c3 #include +#include #include #include @@ -23,7 +26,10 @@ int main(int argc, char ** argv) { int size=0; char fn[512]; struct stat st; - if (argc > 1) chdir(argv[1]); + if (argc > 1 && chdir(argv[1]) < 0) { + fprintf(stderr, "getdu: %s: %s.\n", argv[1], strerror(errno)); + return 1; + } while ( scanf("%*s %s",fn) == 1 ) { if ( lstat(fn,&st) ) continue; if ( S_ISREG(st.st_mode) ) size+=st.st_size; diff --git a/src/tools-source/getfiles.c b/src/tools-source/getfiles.c index 2cfcb5d..2f9600a 100644 --- a/src/tools-source/getfiles.c +++ b/src/tools-source/getfiles.c @@ -1,20 +1,22 @@ /* - * --- T2-COPYRIGHT-NOTE-BEGIN --- + * --- SDE-COPYRIGHT-NOTE-BEGIN --- * This copyright note is auto-generated by ./scripts/Create-CopyPatch. - * - * T2 SDE: misc/tools-source/getfiles.c + * + * Filename: src/tools-source/getfiles.c + * Copyright (C) 2013 The OpenSDE Project * Copyright (C) 2004 - 2006 The T2 SDE Project * Copyright (C) 1998 - 2003 Clifford Wolf - * + * * More information can be found in the files COPYING and README. - * + * * 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; version 2 of the License. A copy of the * GNU General Public License can be found in the file COPYING. - * --- T2-COPYRIGHT-NOTE-END --- + * --- SDE-COPYRIGHT-NOTE-END --- */ +#include #include #include #include @@ -23,7 +25,10 @@ int main(int argc, char ** argv) { char *fn, buf[512], *n; struct stat st; - if (argc > 1) chdir(argv[1]); + if (argc > 1 && chdir(argv[1]) < 0) { + fprintf(stderr, "getfiles: %s: %s.\n", argv[1], strerror(errno)); + return 1; + } while ( fgets(buf, 512, stdin) != NULL && (fn = strchr(buf, ' ')) != NULL ) { if ( (n = strchr(++fn, '\n')) != NULL ) *n = '\0';