📄 php_mcal.c
字号:
convert_to_long_ex(endmonth); convert_to_long_ex(endday); dt_setdate(&startdate, Z_LVAL_PP(startyear), Z_LVAL_PP(startmonth), Z_LVAL_PP(startday)); dt_setdate(&enddate, Z_LVAL_PP(endyear), Z_LVAL_PP(endmonth), Z_LVAL_PP(endday)); } 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, &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; }}/* }}} *//* {{{ proto string mcal_create_calendar(int stream_id, string calendar) Create a new calendar */PHP_FUNCTION(mcal_create_calendar){ zval **streamind, **calendar; int ind, ind_type; pils *mcal_le_struct; int myargc = ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &calendar) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_string_ex(calendar); ind = Z_LVAL_PP(streamind); 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 (mcal_create(mcal_le_struct->mcal_stream,Z_STRVAL_P(calendar))) { RETURN_TRUE; } else { RETURN_FALSE; } */ RETURN_TRUE;}/* }}} *//* {{{ proto string mcal_rename_calendar(int stream_id, string src_calendar, string dest_calendar) Rename a calendar */PHP_FUNCTION(mcal_rename_calendar){ zval **streamind, **src_calendar, **dest_calendar; int ind, ind_type; pils *mcal_le_struct; int myargc=ZEND_NUM_ARGS(); if (myargc != 3 || zend_get_parameters_ex(3, &streamind, &src_calendar, &dest_calendar) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_string_ex(src_calendar); convert_to_string_ex(dest_calendar); ind = Z_LVAL_PP(streamind); 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(mcal_rename(mcal_le_struct->mcal_stream,Z_STRVAL_P(src_calendar),Z_STRVAL_P(dest_calendar))) {RETURN_TRUE;} else {RETURN_FALSE; } */ RETURN_TRUE;}/* }}} *//* {{{ proto bool mcal_list_alarms(int stream_id, int year, int month, int day, int hour, int min, int sec) List alarms for a given time */PHP_FUNCTION(mcal_list_alarms){ zval **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=ZEND_NUM_ARGS(); if ((myargc != 1 && myargc != 7) || zend_get_parameters_ex(myargc, &streamind, &year, &month, &day, &hour, &min, &sec) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); ind = Z_LVAL_PP(streamind); 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 (array_init(return_value) == FAILURE) { RETURN_FALSE; } if (myargc == 7) { convert_to_long_ex(year); convert_to_long_ex(month); convert_to_long_ex(day); convert_to_long_ex(hour); convert_to_long_ex(min); convert_to_long_ex(sec); dt_setdate(&mydate, Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day)); dt_settime(&mydate, Z_LVAL_PP(hour), Z_LVAL_PP(min), Z_LVAL_PP(sec)); } 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; }}/* }}} *//* {{{ proto string mcal_delete_calendar(int stream_id, string calendar) Delete calendar */PHP_FUNCTION(mcal_delete_calendar){ zval **streamind, **calendar; int ind, ind_type; pils *mcal_le_struct; int myargc=ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &calendar) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_string_ex(calendar); ind = Z_LVAL_PP(streamind); 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 (mcal_delete_calendar(mcal_le_struct->mcal_stream,Z_STRVAL_P(calendar))) { RETURN_TRUE; } else { RETURN_FALSE; } */ RETURN_TRUE;}/* }}} *//* {{{ proto string mcal_delete_event(int stream_id, int event_id) Delete an event */PHP_FUNCTION(mcal_delete_event){ zval **streamind, **event_id; int ind, ind_type; pils *mcal_le_struct; int myargc=ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &event_id) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_long_ex(event_id); ind = Z_LVAL_PP(streamind); 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 (cal_remove(mcal_le_struct->mcal_stream, Z_LVAL_PP(event_id))) { RETURN_TRUE; } else { RETURN_FALSE; }}/* }}} *//* {{{ proto string mcal_append_event(int stream_id) Append a new event to the calendar stream */PHP_FUNCTION(mcal_append_event){ zval **streamind; int ind, ind_type; pils *mcal_le_struct; int myargc; unsigned long event_id; CALEVENT *myevent=NULL; myargc = ZEND_NUM_ARGS(); if (myargc != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); ind = Z_LVAL_PP(streamind); 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; } myevent = mcal_le_struct->event; cal_append(mcal_le_struct->mcal_stream, "INBOX", &event_id, myevent); calevent_free(myevent); RETURN_LONG(event_id);}/* }}} *//* {{{ proto string mcal_store_event(int stream_id) Store changes to an event */PHP_FUNCTION(mcal_store_event){ zval **streamind; int ind, ind_type; pils *mcal_le_struct; int myargc; CALEVENT *myevent=NULL; myargc = ZEND_NUM_ARGS(); if (myargc != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); ind = Z_LVAL_PP(streamind); 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; } myevent = mcal_le_struct->event; cal_store(mcal_le_struct->mcal_stream, myevent); RETURN_LONG(myevent->id);}/* }}} *//* {{{ proto string mcal_snooze(int stream_id, int uid) Snooze an alarm */PHP_FUNCTION(mcal_snooze){ zval **streamind, **uid; int ind, ind_type; pils *mcal_le_struct; int myargc; myargc = ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &uid) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_long_ex(uid); ind = Z_LVAL_PP(streamind); 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 (cal_snooze(mcal_le_struct->mcal_stream, Z_LVAL_PP(uid))) { RETURN_TRUE; } else { RETURN_FALSE; }}/* }}} *//* {{{ proto string mcal_event_set_category(int stream_id, string category) Attach a category to an event */PHP_FUNCTION(mcal_event_set_category){ zval **streamind, **category; int ind, ind_type; pils *mcal_le_struct; int myargc; myargc = ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &category) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_string_ex(category); ind = Z_LVAL_PP(streamind); 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; } mcal_le_struct->event->category = strdup(Z_STRVAL_PP(category));}/* }}} *//* {{{ proto string mcal_event_set_title(int stream_id, string title) Attach a title to an event */PHP_FUNCTION(mcal_event_set_title){ zval **streamind, **title; int ind, ind_type; pils *mcal_le_struct; int myargc; myargc = ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &title) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_string_ex(title); ind = Z_LVAL_PP(streamind); 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; } mcal_le_struct->event->title = strdup(Z_STRVAL_PP(title));}/* }}} *//* {{{ proto string mcal_event_set_description(int stream_id, string description) Attach a description to an event */PHP_FUNCTION(mcal_event_set_description){ zval **streamind, **description; int ind, ind_type; pils *mcal_le_struct; int myargc; myargc = ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &description) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_string_ex(description); ind = Z_LVAL_PP(streamind); 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; } mcal_le_struct->event->description = strdup(Z_STRVAL_PP(description));}/* }}} *//* {{{ 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 */PHP_FUNCTION(mcal_event_set_start){ zval **streamind, **year, **month, **date, **hour, **min, **sec; int ind, ind_type; int myhour=0, mymin=0, mysec=0; pils *mcal_le_struct; int myargc; myargc = ZEND_NUM_ARGS(); if (myargc < 4 || myargc > 7 || zend_get_parameters_ex(myargc, &streamind, &year, &month, &date, &hour, &min, &sec) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_long_ex(year); convert_to_long_ex(month); convert_to_long_ex(date); if (myargc > 4) convert_to_long_ex(hour); if (myargc > 5) convert_to_long_ex(min); if (myargc > 6) convert_to_long_ex(sec); ind = Z_LVAL_PP(streamind); 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; } dt_setdate(&(mcal_le_struct->event->start), Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(date)); if (myargc > 4) myhour = Z_LVAL_PP(hour); if (myargc > 5) mymin = Z_LVAL_PP(min); if (myargc > 6) mysec = Z_LVAL_PP(sec); if (myargc > 4) dt_settime(&(mcal_le_struct->event->start), myhour, mymin, mysec);}/* }}} *//* {{{ 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 */PHP_FUNCTION(mcal_event_set_end){ zval **streamind, **year, **month, **date, **hour, **min, **sec; int ind, ind_type; /* initialize these to zero to make sure we don't use them uninitialized (and to avoid the gcc warning) */ int myhour = 0; int mymin = 0; int mysec = 0; pils *mcal_le_struct; int myargc; myargc = ZEND_NUM_ARGS(); if (myargc < 4 || myargc > 7 || zend_get_parameters_ex(myargc, &streamind, &year, &month, &date, &hour, &min, &sec) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_long_ex(year); convert_to_long_ex(month); convert_to_long_ex(date); if (myargc > 4) convert_to_long_ex(hour); if (myargc > 5) convert_to_long_ex(min); if (myargc > 6) convert_to_long_ex(sec); ind = Z_LVAL_PP(streamind); 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; } dt_setdate(&(mcal_le_struct->event->end), Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(date)); if (myargc > 4) myhour = Z_LVAL_PP(hour); if (myargc > 5) mymin = Z_LVAL_PP(min); if (myargc > 6) mysec = Z_LVAL_PP(sec); if (myargc > 4) dt_settime(&(mcal_le_struct->event->end), myhour, mymin, mysec);}/* }}} *//* {{{ proto int mcal_event_set_alarm(int stream_id, int alarm) Add an alarm to the streams global event */PHP_FUNCTION(mcal_event_set_alarm){ zval **streamind, **alarm; int ind, ind_type; pils *mcal_le_struct; int myargc; myargc=ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &alarm) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_long_ex(alarm); ind = Z_LVAL_PP(streamind); 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; } mcal_le_struct->event->alarm = Z_LVAL_PP(alarm);}/* }}} *//* {{{ proto int mcal_event_init(int stream_id) Initialize a streams global event */PHP_FUNCTION(mcal_event_init){ zval **streamind; int ind, ind_type; pils *mcal_le_struct; int myargc; myargc = ZEND_NUM_ARGS(); if (myargc != 1 || zend_get_parameters_ex(1, &streamind) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); ind = Z_LVAL_PP(streamind); 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; } php_mcal_event_init(mcal_le_struct);}/* }}} *//* {{{ proto int mcal_event_set_class(int stream_id, int class) Add an class to the streams global event */PHP_FUNCTION(mcal_event_set_class){ zval **streamind, **class; int ind, ind_type; pils *mcal_le_struct; int myargc; myargc = ZEND_NUM_ARGS(); if (myargc != 2 || zend_get_parameters_ex(2, &streamind, &class) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_long_ex(streamind); convert_to_long_ex(class); ind = Z_LVAL_PP(streamind); 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; } mcal_le_struct->event->public = Z_LVAL_PP(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){ zval **streamind, **attribute, **val; int ind, ind_type;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -