summaryrefslogtreecommitdiff
path: root/meme
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-12 21:23:44 -0300
committerWerner Almesberger <werner@almesberger.net>2014-09-12 21:23:44 -0300
commit6cea3edc58b963ad06ee226d6fbceef3a9640c6a (patch)
tree23c3377e7f3e1e78e7e56422796f8ac2613a17f7 /meme
parentae1f29befcb2f500128598f79101bcbd177ce2f2 (diff)
downloadmisc-6cea3edc58b963ad06ee226d6fbceef3a9640c6a.tar.gz
misc-6cea3edc58b963ad06ee226d6fbceef3a9640c6a.tar.bz2
misc-6cea3edc58b963ad06ee226d6fbceef3a9640c6a.zip
meme/stl.h, stl.c (stl_load): rename to stl_load_file; new stl_load loads by file name
Diffstat (limited to 'meme')
-rw-r--r--meme/main.c7
-rw-r--r--meme/stl.c16
-rw-r--r--meme/stl.h6
3 files changed, 26 insertions, 3 deletions
diff --git a/meme/main.c b/meme/main.c
index 3a70a56..175160b 100644
--- a/meme/main.c
+++ b/meme/main.c
@@ -55,7 +55,12 @@ int main(int argc, char **argv)
switch (argc) {
case 1:
time_start(&t_load);
- stl_load(stdin);
+ stl_load_file(stdin);
+ time_stop(&t_load);
+ break;
+ case 2:
+ time_start(&t_load);
+ stl_load(argv[1]);
time_stop(&t_load);
break;
default:
diff --git a/meme/stl.c b/meme/stl.c
index 084cac5..6e1f80e 100644
--- a/meme/stl.c
+++ b/meme/stl.c
@@ -34,7 +34,7 @@ enum state {
};
-void stl_load(FILE *file)
+void stl_load_file(FILE *file)
{
char buf[MAX_LINE+1];
enum state state = s_init;
@@ -104,3 +104,17 @@ void stl_load(FILE *file)
exit(1);
}
+
+
+void stl_load(const char *name)
+{
+ FILE *file;
+
+ file = fopen(name, "r");
+ if (!file) {
+ perror(name);
+ exit(1);
+ }
+ stl_load_file(file);
+ fclose(file);
+}
diff --git a/meme/stl.h b/meme/stl.h
index da90b92..e1db1c4 100644
--- a/meme/stl.h
+++ b/meme/stl.h
@@ -14,6 +14,10 @@
#ifndef STL_H
#define STL_H
-void stl_load(FILE *file);
+#include <stdio.h>
+
+
+void stl_load_file(FILE *file);
+void stl_load(const char *name);
#endif /* !STL_H */