summaryrefslogtreecommitdiff
path: root/libc/misc
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc')
-rw-r--r--libc/misc/Makefile2
-rw-r--r--libc/misc/mntent/.indent.pro33
-rw-r--r--libc/misc/mntent/Makefile44
-rw-r--r--libc/misc/mntent/mntent.c79
4 files changed, 157 insertions, 1 deletions
diff --git a/libc/misc/Makefile b/libc/misc/Makefile
index d839813fc..9907f2d99 100644
--- a/libc/misc/Makefile
+++ b/libc/misc/Makefile
@@ -21,7 +21,7 @@
# respective copyright holders.
-DIRS = assert crypt fnmatch glob internals lsearch syslog regex shm time
+DIRS = assert crypt fnmatch glob internals lsearch mntent syslog regex shm time
ifeq ($(USE_CTYPE_C_FUNCTIONS),true)
DIRS+=ctype
diff --git a/libc/misc/mntent/.indent.pro b/libc/misc/mntent/.indent.pro
new file mode 100644
index 000000000..492ecf1c7
--- /dev/null
+++ b/libc/misc/mntent/.indent.pro
@@ -0,0 +1,33 @@
+--blank-lines-after-declarations
+--blank-lines-after-procedures
+--break-before-boolean-operator
+--no-blank-lines-after-commas
+--braces-on-if-line
+--braces-on-struct-decl-line
+--comment-indentation25
+--declaration-comment-column25
+--no-comment-delimiters-on-blank-lines
+--cuddle-else
+--continuation-indentation4
+--case-indentation0
+--else-endif-column33
+--space-after-cast
+--line-comments-indentation0
+--declaration-indentation1
+--dont-format-first-column-comments
+--dont-format-comments
+--honour-newlines
+--indent-level4
+/* changed from 0 to 4 */
+--parameter-indentation4
+--line-length78 /* changed from 75 */
+--continue-at-parentheses
+--no-space-after-function-call-names
+--dont-break-procedure-type
+--dont-star-comments
+--leave-optional-blank-lines
+--dont-space-special-semicolon
+--tab-size4
+/* additions by Mark */
+--case-brace-indentation0
+--leave-preprocessor-space
diff --git a/libc/misc/mntent/Makefile b/libc/misc/mntent/Makefile
new file mode 100644
index 000000000..4c60ac1e7
--- /dev/null
+++ b/libc/misc/mntent/Makefile
@@ -0,0 +1,44 @@
+# Makefile for uCLibc
+#
+# Copyright (C) 2000 by Lineo, inc.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Library 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
+#
+# Derived in part from the Linux-8086 C library, the GNU C Library, and several
+# other sundry sources. Files within this library are copyright by their
+# respective copyright holders.
+
+TOPDIR=../../
+include $(TOPDIR)Rules.mak
+LIBC=$(TOPDIR)libc.a
+
+CSRC=mntent.c
+COBJS=$(patsubst %.c,%.o, $(CSRC))
+OBJS=$(COBJS)
+
+all: $(OBJS) $(LIBC)
+
+$(LIBC): ar-target
+
+ar-target: $(OBJS)
+ $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
+
+$(COBJS):
+ $(CC) $(CFLAGS) $< -c $*.c -o $*.o
+ $(STRIPTOOL) -x -R .note -R .comment $*.o
+
+clean:
+ rm -f *.[oa] *~ core
+
diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c
new file mode 100644
index 000000000..2bdd3c7a6
--- /dev/null
+++ b/libc/misc/mntent/mntent.c
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <mntent.h>
+
+
+
+struct mntent *getmntent(FILE * filep)
+{
+ char *cp, *sep = " \t\n";
+ static char buff[MNTMAXSTR];
+ static struct mntent mnt;
+
+ /* Loop on the file, skipping comment lines. - FvK 03/07/93 */
+ while ((cp = fgets(buff, sizeof buff, filep)) != NULL) {
+ if (buff[0] == '#' || buff[0] == '\n')
+ continue;
+ break;
+ }
+
+ /* At the EOF, the buffer should be unchanged. We should
+ * check the return value from fgets ().
+ */
+ if (cp == NULL)
+ return NULL;
+
+ mnt.mnt_fsname = strtok(buff, sep);
+ if (mnt.mnt_fsname == NULL)
+ return NULL;
+
+ mnt.mnt_dir = strtok(NULL, sep);
+ if (mnt.mnt_dir == NULL)
+ return NULL;
+
+ mnt.mnt_type = strtok(NULL, sep);
+ if (mnt.mnt_type == NULL)
+ return NULL;
+
+ mnt.mnt_opts = strtok(NULL, sep);
+ if (mnt.mnt_opts == NULL)
+ mnt.mnt_opts = "";
+
+ cp = strtok(NULL, sep);
+ mnt.mnt_freq = (cp != NULL) ? atoi(cp) : 0;
+
+ cp = strtok(NULL, sep);
+ mnt.mnt_passno = (cp != NULL) ? atoi(cp) : 0;
+
+ return &mnt;
+}
+
+int addmntent(FILE * filep, const struct mntent *mnt)
+{
+ if (fseek(filep, 0, SEEK_END) < 0)
+ return 1;
+
+ if (fprintf (filep, "%s %s %s %s %d %d\n", mnt->mnt_fsname, mnt->mnt_dir,
+ mnt->mnt_type, mnt->mnt_opts, mnt->mnt_freq, mnt->mnt_passno) < 1)
+ return 1;
+
+ return 0;
+}
+
+char *hasmntopt(const struct mntent *mnt, const char *opt)
+{
+ return strstr(mnt->mnt_opts, opt);
+}
+
+FILE *setmntent(const char *name, const char *mode)
+{
+ return fopen(name, mode);
+}
+
+int endmntent(FILE * filep)
+{
+ if (filep != NULL)
+ fclose(filep);
+ return 1;
+}