rs

FTDI serial communication program
git clone git://git.2f30.org/rs
Log | Files | Refs | README | LICENSE

commit fcae73f44231a683aae43b94cc076593bf8f06b4
parent 165a6ab2e8aa0bf07a8f4329d334b733b77e407a
Author: sin <sin@2f30.org>
Date:   Fri, 15 Nov 2013 13:51:17 +0000

Remove useless files

Diffstat:
MMakefile | 5-----
Mutil.h | 5-----
Dutil/agetcwd.c | 18------------------
Dutil/apathmax.c | 25-------------------------
Dutil/dev.c | 46----------------------------------------------
Dutil/mkpath.c | 29-----------------------------
Dutil/recurse.c | 40----------------------------------------
7 files changed, 0 insertions(+), 168 deletions(-)

diff --git a/Makefile b/Makefile @@ -4,13 +4,8 @@ include config.mk .SUFFIXES: .c .o LIB = \ - util/agetcwd.o \ - util/apathmax.o \ - util/dev.o \ util/eprintf.o \ util/estrtol.o \ - util/mkpath.o \ - util/recurse.o \ util/strlcpy.o SRC = rs.c diff --git a/util.h b/util.h @@ -5,12 +5,7 @@ extern char *argv0; -char *agetcwd(void); -void apathmax(char **, long *); -int devtomajmin(const char *path, int *maj, int *min); -int devtype(const char *majmin); void enprintf(int, const char *, ...); void eprintf(const char *, ...); long estrtol(const char *, int); -void recurse(const char *, void (*)(const char *)); size_t strlcpy(char *dest, const char *src, size_t size); diff --git a/util/agetcwd.c b/util/agetcwd.c @@ -1,18 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <unistd.h> - -#include "../util.h" - -char * -agetcwd(void) -{ - char *buf; - long size; - - apathmax(&buf, &size); - if(!getcwd(buf, size)) - eprintf("getcwd:"); - - return buf; -} - diff --git a/util/apathmax.c b/util/apathmax.c @@ -1,25 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include "../util.h" - -void -apathmax(char **p, long *size) -{ - errno = 0; - - if((*size = pathconf("/", _PC_PATH_MAX)) == -1) { - if(errno == 0) { - *size = BUFSIZ; - } else { - eprintf("pathconf:"); - } - } - - if(!(*p = malloc(*size))) - eprintf("malloc:"); -} - diff --git a/util/dev.c b/util/dev.c @@ -1,46 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <limits.h> -#include <stdio.h> -#include "../util.h" - -/* Example `path' is /sys/devices/virtual/tty/tty0/dev */ -int -devtomajmin(const char *path, int *maj, int *min) -{ - char buf[BUFSIZ]; - int fd; - ssize_t n; - - fd = open(path, O_RDONLY); - if (fd < 0) - eprintf("open %s:", path); - n = read(fd, buf, sizeof(buf) - 1); - close(fd); - if (n < 0) - eprintf("%s: read error:", path); - if (!n) - return -1; - if (buf[n - 1] == '\n') - buf[n - 1] = '\0'; - buf[n] = '\0'; - sscanf(buf, "%d:%d", maj, min); - return 0; -} - -/* `majmin' format is maj:min */ -int -devtype(const char *majmin) -{ - char path[PATH_MAX]; - - snprintf(path, sizeof(path), "/sys/dev/block/%s", majmin); - if (!access(path, F_OK)) - return S_IFBLK; - snprintf(path, sizeof(path), "/sys/dev/char/%s", majmin); - if (!access(path, F_OK)) - return S_IFCHR; - return -1; -} diff --git a/util/mkpath.c b/util/mkpath.c @@ -1,29 +0,0 @@ -#include <sys/stat.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <limits.h> - -int -mkpath(const char *path, mode_t mode) -{ - char tmp[PATH_MAX]; - char *p = NULL; - size_t len; - - snprintf(tmp, sizeof(tmp),"%s",path); - len = strlen(tmp); - if(tmp[len - 1] == '/') - tmp[len - 1] = 0; - for(p = tmp + 1; *p; p++) - if(*p == '/') { - *p = 0; - if (mkdir(tmp, mode) < 0 && errno != EEXIST) - return -1; - *p = '/'; - } - if (mkdir(tmp, mode) < 0 && errno != EEXIST) - return -1; - return 0; -} - diff --git a/util/recurse.c b/util/recurse.c @@ -1,40 +0,0 @@ -/* See LICENSE file for copyright and license details. */ -#include <dirent.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/stat.h> - -#include "../util.h" - -void -recurse(const char *path, void (*fn)(const char *)) -{ - char *cwd; - struct dirent *d; - struct stat st; - DIR *dp; - - if(lstat(path, &st) == -1 || !S_ISDIR(st.st_mode)) { - return; - } else if(!(dp = opendir(path))) { - eprintf("opendir %s:", path); - } - - cwd = agetcwd(); - if(chdir(path) == -1) - eprintf("chdir %s:", path); - - while((d = readdir(dp))) { - if(strcmp(d->d_name, ".") && strcmp(d->d_name, "..")) - fn(d->d_name); - } - - closedir(dp); - if(chdir(cwd) == -1) - eprintf("chdir %s:", cwd); - - free(cwd); -} -