home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume9 / fplan / part01 next >
Text File  |  1989-11-26  |  21KB  |  563 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v09i011: FPLAN 1/6
  3. from: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  4. Reply-To: tynor@prism.gatech.edu (Steve Tynor)
  5.  
  6. Posting-number: Volume 9, Issue 11
  7. Submitted-by: tynor@prism.gatech.edu (Steve Tynor)
  8. Archive-name: fplan/part01
  9.  
  10.     FPLAN v.1.1 - Flight Plan program.
  11.  
  12.     FPLAN is a flight planner intended for use in general
  13. aviation.  FPLAN reads a planfile consisting of departure and
  14. destination airports, navigation aids, intermediate checkpoints, fuel
  15. consumption rates, winds aloft, and produces a flight plan including
  16. wind corrected heading, fuel consumption for each leg, vor fixes for
  17. each checkpoint, etc.  FPLAN uses NAV format databases for upward
  18. compatibility with those widely distributed databases (see the file
  19. WHERE_DBS for details on how to get them).
  20.  
  21.     How is FPLAN different from NAV? Mainly, it will automatically
  22. compute VOR cross fixes (radial and distance to/from fix) at each
  23. waypoint along the flight and allow you to enter a waypoint as ``15
  24. miles since the previous waypoint along the current heading''. These
  25. features provide a kind of flight plan more useful in VFR / dead
  26. reckoning flight, where frequent checkpoints are necessary.
  27.  
  28.     This program is in the public domain. Permission to copy,
  29. distribute, modify this program is hearby given as long as this header
  30. remains. If you redistribute this program after modifying it, please
  31. document your changes so that I do not take the blame (or credit) for
  32. those changes.  If you fix bugs or add features, please send me a
  33. patch so that I can keep the `official' version up-to-date. Bug
  34. reports are welcome and I'll make an attempt to fix those that are
  35. reported.
  36.  
  37.     USE AT YOUR OWN RISK! I assume no responsibility for any
  38. errors in this program, its databases or documentation. I will make an
  39. effort to fix bugs, but if you crash and burn because, for example,
  40. fuel estimates in this program were inaccurate, it's your own fault
  41. for trusting somebody else's code! Remember, as Pilot in Command, it's
  42. _your_ responsibility to do complete preflight planning. Use this
  43. program as a flight planning aid, but verify its results before using
  44. them.
  45.  
  46. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  47.     Virtue is its own punishment.
  48.  
  49.     Steve Tynor
  50.  
  51.     Yellow Jacket Flying Club
  52.     and
  53.     Georgia Tech Research Institute
  54.     Artificial Intelligence Branch
  55.     Georgia Institute of Technology
  56.     tynor@prism.gatech.edu
  57.  
  58. ---- cut here ---- cut here ---- cut here ---- cut here ----
  59. # This is part 1/6 of FPLAN
  60. #!/bin/sh
  61. # shar:    Shell Archiver  (v1.22)
  62. #    Packed Mon Nov 20 19:28:33 EST 1989 by gaffa!tynor
  63. #    from directory /files/home/users/tynor/src/fplan
  64. #
  65. #    Run the following text with /bin/sh to create:
  66. #      README
  67. #      NEW_FEATURES
  68. #      EXAMPLE.fplan
  69. #      WHERE_DBS
  70. #      Makefile
  71. #      paddb.c
  72. #
  73. echo "x - extracting README (Text)"
  74. sed 's/^X//' << 'SHAR_EOF' > README &&
  75. X    FPLAN v.1.1 - Flight Plan program.
  76. X
  77. X    FPLAN is a flight planner intended for use in general
  78. Xaviation.  FPLAN reads a planfile consisting of departure and
  79. Xdestination airports, navigation aids, intermediate checkpoints, fuel
  80. Xconsumption rates, winds aloft, and produces a flight plan including
  81. Xwind corrected heading, fuel consumption for each leg, vor fixes for
  82. Xeach checkpoint, etc.  FPLAN uses NAV format databases for upward
  83. Xcompatibility with those widely distributed databases (see the file
  84. XWHERE_DBS for details on how to get them).
  85. X
  86. X    How is FPLAN different from NAV? Mainly, it will automatically
  87. Xcompute VOR cross fixes (radial and distance to/from fix) at each
  88. Xwaypoint along the flight and allow you to enter a waypoint as ``15
  89. Xmiles since the previous waypoint along the current heading''. These
  90. Xfeatures provide a kind of flight plan more useful in VFR / dead
  91. Xreckoning flight, where frequent checkpoints are necessary.
  92. X
  93. X    This program is in the public domain. Permission to copy,
  94. Xdistribute, modify this program is hearby given as long as this header
  95. Xremains. If you redistribute this program after modifying it, please
  96. Xdocument your changes so that I do not take the blame (or credit) for
  97. Xthose changes.  If you fix bugs or add features, please send me a
  98. Xpatch so that I can keep the `official' version up-to-date. Bug
  99. Xreports are welcome and I'll make an attempt to fix those that are
  100. Xreported.
  101. X
  102. X    USE AT YOUR OWN RISK! I assume no responsibility for any
  103. Xerrors in this program, its databases or documentation. I will make an
  104. Xeffort to fix bugs, but if you crash and burn because, for example,
  105. Xfuel estimates in this program were inaccurate, it's your own fault
  106. Xfor trusting somebody else's code! Remember, as Pilot in Command, it's
  107. X_your_ responsibility to do complete preflight planning. Use this
  108. Xprogram as a flight planning aid, but verify its results before using
  109. Xthem.
  110. X
  111. X=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  112. X    Virtue is its own punishment.
  113. X
  114. X    Steve Tynor
  115. X
  116. X    Yellow Jacket Flying Club
  117. X    and
  118. X    Georgia Tech Research Institute
  119. X    Artificial Intelligence Branch
  120. X    Georgia Institute of Technology
  121. X    tynor@prism.gatech.edu
  122. SHAR_EOF
  123. chmod 0444 README || echo "restore of README fails"
  124. echo "x - extracting NEW_FEATURES (Text)"
  125. sed 's/^X//' << 'SHAR_EOF' > NEW_FEATURES &&
  126. XThe following list summarizes the difference between FPLAN version 1.0
  127. Xand  1.1:
  128. X
  129. X    - Added 'return' (-r) switch to produce the return trip version
  130. X       of an input plan.
  131. X    - Ported to MessyDOS (tested with MSC and Zortech compilers).
  132. X      Reports from users of FPLAN 1.0 indicate that it ports fairly
  133. X      easily to other flavors of Unix.
  134. X    - Added a graphic previewer for Sunview.
  135. X    - Added DME fields to VOR fixes.
  136. X    - Slight change in output form.
  137. X    - Added database summary (-d) option (appends a description of each 
  138. X      airport and navaid used to the end of the flight plan).
  139. X    - Fixed a bug that sometimes printed negative headings.
  140. X    - Fixed a bug that prevented refueling at an enroute airport.
  141. X    - Added index (3) to the strings.c file. Can anyone suggest a
  142. X      way to portably handle the myriad different string(3) libraries
  143. X      without totaly redefining everything?
  144. X    - Changed a right recursive rule in grammar to left recursion - longer
  145. X      plans now supported.
  146. X    - Added documentation on the database file format for those without
  147. X      access to the NAV documentation or source.
  148. X    - Added a database formatter for creating private databases.
  149. X    - Incremental waypoints may now be specified as a distance to the
  150. X      _next_ turn point as well as from the _last_.
  151. X
  152. XEnjoy! Let me know what you think.
  153. X
  154. X=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  155. X    Virtue is its own punishment.
  156. X
  157. X    Steve Tynor
  158. X
  159. X    Yellow Jacket Flying Club
  160. X    and
  161. X    Georgia Tech Research Institute
  162. X    Artificial Intelligence Branch
  163. X    Georgia Institute of Technology
  164. X    tynor@prism.gatech.edu
  165. SHAR_EOF
  166. chmod 0444 NEW_FEATURES || echo "restore of NEW_FEATURES fails"
  167. echo "x - extracting EXAMPLE.fplan (Text)"
  168. sed 's/^X//' << 'SHAR_EOF' > EXAMPLE.fplan &&
  169. X# $Id: EXAMPLE.fplan,v 1.2 89/11/05 11:44:32 tynor Exp $
  170. X# This is an example FPLAN planfile. 
  171. X#
  172. X# It illustrates a simple flight from Chicago O'Hare to Champaign, IL
  173. X# via the DuPage VOR with a 5 knot wind from 320. True airspeed is set
  174. X# for 95 knots. VOR cross fixes from the Peotone VOR (EON) will be
  175. X# computed. Initial fuel is 24.5 gallons and fuel economy is set to 5.4
  176. X# gallons per hour.
  177. X#
  178. X# To generate a flight plan from this plan, type:
  179. X#     fplan EXAMPLE.fplan
  180. X# Since the default format is only 80 columns, the VOR-fix from EON is not
  181. X# show with the previous fplan invocation. If you have a wider terminal, or
  182. X# a wide printer, use the wide format to include the VOR-fix:
  183. X#     fplan -w EXAMPLE.fplan
  184. X
  185. Xnav(2) EON;
  186. Xfuel_amt  24.5;
  187. Xfuel_rate 5.4;
  188. Xtas 95;
  189. Xwind 230@5;
  190. Xfrom ORD;
  191. Xvia  DPA;
  192. Xto   CMI;
  193. X
  194. SHAR_EOF
  195. chmod 0444 EXAMPLE.fplan || echo "restore of EXAMPLE.fplan fails"
  196. echo "x - extracting WHERE_DBS (Text)"
  197. sed 's/^X//' << 'SHAR_EOF' > WHERE_DBS &&
  198. XThe complete NAV databases for the US can be found in several places
  199. Xvia anonymous FTP and/or UUCP.  You'll only need the airports.nav.*
  200. Xand vors.nav.* files to use FPLAN.
  201. X
  202. XThe following notes detail where and how:
  203. X
  204. X>From gatech!cwjcc!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!apple!geoff 
  205. X>Thu Sep 28 09:33:31 EDT 1989
  206. X>
  207. X>Berry Kercheval has kindly provided an additional archive site for the
  208. X>full US NAV database on mordor.s1.gov (26.3.0.95).  Berry will keep the
  209. X>data there for the indefinite future, and may at some point provide
  210. X>newer data.  The existing data will still remain on apple.com for a
  211. X>week or so and will then be deleted.
  212. X>
  213. X>I neglected to mention how to decompress the files once you receive them.
  214. X>You can either say "uncompress airports.nav.Z" and "uncompress vors.nav.Z"
  215. X>or, if you prefer to preserve the compressed versions, utter
  216. X>"zcat airports.nav.Z > airports.nav" and "zcat vors.nav.Z > vors.nav".
  217. X>
  218. X>To get the files from mordor rather than apple, do the following (well,
  219. X>approximately):
  220. X>
  221. X>    apple% ftp mordor.s1.gov
  222. X>    Connected to mordor.s1.gov.
  223. X>    220 mordor FTP server (Version 4.172 Fri Dec 9 10:09:46 PST 1988) ready.
  224. X>    Name (mordor.s1.gov:geoff): anonymous
  225. X>    331 Guest login ok, send ident as password.
  226. X>    Password:
  227. X>    230 Guest login ok, access restrictions apply.
  228. X>    ftp> binary
  229. X>    200 Type set to I.
  230. X>    ftp> get airports.nav.Z
  231. X>    200 PORT command successful.
  232. X>    150 Opening BINARY mode data connection for airports.nav.Z (413613 bytes).
  233. X>    226 Transfer complete.
  234. X>    local: airports.nav.Z remote: airports.nav.Z
  235. X>    413613 bytes received in 11 seconds (36 Kbytes/s)
  236. X>    ftp> get vors.nav.Z
  237. X>    200 PORT command successful.
  238. X>    150 Opening BINARY mode data connection for vors.nav.Z (338505 bytes).
  239. X>    226 Transfer complete.
  240. X>    local: vors.nav.Z remote: vors.nav.Z
  241. X>    338505 bytes received in 6.7 seconds (49 Kbytes/s)
  242. X>    ftp> quit
  243. X>    221 Goodbye.
  244. X
  245. X------------------------------------------------------------------------------
  246. X
  247. X>The complete release, database as well as sources, is also available
  248. X>for anonymous FTP on saqqara.cis.ohio-state.edu:pub/nav/* and for
  249. X>anonymous UUCP (1200, 2400, V.32, or TB+) on osu-cis!~/nav/*, in files
  250. X>named
  251. X>
  252. X>airports.nav.Z-part-a[abcde]   (sliced compressed text files)
  253. X>vors.nav.Z-part-a[abcd]                (sliced compressed text files)
  254. X>nav.{dbs,hdr,man}.shar.Z       (compressed shar archives)
  255. X>nav.top_level.shar.Z           (compressed shar archive)
  256. X>nav.src.shar-a[abcdef].Z       (compressed sliced shar archive)
  257. X>
  258. X>This will probably stay around for a while (at least a positive number
  259. X>of days :-), but there are no guarantees because I'm using the space
  260. X>there as a guest.  Because you won't be able to expand wildcards on
  261. X>osu-cis, you'll need to issue a command for each file you want to get,
  262. X>like
  263. X>
  264. X>       uucp osu-cis!~/nav/vors.nav.Z-part-aa
  265. X>       uucp osu-cis!~/nav/vors.nav.Z-part-ab
  266. X>       ... and so on ...
  267. X>
  268. X>Write to uucp@cis.ohio-state.edu (== osu-cis!uucp) for the generic
  269. X>anonymous-UUCP instructions if you need them.
  270. X
  271. X
  272. X
  273. SHAR_EOF
  274. chmod 0444 WHERE_DBS || echo "restore of WHERE_DBS fails"
  275. echo "x - extracting Makefile (Text)"
  276. sed 's/^X//' << 'SHAR_EOF' > Makefile &&
  277. X# $Id: Makefile,v 2.18 89/11/19 16:32:28 tynor Exp Locker: tynor $
  278. X#----------------------------------------------------------------------------
  279. X#    FPLAN - Flight Planner
  280. X#    Steve Tynor
  281. X#    tynor@prism.gatech.edu
  282. X#
  283. X#    This program is in the public domain. Permission to copy,
  284. X# distribute, modify this program is hearby given as long as this header
  285. X# remains. If you redistribute this program after modifying it, please
  286. X# document your changes so that I do not take the blame (or credit) for
  287. X# those changes.  If you fix bugs or add features, please send me a
  288. X# patch so that I can keep the 'official' version up-to-date.
  289. X#
  290. X#    Bug reports are welcome and I'll make an attempt to fix those
  291. X# that are reported.
  292. X#
  293. X#     USE AT YOUR OWN RISK! I assume no responsibility for any
  294. X# errors in this program, its database or documentation. I will make an
  295. X# effort to fix bugs, but if you crash and burn because, for example,
  296. X# fuel estimates in this program were inaccurate, it's your own fault
  297. X# for trusting somebody else's code! Remember, as PIC, it's _your_
  298. X# responsibility to do complete preflight planning. Use this program as
  299. X# a flight planning aid, but verify its results before using them.
  300. X# ---------------------------------------------------------------------------
  301. X
  302. X# ---------------------------------------------------------------------------
  303. X# EDIT THE FOLLOWING DEFINITIONS TO SUIT LOCAL CONDITIONS:
  304. X# ---------------------------------------------------------------------------
  305. X
  306. X# ---------------------------------------------------------------------------
  307. X# define which C compiler (if GNU, be sure to define as 'gcc -traditional')
  308. XCC = gcc -traditional
  309. X
  310. X# ---------------------------------------------------------------------------
  311. X# define where 'install' should put the man pages and executable:
  312. XBINDIR     = /usr/local/bin
  313. XMANDIR     = /usr/local/man
  314. X
  315. X# ---------------------------------------------------------------------------
  316. X# define the install command as 'install' on BSD Unix, otherwise just use 'cp'
  317. XINSTALL  = install
  318. X
  319. X# ---------------------------------------------------------------------------
  320. X# define which graphics subroutines you want to include (currently, Sunview 
  321. X# or nothing).  If you add X, NeWS, NeXT, EGA, etc. support - please mail me
  322. X# your code so I can distribute it!)
  323. X#GFX_OPTIONS = 
  324. XGFX_OPTIONS = -DGFX_SUNVIEW
  325. X
  326. X# ---------------------------------------------------------------------------
  327. X# define which graphics libraries are necessary for linking:
  328. X#GFX_LIBS =
  329. XGFX_LIBS = -lsuntool -lsunwindow -lpixrect
  330. X
  331. X# ---------------------------------------------------------------------------
  332. X# define any flags required for the C compiler:
  333. XCFLAGS   = -g $(GFX_OPTIONS)
  334. X
  335. X# ---------------------------------------------------------------------------
  336. X# command to format the man pages. Note: tbl is necessary for the fplan.1 man
  337. X# page when troffed (not necessary for nroff):
  338. XMAN_FORMAT= nroff
  339. X#MAN_FORMAT= tbl | troff -Tps
  340. X
  341. X# ---------------------------------------------------------------------------
  342. X# NO NEED TO EDIT BELOW HERE.
  343. X# ---------------------------------------------------------------------------
  344. X
  345. X# prevent certain makes (e.g. SunOS) from including wierd flags (like -sun386)
  346. X.c.o:
  347. X    $(CC) -c $(CFLAGS) $(CPPFLAGS) $*.c
  348. X
  349. XOBJS      = output.o main.o add.o misc.o db.o compute.o fp_yacc.o fp_lex.o \
  350. X        strings.o reverse.o sv_draw.o
  351. X
  352. XC_SRC     = output.c main.c add.c misc.c db.c compute.c paddb.c \
  353. X        strings.c reverse.c sv_draw.c wp_info.h mystring.h version.h
  354. X
  355. XOTHER_SRC = fp_lex.l fp_yacc.y
  356. X
  357. X# things required by the DOS version which are generated by Yacc/Lex:
  358. XDOS_SRC   = fp_lex.c fp_yacc.c fp_tok.h dosbuild.bat
  359. X
  360. XMAN      = fplan.1 fplan.5 paddb.1
  361. X
  362. XFORMATTED_MAN = fplan.man fplan_dbs.man paddb.man
  363. X
  364. XDOC       = README NEW_FEATURES EXAMPLE.fplan $(MAN) WHERE_DBS
  365. X
  366. XEXE      = fplan paddb
  367. X
  368. XDIST_FILES = $(DOC) Makefile $(C_SRC) $(OTHER_SRC) dosbuild.bat 
  369. X
  370. X# where I test the MessyDOS version:
  371. XDOSDIR   = /u/tynor/pc/src/fplan
  372. X
  373. Xall : $(EXE)
  374. Xdoc : $(FORMATTED_MAN)
  375. X
  376. Xpaddb.man : paddb.1
  377. X    cat paddb.1 | $(MAN_FORMAT) -man > paddb.man
  378. Xfplan.man : fplan.1
  379. X    cat fplan.1 | $(MAN_FORMAT) -man > fplan.man
  380. Xfplan_dbs.man : fplan.5
  381. X    cat fplan.5 | $(MAN_FORMAT) -man > fplan_dbs.man
  382. X
  383. Xpaddb : paddb.c
  384. X    $(CC) -o paddb paddb.c
  385. X
  386. Xfplan : $(OBJS)
  387. X    $(CC) -o fplan $(OBJS) $(GFX_LIBS) -lm
  388. X
  389. Xfp_lex.c : fp_lex.l fp_tok.h
  390. X    lex fp_lex.l
  391. X    mv lex.yy.c fp_lex.c
  392. X
  393. Xfp_yacc.c fp_tok.h : fp_yacc.y wp_info.h
  394. X    yacc -d fp_yacc.y
  395. X    mv y.tab.c fp_yacc.c
  396. X    mv y.tab.h fp_tok.h
  397. X
  398. X#------------
  399. Xfp_yacc.o     : fp_yacc.c
  400. Xfp_lex.o     : fp_lex.c
  401. Xadd.o         : add.c wp_info.h 
  402. Xcompute.o     : compute.c wp_info.h
  403. Xdb.o         : db.c wp_info.h mystring.h
  404. Xmain.o         : main.c wp_info.h version.h
  405. Xmisc.o         : misc.c 
  406. Xoutput.o     : output.c wp_info.h mystring.h
  407. Xstrings.o     : strings.c mystring.h
  408. Xreverse.o    : reverse.c wp_info.h
  409. Xsv_draw.o    : sv_draw.c wp_info.h
  410. X#------------
  411. X
  412. X# move the current files into the DOS test directory:
  413. Xdos : $(DOS_SRC)
  414. X    cp $(C_SRC) $(DOSDIR)
  415. X    cp $(DOS_SRC) $(DOSDIR)
  416. X    (cd $(DOSDIR); /u/tynor/bin/2dos $(C_SRC) $(DOS_SRC))
  417. X
  418. XTAGS : $(DIST_FILES)
  419. X    etags $(DIST_FILES)
  420. X
  421. Xclean : 
  422. X    -rm *.o *~ fp_tok.h fp_lex.c fp_yacc.c fplan paddb *.man fplan.0? fplan.tar.Z
  423. X
  424. Xdistribute :
  425. X    # all-in-one compressed tar file for FTP archive:
  426. X    tar cfo fplan.tar $(DIST_FILES)
  427. X    compress fplan.tar
  428. X    # many shar files for newsgroup distribution:
  429. X    cat README > fplan.01
  430. X    echo "" >> fplan.01
  431. X    echo "---- cut here ---- cut here ---- cut here ---- cut here ----" >> fplan.01
  432. X    echo "# This is part 1/6 of FPLAN" >> fplan.01
  433. X    shar2 -D -v README NEW_FEATURES EXAMPLE.fplan WHERE_DBS Makefile paddb.c >> fplan.01
  434. X    echo "#This is part 2/6 of FPLAN" > fplan.02
  435. X    shar2 -D -v fplan.1 fplan.5 paddb.1 >> fplan.02
  436. X    echo "#This is part 3/6 of FPLAN" > fplan.03
  437. X    shar2 -D -v add.c compute.c >> fplan.03
  438. X    echo "#This is part 4/6 of FPLAN" > fplan.04
  439. X    shar2 -D -v output.c >> fplan.04
  440. X    echo "#This is part 5/6 of FPLAN" > fplan.05
  441. X    shar2 -D -v main.c misc.c db.c strings.c >> fplan.05
  442. X    echo "#This is part 6/6 of FPLAN" > fplan.06
  443. X    shar2 -D -v fp_lex.l fp_yacc.y sv_draw.c dosbuild.bat mystring.h wp_info.h reverse.c version.h >> fplan.06
  444. X
  445. Xinstall :
  446. X    $(INSTALL) $(EXE) $(BINDIR)
  447. X    $(INSTALL) fplan.1 paddb.1 $(MANDIR)/man1
  448. X    $(INSTALL) fplan.5 $(MANDIR)/man5
  449. SHAR_EOF
  450. chmod 0644 Makefile || echo "restore of Makefile fails"
  451. echo "x - extracting paddb.c (Text)"
  452. sed 's/^X//' << 'SHAR_EOF' > paddb.c &&
  453. X/*
  454. X * $Id: paddb.c,v 1.1 89/11/11 17:29:43 tynor Exp $
  455. X *----------------------------------------------------------------------------
  456. X *    FPLAN - Flight Planner
  457. X *    Steve Tynor
  458. X *    tynor@prism.gatech.edu
  459. X *
  460. X *    This program is in the public domain. Permission to copy,
  461. X * distribute, modify this program is hearby given as long as this header
  462. X * remains. If you redistribute this program after modifying it, please
  463. X * document your changes so that I do not take the blame (or credit) for
  464. X * those changes.  If you fix bugs or add features, please send me a
  465. X * patch so that I can keep the 'official' version up-to-date.
  466. X *
  467. X *    Bug reports are welcome and I'll make an attempt to fix those
  468. X * that are reported.
  469. X *
  470. X *    USE AT YOUR OWN RISK! I assume no responsibility for any
  471. X * errors in this program, its database or documentation. I will make an
  472. X * effort to fix bugs, but if you crash and burn because, for example,
  473. X * fuel estimates in this program were inaccurate, it's your own fault
  474. X * for trusting somebody else's code! Remember, as PIC, it's _your_
  475. X * responsibility to do complete preflight planning. Use this program as
  476. X * a flight planning aid, but verify its results before using them.
  477. X *----------------------------------------------------------------------------
  478. X */
  479. X
  480. Xstatic char rcsid[] = "$Id: paddb.c,v 1.1 89/11/11 17:29:43 tynor Exp $";
  481. X
  482. X#include <stdio.h>
  483. X#include "version.h"
  484. X
  485. X#define EXIT_GOOD 0
  486. X#define EXIT_BAD  1
  487. X
  488. X#define MAX(a,b) ((a)>=(b)?(a):(b))
  489. X
  490. X/*----------------------------------------------------------------------------*/
  491. Xusage (progname)
  492. X     char *progname;
  493. X{
  494. X   fprintf (stderr, "FPLAN %s\n", VERSION);
  495. X   fprintf (stderr, "usage: %s text-file db-file\n", progname);
  496. X   exit (EXIT_BAD);
  497. X}
  498. X
  499. X/*----------------------------------------------------------------------------*/
  500. Xint main (argc, argv)
  501. X     int argc;
  502. X     char *argv[];
  503. X{
  504. X#define BUFSIZE 200
  505. X   FILE *in, *out;
  506. X   int recl = 0;
  507. X   int len, i;
  508. X   char buffer[BUFSIZE];
  509. X
  510. X#ifdef MSDOS
  511. X#define CREATE_MODE "wb"
  512. X#define LINE_TERMINATOR_LEN 2    /* CR-LF */
  513. X#else
  514. X#define CREATE_MODE "w"
  515. X#define LINE_TERMINATOR_LEN 1    /* LF */
  516. X#endif
  517. X
  518. X   if (argc != 3)
  519. X      usage (argv[0]);
  520. X
  521. X   if (! (in = fopen (argv[1], "r"))) {
  522. X      fprintf (stderr, "ERROR: opening input file: %s\n", argv[1]);
  523. X      usage (argv[0]);
  524. X   }
  525. X
  526. X   if (! (out = fopen (argv[2], CREATE_MODE))) {
  527. X      fprintf (stderr, "ERROR: opening output file: %s\n", argv[2]);
  528. X      usage (argv[0]);
  529. X   }
  530. X
  531. X   /*
  532. X    * first pass: find the max record length
  533. X    */
  534. X   while (fgets (buffer, BUFSIZE, in))
  535. X      recl = MAX (recl, strlen (buffer) - LINE_TERMINATOR_LEN);
  536. X
  537. X   fclose (in);
  538. X
  539. X   /*
  540. X    * second pass: copy each record to the output; pad each record
  541. X    */
  542. X
  543. X   if (! (in = fopen (argv[1], "r"))) {
  544. X      fprintf (stderr, "ERROR: opening input file: %s\n", argv[1]);
  545. X      usage (argv[0]);
  546. X   }
  547. X   while (fgets (buffer, BUFSIZE, in)) {
  548. X      len = strlen (buffer) - LINE_TERMINATOR_LEN;
  549. X      buffer[len] = '\0';
  550. X      fprintf (out, "%s", buffer);
  551. X      for (i = len; i < recl; i++)
  552. X     putc ('\0', out);
  553. X      putc ('\n', out);
  554. X   }
  555. X   fclose (in);
  556. X   fclose (out);
  557. X}
  558. X
  559. SHAR_EOF
  560. chmod 0444 paddb.c || echo "restore of paddb.c fails"
  561. exit 0
  562.  
  563.