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

From: Date: Mon, 13 Sep 1999 15:03:13 +0000
Subject: cvs: /php3/functions php3_mcal.c php3_mcal.h
Groups: php.dev 
Request: Send a blank email to php-dev+get-10851@lists.php.net to get a copy of this message
musone Mon Sep 13 11:03:13 1999 EDT Modified files: /php3/functions php3_mcal.c php3_mcal.h Log: lots of cleaups and core changes to the interface Index: php3/functions/php3_mcal.c diff -u php3/functions/php3_mcal.c:1.24 php3/functions/php3_mcal.c:1.25 --- php3/functions/php3_mcal.c:1.24 Wed Sep 8 17:17:27 1999 +++ php3/functions/php3_mcal.c Mon Sep 13 11:03:12 1999 @@ -35,7 +35,9 @@ #endif #include "php.h" +#ifndef ZEND_VERSION #include "internal_functions.h" +#endif #if COMPILE_DL #include "dl/phpdl.h" @@ -48,7 +50,9 @@ #include <ctype.h> #include <signal.h> #include <stdarg.h> +#ifndef ZEND_VERSION #include "php3_list.h" +#endif #include "mcal.h" #include "php3_mcal.h" #include "modules.h" @@ -119,12 +123,14 @@ PHP_FE(mcal_fetch_current_stream_event,NULL) {NULL, NULL, NULL} }; - +#ifdef ZEND_VERSION php3_module_entry php3_mcal_module_entry = { - "mcal", mcal_functions, PHP_MINIT_FUNCTION, NULL, NULL, NULL, PHP_MINFO_FUNCTION, 0, 0, 0, NULL + CALVER, mcal_functions, PHP_MINIT(mcal), NULL, NULL, NULL, PHP_MINFO(mcal), 0, 0, 0, NULL }; - +#else +php3_module_entry php3_mcal_module_entry = {"mcal", mcal_functions, PHP_MINIT_FUNCTION, NULL, NULL, NULL, PHP_MINFO_FUNCTION, 0, 0, 0, NULL}; +#endif #if COMPILE_DL DLEXPORT php3_module_entry *get_module(void) { return &php3_mcal_module_entry; } @@ -148,7 +154,11 @@ } +#ifdef ZEND_VERSION +PHP_MINFO_FUNCTION(mcal) +#else void PHP_MINFO_FUNCTION(void) +#endif { php3_printf("Mcal Support enabled<br>"); php3_printf("<table>"); @@ -157,7 +167,11 @@ php3_printf("</tr></table>"); } +#ifdef ZEND_VERSION +PHP_MINIT_FUNCTION(mcal) +#else int PHP_MINIT_FUNCTION(INIT_FUNC_ARGS) +#endif { le_mcal = register_list_destructors(cal_close_it,NULL); @@ -210,7 +224,18 @@ static int add_assoc_object(pval *arg, char *key, pval tmp) { +#ifdef ZEND_VERSION + HashTable *symtable; + + if (arg->type == IS_OBJECT) { + symtable = arg->value.obj.properties; + } else { + symtable = arg->value.ht; + } + return zend_hash_update(symtable, key, strlen(key)+1, (void *) &tmp, sizeof(pval *), NULL); +#else return _php3_hash_update(arg->value.ht, key, strlen(key)+1, (void *) &tmp, sizeof(pval), NULL); +#endif } @@ -336,8 +361,6 @@ flags = options->value.lval; mcal_le_struct->flags = cl_flags; } - // mcal_stream = cal_connect(calendar->value.str.val); - // cal_login(mcal_stream, calendar->value.str.val); if (mcal_stream == NULL) { php3_error(E_WARNING,"Couldn't re-open stream\n"); RETURN_FALSE; @@ -401,6 +424,10 @@ convert_to_long(options); } cal_fetch(mcal_le_struct->mcal_stream,eventid->value.lval,&myevent); + if(myevent == NULL) + { + RETURN_FALSE; + } calevent_free(mcal_le_struct->event); mcal_le_struct->event=myevent; make_event_object(return_value,mcal_le_struct->event); @@ -499,27 +526,24 @@ -/* {{{ proto array mcal_list_events(int stream_id,int begindate, [int enddate]) +/* {{{ proto array mcal_list_events(int stream_id,object begindate, [object enddate]) Returns list of UIDs for that day or range of days */ void php3_mcal_list_events(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*begindate,*enddate,*recurrence; - pval *pvalue; + pval *streamind,*startyear,*startmonth,*startday; + pval *endyear,*endmonth,*endday; int ind, ind_type; pils *mcal_le_struct; cal_list_t *my_cal_list; - CALEVENT *event; - datetime_t begincal,endcal; int myargc; + datetime_t startdate=DT_INIT; + datetime_t enddate=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc <2 || myargc > 4 || getParameters(ht,myargc,&streamind,&begindate,&enddate,&recurrence) == FAILURE) { + if ((myargc !=1 && myargc !=7) || getParameters(ht,myargc,&streamind,&startyear,&startmonth,&startday,&endyear,&endmonth,&endday) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(streamind); - convert_to_array(begindate); - if(myargc >= 3) convert_to_array(enddate); - if(myargc == 4) convert_to_long(recurrence); ind = streamind->value.lval; mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); @@ -533,68 +557,35 @@ if (array_init(return_value) == FAILURE) { RETURN_FALSE; } - begincal.has_time=0; - endcal.has_time=0; - if(_php3_hash_find(begindate->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){ - convert_to_long(pvalue); - begincal.year=(pvalue)->value.lval; - } - if(_php3_hash_find(begindate->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){ - convert_to_long(pvalue); - begincal.mon=(pvalue)->value.lval; - } - if(_php3_hash_find(begindate->value.ht,"day",sizeof("day"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - begincal.mday=(pvalue)->value.lval; - } -if(myargc == 3) - { - if(_php3_hash_find(enddate->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - endcal.year=(pvalue)->value.lval; - } - if(_php3_hash_find(enddate->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - endcal.mon=(pvalue)->value.lval; - } - if(_php3_hash_find(enddate->value.ht,"day",sizeof("day"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - endcal.mday=(pvalue)->value.lval; - } - } + + if(myargc ==7) + { + convert_to_long(startyear); + convert_to_long(startmonth); + convert_to_long(startday); + convert_to_long(endyear); + convert_to_long(endmonth); + convert_to_long(endday); + dt_setdate(&startdate,startyear->value.lval,startmonth->value.lval,startday->value.lval); + dt_setdate(&enddate,endyear->value.lval,endmonth->value.lval,endday->value.lval); + } + else + { + startdate=mcal_le_struct->event->start; + enddate=mcal_le_struct->event->end; + } - g_cal_list=NULL; - cal_search_range(mcal_le_struct->mcal_stream,&begincal,&endcal); - my_cal_list=g_cal_list; - while(my_cal_list != NULL) - { - if(myargc ==4 && recurrence->value.lval ==1) - { - cal_fetch(mcal_le_struct->mcal_stream,my_cal_list->uid,&event); - if(event->recur_type!=RECUR_NONE) - { - datetime_t clamp = begincal; - calevent_next_recurrence(event,&clamp,SUNDAY); - while(dt_hasdate(&clamp) && clamp.year == mcal_le_struct->event->start.year && clamp.mon == mcal_le_struct->event->start.mon) - { - add_next_index_long(return_value,my_cal_list->uid); - clamp.mday++; - if(clamp.mday > endcal.mday) - break; - calevent_next_recurrence(event,&clamp,SUNDAY); - } - } - } - add_next_index_long(return_value,my_cal_list->uid); - my_cal_list=my_cal_list->next; - free(g_cal_list); - g_cal_list=my_cal_list; - } + g_cal_list=NULL; + cal_search_range(mcal_le_struct->mcal_stream,&startdate,&enddate); + my_cal_list=g_cal_list; + while(my_cal_list != NULL) + { + add_next_index_long(return_value,my_cal_list->uid); + my_cal_list=my_cal_list->next; + free(g_cal_list); + g_cal_list=my_cal_list; + } } /* }}} */ @@ -671,81 +662,54 @@ list alarms for a given time */ void php3_mcal_list_alarms(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind, *date,*time; - pval *pvalue; - datetime_t mydate=DT_INIT; - int ind, ind_type; - pils *mcal_le_struct; - cal_list_t *my_cal_list; - - int myargc=ARG_COUNT(ht); - if (myargc < 1 || myargc !=3 || getParameters(ht,myargc,&streamind,&date,&time) == FAILURE) { - WRONG_PARAM_COUNT; + pval *streamind, *year,*month,*day,*hour,*min,*sec; + datetime_t mydate=DT_INIT; + int ind, ind_type; + pils *mcal_le_struct; + cal_list_t *my_cal_list; + int myargc=ARG_COUNT(ht); + if ((myargc != 1 && myargc !=7) || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec) == FAILURE) { + WRONG_PARAM_COUNT; } - - convert_to_long(streamind); - ind = streamind->value.lval; - + + convert_to_long(streamind); + ind = streamind->value.lval; + mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); if (!mcal_le_struct ) { - php3_error(E_WARNING, "Unable to find stream pointer"); - RETURN_FALSE; + php3_error(E_WARNING, "Unable to find stream pointer"); + RETURN_FALSE; } - + if (array_init(return_value) == FAILURE) { - RETURN_FALSE; + RETURN_FALSE; } - - if(myargc ==3) + + if(myargc ==7) { - convert_to_array(date); - convert_to_array(time); - mydate.has_date=1; - mydate.has_time=1; - if(_php3_hash_find(date->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - mydate.year=(pvalue)->value.lval; - } - if(_php3_hash_find(date->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - mydate.mon=(pvalue)->value.lval; - } - if(_php3_hash_find(date->value.ht,"day",sizeof("day"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - mydate.mday=(pvalue)->value.lval; - } - - if(_php3_hash_find(time->value.ht,"hour",sizeof("hour"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - mydate.hour=(pvalue)->value.lval; - } - if(_php3_hash_find(time->value.ht,"minute",sizeof("minute"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - mydate.min=(pvalue)->value.lval; - } - mydate.sec=0; + convert_to_long(year); + convert_to_long(month); + convert_to_long(day); + convert_to_long(hour); + convert_to_long(min); + convert_to_long(sec); + dt_setdate(&mydate,year->value.lval,month->value.lval,day->value.lval); + dt_setdate(&mydate,hour->value.lval,min->value.lval,sec->value.lval); } else { mydate=mcal_le_struct->event->start; } - g_cal_list=NULL; - cal_search_alarm(mcal_le_struct->mcal_stream,&mydate); - my_cal_list=g_cal_list; - while(my_cal_list != NULL) - { - add_next_index_long(return_value,my_cal_list->uid); - my_cal_list=my_cal_list->next; - free(g_cal_list); - g_cal_list=my_cal_list; - } - - + g_cal_list=NULL; + cal_search_alarm(mcal_le_struct->mcal_stream,&mydate); + my_cal_list=g_cal_list; + while(my_cal_list != NULL) + { + add_next_index_long(return_value,my_cal_list->uid); + my_cal_list=my_cal_list->next; + free(g_cal_list); + g_cal_list=my_cal_list; + } } /* }}} */ @@ -826,21 +790,19 @@ Store an event*/ void php3_mcal_store_event(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*storeobject; + pval *streamind; int ind, ind_type; pils *mcal_le_struct; - pval *pvalue,*temppvalue; int myargc; unsigned long uid; CALEVENT *myevent; myargc=ARG_COUNT(ht); - if (myargc <1 || getParameters(ht,myargc,&streamind,&storeobject) == FAILURE) { + if (myargc !=1 || getParameters(ht,myargc,&streamind) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(streamind); - if(myargc >= 2 )convert_to_array(storeobject); ind = streamind->value.lval; @@ -854,121 +816,8 @@ /* Initialize return array */ if (array_init(return_value) == FAILURE) { RETURN_FALSE; - } - myevent=calevent_new(); - if(myargc >=2) - { - if(_php3_hash_find(storeobject->value.ht,"uid",sizeof("uid"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->id=(pvalue)->value.lval; - } - if(_php3_hash_find(storeobject->value.ht,"public",sizeof("public"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->public=(pvalue)->value.lval; - } - if(_php3_hash_find(storeobject->value.ht,"category",sizeof("category"),(void **) &pvalue)== SUCCESS){ - - convert_to_string(pvalue); - myevent->category=strdup((pvalue)->value.str.val); - } - if(_php3_hash_find(storeobject->value.ht,"title",sizeof("title"),(void **) &pvalue)== SUCCESS){ - - convert_to_string(pvalue); - myevent->title=strdup((pvalue)->value.str.val); - } - if(_php3_hash_find(storeobject->value.ht,"description",sizeof("description"),(void **) &pvalue)== SUCCESS){ - - convert_to_string(pvalue); - myevent->description=strdup((pvalue)->value.str.val); - } - - if(_php3_hash_find(storeobject->value.ht,"alarm",sizeof("alarm"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->alarm=(pvalue)->value.lval; - } - - - if(_php3_hash_find(storeobject->value.ht,"start",sizeof("start"),(void **) &temppvalue)== SUCCESS){ - - convert_to_array(temppvalue); - - if(_php3_hash_find((temppvalue)->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->start.year=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->start.mon=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"mday",sizeof("mday"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->start.mday=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"hour",sizeof("hour"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->start.hour=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"min",sizeof("min"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->start.min=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"sec",sizeof("sec"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->start.sec=(pvalue)->value.lval; - } - myevent->start.has_date=true; } - - if(_php3_hash_find(storeobject->value.ht,"end",sizeof("end"),(void **) &temppvalue)== SUCCESS){ - - convert_to_array(temppvalue); - - if(_php3_hash_find((temppvalue)->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->end.year=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->end.mon=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"mday",sizeof("mday"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->end.mday=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"hour",sizeof("hour"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->end.hour=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"min",sizeof("min"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->end.min=(pvalue)->value.lval; - } - if(_php3_hash_find((temppvalue)->value.ht,"sec",sizeof("sec"),(void **) &pvalue)== SUCCESS){ - - convert_to_long(pvalue); - myevent->end.sec=(pvalue)->value.lval; - } - myevent->end.has_date=true; - } - } - else - { - myevent=mcal_le_struct->event; - } + myevent=mcal_le_struct->event; cal_append(mcal_le_struct->mcal_stream,"INBOX",&uid,myevent); calevent_free(myevent); RETURN_LONG(uid); @@ -1147,7 +996,7 @@ { pval *streamind,*year,*month,*date,*hour,*min,*sec; int ind, ind_type; - int myhour,mymin,mysec; + int myhour=0,mymin=0,mysec=0; pils *mcal_le_struct; int myargc; myargc=ARG_COUNT(ht); @@ -1438,26 +1287,26 @@ /* }}} */ -/* {{{ proto object mcal_next_recurrence(int stream_id, object event,int weekstart) +/* {{{ proto object mcal_next_recurrence(int stream_id, int weekstart,array next) returns an object filled with the next date the event occurs, on or after the supplied date. Returns empty date field if event does not occur or something is invalid. */ void php3_mcal_next_recurrence(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*weekstart; + pval *streamind,*weekstart,*next,*pvalue; int ind, ind_type; pils *mcal_le_struct; int myargc; - datetime_t next; + datetime_t mydate; myargc=ARG_COUNT(ht); - if (myargc !=2 || getParameters(ht,myargc,&streamind,&weekstart) == FAILURE) { + if (myargc !=3 || getParameters(ht,myargc,&streamind,&weekstart,&next) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(streamind); convert_to_long(weekstart); - + convert_to_array(next); ind = streamind->value.lval; mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); @@ -1465,43 +1314,83 @@ if (!mcal_le_struct ) { php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; + } + + + if(_php3_hash_find(next->value.ht,"year",sizeof("year"),(void **) &pvalue)== SUCCESS){ + + convert_to_long(pvalue); + mydate.year=(pvalue)->value.lval; + } + if(_php3_hash_find(next->value.ht,"month",sizeof("month"),(void **) &pvalue)== SUCCESS){ + + convert_to_long(pvalue); + mydate.mon=(pvalue)->value.lval; + } + if(_php3_hash_find(next->value.ht,"mday",sizeof("mday"),(void **) &pvalue)== SUCCESS){ + + convert_to_long(pvalue); + mydate.mday=(pvalue)->value.lval; } - calevent_next_recurrence(mcal_le_struct->event,&next,weekstart->value.lval); + if(_php3_hash_find(next->value.ht,"hour",sizeof("hour"),(void **) &pvalue)== SUCCESS){ + + convert_to_long(pvalue); + mydate.hour=(pvalue)->value.lval; + } + if(_php3_hash_find(next->value.ht,"min",sizeof("min"),(void **) &pvalue)== SUCCESS){ + + convert_to_long(pvalue); + mydate.min=(pvalue)->value.lval; + } + if(_php3_hash_find(next->value.ht,"sec",sizeof("sec"),(void **) &pvalue)== SUCCESS){ + + convert_to_long(pvalue); + mydate.sec=(pvalue)->value.lval; + + } + + calevent_next_recurrence(mcal_le_struct->event,&mydate,weekstart->value.lval); object_init(return_value); - if(next.has_date) + if(mydate.has_date) { - add_property_long(return_value,"year",next.year); - add_property_long(return_value,"month",next.mon); - add_property_long(return_value,"mday",next.mday); + add_property_long(return_value,"year",mydate.year); + add_property_long(return_value,"month",mydate.mon); + add_property_long(return_value,"mday",mydate.mday); } - if(next.has_time) + if(mydate.has_time) { - add_property_long(return_value,"hour",next.hour); - add_property_long(return_value,"min",next.min); - add_property_long(return_value,"sec",next.sec); + add_property_long(return_value,"hour",mydate.hour); + add_property_long(return_value,"min",mydate.min); + add_property_long(return_value,"sec",mydate.sec); } } /* }}} */ -/* {{{ proto string mcal_event_set_recur_daily(int stream_id,object enddate,int interval +/* {{{ proto string mcal_event_set_recur_daily(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval create a daily recurrence */ void php3_mcal_event_set_recur_daily(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*enddate,*interval; + pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval; int ind, ind_type; pils *mcal_le_struct; int myargc; - datetime_t endtime; + datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=3 || getParameters(ht,myargc,&streamind,&enddate,&interval) == FAILURE) { + if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(streamind); - convert_to_object(enddate); + convert_to_long(year); + convert_to_long(month); + convert_to_long(day); + convert_to_long(hour); + convert_to_long(min); + convert_to_long(sec); convert_to_long(interval); + ind = streamind->value.lval; mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); @@ -1510,28 +1399,35 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } + dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); + dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_daily(mcal_le_struct->event, &endtime, interval->value.lval); } /* }}} */ -/* {{{ proto string mcal_event_set_recur_weekly(int stream_id,object enddate,int interval, int weekdays - create a weekly recurrence */ +/* {{{ proto string mcal_event_set_recur_weekly(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval, int weekdays) +create a weekly recurrence */ void php3_mcal_event_set_recur_weekly(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*enddate,*interval,*weekdays; + pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval,*weekdays; int ind, ind_type; pils *mcal_le_struct; int myargc; - datetime_t endtime; + datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=4 || getParameters(ht,myargc,&streamind,&enddate,&interval,&weekdays) == FAILURE) { + if (myargc !=4 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval,&weekdays) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(streamind); - convert_to_object(enddate); + convert_to_long(year); + convert_to_long(month); + convert_to_long(day); + convert_to_long(hour); + convert_to_long(min); + convert_to_long(sec); convert_to_long(interval); convert_to_long(weekdays); ind = streamind->value.lval; @@ -1542,29 +1438,37 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } + dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); + dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_weekly(mcal_le_struct->event, &endtime, interval->value.lval,weekdays->value.lval); } /* }}} */ -/* {{{ proto string mcal_event_set_recur_monthly_mday(int stream_id,object enddate,int interval - create a monthly by day recurrence */ +/* {{{ proto string mcal_event_set_recur_monthly_mday(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval) + create a monthly by day recurrence */ void php3_mcal_event_set_recur_monthly_mday(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*enddate,*interval; + pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval; int ind, ind_type; pils *mcal_le_struct; int myargc; - datetime_t endtime; + datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=3 || getParameters(ht,myargc,&streamind,&enddate,&interval) == FAILURE) { + if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(streamind); - convert_to_object(enddate); + convert_to_long(year); + convert_to_long(month); + convert_to_long(day); + convert_to_long(hour); + convert_to_long(min); + convert_to_long(sec); convert_to_long(interval); + ind = streamind->value.lval; mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); @@ -1573,29 +1477,37 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } + dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); + dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_monthly_mday(mcal_le_struct->event, &endtime, interval->value.lval); } /* }}} */ -/* {{{ proto string mcal_event_set_recur_monthly_wday(int stream_id,object enddate,int interval +/* {{{ proto string mcal_event_set_recur_monthly_wday(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval) create a monthy by week recurrence */ void php3_mcal_event_set_recur_monthly_wday(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*enddate,*interval; + pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval; int ind, ind_type; pils *mcal_le_struct; int myargc; - datetime_t endtime; + datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=3 || getParameters(ht,myargc,&streamind,&enddate,&interval) == FAILURE) { + if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(streamind); - convert_to_object(enddate); + convert_to_long(year); + convert_to_long(month); + convert_to_long(day); + convert_to_long(hour); + convert_to_long(min); + convert_to_long(sec); convert_to_long(interval); + ind = streamind->value.lval; mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); @@ -1604,29 +1516,37 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } + dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); + dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_monthly_wday(mcal_le_struct->event, &endtime, interval->value.lval); } /* }}} */ -/* {{{ proto string mcal_event_set_recur_yearly(int stream_id,object enddate,int interval +/* {{{ proto string mcal_event_set_recur_yearly(int stream_id,int year,int month,int day,int hour,int min,int sec,int interval) create a yearly recurrence */ void php3_mcal_event_set_recur_yearly(INTERNAL_FUNCTION_PARAMETERS) { - pval *streamind,*enddate,*interval; + pval *streamind,*year,*month,*day,*hour,*min,*sec,*interval; int ind, ind_type; pils *mcal_le_struct; int myargc; - datetime_t endtime; + datetime_t endtime=DT_INIT; myargc=ARG_COUNT(ht); - if (myargc !=3 || getParameters(ht,myargc,&streamind,&enddate,&interval) == FAILURE) { + if (myargc !=8 || getParameters(ht,myargc,&streamind,&year,&month,&day,&hour,&min,&sec,&interval) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long(streamind); - convert_to_object(enddate); + convert_to_long(year); + convert_to_long(month); + convert_to_long(day); + convert_to_long(hour); + convert_to_long(min); + convert_to_long(sec); convert_to_long(interval); + ind = streamind->value.lval; mcal_le_struct = (pils *)php3_list_find(ind, &ind_type); @@ -1635,6 +1555,8 @@ php3_error(E_WARNING, "Unable to find stream pointer"); RETURN_FALSE; } + dt_setdate(&endtime,year->value.lval,month->value.lval,day->value.lval); + dt_settime(&endtime,hour->value.lval,min->value.lval,sec->value.lval); calevent_recur_yearly(mcal_le_struct->event, &endtime, interval->value.lval); Index: php3/functions/php3_mcal.h diff -u php3/functions/php3_mcal.h:1.10 php3/functions/php3_mcal.h:1.11 --- php3/functions/php3_mcal.h:1.10 Wed Sep 8 15:30:58 1999 +++ php3/functions/php3_mcal.h Mon Sep 13 11:03:12 1999 @@ -1,4 +1,4 @@ -/* $Id: php3_mcal.h,v 1.10 1999/09/08 19:30:58 musone Exp $ */ +/* $Id: php3_mcal.h,v 1.11 1999/09/13 15:03:12 musone Exp $ */ #ifndef _INCLUDED_MCAL_H #define _INCLUDED_MCAL_H @@ -23,8 +23,13 @@ #define php3_mcal_module_ptr &php3_mcal_module_entry #define phpext_mcal_ptr php3_mcal_module_ptr +#ifdef ZEND_VERSION +extern PHP_MINIT_FUNCTION(mcal); +PHP_MINFO_FUNCTION(mcal); +#else extern int PHP_MINIT_FUNCTION(INIT_FUNC_ARGS); extern void PHP_MINFO_FUNCTION(void); +#endif extern int mcal_init_request(INIT_FUNC_ARGS);

« previous php.dev (#10851) next »