summaryrefslogtreecommitdiff
path: root/coreutils/libcoreutils
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-03-19 09:13:01 +0000
commitcad5364599eb5062d59e0c397ed638ddd61a8d5d (patch)
treea318d0f03aa076c74b576ea45dc543a5669e8e91 /coreutils/libcoreutils
parente01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff)
downloadbusybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2
busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip
Major coreutils update.
Diffstat (limited to 'coreutils/libcoreutils')
-rw-r--r--coreutils/libcoreutils/Makefile30
-rw-r--r--coreutils/libcoreutils/Makefile.in32
-rw-r--r--coreutils/libcoreutils/coreutils.h12
-rw-r--r--coreutils/libcoreutils/cp_mv_stat.c45
-rw-r--r--coreutils/libcoreutils/getopt_mk_fifo_nod.c45
-rw-r--r--coreutils/libcoreutils/xgetoptfile_sort_uniq.c38
6 files changed, 202 insertions, 0 deletions
diff --git a/coreutils/libcoreutils/Makefile b/coreutils/libcoreutils/Makefile
new file mode 100644
index 000000000..59ec24ed9
--- /dev/null
+++ b/coreutils/libcoreutils/Makefile
@@ -0,0 +1,30 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2002 Erik Andersen <andersee@debian.org>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19
20TOPDIR:= ../../
21LIBCOREUTILS_DIR:=./
22include $(TOPDIR).config
23include $(TOPDIR)Rules.mak
24include Makefile.in
25all: $(libraries-y)
26-include $(TOPDIR).depend
27
28clean:
29 rm -f *.o *.a $(AR_TARGET)
30
diff --git a/coreutils/libcoreutils/Makefile.in b/coreutils/libcoreutils/Makefile.in
new file mode 100644
index 000000000..47391dd49
--- /dev/null
+++ b/coreutils/libcoreutils/Makefile.in
@@ -0,0 +1,32 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999-2002 Erik Andersen <andersee@debian.org>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19
20LIBCOREUTILS_AR:=libcoreutils.a
21ifndef $(LIBCOREUTILS_DIR)
22LIBCOREUTILS_DIR:=$(TOPDIR)coreutils/libcoreutils/
23endif
24
25LIBCOREUTILS_SRC:= cp_mv_stat.c getopt_mk_fifo_nod.c xgetoptfile_sort_uniq.c
26
27LIBCOREUTILS_OBJS=$(patsubst %.c,$(LIBCOREUTILS_DIR)%.o, $(LIBCOREUTILS_SRC))
28
29libraries-y+=$(LIBCOREUTILS_DIR)$(LIBCOREUTILS_AR)
30
31$(LIBCOREUTILS_DIR)$(LIBCOREUTILS_AR): $(LIBCOREUTILS_OBJS)
32 $(AR) -ro $@ $(LIBCOREUTILS_OBJS)
diff --git a/coreutils/libcoreutils/coreutils.h b/coreutils/libcoreutils/coreutils.h
new file mode 100644
index 000000000..eabca8204
--- /dev/null
+++ b/coreutils/libcoreutils/coreutils.h
@@ -0,0 +1,12 @@
1#ifndef COREUTILS_H
2#define COREUTILS_H 1
3
4typedef int (*stat_func)(const char *fn, struct stat *ps);
5
6extern int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf);
7extern int cp_mv_stat(const char *fn, struct stat *fn_stat);
8
9extern mode_t getopt_mk_fifo_nod(int argc, char **argv);
10extern FILE *xgetoptfile_sort_uniq(char **argv, const char *mode);
11
12#endif
diff --git a/coreutils/libcoreutils/cp_mv_stat.c b/coreutils/libcoreutils/cp_mv_stat.c
new file mode 100644
index 000000000..5a70b0221
--- /dev/null
+++ b/coreutils/libcoreutils/cp_mv_stat.c
@@ -0,0 +1,45 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * coreutils utility routine
4 *
5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <errno.h>
24#include <sys/stat.h>
25#include "libbb.h"
26#include "coreutils.h"
27
28extern int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf)
29{
30 if (sf(fn, fn_stat) < 0) {
31 if (errno != ENOENT) {
32 bb_perror_msg("unable to stat `%s'", fn);
33 return -1;
34 }
35 return 0;
36 } else if (S_ISDIR(fn_stat->st_mode)) {
37 return 3;
38 }
39 return 1;
40}
41
42extern int cp_mv_stat(const char *fn, struct stat *fn_stat)
43{
44 return cp_mv_stat2(fn, fn_stat, stat);
45}
diff --git a/coreutils/libcoreutils/getopt_mk_fifo_nod.c b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
new file mode 100644
index 000000000..0872bdcf0
--- /dev/null
+++ b/coreutils/libcoreutils/getopt_mk_fifo_nod.c
@@ -0,0 +1,45 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * coreutils utility routine
4 *
5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <sys/types.h>
24#include <sys/stat.h>
25#include <unistd.h>
26#include "libbb.h"
27#include "coreutils.h"
28
29extern mode_t getopt_mk_fifo_nod(int argc, char **argv)
30{
31 mode_t mode = 0666;
32 int opt;
33
34 while ((opt = getopt(argc, argv, "m:")) > 0) {
35 if (opt == 'm') {
36 mode = 0666;
37 if (bb_parse_mode(optarg, &mode)) {
38 umask(0);
39 continue;
40 }
41 }
42 bb_show_usage();
43 }
44 return mode;
45}
diff --git a/coreutils/libcoreutils/xgetoptfile_sort_uniq.c b/coreutils/libcoreutils/xgetoptfile_sort_uniq.c
new file mode 100644
index 000000000..a63daf97b
--- /dev/null
+++ b/coreutils/libcoreutils/xgetoptfile_sort_uniq.c
@@ -0,0 +1,38 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * coreutils utility routine
4 *
5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <stdio.h>
24#include <unistd.h>
25#include "libbb.h"
26#include "coreutils.h"
27
28extern FILE *xgetoptfile_sort_uniq(char **argv, const char *mode)
29{
30 const char *n;
31
32 if ((n = *argv) != NULL) {
33 if ((*n != '-') || n[1]) {
34 return bb_xfopen(n, mode);
35 }
36 }
37 return (*mode == 'r') ? stdin : stdout;
38}