cvs: /php4/ext/mcal php_mcal.c php_mcal.h
| From: | Charles Hagenbuch | Date: | Sun, 05 Mar 2000 05:37:03 +0000 |
| Subject: | cvs: /php4/ext/mcal php_mcal.c php_mcal.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11526@lists.php.net to get a copy of this message | ||
chagenbu Sat Mar 4 21:37:03 2000 EDT
Modified files:
/php4/ext/mcal php_mcal.c php_mcal.h
Log:
Attribute list support ported from php3.
Index: php4/ext/mcal/php_mcal.c
diff -u php4/ext/mcal/php_mcal.c:1.8 php4/ext/mcal/php_mcal.c:1.9
--- php4/ext/mcal/php_mcal.c:1.8 Tue Feb 29 17:34:04 2000
+++ php4/ext/mcal/php_mcal.c Sat Mar 4 21:36:33 2000
@@ -100,6 +100,7 @@
PHP_FE(mcal_event_set_end,NULL)
PHP_FE(mcal_event_set_alarm,NULL)
PHP_FE(mcal_event_set_class,NULL)
+ PHP_FE(mcal_event_add_attribute,NULL)
PHP_FE(mcal_is_leap_year,NULL)
PHP_FE(mcal_days_in_month,NULL)
PHP_FE(mcal_date_valid,NULL)
@@ -206,7 +207,7 @@
static int add_assoc_object(pval *arg, char *key, pval *tmp)
{
HashTable *symtable;
-
+
if (arg->type == IS_OBJECT) {
symtable = arg->value.obj.properties;
} else {
@@ -263,7 +264,9 @@
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);
@@ -321,6 +324,16 @@
add_assoc_object(mypvalue, "recur_enddate", recurend);
add_property_long(mypvalue,"recur_data",event->recur_data.weekly_wday);
+
+ if (event->attrlist) {
+ MAKE_STD_ZVAL(attrlist);
+ object_init(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 int mcal_close(int stream_id [, int options])
@@ -1080,6 +1093,42 @@
RETURN_FALSE;
}
mcal_le_struct->event->public=class->value.lval;
+}
+/* }}} */
+
+/* {{{ proto string mcal_event_add_attribute(int stream_id, string attribute,string value)
+ Add an attribute and value to an event */
+PHP_FUNCTION(mcal_event_add_attribute)
+{
+ 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 *)zend_list_find(ind, &ind_type);
+ if (!mcal_le_struct ) {
+ php_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;
+ }
}
/* }}} */
Index: php4/ext/mcal/php_mcal.h
diff -u php4/ext/mcal/php_mcal.h:1.4 php4/ext/mcal/php_mcal.h:1.5
--- php4/ext/mcal/php_mcal.h:1.4 Fri Feb 25 19:09:10 2000
+++ php4/ext/mcal/php_mcal.h Sat Mar 4 21:36:33 2000
@@ -1,4 +1,4 @@
-/* $Id: php_mcal.h,v 1.4 2000/02/26 03:09:10 chagenbu Exp $ */
+/* $Id: php_mcal.h,v 1.5 2000/03/05 05:36:33 chagenbu Exp $ */
#ifndef _INCLUDED_MCAL_H
#define _INCLUDED_MCAL_H
@@ -58,6 +58,7 @@
PHP_FUNCTION(mcal_event_set_end);
PHP_FUNCTION(mcal_event_set_alarm);
PHP_FUNCTION(mcal_event_set_class);
+PHP_FUNCTION(mcal_event_add_attribute);
PHP_FUNCTION(mcal_is_leap_year);
PHP_FUNCTION(mcal_days_in_month);
PHP_FUNCTION(mcal_date_valid);