dsys2

diff src/dsys.c @ 15:26e3e0359f5b

renamed dsys_demo to dsys
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 26 Jul 2016 23:16:26 +0300
parents 6bab2c0b0e4b
children
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