summaryrefslogtreecommitdiff
path: root/ext/mcal/php_mcal.c
diff options
context:
space:
mode:
authorChuck Hagenbuch <chagenbu@php.net>2000-03-05 05:36:34 +0000
committerChuck Hagenbuch <chagenbu@php.net>2000-03-05 05:36:34 +0000
commite7d03185c471cf2b3f62cd9cd1ff3ae811c11bc5 (patch)
treee93129e78ccdf4a106de1b0aef6cfcf1590ba5b0 /ext/mcal/php_mcal.c
parentb4b82e05d8316d3b9f19b249fe9af1f7633f247a (diff)
downloadphp-git-e7d03185c471cf2b3f62cd9cd1ff3ae811c11bc5.tar.gz
Attribute list support ported from php3.
Diffstat (limited to 'ext/mcal/php_mcal.c')
-rw-r--r--ext/mcal/php_mcal.c53
1 files changed, 51 insertions, 2 deletions
diff --git a/ext/mcal/php_mcal.c b/ext/mcal/php_mcal.c
index 0d98299c4a..4984416696 100644
--- a/ext/mcal/php_mcal.c
+++ b/ext/mcal/php_mcal.c
@@ -100,6 +100,7 @@ function_entry mcal_functions[] = {
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 @@ PHP_MINIT_FUNCTION(mcal)
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 php_mcal_event_init(struct _php_mcal_le_struct *mystruct)
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 @@ void make_event_object(pval *mypvalue, CALEVENT *event)
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])
@@ -1083,6 +1096,42 @@ PHP_FUNCTION(mcal_event_set_class)
}
/* }}} */
+/* {{{ 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;
+ }
+}
+/* }}} */
+
/* {{{ proto bool mcal_is_leap_year(int year)
Returns true if year is a leap year, false if not */
PHP_FUNCTION(mcal_is_leap_year)