public int swi_open_jpl_file(CPointer<double> ss, string fname, string fpath, ref string serr) { int retc = SwissEph.OK; /* if open, return */ if (js != null && js.jplfptr != null) return SwissEph.OK; js = new jpl_save(); //if ((js = (struct jpl_save *) CALLOC(1, sizeof(struct jpl_save))) == NULL // || (js.jplfname = MALLOC(strlen(fname)+1)) == NULL // || (js.jplfpath = MALLOC(strlen(fpath)+1)) == NULL // ) { // serr= "error in malloc() with JPL ephemeris."; // return ERR; //} js.jplfname = fname; js.jplfpath = fpath; retc = read_const_jpl(ss, ref serr); if (retc != SwissEph.OK) swi_close_jpl_file(); else { /* intializations for function interpol() */ js.pc[0] = 1; js.pc[1] = 2; js.vc[1] = 1; js.ac[2] = 4; js.jc[3] = 24; } return retc; }
public void swi_close_jpl_file() { if (js != null) { if (js.jplfptr != null) //fclose(js.jplfptr); js.jplfptr.Dispose(); //if (js.jplfname != null) // FREE((void *) js.jplfname); //if (js.jplfpath != NULL) // FREE((void *) js.jplfpath); //FREE((void *) js); js = null; } }