//
// GENERATED FILE
//
use super::*;
use f2rust_std::*;
const MAXL: i32 = 36;
const MAXP: i32 = 150;
const NPERM: i32 = 692;
const MAXE: i32 = 853;
const NROOM: i32 = 14983;
const KVNMLN: i32 = 32;
const KVLEN: i32 = 80;
const FRNMLN: i32 = 32;
const BDNMLN: i32 = 36;
const MAXCOF: i32 = 20;
const MXNFAC: i32 = 10;
const LBSEP: f64 = 0.001;
const QEXP: i32 = -27;
const KWBFRM: &[u8] = b"RELATIVE";
const KWSTYL: &[u8] = b"DEF_STYLE";
const KVPARM: &[u8] = b"PARAMETERIZED";
const KWFREZ: &[u8] = b"FREEZE_EPOCH";
const KWRSTA: &[u8] = b"ROTATION_STATE";
const KVROTG: &[u8] = b"ROTATING";
const KVINRT: &[u8] = b"INERTIAL";
const KWFFAM: &[u8] = b"FAMILY";
const KVMEQT: &[u8] = b"MEAN_EQUATOR_AND_EQUINOX_OF_DATE";
const KVMECL: &[u8] = b"MEAN_ECLIPTIC_AND_EQUINOX_OF_DATE";
const KVTEQT: &[u8] = b"TRUE_EQUATOR_AND_EQUINOX_OF_DATE";
const KV2VEC: &[u8] = b"TWO-VECTOR";
const KVEULR: &[u8] = b"EULER";
const KVPROD: &[u8] = b"PRODUCT";
const KWPRCM: &[u8] = b"PREC_MODEL";
const KWNUTM: &[u8] = b"NUT_MODEL";
const KWOBQM: &[u8] = b"OBLIQ_MODEL";
const KVM001: &[u8] = b"EARTH_IAU_1976";
const KVM002: &[u8] = b"EARTH_IAU_1980";
const KVM003: &[u8] = b"EARTH_IAU_1980";
const KWVAXI: &[u8] = b"AXIS";
const KVX: &[u8] = b"X";
const KVY: &[u8] = b"Y";
const KVZ: &[u8] = b"Z";
const KWPRI: &[u8] = b"PRI_";
const KWSEC: &[u8] = b"SEC_";
const KWVCDF: &[u8] = b"VECTOR_DEF";
const KVPOSV: &[u8] = b"OBSERVER_TARGET_POSITION";
const KVVELV: &[u8] = b"OBSERVER_TARGET_VELOCITY";
const KVNEAR: &[u8] = b"TARGET_NEAR_POINT";
const KVCONS: &[u8] = b"CONSTANT";
const KWVOBS: &[u8] = b"OBSERVER";
const KWVTRG: &[u8] = b"TARGET";
const KWVFRM: &[u8] = b"FRAME";
const KWVABC: &[u8] = b"ABCORR";
const KWVSPC: &[u8] = b"SPEC";
const KVRECC: &[u8] = b"RECTANGULAR";
const KVLATC: &[u8] = b"LATITUDINAL";
const KVRADC: &[u8] = b"RA/DEC";
const KWVECT: &[u8] = b"VECTOR";
const KWLAT: &[u8] = b"LATITUDE";
const KWLON: &[u8] = b"LONGITUDE";
const KWRA: &[u8] = b"RA";
const KWDEC: &[u8] = b"DEC";
const KWATOL: &[u8] = b"ANGLE_SEP_TOL";
const KWEPOC: &[u8] = b"EPOCH";
const KWEUAX: &[u8] = b"AXES";
const KWEAC1: &[u8] = b"ANGLE_1_COEFFS";
const KWEAC2: &[u8] = b"ANGLE_2_COEFFS";
const KWEAC3: &[u8] = b"ANGLE_3_COEFFS";
const KWFFRM: &[u8] = b"FROM_FRAMES";
const KWTFRM: &[u8] = b"TO_FRAMES";
const KWUNIT: &[u8] = b"UNITS";
const KVRADN: &[u8] = b"RADIANS";
const KVDEGR: &[u8] = b"DEGREES";
const TEMPLT: &[u8] = b"FRAME_#_#";
const TEMPLN: i32 = 7;
//$Procedure ZZDYNBID ( Fetch body ID kernel variable )
pub fn ZZDYNBID(
FRNAME: &[u8],
FRCODE: i32,
ITEM: &[u8],
IDCODE: &mut i32,
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut BODNAM = [b' '; BDNMLN as usize];
let mut CDESTR = [b' '; KVNMLN as usize];
let mut DTYPE = [b' '; 1 as usize];
let mut KVNAME = [b' '; KVNMLN as usize];
let mut CODELN: i32 = 0;
let mut ITEMLN: i32 = 0;
let mut N: i32 = 0;
let mut NAMELN: i32 = 0;
let mut REQNAM: i32 = 0;
let mut REQNUM: i32 = 0;
let mut FOUND: bool = false;
//
// SPICELIB functions
//
//
// Local parameters
//
//
// TEMPLN is the length of the keyword template, minus
// the sum of the lengths of the two substitution markers ('#').
//
//
// Local variables
//
if RETURN(ctx) {
return Ok(());
}
CHKIN(b"ZZDYNBID", ctx)?;
//
// Prepare to check the name of the kernel variable we're about
// to look up.
//
// Convert the frame code to a string.
//
INTSTR(FRCODE, &mut CDESTR, ctx);
if FAILED(ctx) {
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
}
//
// Get the lengths of the input frame code, name and item.
// Compute the length of the ID-based kernel variable name;
// check this length against the maximum allowed value. If
// the name is too long, proceed to look up the form of the
// kernel variable name based on the frame name.
//
CODELN = RTRIM(&CDESTR);
NAMELN = RTRIM(FRNAME);
ITEMLN = RTRIM(ITEM);
REQNUM = ((CODELN + ITEMLN) + TEMPLN);
if (REQNUM <= KVNMLN) {
//
// First try looking for a kernel variable including the frame ID
// code.
//
// Note the template is
//
// 'FRAME_#_#'
//
REPMI(TEMPLT, b"#", FRCODE, &mut KVNAME, ctx);
REPMC(&KVNAME.clone(), b"#", ITEM, &mut KVNAME);
DTPOOL(&KVNAME, &mut FOUND, &mut N, &mut DTYPE, ctx)?;
} else {
//
// The ID-based name is too long. We can't find the variable if
// we can't look it up.
//
FOUND = false;
}
if !FOUND {
//
// We need to look up the frame name-based kernel variable.
// Determine the length of the name of this variable; make
// sure it's not too long.
//
REQNAM = ((NAMELN + ITEMLN) + TEMPLN);
if ((REQNAM > KVNMLN) && (REQNUM > KVNMLN)) {
//
// Both forms of the name are too long.
//
SETMSG(b"Kernel variable FRAME_#_# has length #; kernel variable FRAME_#_# has length #; maximum allowed length is #. Neither variable could be searched for in the kernel pool due to these name length errors.", ctx);
ERRINT(b"#", FRCODE, ctx);
ERRCH(b"#", ITEM, ctx);
ERRINT(b"#", REQNUM, ctx);
ERRCH(b"#", FRNAME, ctx);
ERRCH(b"#", ITEM, ctx);
ERRINT(b"#", REQNAM, ctx);
ERRINT(b"#", KVNMLN, ctx);
SIGERR(b"SPICE(VARNAMETOOLONG)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
} else if (REQNAM > KVNMLN) {
//
// We couldn't find the variable having the ID-based name,
// and the frame name-based variable name is too long to
// look up.
//
// Note that at this point KVNAME contains the ID-based
// kernel variable name.
//
SETMSG(b"Kernel variable # was expected to be present in the kernel pool but was not found. The alternative form of kernel variable name FRAME_#_# was not searched for because this name has excessive length (# characters vs allowed maximum of #). One of these variables is needed to define the reference frame #. Usually this type of problem is due to a missing keyword assignment in a frame kernel. Another, less likely, possibility is that other errors in a frame kernel have confused the frame subsystem into wrongly deciding these variables are needed.", ctx);
ERRCH(b"#", &KVNAME, ctx);
ERRCH(b"#", FRNAME, ctx);
ERRCH(b"#", ITEM, ctx);
ERRINT(b"#", REQNAM, ctx);
ERRINT(b"#", KVNMLN, ctx);
ERRCH(b"#", FRNAME, ctx);
SIGERR(b"SPICE(KERNELVARNOTFOUND)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
}
//
// Now try looking for a kernel variable including the frame
// name.
//
REPMC(TEMPLT, b"#", FRNAME, &mut KVNAME);
REPMC(&KVNAME.clone(), b"#", ITEM, &mut KVNAME);
DTPOOL(&KVNAME, &mut FOUND, &mut N, &mut DTYPE, ctx)?;
if (!FOUND && (REQNUM > KVNMLN)) {
//
// The kernel variable's presence (in one form or the other)
// is mandatory: signal an error. The error message
// depends on which variables we were able to try to
// look up. In this case, we never tried to look up the
// frame ID-based name.
//
// Note that at this point KVNAME contains the name-based
// kernel variable name.
//
SETMSG(b"Kernel variable # was expected to be present in the kernel pool but was not found. The alternative form of kernel variable name FRAME_#_# was not searched for because this name has excessive length (# characters vs allowed maximum of #). One of these variables is needed to define the reference frame #. Usually this type of problem is due to a missing keyword assignment in a frame kernel. Another, less likely, possibility is that other errors in a frame kernel have confused the frame subsystem into wrongly deciding these variables are needed.", ctx);
ERRCH(b"#", &KVNAME, ctx);
ERRINT(b"#", FRCODE, ctx);
ERRCH(b"#", ITEM, ctx);
ERRINT(b"#", REQNUM, ctx);
ERRINT(b"#", KVNMLN, ctx);
ERRCH(b"#", FRNAME, ctx);
SIGERR(b"SPICE(KERNELVARNOTFOUND)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
} else if !FOUND {
//
// We tried to look up both names and failed.
//
SETMSG(b"At least one of the kernel variables FRAME_#_# or FRAME_#_# was expected to be present in the kernel pool but neither was found. One of these variables is needed to define the reference frame #. Usually this type of problem is due to a missing keyword assignment in a frame kernel. Another, less likely, possibility is that other errors in a frame kernel have confused the frame subsystem into wrongly deciding these variables are needed.", ctx);
ERRINT(b"#", FRCODE, ctx);
ERRCH(b"#", ITEM, ctx);
ERRCH(b"#", FRNAME, ctx);
ERRCH(b"#", ITEM, ctx);
ERRCH(b"#", FRNAME, ctx);
SIGERR(b"SPICE(KERNELVARNOTFOUND)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
}
}
//
// Getting to this point means we found a kernel variable. The name
// of the variable is KVNAME. The data type is DTYPE and the
// cardinality is N.
//
if fstr::eq(&DTYPE, b"C") {
//
// Rather than using BADKPV, we check the cardinality of the
// kernel variable in-line so we can create a more detailed error
// message if need be.
//
if (N > 1) {
SETMSG(b"The kernel variable # has used to define frame # was expected to have size not exceeding 1 but in fact has size #. Usually this type of problem is due to an error in a frame definition provided in a frame kernel.", ctx);
ERRCH(b"#", &KVNAME, ctx);
ERRCH(b"#", FRNAME, ctx);
ERRINT(b"#", N, ctx);
SIGERR(b"SPICE(BADVARIABLESIZE)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
}
//
// Look up the kernel variable.
//
GCPOOL(
&KVNAME,
1,
1,
&mut N,
CharArrayMut::from_mut(&mut BODNAM),
&mut FOUND,
ctx,
)?;
if !FOUND {
SETMSG(
b"Variable # not found after DTPOOL indicated it was present in pool.",
ctx,
);
ERRCH(b"#", &KVNAME, ctx);
SIGERR(b"SPICE(BUG)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
}
//
// Convert the body name to a body code.
//
BODS2C(&BODNAM, IDCODE, &mut FOUND, ctx)?;
if !FOUND {
SETMSG(b"Body name # could not be translated to an ID code.", ctx);
ERRCH(b"#", &BODNAM, ctx);
SIGERR(b"SPICE(NOTRANSLATION)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
}
} else {
//
// The variable has numeric type.
//
if (N > 1) {
SETMSG(b"The kernel variable # has used to define frame # was expected to have size not exceeding 1 but in fact has size #. Usually this type of problem is due to an error in a frame definition provided in a frame kernel.", ctx);
ERRCH(b"#", &KVNAME, ctx);
ERRCH(b"#", FRNAME, ctx);
ERRINT(b"#", N, ctx);
SIGERR(b"SPICE(BADVARIABLESIZE)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
}
//
// Look up the kernel variable.
//
GIPOOL(
&KVNAME,
1,
1,
&mut N,
std::slice::from_mut(IDCODE),
&mut FOUND,
ctx,
)?;
if !FOUND {
SETMSG(
b"Variable # not found after DTPOOL indicated it was present in pool.",
ctx,
);
ERRCH(b"#", &KVNAME, ctx);
SIGERR(b"SPICE(BUG)", ctx)?;
CHKOUT(b"ZZDYNBID", ctx)?;
return Ok(());
}
}
CHKOUT(b"ZZDYNBID", ctx)?;
Ok(())
}