diff options
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 |
commit | 66f3304bec026ead71e7f7992bef30e899518561 (patch) | |
tree | 08204d2a8c1829b6b935e1529274e71ff46e17cb | |
parent | a902c98bd884e19619c5d366417c64ad517f60d7 (diff) | |
download | mirror-meh-66f3304bec026ead71e7f7992bef30e899518561.tar.gz mirror-meh-66f3304bec026ead71e7f7992bef30e899518561.tar.bz2 mirror-meh-66f3304bec026ead71e7f7992bef30e899518561.zip |
added rudimentary `meh -list` support
-rw-r--r-- | src/main.c | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -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]; |