Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
/* output to strings */
stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
stardata->preferences->batchmode = BATCHMODE_LIBRARY;
/* Ask the help api */
binary_c_help_all(stardata);
/* get buffer pointer */
binary_c_buffer_info(stardata, buffer, nbytes);
/* get error buffer pointer */
binary_c_error_buffer(stardata, error_buffer);
/* free stardata (except the buffer) */
binary_c_free_memory(&stardata, // Stardata
TRUE, // free_preferences
TRUE, // free_stardata
TRUE, // free_store
FALSE, // free_raw_buffer
TRUE // free_persistent
);
return 0;
}
int return_version_info(char ** const buffer,
char ** const error_buffer,
size_t * const nbytes)
{
struct libbinary_c_stardata_t *stardata = NULL;
struct libbinary_c_store_t * store = NULL;
char * empty_str = "";
/* Set up new system */
binary_c_new_system(&stardata, // stardata
NULL, // previous_stardatas
NULL, // preferences
&store, // store
NULL, // persistent_data
&empty_str, // argv
-1 // argc
);
/* output to strings */
stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
stardata->preferences->batchmode = BATCHMODE_LIBRARY;
/* Ask the help api */
binary_c_version(stardata);
/* get buffer pointer */
binary_c_buffer_info(stardata, buffer, nbytes);
/* get error buffer pointer */
binary_c_error_buffer(stardata, error_buffer);
/* free stardata (except the buffer) */
binary_c_free_memory(&stardata, // Stardata
TRUE, // free_preferences
TRUE, // free_stardata
TRUE, // free_store
FALSE, // free_raw_buffer
TRUE // free_persistent
);
return 0;
}
David Hendriks
committed
int return_minimum_orbit_for_RLOF(char * argstring,
struct libbinary_c_store_t * store,
David Hendriks
committed
char ** buffer,
char ** error_buffer,
size_t * nbytes)
{
/*
* Return the binary_c minimum orbit (separation or period)
* that leads to RLOF
*/
David Hendriks
committed
/* memory for system */
struct libbinary_c_stardata_t *stardata = NULL;
/* Determine whether to free the store memory adress*/
Boolean free_store = FALSE;
if (store==NULL)
David Hendriks
committed
{
debug_printf("Decided to free the store memaddr\n");
free_store = TRUE;
David Hendriks
committed
}
David Hendriks
committed
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
binary_c_new_system(&stardata,
NULL,
NULL,
&store,
NULL,
&argstring,
-1);
// Set preferences.
stardata->preferences->show_minimum_separation_for_instant_RLOF = TRUE;
stardata->preferences->show_minimum_orbital_period_for_instant_RLOF = TRUE;
snprintf(stardata->preferences->log_filename,
STRING_LENGTH-1,"%s","/dev/null");
snprintf(stardata->preferences->api_log_filename_prefix,
STRING_LENGTH-1,"%s","/dev/null");
stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
stardata->preferences->batchmode = BATCHMODE_LIBRARY;
/* Actually show the instant_rlof */
binary_c_show_instant_RLOF(stardata); // prints to the buffer.
/* put results in buffer */
binary_c_buffer_info(stardata, buffer, nbytes);
/* Put errors in error buffer */
binary_c_error_buffer(stardata, error_buffer);
David Hendriks
committed
Boolean free_persistent_data = FALSE;
/* free stardata (except the buffer) */
binary_c_free_memory(&stardata, // Stardata
TRUE, // free_preferences
TRUE, // free_stardata
free_store, // free_store
FALSE, // free_raw_buffer TODO: fix this
free_persistent_data // free_persistent // TODO FIX THIS.
);
return 0;
}
/* =================================================================== */
/* =================================================================== */
struct libbinary_c_store_t * return_store_memaddr(char ** const buffer,
char ** const error_buffer,
size_t * const nbytes)
{
struct libbinary_c_stardata_t * stardata = NULL;
struct libbinary_c_store_t * store = NULL;
char * empty_str = "";
/* Set up new system */
binary_c_new_system(&stardata, // stardata
NULL, // previous_stardatas
NULL, // preferences
&store, // store
NULL, // persistent_data
&empty_str, // argv
-1 // argc
);
/* output to strings */
stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
stardata->preferences->batchmode = BATCHMODE_LIBRARY;
/* get buffer pointer */
binary_c_buffer_info(stardata, buffer, nbytes);
/* get error buffer pointer */
binary_c_error_buffer(stardata, error_buffer);
/* free stardata (except the buffer and the store) */
binary_c_free_memory(&stardata, // Stardata
TRUE, // free_preferences
TRUE, // free_stardata
FALSE, // free_store
FALSE, // free_raw_buffer
TRUE // free_persistent
);
/* Return the memaddr as an int */
debug_printf("Returning store pointer %p\n", store);
return store;
struct persistent_data_t * return_persistent_data_memaddr(char ** const buffer,
char ** const error_buffer,
size_t * const nbytes)
{
/* Function to allocate the persistent_data_memaddr */
struct libbinary_c_stardata_t *stardata = NULL;
struct libbinary_c_store_t * store = NULL;
struct persistent_data_t * persistent_data = NULL;
char * empty_str = "";
/* Set up new system */
binary_c_new_system(&stardata, // stardata
NULL, // previous_stardatas
NULL, // preferences
&store, // store
&persistent_data, // persistent_data
&empty_str, // argv
-1 // argc
);
// uintptr_t persistent_data = (uintptr_t)stardata->persistent_data;
persistent_data = stardata->persistent_data;
/* get buffer pointer */
binary_c_buffer_info(stardata, buffer, nbytes);
/* get error buffer pointer */
binary_c_error_buffer(stardata, error_buffer);
/* free stardata (except the buffer and the persistent data) */
binary_c_free_memory(&stardata, // Stardata
TRUE, // free_preferences
TRUE, // free_stardata
TRUE, // free_store
FALSE, // free_raw_buffer
FALSE // free_persistent
);
/* Return the pointer */
debug_printf("Returning persistent_data pointer %p\n", persistent_data);
return persistent_data;
}
/* =================================================================== */
/* =================================================================== */
int free_persistent_data_memaddr_and_return_json_output(struct persistent_data_t * persistent_data,
char ** const buffer,
char ** const error_buffer,
size_t * const nbytes)
{
struct libbinary_c_store_t *store = NULL;
struct libbinary_c_stardata_t *stardata = NULL;
char * empty_str = "";
debug_printf("Freeing persistent_data pointer %p\n", persistent_data);
/* Set up new system */
binary_c_new_system(&stardata, // stardata
NULL, // previous_stardatas
NULL, // preferences
&store, // store
&persistent_data, // persistent_data
&empty_str, // argv
-1 // argc
);
debug_printf("Freed persistent_data pointer.\n");
/* Set the model hash (usually done internally but we're not evolving a system here */
stardata->model.ensemble_hash = stardata->persistent_data->ensemble_hash;
/* output to strings */
stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
stardata->preferences->batchmode = BATCHMODE_LIBRARY;
/* get output and free memory */
binary_c_output_to_json(stardata);
/* get buffer pointer */
binary_c_buffer_info(stardata, buffer, nbytes);
/* get error buffer pointer */
binary_c_error_buffer(stardata, error_buffer);
/* free the reststardata (except the buffer) */
binary_c_free_memory(&stardata, // Stardata
TRUE, // free_preferences
TRUE, // free_stardata
TRUE, // free_store
FALSE, // free_raw_buffer
FALSE // free_persistent. It already to be sure
int free_store_memaddr(struct libbinary_c_store_t * store,
char ** const buffer,
char ** const error_buffer,
size_t * const nbytes)
{
struct libbinary_c_stardata_t *stardata = NULL;
struct libbinary_c_persistent_data_t *persistent_data = NULL;
char * empty_str = "";
debug_printf("Freeing store pointer %p\n", store);
/* Set up new system */
binary_c_new_system(&stardata, // stardata
NULL, // previous_stardatas
NULL, // preferences
&store, // store
&persistent_data, // persistent_data
&empty_str, // argv
-1 // argc
);
debug_printf("freed store memaddr\n");
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
/* output to strings */
stardata->preferences->internal_buffering = INTERNAL_BUFFERING_STORE;
stardata->preferences->batchmode = BATCHMODE_LIBRARY;
/* get buffer pointer */
binary_c_buffer_info(stardata, buffer, nbytes);
/* get error buffer pointer */
binary_c_error_buffer(stardata, error_buffer);
/* free the reststardata (except the buffer) */
binary_c_free_memory(&stardata, // Stardata
TRUE, // free_preferences
TRUE, // free_stardata
TRUE, // free_store
FALSE, // free_raw_buffer
TRUE // free_persistent
);
return 0;
}