dsys2

changeset 15:26e3e0359f5b tip

renamed dsys_demo to dsys
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 26 Jul 2016 23:16:26 +0300
parents 66d4fe7a8613
children
files src/dsys.c src/dsys.h src/dsys_impl.h
diffstat 3 files changed, 36 insertions(+), 36 deletions(-) [+]
line diff
     1.1 --- a/src/dsys.c	Tue Oct 18 09:46:49 2011 +0300
     1.2 +++ b/src/dsys.c	Tue Jul 26 23:16:26 2016 +0300
     1.3 @@ -7,7 +7,7 @@
     1.4  #include "dsys.h"
     1.5  #include "dsys_impl.h"
     1.6  
     1.7 -static int read_script(struct dsys_demo *demo, FILE *fp, const char *fname);
     1.8 +static int read_script(struct dsys *demo, FILE *fp, const char *fname);
     1.9  static char *strip_ws(char *buf);
    1.10  static void dbg_print_events(struct dsys_event *ev);
    1.11  
    1.12 @@ -19,10 +19,10 @@
    1.13  static struct dsys_event *merge_evlists(struct dsys_event *list1, struct dsys_event *list2);
    1.14  
    1.15  
    1.16 -struct dsys_demo *dsys_open(const char *fname)
    1.17 +struct dsys *dsys_open(const char *fname)
    1.18  {
    1.19  	FILE *fp;
    1.20 -	struct dsys_demo *demo;
    1.21 +	struct dsys *demo;
    1.22  
    1.23  	if(!(fp = fopen(fname, "r"))) {
    1.24  		fprintf(stderr, "failed to open demoscript: %s: %s\n", fname, strerror(errno));
    1.25 @@ -48,9 +48,9 @@
    1.26  	return demo;
    1.27  }
    1.28  
    1.29 -struct dsys_demo *dsys_open_stream(FILE *fp)
    1.30 +struct dsys *dsys_open_stream(FILE *fp)
    1.31  {
    1.32 -	struct dsys_demo *demo;
    1.33 +	struct dsys *demo;
    1.34  
    1.35  	if(!(demo = malloc(sizeof *demo))) {
    1.36  		perror("failed to allocate memory");
    1.37 @@ -68,7 +68,7 @@
    1.38  	return demo;
    1.39  }
    1.40  
    1.41 -void dsys_close(struct dsys_demo *demo)
    1.42 +void dsys_close(struct dsys *demo)
    1.43  {
    1.44  	while(demo->evlist) {
    1.45  		struct dsys_event *ev = demo->evlist;
    1.46 @@ -82,7 +82,7 @@
    1.47  
    1.48  #define SEP	" \t\n\r"
    1.49  
    1.50 -static int read_script(struct dsys_demo *demo, FILE *fp, const char *fname)
    1.51 +static int read_script(struct dsys *demo, FILE *fp, const char *fname)
    1.52  {
    1.53  	int nline = 0;
    1.54  	char buf[512], *line, *tok, *endp;
    1.55 @@ -192,7 +192,7 @@
    1.56  	}
    1.57  }
    1.58  
    1.59 -void dsys_update(struct dsys_demo *demo, demotime_t tm)
    1.60 +void dsys_update(struct dsys *demo, demotime_t tm)
    1.61  {
    1.62  	struct dsys_event *ev;
    1.63  
    1.64 @@ -249,7 +249,7 @@
    1.65  	}
    1.66  }
    1.67  
    1.68 -void dsys_start(struct dsys_demo *demo)
    1.69 +void dsys_start(struct dsys *demo)
    1.70  {
    1.71  	if(demo->running) {
    1.72  		return;
    1.73 @@ -265,7 +265,7 @@
    1.74  	demo->running = 1;
    1.75  }
    1.76  
    1.77 -void dsys_stop(struct dsys_demo *demo)
    1.78 +void dsys_stop(struct dsys *demo)
    1.79  {
    1.80  	if(!demo->running) {
    1.81  		return;
    1.82 @@ -275,29 +275,29 @@
    1.83  	demo->running = 0;
    1.84  }
    1.85  
    1.86 -int dsys_is_running(struct dsys_demo *demo)
    1.87 +int dsys_is_running(struct dsys *demo)
    1.88  {
    1.89  	return demo->running;
    1.90  }
    1.91  
    1.92  
    1.93 -demotime_t dsys_duration(struct dsys_demo *demo)
    1.94 +demotime_t dsys_duration(struct dsys *demo)
    1.95  {
    1.96  	return demo->duration;
    1.97  }
    1.98  
    1.99 -demotime_t dsys_time(struct dsys_demo *demo)
   1.100 +demotime_t dsys_time(struct dsys *demo)
   1.101  {
   1.102  	return demo->tm;
   1.103  }
   1.104  
   1.105 -float dsys_progress(struct dsys_demo *demo)
   1.106 +float dsys_progress(struct dsys *demo)
   1.107  {
   1.108  	return demo->tm / demo->duration;
   1.109  }
   1.110  
   1.111  /* seek without continuity */
   1.112 -void dsys_seek(struct dsys_demo *demo, demotime_t tm)
   1.113 +void dsys_seek(struct dsys *demo, demotime_t tm)
   1.114  {
   1.115  	struct dsys_event *ev;
   1.116  
   1.117 @@ -326,25 +326,25 @@
   1.118  	}
   1.119  }
   1.120  
   1.121 -void dsys_seek_norm(struct dsys_demo *demo, float t)
   1.122 +void dsys_seek_norm(struct dsys *demo, float t)
   1.123  {
   1.124  	dsys_seek(demo, t * demo->duration);
   1.125  }
   1.126  
   1.127  /* seek by accelerating time */
   1.128 -void dsys_warp(struct dsys_demo *demo, demotime_t tm)
   1.129 +void dsys_warp(struct dsys *demo, demotime_t tm)
   1.130  {
   1.131  	fprintf(stderr, "dsys_warp not implemented yet\n");
   1.132  }
   1.133  
   1.134 -void dsys_warp_norm(struct dsys_demo *demo, float t)
   1.135 +void dsys_warp_norm(struct dsys *demo, float t)
   1.136  {
   1.137  	dsys_warp(demo, t * demo->duration);
   1.138  }
   1.139  
   1.140  
   1.141  /* events */
   1.142 -struct dsys_event *dsys_event(struct dsys_demo *demo, const char *name)
   1.143 +struct dsys_event *dsys_event(struct dsys *demo, const char *name)
   1.144  {
   1.145  	struct dsys_event *iter = demo->evlist;
   1.146  
     2.1 --- a/src/dsys.h	Tue Oct 18 09:46:49 2011 +0300
     2.2 +++ b/src/dsys.h	Tue Jul 26 23:16:26 2016 +0300
     2.3 @@ -3,7 +3,7 @@
     2.4  
     2.5  #include <stdio.h>
     2.6  
     2.7 -struct dsys_demo;
     2.8 +struct dsys;
     2.9  struct dsys_event;
    2.10  
    2.11  typedef float demotime_t;
    2.12 @@ -17,33 +17,33 @@
    2.13  extern "C" {
    2.14  #endif
    2.15  
    2.16 -struct dsys_demo *dsys_open(const char *fname);
    2.17 -struct dsys_demo *dsys_open_stream(FILE *fp);
    2.18 -void dsys_close(struct dsys_demo *demo);
    2.19 +struct dsys *dsys_open(const char *fname);
    2.20 +struct dsys *dsys_open_stream(FILE *fp);
    2.21 +void dsys_close(struct dsys *demo);
    2.22  
    2.23 -void dsys_update(struct dsys_demo *demo, demotime_t tm);
    2.24 +void dsys_update(struct dsys *demo, demotime_t tm);
    2.25  
    2.26  
    2.27 -void dsys_start(struct dsys_demo *demo);
    2.28 -void dsys_stop(struct dsys_demo *demo);
    2.29 -int dsys_is_running(struct dsys_demo *demo);
    2.30 +void dsys_start(struct dsys *demo);
    2.31 +void dsys_stop(struct dsys *demo);
    2.32 +int dsys_is_running(struct dsys *demo);
    2.33  
    2.34  
    2.35 -demotime_t dsys_duration(struct dsys_demo *demo);
    2.36 -demotime_t dsys_time(struct dsys_demo *demo);
    2.37 -float dsys_progress(struct dsys_demo *demo);
    2.38 +demotime_t dsys_duration(struct dsys *demo);
    2.39 +demotime_t dsys_time(struct dsys *demo);
    2.40 +float dsys_progress(struct dsys *demo);
    2.41  
    2.42  /* seek without continuity */
    2.43 -void dsys_seek(struct dsys_demo *demo, demotime_t tm);
    2.44 -void dsys_seek_norm(struct dsys_demo *demo, float t);
    2.45 +void dsys_seek(struct dsys *demo, demotime_t tm);
    2.46 +void dsys_seek_norm(struct dsys *demo, float t);
    2.47  
    2.48  /* seek by accelerating time */
    2.49 -void dsys_warp(struct dsys_demo *demo, demotime_t tm);
    2.50 -void dsys_warp_norm(struct dsys_demo *demo, float t);
    2.51 +void dsys_warp(struct dsys *demo, demotime_t tm);
    2.52 +void dsys_warp_norm(struct dsys *demo, float t);
    2.53  
    2.54  
    2.55  /* events */
    2.56 -struct dsys_event *dsys_event(struct dsys_demo *demo, const char *name);
    2.57 +struct dsys_event *dsys_event(struct dsys *demo, const char *name);
    2.58  
    2.59  enum dsys_evtype dsys_event_type(struct dsys_event *ev);
    2.60  float dsys_event_value(struct dsys_event *ev);
     3.1 --- a/src/dsys_impl.h	Tue Oct 18 09:46:49 2011 +0300
     3.2 +++ b/src/dsys_impl.h	Tue Jul 26 23:16:26 2016 +0300
     3.3 @@ -3,7 +3,7 @@
     3.4  
     3.5  #include "dsys.h"
     3.6  
     3.7 -struct dsys_demo {
     3.8 +struct dsys {
     3.9  	demotime_t tm, src_tm, start_tm, stop_tm, duration;
    3.10  	demotime_t stoppage_tm;
    3.11