⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 php_mcal.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	pils *mcal_le_struct; 	int myargc;		myargc = ZEND_NUM_ARGS();	if (myargc != 3 || zend_get_parameters_ex(3, &streamind, &attribute, &val) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(streamind);	convert_to_string_ex(attribute);	convert_to_string_ex(val);		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 MCALVER >= 20000121	if (calevent_setattr(mcal_le_struct->event, Z_STRVAL_PP(attribute), Z_STRVAL_PP(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){	zval **year;	int myargc;		myargc = ZEND_NUM_ARGS();	if (myargc != 1 || zend_get_parameters_ex(1, &year) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(year);		if (isleapyear(Z_LVAL_PP(year))) {	    RETURN_TRUE;	}	else {	    RETURN_FALSE;	}}/* }}} *//* {{{ proto int mcal_days_in_month(int month, bool leap_year)   Returns the number of days in the given month, needs to know if the year is a leap year or not */PHP_FUNCTION(mcal_days_in_month){	zval **month, **leap;	int myargc;		myargc = ZEND_NUM_ARGS();	if (myargc != 2 || zend_get_parameters_ex(2, &month, &leap) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(month);	convert_to_long_ex(leap);	convert_to_boolean_ex(leap);		RETURN_LONG(daysinmonth(Z_LVAL_PP(month), Z_LVAL_PP(leap)));}/* }}} *//* {{{ proto bool mcal_date_valid(int year, int month, int day)   Returns true if the date is a valid date */PHP_FUNCTION(mcal_date_valid){	zval **year, **month, **day;	int myargc;		myargc = ZEND_NUM_ARGS();	if (myargc != 3 || zend_get_parameters_ex(3, &year, &month, &day) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(year);	convert_to_long_ex(month);	convert_to_long_ex(day);		if (datevalid(Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day))) {	    RETURN_TRUE;	}	else {	    RETURN_FALSE;	}}/* }}} *//* {{{ proto bool mcal_time_valid(int hour, int min, int sec)   Returns true if the time is a valid time */PHP_FUNCTION(mcal_time_valid){	zval **hour, **min, **sec;	int myargc;		myargc = ZEND_NUM_ARGS();	if (myargc != 3 || zend_get_parameters_ex(3, &hour, &min, &sec) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(hour);	convert_to_long_ex(min);	convert_to_long_ex(sec);		if (timevalid(Z_LVAL_PP(hour), Z_LVAL_PP(min), Z_LVAL_PP(sec))) {	    RETURN_TRUE;	}	else {	    RETURN_FALSE;	}}/* }}} *//* {{{ proto int mcal_day_of_week(int year, int month, int day)   Returns the day of the week of the given date */PHP_FUNCTION(mcal_day_of_week){	zval **year, **month, **day;	int myargc;	datetime_t mydate;		myargc = ZEND_NUM_ARGS();	if (myargc != 3 || zend_get_parameters_ex(3, &year, &month, &day) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(year);	convert_to_long_ex(month);	convert_to_long_ex(day);		dt_init(&mydate);	dt_setdate(&mydate, Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));		RETURN_LONG(dt_dayofweek(&mydate));}/* }}} *//* {{{ proto int mcal_day_of_year(int year, int month, int day)   Returns the day of the year of the given date */PHP_FUNCTION(mcal_day_of_year){	zval **year, **month, **day;	int myargc;	datetime_t mydate;		myargc = ZEND_NUM_ARGS();	if (myargc != 3 || zend_get_parameters_ex(3, &year, &month, &day) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(year);	convert_to_long_ex(month);	convert_to_long_ex(day);		dt_init(&mydate);	dt_setdate(&mydate, Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));		RETURN_LONG(dt_dayofyear(&mydate));}/* }}} *//* {{{ proto int mcal_week_of_year(int day, int month, int year)   Returns the week number of the given date */PHP_FUNCTION(mcal_week_of_year){	zval **year, **month, **day;	int myargc;		myargc = ZEND_NUM_ARGS();	if (myargc != 3 || zend_get_parameters_ex(3, &day, &month, &year) == FAILURE) {		WRONG_PARAM_COUNT;	}	 	convert_to_long_ex(year); 	convert_to_long_ex(month); 	convert_to_long_ex(day);	 	if (datevalid(Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day))) { 		RETURN_LONG(dt_weekofyear(Z_LVAL_PP(day), Z_LVAL_PP(month), Z_LVAL_PP(year)));	}	else {		RETURN_FALSE;	}}/* }}} *//* {{{ proto int mcal_date_compare(int ayear, int amonth, int aday, int byear, int bmonth, int bday)   Returns <0, 0, >0 if a<b, a==b, a>b respectively */PHP_FUNCTION(mcal_date_compare){	zval **ayear, **amonth, **aday;	zval **byear, **bmonth, **bday;	int myargc;	datetime_t myadate, mybdate;		myargc = ZEND_NUM_ARGS();	if (myargc != 6 || zend_get_parameters_ex(6, &ayear, &amonth, &aday, &byear, &bmonth, &bday) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(ayear);	convert_to_long_ex(amonth);	convert_to_long_ex(aday);	convert_to_long_ex(byear);	convert_to_long_ex(bmonth);	convert_to_long_ex(bday);		dt_init(&myadate);	dt_init(&mybdate);	dt_setdate(&myadate, Z_LVAL_PP(ayear), Z_LVAL_PP(amonth), Z_LVAL_PP(aday));	dt_setdate(&mybdate, Z_LVAL_PP(byear), Z_LVAL_PP(bmonth), Z_LVAL_PP(bday));		RETURN_LONG(dt_compare(&myadate, &mybdate));}/* }}} *//* {{{ 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. */PHP_FUNCTION(mcal_next_recurrence){	zval **streamind, **weekstart, **next, **zvalue;	int ind, ind_type;	pils *mcal_le_struct; 	int myargc;	datetime_t mydate;		myargc=ZEND_NUM_ARGS();	if (myargc != 3 || zend_get_parameters_ex(3, &streamind, &weekstart, &next) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(streamind);	convert_to_long_ex(weekstart);	convert_to_array_ex(next);		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 (zend_hash_find(Z_ARRVAL_PP(next), "year", sizeof("year"), (void **) &zvalue) == SUCCESS) {		SEPARATE_ZVAL(zvalue);		convert_to_long_ex(zvalue);		mydate.year = Z_LVAL_PP(zvalue);	}	if (zend_hash_find(Z_ARRVAL_PP(next), "month", sizeof("month"), (void **) &zvalue) == SUCCESS) {		SEPARATE_ZVAL(zvalue);		convert_to_long_ex(zvalue);		mydate.mon = Z_LVAL_PP(zvalue);	}	if (zend_hash_find(Z_ARRVAL_PP(next), "mday", sizeof("mday"), (void **) &zvalue) == SUCCESS) {		SEPARATE_ZVAL(zvalue);		convert_to_long_ex(zvalue);		mydate.mday = Z_LVAL_PP(zvalue);	}	if (zend_hash_find(Z_ARRVAL_PP(next), "hour", sizeof("hour"), (void **) &zvalue) == SUCCESS) {		SEPARATE_ZVAL(zvalue);		convert_to_long_ex(zvalue);		mydate.hour = Z_LVAL_PP(zvalue);	}	if (zend_hash_find(Z_ARRVAL_PP(next), "min", sizeof("min"), (void **) &zvalue) == SUCCESS) {		SEPARATE_ZVAL(zvalue);		convert_to_long_ex(zvalue);		mydate.min = Z_LVAL_PP(zvalue);	}	if (zend_hash_find(Z_ARRVAL_PP(next), "sec", sizeof("sec"), (void **) &zvalue) == SUCCESS) {		SEPARATE_ZVAL(zvalue);		convert_to_long_ex(zvalue);		mydate.sec = Z_LVAL_PP(zvalue);	}		calevent_next_recurrence(mcal_le_struct->event, &mydate, Z_LVAL_PP(weekstart));		if (object_init(return_value) == FAILURE) {		RETURN_FALSE;	}		if (mydate.has_date) {	    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 (mydate.has_time) {		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_none(int stream_id)   Create a daily recurrence */PHP_FUNCTION(mcal_event_set_recur_none){	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;	}		calevent_recur_none(mcal_le_struct->event);}/* }}} *//* {{{ proto string mcal_event_set_recur_daily(int stream_id, int year, int month, int day, int interval)   Create a daily recurrence */PHP_FUNCTION(mcal_event_set_recur_daily){	zval **streamind, **year, **month, **day, **interval;	int ind, ind_type;	pils *mcal_le_struct; 	int myargc;	datetime_t endtime = DT_INIT;		myargc = ZEND_NUM_ARGS();	if (myargc != 5 || zend_get_parameters_ex(5, &streamind, &year, &month, &day, &interval) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(streamind);	convert_to_long_ex(year);	convert_to_long_ex(month);	convert_to_long_ex(day);	convert_to_long_ex(interval);		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(&endtime, Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));	calevent_recur_daily(mcal_le_struct->event, &endtime, Z_LVAL_PP(interval));}/* }}} *//* {{{ proto string mcal_event_set_recur_weekly(int stream_id, int year, int month, int day, int interval, int weekdays)   Create a weekly recurrence */PHP_FUNCTION(mcal_event_set_recur_weekly){	zval **streamind, **year, **month, **day, **interval, **weekdays;	int ind, ind_type;	pils *mcal_le_struct; 	int myargc;	datetime_t endtime=DT_INIT;		myargc = ZEND_NUM_ARGS();	if (myargc != 6 || zend_get_parameters_ex(6, &streamind, &year, &month, &day, &interval, &weekdays) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(streamind);	convert_to_long_ex(year);	convert_to_long_ex(month);	convert_to_long_ex(day);	convert_to_long_ex(interval);	convert_to_long_ex(weekdays);		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(&endtime, Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));	calevent_recur_weekly(mcal_le_struct->event, &endtime, Z_LVAL_PP(interval), Z_LVAL_PP(weekdays));}/* }}} *//* {{{ proto string mcal_event_set_recur_monthly_mday(int stream_id, int year, int month, int day, int interval)   Create a monthly by day recurrence */PHP_FUNCTION(mcal_event_set_recur_monthly_mday){	zval **streamind, **year, **month, **day, **interval;	int ind, ind_type;	pils *mcal_le_struct; 	int myargc;	datetime_t endtime=DT_INIT;		myargc = ZEND_NUM_ARGS();	if (myargc != 5 || zend_get_parameters_ex(5, &streamind, &year, &month, &day, &interval) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(streamind);	convert_to_long_ex(year);	convert_to_long_ex(month);	convert_to_long_ex(day);	convert_to_long_ex(interval);		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(&endtime, Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));	calevent_recur_monthly_mday(mcal_le_struct->event, &endtime, Z_LVAL_PP(interval));}/* }}} *//* {{{ proto string mcal_event_set_recur_monthly_wday(int stream_id, int year, int month, int day, int interval)   Create a monthly by week recurrence */PHP_FUNCTION(mcal_event_set_recur_monthly_wday){	zval **streamind, **year, **month, **day, **interval;	int ind, ind_type;	pils *mcal_le_struct; 	int myargc;	datetime_t endtime=DT_INIT;		myargc = ZEND_NUM_ARGS();	if (myargc != 5 || zend_get_parameters_ex(5, &streamind, &year, &month, &day, &interval) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(streamind);	convert_to_long_ex(year);	convert_to_long_ex(month);	convert_to_long_ex(day);	convert_to_long_ex(interval);		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(&endtime, Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));	calevent_recur_monthly_wday(mcal_le_struct->event, &endtime, Z_LVAL_PP(interval));}/* }}} *//* {{{ proto string mcal_event_set_recur_yearly(int stream_id, int year, int month, int day, int interval)   Create a yearly recurrence */PHP_FUNCTION(mcal_event_set_recur_yearly){	zval **streamind, **year, **month, **day, **interval;	int ind, ind_type;	pils *mcal_le_struct; 	int myargc;	datetime_t endtime=DT_INIT;		myargc = ZEND_NUM_ARGS();	if (myargc != 5 || zend_get_parameters_ex(5, &streamind, &year, &month, &day, &interval) == FAILURE) {		WRONG_PARAM_COUNT;	}		convert_to_long_ex(streamind);	convert_to_long_ex(year);	convert_to_long_ex(month);	convert_to_long_ex(day);	convert_to_long_ex(interval);		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(&endtime, Z_LVAL_PP(year), Z_LVAL_PP(month), Z_LVAL_PP(day));	calevent_recur_yearly(mcal_le_struct->event, &endtime, Z_LVAL_PP(interval));}/* }}} *//* Interfaces to callbacks */void cc_searched (unsigned long cal_uid){	if (g_cal_list == NULL) {		g_cal_list = malloc(sizeof(struct cal_list));		g_cal_list->uid = cal_uid;		g_cal_list->next = NULL;		g_cal_list_end = g_cal_list;    }	else {		g_cal_list_end->next = malloc(sizeof(struct cal_list));		g_cal_list_end = g_cal_list_end->next;		g_cal_list_end->uid = cal_uid;		g_cal_list_end->next = NULL;	}}void cc_appended(php_uint32 uid){}void cc_fetched(const CALEVENT *event){}void cc_login(const char **user, const char **pwd){	*user=mcal_user;	*pwd=mcal_password; }void cc_vlog(const char *fmt,va_list ap){}void cc_vdlog(const char *fmt,va_list ap){}#endif/* * Local_ variables: * tab-width: 4 * c-basic-offset: 4 * End: */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -