SpiceZmc.h
上传用户:center1979
上传日期:2022-07-26
资源大小:50633k
文件大小:46k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /*
  2. -Disclaimer
  3.    THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
  4.    CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
  5.    GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
  6.    ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
  7.    PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
  8.    TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
  9.    WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
  10.    PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
  11.    SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
  12.    SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
  13.    IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
  14.    BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
  15.    LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  16.    INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
  17.    REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
  18.    REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
  19.    RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
  20.    THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
  21.    CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
  22.    ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
  23. */
  24. /*
  25.  CSPICE private macro file.
  26. -Particulars
  27.    Current list of macros (spelling counts)
  28.      BLANK
  29.      C2F_MAP_CELL
  30.      C2F_MAP_CELL2
  31.      C2F_MAP_CELL3
  32.      CELLINIT
  33.      CELLINIT2
  34.      CELLINIT3
  35.      CELLISSETCHK
  36.      CELLISSETCHK2
  37.      CELLISSETCHK2_VAL
  38.      CELLISSETCHK3
  39.      CELLISSETCHK3_VAL
  40.      CELLISSETCHK_VAL
  41.      CELLMATCH2
  42.      CELLMATCH2_VAL
  43.      CELLMATCH3
  44.      CELLMATCH3_VAL
  45.      CELLTYPECHK
  46.      CELLTYPECHK2
  47.      CELLTYPECHK2_VAL
  48.      CELLTYPECHK3
  49.      CELLTYPECHK3_VAL
  50.      CELLTYPECHK_VAL
  51.      CHKFSTR
  52.      CHKFSTR_VAL
  53.      CHKOSTR
  54.      CHKOSTR_VAL
  55.      CHKPTR
  56.      Constants
  57.      Even
  58.      F2C_MAP_CELL
  59.      Index values
  60.      MOVED
  61.      MOVEI
  62.      MaxAbs
  63.      MaxVal
  64.      MinAbs
  65.      MinVal
  66.      Odd
  67.      SpiceError
  68.      TolOrFail
  69. -Restrictions
  70.    This is a private macro file for use within CSPICE.
  71.    Do not use or alter any entry.  Or else!
  72. -Author_and_Institution
  73.  
  74.    N.J. Bachman    (JPL)
  75.    E.D. Wright     (JPL) 
  76. -Version
  77.  
  78.    -CSPICE Version 4.2.0, 16-FEB-2005   (NJB)
  79.       Bug fix:  in the macro C2F_MAP_CELL, error checking has been
  80.       added after the sequence of calls to ssizec_ and scardc_.
  81.       If either of these routines signals an error, the dynamically
  82.       allocated memory for the "Fortran cell" is freed.
  83.    -CSPICE Version 4.1.0, 06-DEC-2002   (NJB)
  84.    
  85.       Bug fix:  added previous missing, bracketing parentheses to 
  86.       references to input cell pointer argument in macro 
  87.       CELLINIT.
  88.       Changed CELLINIT macro so it no longer initializes to zero
  89.       length all strings in data array of a character cell.  Instead,
  90.       strings are terminated with a null in their final element.  
  91.    -CSPICE Version 4.0.0, 22-AUG-2002   (NJB)
  92.    
  93.        Added macro definitions to support CSPICE cells and sets:
  94.           C2F_MAP_CELL
  95.           C2F_MAP_CELL2
  96.           C2F_MAP_CELL3
  97.           CELLINIT
  98.           CELLINIT2
  99.           CELLINIT3
  100.           CELLISSETCHK
  101.           CELLISSETCHK2
  102.           CELLISSETCHK2_VAL
  103.           CELLISSETCHK3
  104.           CELLISSETCHK3_VAL
  105.           CELLISSETCHK_VAL
  106.           CELLMATCH2
  107.           CELLMATCH2_VAL
  108.           CELLMATCH3
  109.           CELLMATCH3_VAL
  110.           CELLTYPECHK
  111.           CELLTYPECHK2
  112.           CELLTYPECHK2_VAL
  113.           CELLTYPECHK3
  114.           CELLTYPECHK3_VAL
  115.           CELLTYPECHK_VAL
  116.           F2C_MAP_CELL
  117.    -CSPICE Version 3.0.0, 09-JAN-1998   (NJB)
  118.    
  119.        Added output string check macros CHKOSTR and CHKOSTR_VAL.  
  120.        Removed variable name arguments from macros
  121.        
  122.           CHKPTR
  123.           CHKPTR_VAL
  124.           CHKFSTR
  125.           CHKRSTR_VAL
  126.           
  127.        The strings containing names of the checked variables are now 
  128.        generated from the variables themselves via the # operator.
  129.        
  130.    -CSPICE Version 2.0.0, 03-DEC-1997   (NJB)
  131.    
  132.        Added pointer check macro CHKPTR and Fortran string check macro 
  133.        CHKFSTR.
  134.        
  135.    -CSPICE Version 1.0.0, 25-OCT-1997   (EDW)
  136. */
  137. #include <math.h>
  138. #include <string.h>
  139. #include "SpiceZdf.h"
  140. #define MOVED( arrfrm, ndim, arrto )                
  141.                                                     
  142.         ( memmove ( (void*)               (arrto) , 
  143.                     (void*)               (arrfrm), 
  144.                     sizeof (SpiceDouble) * (ndim)  ) )
  145. #define MOVEI( arrfrm, ndim, arrto )               
  146.                                                    
  147.         ( memmove ( (void*)            (arrto) ,   
  148.                     (void*)            (arrfrm),   
  149.                     sizeof (SpiceInt) * (ndim)    ) )
  150. /* 
  151. Define a tolerance test for those pesky double precision reals.
  152. True if the difference is less than the tolerance, false otherwise.
  153. The tolerance refers to a percentage. x, y and tol should be declared
  154. double.  All values are assumed to be non-zero.  Okay?
  155. */
  156. #define TolOrFail( x, y, tol )            
  157.                                           
  158.         ( fabs( x-y ) < ( tol * fabs(x) ) )
  159. /*
  160. Simple error output through standard SPICE error system .  Set the error
  161. message and the type
  162. */
  163. #define SpiceError( errmsg, errtype )   
  164.                                         
  165.         {                               
  166.         setmsg_c ( errmsg  );           
  167.         sigerr_c ( errtype );           
  168.         }
  169. /*
  170. Return a value which is the maximum/minimum of the absolute values of
  171. two values.
  172. */
  173. #define MaxAbs(a,b)   ( fabs(a) >= fabs(b) ? fabs(a) : fabs(b) )
  174. #define MinAbs(a,b)   ( fabs(a) <  fabs(b) ? fabs(a) : fabs(b) )
  175. /*
  176. Return a value which is the maximum/minimum value of two values.
  177. */
  178. #define MaxVal(A,B) ( (A) >= (B) ? (A) : (B) )
  179. #define MinVal(A,B) ( (A) <  (B) ? (A) : (B) )
  180. /*
  181. Determine whether a value is even or odd
  182. */
  183. #define Even( x ) ( ( (x) & 1 ) == 0 )
  184. #define Odd ( x ) ( ( (x) & 1 ) != 0 )
  185. /*
  186. Array indexes for vectors.
  187. */
  188. #define  SpiceX         0
  189. #define  SpiceY         1
  190. #define  SpiceZ         2
  191. #define  SpiceVx        3
  192. #define  SpiceVy        4
  193. #define  SpiceVz        5
  194. /*
  195. Physical constants and dates.
  196. */
  197. #define  B1900     2415020.31352
  198. #define  J1900     2415020.0
  199. #define  JYEAR     31557600.0
  200. #define  TYEAR     31556925.9747
  201. #define  J1950     2433282.5
  202. #define  SPD       86400.0
  203. #define  B1950     2433282.42345905
  204. #define  J2100     2488070.0
  205. #define  CLIGHT    299792.458
  206. #define  J2000     2451545.0
  207. /*
  208. Common literal values.
  209. */
  210. #define  NULLCHAR  ( (SpiceChar   )   0 )
  211. #define  NULLCPTR  ( (SpiceChar * )   0 )
  212. #define  BLANK     ( (SpiceChar   ) ' ' )
  213. /*
  214. Macro CHKPTR is used for checking for a null pointer.  CHKPTR uses
  215. the constants 
  216.    CHK_STANDARD
  217.    CHK_DISCOVER
  218.    CHK_REMAIN
  219. to control tracing behavior.  Values  and meanings are:
  220.    CHK_STANDARD          Standard tracing.  If an error
  221.                          is found, signal it, check out
  222.                          and return.
  223.    CHK_DISCOVER          Discovery check-in.  If an
  224.                          error is found, check in, signal
  225.                          the error, check out, and return.
  226.    CHK_REMAIN            If an error is found, signal it.
  227.                          Do not check out or return.  This
  228.                          would allow the caller to clean up
  229.                          before returning, if necessary.
  230.                          In such cases the caller must test
  231.                          failed_c() after the macro call.
  232.                          
  233. CHKPTR should be used in void functions.  In non-void functions,
  234. use CHKPTR_VAL, which is defined below.
  235. */
  236. #define  CHK_STANDARD   1
  237. #define  CHK_DISCOVER   2
  238. #define  CHK_REMAIN     3
  239. #define  CHKPTR( errHandling, modname, pointer )                     
  240.                                                                      
  241.          if ( (void *)(pointer) == (void *)0 )                       
  242.          {                                                           
  243.             if ( (errHandling) == CHK_DISCOVER  )                    
  244.             {                                                        
  245.                chkin_c ( modname );                                  
  246.             }                                                        
  247.                                                                      
  248.             setmsg_c ( "Pointer "#" is null; a non-null "          
  249.                        "pointer is required."             );         
  250.             errch_c  ( "#", (#pointer)                    );         
  251.             sigerr_c ( "SPICE(NULLPOINTER)"               );         
  252.                                                                      
  253.             if (    ( (errHandling) == CHK_DISCOVER  )               
  254.                  || ( (errHandling) == CHK_STANDARD  )   )           
  255.             {                                                        
  256.                chkout_c ( modname );                                 
  257.                return;                                               
  258.             }                                                        
  259.          }
  260. #define  CHKPTR_VAL( errHandling, modname, pointer, retval )         
  261.                                                                      
  262.          if ( (void *)(pointer) == (void *)0 )                       
  263.          {                                                           
  264.             if ( (errHandling) == CHK_DISCOVER  )                    
  265.             {                                                        
  266.                chkin_c ( modname );                                  
  267.             }                                                        
  268.                                                                      
  269.             setmsg_c ( "Pointer "#" is null; a non-null "          
  270.                        "pointer is required."             );         
  271.             errch_c  ( "#", (#pointer)                    );         
  272.             sigerr_c ( "SPICE(NULLPOINTER)"               );         
  273.                                                                      
  274.             if (    ( (errHandling) == CHK_DISCOVER  )               
  275.                  || ( (errHandling) == CHK_STANDARD  )   )           
  276.             {                                                        
  277.                chkout_c ( modname );                                 
  278.                return   ( retval  );                                 
  279.             }                                                        
  280.          }
  281. /*
  282. Macro CHKFSTR checks strings that are to be passed to Fortran or
  283. f2c'd Fortran routines.  Such strings must have non-zero length,
  284. and their pointers must be non-null.
  285. CHKFSTR should be used in void functions.  In non-void functions,
  286. use CHKFSTR_VAL, which is defined below.
  287. */
  288. #define  CHKFSTR( errHandling, modname, string )                     
  289.                                                                      
  290.          CHKPTR ( errHandling, modname, string );                    
  291.                                                                      
  292.          if (     (  (void *)string    !=  (void *)0  )              
  293.               &&  (   strlen(string)   ==  0          )  )           
  294.          {                                                           
  295.             if ( (errHandling) == CHK_DISCOVER  )                    
  296.             {                                                        
  297.                chkin_c ( modname );                                  
  298.             }                                                        
  299.                                                                      
  300.             setmsg_c ( "String "#" has length zero." );            
  301.             errch_c  ( "#", (#string)                  );            
  302.             sigerr_c ( "SPICE(EMPTYSTRING)"            );            
  303.                                                                      
  304.             if (    ( (errHandling) == CHK_DISCOVER  )               
  305.                  || ( (errHandling) == CHK_STANDARD  )   )           
  306.             {                                                        
  307.                chkout_c ( modname );                                 
  308.                return;                                               
  309.             }                                                        
  310.          }
  311. #define  CHKFSTR_VAL( errHandling, modname, string, retval )         
  312.                                                                      
  313.          CHKPTR_VAL( errHandling, modname, string, retval);          
  314.                                                                      
  315.          if (     (  (void *)string    !=  (void *)0  )              
  316.               &&  (   strlen(string)   ==  0          )  )           
  317.          {                                                           
  318.             if ( (errHandling) == CHK_DISCOVER  )                    
  319.             {                                                        
  320.                chkin_c ( modname );                                  
  321.             }                                                        
  322.                                                                      
  323.             setmsg_c ( "String "#" has length zero." );            
  324.             errch_c  ( "#", (#string)                  );            
  325.             sigerr_c ( "SPICE(EMPTYSTRING)"            );            
  326.                                                                      
  327.             if (    ( (errHandling) == CHK_DISCOVER  )               
  328.                  || ( (errHandling) == CHK_STANDARD  )   )           
  329.             {                                                        
  330.                chkout_c ( modname );                                 
  331.                return    ( retval );                                 
  332.             }                                                        
  333.          }
  334. /*
  335. Macro CHKOSTR checks output string pointers and the associated
  336. string length values supplied as input arguments.  Output string
  337. pointers must be non-null, and the string lengths must be at
  338. least 2, so Fortran routine can write at least one character to
  339. the output string, and so a null terminator can be appended.
  340. CHKOSTR should be used in void functions.  In non-void functions,
  341. use CHKOSTR_VAL, which is defined below.
  342. */
  343. #define  CHKOSTR( errHandling, modname, string, length )             
  344.                                                                      
  345.          CHKPTR ( errHandling, modname, string );                    
  346.                                                                      
  347.          if (     (  (void *)string    !=  (void *)0  )              
  348.               &&  (   length            <  2          )  )           
  349.          {                                                           
  350.             if ( (errHandling) == CHK_DISCOVER  )                    
  351.             {                                                        
  352.                chkin_c ( modname );                                  
  353.             }                                                        
  354.                                                                      
  355.             setmsg_c ( "String "#" has length #; must be >= 2." ); 
  356.             errch_c  ( "#", (#string)                  );            
  357.             errint_c ( "#", (length)                   );            
  358.             sigerr_c ( "SPICE(STRINGTOOSHORT)"         );            
  359.                                                                      
  360.             if (    ( (errHandling) == CHK_DISCOVER  )               
  361.                  || ( (errHandling) == CHK_STANDARD  )   )           
  362.             {                                                        
  363.                chkout_c ( modname );                                 
  364.                return;                                               
  365.             }                                                        
  366.          }
  367. #define  CHKOSTR_VAL( errHandling, modname, string, length, retval ) 
  368.                                                                      
  369.          CHKPTR_VAL( errHandling, modname, string, retval );         
  370.                                                                      
  371.          if (     (  (void *)string    !=  (void *)0  )              
  372.               &&  (   length            <  2          )  )           
  373.          {                                                           
  374.             if ( (errHandling) == CHK_DISCOVER  )                    
  375.             {                                                        
  376.                chkin_c ( modname );                                  
  377.             }                                                        
  378.                                                                      
  379.             setmsg_c ( "String "#" has length #; must be >= 2." ); 
  380.             errch_c  ( "#", (#string)                  );            
  381.             errint_c ( "#", (length)                   );            
  382.             sigerr_c ( "SPICE(STRINGTOOSHORT)"         );            
  383.                                                                      
  384.             if (    ( (errHandling) == CHK_DISCOVER  )               
  385.                  || ( (errHandling) == CHK_STANDARD  )   )           
  386.             {                                                        
  387.                chkout_c ( modname );                                 
  388.                return   ( retval  );                                 
  389.             }                                                        
  390.          }
  391.    /*
  392.    Definitions for Cells and Sets 
  393.    */
  394.    /*
  395.    Cell initialization macros 
  396.    */
  397.    #define CELLINIT( cellPtr )                                       
  398.                                                                      
  399.       if ( !( (cellPtr)->init )  )                                   
  400.       {                                                              
  401.          if (  (cellPtr)->dtype  ==  SPICE_CHR  )                    
  402.          {                                                           
  403.             /*                                                       
  404.             Make sure all elements of the data array, including      
  405.             the control area, start off null-terminated.  We place   
  406.             the null character in the final element of each string,  
  407.             so as to avoid wiping out data that may have been        
  408.             assigned to the data array prior to initialization.      
  409.             */                                                       
  410.             SpiceChar  * sPtr;                                       
  411.             SpiceInt     i;                                          
  412.             SpiceInt     nmax;                                       
  413.                                                                      
  414.             nmax  = SPICE_CELL_CTRLSZ + (cellPtr)->size;             
  415.                                                                      
  416.             for ( i = 1;  i <= nmax;  i++ )                          
  417.             {                                                        
  418.                sPtr  =          (SpiceChar *)((cellPtr)->base)       
  419.                          +  i * (cellPtr)->length                    
  420.                          -  1;                                       
  421.                                                                      
  422.                *sPtr = NULLCHAR;                                     
  423.             }                                                        
  424.          }                                                           
  425.          else                                                        
  426.          {                                                           
  427.             zzsynccl_c ( C2F, (cellPtr) );                           
  428.          }                                                           
  429.                                                                      
  430.          (cellPtr)->init = SPICETRUE;                                
  431.       }                                                             
  432.    #define CELLINIT2( cellPtr1, cellPtr2 )                           
  433.                                                                      
  434.       CELLINIT ( cellPtr1 );                                         
  435.       CELLINIT ( cellPtr2 );
  436.    #define CELLINIT3( cellPtr1, cellPtr2, cellPtr3 )                 
  437.                                                                      
  438.       CELLINIT ( cellPtr1 );                                         
  439.       CELLINIT ( cellPtr2 );                                         
  440.       CELLINIT ( cellPtr3 );
  441.    /*
  442.    Data type checking macros: 
  443.    */
  444.    #define CELLTYPECHK( errHandling, modname, dType, cellPtr1 )      
  445.                                                                      
  446.          if ( (cellPtr1)->dtype != (dType) )                         
  447.          {                                                           
  448.             SpiceChar  * typstr[3] =                                 
  449.             {                                                        
  450.               "character", "double precision", "integer"             
  451.             };                                                       
  452.                                                                      
  453.             if ( (errHandling) == CHK_DISCOVER  )                    
  454.             {                                                        
  455.                chkin_c ( modname );                                  
  456.             }                                                        
  457.                                                                      
  458.             setmsg_c ( "Data type of # is #; expected type "         
  459.                        "is #."                                );     
  460.             errch_c  ( "#", (#cellPtr1)                       );     
  461.             errch_c  ( "#", typstr[ (cellPtr1)->dtype ]       );     
  462.             errch_c  ( "#", typstr[  dType            ]       );     
  463.             sigerr_c ( "SPICE(TYPEMISMATCH)"                  );     
  464.                                                                      
  465.             if (    ( (errHandling) == CHK_DISCOVER  )               
  466.                  || ( (errHandling) == CHK_STANDARD  )   )           
  467.             {                                                        
  468.                chkout_c ( modname );                                 
  469.                return;                                               
  470.             }                                                        
  471.          }
  472.    #define CELLTYPECHK_VAL( errHandling,  modname,                   
  473.                             dType,        cellPtr1,  retval )        
  474.                                                                      
  475.          if ( (cellPtr1)->dtype != (dType) )                         
  476.          {                                                           
  477.             SpiceChar  * typstr[3] =                                 
  478.             {                                                        
  479.               "character", "double precision", "integer"             
  480.             };                                                       
  481.                                                                      
  482.             if ( (errHandling) == CHK_DISCOVER  )                    
  483.             {                                                        
  484.                chkin_c ( modname );                                  
  485.             }                                                        
  486.                                                                      
  487.             setmsg_c ( "Data type of # is #; expected type "         
  488.                        "is #."                                );     
  489.             errch_c  ( "#", (#cellPtr1)                       );     
  490.             errch_c  ( "#", typstr[ (cellPtr1)->dtype ]       );     
  491.             errch_c  ( "#", typstr[  dType            ]       );     
  492.             sigerr_c ( "SPICE(TYPEMISMATCH)"                  );     
  493.                                                                      
  494.             if (    ( (errHandling) == CHK_DISCOVER  )               
  495.                  || ( (errHandling) == CHK_STANDARD  )   )           
  496.             {                                                        
  497.                chkout_c ( modname );                                 
  498.                return (retval);                                      
  499.             }                                                        
  500.          }
  501.    #define CELLTYPECHK2( errHandling,  modname,  dtype,              
  502.                          cellPtr1,     cellPtr2         )            
  503.                                                                      
  504.        CELLTYPECHK( errHandling, modname, dtype, cellPtr1 );         
  505.        CELLTYPECHK( errHandling, modname, dtype, cellPtr2 );
  506.    #define CELLTYPECHK2_VAL( errHandling,  modname,  dtype,          
  507.                              cellPtr1,     cellPtr2, retval )        
  508.                                                                      
  509.        CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr1,       
  510.                         retval                                 );    
  511.        CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr2,       
  512.                         retval                                 );
  513.    #define CELLTYPECHK3( errHandling,  modname,   dtype,             
  514.                          cellPtr1,     cellPtr2,  cellPtr3  )        
  515.                                                                      
  516.        CELLTYPECHK( errHandling, modname, dtype, cellPtr1 );         
  517.        CELLTYPECHK( errHandling, modname, dtype, cellPtr2 );         
  518.        CELLTYPECHK( errHandling, modname, dtype, cellPtr3 );
  519.    #define CELLTYPECHK3_VAL( errHandling, modname,  dtype,           
  520.                              cellPtr1,    cellPtr2, cellPtr3,        
  521.                              retval                            )     
  522.                                                                      
  523.        CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr1,       
  524.                         retval                                 );    
  525.        CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr2,       
  526.                         retval                                 );    
  527.        CELLTYPECHK_VAL( errHandling, modname, dtype, cellPtr3        
  528.                         retval                                 );
  529.    #define CELLMATCH2( errHandling, modname, cellPtr1, cellPtr2 )    
  530.                                                                      
  531.          if ( (cellPtr1)->dtype != (cellPtr2)->dtype )               
  532.          {                                                           
  533.             SpiceChar  * typstr[3] =                                 
  534.             {                                                        
  535.               "character", "double precision", "integer"             
  536.             };                                                       
  537.                                                                      
  538.             if ( (errHandling) == CHK_DISCOVER  )                    
  539.             {                                                        
  540.                chkin_c ( modname );                                  
  541.             }                                                        
  542.                                                                      
  543.             setmsg_c ( "Data type of # is #; data type of # "        
  544.                        "is #, but types must match."          );     
  545.             errch_c  ( "#", (#cellPtr1)                       );     
  546.             errch_c  ( "#", typstr[ (cellPtr1)->dtype ]       );     
  547.             errch_c  ( "#", (#cellPtr2)                       );     
  548.             errch_c  ( "#", typstr[ (cellPtr2)->dtype ]       );     
  549.             sigerr_c ( "SPICE(TYPEMISMATCH)"                  );     
  550.                                                                      
  551.             if (    ( (errHandling) == CHK_DISCOVER  )               
  552.                  || ( (errHandling) == CHK_STANDARD  )   )           
  553.             {                                                        
  554.                chkout_c ( modname );                                 
  555.                return;                                               
  556.             }                                                        
  557.          }
  558.    #define CELLMATCH2_VAL( errHandling, modname,                     
  559.                            cellPtr1,    cellPtr2, retval )           
  560.                                                                      
  561.          if ( (cellPtr1)->dtype != (cellPtr2)->dtype )               
  562.          {                                                           
  563.             SpiceChar  * typstr[3] =                                 
  564.             {                                                        
  565.               "character", "double precision", "integer"             
  566.             };                                                       
  567.                                                                      
  568.             if ( (errHandling) == CHK_DISCOVER  )                    
  569.             {                                                        
  570.                chkin_c ( modname );                                  
  571.             }                                                        
  572.                                                                      
  573.             setmsg_c ( "Data type of # is #; data type of # "        
  574.                        "is #, but types must match."          );     
  575.             errch_c  ( "#", (#cellPtr1)                       );     
  576.             errch_c  ( "#", typstr [ (cellPtr1)->dtype ]      );     
  577.             errch_c  ( "#", (#cellPtr2)                       );     
  578.             errch_c  ( "#", typstr [ (cellPtr2)->dtype ]      );     
  579.             sigerr_c ( "SPICE(TYPEMISMATCH)"                  );     
  580.                                                                      
  581.             if (    ( (errHandling) == CHK_DISCOVER  )               
  582.                  || ( (errHandling) == CHK_STANDARD  )   )           
  583.             {                                                        
  584.                chkout_c ( modname );                                 
  585.                return   ( retval  );                                 
  586.             }                                                        
  587.          }
  588.    #define CELLMATCH3( errHandling, modname,                         
  589.                        cellPtr1,    cellPtr2,  cellPtr3 )            
  590.                                                                      
  591.        CELLMATCH2 ( errHandling, modname, cellPtr1, cellPtr2 );      
  592.        CELLMATCH2 ( errHandling, modname, cellPtr2, cellPtr3 );
  593.       
  594.    #define CELLMATCH3_VAL( errHandling, modname,  cellPtr1,          
  595.                            cellPtr2,    cellPtr3, retval    )        
  596.                                                                      
  597.        CELLMATCH2_VAL ( errHandling, modname,                        
  598.                         cellPtr1,    cellPtr2, retval );             
  599.                                                                      
  600.        CELLMATCH2_VAL ( errHandling, modname,                        
  601.                         cellPtr2,    cellPtr3, retval );
  602.    /*
  603.    Set checking macros: 
  604.    */
  605.    #define CELLISSETCHK( errHandling, modname, cellPtr1 )            
  606.                                                                      
  607.          if ( !(cellPtr1)->isSet )                                   
  608.          {                                                           
  609.             if ( (errHandling) == CHK_DISCOVER  )                    
  610.             {                                                        
  611.                chkin_c ( modname );                                  
  612.             }                                                        
  613.                                                                      
  614.             setmsg_c ( "Cell # must be sorted and have unique "      
  615.                        "values in order to be a CSPICE set. "        
  616.                        "The isSet flag in this cell is SPICEFALSE, " 
  617.                        "indicating the cell may have been modified " 
  618.                        "by a routine that doesn't preserve these "   
  619.                        "properties."                          );     
  620.             errch_c  ( "#", (#cellPtr1)                       );     
  621.             sigerr_c ( "SPICE(NOTASET)"                       );     
  622.                                                                      
  623.             if (    ( (errHandling) == CHK_DISCOVER  )               
  624.                  || ( (errHandling) == CHK_STANDARD  )   )           
  625.             {                                                        
  626.                chkout_c ( modname );                                 
  627.                return;                                               
  628.             }                                                        
  629.          }                                                           
  630.                                                                      
  631.    #define CELLISSETCHK_VAL( errHandling,  modname,                  
  632.                              cellPtr1,     retval  )                 
  633.                                                                      
  634.          if ( !(cellPtr1)->isSet )                                   
  635.          {                                                           
  636.             if ( (errHandling) == CHK_DISCOVER  )                    
  637.             {                                                        
  638.                chkin_c ( modname );                                  
  639.             }                                                        
  640.                                                                      
  641.             setmsg_c ( "Cell # must be sorted and have unique "      
  642.                        "values in order to be a CSPICE set. "        
  643.                        "The isSet flag in this cell is SPICEFALSE, " 
  644.                        "indicating the cell may have been modified " 
  645.                        "by a routine that doesn't preserve these "   
  646.                        "properties."                          );     
  647.             errch_c  ( "#", (#cellPtr1)                       );     
  648.             sigerr_c ( "SPICE(NOTASET)"                       );     
  649.                                                                      
  650.             if (    ( (errHandling) == CHK_DISCOVER  )               
  651.                  || ( (errHandling) == CHK_STANDARD  )   )           
  652.             {                                                        
  653.                chkout_c ( modname );                                 
  654.                return (retval);                                      
  655.             }                                                        
  656.          }
  657.    #define CELLISSETCHK2( errHandling,  modname,                     
  658.                           cellPtr1,     cellPtr2 )                   
  659.                                                                      
  660.        CELLISSETCHK( errHandling, modname, cellPtr1 );               
  661.        CELLISSETCHK( errHandling, modname, cellPtr2 );
  662.    #define CELLISSETCHK2_VAL( errHandling,  modname,                 
  663.                               cellPtr1,     cellPtr2, retval )       
  664.                                                                      
  665.        CELLISSETCHK_VAL( errHandling, modname, cellPtr1, retval );   
  666.        CELLISSETCHK_VAL( errHandling, modname, cellPtr2, retval );   
  667.  
  668.    #define CELLISSETCHK3( errHandling,  modname,                     
  669.                           cellPtr1,     cellPtr2,  cellPtr3  )       
  670.                                                                      
  671.        CELLISSETCHK ( errHandling, modname, cellPtr1 );              
  672.        CELLISSETCHK ( errHandling, modname, cellPtr2 );              
  673.        CELLISSETCHK ( errHandling, modname, cellPtr3 );
  674.    #define CELLISSETCHK3_VAL( errHandling, modname,  cellPtr1,       
  675.                               cellPtr2,    cellPtr3, retval    )     
  676.                                                                      
  677.        CELLISSETCHK_VAL ( errHandling, modname, cellPtr1, retval );  
  678.        CELLISSETCHK_VAL ( errHandling, modname, cellPtr2, retval );  
  679.        CELLISSETCHK_VAL ( errHandling, modname, cellPtr3, retval );
  680.    /*
  681.    C-to-Fortran and Fortran-to-C character cell translation macros:
  682.    */
  683.    /*
  684.    Macros that map one or more character C cells to dynamically 
  685.    allocated Fortran-style character cells:
  686.    */
  687.    #define C2F_MAP_CELL( caller, CCell, fCell, fLen )                
  688.                                                                      
  689.       {                                                              
  690.          /*                                                          
  691.          fCell and fLen are to be passed by reference, as if this    
  692.          macro were a function.                                          
  693.                                                                      
  694.                                                                      
  695.          Caution: dynamically allocates array fCell, which is to be  
  696.          freed by caller!                                            
  697.          */                                                          
  698.          SpiceInt                ndim;                               
  699.          SpiceInt                lenvals;                            
  700.                                                                      
  701.                                                                      
  702.          ndim     =  (CCell)->size  +  SPICE_CELL_CTRLSZ;            
  703.          lenvals  =  (CCell)->length;                                
  704.                                                                      
  705.          C2F_MapFixStrArr ( (caller),      ndim,    lenvals,         
  706.                             (CCell)->base, (fLen),  (fCell)  );      
  707.                                                                      
  708.          if ( !failed_c() )                                          
  709.          {                                                           
  710.             /*                                                       
  711.             Explicitly set the control area info in the Fortran cell.
  712.             */                                                       
  713.             ssizec_ ( ( integer * ) &((CCell)->size),                
  714.                       ( char    * ) *(fCell),                        
  715.                       ( ftnlen    ) *(fLen)           );             
  716.                                                                      
  717.             scardc_ ( ( integer * ) &((CCell)->card),                
  718.                       ( char    * ) *(fCell),                        
  719.                       ( ftnlen    ) *(fLen)           );             
  720.                                                                      
  721.             if ( failed_c() )                                        
  722.             {                                                        
  723.                /*                                                    
  724.                Setting size or cardinality of the Fortran cell       
  725.                can fail, for example if the cell's string length     
  726.                is too short.                                         
  727.                */                                                    
  728.                free ( *(fCell) );                                    
  729.             }                                                        
  730.          }                                                           
  731.       }
  732.    #define C2F_MAP_CELL2( caller, CCell1, fCell1, fLen1,             
  733.                                   CCell2, fCell2, fLen2 )            
  734.                                                                      
  735.       {                                                              
  736.          C2F_MAP_CELL( caller, CCell1, fCell1, fLen1 );              
  737.                                                                      
  738.          if ( !failed_c() )                                          
  739.          {                                                           
  740.             C2F_MAP_CELL( caller, CCell2, fCell2, fLen2 );           
  741.                                                                      
  742.             if ( failed_c() )                                        
  743.             {                                                        
  744.                free ( *(fCell1) );                                   
  745.             }                                                        
  746.          }                                                           
  747.       }
  748.    #define C2F_MAP_CELL3( caller, CCell1, fCell1, fLen1,             
  749.                                   CCell2, fCell2, fLen2,             
  750.                                   CCell3, fCell3, fLen3 )            
  751.                                                                      
  752.       {                                                              
  753.          C2F_MAP_CELL2( caller, CCell1, fCell1, fLen1,               
  754.                                 CCell2, fCell2, fLen2  );            
  755.                                                                      
  756.          if ( !failed_c() )                                          
  757.          {                                                           
  758.             C2F_MAP_CELL( caller, CCell3, fCell3, fLen3 );           
  759.                                                                      
  760.             if ( failed_c() )                                        
  761.             {                                                        
  762.                free ( *(fCell1) );                                   
  763.                free ( *(fCell2) );                                   
  764.             }                                                        
  765.          }                                                           
  766.       }
  767.    /*
  768.    Macro that maps a Fortran-style character cell to a C cell
  769.    (Note: this macro frees the Fortran cell): 
  770.    */
  771.    #define F2C_MAP_CELL( fCell, fLen, CCell )                        
  772.                                                                      
  773.       {                                                              
  774.          SpiceInt                card;                               
  775.          SpiceInt                lenvals;                            
  776.          SpiceInt                ndim;                               
  777.          SpiceInt                nBytes;                             
  778.          SpiceInt                size;                               
  779.          void                  * array;                              
  780.                                                                      
  781.          ndim     =  (CCell)->size  +  SPICE_CELL_CTRLSZ;            
  782.          lenvals  =  (CCell)->length;                                
  783.          array    =  (CCell)->base;                                  
  784.                                                                      
  785.          /*                                                          
  786.          Capture the size and cardinality of the Fortran cell.       
  787.          */                                                          
  788.          if ( !failed_c() )                                          
  789.          {                                                           
  790.             size = sizec_ (  ( char      * ) (fCell),                
  791.                              ( ftnlen      ) fLen     );             
  792.                                                                      
  793.             card = cardc_ (  ( char      * ) (fCell),                
  794.                              ( ftnlen      ) fLen     );             
  795.          }                                                           
  796.                                                                      
  797.                                                                      
  798.          /*                                                          
  799.          Copy the Fortran array into the output array.               
  800.          */                                                          
  801.                                                                      
  802.          nBytes = ndim * fLen * sizeof(SpiceChar);                   
  803.          memmove ( array, fCell, nBytes );                           
  804.          /*                                                          
  805.          Convert the output array from Fortran to C style.           
  806.          */                                                          
  807.          F2C_ConvertTrStrArr ( ndim, lenvals, (SpiceChar *)array );  
  808.                                                                      
  809.          /*                                                          
  810.          Sync the size and cardinality of the C cell.                
  811.          */                                                          
  812.          if ( !failed_c() )                                          
  813.          {                                                           
  814.             (CCell)->size = size;                                    
  815.             (CCell)->card = card;                                    
  816.          }                                                           
  817.       }
  818.    
  819. /*
  820.    End of header SpiceZmc.h 
  821. */