! . */
| 7589 | |
| 7590 | /*! . */ |
| 7591 | GMT_LOCAL void *gmtapi_get_data (void *V_API, int object_ID, unsigned int mode, void *data) { |
| 7592 | /* Function to import registered data sources directly into program memory as a set (not record-by-record). |
| 7593 | * data is pointer to an existing grid container when we read a grid in two steps, otherwise use NULL. |
| 7594 | * ID is the registered resource from which to import. |
| 7595 | * Return: Pointer to data container, or NULL if there were errors (passed back via API->error). |
| 7596 | */ |
| 7597 | int item, family, flag = GMT_NOTSET; |
| 7598 | bool was_enabled; |
| 7599 | void *new_obj = NULL; |
| 7600 | struct GMTAPI_DATA_OBJECT *S_obj = NULL; |
| 7601 | struct GMTAPI_CTRL *API = NULL; |
| 7602 | |
| 7603 | if (V_API == NULL) return_null (V_API, GMT_NOT_A_SESSION); |
| 7604 | |
| 7605 | /* Determine the item in the object list that matches this ID and direction */ |
| 7606 | API = gmtapi_get_api_ptr (V_API); |
| 7607 | API->error = GMT_NOERROR; |
| 7608 | if (object_ID == GMT_NOTSET) { /* Must pick up the family from the shelf */ |
| 7609 | family = API->shelf; |
| 7610 | API->shelf = GMT_NOTSET; |
| 7611 | if (multiple_files_ok(family)) flag = (API->module_input) ? GMTAPI_MODULE_INPUT : GMTAPI_OPTION_INPUT; |
| 7612 | } |
| 7613 | else |
| 7614 | family = GMT_NOTSET; |
| 7615 | if ((item = gmtlib_validate_id (API, family, object_ID, GMT_IN, flag)) == GMT_NOTSET) { |
| 7616 | return_null (API, API->error); |
| 7617 | } |
| 7618 | |
| 7619 | was_enabled = API->io_enabled[GMT_IN]; |
| 7620 | if (!was_enabled && gmtapi_begin_io (API, GMT_IN) != GMT_NOERROR) { /* Enables data input if not already set and sets access mode */ |
| 7621 | return_null (API, API->error); |
| 7622 | } |
| 7623 | S_obj = API->object[item]; /* Short-hand */ |
| 7624 | S_obj->selected = true; /* Make sure it the requested data set is selected */ |
| 7625 | |
| 7626 | /* OK, try to do the importing */ |
| 7627 | if ((new_obj = gmtapi_import_data (API, S_obj->family, object_ID, mode, data)) == NULL) { |
| 7628 | return_null (API, API->error); |
| 7629 | } |
| 7630 | |
| 7631 | if (!was_enabled && GMT_End_IO (API, GMT_IN, 0) != GMT_NOERROR) { /* Disables data input if we had to set it in this function */ |
| 7632 | return_null (API, API->error); |
| 7633 | } |
| 7634 | #ifdef DEBUG |
| 7635 | gmtapi_set_object (API, S_obj); |
| 7636 | //gmtapi_list_objects (API, "gmtapi_get_data"); |
| 7637 | #endif |
| 7638 | |
| 7639 | /* 4GMT.jl For start, copy only 64 columns instead of the GMT_MAX_COLUMNS |
| 7640 | Don't change anything here without consulting with GMT.jl side |
| 7641 | */ |
| 7642 | gmt_M_memcpy (&API->jl_pocket.col_type[0], &API->GMT->current.io.col_type[0], 64, int); |
| 7643 | gmt_M_memcpy (&API->jl_pocket.col_type[1], &API->GMT->current.io.col_type[1], 64, int); |
| 7644 | |
| 7645 | return (new_obj); /* Return pointer to the data container */ |
| 7646 | } |
| 7647 | |
| 7648 | GMT_LOCAL void gmtapi_reconsider_messenger (struct GMTAPI_CTRL *API, struct GMTAPI_DATA_OBJECT *S_obj) { |
no test coverage detected