diff --git a/contribs/phpext/slurm_php/config.m4.in b/contribs/phpext/slurm_php/config.m4.in index 16663776070eb6e1ee4ea858a09d80a3a70bdf21..c60eda7fd38a0720358466bc123c3c6a25b9eef5 100644 --- a/contribs/phpext/slurm_php/config.m4.in +++ b/contribs/phpext/slurm_php/config.m4.in @@ -62,6 +62,7 @@ if test "$PHP_SLURM" != "no"; then PHP_SUBST(SLURM_PHP_SHARED_LIBADD) AC_CHECK_HEADERS(stdbool.h) + AC_CHECK_HEADERS(xmalloc.h) AC_DEFINE(HAVE_SLURM_PHP, 1, [Whether you have SLURM]) #PHP_EXTENSION(slurm_php, $ext_shared) diff --git a/contribs/phpext/slurm_php/slurm_php.c b/contribs/phpext/slurm_php/slurm_php.c index 42db96c40c8f6495a452d2d81215de72744beb54..03a6d984e5cfbc14ec46718df670606c4c7c3a2e 100644 --- a/contribs/phpext/slurm_php/slurm_php.c +++ b/contribs/phpext/slurm_php/slurm_php.c @@ -90,12 +90,17 @@ zend_module_entry slurm_php_module_entry = { ZEND_GET_MODULE(slurm_php) #endif +#ifdef HAVE_XMALLOC_H +#define malloc(size) xmalloc(size) +#define free(ptr) xfree(ptr) +#endif + /*****************************************************************************\ * TODO ***************************************************************************** * [ADJUSTING EXISTING FUNCTIONS] - * - parse_node_pointer + * - _parse_node_pointer * dynamic_plugin_data_t is currently not returned * [EXTRA FUNCTIONS] * - Functions that filter jobs on the nodes they are running on @@ -107,37 +112,13 @@ ZEND_GET_MODULE(slurm_php) * HELPER FUNCTIONS \*****************************************************************************/ -time_t now() -{ - return time(NULL); -} - - -int ld_partition_info(partition_info_msg_t **part_pptr, uint16_t show_flags) -{ - return slurm_load_partitions(now(), part_pptr, show_flags); -} - - -int ld_node_info(node_info_msg_t **node_pptr, uint16_t show_flags) -{ - return slurm_load_node(now(), node_pptr, show_flags); -} - - -int ld_job_info(job_info_msg_t **job_pptr, uint16_t show_flags) -{ - return slurm_load_jobs(now(), job_pptr, show_flags); -} - - -void parse_node_pointer(zval *sub_arr, node_info_t *node_arr) +void _parse_node_pointer(zval *sub_arr, node_info_t *node_arr) { zval *sub_arr_2 = NULL; - zend_add_valid_assoc_string(sub_arr, "Name", node_arr->name); - zend_add_valid_assoc_string(sub_arr, "Arch.", node_arr->arch); - zend_add_valid_assoc_time_string(sub_arr, "Boot Time", + _zend_add_valid_assoc_string(sub_arr, "Name", node_arr->name); + _zend_add_valid_assoc_string(sub_arr, "Arch.", node_arr->arch); + _zend_add_valid_assoc_time_string(sub_arr, "Boot Time", &node_arr->boot_time); add_assoc_long(sub_arr, "#CPU'S", node_arr->cpus); add_assoc_long(sub_arr, "#Cores/CPU", node_arr->cores); @@ -147,19 +128,19 @@ void parse_node_pointer(zval *sub_arr, node_info_t *node_arr) } else { ALLOC_INIT_ZVAL(sub_arr_2); array_init(sub_arr_2); - parse_array(node_arr->features, ",", sub_arr_2); + _parse_array(node_arr->features, ",", sub_arr_2); add_assoc_zval(sub_arr, "Features", sub_arr_2); } - zend_add_valid_assoc_string(sub_arr, "GRES", node_arr->gres); + _zend_add_valid_assoc_string(sub_arr, "GRES", node_arr->gres); add_assoc_long(sub_arr, "State", node_arr->node_state); - zend_add_valid_assoc_string(sub_arr, "OS", node_arr->os); + _zend_add_valid_assoc_string(sub_arr, "OS", node_arr->os); add_assoc_long(sub_arr, "Real Mem", node_arr->real_memory); if (node_arr->reason!=NULL) { - zend_add_valid_assoc_string(sub_arr, "Reason", + _zend_add_valid_assoc_string(sub_arr, "Reason", node_arr->reason); - zend_add_valid_assoc_time_string(sub_arr,"Reason Timestamp", + _zend_add_valid_assoc_time_string(sub_arr,"Reason Timestamp", &node_arr->reason_time); add_assoc_long(sub_arr, "Reason User Id", node_arr->reason_uid); @@ -169,7 +150,7 @@ void parse_node_pointer(zval *sub_arr, node_info_t *node_arr) add_assoc_null(sub_arr, "Reason User Id"); } - zend_add_valid_assoc_time_string(sub_arr, "Slurmd Startup Time", + _zend_add_valid_assoc_time_string(sub_arr, "Slurmd Startup Time", &node_arr->slurmd_start_time); add_assoc_long(sub_arr, "#Sockets/Node", node_arr->sockets); add_assoc_long(sub_arr, "#Threads/Core", node_arr->threads); @@ -178,7 +159,7 @@ void parse_node_pointer(zval *sub_arr, node_info_t *node_arr) } -void parse_assoc_array(char *char_arr, char *delims, zval *result_arr) +void _parse_assoc_array(char *char_arr, char *delims, zval *result_arr) { char *rslt = NULL; char *tmp; @@ -192,7 +173,7 @@ void parse_assoc_array(char *char_arr, char *delims, zval *result_arr) if (strcmp(rslt,"(null)")==0) { add_assoc_null(result_arr, tmp); } else { - zend_add_valid_assoc_string(result_arr, + _zend_add_valid_assoc_string(result_arr, tmp, rslt); } } @@ -205,53 +186,40 @@ void parse_assoc_array(char *char_arr, char *delims, zval *result_arr) } -void parse_array(char *char_arr, char *delims, zval *rslt_arr) +void _parse_array(char *char_arr, char *delims, zval *rslt_arr) { char *rslt = NULL; + char *tmp = NULL; rslt = strtok(char_arr, delims); while (rslt != NULL) { if (strcmp(rslt,"(null)")==0) { add_next_index_null(rslt_arr); } else { - add_next_index_string(rslt_arr, rslt, 1); + tmp = malloc(strlen(rslt) + 1); + strcpy(tmp,rslt); + add_next_index_string(rslt_arr, tmp, 1); + free(tmp); } rslt = strtok(NULL, delims); } } - -partition_info_t *get_partition_from_name(char *name, - partition_info_t *prt_data, - partition_info_msg_t *prt_ptr) -{ - int i; - - if (prt_ptr->record_count != 0) { - for (i = 0; i < prt_ptr->record_count; i++) { - if (strcmp(prt_ptr->partition_array->name, name) == 0) { - prt_data = prt_ptr->partition_array; - break; - } - prt_ptr->partition_array++; - } - } - - return prt_data; -} - - -void zend_add_valid_assoc_string(zval *rstl_arr, char *key, char *val) +void _zend_add_valid_assoc_string(zval *rstl_arr, char *key, char *val) { + char *tmp = NULL; if (val==NULL) { add_assoc_null(rstl_arr, key); } else { - add_assoc_string(rstl_arr, key, val, 1); + tmp = malloc(strlen(val) + 1); + strcpy(tmp,val); + add_assoc_string(rstl_arr, key, tmp, 1); + free(tmp); } } -void zend_add_valid_assoc_time_string(zval *rstl_arr, char *key, time_t *val) +void _zend_add_valid_assoc_time_string(zval *rstl_arr, char *key, time_t *val) { char buf[80]; struct tm *timeinfo; @@ -285,7 +253,7 @@ PHP_FUNCTION(slurm_ping) PHP_FUNCTION(slurm_slurmd_status) { int err = SLURM_SUCCESS; - static slurmd_status_t *status_ptr = NULL; + slurmd_status_t *status_ptr = NULL; err = slurm_load_slurmd_status(&status_ptr); if (err) { @@ -293,9 +261,9 @@ PHP_FUNCTION(slurm_slurmd_status) } array_init(return_value); - zend_add_valid_assoc_time_string(return_value,"Booted_at", + _zend_add_valid_assoc_time_string(return_value,"Booted_at", &status_ptr->booted); - zend_add_valid_assoc_time_string(return_value,"Last_Msg", + _zend_add_valid_assoc_time_string(return_value,"Last_Msg", &status_ptr->last_slurmctld_msg); add_assoc_long(return_value,"Logging_Level", status_ptr->slurmd_debug); add_assoc_long(return_value,"Actual_CPU's", status_ptr->actual_cpus); @@ -309,14 +277,18 @@ PHP_FUNCTION(slurm_slurmd_status) add_assoc_long(return_value,"Actual_Tmp_Disk", status_ptr->actual_tmp_disk); add_assoc_long(return_value,"PID",status_ptr->pid); - zend_add_valid_assoc_string(return_value, "Hostname", + _zend_add_valid_assoc_string(return_value, "Hostname", status_ptr->hostname); - zend_add_valid_assoc_string(return_value, "Slurm Logfile", + _zend_add_valid_assoc_string(return_value, "Slurm Logfile", status_ptr->slurmd_logfile); - zend_add_valid_assoc_string(return_value, "Step List", + _zend_add_valid_assoc_string(return_value, "Step List", status_ptr->step_list); - zend_add_valid_assoc_string(return_value, "Version", + _zend_add_valid_assoc_string(return_value, "Version", status_ptr->version); + + if (status_ptr != NULL) { + slurm_free_slurmd_status(status_ptr); + } } @@ -426,7 +398,7 @@ PHP_FUNCTION(slurm_array_to_hostlist) array_init(return_value); buf = slurm_hostlist_ranged_string_xmalloc(hl); - zend_add_valid_assoc_string(return_value,"HOSTLIST",buf); + _zend_add_valid_assoc_string(return_value,"HOSTLIST",buf); } @@ -438,23 +410,33 @@ PHP_FUNCTION(slurm_print_partition_names) { int err = SLURM_SUCCESS; int i; - static partition_info_msg_t *prt_ptr = NULL; + partition_info_msg_t *prt_ptr = NULL; + char *tmp; + + err = slurm_load_partitions((time_t) NULL, &prt_ptr, 0); - err = ld_partition_info(&prt_ptr, 0); if (err) { RETURN_LONG(-2); } - if (prt_ptr->record_count == 0) { - RETURN_LONG(-1); - } - array_init(return_value); for (i = 0; i < prt_ptr->record_count; i++) { + tmp = malloc(strlen(prt_ptr->partition_array->name)+1); + strcpy(tmp,prt_ptr->partition_array->name); add_next_index_string(return_value, - prt_ptr->partition_array->name, 1); + tmp, 1); + free(tmp); prt_ptr->partition_array++; } + + if(prt_ptr != NULL) { + prt_ptr->partition_array -= i; + slurm_free_partition_info_msg(prt_ptr); + } + + if (i == 0) { + RETURN_LONG(-1); + } } @@ -462,10 +444,13 @@ PHP_FUNCTION(slurm_get_specific_partition_info) { long lngth = 0; int err = SLURM_SUCCESS; - static partition_info_msg_t *prt_ptr = NULL; + partition_info_msg_t *prt_ptr = NULL; partition_info_t *prt_data = NULL; + partition_info_t *prt_data_tmp = NULL; char *name = NULL; char *tmp = NULL; + int i = 0; + int y = 0; if (zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC, "s|d", &name, &lngth) == FAILURE) { @@ -476,19 +461,34 @@ PHP_FUNCTION(slurm_get_specific_partition_info) RETURN_LONG(-3); } - err = ld_partition_info(&prt_ptr,0); + err = slurm_load_partitions((time_t) NULL, &prt_ptr, 0); + if (err) { RETURN_LONG(-2); } - prt_data = get_partition_from_name(name, prt_data, prt_ptr); - if (prt_data == NULL) { - RETURN_LONG(-1); + if (prt_ptr->record_count != 0) { + for (i = 0; i < prt_ptr->record_count; i++) { + if (strcmp(prt_ptr->partition_array->name, name) == 0) { + prt_data = prt_ptr->partition_array; + tmp = slurm_sprint_partition_info(prt_data, 1); + array_init(return_value); + _parse_assoc_array(tmp, "= ", return_value); + y++; + break; + } + prt_ptr->partition_array++; + } } - tmp = slurm_sprint_partition_info(prt_data, 1); - array_init(return_value); - parse_assoc_array(tmp, "= ", return_value); + if(prt_ptr != NULL) { + prt_ptr->partition_array -= i; + slurm_free_partition_info_msg(prt_ptr); + } + + if (y == 0) { + RETURN_LONG(-1); + } } @@ -497,9 +497,11 @@ PHP_FUNCTION(slurm_get_partition_node_names) char *prt_name = NULL; long lngth = 0; int err = SLURM_SUCCESS; - static partition_info_msg_t *prt_ptr = NULL; + partition_info_msg_t *prt_ptr = NULL; partition_info_t *prt_data = NULL; char *tmp = NULL; + int i = 0; + int y = 0; if (zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC, "s|d", &prt_name, &lngth) == FAILURE) { @@ -510,19 +512,36 @@ PHP_FUNCTION(slurm_get_partition_node_names) RETURN_LONG(-3); } - err = ld_partition_info(&prt_ptr,0); + err = slurm_load_partitions((time_t) NULL, &prt_ptr, 0); if (err) { RETURN_LONG(-2); } - prt_data = get_partition_from_name(prt_name, prt_data, prt_ptr); - if (prt_data == NULL) { - RETURN_LONG(-1); + if (prt_ptr->record_count != 0) { + for (i = 0; i < prt_ptr->record_count; i++) { + if (strcmp(prt_ptr->partition_array->name, prt_name) == 0) { + prt_data = prt_ptr->partition_array; + array_init(return_value); + tmp = malloc(strlen(prt_data->nodes)+1); + strcpy(tmp,prt_data->nodes); + add_next_index_string(return_value,tmp,1); + free(tmp); + y++; + break; + } + prt_ptr->partition_array++; + } } - array_init(return_value); - add_next_index_string(return_value,prt_data->nodes,1); + if(prt_ptr != NULL) { + prt_ptr->partition_array -= i; + slurm_free_partition_info_msg(prt_ptr); + } + + if (y == 0) { + RETURN_LONG(-1); + } } @@ -534,21 +553,30 @@ PHP_FUNCTION(slurm_get_node_names) { int err = SLURM_SUCCESS; int i = 0; - static node_info_msg_t *node_ptr; + node_info_msg_t *node_ptr = NULL; + char *tmp; - err = ld_node_info(&node_ptr,0); + err = slurm_load_node((time_t) NULL, &node_ptr, 0); if (err) { RETURN_LONG(-2); } - if (node_ptr->record_count != 0) { + if (node_ptr->record_count > 0) { array_init(return_value); for (i = 0; i < node_ptr->record_count; i++) { - add_next_index_string(return_value, - node_ptr->node_array->name, 1); + tmp = malloc(strlen(node_ptr->node_array->name)); + strcpy(tmp,node_ptr->node_array->name); + add_next_index_string(return_value,tmp, 1); + free(tmp); node_ptr->node_array++; } - } else { + } + + if (node_ptr != NULL) { + node_ptr->node_array-=i; + slurm_free_node_info_msg(node_ptr); + } + if(i==0) { RETURN_LONG(-1); } } @@ -558,26 +586,37 @@ PHP_FUNCTION(slurm_get_node_elements) { int err = SLURM_SUCCESS; int i = 0; - static node_info_msg_t *node_ptr; + node_info_msg_t *node_ptr; zval *sub_arr = NULL; + char *tmp; - err = ld_node_info(&node_ptr,0); + err = slurm_load_node((time_t) NULL, &node_ptr, 0); if (err) { RETURN_LONG(-2); } - if (node_ptr->record_count == 0) { - RETURN_LONG(-1); + if (node_ptr->record_count > 0) { + array_init(return_value); + for (i = 0; i < node_ptr->record_count; i++) { + ALLOC_INIT_ZVAL(sub_arr); + array_init(sub_arr); + _parse_node_pointer(sub_arr, node_ptr->node_array); + tmp = malloc(strlen(node_ptr->node_array->name)+1); + strcpy(tmp,node_ptr->node_array->name); + add_assoc_zval(return_value, tmp, + sub_arr); + free(tmp); + node_ptr->node_array++; + } } - array_init(return_value); - for (i = 0; i < node_ptr->record_count; i++) { - ALLOC_INIT_ZVAL(sub_arr); - array_init(sub_arr); - parse_node_pointer(sub_arr, node_ptr->node_array); - add_assoc_zval(return_value, node_ptr->node_array->name, - sub_arr); - node_ptr->node_array++; + if (node_ptr != NULL) { + node_ptr->node_array -= i; + slurm_free_node_info_msg(node_ptr); + } + + if(i==0) { + RETURN_LONG(-1); } } @@ -586,7 +625,7 @@ PHP_FUNCTION(slurm_get_node_element_by_name) { int err = SLURM_SUCCESS; int i = 0,y = 0; - static node_info_msg_t *node_ptr; + node_info_msg_t *node_ptr; char *node_name = NULL; long lngth; zval *sub_arr = NULL; @@ -600,30 +639,32 @@ PHP_FUNCTION(slurm_get_node_element_by_name) RETURN_LONG(-3); } - err = ld_node_info(&node_ptr,0); + err = slurm_load_node((time_t) NULL, &node_ptr, 0); if (err) { RETURN_LONG(-2); } - if (node_ptr->record_count == 0) { - RETURN_LONG(-1); - } - array_init(return_value); + for (i = 0; i < node_ptr->record_count; i++) { if (strcmp(node_ptr->node_array->name, node_name) == 0) { y++; ALLOC_INIT_ZVAL(sub_arr); array_init(sub_arr); - parse_node_pointer(sub_arr, node_ptr->node_array); - add_assoc_zval(return_value, node_ptr->node_array->name, + _parse_node_pointer(sub_arr, node_ptr->node_array); + add_assoc_zval(return_value, node_name, sub_arr); break; } node_ptr->node_array++; } - if (y==0) { + if (node_ptr != NULL) { + node_ptr->node_array -= i; + slurm_free_node_info_msg(node_ptr); + } + + if (y == 0) { RETURN_LONG(-1); } } @@ -633,7 +674,7 @@ PHP_FUNCTION(slurm_get_node_state_by_name) { int err = SLURM_SUCCESS; int i = 0,y = 0; - static node_info_msg_t *node_ptr; + node_info_msg_t *node_ptr; char *node_name = NULL; long lngth; @@ -646,15 +687,11 @@ PHP_FUNCTION(slurm_get_node_state_by_name) RETURN_LONG(-3); } - err = ld_node_info(&node_ptr,0); + err = slurm_load_node((time_t) NULL, &node_ptr, 0); if (err) { RETURN_LONG(-2); } - if (node_ptr->record_count == 0) { - RETURN_LONG(-1); - } - for (i = 0; i < node_ptr->record_count; i++) { if (strcmp(node_ptr->node_array->name, node_name) == 0) { y++; @@ -664,6 +701,15 @@ PHP_FUNCTION(slurm_get_node_state_by_name) node_ptr->node_array++; } + if(node_ptr != NULL) { + node_ptr->node_array -= i; + slurm_free_node_info_msg(node_ptr); + } + + if (i == 0) { + RETURN_LONG(-1); + } + if (y==0) { RETURN_LONG(-1); } @@ -674,24 +720,29 @@ PHP_FUNCTION(slurm_get_node_states) { int err = SLURM_SUCCESS; int i = 0; - static node_info_msg_t *node_ptr; + node_info_msg_t *node_ptr; zval *sub_arr = NULL; - err = ld_node_info(&node_ptr,0); + err = slurm_load_node((time_t) NULL, &node_ptr, 0); if (err) { RETURN_LONG(-2); } - if (node_ptr->record_count == 0) { - RETURN_LONG(-1); - } - array_init(return_value); for (i = 0; i < node_ptr->record_count; i++) { add_next_index_long(return_value, node_ptr->node_array->node_state); node_ptr->node_array++; } + + if (node_ptr != NULL) { + node_ptr->node_array -= i; + slurm_free_node_info_msg(node_ptr); + } + + if (i == 0) { + RETURN_LONG(-1); + } } @@ -702,12 +753,12 @@ PHP_FUNCTION(slurm_get_node_states) PHP_FUNCTION(slurm_get_control_configuration_keys) { int err = SLURM_SUCCESS; - static slurm_ctl_conf_t *ctrl_conf_ptr; + slurm_ctl_conf_t *ctrl_conf_ptr; List lst; ListIterator iter = NULL; key_pair_t *k_p; - err = slurm_load_ctl_conf(now(), &ctrl_conf_ptr); + err = slurm_load_ctl_conf((time_t) NULL, &ctrl_conf_ptr); if (err) { RETURN_LONG(-2); } @@ -722,18 +773,20 @@ PHP_FUNCTION(slurm_get_control_configuration_keys) while ((k_p = slurm_list_next(iter))) { add_next_index_string(return_value,k_p->name, 1); } + + slurm_free_ctl_conf(ctrl_conf_ptr); } PHP_FUNCTION(slurm_get_control_configuration_values) { int err = SLURM_SUCCESS; - static slurm_ctl_conf_t *ctrl_conf_ptr; + slurm_ctl_conf_t *ctrl_conf_ptr; List lst; ListIterator iter = NULL; key_pair_t *k_p; - err = slurm_load_ctl_conf(now(), &ctrl_conf_ptr); + err = slurm_load_ctl_conf((time_t) NULL, &ctrl_conf_ptr); if (err) { RETURN_LONG(-2); } @@ -752,6 +805,8 @@ PHP_FUNCTION(slurm_get_control_configuration_values) add_next_index_string(return_value, k_p->value, 1); } } + + slurm_free_ctl_conf(ctrl_conf_ptr); } @@ -763,31 +818,36 @@ PHP_FUNCTION(slurm_load_job_information) { int err = SLURM_SUCCESS; int i = 0; - static job_info_msg_t *job_ptr; + job_info_msg_t *job_ptr; zval *sub_arr = NULL; char *tmp; - err = ld_job_info(&job_ptr,0); + err = slurm_load_jobs((time_t) NULL, &job_ptr, 0); if (err) { RETURN_LONG(-2); } - if (job_ptr->record_count == 0) { - RETURN_LONG(-1); - } - array_init(return_value); for (i = 0; i < job_ptr->record_count; i++) { tmp = malloc(sizeof(uint32_t) + 1); sprintf(tmp, "%d", job_ptr->job_array->job_id); ALLOC_INIT_ZVAL(sub_arr); array_init(sub_arr); - parse_assoc_array(slurm_sprint_job_info(job_ptr->job_array, 1), + _parse_assoc_array(slurm_sprint_job_info(job_ptr->job_array, 1), "= ", sub_arr); add_assoc_zval(return_value, tmp, sub_arr); job_ptr->job_array++; free(tmp); } + + if (job_ptr != NULL) { + job_ptr->job_array -= i; + slurm_free_job_info_msg(job_ptr); + } + + if (i == 0) { + RETURN_LONG(-1); + } } @@ -795,7 +855,7 @@ PHP_FUNCTION(slurm_load_partition_jobs) { int err = SLURM_SUCCESS; int i = 0; - static job_info_msg_t *job_ptr; + job_info_msg_t *job_ptr; zval *sub_arr = NULL; char *tmp; char *pname = NULL; @@ -811,15 +871,11 @@ PHP_FUNCTION(slurm_load_partition_jobs) RETURN_LONG(-3); } - err = ld_job_info(&job_ptr,0); + err = slurm_load_jobs((time_t) NULL, &job_ptr, 0); if (err) { RETURN_LONG(-2); } - if (job_ptr->record_count == 0) { - RETURN_LONG(-1); - } - array_init(return_value); for (i = 0; i < job_ptr->record_count; i++) { if (!strcmp(job_ptr->job_array->partition, pname)) { @@ -828,7 +884,7 @@ PHP_FUNCTION(slurm_load_partition_jobs) sprintf(tmp, "%d", job_ptr->job_array->job_id); ALLOC_INIT_ZVAL(sub_arr); array_init(sub_arr); - parse_assoc_array( + _parse_assoc_array( slurm_sprint_job_info(job_ptr->job_array, 1), "= ", sub_arr); add_assoc_zval(return_value, tmp, sub_arr); @@ -837,6 +893,15 @@ PHP_FUNCTION(slurm_load_partition_jobs) job_ptr->job_array++; } + if (job_ptr != NULL) { + job_ptr->job_array -= i; + slurm_free_job_info_msg(job_ptr); + } + + if (i == 0) { + RETURN_LONG(-1); + } + if (checker==0) { RETURN_LONG(-1); } diff --git a/contribs/phpext/slurm_php/slurm_php.h b/contribs/phpext/slurm_php/slurm_php.h index e3efc7da7540ef047281d6c05afe74fd7fdb1449..89abaca2506eb8d7d6acf6590c884daf76b1bbe5 100644 --- a/contribs/phpext/slurm_php/slurm_php.h +++ b/contribs/phpext/slurm_php/slurm_php.h @@ -38,7 +38,7 @@ #ifndef SLURM_PHP_H #define SLURM_PHP_H 1 -#define SLURM_PHP_VERSION "1.0" +#define SLURM_PHP_VERSION "1.0.1" #define SLURM_PHP_EXTNAME "slurm" /* * Adjust this value to change the format of the returned string @@ -54,6 +54,7 @@ #include <slurm/slurmdb.h> #include <time.h> +#include <string.h> #include <stdlib.h> extern zend_module_entry slurm_php_module_entry; @@ -73,53 +74,17 @@ typedef struct key_value { \*****************************************************************************/ /* - * now - Get the current time - * RET time_t * : Pointer to the memory holding the current time - */ -time_t now(); - -/* - * ld_partition_info - Issue slurm to load the partition info into part_pptr - * - * IN part_pptr - place to store a partition configuration pointer - * IN show_flags - partition filtering options - * RET 0 or a slurm error code - * NOTE: free the response using slurm_free_partition_info_msg - */ -int ld_partition_info(partition_info_msg_t **part_pptr, uint16_t show_flags); - -/* - * ld_node_info - Issue slurm to load the node info into node_pptr - * - * IN node_pptr - place to store a node configuration pointer - * IN show_flags - partition filtering options - * RET 0 or a slurm error code - * NOTE: free the response using slurm_free_node_info_msg - */ -int ld_node_info(node_info_msg_t **node_pptr, uint16_t show_flags); - -/* - * ld_job_info - Issue slurm to load the job info into job_pptr - * - * IN job_pptr - place to store a node configuration pointer - * IN show_flags - partition filtering options - * RET 0 or a slurm error code - * NOTE: free the response using slurm_free_job_info_msg - */ -int ld_job_info(job_info_msg_t **job_pptr, uint16_t show_flags); - -/* - * parse_node_pointer - Parse a node pointer's contents into an + * _parse_node_pointer - Parse a node pointer's contents into an * assocative zval array where the key is descriptive to the * value * * IN sub_arr - array to store the contents of the node pointer * IN node_arr - node pointer that needs parsing */ -void parse_node_pointer(zval *sub_arr, node_info_t *node_arr); +void _parse_node_pointer(zval *sub_arr, node_info_t *node_arr); /* - * parse_assoc_array - Parse a character array where the elements are + * _parse_assoc_array - Parse a character array where the elements are * key-value pairs separated by delimiters into an associative * array * @@ -127,35 +92,20 @@ void parse_node_pointer(zval *sub_arr, node_info_t *node_arr); * IN delims - character array that contains the delimeters used in parsing * IN result_arr - associative array used to store the key_value pairs in */ -void parse_assoc_array(char *char_arr, char *delims, zval *result_arr); +void _parse_assoc_array(char *char_arr, char *delims, zval *result_arr); /* - * parse_array - Parse a character array where the elements are values + * _parse_array - Parse a character array where the elements are values * separated by delimiters into a numerically indexed array * * IN char_arr - character array that needs parsing * IN delims - character array that contains the delimeters used in parsing * IN result_arr - numerically indexed array used to store the values in */ -void parse_array(char *char_arr, char *delims, zval *rslt_arr); - -/* - * get_partition_from_name - Load the information about a specific partition - * by passing on a character array containing the partition name - * - * IN name - character array containing the partition name - * IN prt_data - pointer to store the partition information in (if a - * partition is found with that specific name) - * IN prt_ptr - pointer containing all the partition information of all the - * arrays - * RET partition_info_t pointer that contains the partition data, or - * null if the partition wasn't found - */ -partition_info_t *get_partition_from_name( - char *name, partition_info_t *prt_data, partition_info_msg_t *prt_ptr); +void _parse_array(char *char_arr, char *delims, zval *rslt_arr); /* - * zend_add_valid_assoc_string - checks a character array to see if + * _zend_add_valid_assoc_string - checks a character array to see if * it's NULL or not, if so an associative null is added, if not * an associative string is added. * @@ -163,10 +113,10 @@ partition_info_t *get_partition_from_name( * IN key - character array used as the associative key * IN val - character array to be validated and added as value if valid */ -void zend_add_valid_assoc_string(zval *rstl_arr, char *key, char *val); +void _zend_add_valid_assoc_string(zval *rstl_arr, char *key, char *val); /* - * zend_add_valid_assoc_time_string - checks a unix timestamp to see if it's + * _zend_add_valid_assoc_time_string - checks a unix timestamp to see if it's * 0 or not, if so an associative null is added, if not a formatted string * is added. * @@ -176,7 +126,7 @@ void zend_add_valid_assoc_string(zval *rstl_arr, char *key, char *val); * NOTE : If you'd like to change the format in which the valid strings are * returned, you can change the TIME_FORMAT_STRING macro to the needed format */ -void zend_add_valid_assoc_time_string(zval *rstl_arr, char *key, time_t *val); +void _zend_add_valid_assoc_time_string(zval *rstl_arr, char *key, time_t *val); /*****************************************************************************\