# HG changeset patch # User John Tsiombikas # Date 1469564186 -10800 # Node ID 26e3e0359f5b3f2a33f03db2cadf518526c29b87 # Parent 66d4fe7a86137fe7851b2fbe9f5aa220585689b0 renamed dsys_demo to dsys diff -r 66d4fe7a8613 -r 26e3e0359f5b src/dsys.c --- a/src/dsys.c Tue Oct 18 09:46:49 2011 +0300 +++ b/src/dsys.c Tue Jul 26 23:16:26 2016 +0300 @@ -7,7 +7,7 @@ #include "dsys.h" #include "dsys_impl.h" -static int read_script(struct dsys_demo *demo, FILE *fp, const char *fname); +static int read_script(struct dsys *demo, FILE *fp, const char *fname); static char *strip_ws(char *buf); static void dbg_print_events(struct dsys_event *ev); @@ -19,10 +19,10 @@ static struct dsys_event *merge_evlists(struct dsys_event *list1, struct dsys_event *list2); -struct dsys_demo *dsys_open(const char *fname) +struct dsys *dsys_open(const char *fname) { FILE *fp; - struct dsys_demo *demo; + struct dsys *demo; if(!(fp = fopen(fname, "r"))) { fprintf(stderr, "failed to open demoscript: %s: %s\n", fname, strerror(errno)); @@ -48,9 +48,9 @@ return demo; } -struct dsys_demo *dsys_open_stream(FILE *fp) +struct dsys *dsys_open_stream(FILE *fp) { - struct dsys_demo *demo; + struct dsys *demo; if(!(demo = malloc(sizeof *demo))) { perror("failed to allocate memory"); @@ -68,7 +68,7 @@ return demo; } -void dsys_close(struct dsys_demo *demo) +void dsys_close(struct dsys *demo) { while(demo->evlist) { struct dsys_event *ev = demo->evlist; @@ -82,7 +82,7 @@ #define SEP " \t\n\r" -static int read_script(struct dsys_demo *demo, FILE *fp, const char *fname) +static int read_script(struct dsys *demo, FILE *fp, const char *fname) { int nline = 0; char buf[512], *line, *tok, *endp; @@ -192,7 +192,7 @@ } } -void dsys_update(struct dsys_demo *demo, demotime_t tm) +void dsys_update(struct dsys *demo, demotime_t tm) { struct dsys_event *ev; @@ -249,7 +249,7 @@ } } -void dsys_start(struct dsys_demo *demo) +void dsys_start(struct dsys *demo) { if(demo->running) { return; @@ -265,7 +265,7 @@ demo->running = 1; } -void dsys_stop(struct dsys_demo *demo) +void dsys_stop(struct dsys *demo) { if(!demo->running) { return; @@ -275,29 +275,29 @@ demo->running = 0; } -int dsys_is_running(struct dsys_demo *demo) +int dsys_is_running(struct dsys *demo) { return demo->running; } -demotime_t dsys_duration(struct dsys_demo *demo) +demotime_t dsys_duration(struct dsys *demo) { return demo->duration; } -demotime_t dsys_time(struct dsys_demo *demo) +demotime_t dsys_time(struct dsys *demo) { return demo->tm; } -float dsys_progress(struct dsys_demo *demo) +float dsys_progress(struct dsys *demo) { return demo->tm / demo->duration; } /* seek without continuity */ -void dsys_seek(struct dsys_demo *demo, demotime_t tm) +void dsys_seek(struct dsys *demo, demotime_t tm) { struct dsys_event *ev; @@ -326,25 +326,25 @@ } } -void dsys_seek_norm(struct dsys_demo *demo, float t) +void dsys_seek_norm(struct dsys *demo, float t) { dsys_seek(demo, t * demo->duration); } /* seek by accelerating time */ -void dsys_warp(struct dsys_demo *demo, demotime_t tm) +void dsys_warp(struct dsys *demo, demotime_t tm) { fprintf(stderr, "dsys_warp not implemented yet\n"); } -void dsys_warp_norm(struct dsys_demo *demo, float t) +void dsys_warp_norm(struct dsys *demo, float t) { dsys_warp(demo, t * demo->duration); } /* events */ -struct dsys_event *dsys_event(struct dsys_demo *demo, const char *name) +struct dsys_event *dsys_event(struct dsys *demo, const char *name) { struct dsys_event *iter = demo->evlist; diff -r 66d4fe7a8613 -r 26e3e0359f5b src/dsys.h --- a/src/dsys.h Tue Oct 18 09:46:49 2011 +0300 +++ b/src/dsys.h Tue Jul 26 23:16:26 2016 +0300 @@ -3,7 +3,7 @@ #include -struct dsys_demo; +struct dsys; struct dsys_event; typedef float demotime_t; @@ -17,33 +17,33 @@ extern "C" { #endif -struct dsys_demo *dsys_open(const char *fname); -struct dsys_demo *dsys_open_stream(FILE *fp); -void dsys_close(struct dsys_demo *demo); +struct dsys *dsys_open(const char *fname); +struct dsys *dsys_open_stream(FILE *fp); +void dsys_close(struct dsys *demo); -void dsys_update(struct dsys_demo *demo, demotime_t tm); +void dsys_update(struct dsys *demo, demotime_t tm); -void dsys_start(struct dsys_demo *demo); -void dsys_stop(struct dsys_demo *demo); -int dsys_is_running(struct dsys_demo *demo); +void dsys_start(struct dsys *demo); +void dsys_stop(struct dsys *demo); +int dsys_is_running(struct dsys *demo); -demotime_t dsys_duration(struct dsys_demo *demo); -demotime_t dsys_time(struct dsys_demo *demo); -float dsys_progress(struct dsys_demo *demo); +demotime_t dsys_duration(struct dsys *demo); +demotime_t dsys_time(struct dsys *demo); +float dsys_progress(struct dsys *demo); /* seek without continuity */ -void dsys_seek(struct dsys_demo *demo, demotime_t tm); -void dsys_seek_norm(struct dsys_demo *demo, float t); +void dsys_seek(struct dsys *demo, demotime_t tm); +void dsys_seek_norm(struct dsys *demo, float t); /* seek by accelerating time */ -void dsys_warp(struct dsys_demo *demo, demotime_t tm); -void dsys_warp_norm(struct dsys_demo *demo, float t); +void dsys_warp(struct dsys *demo, demotime_t tm); +void dsys_warp_norm(struct dsys *demo, float t); /* events */ -struct dsys_event *dsys_event(struct dsys_demo *demo, const char *name); +struct dsys_event *dsys_event(struct dsys *demo, const char *name); enum dsys_evtype dsys_event_type(struct dsys_event *ev); float dsys_event_value(struct dsys_event *ev); diff -r 66d4fe7a8613 -r 26e3e0359f5b src/dsys_impl.h --- a/src/dsys_impl.h Tue Oct 18 09:46:49 2011 +0300 +++ b/src/dsys_impl.h Tue Jul 26 23:16:26 2016 +0300 @@ -3,7 +3,7 @@ #include "dsys.h" -struct dsys_demo { +struct dsys { demotime_t tm, src_tm, start_tm, stop_tm, duration; demotime_t stoppage_tm;