aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author"John Hawthorn ext:(%22) <jhawthor@uvic.ca>2008-12-26 23:04:23 -0800
committer"John Hawthorn ext:(%22) <jhawthor@uvic.ca>2008-12-26 23:04:23 -0800
commit66f3304bec026ead71e7f7992bef30e899518561 (patch)
tree08204d2a8c1829b6b935e1529274e71ff46e17cb
parenta902c98bd884e19619c5d366417c64ad517f60d7 (diff)
downloadmirror-meh-66f3304bec026ead71e7f7992bef30e899518561.tar.gz
mirror-meh-66f3304bec026ead71e7f7992bef30e899518561.tar.bz2
mirror-meh-66f3304bec026ead71e7f7992bef30e899518561.zip
added rudimentary `meh -list` support
-rw-r--r--src/main.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 872ec7a..b2ed1e9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -249,6 +249,24 @@ void run(){
}
}
+void readlist(FILE *f){
+ int lsize = 1;
+ imageslen = 0;
+ images = NULL;
+ while(!feof(f)){
+ images = realloc(images, lsize * sizeof(char *));
+ while(imageslen < lsize && !feof(f)){
+ char *tmp = malloc(512);
+ if(fgets(tmp, 512, f)){
+ tmp[strlen(tmp)-1] = '\0';
+ images[imageslen] = tmp;
+ imageslen++;
+ }
+ }
+ lsize *= 2;
+ }
+}
+
int main(int argc, char *argv[]){
if(argc < 2)
usage();
@@ -259,11 +277,16 @@ int main(int argc, char *argv[]){
mode = MODE_CTL;
exit(EXIT_FAILURE);
}else if(!strcmp(argv[1], "-list")){
- if(argc != 2)
- usage();
mode = MODE_LIST;
- printf("not implemented\n");
- exit(EXIT_FAILURE);
+ if(argc == 2){
+ readlist(stdin);
+ }else if(argc == 3){
+ FILE *f = fopen(argv[2], "r");
+ readlist(f);
+ fclose(f);
+ }else{
+ usage();
+ }
}else{
mode = MODE_NORM;
images = &argv[1];