cvs: /php3/functions php3_mcal.c php3_mcal.h
| From: | Mark Musone | Date: | Sat, 22 Jan 2000 03:13:38 +0000 |
| Subject: | cvs: /php3/functions php3_mcal.c php3_mcal.h | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-14821@lists.php.net to get a copy of this message | ||
musone Fri Jan 21 19:13:38 2000 EDT
Modified files:
/php3/functions php3_mcal.c php3_mcal.h
Log:
fixed a small seg fault bug when retreiving an empty event. Also added event attribute/value
support for latest mcal cvs
Index: php3/functions/php3_mcal.c
diff -u php3/functions/php3_mcal.c:1.34 php3/functions/php3_mcal.c:1.35
--- php3/functions/php3_mcal.c:1.34 Fri Dec 31 20:31:16 1999
+++ php3/functions/php3_mcal.c Fri Jan 21 19:13:38 2000
@@ -121,6 +121,7 @@
PHP_FE(mcal_event_set_end_now,NULL)
PHP_FE(mcal_event_set_start_now,NULL)
PHP_FE(mcal_fetch_current_stream_event,NULL)
+PHP_FE(mcal_event_add_attribute,NULL)
{NULL, NULL, NULL}
};
@@ -163,6 +164,9 @@
php3_printf("<table>");
php3_printf("<tr><td>Mcal Version:</td>");
php3_printf("<td>%s</td>",CALVER);
+#ifdef MCALVER
+ php3_printf("<td>%d</td>",MCALVER);
+#endif
php3_printf("</tr></table>");
}
@@ -238,7 +242,7 @@
pval *user;
pval *passwd;
pval *options;
- CALSTREAM *mcal_stream;
+ CALSTREAM *mcal_stream=NULL;
pils *mcal_le_struct;
long flags=0;
int ind;
@@ -388,7 +392,7 @@
pval *streamind,*eventid,*options=NULL;
int ind, ind_type;
pils *mcal_le_struct=NULL;
- CALEVENT *myevent;
+ CALEVENT *myevent=NULL;
int myargcount=ARG_COUNT(ht);
if (myargcount < 1 || myargcount > 3 || getParameters(ht, myargcount, &streamind,
&eventid,&options) == FAILURE) {
@@ -443,7 +447,8 @@
void make_event_object(pval *mypvalue,CALEVENT *event)
{
- pval start,end,recurend;
+ pval start,end,recurend,attrlist;
+ CALATTR *attr;
object_init(mypvalue);
add_property_long(mypvalue,"id",event->id);
add_property_long(mypvalue,"public",event->public);
@@ -497,6 +502,14 @@
}
add_assoc_object(mypvalue, "recur_enddate",recurend);
add_property_long(mypvalue,"recur_data",event->recur_data.weekly_wday);
+ if(event->attrlist)
+ {
+ array_init(&attrlist);
+ for (attr = event->attrlist; attr; attr = attr->next) {
+ add_assoc_string(&attrlist,attr->name,attr->value,1);
+ }
+ add_assoc_object(mypvalue,"attrlist",attrlist);
+ }
}
/* {{{ proto array mcal_list_events(int stream_id, int startyear, int startmonth, int startday, int
endyear, int endmonth, int endday)
@@ -758,7 +771,7 @@
pils *mcal_le_struct;
int myargc;
unsigned long uid;
- CALEVENT *myevent;
+ CALEVENT *myevent=NULL;
myargc=ARG_COUNT(ht);
if (myargc !=1 || getParameters(ht,myargc,&streamind) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -850,6 +863,45 @@
mcal_le_struct->event->category=strdup(category->value.str.val);
}
/* }}} */
+
+/* {{{ proto string mcal_event_add_attribute(int stream_id, string attribute,string value)
+ Add an attribute and value to an event */
+void php3_mcal_event_add_attribute(INTERNAL_FUNCTION_PARAMETERS)
+{
+ pval *streamind,*attribute,*val;
+ int ind, ind_type;
+ pils *mcal_le_struct;
+ int myargc;
+ myargc=ARG_COUNT(ht);
+ if (myargc !=3 || getParameters(ht,myargc,&streamind,&attribute,&val) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(streamind);
+ convert_to_string(attribute);
+ convert_to_string(val);
+
+ 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;
+ }
+#if MCALVER >= 20000121
+ if(calevent_setattr(mcal_le_struct->event,attribute->value.str.val,val->value.str.val))
+ {
+ RETURN_TRUE;
+ }
+ else
+#endif
+ {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
/* {{{ proto string mcal_event_set_title(int stream_id, string title)
Attach a title to an event */
Index: php3/functions/php3_mcal.h
diff -u php3/functions/php3_mcal.h:1.14 php3/functions/php3_mcal.h:1.15
--- php3/functions/php3_mcal.h:1.14 Sun Dec 26 10:44:47 1999
+++ php3/functions/php3_mcal.h Fri Jan 21 19:13:38 2000
@@ -1,4 +1,4 @@
-/* $Id: php3_mcal.h,v 1.14 1999/12/26 18:44:47 rasmus Exp $ */
+/* $Id: php3_mcal.h,v 1.15 2000/01/22 03:13:38 musone Exp $ */
#ifndef _INCLUDED_MCAL_H
#define _INCLUDED_MCAL_H
@@ -68,6 +68,7 @@
void php3_mcal_event_set_start_now(INTERNAL_FUNCTION_PARAMETERS);
void php3_mcal_event_set_end_now(INTERNAL_FUNCTION_PARAMETERS);
void php3_mcal_fetch_current_stream_event(INTERNAL_FUNCTION_PARAMETERS);
+void php3_mcal_event_add_attribute(INTERNAL_FUNCTION_PARAMETERS);
#else