cvs: /php3/functions php3_mcal.c php3_mcal.h

From: Date: Tue, 07 Sep 1999 20:43:15 +0000
Subject: cvs: /php3/functions php3_mcal.c php3_mcal.h
Groups: php.dev 
Request: Send a blank email to php-dev+get-10677@lists.php.net to get a copy of this message
musone Tue Sep 7 16:43:15 1999 EDT Modified files: /php3/functions php3_mcal.c php3_mcal.h Log: changed to use PHP_FE as per Andrey Index: php3/functions/php3_mcal.c diff -u php3/functions/php3_mcal.c:1.17 php3/functions/php3_mcal.c:1.18 --- php3/functions/php3_mcal.c:1.17 Tue Sep 7 15:54:40 1999 +++ php3/functions/php3_mcal.c Tue Sep 7 16:43:15 1999 @@ -63,10 +63,8 @@ typedef struct php3_mcal_le_struct { CALSTREAM *mcal_stream; long public; - char *category,*title,*description; - long alarm,start_year,start_month,start_mday,start_hour,start_min,start_sec,start_has_date,start_has_time; - long end_year,end_month,end_mday,end_hour,end_min,end_sec,end_has_date,end_has_time; - long flags,class; + CALEVENT *event; + long flags; } pils; @@ -84,33 +82,33 @@ */ function_entry mcal_functions[] = { - {"mcal_open", php3_mcal_open, NULL}, - {"mcal_popen", php3_mcal_popen, NULL}, - {"mcal_reopen", php3_mcal_reopen, NULL}, - {"mcal_fetch_event", php3_mcal_fetch_event, NULL}, - {"mcal_list_events", php3_mcal_list_events, NULL}, - {"mcal_list_alarms", php3_mcal_list_alarms, NULL}, - {"mcal_create_calendar", php3_mcal_create_calendar, NULL}, - {"mcal_rename_calendar", php3_mcal_rename_calendar, NULL}, - {"mcal_delete_calendar", php3_mcal_delete_calendar, NULL}, - {"mcal_delete_event", php3_mcal_delete_event, NULL}, - {"mcal_store_event", php3_mcal_store_event, NULL}, - {"mcal_snooze", php3_mcal_snooze, NULL}, - {"mcal_event_set_category",php3_mcal_event_add_category,NULL}, - {"mcal_event_set_title",php3_mcal_event_add_title,NULL}, - {"mcal_event_set_description",php3_mcal_event_add_description,NULL}, - {"mcal_event_set_start",php3_mcal_event_add_start,NULL}, - {"mcal_event_set_end",php3_mcal_event_add_end,NULL}, - {"mcal_event_set_alarm",php3_mcal_event_add_alarm,NULL}, - {"mcal_event_set_class",php3_mcal_event_add_class,NULL}, - {"mcal_is_leap_year",php3_mcal_is_leap_year,NULL}, - {"mcal_days_in_month",php3_mcal_days_in_month,NULL}, - {"mcal_date_valid",php3_mcal_date_valid,NULL}, - {"mcal_time_valid",php3_mcal_time_valid,NULL}, - {"mcal_day_of_week",php3_mcal_day_of_week,NULL}, - {"mcal_day_of_year",php3_mcal_day_of_year,NULL}, - {"mcal_date_compare",php3_mcal_date_compare,NULL}, - {"mcal_event_init",php3_mcal_init_event,NULL}, +PHP_FE(mcal_open,NULL) +PHP_FE(mcal_popen,NULL) +PHP_FE(mcal_reopen,NULL) +PHP_FE(mcal_fetch_event,NULL) +PHP_FE(mcal_list_events,NULL) +PHP_FE(mcal_list_alarms,NULL) +PHP_FE(mcal_create_calendar,NULL) +PHP_FE(mcal_rename_calendar,NULL) +PHP_FE(mcal_delete_calendar,NULL) +PHP_FE(mcal_delete_event,NULL) +PHP_FE(mcal_store_event,NULL) +PHP_FE(mcal_snooze,NULL) +PHP_FE(mcal_event_set_category,NULL) +PHP_FE(mcal_event_set_title,NULL) +PHP_FE(mcal_event_set_description,NULL) +PHP_FE(mcal_event_set_start,NULL) +PHP_FE(mcal_event_set_end,NULL) +PHP_FE(mcal_event_set_alarm,NULL) +PHP_FE(mcal_event_set_class,NULL) +PHP_FE(mcal_is_leap_year,NULL) +PHP_FE(mcal_days_in_month,NULL) +PHP_FE(mcal_date_valid,NULL) +PHP_FE(mcal_time_valid,NULL) +PHP_FE(mcal_day_of_week,NULL) +PHP_FE(mcal_day_of_year,NULL) +PHP_FE(mcal_date_compare,NULL) +PHP_FE(mcal_event_init,NULL) {NULL, NULL, NULL} }; @@ -200,10 +198,7 @@ mcal_le_struct = emalloc(sizeof(pils)); mcal_le_struct->mcal_stream = mcal_stream; - mcal_le_struct->category=NULL; - mcal_le_struct->title=NULL; - mcal_le_struct->description=NULL; - php3_event_init(mcal_le_struct); + mcal_le_struct->event=calevent_new(); ind = php3_list_insert(mcal_le_struct, le_mcal); RETURN_LONG(ind); @@ -859,27 +854,9 @@ } else { - myevent->description=strdup(mcal_le_struct->description); - myevent->title=strdup(mcal_le_struct->title); - myevent->category=strdup(mcal_le_struct->category); - myevent->alarm=mcal_le_struct->alarm; - myevent->public=mcal_le_struct->class; - myevent->start.year=mcal_le_struct->start_year; - myevent->start.mon=mcal_le_struct->start_month; - myevent->start.mday=mcal_le_struct->start_mday; - myevent->start.hour=mcal_le_struct->start_hour; - myevent->start.min=mcal_le_struct->start_min; - myevent->start.sec=mcal_le_struct->start_sec; - myevent->start.has_date=true; - myevent->end.year=mcal_le_struct->end_year; - myevent->end.mon=mcal_le_struct->end_month; - myevent->end.mday=mcal_le_struct->end_mday; - myevent->end.hour=mcal_le_struct->end_hour; - myevent->end.min=mcal_le_struct->end_min; - myevent->end.sec=mcal_le_struct->start_sec; - myevent->end.has_date=true; + myevent=mcal_le_struct->event; } - cal_append(mcal_le_struct->mcal_stream,"INBOX",&uid,myevent); + cal_append(mcal_le_struct->mcal_stream,"INBOX",&uid,myevent); calevent_free(myevent); RETURN_LONG(uid); } @@ -926,9 +903,9 @@ /* }}} */ -/* {{{ proto string mcal_event_add_category(int stream_id, string category) +/* {{{ proto string mcal_event_set_category(int stream_id, string category) attach a category to an event*/ -void php3_mcal_event_add_category(INTERNAL_FUNCTION_PARAMETERS) +void php3_mcal_event_set_category(INTERNAL_FUNCTION_PARAMETERS) { pval *streamind,*category; int ind, ind_type; @@ -958,13 +935,13 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } - mcal_le_struct->category=estrdup(category->value.str.val); + mcal_le_struct->event->category=strdup(category->value.str.val); } /* }}} */ -/* {{{ proto string mcal_event_add_title(int stream_id, string title) +/* {{{ proto string mcal_event_set_title(int stream_id, string title) attach a title to an event*/ -void php3_mcal_event_add_title(INTERNAL_FUNCTION_PARAMETERS) +void php3_mcal_event_set_title(INTERNAL_FUNCTION_PARAMETERS) { pval *streamind,*title; int ind, ind_type; @@ -994,13 +971,13 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } - mcal_le_struct->title=estrdup(title->value.str.val); + mcal_le_struct->event->title=strdup(title->value.str.val); } /* }}} */ -/* {{{ proto string mcal_event_add_description(int stream_id, string description) +/* {{{ proto string mcal_event_set_description(int stream_id, string description) attach a description to an event*/ -void php3_mcal_event_add_description(INTERNAL_FUNCTION_PARAMETERS) +void php3_mcal_event_set_description(INTERNAL_FUNCTION_PARAMETERS) { pval *streamind,*description; int ind, ind_type; @@ -1030,19 +1007,19 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } - mcal_le_struct->description=estrdup(description->value.str.val); + mcal_le_struct->event->description=strdup(description->value.str.val); } /* }}} */ -/* {{{ proto string mcal_event_add_start(int stream_id, int year,int month, int day, [[[int hour],int min],int sec]) +/* {{{ proto string mcal_event_set_start(int stream_id, int year,int month, int day, [[[int hour],int min],int sec]) attach a start datetime to an event*/ -void php3_mcal_event_add_start(INTERNAL_FUNCTION_PARAMETERS) +void php3_mcal_event_set_start(INTERNAL_FUNCTION_PARAMETERS) { pval *streamind,*year,*month,*date,*hour,*min,*sec; int ind, ind_type; unsigned long i; char *t; - int mcal_folders=0; + int mcal_folders=0,myhour=0,mymin=0,mysec=0; unsigned int msgno; pils *mcal_le_struct; pval *pvalue,*temppvalue; @@ -1071,25 +1048,27 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } - mcal_le_struct->start_year=year->value.lval; - mcal_le_struct->start_month=month->value.lval; - mcal_le_struct->start_mday=date->value.lval; - if(myargc > 4) mcal_le_struct->start_hour=hour->value.lval; - if(myargc > 4) mcal_le_struct->start_has_time=1; - if(myargc > 5) mcal_le_struct->start_min=min->value.lval; - if(myargc > 6) mcal_le_struct->start_sec=sec->value.lval; + + + dt_setdate(&(mcal_le_struct->event->start),year->value.lval,month->value.lval,date->value.lval); + + if(myargc > 4) myhour=hour->value.lval; + if(myargc > 5) mymin=min->value.lval; + if(myargc > 6) mysec=sec->value.lval; + if(myargc >4) dt_settime(&(mcal_le_struct->event->start),year->value.lval,month->value.lval,date->value.lval); + } /* }}} */ -/* {{{ proto string mcal_event_add_end(int stream_id, int year,int month, int day, [[[int hour],int min],int sec]) +/* {{{ proto string mcal_event_set_end(int stream_id, int year,int month, int day, [[[int hour],int min],int sec]) attach an end datetime to an event*/ -void php3_mcal_event_add_end(INTERNAL_FUNCTION_PARAMETERS) +void php3_mcal_event_set_end(INTERNAL_FUNCTION_PARAMETERS) { pval *streamind,*year,*month,*date,*hour,*min,*sec; int ind, ind_type; unsigned long i; char *t; - int mcal_folders=0; + int mcal_folders=0,myhour,mymin,mysec; unsigned int msgno; pils *mcal_le_struct; pval *pvalue,*temppvalue; @@ -1118,19 +1097,20 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } - mcal_le_struct->end_year=year->value.lval; - mcal_le_struct->end_month=month->value.lval; - mcal_le_struct->end_mday=date->value.lval; - if(myargc > 4) mcal_le_struct->end_hour=hour->value.lval; - if(myargc > 4) mcal_le_struct->end_has_time=1; - if(myargc > 5) mcal_le_struct->end_min=min->value.lval; - if(myargc > 6) mcal_le_struct->end_sec=sec->value.lval; + + + dt_setdate(&(mcal_le_struct->event->end),year->value.lval,month->value.lval,date->value.lval); + + if(myargc > 4) myhour=hour->value.lval; + if(myargc > 5) mymin=min->value.lval; + if(myargc > 6) mysec=sec->value.lval; + if(myargc >4) dt_settime(&(mcal_le_struct->event->end),year->value.lval,month->value.lval,date->value.lval); } /* }}} */ -/* {{{ proto int mcal_event_add_alarm(int stream_id, int alarm) +/* {{{ proto int mcal_event_set_alarm(int stream_id, int alarm) add an alarm to the streams global event */ -void php3_mcal_event_add_alarm(INTERNAL_FUNCTION_PARAMETERS) +void php3_mcal_event_set_alarm(INTERNAL_FUNCTION_PARAMETERS) { pval *streamind,*alarm; int ind, ind_type; @@ -1160,13 +1140,13 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } - mcal_le_struct->alarm=alarm->value.lval; + mcal_le_struct->event->alarm=alarm->value.lval; } /* }}} */ -/* {{{ proto int mcal_event_add_alarm(int stream_id) +/* {{{ proto int mcal_event_init(int stream_id) initialize a streams global event */ -void php3_mcal_init_event(INTERNAL_FUNCTION_PARAMETERS) +void php3_mcal_event_init(INTERNAL_FUNCTION_PARAMETERS) { pval *streamind; int ind, ind_type; @@ -1201,36 +1181,14 @@ php3_event_init(struct php3_mcal_le_struct *mystruct) { - mystruct->class=1; - if(mystruct->category) efree(mystruct->category); - if(mystruct->title) efree(mystruct->title); - if(mystruct->description) efree(mystruct->description); - mystruct->alarm=0; - mystruct->start_year=0; - mystruct->start_month=0; - mystruct->start_mday=0; - mystruct->start_hour=0; - mystruct->start_min=0; - mystruct->start_sec=0; - mystruct->start_has_time=0; - - mystruct->end_year=0; - mystruct->end_month=0; - mystruct->end_mday=0; - mystruct->end_hour=0; - mystruct->end_min=0; - mystruct->end_sec=0; - mystruct->end_has_time=0; - - mystruct->category=NULL; - mystruct->title=NULL; - mystruct->description=NULL; + calevent_free(mystruct->event); + mystruct->event=calevent_new(); } -/* {{{ proto int mcal_event_add_class(int stream_id, int class) +/* {{{ proto int mcal_event_set_class(int stream_id, int class) add an class to the streams global event */ -void php3_mcal_event_add_class(INTERNAL_FUNCTION_PARAMETERS) +void php3_mcal_event_set_class(INTERNAL_FUNCTION_PARAMETERS) { pval *streamind,*class; int ind, ind_type; @@ -1260,7 +1218,7 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } - mcal_le_struct->class=class->value.lval; + mcal_le_struct->event->public=class->value.lval; } /* }}} */ Index: php3/functions/php3_mcal.h diff -u php3/functions/php3_mcal.h:1.6 php3/functions/php3_mcal.h:1.7 --- php3/functions/php3_mcal.h:1.6 Tue Sep 7 15:54:40 1999 +++ php3/functions/php3_mcal.h Tue Sep 7 16:43:15 1999 @@ -1,4 +1,4 @@ -/* $Id: php3_mcal.h,v 1.6 1999/09/07 19:54:40 musone Exp $ */ +/* $Id: php3_mcal.h,v 1.7 1999/09/07 20:43:15 musone Exp $ */ #ifndef _INCLUDED_MCAL_H #define _INCLUDED_MCAL_H @@ -42,13 +42,13 @@ void php3_mcal_delete_event(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_snooze(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_list_alarms(INTERNAL_FUNCTION_PARAMETERS); -void php3_mcal_event_add_category(INTERNAL_FUNCTION_PARAMETERS); -void php3_mcal_event_add_title(INTERNAL_FUNCTION_PARAMETERS); -void php3_mcal_event_add_description(INTERNAL_FUNCTION_PARAMETERS); -void php3_mcal_event_add_start(INTERNAL_FUNCTION_PARAMETERS); -void php3_mcal_event_add_end(INTERNAL_FUNCTION_PARAMETERS); -void php3_mcal_event_add_alarm(INTERNAL_FUNCTION_PARAMETERS); -void php3_mcal_event_add_class(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_category(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_title(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_description(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_start(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_end(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_alarm(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_set_class(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_is_leap_year(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_days_in_month(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_date_valid(INTERNAL_FUNCTION_PARAMETERS); @@ -56,7 +56,7 @@ void php3_mcal_day_of_week(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_day_of_year(INTERNAL_FUNCTION_PARAMETERS); void php3_mcal_date_compare(INTERNAL_FUNCTION_PARAMETERS); -void php3_mcal_init_event(INTERNAL_FUNCTION_PARAMETERS); +void php3_mcal_event_init(INTERNAL_FUNCTION_PARAMETERS);

« previous php.dev (#10677) next »