1 /* 2 3 -Procedure zzsynccl_c ( Sync a CSPICE cell ) 4 5 -Abstract 6 7 CSPICE Private routine intended solely for the support of CSPICE 8 routines. Users should not call this routine directly due 9 to the volatile nature of this routine. 10 11 Sync a CSPICE cell. 12 13 -Disclaimer 14 15 THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE 16 CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. 17 GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE 18 ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE 19 PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" 20 TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY 21 WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A 22 PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC 23 SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 24 SOFTWARE AND RELATED MATERIALS, HOWEVER USED. 25 26 IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA 27 BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT 28 LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, 29 INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, 30 REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE 31 REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. 32 33 RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF 34 THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY 35 CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE 36 ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. 37 38 -Required_Reading 39 40 CELLS 41 42 -Keywords 43 44 CELLS 45 46 */ 47 48 #include "SpiceUsr.h" 49 #include "SpiceZfc.h" 50 #include "SpiceCel.h" 51 #include "SpiceZmc.h" 52 zzsynccl_c(SpiceTransDir xdir,SpiceCell * cell)53 void zzsynccl_c ( SpiceTransDir xdir, 54 SpiceCell * cell ) 55 56 /* 57 58 -Brief_I/O 59 60 VARIABLE I/O DESCRIPTION 61 -------- --- -------------------------------------------------- 62 xdir I Translation direction. 63 cell I/O Cell to be synced. 64 65 -Detailed_Input 66 67 xdir indicates the translation direction. Values and 68 meanings are: 69 70 71 C2F Support C to Fortran translation. 72 73 Set the size and cardinality 74 represented by the control area of the 75 cell's data array. The size and 76 cardinality will be set to the values 77 indicated by the corresponding members 78 of the SpiceCell structure. 79 80 This operation is meaningful only for 81 numeric SpiceCell types. For 82 character SpiceCells, this option 83 results in a no-op. 84 85 F2C Support Fortran to C translation. 86 87 Set the size and cardinality members 88 of the SpiceCell structure to the 89 values represented by the control area 90 of the cell's data array. 91 92 93 cell The cell to be synced. The cell's size and cardinality 94 values in the SpiceCell structure and in the data array 95 are to be synced---set to identical values. 96 97 -Detailed_Output 98 99 cell The cell to be synced. The cell's size and cardinality 100 values in the SpiceCell structure and in the data array 101 are synced---set to identical values---with the direction 102 of synchronization controlled by the argument xdir. 103 104 -Parameters 105 106 None. 107 108 -Exceptions 109 110 1) If the input cell does not have a recognized data type, 111 the error SPICE(NOTSUPPORTED) is signaled. 112 113 2) It's a no-op, but not an error, to have this routine perform an 114 C2F sync on a character cell. The reason this operational 115 capability is omitted is that the control area of a character 116 cell's data array is not used: when a character cell is to 117 be operated on by an f2c'd routine, the cell's contents are mapped 118 to a dynamically allocated array, and the control area of that 119 array is set up on the fly via calls to ssizec_ and scardc_. 120 121 -Files 122 123 None. 124 125 -Particulars 126 127 This utility performs a commonly required cell operation, simplifying 128 the coding of CSPICE wrappers for functions that have SpiceCell 129 inputs or outputs. 130 131 -Examples 132 133 See wninsd_c and the CELLINIT macro defined in SpiceZmc.h. 134 135 -Restrictions 136 137 1) This is a CSPICE private routine. The interface may be changed 138 without notice, so this routine should not be called except by 139 other CSPICE routines. 140 141 -Literature_References 142 143 None. 144 145 -Author_and_Institution 146 147 N.J. Bachman (JPL) 148 149 -Version 150 151 -CSPICE Version 1.0.0, 29-JUL-2002 (NJB) 152 153 -Index_Entries 154 155 sync a CSPICE cell 156 157 -& 158 */ 159 160 161 { 162 /* 163 Local variables 164 */ 165 SpiceCellDataType dtype; 166 167 SpiceInt ccard; 168 SpiceInt csize; 169 SpiceInt cstrlen; 170 171 void * fcell; 172 173 /* 174 Discovery check-in here. 175 */ 176 177 178 /* 179 Define some abbreviations first. 180 */ 181 csize = cell->size; 182 ccard = cell->card; 183 dtype = cell->dtype; 184 fcell = cell->base; 185 186 if ( xdir == C2F ) 187 { 188 /* 189 Sync the Fortran array with the size and cardinality values 190 stored in the associated C structure. 191 192 Setting a Fortran cell's size automatically sets the cardinality 193 to zero, so scard* must be called to set the cardinality. 194 */ 195 if ( dtype == SPICE_DP ) 196 { 197 ssized_ ( ( integer * ) &csize, 198 ( doublereal * ) fcell ); 199 200 scardd_ ( ( integer * ) &ccard, 201 ( doublereal * ) fcell ); 202 } 203 204 else if ( dtype == SPICE_INT ) 205 { 206 ssizei_ ( ( integer * ) &csize, 207 ( integer * ) fcell ); 208 209 scardi_ ( ( integer * ) &ccard, 210 ( integer * ) fcell ); 211 } 212 213 else if ( dtype != SPICE_CHR ) 214 { 215 chkin_c ( "zzsynccl_c" ); 216 setmsg_c ( "Invalid data type code # seen" ); 217 errint_c ( "#", (SpiceInt) dtype ); 218 sigerr_c ( "SPICE(NOTSUPPORTED)" ); 219 chkout_c ( "zzsynccl_c" ); 220 return; 221 } 222 } 223 224 225 else 226 { 227 /* 228 Sync the C structure size and cardinality values with those 229 in the Fortran array. 230 */ 231 if ( dtype == SPICE_CHR ) 232 { 233 cstrlen = cell->length; 234 235 cell->size = sizec_ ( ( char * ) fcell, 236 ( ftnlen ) cstrlen-1 ); 237 cell->card = cardc_ ( ( char * ) fcell, 238 ( ftnlen ) cstrlen-1 ); 239 } 240 241 else if ( dtype == SPICE_DP ) 242 { 243 cell->size = sized_ ( ( doublereal * ) fcell ); 244 cell->card = cardd_ ( ( doublereal * ) fcell ); 245 } 246 247 else if ( dtype == SPICE_INT ) 248 { 249 cell->size = sizei_ ( ( integer * ) fcell ); 250 cell->card = cardi_ ( ( integer * ) fcell ); 251 } 252 253 else 254 { 255 chkin_c ( "zzsynccl_c" ); 256 setmsg_c ( "Invalid data type code # seen" ); 257 errint_c ( "#", (SpiceInt) dtype ); 258 sigerr_c ( "SPICE(NOTSUPPORTED)" ); 259 chkout_c ( "zzsynccl_c" ); 260 return; 261 } 262 } 263 } 264