| 1 | /*--------------------------------------------------------------------------- |
|---|
| 2 | NeXus - Neutron & X-ray Common Data Format |
|---|
| 3 | |
|---|
| 4 | NeXus Utility (NXU) Application Program Interface Header File |
|---|
| 5 | |
|---|
| 6 | Copyright (C) 2005 Freddie Akeroyd |
|---|
| 7 | |
|---|
| 8 | This library is free software; you can redistribute it and/or |
|---|
| 9 | modify it under the terms of the GNU Lesser General Public |
|---|
| 10 | License as published by the Free Software Foundation; either |
|---|
| 11 | version 2 of the License, or (at your option) any later version. |
|---|
| 12 | |
|---|
| 13 | This library is distributed in the hope that it will be useful, |
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 16 | Lesser General Public License for more details. |
|---|
| 17 | |
|---|
| 18 | You should have received a copy of the GNU Lesser General Public |
|---|
| 19 | License along with this library; if not, write to the Free Software |
|---|
| 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 21 | |
|---|
| 22 | For further information, see <http://www.nexus.anl.gov/> |
|---|
| 23 | |
|---|
| 24 | $Id$ |
|---|
| 25 | |
|---|
| 26 | ----------------------------------------------------------------------------*/ |
|---|
| 27 | static const char* rscid = "$Id$"; /* Revision interted by CVS */ |
|---|
| 28 | |
|---|
| 29 | #include <stdlib.h> |
|---|
| 30 | #include <assert.h> |
|---|
| 31 | #include <string.h> |
|---|
| 32 | #include <time.h> |
|---|
| 33 | #include "napiu.h" |
|---|
| 34 | |
|---|
| 35 | #define DO_GLOBAL(__name) \ |
|---|
| 36 | if (__name != NULL) \ |
|---|
| 37 | { \ |
|---|
| 38 | if (NXputattr(file_id, #__name, (char*)__name, strlen(__name), NX_CHAR) != NX_OK) \ |
|---|
| 39 | { \ |
|---|
| 40 | return NX_ERROR; \ |
|---|
| 41 | } \ |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | NXstatus NXUwriteglobals(NXhandle file_id, const char* user, const char* affiliation, const char* address, const char* telephone_number, const char* fax_number, const char* email) |
|---|
| 45 | { |
|---|
| 46 | DO_GLOBAL(user); |
|---|
| 47 | DO_GLOBAL(affiliation); |
|---|
| 48 | DO_GLOBAL(address); |
|---|
| 49 | DO_GLOBAL(telephone_number); |
|---|
| 50 | DO_GLOBAL(fax_number); |
|---|
| 51 | DO_GLOBAL(email); |
|---|
| 52 | return NX_OK; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | /* NXUwritegroup creates and leaves open a group */ |
|---|
| 56 | NXstatus NXUwritegroup(NXhandle file_id, const char* group_name, const char* group_class) |
|---|
| 57 | { |
|---|
| 58 | int status; |
|---|
| 59 | status = NXmakegroup(file_id, group_name, group_class); |
|---|
| 60 | if (status == NX_OK) |
|---|
| 61 | { |
|---|
| 62 | status = NXopengroup(file_id, group_name, group_class); |
|---|
| 63 | } |
|---|
| 64 | return status; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | NXstatus NXUwritedata(NXhandle file_id, const char* data_name, const void* data, int data_type, int rank, const int dim[], const char* units, const int start[], const int size[]) |
|---|
| 68 | { |
|---|
| 69 | return NX_OK; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | NXstatus NXUreaddata(NXhandle file_id, const char* data_name, void* data, char* units, const int start[], const int size[]) |
|---|
| 73 | { |
|---|
| 74 | return NX_OK; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | NXstatus NXUwritehistogram(NXhandle file_id, const char* data_name, const void* data, const char* units) |
|---|
| 78 | { |
|---|
| 79 | return NX_OK; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | NXstatus NXUreadhistogram(NXhandle file_id, const char* data_name, void* data, char* units) |
|---|
| 83 | { |
|---|
| 84 | return NX_OK; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | static int NXcompress_type = 0; |
|---|
| 88 | static int NXcompress_size = 0; |
|---|
| 89 | |
|---|
| 90 | /* NXUsetcompress sets the default compression type and minimum size */ |
|---|
| 91 | NXstatus NXUsetcompress(NXhandle file_id, int comp_type, int comp_size) |
|---|
| 92 | { |
|---|
| 93 | int status; |
|---|
| 94 | if (comp_type == NX_COMP_LZW || comp_type == NX_COMP_HUF || |
|---|
| 95 | comp_type == NX_COMP_RLE || comp_type == NX_COMP_NONE) |
|---|
| 96 | { |
|---|
| 97 | NXcompress_type = comp_type; |
|---|
| 98 | if (comp_size != 0) |
|---|
| 99 | { |
|---|
| 100 | NXcompress_size = comp_size; |
|---|
| 101 | } |
|---|
| 102 | status = NX_OK; |
|---|
| 103 | } |
|---|
| 104 | else |
|---|
| 105 | { |
|---|
| 106 | NXReportError( "Invalid compression option"); |
|---|
| 107 | status = NX_ERROR; |
|---|
| 108 | } |
|---|
| 109 | return status; |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | /* !NXUfindgroup finds if a NeXus group of the specified name exists */ |
|---|
| 113 | NXstatus NXUfindgroup(NXhandle file_id, const char* group_name, char* group_class) |
|---|
| 114 | { |
|---|
| 115 | int status, n; |
|---|
| 116 | NXname vname, vclass; |
|---|
| 117 | status = NXgetgroupinfo(file_id, &n, vname, vclass); |
|---|
| 118 | if (status != NX_OK) |
|---|
| 119 | { |
|---|
| 120 | return status; |
|---|
| 121 | } |
|---|
| 122 | return NX_OK; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | NXstatus NXUfindclass(NXhandle file_id, const char* group_class, char* group_name, int find_index) |
|---|
| 126 | { |
|---|
| 127 | return NX_OK; |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | /* NXUfinddata finds if a NeXus data item is in the current group */ |
|---|
| 131 | NXstatus NXUfinddata(NXhandle file_id, const char* data_name) |
|---|
| 132 | { |
|---|
| 133 | return NX_OK; |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | NXstatus NXUfindattr(NXhandle file_id, const char* attr_name) |
|---|
| 137 | { |
|---|
| 138 | return NX_OK; |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | NXstatus NXUfindsignal(NXhandle file_id, int signal, char* data_name, int* data_rank, int* data_type, int data_dimensions[]) |
|---|
| 142 | { |
|---|
| 143 | return NX_OK; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | NXstatus NXUfindaxis(NXhandle file_id, int axis, int primary, char* data_name, int* data_rank, int* data_type, int data_dimensions[]) |
|---|
| 147 | { |
|---|
| 148 | return NX_OK; |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | NXstatus NXUfindlink(NXhandle file_id, NXlink* group_id, const char* group_class) |
|---|
| 152 | { |
|---|
| 153 | return NX_OK; |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | NXstatus NXUresumelink(NXhandle file_id, NXlink group_id) |
|---|
| 157 | { |
|---|
| 158 | return NX_OK; |
|---|
| 159 | } |
|---|
| 160 | |
|---|