aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Hawthorn <jhawthor@uvic.ca>2008-06-25 02:42:36 -0700
committerJohn Hawthorn <jhawthor@uvic.ca>2008-06-25 02:42:36 -0700
commit70fb2744602b95b865e19990bceebd5a86d54b85 (patch)
treeb3e6bfe99233d593df67514e3f2a19673081afaa /src
parentae22db5d707dd2728bbdf4d2f70d7d9285017024 (diff)
downloadmirror-meh-70fb2744602b95b865e19990bceebd5a86d54b85.tar.gz
mirror-meh-70fb2744602b95b865e19990bceebd5a86d54b85.tar.bz2
mirror-meh-70fb2744602b95b865e19990bceebd5a86d54b85.zip
cleanup
Diffstat (limited to 'src')
-rw-r--r--src/main.c44
1 files changed, 12 insertions, 32 deletions
diff --git a/src/main.c b/src/main.c
index c5ddd98..bb8c73f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -46,42 +46,20 @@ struct image *imgopen(FILE *f){
return NULL;
}
-struct imagenode{
- struct imagenode *next, *prev;
- char *filename;
-};
-
-struct imagenode *buildlist(int argc, char *argv[]){
- struct imagenode *head = NULL, *tail = NULL, *tmp;
- if(argc){
- while(argc--){
- tmp = malloc(sizeof(struct imagenode));
- if(!head)
- head = tail = tmp;
- tmp->filename = *argv++;
- tmp->prev = tail;
- tail->next = tmp;
- tail=tmp;
- }
- tail->next = head;
- head->prev = tail;
- return head;
- }else{
- fprintf(stderr, "No files to view\n");
- exit(1);
- }
-}
-
-struct imagenode *images;
+int imageslen;
+int imageidx;
+char **images;
const char *nextimage(){
- images = images->next;
- return images->filename;
+ if(++imageidx == imageslen)
+ imageidx = 0;
+ return images[imageidx];
}
const char *previmage(){
- images = images->prev;
- return images->filename;
+ if(--imageidx < 0)
+ imageidx = imageslen - 1;
+ return images[imageidx];
}
void run(){
@@ -207,7 +185,9 @@ int main(int argc, char *argv[]){
usage();
xinit();
- images = buildlist(argc - 1, &argv[1]);
+ images = &argv[1];
+ imageslen = argc-1;
+ imageidx = -1;
run();
return 0;