Doxygen Source Code Documentation
niml.h File Reference
#include <stddef.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <ctype.h>#include <errno.h>#include <sys/types.h>#include <sys/stat.h>#include <string.h>#include <sys/socket.h>#include <netinet/in.h>#include <netinet/tcp.h>#include <netdb.h>#include <arpa/inet.h>#include <sys/time.h>#include <fcntl.h>#include <sys/times.h>#include <limits.h>#include <sys/ipc.h>#include <sys/shm.h>Go to the source code of this file.
Data Structures | |
| struct | complex |
| struct | DIME_message |
| struct | DIME_part |
| struct | Dtable |
| struct | Htable |
| struct | NI_affine_3dmap |
| struct | NI_byte_vector |
| struct | NI_complex_vector |
| struct | NI_dataset |
| struct | NI_double_vector |
| struct | NI_element |
| struct | NI_float_one |
| struct | NI_float_vector |
| struct | NI_group |
| struct | NI_int_vector |
| struct | NI_objcontainer |
| struct | NI_points_domain |
| struct | NI_procins |
| struct | NI_rect_domain |
| struct | NI_rgb_vector |
| struct | NI_rgba_vector |
| struct | NI_rowtype |
| struct | NI_short_vector |
| struct | NI_statistic |
| struct | NI_str_array |
| struct | NI_stream_type |
| struct | NI_string_vector |
| struct | NI_struct |
| struct | NI_vector |
| struct | rgb |
| struct | rgba |
| struct | SHMioc |
Defines | |
| #define | offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) |
| #define | NI_BYTE 0 |
| #define | NI_SHORT 1 |
| #define | NI_INT 2 |
| #define | NI_FLOAT32 3 |
| #define | NI_FLOAT NI_FLOAT32 |
| #define | NI_FLOAT64 4 |
| #define | NI_DOUBLE NI_FLOAT64 |
| #define | NI_COMPLEX64 5 |
| #define | NI_COMPLEX NI_COMPLEX64 |
| #define | NI_RGB 6 |
| #define | NI_RGBA 7 |
| #define | NI_IS_NUMERIC_TYPE(t) ( (t) >= 0 && (t) <= NI_RGBA ) |
| #define | NI_STRING 8 |
| #define | NI_NUM_TYPES 9 |
| #define | NI_NUM_BASIC_TYPES 8 |
| #define | IS_DATUM_CHAR(c) |
| #define | NI_is_builtin_type(t) ( (t) >= 0 && (t) < NI_NUM_TYPES ) |
| #define | NI_is_basic_type(t) ( (t) >= 0 && (t) < NI_NUM_BASIC_TYPES ) |
| #define | ROWTYPE_VARSIZE_MASK (1<<0) |
| #define | ROWTYPE_is_varsize(rr) (((rr)->flag & ROWTYPE_VARSIZE_MASK) != 0) |
| #define | ROWTYPE_part_dimen(rt, pt, qq) ( *((int *)( (pt) + (rt)->part_off[ (rt)->part_dim[qq] ] )) ) |
| #define | delete_rowtype(rr) |
| #define | ROWTYPE_is_basic_code NI_is_basic_type |
| #define | NI_ELEMENT_TYPE 17 |
| #define | NI_GROUP_TYPE 18 |
| #define | NI_PROCINS_TYPE 19 |
| #define | SHM_WAIT_CREATE 9 |
| #define | SHM_WAIT_ACCEPT 10 |
| #define | SHM_IS_DEAD 99 |
| #define | SHM_CREATOR 33 |
| #define | SHM_ACCEPTOR 44 |
| #define | SHM_DEFAULT_SIZE 196689 |
| #define | SHM_HSIZE 128 |
| #define | SHM_SIZE1 0 |
| #define | SHM_BSTART1 1 |
| #define | SHM_BEND1 2 |
| #define | SHM_SIZE2 3 |
| #define | SHM_BSTART2 4 |
| #define | SHM_BEND2 5 |
| #define | NI_BUFSIZE (31*1024) |
| #define | NI_TCP_TYPE 1 |
| #define | NI_FILE_TYPE 2 |
| #define | NI_STRING_TYPE 3 |
| #define | NI_REMOTE_TYPE 4 |
| #define | NI_FD_TYPE 5 |
| #define | NI_SHM_TYPE 6 |
| #define | TCP_WAIT_ACCEPT 7 |
| #define | TCP_WAIT_CONNECT 8 |
| #define | MARKED_FOR_DEATH 6666 |
| #define | NI_INPUT_MODE 0 |
| #define | NI_OUTPUT_MODE 1 |
| #define | NI_TEXT_MODE 0 |
| #define | NI_BINARY_MODE 1 |
| #define | NI_BASE64_MODE 2 |
| #define | NI_HEADERONLY_FLAG (1<<8) |
| #define | NI_HEADERSHARP_FLAG (1<<9) |
| #define | NI_LSB_FIRST 1 |
| #define | NI_MSB_FIRST 2 |
| #define | NI_ATTMODE_NORMAL 0 |
| #define | NI_ATTMODE_SPACED 1 |
| #define | NI_ATTMODE_LAST 1 |
| #define | NI_NAMEMODE_NORMAL 0 |
| #define | NI_NAMEMODE_ALIAS 1 |
| #define | NI_NAMEMODE_LAST 1 |
| #define | sizeof_Htable(ht) ((ht)->ntot) |
| #define | DIME_MB_MASK (1<<0) |
| #define | DIME_ME_MASK (1<<1) |
| #define | DIME_CF_MASK (1<<2) |
| #define | DIME_VERSION_MASK (0xf8) |
| #define | NI_malloc(typ, a) (typ*) hidden_NI_malloc((a),__FILE__,__LINE__) |
| #define | NI_calloc(a, b) hidden_NI_malloc((a)*(b),__FILE__,__LINE__) |
| #define | NI_realloc(a, typ, b) (typ*) hidden_NI_realloc((a),(b),__FILE__,__LINE__) |
| #define | NI_free(a) hidden_NI_free((a),__FILE__,__LINE__) |
| #define | NI_FREE(p) ( NI_free(p), (p)=NULL ) |
| #define | NI_new(typ) ( NI_malloc(typ, sizeof(typ)) ) |
| #define | NI_is_file(pn) (NI_filesize(pn) >= 0) |
| #define | NI_SWAP_MASK (1<<0) |
| #define | NI_LTEND_MASK (1<<1) |
| #define | NI_STREAM_CLOSE(nn) do{ NI_stream_close(nn); (nn)=NULL; } while(0) |
| #define | NI_BASIC_PARTS |
| #define | NI_float_val(nd) ((nd)->val) |
| #define | NI_stat_code(nd) ((nd)->statcode) |
| #define | NI_stat_param_num(nd) ((nd)->param_num) |
| #define | NI_stat_param(nd, i, j) |
| #define | NI_STAT_CORREL 2 |
| #define | NI_STAT_TTEST 3 |
| #define | NI_STAT_FTEST 4 |
| #define | NI_STAT_ZSCORE 5 |
| #define | NI_STAT_CHISQ 6 |
| #define | NI_STAT_BETA 7 |
| #define | NI_STAT_BINOM 8 |
| #define | NI_STAT_GAMMA 9 |
| #define | NI_STAT_POISSON 10 |
| #define | NI_STAT_NORMAL 11 |
| #define | NI_STAT_FTEST_NONC 12 |
| #define | NI_STAT_CHISQ_NONC 13 |
| #define | NI_STAT_LOGISTIC 14 |
| #define | NI_STAT_LAPLACE 15 |
| #define | NI_STAT_UNIFORM 16 |
| #define | NI_STAT_TTEST_NONC 17 |
| #define | NI_STAT_WEIBULL 18 |
| #define | NI_STAT_CHI 19 |
| #define | NI_STAT_INVGAUSS 20 |
| #define | NI_STAT_EXTVAL 21 |
| #define | NI_STAT_PVAL 22 |
| #define | NI_STAT_LOGPVAL 23 |
| #define | NI_STAT_LOG10PVAL 24 |
| #define | NI_STAT_FIRSTCODE 2 |
| #define | NI_STAT_LASTCODE 24 |
| #define | NI_NODE_DIRECTION 55 |
| #define | NI_INDEX_DIRECTION 56 |
| #define | NI_dataset_vecnum(nd) ( ((nd)->order == NI_NODE_DIRECTION) ? (nd)->num_val : (nd)->num_node ) |
| #define | NI_dataset_veclen(nd) ( ((nd)->order == NI_NODE_DIRECTION) ? (nd)->num_node: (nd)->num_val ) |
| #define | NI_opposite_order(oo) ( ((oo) == NI_NODE_DIRECTION) ? NI_INDEX_DIRECTION : NI_NODE_DIRECTION ) |
| #define | NI_STRUCT_TYPE 6660000 |
| #define | NI_FLOAT_ONE_TYPE 6660002 |
| #define | NI_STATISTIC_TYPE 6660003 |
| #define | NI_DATASET_TYPE 6660004 |
| #define | NI_VECTOR_TYPE 6660100 |
| #define | NI_BYTE_VECTOR_TYPE 6660101 |
| #define | NI_SHORT_VECTOR_TYPE 6660102 |
| #define | NI_INT_VECTOR_TYPE 6660103 |
| #define | NI_FLOAT_VECTOR_TYPE 6660104 |
| #define | NI_DOUBLE_VECTOR_TYPE 6660105 |
| #define | NI_COMPLEX_VECTOR_TYPE 6660106 |
| #define | NI_RGB_VECTOR_TYPE 6660107 |
| #define | NI_RGBA_VECTOR_TYPE 6660108 |
| #define | NI_STRING_VECTOR_TYPE 6660109 |
| #define | NI_is_vector_type(tt) ( (tt) >= NI_VECTOR_TYPE && (tt) <= NI_STRING_VECTOR_TYPE ) |
| #define | NI_patch_vector_type(nn) |
| #define | NI_RECT_DOMAIN_TYPE 6660201 |
| #define | NI_POINTS_DOMAIN_TYPE 6660202 |
| #define | NI_is_domain_type(tt) ( (tt) >= NI_RECT_DOMAIN_TYPE && (tt) <= NI_POINTS_DOMAIN_TYPE ) |
| #define | NI_AFFINE_3DMAP_TYPE 6660301 |
| #define | NI_is_3dmap_type(tt) ( (tt) >= NI_AFFINE_3DMAP_TYPE && (tt) <= NI_AFFINE_3DMAP_TYPE ) |
| #define | NI_datatype_size(n) NI_rowtype_code_to_size(n) |
| #define | NI_delete_str_array(sar) |
| #define | NI_decode_str_array NI_decode_string_list |
| #define | IDCODE_LEN 32 |
| #define | LEN_IDCODE IDCODE_LEN |
Typedefs | |
| typedef unsigned char | byte |
| typedef NI_rowtype | NI_rowtype |
| typedef NI_stream_type * | NI_stream |
| typedef int | NI_index_t |
| typedef void | NI_voidfunc () |
| typedef int(* | NI_objconverter_func )(NI_objcontainer *) |
Functions | |
| int | NI_rowtype_define (char *, char *) |
| NI_rowtype * | NI_rowtype_find_name (char *) |
| NI_rowtype * | NI_rowtype_find_code (int) |
| int | NI_rowtype_name_to_code (char *) |
| char * | NI_rowtype_code_to_name (int) |
| char * | NI_rowtype_code_to_alias (int) |
| int | NI_rowtype_name_to_size (char *) |
| int | NI_rowtype_code_to_size (int) |
| int | NI_rowtype_vsize (NI_rowtype *, void *) |
| void | NI_val_to_text (NI_rowtype *, char *, char *) |
| int | NI_val_to_binary (NI_rowtype *, char *, char *) |
| void | NI_multival_to_text (NI_rowtype *, int, char *, char *) |
| int | NI_multival_to_binary (NI_rowtype *, int, char *, char *) |
| int | NI_has_String (NI_rowtype *) |
| void | NI_swap_column (NI_rowtype *, int, char *) |
| void | NI_rowtype_debug (int) |
| char * | NI_type_name (int) |
| NI_procins * | NI_rowtype_procins (NI_rowtype *) |
| void | NI_set_attribute_mode (int) |
| void | NI_set_typename_mode (int) |
| Htable * | new_Htable (int) |
| void | destroy_Htable (Htable *) |
| void | addto_Htable (char *, void *, Htable *) |
| void * | findin_Htable (char *, Htable *) |
| void | removefrom_Htable (char *, Htable *) |
| void | profile_Htable (char *, Htable *) |
| void | subsume_Htable (Htable *, Htable *) |
| void | Htable_set_vtkill (int) |
| void | resize_Htable (int, Htable *) |
| Dtable * | new_Dtable (int) |
| void | destroy_Dtable (Dtable *) |
| void | addto_Dtable (char *, char *, Dtable *) |
| char * | findin_Dtable_a (char *, Dtable *) |
| char * | findin_Dtable_b (char *, Dtable *) |
| void | removefrom_Dtable_a (char *, Dtable *) |
| void | removefrom_Dtable_b (char *, Dtable *) |
| int | listize_Dtable (Dtable *, char ***, char ***) |
| char * | Dtable_to_nimlstring (Dtable *, char *) |
| Dtable * | Dtable_from_nimlstring (char *) |
| DIME_message * | DIME_read_message (NI_stream_type *, int) |
| DIME_part * | DIME_read_part (NI_stream_type *, int) |
| void | DIME_destroy_message (DIME_message *) |
| void * | hidden_NI_malloc (size_t, char *, int) |
| void * | hidden_NI_realloc (void *, size_t, char *, int) |
| void | hidden_NI_free (void *, char *, int) |
| char * | NI_malloc_status (void) |
| void | NI_malloc_dump (void) |
| void | NI_malloc_enable_tracking (void) |
| int | NI_malloc_tracking_enabled (void) |
| int | NI_malloc_replace (void *(*um)(size_t), void *(*ur)(void *, size_t), void(*uf)(void *)) |
| char * | NI_strncpy (char *, const char *, size_t) |
| char * | NI_strdup (char *) |
| int | NI_strlen (char *) |
| long | NI_filesize (char *) |
| int | NI_clock_time (void) |
| int | NI_byteorder (void) |
| void | NI_swap2 (int, void *) |
| void | NI_swap4 (int, void *) |
| void | NI_swap8 (int, void *) |
| char * | NI_mktemp (char *) |
| int | NI_type_size (int) |
| int | NI_element_rowsize (NI_element *) |
| int | NI_element_allsize (NI_element *) |
| void | NI_free_element (void *) |
| int | NI_element_type (void *) |
| char * | NI_element_name (void *) |
| NI_element * | NI_new_data_element (char *, int) |
| void | NI_add_column (NI_element *, int, void *) |
| void | NI_set_attribute (void *, char *, char *) |
| char * | NI_get_attribute (void *, char *) |
| void | NI_insert_value (NI_element *, int, int, void *) |
| void | NI_add_column_stride (NI_element *, int, void *, int) |
| void | NI_fill_column_stride (NI_element *, int, void *, int, int) |
| void | NI_insert_string (NI_element *, int, int, char *) |
| void | NI_alter_veclen (NI_element *, int) |
| NI_group * | NI_new_group_element (void) |
| void | NI_add_to_group (NI_group *, void *) |
| void | NI_rename_group (NI_group *, char *) |
| void | NI_remove_from_group (NI_group *, void *) |
| int | NI_search_group_shallow (NI_group *, char *, void ***) |
| int | NI_search_group_deep (NI_group *, char *, void ***) |
| NI_procins * | NI_new_processing_instruction (char *) |
| void | NI_swap_vector (int, int, void *) |
| NI_stream | NI_stream_open (char *, char *) |
| int | NI_stream_goodcheck (NI_stream_type *, int) |
| void | NI_stream_close (NI_stream_type *) |
| void | NI_stream_kill (NI_stream_type *) |
| void | NI_stream_closenow (NI_stream_type *) |
| int | NI_stream_readcheck (NI_stream_type *, int) |
| int | NI_stream_writecheck (NI_stream_type *, int) |
| int | NI_stream_write (NI_stream_type *, char *, int) |
| int | NI_stream_read (NI_stream_type *, char *, int) |
| void | NI_binary_threshold (NI_stream_type *, int) |
| void | NI_sleep (int) |
| char * | NI_stream_getbuf (NI_stream_type *) |
| void | NI_stream_clearbuf (NI_stream_type *) |
| void | NI_stream_setbuf (NI_stream_type *, char *) |
| char * | NI_stream_name (NI_stream_type *) |
| int | NI_stream_readable (NI_stream_type *) |
| int | NI_stream_writeable (NI_stream_type *) |
| int | NI_stream_hasinput (NI_stream_type *, int) |
| void | NI_stream_seek (NI_stream_type *, int, int) |
| int | NI_stream_writestring (NI_stream_type *, char *) |
| int | NI_stream_setbufsize (NI_stream_type *, int) |
| int | NI_stream_getbufsize (NI_stream_type *) |
| int | NI_stream_readbuf (NI_stream_type *, char *, int) |
| int | NI_stream_readbuf64 (NI_stream_type *, char *, int) |
| int | NI_text_to_val (NI_stream_type *, NI_rowtype *, void *, int) |
| int | NI_binary_to_val (NI_stream_type *, NI_rowtype *, void *, int) |
| int | NI_base64_to_val (NI_stream_type *, NI_rowtype *, void *, int) |
| int | NI_stream_setb64 (NI_stream_type *, int) |
| int | NI_stream_reopen (NI_stream_type *, char *) |
| void * | NI_read_element (NI_stream_type *, int) |
| int | NI_write_element (NI_stream_type *, void *, int) |
| int | NI_write_procins (NI_stream_type *, char *) |
| int | NI_write_columns (NI_stream_type *, int, int *, int, void **, int) |
| int | NI_write_rowtype (NI_stream_type *, NI_rowtype *, int, void *, int) |
| int | NI_read_columns (NI_stream_type *, int, int *, int, void **, int, int) |
| void | NI_free_column (NI_rowtype *, int, void *) |
| void * | NI_copy_column (NI_rowtype *, int, void *) |
| int | NI_size_column (NI_rowtype *, int, void *) |
| void | NI_read_header_only (int) |
| void * | NI_read_element_header (NI_stream_type *, int) |
| void | NI_skip_procins (int) |
| int | NI_read_URL_tmpdir (char *url, char **tname) |
| int | NI_read_URL (char *url, char **data) |
| void | NI_set_URL_ftp_ident (char *name, char *pwd) |
| void | B64_set_crlf (int nn) |
| void | B64_set_linelen (int ll) |
| void | B64_to_binary (int nb64, byte *b64, int *nbin, byte **bin) |
| void | B64_to_base64 (int nbin, byte *bin, int *nb64, byte **b64) |
| char * | MD5_static_array (int n, char *bytes) |
| char * | MD5_malloc_array (int n, char *bytes) |
| char * | MD5_static_string (char *string) |
| char * | MD5_malloc_string (char *string) |
| char * | MD5_static_file (char *filename) |
| char * | MD5_malloc_file (char *filename) |
| char * | MD5_B64_array (int n, char *bytes) |
| char * | MD5_B64_string (char *string) |
| char * | MD5_B64_file (char *filename) |
| char * | UNIQ_idcode (void) |
| void | UNIQ_idcode_fill (char *) |
| char * | UNIQ_hashcode (char *) |
| char * | UUID_hashcode (char *) |
| char * | UUID_idcode (void) |
| char * | NI_hostname_to_inet (char *host) |
| void | NI_add_trusted_host (char *hostname) |
| int | NI_trust_host (char *hostid) |
| void | NI_free_struct (void *) |
| void * | NI_copy_struct (void *) |
| void * | NI_pointto_struct (void *) |
| void | NI_register_struct (void *) |
| void * | NI_find_struct (char *) |
| void | NI_unregister_struct (void *) |
| int | NI_stat_numparam (int) |
| char * | NI_stat_distname (int) |
| void | NI_stat_decode (char *, int *, float *, float *, float *) |
| char * | NI_stat_encode (int, float, float, float) |
| void * | NI_new_vector (int, NI_index_t) |
| void | NI_set_vector_range (void *) |
| void * | NI_dataset_transpose (void *) |
| int | NI_do (NI_stream_type *, NI_element *) |
| void | NI_register_doer (char *, NI_voidfunc *) |
| NI_str_array * | NI_decode_string_list (char *ss, char *sep) |
| void * | NI_registry_malloc (char *, char *, size_t) |
| void * | NI_registry_realloc (void *, size_t) |
| void | NI_registry_free (void *) |
| void * | NI_registry_idcode_to_ptr (char *) |
| char * | NI_registry_idcode_to_name (char *) |
| char * | NI_registry_ptr_to_idcode (void *) |
| char * | NI_registry_ptr_to_name (void *) |
| void | NI_registry_idcode_altername (char *, char *) |
| void | NI_registry_ptr_altername (void *, char *) |
| size_t | NI_registry_idcode_to_len (char *) |
| size_t | NI_registry_ptr_to_len (void *) |
| void * | NI_registry_add (char *, char *, void *) |
| void * | NI_registry_replace (void *, void *) |
| char * | NI_self_idcode (void *) |
| void | NI_suck_stream (char *, int, int *, NI_objcontainer ***) |
| void | NI_convert_elm_to_obj (NI_objcontainer *) |
| void | NI_convert_obj_to_elm (NI_objcontainer *) |
| void | NI_register_objconverters (char *, NI_objconverter_func, NI_objconverter_func) |
Define Documentation
|
|
Value: do{ NI_free((rr)->name) ; \ NI_free((rr)->userdef) ; \ NI_free((rr)->comp_typ) ; \ NI_free((rr)->part_typ) ; \ NI_free((rr)->part_off) ; \ NI_free(rr) ; } while(0) Definition at line 153 of file niml.h. Referenced by NI_rowtype_define(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1184 of file niml.h. Referenced by NI_convert_elm_to_obj(), NI_register_objconverters(), and NI_suck_stream(). |
|
|
Value: ( (c) == 'b' || (c) == 's' || (c) == 'i' || \ (c) == 'f' || (c) == 'd' || (c) == 'c' || \ (c) == 'r' || (c) == 'S' || (c) == 'L' || \ (c) == 'R' ) |
|
|
|
|
|
|
Definition at line 1137 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Definition at line 406 of file niml.h. Referenced by NI_set_typename_mode(). |
|
|
|
|
|
|
|
|
Definition at line 394 of file niml.h. Referenced by main(), NI_read_columns(), NI_read_element(), NI_write_columns(), and NI_write_element(). |
|
|
Value: int type ; \ int nref ; \ char *idcode ; \ char *name
|
|
|
|
Size of NI_stream buffer. Definition at line 327 of file niml.h. Referenced by AFNI_niml_workproc(), NI_stream_open(), and THD_read_niml_atr(). |
|
|
|
Definition at line 1112 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
|
|
|
Definition at line 74 of file niml.h. Referenced by decode_type_field(), NI_set_vector_range(), NI_swap_column(), NI_text_to_val(), NI_val_to_text(), and setup_basic_types(). |
|
|
|
|
|
Definition at line 1117 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Definition at line 1109 of file niml.h. Referenced by NI_copy_struct(), NI_dataset_transpose(), and NI_free_struct(). |
|
|
Definition at line 1095 of file niml.h. Referenced by NI_dataset_transpose(). |
|
|
Definition at line 1092 of file niml.h. Referenced by NI_copy_struct(), NI_dataset_transpose(), and NI_free_struct(). |
|
|
Definition at line 1142 of file niml.h. Referenced by NI_copy_struct(), NI_dataset_transpose(), NI_new_vector(), and NI_set_vector_range(). |
|
|
|
|
|
Value: do{ int pp ; \ for( pp=0 ; pp < (sar)->num ; pp++ ) \ NI_free( (sar)->str[pp] ); \ NI_free((sar)->str) ; NI_free(sar) ; \ } while(0) Definition at line 1155 of file niml.h. Referenced by basis_parser(), make_empty_data_element(), mri_1D_fromstring(), NI_rowtype_define(), SYM_expand_ranges(), THD_datablock_from_atr(), THD_load_tcat(), THD_open_3D(), and THD_open_tcat(). |
|
|
Definition at line 72 of file niml.h. Referenced by decode_type_field(), matrix_to_niml(), NI_set_vector_range(), NI_swap_column(), NI_text_to_val(), NI_val_to_text(), niml_to_matrix(), setup_basic_types(), SUMA_AddDsetNelCol(), SUMA_AddNelCol(), SUMA_Copy_Part_Column(), SUMA_FillDsetNelCol(), SUMA_FillNelCol(), and SUMA_oDsetNel2nDsetNgr(). |
|
|
Definition at line 1116 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
|
Definition at line 377 of file niml.h. Referenced by NI_stream_close_keep(), NI_stream_goodcheck(), NI_stream_open(), NI_stream_read(), NI_stream_readcheck(), NI_stream_setbufsize(), NI_stream_write(), and NI_stream_writecheck(). |
|
|
Definition at line 374 of file niml.h. Referenced by NI_stream_close_keep(), NI_stream_goodcheck(), NI_stream_open(), NI_stream_read(), NI_stream_readcheck(), NI_stream_seek(), NI_stream_setbufsize(), NI_stream_write(), and NI_stream_writecheck(). |
|
|
|
|
|
|
|
|
|
Definition at line 1107 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
|
|
|
Definition at line 1115 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Free and set pointer to NULL. |
|
|
|
|
Definition at line 396 of file niml.h. Referenced by NI_write_element(), and NIML_to_stderr(). |
|
|
Definition at line 397 of file niml.h. Referenced by main(), NI_write_element(), NIML_to_stderr(), SUMA_FakeIt(), SUMA_SaveVisualState(), SUMA_SendToSuma(), and SUMA_Write_DrawnROI_NIML(). |
|
|
|
|
|
Definition at line 387 of file niml.h. Referenced by NI_stream_goodcheck(), NI_stream_open(), NI_stream_readable(), NI_stream_setbuf(), and NI_stream_setbufsize(). |
|
|
|
Definition at line 1114 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
|
|
|
|
|
|
Definition at line 99 of file niml.h. Referenced by NI_new_vector(), and NI_set_vector_range(). |
|
|
|
|
|
Definition at line 543 of file niml.h. Referenced by NI_malloc_dump(). |
|
|
Definition at line 78 of file niml.h. Referenced by THD_open_3D(). |
|
|
Definition at line 1122 of file niml.h. Referenced by NI_set_vector_range(). |
|
|
Definition at line 399 of file niml.h. Referenced by NI_byteorder(), NI_read_element(), NI_write_element(), and THD_write_1D(). |
|
|
Definition at line 633 of file niml.h. Referenced by NI_read_columns(), and NI_read_element(). |
|
|
|
Definition at line 400 of file niml.h. Referenced by NI_byteorder(), and NI_read_element(). |
|
|
Definition at line 413 of file niml.h. Referenced by NI_type_name(). |
|
|
|
|
|
Definition at line 412 of file niml.h. Referenced by NI_set_typename_mode(). |
|
|
Make a new block of a given type. Definition at line 531 of file niml.h. Referenced by NI_dataset_transpose(), NI_new_vector(), NI_rowtype_define(), and setup_basic_types(). |
|
|
|
|
|
Number of types of fixed size ("basic" types). Note that if this changes, the NI_rowtype stuff must be altered accordingly. Definition at line 90 of file niml.h. Referenced by NI_rowtype_code_to_alias(), NI_rowtype_find_name(), and setup_basic_types(). |
|
|
One more than the last NI_ data type code defined above. |
|
|
Definition at line 1098 of file niml.h. Referenced by NI_dataset_transpose(). |
|
|
Definition at line 388 of file niml.h. Referenced by NI_stream_clearbuf(), NI_stream_close_keep(), NI_stream_getbuf(), NI_stream_open(), NI_stream_read(), NI_stream_readcheck(), NI_stream_writeable(), and NI_stream_writecheck(). |
|
|
Value: do{ if( NI_is_vector_type((nn)->type) && \ NI_is_builtin_type((nn)->vec_typ) ) \ (nn)->type = NI_VECTOR_TYPE + (nn)->vec_typ + 1 ; \ } while(0) |
|
|
Definition at line 1132 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Definition at line 192 of file niml.h. Referenced by AFNI_niml_workproc(), AFNI_process_NIML_data(), main(), NI_element_name(), NI_element_type(), NI_free_element(), NI_get_attribute(), NI_new_processing_instruction(), NI_read_element(), NI_set_attribute(), and NI_write_element(). |
|
|
|
Definition at line 1131 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Definition at line 376 of file niml.h. Referenced by NI_stream_close_keep(), NI_stream_fillbuf(), NI_stream_goodcheck(), NI_stream_open(), NI_stream_read(), NI_stream_readbuf(), NI_stream_readcheck(), NI_stream_write(), and NI_stream_writecheck(). |
|
|
Definition at line 75 of file niml.h. Referenced by decode_type_field(), NI_set_vector_range(), NI_swap_column(), NI_text_to_val(), NI_val_to_text(), and setup_basic_types(). |
|
|
Definition at line 1118 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Definition at line 76 of file niml.h. Referenced by decode_type_field(), NI_set_vector_range(), NI_swap_column(), NI_text_to_val(), NI_val_to_text(), and setup_basic_types(). |
|
|
Definition at line 1119 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Definition at line 378 of file niml.h. Referenced by NI_stream_close_keep(), NI_stream_goodcheck(), NI_stream_open(), NI_stream_read(), NI_stream_readable(), NI_stream_readcheck(), NI_stream_setbufsize(), NI_stream_write(), NI_stream_writeable(), and NI_stream_writecheck(). |
|
|
Definition at line 67 of file niml.h. Referenced by decode_type_field(), NI_set_vector_range(), NI_swap_column(), NI_text_to_val(), NI_val_to_text(), setup_basic_types(), and SUMA_Copy_Part_Column(). |
|
|
Definition at line 1113 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Parameters * |
|
|
|
|
|
Definition at line 788 of file niml.h. Referenced by NI_stat_decode(), and THD_open_3D(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 789 of file niml.h. Referenced by NI_stat_decode(), NI_stat_distname(), NI_stat_encode(), NI_stat_numparam(), and THD_open_3D(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value: ( ((nd)->param[i]->type == NI_FLOAT_ONE_TYPE) \ ? ( ((NI_float_one *)(nd)->param[i])->val ) \ : ( ((NI_float_vector *)(nd)->param[i])->vec[j] ) ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1108 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Close a NI_stream, and set the pointer to NULL. |
|
|
|
Definition at line 375 of file niml.h. Referenced by NI_stream_clearbuf(), NI_stream_close_keep(), NI_stream_fillbuf(), NI_stream_getbuf(), NI_stream_goodcheck(), NI_stream_open(), NI_stream_read(), NI_stream_readbuf(), NI_stream_readcheck(), NI_stream_setbuf(), NI_stream_setbufsize(), NI_stream_write(), NI_stream_writecheck(), NI_write_columns(), and NI_write_element(). |
|
|
Definition at line 1120 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Definition at line 1106 of file niml.h. Referenced by NI_copy_struct(), and NI_free_struct(). |
|
|
Definition at line 632 of file niml.h. Referenced by NI_read_columns(), and NI_read_element(). |
|
|
Definition at line 373 of file niml.h. Referenced by NI_stream_close_keep(), NI_stream_goodcheck(), NI_stream_open(), NI_stream_read(), NI_stream_readable(), NI_stream_readcheck(), NI_stream_reopen(), NI_stream_setbufsize(), NI_stream_write(), NI_stream_writeable(), NI_stream_writecheck(), and tcp_sigurg_handler(). |
|
|
|
Definition at line 1111 of file niml.h. Referenced by NI_copy_struct(), NI_free_struct(), and NI_new_vector(). |
|
|
Definition at line 32 of file niml.h. Referenced by AGNI_nod_to_NIML_row(), AGNI_nod_to_NIML_rows(), NIML_to_AGNI_nod(), ply_describe_other_elements(), ply_get_other_element(), and setup_basic_types(). |
|
|
Used to test if a rowtype code is a basic type. |
|
|
Check if a NI_rowtype struct is marked as having variable size data Definition at line 141 of file niml.h. Referenced by NI_base64_to_val(), NI_binary_to_val(), NI_copy_column(), NI_free_column(), NI_insert_value(), NI_read_columns(), NI_rowtype_define(), NI_rowtype_vsize(), NI_size_column(), NI_text_to_val(), NI_val_to_binary(), NI_write_columns(), and SUMA_MaskedCopyofDset(). |
|
|
Get the dimension of the qq-th part of the struct stored at pointer pt, of type rt. This macro should only be used if rt->part_dim[qq] >= 0. Definition at line 147 of file niml.h. Referenced by NI_base64_to_val(), NI_binary_to_val(), NI_copy_column(), NI_insert_value(), NI_rowtype_vsize(), NI_swap_column(), NI_text_to_val(), and NI_write_columns(). |
|
|
NI_rowtype bit flag for variable size data. Definition at line 137 of file niml.h. Referenced by NI_rowtype_define(), and setup_basic_types(). |
|
|
Definition at line 271 of file niml.h. Referenced by SHM_init(), SHM_readcheck(), SHM_recv(), SHM_send(), and SHM_writecheck(). |
|
|
Definition at line 278 of file niml.h. Referenced by SHM_fill_accept(), and SHM_init(). |
|
|
Definition at line 281 of file niml.h. Referenced by SHM_fill_accept(), and SHM_init(). |
|
|
Definition at line 277 of file niml.h. Referenced by SHM_fill_accept(), and SHM_init(). |
|
|
Definition at line 280 of file niml.h. Referenced by SHM_fill_accept(), and SHM_init(). |
|
|
Definition at line 270 of file niml.h. Referenced by SHM_init(), SHM_readcheck(), SHM_recv(), SHM_send(), and SHM_writecheck(). |
|
|
Definition at line 273 of file niml.h. Referenced by SHM_init(). |
|
|
Definition at line 275 of file niml.h. Referenced by SHM_fill_accept(), and SHM_init(). |
|
|
Definition at line 268 of file niml.h. Referenced by SHM_close(), SHM_fill_accept(), and SHM_goodcheck(). |
|
|
Definition at line 276 of file niml.h. Referenced by SHM_fill_accept(), and SHM_init(). |
|
|
Definition at line 279 of file niml.h. Referenced by SHM_fill_accept(), and SHM_init(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Typedef Documentation
|
|
|
|
|
Definition at line 683 of file niml.h. Referenced by NI_copy_struct(), NI_dataset_transpose(), NI_free_struct(), NI_new_vector(), and NI_set_vector_range(). |
|
|
Definition at line 1197 of file niml.h. Referenced by NI_register_objconverters(). |
|
|
|
|
|
Opaque type for the C API. |
|
|
Definition at line 1146 of file niml.h. Referenced by NI_register_doer(). |
Function Documentation
|
||||||||||||||||
|
Insert string pair str_a,str_b into the Dtable. Copies of the strings are made. ------------------------------------------------------------------- Definition at line 40 of file niml_dtable.c. References addto_Htable(), dt, Dtable::hta, Dtable::htb, and sb. Referenced by DRAW_label_CB(), and Dtable_from_nimlstring().
00041 {
00042 char *sa , *sb ;
00043 if( dt == NULL || str_a == NULL || str_b == NULL ) return ;
00044 sa = strdup(str_a) ; sb = strdup(str_b) ;
00045 addto_Htable( sa , (void *)sb , dt->hta ) ;
00046 addto_Htable( sb , (void *)sa , dt->htb ) ;
00047 return ;
00048 }
|
|
||||||||||||||||
|
Add a string/pointer pair to a hash table.
Definition at line 129 of file niml_htable.c. References calloc, Htable::ctab, free, hashkey(), key, Htable::len, Htable::ntab, Htable::ntot, realloc, removefrom_Htable(), UINT, Htable::vtab, and vtkill. Referenced by addto_Dtable(), NI_register_struct(), NI_registry_add(), NI_registry_malloc(), NI_registry_realloc(), NI_registry_replace(), subsume_Htable(), and THD_init_session().
00130 {
00131 UINT jj ;
00132 int kk , ll=-1 ;
00133 char *key ;
00134
00135 /* check for bad inputs */
00136
00137 if( str == NULL || ht == NULL ) return ;
00138
00139 if( vpt == NULL ){ removefrom_Htable( str , ht ) ; return ; }
00140
00141 jj = hashkey(str) % ht->len ; /* hash table row */
00142
00143 key = strdup(str) ; /* internal key string */
00144
00145 if( ht->vtab[jj] == NULL ){ /* create this row in table */
00146
00147 ht->vtab[jj] = (void **) calloc(3,sizeof(void *)) ;
00148 ht->ctab[jj] = (char **) calloc(3,sizeof(char *)) ;
00149 ht->ntab[jj] = 3 ; /* made 2 extra entries */
00150
00151 ht->vtab[jj][0] = vpt ; /* save pointer */
00152 ht->ctab[jj][0] = key ; /* save key string */
00153 ht->ntot ++ ; /* 1 more in table */
00154
00155 } else { /* search this row */
00156
00157 for( kk=0 ; kk < ht->ntab[jj] ; kk++ ){
00158 if( ht->ctab[jj][kk] == NULL ){ if(ll < 0) ll=kk; } /* add here? */
00159 else if( strcmp(key,ht->ctab[jj][kk]) == 0 ) break ; /* found it? */
00160 }
00161
00162 if( kk == ht->ntab[jj] ){ /* didn't find str in row already */
00163
00164 if( ll >= 0 ){ /* have a NULL slot from scan above */
00165
00166 ht->vtab[jj][ll] = vpt ; /* save ptr */
00167 ht->ctab[jj][ll] = key ; /* save key string */
00168 ht->ntot ++ ; /* 1 more in table */
00169
00170 } else { /* must make row longer */
00171
00172 ht->vtab[jj] = (void **) realloc( ht->vtab[jj] , (kk+3)*sizeof(void *)) ;
00173 ht->ctab[jj] = (char **) realloc( ht->ctab[jj] , (kk+3)*sizeof(char *)) ;
00174 ht->ntab[jj] = kk+3 ;
00175
00176 ht->vtab[jj][kk] = vpt ; /* save ptr */
00177 ht->ctab[jj][kk] = key ; /* save key string */
00178 ht->ntot ++ ; /* 1 more in table */
00179
00180 ht->vtab[jj][kk+1] = ht->vtab[jj][kk+2] = NULL ; /* created 2 extra */
00181 ht->ctab[jj][kk+1] = ht->ctab[jj][kk+2] = NULL ; /* elements above */
00182
00183 }
00184
00185 } else { /* found str in row at index kk */
00186
00187 if( vtkill && ht->vtab[jj][kk] != NULL ) free(ht->vtab[jj][kk]) ;
00188
00189 ht->vtab[jj][kk] = vpt ; /* replace old ptr with new */
00190 free(key) ; /* don't need this */
00191 }
00192 }
00193 }
|
|
|
Set the number of characters to use for end of line: 1 = Unix standard (LF only); 2 = DOS standard (CR LF). ------------------------------------------------------------------------ Definition at line 19 of file niml_b64.c. References ncrlf. Referenced by main().
|
|
|
Set the length of a line of output in base64; ll should be between 16 and 76 (inclusive). Will round down to a multiple of 4. ------------------------------------------------------------------------ Definition at line 31 of file niml_b64.c. References linelen. Referenced by main().
|
|
||||||||||||||||||||
|
Convert binary array to base64 encoding. Inputs: nbin = number of bytes in bin bin = array of binary bytes to encode Outputs: *nb64 = number of base64 bytes [*nb64==0 flags an error] b64 = pointer to newly malloc()-ed space with bytes The output array (*b64) line length can be set by B64_set_linelen(n) where n is from 16 to 76. The default is 72. Note, however, that encoded bytes will always be written out in groups of 4. The output array line separator can be the LF character only (Unix) or the CR-LF combination (DOS, etc.). This is controlled by B64_set_crlf(n) where n=1 for LF, n=2 for CR LF. The default is LF. The output array will be terminated with a line separator. If you call B64_set_crlf(0) then this will toggle the use of line separators. There will be no ASCII NUL character at the end of *b64 -- that is, the output is not a C string. Example:
Definition at line 177 of file niml_b64.c.
00178 {
00179 int ii,jj , nn,n3 ;
00180 byte a,b,c , w,x,y,z ;
00181
00182 /*- sanity checks -*/
00183
00184 if( nb64 == NULL || b64 == NULL ) return ;
00185 if( nbin <= 0 || bin == NULL ){ *nb64 = 0 ; *b64 = NULL ; return ; }
00186
00187 /* calculate size of output (3 bytes in -> 4 bytes out, plus EOL */
00188
00189 nn = (int)((4.0*(linelen+ncrlf+1.0)/(3.0*linelen))*nbin + 256.0) ;
00190 *b64 = (byte *) malloc(sizeof(byte)*nn) ;
00191 if( *b64 == NULL ){ *nb64 = 0 ; return ; } /* this is bad */
00192
00193 /*- do blocks of 3 bytes in -*/
00194
00195 load_encode_table() ;
00196 n3 = (nbin/3)*3 ;
00197 for( nn=jj=ii=0 ; ii < n3 ; ){
00198
00199 /* encode next 3 bytes to 4 outputs */
00200
00201 a = bin[ii++] ; b = bin[ii++] ; c = bin[ii++] ;
00202 B64_encode3(a,b,c,w,x,y,z) ;
00203 (*b64)[jj++] = w ;
00204 (*b64)[jj++] = x ;
00205 (*b64)[jj++] = y ;
00206 (*b64)[jj++] = z ;
00207
00208 /* if we past the line length, add the EOL stuff */
00209
00210 if( !nocrlf ){
00211 nn += 4 ; if( nn >= linelen ){
00212 if( ncrlf == 2 ) (*b64)[jj++] = B64_EOL1 ;
00213 (*b64)[jj++] = B64_EOL2 ;
00214 nn = 0 ;
00215 }
00216 }
00217 }
00218
00219 /*- do the leftover data, if any (1 or 2 bytes) -*/
00220
00221 if( ii < nbin ){
00222 if( ii == nbin-2 )
00223 B64_encode2(bin[ii],bin[ii+1],w,x,y,z) ;
00224 else
00225 B64_encode1(bin[ii],w,x,y,z) ;
00226
00227 (*b64)[jj++] = w ;
00228 (*b64)[jj++] = x ;
00229 (*b64)[jj++] = y ;
00230 (*b64)[jj++] = z ; nn += 4 ;
00231 }
00232
00233 /* if any output bytes are left, add EOL */
00234
00235 if( nn > 0 && !nocrlf ){
00236 if( ncrlf == 2 ) (*b64)[jj++] = B64_EOL1 ;
00237 (*b64)[jj++] = B64_EOL2 ;
00238 }
00239
00240 /* resize output array to be exact fit */
00241
00242 *b64 = (byte *) realloc( *b64 , sizeof(byte)*jj ) ;
00243 *nb64 = jj ;
00244 return ;
00245 }
|
|
||||||||||||||||||||
|
Convert base64-encoded array to a binary array (decoding). Inputs:
Definition at line 92 of file niml_b64.c. References a, B64_decode4, B64_decode_count, B64_goodchar, byte, c, load_decode_table(), malloc, and realloc. Referenced by main().
00093 {
00094 int ii,jj , nn ;
00095 byte a,b,c , w,x,y,z ;
00096
00097 /*- sanity checks -*/
00098
00099 if( nbin == NULL || bin == NULL ) return ;
00100
00101 if( nb64 < 4 || b64 == NULL ){ *nbin = 0 ; *bin = NULL ; return ; }
00102
00103 *bin = (byte *) malloc(sizeof(byte)*(2+3*nb64/4)) ;
00104 if( *bin == NULL ){ *nbin = 0 ; return ; }
00105
00106 /*- some work -*/
00107
00108 load_decode_table() ;
00109 for( ii=jj=0 ; ii < nb64 ; ){ /* scan inputs, skipping bad characters */
00110
00111 /* get next 4 characters (use '=' if we hit the end early) */
00112
00113 w = b64[ii++] ;
00114 while( !B64_goodchar(w) && ii < nb64 ) w = b64[ii++] ;
00115 x = (ii < nb64) ? b64[ii++] : '=' ;
00116 while( !B64_goodchar(x) && ii < nb64 ) x = b64[ii++] ;
00117 y = (ii < nb64) ? b64[ii++] : '=' ;
00118 while( !B64_goodchar(y) && ii < nb64 ) y = b64[ii++] ;
00119 z = (ii < nb64) ? b64[ii++] : '=' ;
00120 while( !B64_goodchar(z) && ii < nb64 ) z = b64[ii++] ;
00121
00122 B64_decode4(w,x,y,z,a,b,c) ; /* decode 4 bytes into 3 */
00123
00124 if( z == '=' ){ /* got to the end? */
00125 nn = B64_decode_count(w,x,y,z) ; /* see how many to save */
00126 if( nn > 0 ) (*bin)[jj++] = a ;
00127 if( nn > 1 ) (*bin)[jj++] = b ;
00128 break ; /* end of decoding loop */
00129 }
00130
00131 /* not at the end => save all 3 outputs, loop back */
00132
00133 (*bin)[jj++] = a ; (*bin)[jj++] = b ; (*bin)[jj++] = c ;
00134 }
00135
00136 /* resize output array to be exact fit */
00137
00138 *bin = (byte *) realloc( *bin , sizeof(byte)*jj ) ;
00139 *nbin = jj ;
00140 return ;
00141 }
|
|
|
Death and destruction of a Dtable. ------------------------------------------------------------------- Definition at line 25 of file niml_dtable.c. References destroy_Htable(), dt, Dtable::hta, Htable_set_vtkill(), and Dtable::htb. Referenced by DRAW_finalize_dset_CB(), DRAW_label_getfile(), and DRAW_main().
00026 {
00027 if( dt == NULL ) return ;
00028 Htable_set_vtkill(1) ;
00029 destroy_Htable( dt->hta ) ;
00030 destroy_Htable( dt->htb ) ;
00031 Htable_set_vtkill(0) ; ;
00032 return ;
00033 }
|
|
|
Delete a Htable forever. ----------------------------------------------------------- Definition at line 65 of file niml_htable.c. References Htable::ctab, free, Htable::len, Htable::ntab, and Htable::vtab. Referenced by AFNI_finalize_read_sess_CB(), AFNI_read_inputs(), AFNI_rescan_session_NEW(), AFNI_rescan_session_OLD(), and destroy_Dtable().
00066 {
00067 int jj , kk ;
00068
00069 if( ht == NULL ) return ;
00070
00071 for( jj=0 ; jj < ht->len ; jj++ ){
00072 if( ht->vtab[jj] != NULL ){
00073 if( vtkill ){
00074 for( kk=0 ; kk < ht->ntab[jj] ; kk++ )
00075 if( ht->vtab[jj][kk] != NULL ) free(ht->vtab[jj][kk]) ;
00076 }
00077 free(ht->vtab[jj]) ;
00078 }
00079 if( ht->ctab[jj] != NULL ){
00080 for( kk=0 ; kk < ht->ntab[jj] ; kk++ )
00081 if( ht->ctab[jj][kk] != NULL ) free(ht->ctab[jj][kk]) ;
00082 free(ht->ctab[jj]) ;
00083 }
00084 }
00085 free(ht->vtab) ; free(ht->ctab) ; free(ht->ntab) ; free(ht) ;
00086 return ;
00087 }
|
|
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
Definition at line 164 of file niml_dtable.c. References addto_Dtable(), dt, l, new_Dtable(), NI_element_type(), NI_ELEMENT_TYPE, NI_free_element(), NI_read_element(), NI_stream_close(), NI_stream_open(), NI_stream_setbuf(), NI_STRING, NI_element::vec, NI_element::vec_filled, NI_element::vec_len, NI_element::vec_num, and NI_element::vec_typ. Referenced by DRAW_finalize_dset_CB(), and DRAW_label_getfile().
00165 {
00166 NI_stream ns ;
00167 NI_element *nel ;
00168 int nn , ii ;
00169 Dtable *dt ;
00170 char **la , **lb ;
00171
00172 if( nstr == NULL || *nstr == '\0' ) return NULL ;
00173
00174 /* convert string to a NIML element */
00175
00176 ns = NI_stream_open( "str:" , "r" ) ;
00177 NI_stream_setbuf( ns , nstr ) ;
00178 nel = (NI_element *)NI_read_element( ns , 1 ) ;
00179 NI_stream_close( ns ) ;
00180 if( nel == NULL ) return NULL ;
00181
00182 /* see if element is OK for this purpose */
00183
00184 if( NI_element_type(nel) != NI_ELEMENT_TYPE ){
00185 NI_free_element(nel) ; return NULL ;
00186 }
00187
00188 if( nel->vec_len < 1 || /* empty element? */
00189 nel->vec_filled < 1 || /* no data was filled in? */
00190 nel->vec_num < 2 || /* less than 4 columns? */
00191 nel->vec_typ[0] != NI_STRING || /* must be String, String */
00192 nel->vec_typ[1] != NI_STRING ){
00193
00194 NI_free_element(nel) ; return NULL ;
00195 }
00196
00197 la = (char **) nel->vec[0] ; /* first column of String */
00198 lb = (char **) nel->vec[1] ; /* second column of String */
00199
00200 nn = nel->vec_filled ;
00201 ii = rint(sqrt(2*nn+1.0l)) ;
00202 if( ii < 7 ) ii = 7 ; else if( ii%2 == 0 ) ii++ ;
00203
00204 /* make table, insert strings */
00205
00206 dt = new_Dtable( ii ) ;
00207 for( ii=0 ; ii < nn ; ii++ )
00208 addto_Dtable( la[ii] , lb[ii] , dt ) ;
00209
00210 NI_free_element(nel) ; return dt ;
00211 }
|
|
||||||||||||
|
Definition at line 134 of file niml_dtable.c. References dt, free, listize_Dtable(), name, NI_add_column(), NI_free_element(), NI_new_data_element(), NI_stream_close(), NI_stream_getbuf(), NI_stream_open(), NI_STRING, NI_TEXT_MODE, and NI_write_element(). Referenced by DRAW_attach_dtable(), and dump_vallab().
00135 {
00136 int nn , ii ;
00137 char **la , **lb , *stout ;
00138 NI_element *nel ;
00139 NI_stream ns ;
00140
00141 nn = listize_Dtable( dt , &la , &lb ) ;
00142 if( nn == 0 || la == NULL || lb == NULL ) return (char *)NULL ;
00143
00144 if( name == NULL || *name == '\0' ) name = "Dtable" ;
00145
00146 nel = NI_new_data_element( name , nn ) ;
00147 NI_add_column( nel , NI_STRING , la ) ;
00148 NI_add_column( nel , NI_STRING , lb ) ;
00149 free(la) ; free(lb) ;
00150
00151 ns = NI_stream_open( "str:" , "w" ) ;
00152 (void) NI_write_element( ns , nel , NI_TEXT_MODE ) ;
00153 NI_free_element( nel ) ;
00154 stout = strdup( NI_stream_getbuf(ns) ) ;
00155 NI_stream_close( ns ) ;
00156 nn = strlen(stout) ;
00157 for( ii=nn-1 ; ii > 0 && isspace(stout[ii]) ; ii-- ) ; /* trailing blanks */
00158 stout[ii+1] = '\0' ;
00159 return stout ;
00160 }
|
|
||||||||||||
|
Definition at line 52 of file niml_dtable.c. References dt, findin_Htable(), and Dtable::hta. Referenced by DRAW_label_CB(), and DRAW_set_value_label().
00053 {
00054 if( dt == NULL || str_a == NULL ) return NULL ;
00055 return (char *)findin_Htable( str_a , dt->hta ) ;
00056 }
|
|
||||||||||||
|
Definition at line 60 of file niml_dtable.c. References dt, findin_Htable(), and Dtable::htb. Referenced by DRAW_label_CB().
00061 {
00062 if( dt == NULL || str_b == NULL ) return NULL ;
00063 return (char *)findin_Htable( str_b , dt->htb ) ;
00064 }
|
|
||||||||||||
|
Definition at line 95 of file niml_htable.c. References Htable::ctab, hashkey(), key, Htable::len, Htable::ntab, Htable::ntot, UINT, and Htable::vtab. Referenced by AFNI_find_warp(), findin_Dtable_a(), findin_Dtable_b(), NI_find_struct(), NI_register_struct(), NI_registry_add(), NI_registry_free(), NI_registry_idcode_altername(), NI_registry_idcode_to_len(), NI_registry_idcode_to_name(), NI_registry_idcode_to_ptr(), NI_registry_malloc(), NI_registry_ptr_altername(), NI_registry_ptr_to_idcode(), NI_registry_ptr_to_len(), NI_registry_ptr_to_name(), NI_registry_realloc(), NI_registry_replace(), NI_rowtype_find_name(), removefrom_Dtable_a(), and removefrom_Dtable_b().
00096 {
00097 UINT jj ;
00098 int kk , ntab ;
00099 char *key , **ctab ;
00100 void ***vtab ;
00101
00102 if( str == NULL || ht == NULL || ht->ntot == 0 ) return NULL ;
00103
00104 jj = hashkey(str) % ht->len ; /* hash table row */
00105
00106 vtab = ht->vtab ;
00107
00108 if( vtab[jj] == NULL ) return NULL ; /* nothing there */
00109
00110 key = str ;
00111
00112 ctab = ht->ctab[jj] ; ntab = ht->ntab[jj] ;
00113
00114 for( kk=0 ; kk < ntab ; kk++ ) /* scan for match of key to ctab */
00115 if( ctab[kk] != NULL && strcmp(key,ctab[kk]) == 0 )
00116 return vtab[jj][kk];
00117
00118 return NULL ; /* no match found */
00119 }
|
|
||||||||||||||||
|
Definition at line 623 of file niml_malloc.c. References free, free_track(), NI_dpr(), shift_tracker, use_tracking, and user_free. Referenced by NI_free().
00624 {
00625 NI_mallitem *ip ;
00626
00627 if( fred == NULL ) return ;
00628
00629 if( use_userfunc ) user_free(fred) ;
00630 else if( use_tracking && (ip=shift_tracker(fred)) != NULL ) free_track( ip ) ;
00631 else free( fred ) ;
00632
00633 #ifdef NIML_DEBUG
00634 NI_dpr("hidden_NI_free: called from %s#%d\n",fnam,lnum) ;
00635 #endif
00636
00637 }
|
|
||||||||||||||||
|
Allocate memory (actually uses calloc); calls exit() if it fails. ---------------------------------------------------------------------------- Definition at line 568 of file niml_malloc.c. References calloc, calloc_track(), NI_dpr(), NI_sleep(), p, and user_malloc. Referenced by hidden_NI_realloc().
00569 {
00570 void *p ;
00571
00572 if( use_userfunc ){ p = user_malloc(n); if(p)memset(p,0,n); }
00573 else if( use_tracking ) p = calloc_track(1,n,fnam,lnum) ;
00574 else p = calloc(1,n) ;
00575
00576 if( p == NULL ){
00577 fprintf(stderr,"** ERROR: NI_malloc() fails. Aauugghh!\n") ;
00578 NI_sleep(333); exit(1);
00579 }
00580
00581 #ifdef NIML_DEBUG
00582 NI_dpr("hidden_NI_malloc: called from %s#%d\n",fnam,lnum) ;
00583 #endif
00584
00585 return p ;
00586 }
|
|
||||||||||||||||||||
|
Reallocate memory; calls exit() if it fails. ---------------------------------------------------------------------------- Definition at line 592 of file niml_malloc.c. References hidden_NI_malloc(), NI_dpr(), NI_sleep(), q, realloc, realloc_track(), shift_tracker, use_tracking, and user_realloc.
00593 {
00594 NI_mallitem *ip ;
00595 void *q ;
00596
00597 if( fred == NULL )
00598 return hidden_NI_malloc( n , fnam , lnum ) ;
00599
00600 if( use_userfunc )
00601 q = user_realloc( fred , n ) ;
00602 else if( use_tracking && (ip=shift_tracker(fred)) != NULL )
00603 q = realloc_track( ip , n , fnam,lnum ) ;
00604 else
00605 q = realloc( fred , n ) ;
00606
00607 if( q == NULL && n > 0 ){
00608 fprintf(stderr,"** ERROR: NI_realloc() fails. Ooooogg!\n");
00609 NI_sleep(333); exit(1);
00610 }
00611
00612 #ifdef NIML_DEBUG
00613 NI_dpr("hidden_NI_realloc: called from %s#%d\n",fnam,lnum) ;
00614 #endif
00615
00616 return q ;
00617 }
|
|
|
Definition at line 18 of file niml_htable.c. References vtkill. Referenced by destroy_Dtable().
00018 { vtkill = vt ; }
|
|
||||||||||||||||
|
Definition at line 107 of file niml_dtable.c. References Htable::ctab, dt, Dtable::hta, Htable::len, Htable::ntab, realloc, sb, and Htable::vtab. Referenced by DRAW_label_EV(), and Dtable_to_nimlstring().
00108 {
00109 char **la=NULL , **lb=NULL , *sa,*sb ;
00110 int jj,kk,nn ;
00111 Htable *ht ;
00112
00113 if( dt == NULL || list_a == NULL || list_b == NULL ) return 0 ;
00114
00115 ht = dt->hta ;
00116
00117 for( nn=jj=0 ; jj < ht->len ; jj++ ){
00118 if( ht->vtab[jj] == NULL ) continue ;
00119 for( kk=0 ; kk < ht->ntab[jj] ; kk++ ){
00120 sa = (char *) ht->ctab[jj][kk] ; if( sa == NULL ) continue ;
00121 sb = (char *) ht->vtab[jj][kk] ; if( sb == NULL ) continue ;
00122 la = (char **) realloc( (void *)la , sizeof(char *)*(nn+1) ) ;
00123 lb = (char **) realloc( (void *)lb , sizeof(char *)*(nn+1) ) ;
00124 la[nn] = sa ; lb[nn] = sb ; nn++ ;
00125 }
00126 }
00127 *list_a = la ; *list_b = lb ; return nn ;
00128 }
|
|
||||||||||||
|
Return the MD5 hash of an array as a Base64 string, instead of a hex string. strlen(result) is 22 instead of 32 result is malloc()-ed and should be free()-d when appropriate ------------------------------------------------------------------------------ Definition at line 466 of file niml_md5.c. References MD5_to_B64(), MD5Final(), MD5Init(), and MD5Update(). Referenced by MD5_B64_string().
00467 {
00468 MD5_CTX context;
00469 unsigned char digest[16];
00470
00471 if( n < 0 || bytes == NULL ) return NULL ;
00472
00473 MD5Init( &context ) ;
00474 MD5Update( &context, (unsigned char *)bytes, n ) ;
00475 MD5Final( digest, &context ) ;
00476
00477 return MD5_to_B64( digest ) ;
00478 }
|
|
|
Return the MD5 hash of a file as a Base64 string, instead of a hex string.
Definition at line 500 of file niml_md5.c. References file, MD5_to_B64(), MD5Final(), MD5Init(), and MD5Update().
00501 {
00502 FILE *file;
00503 MD5_CTX context;
00504 int len;
00505 unsigned char buffer[1024] ;
00506 unsigned char digest[16] ;
00507
00508 if( (file=fopen (filename, "rb")) == NULL ) return NULL ;
00509
00510 MD5Init( &context ) ;
00511
00512 while( len = fread(buffer, 1, 1024, file) )
00513 MD5Update( &context, buffer, len ) ;
00514
00515 MD5Final( digest, &context );
00516 fclose (file);
00517
00518 return MD5_to_B64( digest ) ;
00519 }
|
|
|
Return the MD5 hash of a C string as a Base64 string, instead of a hex string. strlen(result) is 22 instead of 32 result is malloc()-ed and should be free()-d when appropriate ------------------------------------------------------------------------------ Definition at line 487 of file niml_md5.c. References MD5_B64_array(). Referenced by UNIQ_hashcode(), and UNIQ_idcode().
00488 {
00489 if( string == NULL ) string = "ElvisTheKing" ;
00490 return MD5_B64_array( strlen(string) , string ) ;
00491 }
|
|
||||||||||||
|
Digest an array and returns the printable string of the result, stored in a malloc()-ed array (length=32+1 bytes). ------------------------------------------------------------------------ Definition at line 372 of file niml_md5.c. References malloc, and MD5_static_array(). Referenced by MD5_malloc_string().
00373 {
00374 char *st , *dy ;
00375 st = MD5_static_array( n , bytes ) ;
00376 if( st == NULL ) return NULL ;
00377 dy = (char *) malloc(33) ; strcpy(dy,st) ; return dy ;
00378 }
|
|
|
Digests a file and prints the result, stored in a malloc()-ed array (length=32+1 bytes). ------------------------------------------------------------------------ Definition at line 433 of file niml_md5.c. References malloc, and MD5_static_file().
00434 {
00435 char *st , *dy ;
00436
00437 st = MD5_static_file( filename ) ;
00438 if( st == NULL ) return NULL ;
00439 dy = (char *) malloc(33) ; strcpy(dy,st) ; return dy ;
00440 }
|
|
|
Digest a C string and returns the printable string of the result, stored in a malloc()-ed array (length=32+1 bytes). ------------------------------------------------------------------------ Definition at line 396 of file niml_md5.c. References MD5_malloc_array().
00397 {
00398 if( string == NULL ) string = "ElvisTheKing" ;
00399 return MD5_malloc_array( strlen(string)+1 , string ) ;
00400 }
|
|
||||||||||||
|
Digest an array and returns the printable string of the result, stored in a static array (length=32+1 bytes). ------------------------------------------------------------------------ Definition at line 353 of file niml_md5.c. References MD5_static_printf(), MD5Final(), MD5Init(), and MD5Update(). Referenced by MD5_malloc_array(), and MD5_static_string().
00354 {
00355 MD5_CTX context;
00356 unsigned char digest[16];
00357
00358 if( n < 0 || bytes == NULL ) return NULL ;
00359
00360 MD5Init( &context ) ;
00361 MD5Update( &context, (unsigned char *)bytes, n ) ;
00362 MD5Final( digest, &context ) ;
00363
00364 return MD5_static_printf(digest) ;
00365 }
|
|
|
Digests a file and prints the result, stored in a static array (length=32+1 bytes). ------------------------------------------------------------------------ Definition at line 407 of file niml_md5.c. References file, MD5_static_printf(), MD5Final(), MD5Init(), and MD5Update(). Referenced by MD5_malloc_file().
00408 {
00409 FILE *file;
00410 MD5_CTX context;
00411 int len;
00412 unsigned char buffer[1024] ;
00413 unsigned char digest[16] ;
00414
00415 if( (file = fopen(filename, "rb")) == NULL ) return NULL ;
00416
00417 MD5Init( &context ) ;
00418
00419 while( len = fread(buffer, 1, 1024, file) )
00420 MD5Update( &context, buffer, len ) ;
00421
00422 MD5Final( digest, &context );
00423 fclose (file);
00424
00425 return MD5_static_printf( digest ) ;
00426 }
|
|
|
Digest a C string and returns the printable string of the result, stored in a static array (length=32+1 bytes). ------------------------------------------------------------------------ Definition at line 385 of file niml_md5.c. References MD5_static_array().
00386 {
00387 if( string == NULL ) string = "ElvisTheKing" ;
00388 return MD5_static_array( strlen(string) , string ) ;
00389 }
|
|
|
Create a Dtable with len slots. ------------------------------------------------------------------- Definition at line 12 of file niml_dtable.c. References calloc, dt, Dtable::hta, Dtable::htb, and new_Htable(). Referenced by DRAW_label_CB(), and Dtable_from_nimlstring().
00013 {
00014 Dtable *dt ;
00015 dt = (Dtable *) calloc( 1 , sizeof(Dtable) ) ;
00016 dt->hta = new_Htable( len ) ;
00017 dt->htb = new_Htable( len ) ;
00018 return dt ;
00019 }
|
|
|
Create a new Htable, with len slots. --------------------------------------------------------- Definition at line 44 of file niml_htable.c. References calloc, Htable::ctab, Htable::len, Htable::ntab, and Htable::vtab. Referenced by AFNI_finalize_read_sess_CB(), AFNI_read_inputs(), AFNI_rescan_session_NEW(), AFNI_rescan_session_OLD(), init_registry(), new_Dtable(), NI_register_struct(), resize_Htable(), setup_basic_types(), and THD_init_session().
00045 {
00046 Htable *ht ;
00047
00048 if( len <= 7 ) len = 7 ; /* smallest allowed */
00049 else if( len%2 == 0 ) len++ ; /* mustn't be even */
00050
00051 ht = (Htable *) calloc( 1 , sizeof(Htable) ) ;
00052
00053 ht->len = len ;
00054 ht->vtab = (void ***) calloc( len , sizeof(void **) ) ;
00055 ht->ctab = (char ***) calloc( len , sizeof(char **) ) ;
00056 ht->ntab = (int *) calloc( len , sizeof(int) ) ;
00057
00058 return ht ;
00059 }
|
|
||||||||||||||||
|
Add a vector (column) of data to a data element.
Definition at line 442 of file niml_element.c. References NI_copy_column(), NI_ELEMENT_TYPE, NI_malloc, NI_realloc, NI_rowtype_find_code(), NI_rowtype::size, typ, NI_element::type, NI_element::vec, NI_element::vec_len, NI_element::vec_num, and NI_element::vec_typ. Referenced by AFNI_niml_redisplay_CB(), AFNI_niml_viewpoint_CB(), AGNI_nod_to_NIML_col(), Dtable_to_nimlstring(), intvec_to_niml(), main(), matrix_to_niml(), mri_to_niml(), NI_add_column_stride(), stringvec_to_niml(), SUMA_FakeIt(), SUMA_ixyz_to_NIML(), SUMA_makeNI_CrossHair(), SUMA_makeNI_SurfIJK(), SUMA_makeNI_SurfINORM(), SUMA_makeNI_SurfIXYZ(), SUMA_Write_DrawnROI_NIML(), symvec_to_niml(), THD_nimlize_dsetatr(), THD_subbrick_to_niml(), and v2s_write_outfile_niml().
00443 {
00444 int nn ;
00445 NI_rowtype *rt ;
00446
00447 /* check for reasonable inputs */
00448
00449 if( nel == NULL || nel->vec_len <= 0 ) return ;
00450 if( nel->type != NI_ELEMENT_TYPE ) return ;
00451 rt = NI_rowtype_find_code(typ) ; if( rt == NULL ) return ;
00452
00453 /* get number of vectors currently in element */
00454
00455 nn = nel->vec_num ;
00456
00457 /* add 1 to the vec_typ array */
00458
00459 nel->vec_typ = NI_realloc( nel->vec_typ, int, sizeof(int)*(nn+1) ) ;
00460 nel->vec_typ[nn] = typ ;
00461
00462 /* add 1 element to the vec array, and copy data into it */
00463
00464 nel->vec = NI_realloc( nel->vec , void*, sizeof(void *)*(nn+1) ) ;
00465 if( arr != NULL )
00466 nel->vec[nn] = NI_copy_column( rt , nel->vec_len , arr ) ;
00467 else
00468 nel->vec[nn] = NI_malloc(void, rt->size * nel->vec_len ) ;
00469
00470 /* add 1 to the count of vectors */
00471
00472 nel->vec_num = nn+1 ;
00473 return ;
00474 }
|
|
||||||||||||||||||||
|
As in NI_add_column(), but adding every stride-th element from arr. Thus, arr should be at least nel->vec_len * stride elements long. -------------------------------------------------------------------------- Definition at line 517 of file niml_element.c. References NI_add_column(), NI_ELEMENT_TYPE, NI_insert_value(), NI_rowtype_find_code(), NI_rowtype::size, stride, typ, NI_element::type, NI_element::vec_len, and NI_element::vec_num. Referenced by SUMA_AddDsetColAttr(), SUMA_AddDsetNelCol(), SUMA_AddGenDsetColAttr(), SUMA_AddNelCol(), SUMA_AddNgrHist(), SUMA_Mesh_IJK2Mesh_IJK_nel(), SUMA_NodeXYZ2NodeXYZ_nel(), and SUMA_oDsetNel2nDsetNgr().
00518 {
00519 int nn , ii ;
00520 NI_rowtype *rt ;
00521 char *idat ;
00522
00523 /* check for reasonable inputs */
00524
00525 if( nel == NULL || nel->vec_len <= 0 ) return ;
00526 if( nel->type != NI_ELEMENT_TYPE ) return ;
00527 rt = NI_rowtype_find_code(typ) ; if( rt == NULL ) return ;
00528
00529 /* add an empty column */
00530
00531 NI_add_column( nel , typ , NULL ) ;
00532 if( arr == NULL ) return ; /* no input data ==> we're done */
00533
00534 /* loop over inputs and put them in one at a time */
00535
00536 nn = nel->vec_num-1 ;
00537 idat = (char *) arr ;
00538
00539 for( ii=0 ; ii < nel->vec_len ; ii++ )
00540 NI_insert_value( nel , ii , nn , idat + (ii*stride*rt->size) ) ;
00541
00542 return ;
00543 }
|
|
||||||||||||
|
Add an element to a group element. ------------------------------------------------------------------------- Definition at line 955 of file niml_element.c. References NI_element_type(), NI_GROUP_TYPE, NI_realloc, NI_group::part, NI_group::part_num, NI_group::part_typ, tt, and NI_group::type. Referenced by main(), NI_read_element(), SUMA_AddDsetColAttr(), SUMA_AddGenDsetColAttr(), SUMA_AddNgrHist(), SUMA_NewDsetGrp(), SUMA_oDsetNel2nDsetNgr(), SUMA_SO2nimlSO(), THD_dataset_to_niml(), and THD_nimlize_dsetatr().
00956 {
00957 int nn , tt=NI_element_type(nini) ;
00958
00959 if( ngr == NULL || ngr->type != NI_GROUP_TYPE || tt < 0 ) return ;
00960
00961 nn = ngr->part_num ;
00962
00963 ngr->part_typ = NI_realloc( ngr->part_typ , int, sizeof(int)*(nn+1) ) ;
00964 ngr->part_typ[nn] = tt ;
00965 ngr->part = NI_realloc( ngr->part , void*, sizeof(void *)*(nn+1) );
00966 ngr->part[nn] = nini ;
00967 ngr->part_num = nn+1 ;
00968 return ;
00969 }
|
|
|
Externally callable routine to add a host to the trusted list. If call with NULL, will just initialize the default trusted host list. ---------------------------------------------------------------------------- Definition at line 675 of file niml_stream.c. References add_trusted_host(), host_num, and init_trusted_list(). Referenced by main(), NI_suck_stream(), and TRUST_addhost().
00676 {
00677 if( host_num == 0 ) init_trusted_list() ;
00678 if( hostname == NULL || hostname[0] == '\0' ) return ;
00679 add_trusted_host(hostname) ;
00680 }
|
|
||||||||||||
|
Change the length of all the columns in a data element.
Definition at line 485 of file niml_element.c. References NI_ELEMENT_TYPE, NI_realloc, NI_rowtype_find_code(), NI_rowtype::size, NI_element::type, NI_element::vec, NI_element::vec_filled, NI_element::vec_len, NI_element::vec_num, and NI_element::vec_typ.
00486 {
00487 int oldlen , ii ;
00488 NI_rowtype *rt ;
00489 char *pt ;
00490
00491 if( nel == NULL || nel->type != NI_ELEMENT_TYPE ) return ;
00492 if( nel->vec_len <= 0 || newlen <= 0 ) return ;
00493
00494 if( nel->vec_num == 0 ){ /* if have no data yet */
00495 nel->vec_len = nel->vec_filled = newlen; return;
00496 }
00497
00498 oldlen = nel->vec_len ; if( oldlen == newlen ) return ;
00499
00500 for( ii=0 ; ii < nel->vec_num ; ii++ ){
00501 rt = NI_rowtype_find_code( nel->vec_typ[ii] ) ;
00502 nel->vec[ii] = NI_realloc( nel->vec[ii] , void , rt->size * newlen ) ;
00503 if( oldlen < newlen ){
00504 pt = ((char *)nel->vec[ii]) + (rt->size * oldlen) ; /* zero fill */
00505 memset( pt , 0 , (newlen-oldlen)*rt->size ) ; /* new data! */
00506 }
00507 }
00508
00509 nel->vec_len = nel->vec_filled = newlen ; return ;
00510 }
|
|
||||||||||||||||||||
|
Decode Base64 data from the NI_stream ns into a rowtype struct *dpt.
Definition at line 1680 of file niml_rowtype.c. References NI_rowtype::code, NI_free, NI_malloc, NI_stream_readbuf64(), NI_STRING, NI_swap4(), NI_rowtype::part_dim, NI_rowtype::part_num, NI_rowtype::part_off, NI_rowtype::part_rtp, NI_rowtype::psiz, ROWTYPE_is_varsize, ROWTYPE_part_dimen, NI_rowtype::size, and swap. Referenced by NI_read_columns().
01681 {
01682 int nn , jj ;
01683
01684 if( rt->code == NI_STRING ) return 0 ; /* shouldn't happen */
01685
01686 if( rt->size == rt->psiz ){ /* fixed-size type with no padding */
01687 /* ==> can read directly into data struct */
01688
01689 jj = NI_stream_readbuf64( ns , (char *)dpt , rt->size ) ;
01690 return (jj == rt->size) ;
01691
01692 } else { /* derived type */
01693
01694 char *dat = (char *)dpt , **aaa = NULL ;
01695 int ii , naaa = 0 , iaaa = 0 ;
01696
01697 if( ROWTYPE_is_varsize(rt) ){ /* variable dim arrays inside */
01698 for( naaa=ii=0 ; ii < rt->part_num ; ii++ )
01699 if( rt->part_dim[ii] >= 0 ) naaa++ ; /* count var dim arrays */
01700 if( naaa > 0 )
01701 aaa = NI_malloc(char*, sizeof(char *)*naaa) ; /* save their addresses */
01702 } /* for possible deletion later */
01703
01704 /* loop over parts and load them;
01705 set nn=0 if read fails at any part (and break out of read loop) */
01706
01707 for( nn=1,ii=0 ; ii < rt->part_num ; ii++ ){
01708
01709 if( rt->part_dim[ii] < 0 ){ /* read one fixed dim part */
01710
01711 nn = NI_base64_to_val( ns, rt->part_rtp[ii], dat+rt->part_off[ii], 0 );
01712
01713 } else { /* read var dim array */
01714
01715 char **apt = (char **)(dat+rt->part_off[ii]); /* data in struct */
01716 /* will be ptr to array */
01717 int dim = ROWTYPE_part_dimen(rt,dat,ii) ; /* dimension of part */
01718 int siz = rt->part_rtp[ii]->size ; /* size of one part */
01719
01720 if( swap ) NI_swap4( 1 , &dim ) ; /* byte-swap dim, which was */
01721 /* just read in a moment ago */
01722
01723 if( dim > 0 ){ /* need to get some data */
01724 *apt = NI_malloc(char, siz * dim ); /* make array */
01725
01726 if( siz != rt->part_rtp[ii]->psiz ){ /* padded values ==> */
01727 for( jj=0 ; jj < dim ; jj++ ){ /* read 1 val at a time */
01728 nn = NI_base64_to_val( ns, rt->part_rtp[ii],
01729 *apt + siz * jj , 0 ) ;
01730 if( !nn ) break ; /* bad read */
01731 }
01732
01733 } else { /* unpadded values ==> read all at once */
01734 jj = NI_stream_readbuf64( ns , *apt , siz*dim ) ;
01735 nn = ( jj == siz*dim ) ;
01736 }
01737
01738 } else {
01739 *apt = NULL ; /* dim=0 ==> no array needed */
01740 }
01741 aaa[iaaa++] = *apt ; /* save for possible deletion */
01742 /* if read fails later in loop */
01743 }
01744
01745 if( !nn ) break ; /* some read was bad */
01746 } /* end of loop over parts */
01747
01748 /* bad news ==> delete any allocated var dim arrays */
01749
01750 if( !nn ){
01751 for( ii=0 ; ii < iaaa ; ii++ ) NI_free( aaa[ii] ) ;
01752 }
01753 NI_free( aaa ) ; /* don't need list of var dim arrays no more */
01754 }
01755
01756 return nn ;
01757 }
|
|
||||||||||||
|
|
|
||||||||||||||||||||
|
Decode binary data from the NI_stream ns into a rowtype struct *dpt.
Definition at line 1591 of file niml_rowtype.c. References NI_rowtype::code, NI_free, NI_malloc, NI_stream_readbuf(), NI_STRING, NI_swap4(), NI_rowtype::part_dim, NI_rowtype::part_num, NI_rowtype::part_off, NI_rowtype::part_rtp, NI_rowtype::psiz, ROWTYPE_is_varsize, ROWTYPE_part_dimen, NI_rowtype::size, and swap. Referenced by NI_read_columns().
01592 {
01593 int nn , jj ;
01594
01595 if( rt->code == NI_STRING ) return 0 ; /* shouldn't happen */
01596
01597 if( rt->size == rt->psiz ){ /* fixed-size type with no padding */
01598 /* ==> can read directly into data struct */
01599
01600 jj = NI_stream_readbuf( ns , (char *)dpt , rt->size ) ;
01601 return (jj == rt->size) ;
01602
01603 } else { /* derived type */
01604
01605 char *dat = (char *)dpt , **aaa = NULL ;
01606 int ii , naaa = 0 , iaaa = 0 ;
01607
01608 if( ROWTYPE_is_varsize(rt) ){ /* variable dim arrays inside */
01609 for( naaa=ii=0 ; ii < rt->part_num ; ii++ )
01610 if( rt->part_dim[ii] >= 0 ) naaa++ ; /* count var dim arrays */
01611 if( naaa > 0 )
01612 aaa = NI_malloc(char*, sizeof(char *)*naaa) ; /* save their addresses */
01613 } /* for possible deletion later */
01614
01615 /* loop over parts and load them;
01616 set nn=0 if read fails at any part (and break out of read loop) */
01617
01618 for( nn=1,ii=0 ; ii < rt->part_num ; ii++ ){
01619
01620 if( rt->part_dim[ii] < 0 ){ /* read one fixed dim part */
01621
01622 nn = NI_binary_to_val( ns, rt->part_rtp[ii], dat+rt->part_off[ii], 0 );
01623
01624 } else { /* read var dim array */
01625
01626 char **apt = (char **)(dat+rt->part_off[ii]); /* data in struct */
01627 /* will be ptr to array */
01628 int dim = ROWTYPE_part_dimen(rt,dat,ii) ; /* dimension of part */
01629 int siz = rt->part_rtp[ii]->size ; /* size of one part */
01630
01631 if( swap ) NI_swap4( 1 , &dim ) ; /* byte-swap dim, which was */
01632 /* just read in a moment ago */
01633
01634 if( dim > 0 ){ /* need to get some data */
01635 *apt = NI_malloc(char, siz * dim ); /* make array */
01636
01637 if( siz != rt->part_rtp[ii]->psiz ){ /* padded values ==> */
01638 for( jj=0 ; jj < dim ; jj++ ){ /* read 1 val at a time */
01639 nn = NI_binary_to_val( ns, rt->part_rtp[ii],
01640 *apt + siz * jj , 0 ) ;
01641 if( !nn ) break ; /* bad read */
01642 }
01643
01644 } else { /* unpadded values ==> read all at once */
01645 jj = NI_stream_readbuf( ns , *apt , siz*dim ) ;
01646 nn = ( jj == siz*dim ) ;
01647 }
01648
01649 } else {
01650 *apt = NULL ; /* dim=0 ==> no array needed */
01651 }
01652 aaa[iaaa++] = *apt ; /* save for possible deletion */
01653 /* if read fails later in loop */
01654 }
01655
01656 if( !nn ) break ; /* some read was bad */
01657 } /* end of loop over parts */
01658
01659 /* bad news ==> delete any allocated var dim arrays */
01660
01661 if( !nn ){
01662 for( ii=0 ; ii < iaaa ; ii++ ) NI_free( aaa[ii] ) ;
01663 }
01664 NI_free( aaa ) ; /* don't need list of var dim arrays no more */
01665 }
01666
01667 return nn ;
01668 }
|
|
|
Find the byte order on this system. Return is either NI_LSB_FIRST or NI_MSB_FIRST. We are assuming that there are only 2 possible order, which is of course false. ----------------------------------------------------------------- Definition at line 14 of file niml_byteorder.c. References NI_LSB_FIRST, and NI_MSB_FIRST. Referenced by NI_read_element(), NI_write_element(), and THD_write_1D().
00015 {
00016 union { unsigned char bb[2] ;
00017 short ss ; } fred ;
00018
00019 fred.bb[0] = 1 ; fred.bb[1] = 0 ;
00020
00021 return (fred.ss == 1) ? NI_LSB_FIRST : NI_MSB_FIRST ;
00022 }
|
|
|
Return time elapsed since first call to this routine (msec). Note this will overflow an int after 24+ days. You probably don't want to use this if the program will be running continuously for such a long time. ----------------------------------------------------------------- Definition at line 62 of file niml_util.c. Referenced by AFNI_faceup(), AFNI_niml_redisplay_CB(), AFNI_niml_workproc(), ISQ_drawing_EV(), main(), mri_warp3d_align_one(), mri_warp3D_align_setup(), NI_read_element(), NI_stream_fillbuf(), NI_suck_stream(), NI_write_columns(), process_NIML_AFNI_dataset(), process_NIML_AFNI_volumedata(), process_NIML_Node_ROI(), process_NIML_SUMA_ijk(), process_NIML_SUMA_ixyz(), process_NIML_SUMA_node_normals(), scan_for_angles(), SHM_goodcheck(), SHM_readcheck(), and SUMA_niml_workproc().
00063 {
00064 struct timeval new_tval ;
00065 struct timezone tzone ;
00066 static struct timeval old_tval ;
00067 static int first = 1 ;
00068
00069 gettimeofday( &new_tval , &tzone ) ;
00070
00071 if( first ){
00072 old_tval = new_tval ;
00073 first = 0 ;
00074 return 0 ;
00075 }
00076
00077 if( old_tval.tv_usec > new_tval.tv_usec ){
00078 new_tval.tv_usec += 1000000 ;
00079 new_tval.tv_sec -- ;
00080 }
00081
00082 return (int)( (new_tval.tv_sec - old_tval.tv_sec )*1000.0
00083 +(new_tval.tv_usec - old_tval.tv_usec)*0.001 + 0.5 ) ;
00084 }
|
|
|
See if we can convert an element to an object. On input:
Definition at line 154 of file niml_sucker.c. References IDCODE_LEN, NI_strncpy(), num_converters, NI_objcontainer::self_name, and NI_converterstruct::to_obj. Referenced by NI_suck_stream().
00155 {
00156 int cc , nn ;
00157
00158 if( dc == NULL ) return ;
00159
00160 if( strcmp(dc->typename,"NI_ELEMENT") != 0 &&
00161 strcmp(dc->typename,"NI_GROUP" ) != 0 ) return ;
00162
00163 for( cc=0 ; cc < num_converters ; cc++ )
00164 if( strcmp(converters[cc].self_name,dc->self_name) == 0 ) break ;
00165
00166 if( cc == num_converters ) return ;
00167
00168 nn = converters[cc].to_obj( dc ) ;
00169 if( nn > 0 )
00170 NI_strncpy( dc->typename , dc->self_name , IDCODE_LEN ) ;
00171
00172 return ;
00173 }
|
|
|
|
|
||||||||||||||||
|
Copy a column of rowtype structs, including var dim arrays. Return is the pointer to the copy. ------------------------------------------------------------------------------ Definition at line 2042 of file niml_rowtype.c. References NI_malloc, NI_strdup(), NI_STRING, NI_rowtype::part_dim, NI_rowtype::part_num, NI_rowtype::part_off, NI_rowtype::part_rtp, NI_rowtype::part_typ, ROWTYPE_is_varsize, ROWTYPE_part_dimen, and NI_rowtype::size. Referenced by NI_add_column().
02043 {
02044 char *dat=(char *)cpt , *ndat , *nptr , *qpt ;
02045 int ii , jj , kk ;
02046
02047 if( rt == NULL || dat == NULL || col_len < 1 ) return NULL ;
02048
02049 /* make a quick (surface) copy */
02050
02051 ndat = NI_malloc(char, rt->size * col_len ) ; /* new data column */
02052 memcpy( ndat , dat , rt->size * col_len ) ; /* the quick copying */
02053
02054 /* copy any var dim arrays inside, since the pointers
02055 in ndat right now still point to data in dat,
02056 but we want ndat to be entirely self-contained! */
02057
02058 if( ROWTYPE_is_varsize(rt) ){
02059 for( ii=0 ; ii < col_len ; ii++ ){ /* loop over structs */
02060 nptr = ndat + rt->size * ii ; /* ptr to this struct */
02061 for( jj=0 ; jj < rt->part_num ; jj++ ){ /* loop over parts */
02062
02063 if( rt->part_typ[jj] == NI_STRING ){ /* a string part */
02064 char **apt = (char **)(nptr+rt->part_off[jj]) ; /* *apt => data */
02065 qpt = NI_strdup(*apt) ; *apt = qpt ;
02066 } else if( rt->part_dim[jj] >= 0 ){
02067 char **apt = (char **)(nptr+rt->part_off[jj]) ; /* *apt => data */
02068 if( *apt != NULL ){
02069 kk = ROWTYPE_part_dimen(rt,nptr,jj) * rt->part_rtp[jj]->size ;
02070 qpt = NI_malloc(char, kk) ; memcpy(qpt,*apt,kk) ; *apt = qpt ;
02071 }
02072 }
02073 }
02074 }
02075 }
02076
02077 return ndat ;
02078 }
|
|
|
Make a copy of a struct, as opposed to a new reference (which is what NI_pointto_struct() does). ------------------------------------------------------------- Definition at line 218 of file niml_struct.c. References DUPLICATE_STRUCT, NI_AFFINE_3DMAP_TYPE, NI_BYTE_VECTOR_TYPE, NI_COMPLEX_VECTOR_TYPE, NI_DATASET_TYPE, NI_dataset_vecnum, NI_datatype_size, NI_DOUBLE_VECTOR_TYPE, NI_FLOAT_ONE_TYPE, NI_FLOAT_VECTOR_TYPE, NI_index_t, NI_INT_VECTOR_TYPE, NI_malloc, NI_POINTS_DOMAIN_TYPE, NI_RECT_DOMAIN_TYPE, NI_RGB_VECTOR_TYPE, NI_RGBA_VECTOR_TYPE, NI_SHORT_VECTOR_TYPE, NI_STATISTIC_TYPE, NI_strdup(), NI_STRING_VECTOR_TYPE, NI_STRUCT_TYPE, and NI_VECTOR_TYPE.
00219 {
00220 NI_struct *nd = (NI_struct *)ndd ;
00221 NI_struct *ndnew=NULL ;
00222
00223 if( nd == NULL ) return NULL ; /* bad input :-( */
00224
00225 switch( nd->type ){ /* N.B.: there is no default */
00226
00227 case NI_STRUCT_TYPE:{
00228 DUPLICATE_STRUCT(NI_struct) ;
00229 }
00230 break ;
00231
00232 case NI_FLOAT_ONE_TYPE:{
00233 DUPLICATE_STRUCT(NI_float_one) ;
00234 nn->val = qq->val ;
00235 }
00236 break ;
00237
00238 case NI_AFFINE_3DMAP_TYPE:{
00239 DUPLICATE_STRUCT(NI_affine_3dmap) ;
00240 nn->mat[0][0] = qq->mat[0][0]; nn->mat[0][1] = qq->mat[0][1];
00241 nn->mat[0][2] = qq->mat[0][2]; nn->mat[0][3] = qq->mat[0][3];
00242 nn->mat[1][0] = qq->mat[1][0]; nn->mat[1][1] = qq->mat[1][1];
00243 nn->mat[1][2] = qq->mat[1][2]; nn->mat[1][3] = qq->mat[1][3];
00244 nn->mat[2][0] = qq->mat[2][0]; nn->mat[2][1] = qq->mat[2][1];
00245 nn->mat[2][2] = qq->mat[2][2]; nn->mat[2][3] = qq->mat[2][3];
00246 nn->mat[3][0] = qq->mat[3][0]; nn->mat[3][1] = qq->mat[3][1];
00247 nn->mat[3][2] = qq->mat[3][2]; nn->mat[3][3] = qq->mat[3][3];
00248 }
00249 break ;
00250
00251 case NI_RECT_DOMAIN_TYPE:{
00252 DUPLICATE_STRUCT(NI_rect_domain) ;
00253 nn->nx = qq->nx; nn->ny = qq->ny; nn->nz = qq->nz; nn->nt = qq->nt;
00254 nn->dx = qq->dx; nn->dy = qq->dy; nn->dz = qq->dz; nn->dt = qq->dt;
00255 nn->xo = qq->xo; nn->yo = qq->yo; nn->zo = qq->zo; nn->to = qq->to;
00256 }
00257 break ;
00258
00259 case NI_STATISTIC_TYPE:{
00260 NI_index_t ii ;
00261 DUPLICATE_STRUCT(NI_statistic) ;
00262 nn->statcode = qq->statcode ;
00263 nn->param_num = qq->param_num ;
00264 if( qq->param != NULL ){
00265 nn->param = NI_malloc(NI_struct*, sizeof(NI_struct *)*nn->param_num) ;
00266 for( ii=0 ; ii < nn->param_num ; ii++ )
00267 nn->param[ii] = (NI_struct *)NI_copy_struct( qq->param[ii] ) ; /* recursion */
00268 } else {
00269 nn->param = NULL ;
00270 }
00271 }
00272 break ;
00273
00274 case NI_VECTOR_TYPE:
00275 case NI_BYTE_VECTOR_TYPE:
00276 case NI_SHORT_VECTOR_TYPE:
00277 case NI_INT_VECTOR_TYPE:
00278 case NI_FLOAT_VECTOR_TYPE:
00279 case NI_DOUBLE_VECTOR_TYPE:
00280 case NI_COMPLEX_VECTOR_TYPE:
00281 case NI_RGB_VECTOR_TYPE:
00282 case NI_RGBA_VECTOR_TYPE:{
00283 NI_index_t ii ;
00284 DUPLICATE_STRUCT(NI_vector) ;
00285 nn->vec_len = qq->vec_len ;
00286 nn->vec_typ = qq->vec_typ ;
00287 if( qq->vec != NULL ){ /* copy array */
00288 ii = nn->vec_len * NI_datatype_size(nn->vec_typ) ;
00289 nn->vec = NI_malloc(void, ii) ;
00290 memcpy( nn->vec , qq->vec , ii ) ;
00291 } else {
00292 nn->vec = NULL ;
00293 }
00294 if( qq->vec_range != NULL ){ /* copy array */
00295 ii = 2 * NI_datatype_size(nn->vec_typ) ;
00296 nn->vec_range = NI_malloc(void, ii) ;
00297 memcpy( nn->vec_range , qq->vec_range , ii ) ;
00298 } else {
00299 nn->vec_range = NULL ;
00300 }
00301 nn->statistic = (NI_statistic *)NI_copy_struct( qq->statistic ) ; /* recursion */
00302 }
00303 break ;
00304
00305 case NI_STRING_VECTOR_TYPE:{
00306 NI_index_t ii ;
00307 DUPLICATE_STRUCT(NI_string_vector) ;
00308 nn->vec_len = qq->vec_len ;
00309 nn->vec_typ = qq->vec_typ ;
00310 if( qq->vec != NULL ){ /* copy array */
00311 nn->vec = NI_malloc(char*, sizeof(char *)*nn->vec_len) ;
00312 for( ii=0 ; ii < nn->vec_len ; ii++ )
00313 nn->vec[ii] = NI_strdup(qq->vec[ii]) ;
00314 } else {
00315 nn->vec = NULL ;
00316 }
00317 nn->vec_range = NULL ; /* string vectors don't use vec_range */
00318 nn->statistic = NULL ;
00319 }
00320 break ;
00321
00322 case NI_POINTS_DOMAIN_TYPE:{
00323 NI_index_t ii ;
00324 DUPLICATE_STRUCT(NI_points_domain) ;
00325 nn->num_node = ii = qq->num_node ;
00326 if( qq->id != NULL ){ /* copy array */
00327 nn->id = NI_malloc(NI_index_t, ii*sizeof(NI_index_t)) ;
00328 memcpy( nn->id , qq->id , ii*sizeof(NI_index_t) ) ;
00329 }
00330 if( qq->x != NULL ){ /* copy array */
00331 nn->x = NI_malloc(float, ii*sizeof(float)) ;
00332 memcpy( nn->x , qq->x , ii*sizeof(float) ) ;
00333 }
00334 if( qq->y != NULL ){ /* copy array */
00335 nn->y = NI_malloc(float, ii*sizeof(float)) ;
00336 memcpy( nn->y , qq->y , ii*sizeof(float) ) ;
00337 }
00338 if( qq->z != NULL ){ /* copy array */
00339 nn->z = NI_malloc(float, ii*sizeof(float)) ;
00340 memcpy( nn->z , qq->z , ii*sizeof(float) ) ;
00341 }
00342 nn->seq = qq->seq; nn->seqbase = qq->seqbase; nn->sorted = qq->sorted;
00343 }
00344 break ;
00345
00346 case NI_DATASET_TYPE:{
00347 DUPLICATE_STRUCT(NI_dataset) ;
00348 nn->num_node = qq->num_node ;
00349 nn->num_val = qq->num_val ;
00350 nn->order = qq->order ;
00351 if( qq->vec != NULL ){
00352 NI_index_t nv , ii ;
00353 nv = NI_dataset_vecnum(nn) ;
00354 nn->vec = NI_malloc(NI_vector*, sizeof(NI_vector *)*nv) ;
00355 for( ii=0 ; ii < nv ; ii++ )
00356 nn->vec[ii] = (NI_vector *)NI_copy_struct( qq->vec[ii] ) ; /* recursion */
00357 } else {
00358 nn->vec = NULL ;
00359 }
00360 nn->domain = (NI_struct *)NI_copy_struct( qq->domain ) ; /* recursion */
00361 }
00362 break ;
00363
00364 }
00365
00366 return (void *)ndnew ;
00367 }
|
|
|
Transpose a dataset, so that rows are columns and vice- versa.
Definition at line 28 of file niml_dataset.c. References COPY_BASIC_STRUCT, NI_dataset::domain, NI_DATASET_TYPE, NI_dataset_veclen, NI_dataset_vecnum, NI_datatype_size, NI_index_t, NI_malloc, NI_new, NI_new_vector(), NI_opposite_order, NI_pointto_struct(), NI_set_vector_range(), NI_strdup(), NI_STRING, NI_dataset::num_node, NI_dataset::num_val, NI_dataset::order, NI_vector::statistic, tt, NI_dataset::vec, NI_vector::vec, and NI_vector::vec_typ.
00029 {
00030 NI_dataset *ndnew , *nd = (NI_dataset *)ndd ;
00031 NI_index_t ii,jj , nvec_old,nvec_new , len_old,len_new ;
00032 int tt , lt ;
00033
00034 if( nd == NULL ||
00035 nd->type != NI_DATASET_TYPE ||
00036 nd->vec == NULL ) return NULL ; /* bad input */
00037
00038 /* check if all columns have same type, etc. */
00039
00040 nvec_old = NI_dataset_vecnum(nd) ;
00041 len_old = NI_dataset_veclen(nd) ;
00042
00043 if( nvec_old <= 0 || len_old <= 0 ) return NULL ;
00044 if( nd->vec[0] == NULL ) return NULL ;
00045 if( nd->vec[0]->statistic != NULL ) return NULL ;
00046
00047 tt = nd->vec[0]->vec_typ ;
00048 lt = NI_datatype_size(tt) ;
00049 for( ii=1 ; ii < nvec_old ; ii++ ){
00050 if( nd->vec[ii] == NULL ) return NULL ;
00051 if( nd->vec[ii]->vec_typ != tt ) return NULL ;
00052 if( nd->vec[ii]->statistic != NULL ) return NULL ;
00053 }
00054
00055 /* create output struct */
00056
00057 ndnew = NI_new(NI_dataset) ;
00058 COPY_BASIC_STRUCT(ndnew,nd) ;
00059 ndnew->num_node = nd->num_node ;
00060 ndnew->num_val = nd->num_val ;
00061 ndnew->order = NI_opposite_order(nd->order) ; /* flipped */
00062 ndnew->domain = (NI_struct *)NI_pointto_struct(nd->domain) ; /* same domain */
00063
00064 /* create new vectors */
00065
00066 nvec_new = NI_dataset_vecnum(ndnew) ;
00067 len_new = NI_dataset_veclen(ndnew) ;
00068
00069 ndnew->vec = NI_malloc(NI_vector*, sizeof(NI_vector *) * nvec_new ) ;
00070 for( ii=0 ; ii < nvec_new ; ii++ )
00071 ndnew->vec[ii] = (NI_vector *)NI_new_vector( tt , len_new ) ;
00072
00073 /* copy data from old vectors to new vectors */
00074
00075 if( tt != NI_STRING ){ /* copy fixed length content */
00076
00077 char *vnew , *vold ;
00078 for( ii=0 ; ii < nvec_new ; ii++ ){
00079 vnew = (char *)ndnew->vec[ii]->vec ;
00080 for( jj=0 ; jj < nvec_old ; jj++ ){
00081 vold = (char *)nd->vec[jj]->vec ;
00082 memcpy( vnew+lt*jj , vold+lt*ii , lt ) ;
00083 }
00084 }
00085
00086 for( ii=0 ; ii < nvec_new ; ii++ )
00087 NI_set_vector_range( ndnew->vec[ii] ) ;
00088
00089 } else { /* duplicate strings */
00090
00091 char **vnew , **vold ;
00092 for( ii=0 ; ii < nvec_new ; ii++ ){
00093 vnew = (char **)ndnew->vec[ii]->vec ;
00094 for( jj=0 ; jj < nvec_old ; jj++ ){
00095 vold = (char **)nd->vec[jj]->vec ;
00096 vnew[jj] = NI_strdup( vold[ii] ) ;
00097 }
00098 }
00099
00100 }
00101
00102 /** done **/
00103
00104 return (void *)ndnew ;
00105 }
|
|
||||||||||||
|
Decode a single string into a bunch of strings, separated by characters from the list in sep.
Definition at line 338 of file niml_header.c. References NI_malloc, NI_realloc, NI_strlen(), NI_str_array::num, and NI_str_array::str. Referenced by basis_parser(), make_empty_data_element(), mri_1D_fromstring(), NI_rowtype_define(), SYM_expand_ranges(), THD_datablock_from_atr(), THD_load_tcat(), THD_open_3D(), and THD_open_tcat().
00339 {
00340 NI_str_array *sar ;
00341 int num , nn,id,jd , lss ;
00342
00343 if( ss == NULL || ss[0] == '\0' ) return NULL ; /* bad input */
00344
00345 if( sep == NULL || sep[0] == '\0' ) sep = "," ; /* default sep */
00346
00347 sar = NI_malloc(NI_str_array, sizeof(NI_str_array)) ; /* create output */
00348 sar->num = 0 ; sar->str = NULL ;
00349
00350 /* scan for sub-strings */
00351
00352 lss = NI_strlen(ss) ;
00353 num = id = 0 ;
00354 while( id < lss ){
00355
00356 /* skip current position ahead over whitespace */
00357
00358 while( id < lss && isspace(ss[id]) ) id++ ;
00359 if( id == lss ) break ; /* ran out of string */
00360
00361 jd = id ; /* save current position (start of new string) */
00362
00363 /* skip ahead until ss[id] is a separator [or a space - 10 Dec 2002] */
00364
00365 while( id < lss && strchr(sep,ss[id]) == NULL && !isspace(ss[id]) ) id++;
00366 if( id == jd ){ id++; continue; } /* is only a separator? */
00367
00368 /* new sub-string runs from ss[jd] to ss[id-1] */
00369
00370 sar->str = NI_realloc( sar->str , char*, sizeof(char *)*(num+1) ) ;
00371
00372 nn = id-jd ; /* length of sub-string */
00373 #if 0
00374 while( nn > 0 && isspace(ss[jd+nn-1]) ) nn-- ; /* clip trailing blanks */
00375 #endif
00376 sar->str[num] = NI_malloc(char, nn+1) ; /* make output string */
00377 if( nn > 0 ) memcpy(sar->str[num],ss+jd,nn) ; /* copy sub-string */
00378 sar->str[num++][nn] = '\0' ; /* terminate output */
00379
00380 id++ ; /* skip separator */
00381 }
00382
00383 sar->num = num ; return sar ;
00384 }
|
|
||||||||||||
|
Carry out an action ordered by a "ni_do" element received on the input stream. Actions we know about:
Definition at line 75 of file niml_do.c. References builtin(), doer_func, doer_num, doer_verb, NI_element::name, NI_ELEMENT_TYPE, NI_free, NI_get_attribute(), NI_rowtype_define(), NI_stream_close_keep(), NI_stream_open(), object, tt, and NI_element::type. Referenced by NI_read_element().
00076 {
00077 char *verb , *object ;
00078 int ii , builtin=0 ;
00079
00080 /*- check inputs for OK-ositiness -*/
00081
00082 if( ns == NULL || nel == NULL || nel->type != NI_ELEMENT_TYPE ) return -1 ;
00083
00084 if( strcmp(nel->name ,"ni_do") != 0 &&
00085 strcmp(nel->name+1,"ni_do") != 0 ) return -1 ;
00086
00087 /* 25 Apr 2005: check for diverse forms of the verb and object attributes */
00088
00089 verb = NI_get_attribute( nel , "ni_verb" ) ;
00090 if( verb == NULL ) verb = NI_get_attribute( nel , "verb" ) ;
00091
00092 object = NI_get_attribute( nel , "ni_object" ) ;
00093 if( object == NULL ) object = NI_get_attribute( nel , "object" ) ;
00094 if( object == NULL ) object = NI_get_attribute( nel , "ni_obj" ) ;
00095 if( object == NULL ) object = NI_get_attribute( nel , "obj" ) ;
00096
00097 if( verb == NULL || verb[0] == '\0' ) return -1 ; /* need a verb; */
00098 /* but not always */
00099 /* need an object */
00100 /*******************************************/
00101 /*---- check for various builtin verbs ----*/
00102 /*******************************************/
00103
00104 if( strcmp(verb,"reopen_this") == 0 ){ /****----- reopen stream ------****/
00105
00106 NI_stream_type *nsnew ;
00107
00108 if( object == NULL || object[0] == '\0' ) return -1 ; /* bad */
00109
00110 nsnew = NI_stream_open( object , "r" ) ; /* open new stream */
00111 if( nsnew == NULL ) return -1 ; /* bad */
00112
00113 NI_stream_close_keep(ns,0) ; /* trash old stream */
00114 *ns = *nsnew; NI_free(nsnew); /* replace old guts */
00115 builtin = 1 ;
00116
00117 } /****------------------------- end reopen --------------------------*****/
00118
00119 else if( strcmp(verb,"close_this") == 0 ){ /****-- close this stream -****/
00120
00121 NI_stream_close_keep(ns,0); /* close and mark as dead */
00122 builtin = 1 ;
00123
00124 } /****------------------------ end close_this ------------------------****/
00125
00126 else if( strcmp(verb,"typedef") == 0 ){ /****-- define a NIML type -****/
00127 /**** [12 Feb 2003] ****/
00128 char tnam[256] , tdef[8200] ;
00129 int tt ;
00130
00131 if( object == NULL || object[0] == '\0' ) return -1 ; /* bad */
00132
00133 tnam[0] = tdef[0] = '\0' ;
00134 sscanf(object,"%255s %8199s",tnam,tdef) ;
00135 tt = NI_rowtype_define( tnam , tdef ) ;
00136 if( tt < 0 ) return -1 ; /* bad definition */
00137 builtin = 1 ;
00138
00139 } /****------------------------ end typedef ---------------------------****/
00140
00141 /**************************************************************/
00142 /**** Here, check for user-defined callbacks [12 Feb 2003] ****/
00143
00144 for( ii=0 ; ii < doer_num ; ii++ ){
00145 if( strcmp(verb,doer_verb[ii]) == 0 ){
00146 if( doer_func[ii] != NULL ){
00147 void (*df)(char *,NI_stream_type *,NI_element *) = (ddfun)doer_func[ii] ;
00148 df( object , ns , nel ) ;
00149 }
00150 return 0 ;
00151 }
00152 }
00153
00154 /*--- if we get here, we got a verb we don't recognize ---*/
00155
00156 return ((builtin) ? 0 : -1) ;
00157 }
|
|
|
|
|
|
Return the name of a NI element. If the input is bad, returns a NULL pointer. Do not free this pointer! It points to the name string inside the element struct. ------------------------------------------------------------------------- Definition at line 275 of file niml_element.c. References NI_element::name, NI_group::name, NI_procins::name, NI_ELEMENT_TYPE, NI_GROUP_TYPE, NI_PROCINS_TYPE, NI_element::type, NI_group::type, and NI_procins::type. Referenced by NI_search_group_deep(), and NI_search_group_shallow().
00276 {
00277 NI_element *nel = (NI_element *) nini ;
00278 NI_group *ngr = (NI_group *) nini ;
00279 NI_procins *npi = (NI_procins *) nini ;
00280
00281 if( nini == NULL ) return NULL ;
00282
00283 if( nel->type == NI_ELEMENT_TYPE ) return nel->name ;
00284 if( ngr->type == NI_GROUP_TYPE ) return ngr->name ;
00285 if( npi->type == NI_PROCINS_TYPE ) return npi->name ;
00286
00287 return NULL ;
00288 }
|
|
|
|
|
|
Return the type of something that points to a NI element.
Definition at line 254 of file niml_element.c. References NI_ELEMENT_TYPE, NI_GROUP_TYPE, NI_PROCINS_TYPE, NI_element::type, NI_group::type, and NI_procins::type. Referenced by AFNI_niml_workproc(), AFNI_process_NIML_data(), AIVVV_workproc(), Dtable_from_nimlstring(), main(), NI_add_to_group(), NI_free_element(), NI_get_attribute(), NI_search_group_deep(), NI_set_attribute(), NI_suck_stream(), NI_write_element(), niml_to_mri(), NIML_to_stderr(), SUMA_LoadNimlDset(), SUMA_process_NIML_data(), THD_add_bricks(), THD_dblkatr_from_niml(), THD_niml_to_dataset(), THD_open_3D(), THD_open_nifti(), and THD_read_niml_atr().
00255 {
00256 NI_element *nel = (NI_element *) nini ;
00257 NI_group *ngr = (NI_group *) nini ;
00258 NI_procins *npi = (NI_procins *) nini ; /* 16 Mar 2005 */
00259
00260 if( nini == NULL ) return -1 ;
00261
00262 if( nel->type == NI_ELEMENT_TYPE ) return NI_ELEMENT_TYPE ;
00263 if( ngr->type == NI_GROUP_TYPE ) return NI_GROUP_TYPE ;
00264 if( npi->type == NI_PROCINS_TYPE ) return NI_PROCINS_TYPE ;
00265
00266 return -1 ;
00267 }
|
|
|
Return the file length (-1 if file not found). ---------------------------------------------------------------------------- Definition at line 31 of file niml_util.c. Referenced by NI_stream_open(), read_URL_ftp(), read_URL_http(), and THD_read_niml_atr().
00032 {
00033 static struct stat buf ; int ii ;
00034
00035 if( pathname == NULL ) return -1 ;
00036 ii = stat( pathname , &buf ) ; if( ii != 0 ) return -1 ;
00037 return buf.st_size ;
00038 }
|
|
||||||||||||||||||||||||
|
ZSS; Fills an already created column with values up to vec_filled the values in arr are inserted into nel->vec[nn] -------------------------------------------------------------------------- Definition at line 550 of file niml_element.c. References NI_ELEMENT_TYPE, NI_insert_value(), NI_rowtype_find_code(), NI_rowtype::size, stride, typ, NI_element::type, NI_element::vec, NI_element::vec_filled, NI_element::vec_len, NI_element::vec_num, and NI_element::vec_typ. Referenced by SUMA_FillDsetNelCol(), and SUMA_FillNelCol().
00552 {
00553 int ii , nf;
00554 NI_rowtype *rt ;
00555 char *idat ;
00556
00557 /* check for reasonable inputs */
00558
00559 if( nel == NULL || nel->vec_len <= 0 ) return ;
00560 if( nel->type != NI_ELEMENT_TYPE ) return ;
00561 rt = NI_rowtype_find_code(typ) ; if( rt == NULL ) return ;
00562
00563 /* check for NULL column or other similar errors*/
00564
00565 if( arr == NULL ) return ;
00566 if( nel->vec[nn] == NULL ) return ;
00567 if( nn < 0 || nn >= nel->vec_num ) return ;
00568 if( typ != nel->vec_typ[nn] ) return ;
00569
00570 /* loop over inputs and put them in */
00571
00572 if( nel->vec_filled > 0 && nel->vec_filled <= nel->vec_len )
00573 nf = nel->vec_filled ;
00574 else
00575 nf = nel->vec_len ;
00576
00577 idat = (char *) arr ;
00578
00579 for( ii=0 ; ii < nf ; ii++ )
00580 NI_insert_value( nel , ii , nn , idat + (ii*stride*rt->size) ) ;
00581
00582 return ;
00583 }
|
|
|
Find a struct by its idcode. Definition at line 39 of file niml_struct.c. References findin_Htable().
00040 {
00041 void *vp ;
00042 if( idcode == NULL ) return NULL ; /* nothing to do */
00043 vp = findin_Htable( idcode , ni_struct_table ) ;
00044 return vp ;
00045 }
|
|
||||||||||||||||
|
Delete a column of rowtype structs, including any var dim arrays. Assumes everything was allocated with NI_malloc(). After this is called, the cpt argument should be set to NULL. ---------------------------------------------------------------------------- Definition at line 2010 of file niml_rowtype.c. References NI_free, NI_STRING, NI_rowtype::part_dim, NI_rowtype::part_num, NI_rowtype::part_off, NI_rowtype::part_typ, ROWTYPE_is_varsize, and NI_rowtype::size. Referenced by NI_free_element().
02011 {
02012 char *dat=(char *)cpt , *ptr ;
02013 int ii , jj ;
02014
02015 if( rt == NULL || dat == NULL || col_len < 1 ) return ; /* nothing to do */
02016
02017 /* if has variable dim arrays inside, free them */
02018
02019 if( ROWTYPE_is_varsize(rt) ){
02020 for( ii=0 ; ii < col_len ; ii++ ){ /* loop over structs */
02021 ptr = dat + rt->size * ii ; /* pointer to this struct */
02022 for( jj=0 ; jj < rt->part_num ; jj++ ){ /* loop over parts */
02023 if( rt->part_typ[jj] == NI_STRING ||
02024 rt->part_dim[jj] >= 0 ){
02025 char **apt = (char **)(ptr+rt->part_off[jj]) ;
02026 NI_free(*apt) ; *apt = NULL ;
02027 }
02028 }
02029 }
02030 }
02031
02032 /* free the column array itself */
02033
02034 NI_free(cpt) ; return ;
02035 }
|
|
|
|
Decrement the reference counter, and destroy the struct (recursively in some cases) if the counter goes to zero. ------------------------------------------------------------- Definition at line 90 of file niml_struct.c. References DELETE_STRUCT, NI_dataset::domain, NI_points_domain::id, NI_AFFINE_3DMAP_TYPE, NI_BYTE_VECTOR_TYPE, NI_COMPLEX_VECTOR_TYPE, NI_DATASET_TYPE, NI_dataset_vecnum, NI_DOUBLE_VECTOR_TYPE, NI_FLOAT_ONE_TYPE, NI_FLOAT_VECTOR_TYPE, NI_free, NI_index_t, NI_INT_VECTOR_TYPE, NI_POINTS_DOMAIN_TYPE, NI_RECT_DOMAIN_TYPE, NI_RGB_VECTOR_TYPE, NI_RGBA_VECTOR_TYPE, NI_SHORT_VECTOR_TYPE, NI_STATISTIC_TYPE, NI_STRING_VECTOR_TYPE, NI_STRUCT_TYPE, NI_VECTOR_TYPE, NI_statistic::param, NI_statistic::param_num, NI_vector::statistic, NI_vector::vec, NI_string_vector::vec, NI_dataset::vec, NI_string_vector::vec_len, NI_vector::vec_range, NI_points_domain::x, NI_points_domain::y, and NI_points_domain::z.
00091 {
00092 NI_struct *nd = (NI_struct *)ndd ;
00093 if( nd == NULL ) return ;
00094
00095 /* decrementation */
00096
00097 nd->nref -- ;
00098 if( nd->nref > 0 ) return ; /* keep it */
00099
00100 /* OK, blot it from the universe */
00101
00102 switch( nd->type ){ /* N.B.: there is no default */
00103
00104 case NI_STRUCT_TYPE: /* These types have no sub-structs */
00105 case NI_FLOAT_ONE_TYPE: /* or sub-arrays that need deleting */
00106 case NI_AFFINE_3DMAP_TYPE:
00107 case NI_RECT_DOMAIN_TYPE:
00108 DELETE_STRUCT(nd) ;
00109 break ;
00110
00111 case NI_STATISTIC_TYPE:{
00112 NI_statistic *ns = (NI_statistic *)nd ;
00113 NI_index_t ii ;
00114 if( ns->param != NULL ){
00115 for( ii=0 ; ii < ns->param_num ; ii++ )
00116 NI_free_struct( ns->param[ii] ) ; /* recursion */
00117 NI_free(ns->param) ;
00118 }
00119 }
00120 DELETE_STRUCT(nd) ;
00121 break ;
00122
00123 case NI_VECTOR_TYPE:
00124 case NI_BYTE_VECTOR_TYPE:
00125 case NI_SHORT_VECTOR_TYPE:
00126 case NI_INT_VECTOR_TYPE:
00127 case NI_FLOAT_VECTOR_TYPE:
00128 case NI_DOUBLE_VECTOR_TYPE:
00129 case NI_COMPLEX_VECTOR_TYPE:
00130 case NI_RGB_VECTOR_TYPE:
00131 case NI_RGBA_VECTOR_TYPE:{
00132 NI_vector *nv = (NI_vector *)nd ;
00133 NI_free( nv->vec ) ;
00134 NI_free( nv->vec_range ) ;
00135 NI_free( nv->statistic ) ;
00136 }
00137 DELETE_STRUCT(nd) ;
00138 break ;
00139
00140 case NI_STRING_VECTOR_TYPE:{
00141 NI_string_vector *nv = (NI_string_vector *)nd ;
00142 NI_index_t ii ;
00143 if( nv->vec != NULL ){
00144 for( ii=0 ; ii < nv->vec_len ; ii++ )
00145 NI_free( nv->vec[ii] ) ;
00146 NI_free( nv->vec ) ;
00147 }
00148 /* vec_range not used for string vectors */
00149 /* statistic not used for string vectors */
00150 }
00151 DELETE_STRUCT(nd) ;
00152 break ;
00153
00154 case NI_POINTS_DOMAIN_TYPE:{
00155 NI_points_domain *np = (NI_points_domain *)nd ;
00156 NI_free( np->id ) ;
00157 NI_free( np->x ) ;
00158 NI_free( np->y ) ;
00159 NI_free( np->z ) ;
00160 }
00161 DELETE_STRUCT(nd) ;
00162 break ;
00163
00164 case NI_DATASET_TYPE:{
00165 NI_dataset *nn = (NI_dataset *)nd ;
00166 if( nn->vec != NULL ){
00167 NI_index_t nv , ii ;
00168 nv = NI_dataset_vecnum(nn) ;
00169 for( ii=0 ; ii < nv ; ii++ )
00170 NI_free_struct( nn->vec[ii] ) ; /* recursion */
00171 NI_free( nn->vec ) ;
00172 }
00173 NI_free_struct( nn->domain ) ; /* recursion */
00174 }
00175 DELETE_STRUCT(nd) ;
00176 break ;
00177
00178 }
00179
00180 return ;
00181 }
|
|
||||||||||||
|
Get an attribute with the given LHS name. Returns a pointer to the RHS field in the element if the attribute name is found; otherwise returns NULL. If the LHS is found, but the RHS is NULL, returns a pointer to an empty C string ("\0"). Do not free() the result from this function, since it points to the internal field of the element! ------------------------------------------------------------------------- Definition at line 755 of file niml_element.c. References NI_element::attr_lhs, NI_group::attr_lhs, NI_procins::attr_lhs, NI_element::attr_num, NI_group::attr_num, NI_procins::attr_num, NI_element::attr_rhs, NI_group::attr_rhs, NI_procins::attr_rhs, NI_element_type(), NI_ELEMENT_TYPE, NI_GROUP_TYPE, NI_PROCINS_TYPE, and tt. Referenced by AFNI_niml_workproc(), AFNI_start_version_check(), NI_do(), NI_self_idcode(), nifti_set_afni_extension(), niml_to_mri(), process_NIML_AFNI_volumedata(), process_NIML_Node_ROI(), process_NIML_SUMA_ijk(), process_NIML_SUMA_ixyz(), process_NIML_SUMA_node_normals(), SUMA_AddNelHist(), SUMA_ColLabelCopy(), SUMA_DsetColLabelCopy(), SUMA_FakeIt(), SUMA_FindDset(), SUMA_GetColRange(), SUMA_MaskedCopyofDset(), SUMA_Mesh_IJK_nel2Mesh_IJK(), SUMA_niml_workproc(), SUMA_nimlSO2SO(), SUMA_NodeXYZ_nel2NodeXYZ(), SUMA_oDsetNel2nDsetNgr(), SUMA_OpenDrawnROI_NIML(), SUMA_process_NIML_data(), SUMA_sdset_id(), SUMA_sdset_idmdom(), SUMA_TypeOfColNumb(), SUMA_TypeOfDsetColNumb(), SUMA_VolPar_nel2SOVolPar(), THD_add_bricks(), THD_dblkatr_from_niml(), THD_niml_to_dataset(), THD_open_3D(), THD_open_nifti(), and XSAVE_input().
00756 {
00757 int nn , tt=NI_element_type(nini) ;
00758 static char *zorkon = "\0" ;
00759
00760 if( tt < 0 || attname == NULL || attname[0] == '\0' ) return NULL ;
00761
00762 /* input is a data element */
00763
00764 if( tt == NI_ELEMENT_TYPE ){
00765 NI_element *nel = (NI_element *) nini ;
00766
00767 for( nn=0 ; nn < nel->attr_num ; nn++ )
00768 if( strcmp(nel->attr_lhs[nn],attname) == 0 ) break ;
00769
00770 if( nn == nel->attr_num ) return NULL ;
00771
00772 if( nel->attr_rhs[nn] == NULL ) return zorkon ;
00773
00774 return nel->attr_rhs[nn] ;
00775
00776 /* input is a group element */
00777
00778 } else if( tt == NI_GROUP_TYPE ){
00779 NI_group *ngr = (NI_group *) nini ;
00780
00781 for( nn=0 ; nn < ngr->attr_num ; nn++ )
00782 if( strcmp(ngr->attr_lhs[nn],attname) == 0 ) break ;
00783
00784 if( nn == ngr->attr_num ) return NULL ;
00785
00786 if( ngr->attr_rhs[nn] == NULL ) return zorkon ;
00787
00788 return ngr->attr_rhs[nn] ;
00789
00790 /* input is a processing instruction */
00791
00792 } else if( tt == NI_PROCINS_TYPE ){
00793 NI_procins *npi = (NI_procins *) nini ;
00794
00795 for( nn=0 ; nn < npi->attr_num ; nn++ )
00796 if( strcmp(npi->attr_lhs[nn],attname) == 0 ) break ;
00797
00798 if( nn == npi->attr_num ) return NULL ;
00799
00800 if( npi->attr_rhs[nn] == NULL ) return zorkon ;
00801
00802 return npi->attr_rhs[nn] ;
00803 }
00804
00805 return NULL ; /* should never be reached */
00806 }
|
|