summaryrefslogtreecommitdiff
path: root/utility.c
diff options
context:
space:
mode:
authorPavel Roskin2000-07-17 20:18:42 +0000
committerPavel Roskin2000-07-17 20:18:42 +0000
commitcc8a66b113dbdf04082b6f7c9b0b58984d433028 (patch)
tree98490b8eadc4e44b46c073fa2d21de403a2b61d4 /utility.c
parent97562bd9d7fe18bdc4f63e6e80bdce980416a915 (diff)
downloadbusybox-cc8a66b113dbdf04082b6f7c9b0b58984d433028.zip
busybox-cc8a66b113dbdf04082b6f7c9b0b58984d433028.tar.gz
Moved functions used by "lsmod" from cat.c to utility.c
Adjusted to make lsmod and sh compilable as standalone apps. Comment fixes
Diffstat (limited to 'utility.c')
-rw-r--r--utility.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/utility.c b/utility.c
index c682bf0..5f890c0 100644
--- a/utility.c
+++ b/utility.c
@@ -483,7 +483,7 @@ const char *timeString(time_t timeVal)
return buf;
}
-#endif /* BB_TAR */
+#endif /* BB_TAR || BB_AR */
#if defined BB_TAR || defined BB_CP_MV || defined BB_AR
/*
@@ -511,10 +511,10 @@ int fullWrite(int fd, const char *buf, int len)
return total;
}
-#endif /* BB_TAR || BB_CP_MV */
+#endif /* BB_TAR || BB_CP_MV || BB_AR */
-#if defined BB_TAR || defined BB_TAIL || defined BB_AR
+#if defined BB_TAR || defined BB_TAIL || defined BB_AR || defined BB_SH
/*
* Read all of the supplied buffer from a file.
* This does multiple reads as necessary.
@@ -544,7 +544,7 @@ int fullRead(int fd, char *buf, int len)
return total;
}
-#endif /* BB_TAR || BB_TAIL */
+#endif /* BB_TAR || BB_TAIL || BB_AR || BB_SH */
#if defined (BB_CHMOD_CHOWN_CHGRP) \
@@ -1667,6 +1667,29 @@ extern char *get_line_from_file(FILE *file)
return linebuf;
}
+#if defined BB_CAT || defined BB_LSMOD
+extern void print_file(FILE *file)
+{
+ int c;
+
+ while ((c = getc(file)) != EOF)
+ putc(c, stdout);
+ fclose(file);
+ fflush(stdout);
+}
+
+extern int print_file_by_name(char *filename)
+{
+ FILE *file;
+ file = fopen(filename, "r");
+ if (file == NULL) {
+ return FALSE;
+ }
+ print_file(file);
+ return TRUE;
+}
+#endif /* BB_CAT || BB_LSMOD */
+
#if defined BB_ECHO || defined BB_TR
char process_escape_sequence(char **ptr)
{