home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / star.lzh / star.23 < prev    next >
Encoding:
Text File  |  1990-04-06  |  35.3 KB  |  1,405 lines

  1.  
  2. #! /bin/sh
  3. # This is a shell archive.  Remove anything before this line, then unpack
  4. # it by saving it into a file and typing "sh file".  To overwrite existing
  5. # files, type "sh file -c".  You can also feed this as standard input via
  6. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  7. # will see the following message at the end:
  8. #        "End of archive 23 (of 32)."
  9. # Contents:  starchart/starmain.c
  10. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  11. if test -f 'starchart/starmain.c' -a "${1}" != "-c" ; then 
  12.   echo shar: Will not clobber existing file \"'starchart/starmain.c'\"
  13. else
  14. echo shar: Extracting \"'starchart/starmain.c'\" \(33377 characters\)
  15. sed "s/^X//" >'starchart/starmain.c' <<'END_OF_FILE'
  16. X/*
  17. X * starmain.c, starchart.c without routines moved to starsupp.c
  18. X * starchart.c -- version 2, September 1987
  19. X *        revision 2.1 December, 1987
  20. X *        revision 3.2 February 1990
  21. X * contact Craig Counterman, email: ccount@athena.mit.edu
  22. X *
  23. X * Portions Copyright (c) 1987 by Alan Paeth (awpaeth@watcgl)
  24. X *
  25. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  26. X *
  27. X * This software may be redistributed freely, not sold.
  28. X * This copyright notice and disclaimer of warranty must remain
  29. X *    unchanged. 
  30. X *
  31. X * No representation is made about the suitability of this
  32. X * software for any purpose.  It is provided "as is" without express or
  33. X * implied warranty, to the extent permitted by applicable law.
  34. X *
  35. X * DISCLAIMER OF WARRANTY
  36. X * ----------------------
  37. X * The author  disclaims all warranties  with regard to  this software to
  38. X * the   extent  permitted  by applicable   law,  including all   implied
  39. X * warranties  of merchantability  and  fitness. In  no event shall   the
  40. X * author be liable for any special, indirect or consequential damages or
  41. X * any  damages whatsoever resulting from  loss of use, data or  profits,
  42. X * whether in an action of contract, negligence or other tortious action,
  43. X * arising  out of  or in connection with the  use or performance of this
  44. X * software.
  45. X *
  46. X */
  47. X
  48. X/*
  49. X ! Version 2 modification authors:
  50. X !
  51. X !   [a] Petri Launiainen, pl@intrin.FI (with Jyrki Yli-Nokari, jty@intrin.FI)
  52. X !   [b] Bob Tidd, inp@VIOLET.BERKELEY.EDU
  53. X !   [c] Alan Paeth, awpaeth@watcgl
  54. X !
  55. X */
  56. X
  57. Xstatic char rcsid[]="$Header: starmain.c,v 2.15 90/03/10 15:31:37 ccount Exp $";
  58. X
  59. X#include <stdio.h>
  60. X#include <math.h>
  61. X#ifndef SYSV
  62. X#include <strings.h>
  63. X#else
  64. X#include <string.h>
  65. X#endif
  66. X#include <ctype.h>
  67. X
  68. X#include "star3.h"
  69. X#include "parse_input.h"
  70. X
  71. X#ifndef READMODE
  72. X#define READMODE "r"
  73. X#endif
  74. X#define OPENFAIL 0
  75. X#define LINELEN 82
  76. X
  77. X#ifndef MAXPATHLEN
  78. X#define MAXPATHLEN 1025
  79. X#endif
  80. X
  81. X/* PI / 180 = .0174532925199 */
  82. X#define DCOS(x) (cos((x)*.0174532925199))
  83. X#define DSIN(x) (sin((x)*.0174532925199))
  84. X#define DTAN(x) (tan((x)*.0174532925199))
  85. X#define DASIN(x) (asin(x)/.0174532925199)
  86. X#define DATAN2(x,y) (atan2(x,y)/.0174532925199)
  87. X#define MAX(a,b) ((a)>(b)?(a):(b))
  88. X#define MIN(a,b) ((a)<(b)?(a):(b))
  89. X
  90. X/*
  91. X * default datasets are local, unless defined in Makefile
  92. X */
  93. X
  94. X#ifndef STARFILE
  95. X#define STARFILE    "./yale.star"
  96. X#endif
  97. X#ifndef STARFTYPE
  98. X#define STARFTYPE LINEREAD
  99. X#endif
  100. X
  101. X#ifndef INDEXFILE
  102. X#define INDEXFILE    "./index.indx"
  103. X#endif
  104. X#ifndef INDEXFTYPE
  105. X#define INDEXFTYPE INDEXTYPE
  106. X#endif
  107. X
  108. X#ifndef PLANETFILE
  109. X#define PLANETFILE    "./planet.star"
  110. X#endif
  111. X#ifndef PLANETFTYPE
  112. X#define PLANETFTYPE LINEREAD
  113. X#endif
  114. X
  115. X#ifndef NEBFILE
  116. X#define NEBFILE        "./neb.star"
  117. X#endif
  118. X#ifndef NEBFTYPE
  119. X#define NEBFTYPE LINEREAD
  120. X#endif
  121. X
  122. X#ifndef BOUNDFILE
  123. X#define BOUNDFILE    "./boundaries.star"
  124. X#endif
  125. X#ifndef BOUNDFTYPE
  126. X#define BOUNDFTYPE LINEREAD
  127. X#endif
  128. X
  129. X#ifndef PATTERNFILE
  130. X#define PATTERNFILE    "./pattern.star"
  131. X#endif
  132. X#ifndef PATTFTYPE
  133. X#define PATTFTYPE LINEREAD
  134. X#endif
  135. X
  136. X#ifndef CNAMEFILE
  137. X#define CNAMEFILE    "./cnames.star"
  138. X#endif
  139. X#ifndef CNAMEFTYPE
  140. X#define CNAMEFTYPE LINEREAD
  141. X#endif
  142. X
  143. X#ifndef CONSTFILE
  144. X#define CONSTFILE    "./con.locs"
  145. X#endif
  146. X
  147. X#ifndef RCFILE
  148. X#define RCFILE    "./.starrc"
  149. X#endif
  150. X
  151. X
  152. X/* arguments */
  153. Xint g_argc;
  154. Xchar **g_argv;
  155. X
  156. X/* Globals read from command line or set by D_userinput */
  157. Xchar *progname;
  158. Xdouble ra, de, sc;
  159. Xchar *title = "";
  160. Xdouble all_lbllim, all_maglim, all_gklim;
  161. Xint use_lbllim = FALSE, use_maglim = FALSE, use_gklim = FALSE;
  162. X
  163. Xint user_interact = FALSE;
  164. X
  165. Xint precess = FALSE;
  166. Xdouble to_precess = 2000.0;
  167. X
  168. Xdouble all_vmin, all_vmax;
  169. Xint use_vmin = FALSE;
  170. Xint nomaglbls = FALSE;
  171. X
  172. Xdouble all_rstep, all_dstep;
  173. Xint use_rstep = FALSE;
  174. Xint no_ra_grid = FALSE;
  175. Xint no_dec_grid = FALSE;
  176. Xdouble all_rstrt = 0.0, all_dstrt = 0.0;
  177. X
  178. Xint all_invert = FALSE;
  179. X
  180. Xint chart_type = THREEPART;
  181. X
  182. Xint all_proj_mode = SANSONS;
  183. X
  184. Xchar *rcfile = RCFILE;
  185. X
  186. Xchar *constfile = CONSTFILE;
  187. Xchar *boundfile = BOUNDFILE;
  188. Xchar boundftype = BOUNDFTYPE;
  189. Xchar *patternfile = PATTERNFILE;
  190. Xchar pattftype = PATTFTYPE;
  191. Xchar *cnamefile = CNAMEFILE;
  192. Xchar cnameftype = CNAMEFTYPE;
  193. Xchar *mapfiles[MAXMAPFILES];
  194. Xint mapftypes[MAXMAPFILES];
  195. Xint nummapfiles;
  196. X
  197. Xmapwindow *mapwin[MAXWINDOWS];
  198. Xint numwins;
  199. X
  200. Xint cur_function;
  201. Xint cur_map_type;
  202. Xint cur_map_tag;
  203. Xchar *cur_tag_field;
  204. Xchar *cur_file_name = "";
  205. Xmapwindow *cur_win;
  206. X
  207. Xint read_mapwin_file;
  208. Xint write_mapwin_file;
  209. Xchar mapwin_file[MAXPATHLEN];
  210. X
  211. X
  212. X/* read file function indirection to allow for use of alternate file readers */
  213. Xint readstar();
  214. Xint buf_readstar();
  215. X/* Macintosh MPW currently doesn't support buf_readstar */
  216. X#ifndef macintosh
  217. Xint (*readfile)() = buf_readstar;
  218. X#else
  219. Xint (*readfile)() = readstar;
  220. X#endif
  221. X
  222. X/* Readstar globals */
  223. Xdouble obj_lat, obj_lon, obj_mag;
  224. Xchar obj_type[] ="SS", obj_color[3], obj_label[3];
  225. Xchar obj_constell[3], obj_name[LINELEN];
  226. Xchar *obj_commnt, fileline[LINELEN];
  227. X
  228. X/* xform globals */
  229. Xextern double xf_west, xf_east, xf_north, xf_south, xf_bottom;
  230. Xextern int xf_xcen, xf_ycen, xf_ybot;
  231. Xextern int xf_w_left, xf_w_right, xf_w_top, xf_w_bot;
  232. X
  233. Xextern double xf_c_scale;
  234. X
  235. X/* Other globals */
  236. Xint all_layer[MAXLAYRS];
  237. Xint numlayers;
  238. X
  239. X/* storage area big enough for inputs */
  240. Xchar a_title[MAXPATHLEN];
  241. Xchar a_starfile[MAXPATHLEN];
  242. Xchar a_indexfile[MAXPATHLEN];
  243. Xchar a_planetfile[MAXPATHLEN];
  244. Xchar a_nebfile[MAXPATHLEN];
  245. Xchar a_constfile[MAXPATHLEN];
  246. Xchar a_boundfile[MAXPATHLEN];
  247. Xchar a_patternfile[MAXPATHLEN];
  248. Xchar a_cnamefile[MAXPATHLEN];
  249. Xchar a_userfile[MAXMAPFILES][MAXPATHLEN];
  250. X
  251. X
  252. X/* externals */
  253. Xextern mapwindow fullpage;
  254. Xextern mapwindow mainmap;
  255. Xextern mapwindow thumbmap;
  256. Xextern int htick_lim, htext_lim;
  257. Xextern int htext_xoff, htext_yoff;
  258. Xextern int vtick_lim, vtext_lim;
  259. Xextern int vtext_xoff, vtext_yoff;
  260. X
  261. X/* the code */
  262. Xmain(argc, argv)
  263. X     int argc;
  264. X     char *argv[];
  265. X{
  266. X  int i, j, k;
  267. X  int imap;
  268. X  int ilay;
  269. X  mapwindow *win;
  270. X#define COMMBUFLEN 1000
  271. X  char commbuf[COMMBUFLEN+2];
  272. X  FILE *mfile;
  273. X
  274. X  /* Set global arguments */
  275. X  g_argc = argc;
  276. X  g_argv = argv;
  277. X  progname = g_argv[0];
  278. X  
  279. X  /* Set defaults */
  280. X  ra = 0.0;
  281. X  de = 0.0;
  282. X  sc = 15.0;
  283. X
  284. X  mapfiles[YALEF] = a_starfile;
  285. X  strcpy(a_starfile, STARFILE);
  286. X  mapfiles[INDXF] = a_indexfile;
  287. X  strcpy(a_indexfile, INDEXFILE);
  288. X  mapfiles[PLANF] = a_planetfile;
  289. X  strcpy(a_planetfile, PLANETFILE);
  290. X  mapfiles[NEBF] = a_nebfile;
  291. X  strcpy(a_nebfile, NEBFILE);
  292. X  mapftypes[YALEF] = STARFTYPE;
  293. X  mapftypes[INDXF] = INDEXFTYPE;
  294. X  mapftypes[PLANF] = PLANETFTYPE;
  295. X  mapftypes[NEBF] = NEBFTYPE;
  296. X  nummapfiles = NUMFS;
  297. X  
  298. X  for (i = 0; i < MAXUFILES; i++) {
  299. X    mapfiles[NUMFS+i] = a_userfile[i];
  300. X    mapftypes[NUMFS+i] = LINEREAD;
  301. X  }
  302. X  
  303. X  all_layer[0] = OUTLINE;
  304. X  all_layer[1] = RA_GRID;
  305. X  all_layer[2] = DEC_GRID;
  306. X  all_layer[3] = ECLIPTIC;
  307. X  all_layer[4] = BOUNDARIES;
  308. X  all_layer[5] = PATTERNS;
  309. X  all_layer[6] = CONSTLNAMES;
  310. X  all_layer[7] = ALLFILES;
  311. X  all_layer[8] = LEGENDS;
  312. X  numlayers = 9;
  313. X  
  314. X  /* Read .starrc or other rc file */
  315. X  if (!rc_read(rcfile));
  316. X  /* couldn't open rcfile, but that's OK */
  317. X  
  318. X  /* Read command line: may override .starrc */
  319. X  if (!commandline());
  320. X  /* no arguments, but that's OK */
  321. X  
  322. X#ifdef INTERACTIVE_CONTROL
  323. X  while (D_userinput()) {
  324. X#endif
  325. X  
  326. X  /* set up maps */
  327. X  switch (chart_type) {
  328. X  case THREEPART:
  329. X    mapwin[0] = &mainmap;
  330. X/* it's okay to have thumbmap in stereographic mode now
  331. X    if (all_proj_mode == STEREOGR) {
  332. X      numwins = 1;
  333. X    } else {
  334. X      mapwin[1] = &thumbmap;
  335. X      numwins = 2;
  336. X    }
  337. X*/
  338. X    mapwin[1] = &thumbmap;
  339. X    numwins = 2;
  340. X    break;
  341. X  case FULLPAGE:
  342. X    mapwin[0] = &fullpage;
  343. X    numwins = 1;
  344. X    break;
  345. X  default:
  346. X    numwins = 0;
  347. X    break;
  348. X  }
  349. X  
  350. X      
  351. X  for (i = 0; i < numwins; i++) {
  352. X    if (use_maglim) 
  353. X      mapwin[i]->maglim = all_maglim;
  354. X
  355. X    if (use_lbllim) mapwin[i]->lbllim = all_lbllim;
  356. X    if (use_gklim) mapwin[i]->gklim = all_gklim;
  357. X
  358. X    mapwin[i]->racen = ra;
  359. X    mapwin[i]->dlcen = de;
  360. X    
  361. X    mapwin[i]->scale = sc;
  362. X
  363. X    mapwin[i]->proj_mode = all_proj_mode;
  364. X    
  365. X   
  366. X    if (use_rstep) {
  367. X      mapwin[i]->draw_ragrid = TRUE;
  368. X      mapwin[i]->draw_decgrid = TRUE;
  369. X      mapwin[i]->ra_step = all_rstep;
  370. X      mapwin[i]->dec_step = all_dstep;
  371. X      mapwin[i]->ra_strt = all_rstrt;
  372. X      mapwin[i]->dec_strt = all_dstrt;
  373. X    }
  374. X    
  375. X    if (no_ra_grid) mapwin[i]->draw_ragrid = FALSE;
  376. X    if (no_dec_grid) mapwin[i]->draw_decgrid = FALSE;
  377. X
  378. X    if (all_invert) mapwin[i]->invert = TRUE;
  379. X    
  380. X    for (j =0; j < numlayers; j++)
  381. X      mapwin[i]->layer[j] = all_layer[j];
  382. X    mapwin[i]->nlayers= numlayers;
  383. X
  384. X    for (j =0; j < nummapfiles; j++) {
  385. X      mapwin[i]->file[j].name = mapfiles[j];
  386. X      mapwin[i]->file[j].type = mapftypes[j];
  387. X      mapwin[i]->file[j].maglim = mapwin[i]->maglim;
  388. X      mapwin[i]->file[j].lbllim = mapwin[i]->lbllim;
  389. X      mapwin[i]->file[j].gklim = mapwin[i]->gklim;
  390. X
  391. X      if (use_vmin)  {
  392. X    mapwin[i]->file[j].draw_maglbl = TRUE;
  393. X    mapwin[i]->file[j].maglmin = all_vmin;
  394. X    mapwin[i]->file[j].maglmax = all_vmax;
  395. X      }
  396. X      if (nomaglbls) mapwin[i]->file[j].draw_maglbl = FALSE;
  397. X    }
  398. X    mapwin[i]->numfiles = nummapfiles;
  399. X  }
  400. X      
  401. X  /* Give driver a chance to change the mapwins */
  402. X  fix_mapwin();
  403. X#ifdef INTERACTIVE_CONTROL
  404. X  if (user_interact)
  405. X    D_mapwininput();
  406. X#endif
  407. X
  408. X      
  409. X  /* Begin chart */
  410. X  if (!D_open())
  411. X    die("couldn't open device", "");
  412. X
  413. X  k = 0;
  414. X  commbuf[0] = '\0';
  415. X  for (i = 0; (i < argc) && (k < COMMBUFLEN); i++) {
  416. X    sprintf(&commbuf[strlen(commbuf)], "%s ", argv[i]);
  417. X  }
  418. X  D_comment(commbuf);
  419. X
  420. X  /* Write the current settings to mapwin file */
  421. X  /* Must be done here to allow D_open to change settings, esp. window size */
  422. X  if ((write_mapwin_file)  && ((mfile = fopen(mapwin_file, "w")) != NULL)) {
  423. X    write_mfile(mfile);
  424. X    fclose(mfile);
  425. X  }
  426. X  
  427. X  if (precess)
  428. X    initprecess(to_precess);
  429. X
  430. X
  431. X  D_comment("Start");
  432. X
  433. X  /* Draw the chart */
  434. X  /* For each map
  435. X       for each layer
  436. X         draw the layer */
  437. X  for (imap = 0; imap < numwins; imap++) {
  438. X#ifdef INTERACTIVE_CONTROL
  439. X  if (user_interact)
  440. X    if (D_break()) break;
  441. X#endif
  442. X    win = mapwin[imap];
  443. X    if (!chartparms(win)) continue;
  444. X    if (!initxform(win)) continue;    /* initialize xform before using it */
  445. X
  446. X    cur_map_type = win->map_type;
  447. X    cur_map_tag = win->tag;
  448. X    cur_tag_field = win->tag_field;
  449. X    cur_win = mapwin[imap];
  450. X
  451. X    for (ilay = 0; ilay < win->nlayers; ilay++) {
  452. X#ifdef INTERACTIVE_CONTROL
  453. X      if (user_interact)
  454. X    if (D_break()) break;
  455. X#endif
  456. X      switch (win->layer[ilay]) {
  457. X      case OUTLINE:
  458. X    D_comment("OUTLINE");
  459. X    chartoutline(win);
  460. X    break;
  461. X      case RA_GRID:
  462. X    D_comment("RA_GRID");
  463. X    chartragrid(win);
  464. X    break;
  465. X      case DEC_GRID:
  466. X    D_comment("DEC_GRID");
  467. X    chartdecgrid(win);
  468. X    break;
  469. X      case ECLIPTIC:
  470. X    D_comment("ECLIPTIC");
  471. X    chartecliptic(win);
  472. X    break;
  473. X      case BOUNDARIES:
  474. X    D_comment("BOUNDARIES");
  475. X    chartboundaries(win);
  476. X    break;
  477. X      case PATTERNS:
  478. X    D_comment("PATTERNS");
  479. X    chartpatterns(win);
  480. X    break;
  481. X      case CONSTLNAMES:
  482. X    D_comment("CONSTLNAMES");
  483. X    chartconstlnames(win);
  484. X    break;
  485. X      case ALLFILES:
  486. X    D_comment("ALLFILES");
  487. X    chartmain(win, ALLFILES);
  488. X    break;
  489. X      case ALLGLYPHS:
  490. X    D_comment("ALLGLYPHS");
  491. X    chartmain(win, ALLGLYPHS);
  492. X    break;
  493. X      case ALLNAMES:
  494. X    D_comment("ALLNAMES");
  495. X    chartmain(win, ALLNAMES);
  496. X    break;
  497. X      case ALLMAGLBLS:
  498. X    D_comment("ALLMAGLBLS");
  499. X    chartmain(win, ALLMAGLBLS);
  500. X    break;
  501. X      case ALLVECTORS:
  502. X    D_comment("ALLVECTORS");
  503. X    chartmain(win, ALLVECTORS);
  504. X    break;
  505. X      case ALLAREAS:
  506. X    D_comment("ALLAREAS");
  507. X    chartmain(win, ALLAREAS);
  508. X    break;
  509. X      case LEGENDS:
  510. X    D_comment("LEGENDS");
  511. X    chartlegend(win);
  512. X    break;
  513. X      }
  514. X    }
  515. X  }
  516. X  
  517. X  /* Done chart: close and exit */
  518. X  D_comment("Close");
  519. X  D_close();
  520. X
  521. X#ifdef INTERACTIVE_CONTROL
  522. X  }
  523. X#endif
  524. X
  525. X
  526. X  exit(0);
  527. X}
  528. X
  529. X
  530. Xcommandline()
  531. X{
  532. X  int j, k;
  533. X  double varmag, varrange;
  534. X  int loc_argc;
  535. X/*
  536. X * check command line style
  537. X */
  538. X  if (g_argc == 1) return (FALSE);
  539. X
  540. X  if  ( (g_argv[1][0] == '-') && g_argv[1][1] ) {
  541. X/*
  542. X * new style command line (using flags)
  543. X */
  544. X    loc_argc = g_argc;        /* in case D_control_args changes g_argc */
  545. X    for (j=1; j<loc_argc; j++) {
  546. X      if (g_argv[j][0] != '-') die("unknown argument - '%s'", g_argv[j]);
  547. X      switch (g_argv[j][1]) {
  548. X
  549. X#ifdef INTERACTIVE_CONTROL
  550. X      case 'u': user_interact = TRUE; break;
  551. X#endif
  552. X
  553. X      case 'r': ra = htod(g_argv[++j])*15.0; break; /* hrs -> deg */
  554. X      case 'd': de = htod(g_argv[++j]); break;
  555. X      case 's': sc = atof(g_argv[++j]); break;
  556. X
  557. X      case 'm': all_maglim = (double)(atof(g_argv[++j]));
  558. X    use_maglim = TRUE; break;
  559. X      case 'l': all_lbllim = (double)(atof(g_argv[++j]));
  560. X    use_lbllim = TRUE; break;
  561. X      case 'g': all_gklim  = (double)(atof(g_argv[++j]));
  562. X    use_gklim = TRUE; break;
  563. X
  564. X      case 'p':
  565. X    if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-'))
  566. X      {
  567. X        if (k = tr_pmode(g_argv[++j])) {
  568. X          all_proj_mode = k;
  569. X        }
  570. X      }
  571. X    else all_proj_mode = STEREOGR;
  572. X    break;
  573. X
  574. X      case 'b': chart_type = FULLPAGE; break;
  575. X
  576. X      case 'i': all_invert = TRUE; break;
  577. X
  578. X      case 't': title = g_argv[++j]; break;
  579. X
  580. X    /* can be filename filetype  or just  filename */
  581. X      case 'y':
  582. X    strcpy(mapfiles[YALEF], g_argv[++j]);
  583. X    if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-') && 
  584. X        tr_fty(g_argv[j+1]))
  585. X      mapftypes[YALEF] = tr_fty(g_argv[++j]);
  586. X    break;
  587. X      case 'h':  strcpy(mapfiles[INDXF], g_argv[++j]); break;
  588. X      case 'n':
  589. X    strcpy(mapfiles[NEBF], g_argv[++j]);
  590. X    if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-') && 
  591. X        tr_fty(g_argv[j+1]))
  592. X      mapftypes[NEBF] = tr_fty(g_argv[++j]);
  593. X    break;
  594. X      case 'w':
  595. X    strcpy(mapfiles[PLANF], g_argv[++j]);
  596. X    if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-') && 
  597. X        tr_fty(g_argv[j+1]))
  598. X      mapftypes[PLANF] = tr_fty(g_argv[++j]);
  599. X    break;
  600. X      case 'f': 
  601. X    if (nummapfiles == MAXMAPFILES) {
  602. X      fprintf(stderr, "Too many user files\n");
  603. X      j++;
  604. X    } else {
  605. X      strcpy(mapfiles[nummapfiles], g_argv[++j]);
  606. X      if (((j+1) < loc_argc) && (g_argv[j+1][0] != '-') && 
  607. X          tr_fty(g_argv[j+1]))
  608. X        mapftypes[nummapfiles] = tr_fty(g_argv[++j]);
  609. X      else
  610. X        mapftypes[nummapfiles] = LINEREAD;
  611. X      nummapfiles++;
  612. X    }
  613. X    break;
  614. X
  615. X      case 'c':    /* could be -c con or -c con con.locs */
  616. X    if (((j+2) < loc_argc) && (g_argv[j+2][0] != '-'))
  617. X      {
  618. X        constfile = g_argv[j+2];
  619. X        findconst(g_argv[++j]);
  620. X        j++;
  621. X      }
  622. X    else findconst(g_argv[++j]);
  623. X    break;
  624. X    
  625. X    
  626. X      case 'v':
  627. X    if (((j+2) < loc_argc) && (g_argv[j+2][0] != '-')
  628. X        && (g_argv[j+1][0] != '-')) {
  629. X      varmag = atof(g_argv[j+1]);
  630. X      varrange = atof(g_argv[j+2]);
  631. X      use_vmin = TRUE;
  632. X      all_vmin = varmag - varrange;
  633. X      all_vmax = varmag + varrange;
  634. X      j += 2;
  635. X    } else die("Need varmag varrange for -v","");
  636. X    break;
  637. X
  638. X      case 'x':
  639. X    if (((j+2) < loc_argc) && (g_argv[j+2][0] != '-')
  640. X        && (g_argv[j+1][0] != '-')) {
  641. X      use_rstep = TRUE;
  642. X      all_rstep = htod(g_argv[j+1])*15.0;
  643. X      all_dstep = htod(g_argv[j+2]);
  644. X      if (((j+4) < loc_argc)
  645. X          && (!isalpha(g_argv[j+3][1]))
  646. X          && (!isalpha(g_argv[j+4][1]))) {
  647. X        all_rstrt = htod(g_argv[j+3])*15.0;
  648. X        all_dstrt = htod(g_argv[j+4]);
  649. X        j += 4;
  650. X      } else
  651. X        j += 2;
  652. X    } else die("Need ra_step de_step for -x","");
  653. X    break;
  654. X
  655. X      case 'e':
  656. X    if (!rc_read(g_argv[++j]))
  657. X      fprintf(stderr,
  658. X          "%s: error, couldn't read rc file '%s'\n",
  659. X          progname, g_argv[j]);
  660. X    break;
  661. X
  662. X      case 'a':
  663. X    D_control_arg(g_argv[++j]);
  664. X    break;
  665. X    
  666. X      default:
  667. X    if (!ident_arg(&j))
  668. X      die("unknown switch - '%s'", g_argv[j]);
  669. X    break;
  670. X      }
  671. X      if (j == loc_argc) die("trailing command line flag - '%s'", g_argv[j-1]);
  672. X    }
  673. X  }
  674. X  else
  675. X    {
  676. X      /*
  677. X       * old style command line (position dependent)
  678. X       */
  679. X      fprintf(stderr, "Old style command line no longer supported\n");
  680. X      fprintf(stderr, "Please convert:\n");
  681. X      fprintf(stderr, "old: Ra Dcl Scale Title Maglim Labellim\n");
  682. X      fprintf(stderr, "new: -r Ra -d Dcl -s Scale -t Title\n");
  683. X    }
  684. X  return (TRUE);
  685. X}
  686. X
  687. Xdie(a,b)
  688. X     char *a, *b;
  689. X{
  690. X  /* Currently only Gdos needs this, there appl_exit() is always necessary */
  691. X#ifdef ATARI_ST
  692. X  D_die(a,b);
  693. X#endif
  694. X  fprintf(stderr,"%s: ", progname);
  695. X  fprintf(stderr,a,b);
  696. X  fprintf(stderr,"\n");
  697. X  exit(1);
  698. X}
  699. X
  700. Xdouble htod(s)
  701. X     char *s;
  702. X{
  703. X  /*
  704. X   * htod(str) reads floating point strings of the form {+-}hh.{mm} thus
  705. X   * allowing for fractional values in base 60 (ie, degrees/minutes).
  706. X   */
  707. X  return(ftod(atof(s)));
  708. X}
  709. X
  710. Xdouble ftod(x)
  711. X     double x;
  712. X{
  713. X  int full;
  714. X  full = x;
  715. X  return(full + (x-full)*100.0/60.0);
  716. X}
  717. X
  718. X
  719. X/* dtof(x) undoes ftod */
  720. Xdouble dtof(x)
  721. X     double x;
  722. X{
  723. X  int full;
  724. X  full = x;
  725. X  return(full + (x-full)*60.0/100.0);
  726. X}
  727. X
  728. X/* Adapted from code from Dean Payne deanp@hplsla.hp.com */
  729. X/* Format of each line is
  730. X    variable_name variable_value
  731. Xor    variable_name=variable_value
  732. X
  733. Xvariable_value may be a string which extends to the end of line.
  734. XLines must be 80 chars max.
  735. XComments are anything after a #
  736. XBlank lines are allowed.
  737. X*/
  738. X
  739. Xrc_read(filename)
  740. X     char *filename;
  741. X{
  742. X  FILE *sfile;
  743. X  char sbuf[LINELEN], *var_name, *c_buf;
  744. X  double f_buf;    /* value parsed as double */
  745. X  int i_buf;    /* value parsed as integer */
  746. X  int l_buf;    /* value parsed as TRUE or FALSE */
  747. X  int ret_code, var_type;
  748. X
  749. X  
  750. X  if ((sfile = fopen(filename, READMODE)) == OPENFAIL) return(FALSE);
  751. X
  752. X  fgets(sbuf, LINELEN, sfile);
  753. X  if (!(strcmp(sbuf,
  754. X          "#mapwin format 1 file: don't edit this line or change order of lines in this file"))) {
  755. X    /* This file is a mapwin file */
  756. X    strncpy(mapwin_file, filename, MAXPATHLEN-1);
  757. X    read_mapwin_file = TRUE;
  758. X    return TRUE;
  759. X  };
  760. X    
  761. X  for (;;) {
  762. X    /* We read the first line into  sbuf above, and will read the next line 
  763. X       at the bottom of the loop */
  764. X
  765. X    if (ferror(sfile)) { fprintf(stderr, "file read error\n"); break; }
  766. X    if (feof(sfile)) break;
  767. X    
  768. X    if (!parse_line(sbuf, &var_name, &ret_code, &var_type,
  769. X            &c_buf, &f_buf, &i_buf, &l_buf)) {
  770. X      /* Not recognized by parse routine,
  771. X     see if ident_rc can recognize it */
  772. X      if (!(ident_rc(var_name, c_buf))) {
  773. X    fprintf(stderr, "cannot interpret '%s = %s'\n", var_name, c_buf);
  774. X    help_vars(var_name);
  775. X      }
  776. X    } else
  777. X      switch (ret_code) {
  778. X      case TINT:
  779. X    fprintf(stderr, "int = %d\n", i_buf);
  780. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  781. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  782. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  783. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  784. X    break;
  785. X      case TFLO:
  786. X    fprintf(stderr, "flo = %f\n", f_buf);
  787. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  788. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  789. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  790. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  791. X    break;
  792. X      case TBOOL:
  793. X    fprintf(stderr, "bool = %d\n", l_buf);
  794. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  795. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  796. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  797. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  798. X    break;
  799. X      case TNONE:
  800. X    fprintf(stderr, "none = %s\n", c_buf);
  801. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  802. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  803. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  804. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  805. X    break;
  806. X      case TCHAR:
  807. X    fprintf(stderr, "char = %s\n", c_buf);
  808. X    fprintf(stderr, "i_buf = %d\n", i_buf);
  809. X    fprintf(stderr, "f_buf = %f\n", f_buf);
  810. X    fprintf(stderr, "l_buf = %d\n", l_buf);
  811. X    fprintf(stderr, "c_buf = %s\n", c_buf);
  812. X    break;
  813. X      case R_NONE:
  814. X    /* blank line */
  815. X    break;
  816. X      case END_INPUT:
  817. X    return TRUE;
  818. X    break;
  819. X      case EXIT:
  820. X    exit(0);
  821. X    break;
  822. X      case HELP_ME:
  823. X    help_vars("");
  824. X    break;
  825. X      case WRITE_RC_FILE:
  826. X    {
  827. X      FILE *tfile;
  828. X
  829. X      if ((tfile = fopen(c_buf, "w")) != NULL)
  830. X        if (rc_write(tfile)) {
  831. X          fclose(tfile);
  832. X          printf("wrote %s\n", c_buf);
  833. X        };
  834. X    };
  835. X    break;
  836. X      default:
  837. X    /* Identified but not special to this routine,
  838. X       try to set variables */
  839. X    if (!set_varvals(var_name, ret_code, var_type,
  840. X            c_buf, f_buf, i_buf, l_buf)) {
  841. X      fprintf(stderr, "cannot interpret '%s = %s'\n", var_name, c_buf);
  842. X      help_vars(var_name);
  843. X    };
  844. X    break;
  845. X      };
  846. X
  847. X    /* Always call ident_rc */
  848. X    ident_rc(var_name, c_buf);
  849. X
  850. X
  851. X    fgets(sbuf, LINELEN, sfile);
  852. X  }
  853. X  fclose(sfile);
  854. X  return (TRUE);
  855. X}
  856. X
  857. X
  858. Xrc_write(tfile)
  859. XFILE *tfile;
  860. X{
  861. X  int i;
  862. X
  863. X  fprintf(tfile, "ra = %g\n", dtof(ra / 15.0));
  864. X  fprintf(tfile, "dec = %g\n", dtof(de));
  865. X  fprintf(tfile, "scale = %g\n", sc);
  866. X  if (use_lbllim)
  867. X    fprintf(tfile, "namelim = %g\n", all_lbllim);
  868. X  if (use_gklim)
  869. X    fprintf(tfile, "gklim = %g\n", all_gklim);
  870. X  if (use_maglim)
  871. X    fprintf(tfile, "maglim = %g\n", all_maglim);
  872. X
  873. X  fprintf(tfile, "title = %s\n", title);
  874. X
  875. X  for (i = 0; i < nummapfiles; i++)
  876. X    fprintf(tfile, "mapfile = %s %s\n", mapfiles[i], inv_ftypes[mapftypes[i]]);
  877. X
  878. X  fprintf(tfile, "constfile = %s\n", constfile);
  879. X  fprintf(tfile, "boundfile = %s\n", boundfile);
  880. X  fprintf(tfile, "patternfile = %s\n", patternfile);
  881. X  fprintf(tfile, "constlnamefile = %s\n", cnamefile);
  882. X
  883. X  for (i = 0; i < numlayers; i++)
  884. X    fprintf(tfile, "all_layer = %s\n", inv_layrs[all_layer[i]]);
  885. X
  886. X  fprintf(tfile, "projection_mode = %s\n", inv_projs[all_proj_mode]);
  887. X
  888. X  fprintf(tfile, "chart_type = %s\n", inv_ctypes[chart_type]);
  889. X
  890. X  fprintf(tfile, "invert = %s\n", all_invert ? "true" : "false");
  891. X
  892. X  if (use_vmin)
  893. X    fprintf(tfile, "vrange %g %g\n", all_vmin, all_vmax);
  894. X
  895. X  if (use_rstep)
  896. X    fprintf(tfile, "grid %g %g %g %g\n", dtof(all_rstep/15.0), dtof(all_dstep),
  897. X        dtof(all_rstrt/15.0), dtof(all_dstrt));
  898. X
  899. X  if (precess)
  900. X    fprintf(tfile, "precess_to %g\n", to_precess);
  901. X
  902. X  i = ferror(tfile);
  903. X  return !i;
  904. X} 
  905. X  
  906. X
  907. Xset_varvals(var_name, ret_code, var_type, c_buf, f_buf, i_buf, l_buf)
  908. X     char *var_name;
  909. X     int ret_code, var_type;
  910. X     char *c_buf;
  911. X     double f_buf;    /* value parsed as double */
  912. X     int i_buf;    /* value parsed as integer */
  913. X     int l_buf;    /* value parsed as TRUE or FALSE */
  914. X{
  915. X  int i;
  916. X  static int nufiles = 0;
  917. X  static int nmapfs = 0;
  918. X  static int nlays = 0;
  919. X  double varmag, varrange;
  920. X  int good_flag;
  921. X  char tbuf1[LINELEN], tbuf2[LINELEN], tbuf3[LINELEN], tbuf4[LINELEN];
  922. X
  923. X
  924. X  good_flag = FALSE;
  925. X
  926. X  switch (ret_code) {
  927. X  case R_RA:
  928. X    ra = htod(c_buf)*15.0;
  929. X    good_flag = TRUE; 
  930. X    break;
  931. X  case R_DEC:
  932. X    de = htod(c_buf); 
  933. X    good_flag = TRUE; 
  934. X    break;
  935. X  case R_SCALE:
  936. X    sc = f_buf; 
  937. X    good_flag = TRUE; 
  938. X    break;
  939. X  case R_NAMELIM:
  940. X    all_lbllim = f_buf; 
  941. X    use_lbllim = TRUE;
  942. X    good_flag = TRUE; 
  943. X    break;
  944. X  case R_MAGLIM:
  945. X    all_maglim = f_buf; 
  946. X    use_maglim = TRUE;
  947. X    good_flag = TRUE; 
  948. X    break;
  949. X  case R_GKLIM:
  950. X    all_gklim = f_buf; 
  951. X    use_gklim = TRUE;
  952. X    good_flag = TRUE; 
  953. X    break;
  954. X  case R_TITLE:
  955. X    strcpy(a_title, c_buf); 
  956. X    title = a_title; 
  957. X    good_flag = TRUE; 
  958. X    break;
  959. X  case R_STARFILE:
  960. X    strcpy(a_starfile, c_buf);  
  961. X    mapfiles[YALEF] = a_starfile;
  962. X    good_flag = TRUE; 
  963. X    break;
  964. X  case R_INDEXFILE:
  965. X    strcpy(a_indexfile, c_buf);
  966. X    mapfiles[INDXF] = a_indexfile;
  967. X    good_flag = TRUE; 
  968. X    break;
  969. X  case R_NEBFILE:
  970. X    strcpy(a_nebfile, c_buf); 
  971. X    mapfiles[NEBF] = a_nebfile;
  972. X    good_flag = TRUE; 
  973. X    break;
  974. X  case R_PLANETFILE:
  975. X    strcpy(a_planetfile, c_buf); 
  976. X    mapfiles[PLANF] = a_planetfile;
  977. X    good_flag = TRUE; 
  978. X    break;
  979. X  case R_USERFILE:
  980. X    if (nummapfiles == MAXMAPFILES) {
  981. X      fprintf(stderr, "Too many user files\n");
  982. X    } else {
  983. X      i = sscanf(c_buf, "%s %s", a_userfile[nufiles], tbuf1);
  984. X      if ((i == 2) && tr_fty(tbuf1))    /* There's a type specified */
  985. X    mapftypes[nummapfiles] = tr_fty(tbuf1);
  986. X      else mapftypes[nummapfiles] = LINEREAD;
  987. X      
  988. X      mapfiles[nummapfiles] = a_userfile[nufiles];
  989. X      nufiles++;
  990. X      nummapfiles++;
  991. X    }
  992. X    good_flag = TRUE;
  993. X    break;
  994. X  case R_MAPFILE:
  995. X    if (nmapfs >= MAXMAPFILES)
  996. X      fprintf(stderr, "Too many user files\n");
  997. X    else {
  998. X      if (nmapfs == 0) {
  999. X    /* reset mapfiles pointers */
  1000. X    for (i = 0; i < MAXMAPFILES; i++)
  1001. X      mapfiles[i] = a_userfile[i];
  1002. X      };
  1003. X
  1004. X      i = sscanf(c_buf, "%s %s", a_userfile[nmapfs], tbuf1);
  1005. X      if ((i == 2) && tr_fty(tbuf1))    /* There's a type specified */
  1006. X    mapftypes[nmapfs] = tr_fty(tbuf1);
  1007. X      else mapftypes[nmapfs] = LINEREAD;
  1008. X      
  1009. X      mapfiles[nmapfs] = a_userfile[nmapfs];
  1010. X      
  1011. X      nummapfiles = ++nmapfs;
  1012. X    }
  1013. X    good_flag = TRUE;
  1014. X    break;
  1015. X  case R_CONSTFILE:
  1016. X    strcpy(a_constfile, c_buf);
  1017. X    constfile = a_constfile; 
  1018. X    good_flag = TRUE; 
  1019. X    break;
  1020. X  case R_FINDCONST:
  1021. X    findconst(c_buf); 
  1022. X    good_flag = TRUE; 
  1023. X    break;
  1024. X  case R_BOUNDFILE:
  1025. X    strcpy(a_boundfile, c_buf);
  1026. X    boundfile = a_boundfile; 
  1027. X    good_flag = TRUE; 
  1028. X    break;
  1029. X  case R_PATTERNFILE:
  1030. X    strcpy(a_patternfile, c_buf);
  1031. X    patternfile = a_patternfile; 
  1032. X    good_flag = TRUE; 
  1033. X    break;
  1034. X  case R_CONSTLNAMEFILE:
  1035. X    strcpy(a_cnamefile, c_buf);
  1036. X    cnamefile = a_cnamefile; 
  1037. X    good_flag = TRUE; 
  1038. X    break;
  1039. X  case R_LAYERS:
  1040. X    if (nlays >= MAXLAYRS)
  1041. X      fprintf(stderr, "Too many user layers\n");
  1042. X    else {
  1043. X      if (i = tr_layr(c_buf)) {
  1044. X    all_layer[nlays] = i;
  1045. X    numlayers = ++nlays;
  1046. X      }
  1047. X    }
  1048. X    good_flag = TRUE;
  1049. X    break;
  1050. X  case R_POLARMODE:
  1051. X    if (l_buf) all_proj_mode = STEREOGR; 
  1052. X    good_flag = TRUE; 
  1053. X    break;
  1054. X  case R_BIGFLAG:
  1055. X    if (l_buf) chart_type = FULLPAGE; 
  1056. X    good_flag = TRUE; 
  1057. X    break;
  1058. X  case R_PROJECTION_MODE:
  1059. X    if (i = tr_pmode(c_buf)) {
  1060. X      all_proj_mode = i;
  1061. X    }
  1062. X    good_flag = TRUE;
  1063. X    break;
  1064. X  case R_INVERT:
  1065. X    all_invert = l_buf; 
  1066. X    good_flag = TRUE; 
  1067. X    break;
  1068. X  case R_CHART_TYPE:
  1069. X    if (i = tr_ctype(c_buf)) {
  1070. X      chart_type = i;
  1071. X    }
  1072. X    good_flag = TRUE;
  1073. X    break;
  1074. X  case R_VRANGE:
  1075. X    i = sscanf(c_buf, "%lf %lf", &all_vmin, &all_vmax);
  1076. X    use_vmin = (i == 2);
  1077. X    good_flag = TRUE;
  1078. X    break;
  1079. X  case R_VMAGS:
  1080. X    i = sscanf(c_buf, "%lf %lf", &varmag, &varrange);
  1081. X    if (i == 2) {
  1082. X      use_vmin = TRUE;
  1083. X      all_vmin = varmag - varrange;
  1084. X      all_vmax = varmag + varrange;
  1085. X    }
  1086. X    good_flag = TRUE;
  1087. X    break;
  1088. X  case R_GRID:
  1089. X    i = sscanf(c_buf, "%s %s %s %s", tbuf1, tbuf2, tbuf3, tbuf4);
  1090. X    all_rstep = htod(tbuf1)*15.0;
  1091. X    all_dstep = htod(tbuf2);
  1092. X    all_rstrt = htod(tbuf3)*15.0;
  1093. X    all_dstrt = htod(tbuf4);
  1094. X    use_rstep = (i > 1);
  1095. X    good_flag = TRUE;
  1096. X    break;
  1097. X  case R_NOGRID:
  1098. X    no_ra_grid = no_dec_grid = l_buf; 
  1099. X    good_flag = TRUE; 
  1100. X    break;
  1101. X  case R_NOGRID_RA:
  1102. X    no_ra_grid = l_buf; 
  1103. X    good_flag = TRUE; 
  1104. X    break;
  1105. X  case R_NOGRID_DEC:
  1106. X    no_dec_grid = l_buf; 
  1107. X    good_flag = TRUE; 
  1108. X    break;
  1109. X  case R_NOMAGLBLS:
  1110. X    nomaglbls = l_buf; 
  1111. X    good_flag = TRUE; 
  1112. X    break;
  1113. X  case R_PRECESS_TO:
  1114. X    to_precess = f_buf;
  1115. X    precess = TRUE;
  1116. X    good_flag = TRUE;
  1117. X    break;
  1118. X  case R_DRIVER_CONTROL:
  1119. X    D_control_arg(c_buf);
  1120. X    good_flag = TRUE;
  1121. X    break;
  1122. X  case R_WRITE_MAPWIN_FILE:
  1123. X    write_mapwin_file = TRUE;
  1124. X    strncpy(mapwin_file, c_buf, MAXPATHLEN-1);
  1125. X    good_flag = TRUE;
  1126. X    break;
  1127. X  case R_READ_MAPWIN_FILE:
  1128. X    read_mapwin_file = TRUE;
  1129. X    strncpy(mapwin_file, c_buf, MAXPATHLEN-1);
  1130. X    good_flag = TRUE;
  1131. X    break;
  1132. X  default:
  1133. X    break;
  1134. X  };
  1135. X
  1136. X  return good_flag;
  1137. X}
  1138. X
  1139. X
  1140. Xint tr_layr(s)
  1141. X     char *s;
  1142. X{
  1143. X  int i;
  1144. X
  1145. X  for (i = 0; s[i]; i++)
  1146. X    if (isupper(s[i]))
  1147. X      s[i] = tolower(s[i]);
  1148. X
  1149. X  if(!strcmp(s, "outline")) return OUTLINE;
  1150. X  else if (!strcmp(s, "ra_grid")) return RA_GRID;
  1151. X  else if (!strcmp(s, "dec_grid")) return DEC_GRID;
  1152. X  else if (!strcmp(s, "ecliptic")) return ECLIPTIC;
  1153. X  else if (!strcmp(s, "boundaries")) return BOUNDARIES;
  1154. X  else if (!strcmp(s, "patterns")) return PATTERNS;
  1155. X  else if (!strcmp(s, "constlnames")) return CONSTLNAMES;
  1156. X  else if (!strcmp(s, "allfiles")) return ALLFILES;
  1157. X  else if (!strcmp(s, "allglyphs")) return ALLGLYPHS;
  1158. X  else if (!strcmp(s, "allnames")) return ALLNAMES;
  1159. X  else if (!strcmp(s, "allmaglbls")) return ALLMAGLBLS;
  1160. X  else if (!strcmp(s, "allvectors")) return ALLVECTORS;
  1161. X  else if (!strcmp(s, "allareas")) return ALLAREAS;
  1162. X  else if (!strcmp(s, "legends")) return LEGENDS;
  1163. X  else return 0;
  1164. X}
  1165. X
  1166. X
  1167. Xint tr_pmode(s)
  1168. X     char *s;
  1169. X{
  1170. X  int i;
  1171. X
  1172. X  for (i = 0; s[i]; i++)
  1173. X    if (isupper(s[i]))
  1174. X      s[i] = tolower(s[i]);
  1175. X
  1176. X  if(!strcmp(s, "stereogr")) return STEREOGR;
  1177. X  else if(!strcmp(s, "stereographic")) return STEREOGR;
  1178. X  else if (!strcmp(s, "sansons")) return SANSONS;
  1179. X  else if (!strcmp(s, "gnomonic")) return GNOMONIC;
  1180. X  else if (!strcmp(s, "orthogr")) return ORTHOGR;
  1181. X  else if (!strcmp(s, "orthographic")) return ORTHOGR;
  1182. X  else if (!strcmp(s, "rectangular")) return RECTANGULAR;
  1183. X  else return 0;
  1184. X}
  1185. X
  1186. X
  1187. Xint tr_ctype(s)
  1188. X     char *s;
  1189. X{
  1190. X  int i;
  1191. X  for (i = 0; s[i]; i++)
  1192. X    if (isupper(s[i]))
  1193. X      s[i] = tolower(s[i]);
  1194. X
  1195. X  if(!strcmp(s, "fullpage")) return FULLPAGE;
  1196. X  else if (!strcmp(s, "threepart")) return THREEPART;
  1197. X  else return 0;
  1198. X}
  1199. X
  1200. Xint tr_fty(s)
  1201. X     char *s;
  1202. X{
  1203. X  int i;
  1204. X
  1205. X  for (i = 0; s[i]; i++)
  1206. X    if (isupper(s[i]))
  1207. X      s[i] = tolower(s[i]);
  1208. X
  1209. X  if(!strcmp(s, "lineread")) return LINEREAD;
  1210. X  else if (!strcmp(s, "indextype")) return INDEXTYPE;
  1211. X  else if (!strcmp(s, "binfull")) return BINFULL;
  1212. X  else if (!strcmp(s, "binobj")) return BINOBJ;
  1213. X  else if (!strcmp(s, "binstar")) return BINSTAR;
  1214. X/*  else if (!strcmp(s, "saoformat")) return SAOFORMAT;*/
  1215. X  else if (!strcmp(s, "gsc")) return GSCTYPE;
  1216. X  else return 0;
  1217. X}
  1218. X
  1219. X
  1220. X
  1221. Xstatic char title_string[LINELEN];
  1222. X
  1223. Xfindconst(tag)
  1224. X     char *tag;
  1225. X{
  1226. X/*
  1227. X * lookup "con.locs" for a matching tag, and then substitute initial values
  1228. X * for ra, decl, scale, and label. File layout follows:
  1229. X *
  1230. X * com  13    25   10   Coma Bereneces
  1231. X * cor  15.45 28   10   Corona Borealis
  1232. X * 0....+....1....+....2....+....3
  1233. X */
  1234. X  FILE *cfile;
  1235. X  int taglen;
  1236. X  char cbuf[LINELEN+1];
  1237. X  int i;
  1238. X  
  1239. X  if ((cfile = fopen(constfile, "r")) == NULL)
  1240. X    die("open fail on '%s'", constfile);
  1241. X  taglen = strlen(tag);
  1242. X  if ((taglen < 3) || (taglen > 4))
  1243. X    die("constellation name must be three or four characters","");
  1244. X  for (;;)
  1245. X    {
  1246. X      fgets(cbuf, LINELEN, cfile);
  1247. X      if (ferror(cfile)) die("read error in '%s'", constfile);
  1248. X      if (feof(cfile)) break;
  1249. X      if (strncmp(tag, cbuf, taglen) == 0)    /* FOUND */
  1250. X    {    
  1251. X      if (4!=sscanf(cbuf,"%*5s%lf%lf%lf %[^\n]",
  1252. X            &ra, &de, &sc, title_string))
  1253. X        die("bogus line in constellation file: \"%s\"", cbuf);
  1254. X
  1255. X      ra    = ftod(ra)*15.0;
  1256. X      de    = ftod(de);
  1257. X      
  1258. X      /* remove trailing \n */
  1259. X      i = strlen(title_string);
  1260. X      if (title_string[i-1] == '\n') title_string[i-1] = '\0';
  1261. X      title = title_string;
  1262. X      return;
  1263. X    }
  1264. X    }
  1265. X  die("Constellation '%s' not found", tag);
  1266. X}
  1267. X
  1268. X/* check validity of win structure */
  1269. Xchartparms(win)
  1270. X     mapwindow *win;
  1271. X{
  1272. X  double maxdl;
  1273. X
  1274. X  /*
  1275. X   * check for bogus ra, decl, or scale
  1276. X   */
  1277. X  if ((win->racen >= 360.0) || (win->racen < 0.0))
  1278. X    die("right ascension out of range","");
  1279. X  if ((win->dlcen > 90.0) || (win->dlcen < -90.0))
  1280. X    die("declination out of range","");
  1281. X  if (win->scale < 0.0)
  1282. X    die("scale negative","");
  1283. X
  1284. X  /*
  1285. X   * check for pole wrapping and do a potential clip
  1286. X   */
  1287. X  if (win->proj_mode == SANSONS) {
  1288. X    maxdl = (90.0 - fabs(win->dlcen))*2.0;
  1289. X    if (win->scale > maxdl) win->scale = maxdl;
  1290. X    if (win->scale <= 0.0) { /* North pole is included in chart */
  1291. X      return(FALSE);
  1292. X    }
  1293. X  };
  1294. X
  1295. X      return(TRUE);
  1296. X}
  1297. X
  1298. X
  1299. X
  1300. X/* Dump current mapwin information to file. */
  1301. Xwrite_mfile(mfile)
  1302. X     FILE *mfile;
  1303. X{
  1304. X  int i, j;
  1305. X  
  1306. X  /* Tag file as being mapwin format */
  1307. X  fprintf(mfile,
  1308. X      "#mapwin format 1 file: don't edit this line or change order of lines in this file\n");
  1309. X  /* Write the title */
  1310. X  fprintf(mfile, "title=%s\n", title);
  1311. X
  1312. X  /* write number of mapwins */
  1313. X  fprintf(mfile, "numwins=%d\n", numwins);
  1314. X  for (i = 0; i < numwins; i++) {
  1315. X    fprintf(mfile, "mapwin=%d\n",i);
  1316. X    
  1317. X    fprintf(mfile, "width=%d\n", mapwin[i]->width);
  1318. X    fprintf(mfile, "height=%d\n", mapwin[i]->height);
  1319. X    fprintf(mfile, "x_offset=%d\n", mapwin[i]->x_offset);
  1320. X    fprintf(mfile, "y_offset=%d\n", mapwin[i]->y_offset);
  1321. X    
  1322. X    fprintf(mfile, "maglim=%.10f\n", mapwin[i]->maglim);
  1323. X    fprintf(mfile, "lbllim=%.10f\n", mapwin[i]->lbllim);
  1324. X    fprintf(mfile, "gklim=%.10f\n", mapwin[i]->gklim);
  1325. X    
  1326. X    
  1327. X    fprintf(mfile, "map_type=%d\n", mapwin[i]->map_type);
  1328. X    
  1329. X    
  1330. X    fprintf(mfile, "tag=%d\n", mapwin[i]->tag);
  1331. X    
  1332. X    fprintf(mfile, "tag_field=%s\n", mapwin[i]->tag_field);
  1333. X    
  1334. X    
  1335. X    fprintf(mfile, "proj_mode=%d\n", mapwin[i]->proj_mode);
  1336. X    
  1337. X    
  1338. X    fprintf(mfile, "draw_ragrid=%d\n", mapwin[i]->draw_ragrid);
  1339. X    fprintf(mfile, "draw_decgrid=%d\n", mapwin[i]->draw_decgrid);
  1340. X    
  1341. X    fprintf(mfile, "ra_step=%.10f\n", mapwin[i]->ra_step);
  1342. X    fprintf(mfile, "dec_step=%.10f\n", mapwin[i]->dec_step);
  1343. X    
  1344. X    fprintf(mfile, "ra_strt=%.10f\n", mapwin[i]->ra_strt);
  1345. X    fprintf(mfile, "dec_strt=%.10f\n", mapwin[i]->dec_strt);
  1346. X    
  1347. X    
  1348. X    fprintf(mfile, "invert=%d\n", mapwin[i]->invert);
  1349. X    
  1350. X    fprintf(mfile, "racen=%.10f\n", mapwin[i]->racen);
  1351. X    fprintf(mfile, "dlcen=%.10f\n", mapwin[i]->dlcen);
  1352. X    fprintf(mfile, "scale=%.10f\n", mapwin[i]->scale);
  1353. X    
  1354. X    fprintf(mfile, "c_scale=%.10f\n", mapwin[i]->c_scale);
  1355. X    
  1356. X    fprintf(mfile, "nlayers=%d\n", mapwin[i]->nlayers);
  1357. X    for (j = 0; j < mapwin[i]->nlayers; j++)
  1358. X      fprintf(mfile, "layer[%d] = %d\n", j, mapwin[i]->layer[j]);  
  1359. X    
  1360. X    fprintf(mfile, "numfiles=%d\n", mapwin[i]->numfiles);
  1361. X    for (j = 0; j < mapwin[i]->numfiles; j++) {
  1362. X      fprintf(mfile, "file=%d\n", j);
  1363. X      fprintf(mfile, "name=%s\n",mapwin[i]->file[j].name);
  1364. X      fprintf(mfile, "type=%d\n", mapwin[i]->file[j].type);
  1365. X      fprintf(mfile, "maglim=%.10f\n", mapwin[i]->file[j].maglim);
  1366. X      fprintf(mfile, "lbllim=%.10f\n", mapwin[i]->file[j].lbllim);
  1367. X      fprintf(mfile, "gklim=%.10f\n", mapwin[i]->file[j].gklim);
  1368. X      fprintf(mfile, "draw_maglbl=%d\n", mapwin[i]->file[j].draw_maglbl);
  1369. X      fprintf(mfile, "maglmin=%.10f\n", mapwin[i]->file[j].maglmin);
  1370. X      fprintf(mfile, "maglmax=%.10f\n", mapwin[i]->file[j].maglmax);
  1371. X    }
  1372. X  }
  1373. X  
  1374. X  
  1375. X  /* Tag file as being mapwin format */
  1376. X  fprintf(mfile,
  1377. X      "#mapwin format 1 file: don't edit this line or change order of lines in this file\n");
  1378. X}
  1379. END_OF_FILE
  1380. if test 33377 -ne `wc -c <'starchart/starmain.c'`; then
  1381.     echo shar: \"'starchart/starmain.c'\" unpacked with wrong size!
  1382. fi
  1383. # end of 'starchart/starmain.c'
  1384. fi
  1385. echo shar: End of archive 23 \(of 32\).
  1386. cp /dev/null ark23isdone
  1387. MISSING=""
  1388. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
  1389.     if test ! -f ark${I}isdone ; then
  1390.     MISSING="${MISSING} ${I}"
  1391.     fi
  1392. done
  1393. if test "${MISSING}" = "" ; then
  1394.     echo You have unpacked all 32 archives.
  1395.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1396. else
  1397.     echo You still need to unpack the following archives:
  1398.     echo "        " ${MISSING}
  1399. fi
  1400. ##  End of shell archive.
  1401. exit 0
  1402.  
  1403.  
  1404.