PHP_FUNCTION(nagios_get_status) { char *hostkeys[64] = {"host_name", "has_been_checked", "check_execution_time", "check_latency", "check_type", "current_state", "current_attempt", "state_type", "last_state_change", "last_time_up", "last_time_down", "last_time_unreachable", "last_notification", "next_notification", "no_more_notifications", "current_notification_number", "notifications_enabled", "problem_has_been_acknowledged", "acknowledgement_type", "active_checks_enabled", "passive_checks_enabled", "last_update"}; int hostkeySize = 22; char *servicekeys[64] = {"host_name", "service_description", "has_been_checked", "check_execution_time", "check_latency", "current_state", "state_type", "last_state_change", "last_time_ok", "last_time_warning", "last_time_unknown", "last_time_critical", "plugin_output", "last_check", "notifications_enabled", "active_checks_enabled", "passive_checks_enabled", "problem_has_been_acknowledged", "acknowledgement_type", "last_update", "is_flapping"}; int servicekeySize = 21; FILE *statusfile; int buffer_size = 512; void *bufferptr = malloc(buffer_size + 1); char * lineptr = (char *) bufferptr; int linenumber = 0; int line_size = 0; char *filename; int filename_len; int inSection = 0; char *sectionType = malloc(buffer_size); int sectionTypeSize = 0; char *linekey = malloc(buffer_size); int linekeySize = 0; char *lineval = malloc(buffer_size); int linevalSize = 0; zval * sectionData; zval * serviceStatus; zval * hostStatus; zval * serviceDescription; zval **tmp; char *hostname; char *servdesc; int hostnameSize = 0; int servdescSize = 0; array_init(serviceStatus); array_init(hostStatus); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { RETURN_NULL(); } //php_printf("Hello %s ", filename); statusfile = fopen(filename, "r"); if (statusfile == NULL) { php_printf("Error opening file."); free(bufferptr); free(linekey); free(lineval); free(sectionType); RETURN_FALSE; } php_printf("|%p|\n", statusfile); fclose(statusfile); //free(lineval); //free(linekey); //free(sectionType); }