MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / read_const

Function read_const

sweph.cpp:4512–4890  ·  view source on GitHub ↗

SWISSEPH * reads constants on ephemeris file * ifno file # * serr error string */

Source from the content-addressed store, hash-verified

4510 * serr error string
4511 */
4512static int read_const(int ifno, char *serr)
4513{
4514 char *c, c2, *sp;
4515 char s[AS_MAXCH*2], s2[AS_MAXCH];
4516 char sastnam[41];
4517 int i, ipli, kpl;
4518 int retc;
4519 int fendian, freord;
4520 int lastnam = 19;
4521 FILE *fp;
4522 int32 lng;
4523 uint32 ulng;
4524 int32 flen, fpos;
4525 short nplan;
4526 int32 testendian;
4527 double doubles[20];
4528 struct plan_data *pdp;
4529 struct file_data *fdp = &swed.fidat[ifno];
4530 char *serr_file_damage = "Ephemeris file %s is damaged (0%s). ";
4531 char *smsg = "";
4532 int nbytes_ipl = 2;
4533 fp = fdp->fptr;
4534 /*************************************
4535 * version number of file *
4536 *************************************/
4537 sp = fgets(s, AS_MAXCH, fp);
4538 if (sp == NULL || strstr(sp, "\r\n") == NULL) {
4539 goto file_damage;
4540 }
4541 sp = strchr(s, '\r');
4542 *sp = '\0';
4543 sp = s;
4544 while (isdigit((int) *sp) == 0 && *sp != '\0')
4545 sp++;
4546 if (*sp == '\0') {
4547 smsg = "a";
4548 goto file_damage;
4549 }
4550 /* version unused so far */
4551 fdp->fversion = atoi(sp);
4552 /*************************************
4553 * correct file name? *
4554 *************************************/
4555 sp = fgets(s, AS_MAXCH, fp);
4556 if (sp == NULL || strstr(sp, "\r\n") == NULL) {
4557 smsg = "b";
4558 goto file_damage;
4559 }
4560 /* file name, without path */
4561 sp = strrchr(fdp->fnam, (int) *DIR_GLUE);
4562 if (sp == NULL) {
4563 sp = fdp->fnam;
4564 } else {
4565 sp++;
4566 }
4567 strcpy(s2, sp);
4568 /* to lower case */
4569 for (sp = s2; *sp != '\0'; sp++)

Callers 1

swephFunction · 0.85

Calls 3

do_freadFunction · 0.85
swi_crc32Function · 0.85
free_planetsFunction · 0.85

Tested by

no test coverage detected