Mercurial > bday
comparison bdengine.c @ 3:dc2f94280b01
new Makefile; removed MinWarn and MaxWarn; adjusted manpage
author | meillo@marmaro.de |
---|---|
date | Mon, 17 Dec 2007 11:28:40 +0100 |
parents | 9ec037775c38 |
children | 5326c222cd4e |
comparison
equal
deleted
inserted
replaced
2:9ec037775c38 | 3:dc2f94280b01 |
---|---|
80 xmalloc/xrealloc functions, and fatal exit function | 80 xmalloc/xrealloc functions, and fatal exit function |
81 Note: the x* functions are lifted straight from the GNU libc info docs | 81 Note: the x* functions are lifted straight from the GNU libc info docs |
82 $Id: xmalloc.c,v 1.2 1999/01/16 17:08:59 andy Exp $ | 82 $Id: xmalloc.c,v 1.2 1999/01/16 17:08:59 andy Exp $ |
83 */ | 83 */ |
84 | 84 |
85 void *xmalloc (size_t size) { | 85 void* xmalloc (size_t size) { |
86 register void *value = malloc (size); | 86 register void* value = malloc (size); |
87 if (value == 0) { | 87 if (value == 0) { |
88 fprintf(stderr, "virtual memory exhausted\n"); | 88 fprintf(stderr, "virtual memory exhausted\n"); |
89 exit(1); | 89 exit(1); |
90 } | 90 } |
91 return value; | 91 return value; |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 void *xrealloc (void *ptr, size_t size) { | 95 void* xrealloc (void* ptr, size_t size) { |
96 register void *value = realloc (ptr, size); | 96 register void* value = realloc (ptr, size); |
97 if (value == 0) { | 97 if (value == 0) { |
98 fprintf(stderr, "virtual memory exhausted\n"); | 98 fprintf(stderr, "virtual memory exhausted\n"); |
99 exit(1); | 99 exit(1); |
100 } | 100 } |
101 return value; | 101 return value; |
110 | 110 |
111 int skptok(int j, char *ptr); | 111 int skptok(int j, char *ptr); |
112 int evcmp(const void *e1, const void *e2); | 112 int evcmp(const void *e1, const void *e2); |
113 char *deffname(void); | 113 char *deffname(void); |
114 | 114 |
115 /*struct event *dir_include(char *dir, char *parm);*/ | |
116 | 115 |
117 /* ========== Global variables */ | 116 /* ========== Global variables */ |
118 | 117 |
119 struct date today; | 118 struct date today; |
120 int iDWarn = DEF_WARN; | 119 int iDWarn = DEF_WARN; |
121 int iMaxWarn = MAX_WARN; | |
122 int iMinWarn = MIN_WARN; | |
123 | 120 |
124 const unsigned MLENDAT[]={31,-1,31,30,31,30,31,31,30,31,30,31}; | 121 const unsigned MLENDAT[]={31,-1,31,30,31,30,31,31,30,31,30,31}; |
125 | 122 |
126 const struct _ftable FTABLE[] = { | 123 const struct _ftable FTABLE[] = { |
127 {"bir",F_TBIRTHDAY}, | 124 {"bir",F_TBIRTHDAY}, |
288 size = 128; | 285 size = 128; |
289 | 286 |
290 if (evl[i].warn == -1 && delta(&(evl[i].date))==0) { | 287 if (evl[i].warn == -1 && delta(&(evl[i].date))==0) { |
291 append(buf, evl[i].text); | 288 append(buf, evl[i].text); |
292 } else if (evl[i].enddate.day == 0) { | 289 } else if (evl[i].enddate.day == 0) { |
293 if (delta(&(evl[i].date)) <= warnperiod(evl[i])) { | 290 if (delta(&(evl[i].date)) <= evl[i].warn) { |
294 append(buf, evl[i].text); | 291 append(buf, evl[i].text); |
295 append(buf, " "); | 292 append(buf, " "); |
296 tmp = tdelta(&(evl[i].date)); | 293 tmp = tdelta(&(evl[i].date)); |
297 append(buf, tmp); | 294 append(buf, tmp); |
298 free(tmp); | 295 free(tmp); |
299 } | 296 } |
300 } else { | 297 } else { |
301 if (delta(&(evl[i].date)) <= warnperiod(evl[i])) { | 298 if (delta(&(evl[i].date)) <= evl[i].warn) { |
302 append(buf, evl[i].text); | 299 append(buf, evl[i].text); |
303 append(buf, " for "); | 300 append(buf, " for "); |
304 /* +1 because, if the difference between two dates is one day, | 301 /* +1 because, if the difference between two dates is one day, |
305 then the length of an event on those days is two days */ | 302 then the length of an event on those days is two days */ |
306 j = ddiff(&(evl[i].date),&(evl[i].enddate)) + 1; | 303 j = ddiff(&(evl[i].date),&(evl[i].enddate)) + 1; |
308 append(buf, tmp); | 305 append(buf, tmp); |
309 free(tmp); | 306 free(tmp); |
310 append(buf, " "); | 307 append(buf, " "); |
311 tmp = tdelta(&(evl[i].date)); | 308 tmp = tdelta(&(evl[i].date)); |
312 append(buf, tmp); | 309 append(buf, tmp); |
313 } else if (delta(&(evl[i].enddate)) <= warnperiod(evl[i])) { | 310 } else if (delta(&(evl[i].enddate)) <= evl[i].warn) { |
314 append(buf, evl[i].text); | 311 append(buf, evl[i].text); |
315 append(buf, " "); | 312 append(buf, " "); |
316 j = delta(&(evl[i].enddate)); | 313 j = delta(&(evl[i].enddate)); |
317 if (j) { | 314 if (j) { |
318 append(buf, "for "); | 315 append(buf, "for "); |