Compare commits
115 Commits
RELEASE_0_
...
RELEASE_0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c35255549 | ||
|
|
c985d8846d | ||
|
|
9a8ab26381 | ||
|
|
711622fd5b | ||
|
|
96474823b5 | ||
|
|
bbf4b54613 | ||
|
|
9795c5dd6b | ||
|
|
addcace80d | ||
|
|
77e43a5fa8 | ||
|
|
b751188e56 | ||
|
|
1ad9a15864 | ||
|
|
d0d7878e0a | ||
|
|
be5d365348 | ||
|
|
a8e0002a64 | ||
|
|
bf75cf7225 | ||
|
|
c024b680bc | ||
|
|
c896475765 | ||
|
|
101fdb3598 | ||
|
|
b13505afdf | ||
|
|
9d96b171a0 | ||
|
|
8b5a0cde69 | ||
|
|
bed7593cdd | ||
|
|
9fed946567 | ||
|
|
4d0bc0ae39 | ||
|
|
f9824aa7de | ||
|
|
4d2522964a | ||
|
|
dbe4a59b8e | ||
|
|
918f8a3ed4 | ||
|
|
f645596606 | ||
|
|
d778dd081d | ||
|
|
f6ed02c3fb | ||
|
|
7fa5dd7a35 | ||
|
|
a3186af099 | ||
|
|
a2d95ac742 | ||
|
|
10715bbea7 | ||
|
|
89fcb12556 | ||
|
|
cc3d7ddee5 | ||
|
|
cc01f99acb | ||
|
|
62b75190bb | ||
|
|
520124c1be | ||
|
|
e251bfcbaf | ||
|
|
aef809348f | ||
|
|
2d4a8774b8 | ||
|
|
b55c8fd828 | ||
|
|
dfff091b5f | ||
|
|
47eb7efafa | ||
|
|
b2a7fff26e | ||
|
|
5f70123723 | ||
|
|
dd629da8d3 | ||
|
|
74f7d52d95 | ||
|
|
7a65a990ba | ||
|
|
fe0076e291 | ||
|
|
1a8bc06cc6 | ||
|
|
8c41081a5c | ||
|
|
5b40eed554 | ||
|
|
b1c4d34eef | ||
|
|
0152b607f8 | ||
|
|
ab6e72047b | ||
|
|
15399bfe95 | ||
|
|
0ff748987b | ||
|
|
58e0e7736b | ||
|
|
2d1b2ca938 | ||
|
|
9a4152eb2d | ||
|
|
6ab443545f | ||
|
|
98a9b4a10c | ||
|
|
a6251606dd | ||
|
|
c3b21e143c | ||
|
|
b496593883 | ||
|
|
4ef4b019ca | ||
|
|
a8021531ab | ||
|
|
93fd948978 | ||
|
|
a1b3740dc6 | ||
|
|
40920457cb | ||
|
|
5039c84fd0 | ||
|
|
220a43bf46 | ||
|
|
45d3e19c38 | ||
|
|
5bab565cfe | ||
|
|
319a4282c8 | ||
|
|
c6aa8bc8e9 | ||
|
|
6f1bfa202e | ||
|
|
6fa9f86d1c | ||
|
|
019a9527d2 | ||
|
|
d100ca485f | ||
|
|
35ab6900ee | ||
|
|
c8570302f5 | ||
|
|
74f10486bc | ||
|
|
2b12425a62 | ||
|
|
c600aad7a7 | ||
|
|
67b2f0a977 | ||
|
|
70c6b48a07 | ||
|
|
76084f8538 | ||
|
|
64c408d2b7 | ||
|
|
73b050ae34 | ||
|
|
59991393ca | ||
|
|
69b2717b62 | ||
|
|
f2a323e048 | ||
|
|
7d07e6ea51 | ||
|
|
7c846972bf | ||
|
|
4f76c258af | ||
|
|
eca2afb982 | ||
|
|
9ff6934c83 | ||
|
|
e04839765d | ||
|
|
d0c655109f | ||
|
|
b28b55abb1 | ||
|
|
c3a0db1aba | ||
|
|
5e929d7d01 | ||
|
|
17f113f8cd | ||
|
|
445cd4ccda | ||
|
|
55845bbbb9 | ||
|
|
1976481ba2 | ||
|
|
5f17edbc72 | ||
|
|
6f7fe4b481 | ||
|
|
66ebe6e690 | ||
|
|
a9cd67e0ce | ||
|
|
994a470fbf |
8
.cvsignore
Normal file
8
.cvsignore
Normal file
@@ -0,0 +1,8 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
SimGear.spec
|
||||
aclocal.m4
|
||||
config.cache
|
||||
config.log
|
||||
config.status
|
||||
configure
|
||||
2
Doxyfile
2
Doxyfile
@@ -22,7 +22,7 @@ PROJECT_NAME = SimGear
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = 0.0.16
|
||||
PROJECT_NUMBER = 0.0.17
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
|
||||
107
Makefile.am
107
Makefile.am
@@ -1,104 +1,17 @@
|
||||
EXTRA_DIST = mksymlinks.sh acsite.m4 acconfig.h SimGear.dsp SimGear.dsw
|
||||
EXTRA_DIST = \
|
||||
acsite.m4 \
|
||||
acconfig.h \
|
||||
mksymlinks.sh \
|
||||
README.metakit \
|
||||
README.zlib \
|
||||
SimGear.dsp \
|
||||
SimGear.dsw
|
||||
|
||||
SUBDIRS = simgear
|
||||
|
||||
#
|
||||
# Additional all, clean, and distclean rules for additional packages.
|
||||
# We can't just include the additional package dirs in SUBDIRS (which
|
||||
# would be nice because there are then problems with make dist
|
||||
#
|
||||
|
||||
all:
|
||||
@list='@subdirs@'; \
|
||||
target=`echo $@`; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done
|
||||
|
||||
install:
|
||||
@list='@subdirs@'; \
|
||||
target=`echo $@`; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done
|
||||
|
||||
clean:
|
||||
@list='@subdirs@'; \
|
||||
target=`echo $@`; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done
|
||||
|
||||
distclean:
|
||||
@list='@subdirs@'; \
|
||||
target=`echo $@`; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
|
||||
done
|
||||
|
||||
#
|
||||
# distclean the associated packages and include them in the dist
|
||||
#
|
||||
|
||||
dist-hook:
|
||||
(cd $(top_srcdir); \
|
||||
$(HOME)/projects/FlightGear-0.7/admin/am2dsp.pl --lib)
|
||||
pwd
|
||||
echo "copying simgear/metar"
|
||||
echo "other stuff"
|
||||
@list='@subdirs@'; \
|
||||
target=distclean; \
|
||||
for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| case "$$amf" in *=*) echo "distclean error ignored...";; *k*) fail=yes;; *) echo "distclean error ignored...";; esac; \
|
||||
done
|
||||
(cd $(top_srcdir); tar cf - simgear/metakit) | \
|
||||
(cd $(distdir); tar xvf -)
|
||||
|
||||
SUBDIRS = src-libs simgear
|
||||
|
||||
#
|
||||
# Rule to build RPM distribution package
|
||||
#
|
||||
rpm: dist
|
||||
cp $(PACKAGE)-$(VERSION).tar.gz /usr/src/packages/SOURCES
|
||||
rpm -ba @PACKAGE@.spec
|
||||
rpm -ta $(PACKAGE)-$(VERSION).tar.gz
|
||||
|
||||
|
||||
70
NEWS
70
NEWS
@@ -1,3 +1,63 @@
|
||||
New in 0.0.18
|
||||
* April 20, 2002
|
||||
|
||||
* Created a src/libs subdirectory for several packages that need to be
|
||||
installed by the user but are used by many other packages and may already
|
||||
be installed. So we just bundle the source separately as a convenience
|
||||
if the user needs to build and install these.
|
||||
* Upgrade to zlib-1.1.4 (security fix)
|
||||
* Upgrade to metakit-2.4.2-32.tar.gz (latest upstream release)
|
||||
* Added support for point objects in the scenery file format.
|
||||
* Additions to the binary file format to make it *much* more flexible.
|
||||
For each major primative type: points, triangles, fans, and strips, you
|
||||
can specify an index list of vertices, normals, colors, and texture
|
||||
coordinates. You can skip any of these you like to save on space.
|
||||
* Added support for new file features in the binary -> ascii scenery file
|
||||
decoder.
|
||||
* Various code clean ups.
|
||||
* Separate XML I/O operations into a separate header file.
|
||||
* Major property manager rewrite, then lots of followup cleaning and
|
||||
improvements.
|
||||
|
||||
|
||||
New in 0.0.17 (final)
|
||||
* February 16, 2002
|
||||
|
||||
* Explicitely reset the glBlendFunc() after drawing the moon for the
|
||||
Voodoo2 linux driver since it seems to have a bug in glPopAttrib().
|
||||
|
||||
|
||||
New in 0.0.17pre2
|
||||
* February 13, 2002
|
||||
|
||||
* Replaced some cout's with SG_LOG's
|
||||
|
||||
|
||||
New in 0.0.17pre1
|
||||
* February 12, 2002
|
||||
|
||||
* Removed metakit and zlib from build process. Tarballs are still included
|
||||
for those who's systems don't provide these packages.
|
||||
* MSVC fixes.
|
||||
* IRIX fixes.
|
||||
* Mingwin fixes.
|
||||
* Mac OS X fixes.
|
||||
* FreeBSD fixes.
|
||||
* Added support for Intel's C++ compiler under Linux.
|
||||
* Attempt to build in support for various non-compatible automake/autoconf
|
||||
versions.
|
||||
* Fix for a problem that could lead to a bogus build for people with voodoo
|
||||
cards.
|
||||
* Added Norman's jpegfactory code which can create jpeg format screen shots
|
||||
of a live running application.
|
||||
* implemented set/get_log_classes and set/get_log_priority.
|
||||
* Socket library improvements.
|
||||
* Added a C++ exception abstraction.
|
||||
* Property manager fixes and improvements including node path caching
|
||||
and debug tracing of property reads/writes.
|
||||
* Updates/fixes to xml handling.
|
||||
|
||||
|
||||
New in 0.0.16
|
||||
* July 12, 2001
|
||||
* Various changes to the property manager implimentation to better support
|
||||
@@ -22,6 +82,7 @@ New in 0.0.16
|
||||
ultra-hires tiled screen dumps suitable for large format printers.
|
||||
(Norman Vine)
|
||||
|
||||
|
||||
New in 0.0.15
|
||||
* June 20, 2001
|
||||
* Various bug fixes, tweaks, and optimizations.
|
||||
@@ -50,6 +111,7 @@ New in 0.0.15
|
||||
* Fixed some critical null pointer bugs in property manager.
|
||||
* Magnetic variation can now be fetched for any arbitrary location.
|
||||
|
||||
|
||||
New in 0.0.14
|
||||
* December 14, 2000
|
||||
* Added a module to manage waypoints and routes, calculate bearing and
|
||||
@@ -71,6 +133,7 @@ New in 0.0.14
|
||||
* MacOS tweaks.
|
||||
* FreeBSD tweaks.
|
||||
|
||||
|
||||
New in 0.0.13
|
||||
* September 14, 2000
|
||||
* Added support for reading and writing xml files (easyxml)
|
||||
@@ -81,6 +144,7 @@ New in 0.0.13
|
||||
* MacOS tweaks.
|
||||
* MSVC tweaks.
|
||||
|
||||
|
||||
New in 0.0.12
|
||||
* July 19, 2000
|
||||
* Converted project license from GPL to LGPL.
|
||||
@@ -90,6 +154,7 @@ New in 0.0.12
|
||||
* Added a property manager (registry)
|
||||
* Some documentation added.
|
||||
|
||||
|
||||
New in 0.0.11
|
||||
* July 3, 2000
|
||||
* Replaced gdbm with metakit
|
||||
@@ -98,6 +163,7 @@ New in 0.0.11
|
||||
* MSVC5 fixes
|
||||
* Math/bucket/tiling tweaks from Norman Vine
|
||||
|
||||
|
||||
New in 0.0.7
|
||||
* March 29, 2000
|
||||
* Added support for RedHat package building contributed by Habibie
|
||||
@@ -110,18 +176,22 @@ New in 0.0.7
|
||||
* Optimizations and bullet proofing of magnetic variation code by Norman
|
||||
Vine and Ed Williams
|
||||
|
||||
|
||||
New in 0.0.6
|
||||
* March 27, 2000
|
||||
* Added Nima World Magnetic Model 2000 contributed by Ed Williams
|
||||
* Fixes for MSVC++
|
||||
|
||||
|
||||
New in 0.0.5
|
||||
* March 17, 2000
|
||||
* Restructured directory layout to facilitate windows/mac IDE builds.
|
||||
|
||||
|
||||
New in 0.0.4
|
||||
* Removed mat3.h and friends (we now use plib's sg lib for these sorts of
|
||||
things.)
|
||||
|
||||
|
||||
New in 0.0.3
|
||||
* Release that conincides with FlightGear-0.7.2
|
||||
|
||||
4
README
4
README
@@ -1,3 +1 @@
|
||||
MSVC5 users:
|
||||
|
||||
Copy simgear/config.h.vc5 to simgear/config.h before building.
|
||||
[ Nothing here at this time. ]
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
With the author's permission, SimGear now bundles MetaKit.
|
||||
For your convenience (and with the author's permission) a copy of the
|
||||
MetaKit source is bundled with SimGear in $(top_srcdir)/src-libs/.
|
||||
You must have metakit installed before you can build SimGear.
|
||||
|
||||
Important build note:
|
||||
- Most linux distributions have a metakit package. For linux
|
||||
developers, we recommend ysou install your distributions package
|
||||
rather than building from source.
|
||||
|
||||
- For developers on most other platforms, you will have to build
|
||||
metakit from source and install it yourself. For your convenience a
|
||||
tar ball of the metakit source is included with the simgear source
|
||||
distribution. Untar the metakit source, and follow the included
|
||||
build and installation instructions.
|
||||
|
||||
Once metakit is installed you can return to configuring and building
|
||||
Simgear.
|
||||
|
||||
=============================================================================
|
||||
|
||||
Potentially important build note:
|
||||
|
||||
Later on when you are linking programs with -lmk4 (i.e. FlightGear or one
|
||||
of it's associated programs) if you come across an error similar to the
|
||||
|
||||
173
README.zlib
Normal file
173
README.zlib
Normal file
@@ -0,0 +1,173 @@
|
||||
For your convenience and allowed by zlib's license terms:
|
||||
http://www.gzip.org/zlib/zlib_license.html a copy of the zlib source
|
||||
is bundled with SimGear in $(top_srcdir)/src-libs/. You must have
|
||||
zlib installed before you can build SimGear.
|
||||
|
||||
- Most linux distributions have a zlib package. For linux
|
||||
developers, we recommend ysou install your distributions package
|
||||
rather than building from source.
|
||||
|
||||
- Cygwin installs zlib automatically.
|
||||
|
||||
- For developers on most other platforms, you will have to build
|
||||
zlib from source and install it yourself. For your convenience a
|
||||
tar ball of the zlib source is included with the simgear source
|
||||
distribution. Untar the zlib source, and follow the included
|
||||
build and installation instructions.
|
||||
|
||||
Once zlib is installed you can return to configuring and building
|
||||
Simgear.
|
||||
|
||||
We now send you to the official zlib README ...
|
||||
|
||||
|
||||
=============================================================================
|
||||
|
||||
|
||||
zlib 1.1.4 is a general purpose data compression library. All the code
|
||||
is thread safe. The data format used by the zlib library
|
||||
is described by RFCs (Request for Comments) 1950 to 1952 in the files
|
||||
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate
|
||||
format) and rfc1952.txt (gzip format). These documents are also available in
|
||||
other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
||||
|
||||
All functions of the compression library are documented in the file zlib.h
|
||||
(volunteer to write man pages welcome, contact jloup@gzip.org). A usage
|
||||
example of the library is given in the file example.c which also tests that
|
||||
the library is working correctly. Another example is given in the file
|
||||
minigzip.c. The compression library itself is composed of all source files
|
||||
except example.c and minigzip.c.
|
||||
|
||||
To compile all files and run the test program, follow the instructions
|
||||
given at the top of Makefile. In short "make test; make install"
|
||||
should work for most machines. For Unix: "./configure; make test; make install"
|
||||
For MSDOS, use one of the special makefiles such as Makefile.msc.
|
||||
For VMS, use Make_vms.com or descrip.mms.
|
||||
|
||||
Questions about zlib should be sent to <zlib@gzip.org>, or to
|
||||
Gilles Vollant <info@winimage.com> for the Windows DLL version.
|
||||
The zlib home page is http://www.zlib.org or http://www.gzip.org/zlib/
|
||||
Before reporting a problem, please check this site to verify that
|
||||
you have the latest version of zlib; otherwise get the latest version and
|
||||
check whether the problem still exists or not.
|
||||
|
||||
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html
|
||||
before asking for help.
|
||||
|
||||
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available in
|
||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
||||
|
||||
The changes made in version 1.1.4 are documented in the file ChangeLog.
|
||||
The only changes made since 1.1.3 are bug corrections:
|
||||
|
||||
- ZFREE was repeated on same allocation on some error conditions.
|
||||
This creates a security problem described in
|
||||
http://www.zlib.org/advisory-2002-03-11.txt
|
||||
- Returned incorrect error (Z_MEM_ERROR) on some invalid data
|
||||
- Avoid accesses before window for invalid distances with inflate window
|
||||
less than 32K.
|
||||
- force windowBits > 8 to avoid a bug in the encoder for a window size
|
||||
of 256 bytes. (A complete fix will be available in 1.1.5).
|
||||
|
||||
The beta version 1.1.5beta includes many more changes. A new official
|
||||
version 1.1.5 will be released as soon as extensive testing has been
|
||||
completed on it.
|
||||
|
||||
|
||||
Unsupported third party contributions are provided in directory "contrib".
|
||||
|
||||
A Java implementation of zlib is available in the Java Development Kit
|
||||
http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
|
||||
See the zlib home page http://www.zlib.org for details.
|
||||
|
||||
A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk>
|
||||
is in the CPAN (Comprehensive Perl Archive Network) sites
|
||||
http://www.cpan.org/modules/by-module/Compress/
|
||||
|
||||
A Python interface to zlib written by A.M. Kuchling <amk@magnet.com>
|
||||
is available in Python 1.5 and later versions, see
|
||||
http://www.python.org/doc/lib/module-zlib.html
|
||||
|
||||
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com>
|
||||
is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html
|
||||
|
||||
An experimental package to read and write files in .zip format,
|
||||
written on top of zlib by Gilles Vollant <info@winimage.com>, is
|
||||
available at http://www.winimage.com/zLibDll/unzip.html
|
||||
and also in the contrib/minizip directory of zlib.
|
||||
|
||||
|
||||
Notes for some targets:
|
||||
|
||||
- To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc
|
||||
and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL
|
||||
The zlib DLL support was initially done by Alessandro Iacopetti and is
|
||||
now maintained by Gilles Vollant <info@winimage.com>. Check the zlib DLL
|
||||
home page at http://www.winimage.com/zLibDll
|
||||
|
||||
From Visual Basic, you can call the DLL functions which do not take
|
||||
a structure as argument: compress, uncompress and all gz* functions.
|
||||
See contrib/visual-basic.txt for more information, or get
|
||||
http://www.tcfb.com/dowseware/cmp-z-it.zip
|
||||
|
||||
- For 64-bit Irix, deflate.c must be compiled without any optimization.
|
||||
With -O, one libpng test fails. The test works in 32 bit mode (with
|
||||
the -n32 compiler flag). The compiler bug has been reported to SGI.
|
||||
|
||||
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1
|
||||
it works when compiled with cc.
|
||||
|
||||
- on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1
|
||||
is necessary to get gzprintf working correctly. This is done by configure.
|
||||
|
||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works
|
||||
with other compilers. Use "make test" to check your compiler.
|
||||
|
||||
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
|
||||
|
||||
- For Turbo C the small model is supported only with reduced performance to
|
||||
avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3
|
||||
|
||||
- For PalmOs, see http://www.cs.uit.no/~perm/PASTA/pilot/software.html
|
||||
Per Harald Myrvang <perm@stud.cs.uit.no>
|
||||
|
||||
|
||||
Acknowledgments:
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz. The deflate
|
||||
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||
people who reported problems and suggested various improvements in zlib;
|
||||
they are too numerous to cite here.
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2002 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
jloup@gzip.org madler@alumni.caltech.edu
|
||||
|
||||
If you use the zlib library in a product, we would appreciate *not*
|
||||
receiving lengthy legal documents to sign. The sources are provided
|
||||
for free but without warranty of any kind. The library has been
|
||||
entirely written by Jean-loup Gailly and Mark Adler; it does not
|
||||
include third-party code.
|
||||
|
||||
If you redistribute modified sources, we would appreciate that you include
|
||||
in the file ChangeLog history information documenting your changes.
|
||||
47
SimGear.dsp
47
SimGear.dsp
@@ -41,7 +41,7 @@ RSC=rc.exe
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "." /I ".." /I ".\SimGear" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "HAVE_CONFIG_H" /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "HAVE_CONFIG_H" /I "." /I ".." /I ".\SimGear" /D "HAVE_CONFIG_H" /D "NDEBUG" /D "WIN32" /D "_MBCS" /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -64,7 +64,7 @@ LINK32=link.exe -lib
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /GX /ZI /Od /I "." /I ".." /I ".\SimGear" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "HAVE_CONFIG_H" /FR /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /GX /ZI /Od /D "HAVE_CONFIG_H" /I "." /I ".." /I ".\SimGear" /D "HAVE_CONFIG_H" /D "_DEBUG" /D "WIN32" /D "_MBCS" /FR /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
@@ -773,6 +773,21 @@ SOURCE=.\simgear\misc\commands.cxx
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\misc\exception.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
|
||||
# PROP Intermediate_Dir "Release\Lib_sgmisc"
|
||||
|
||||
!ELSEIF "$(CFG)" == "SimGear - Win32 Debug"
|
||||
|
||||
# PROP Intermediate_Dir "Debug\Lib_sgmisc"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\simgear\misc\props.cxx
|
||||
|
||||
!IF "$(CFG)" == "SimGear - Win32 Release"
|
||||
@@ -1824,5 +1839,33 @@ SOURCE=.\simgear\zlib\zutil.h
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
|
||||
# Begin Source File
|
||||
|
||||
SOURCE = .\simgear\simgear_config.h.vc5
|
||||
|
||||
!IF "$(CFG)" == "FlightGear - Win32 Release"
|
||||
|
||||
# Begin Custom Build - Creating config.h
|
||||
InputPath=.\simgear\simgear_config.h.vc5
|
||||
|
||||
".\simgear\simgear_config.h": $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
copy .\simgear\simgear_config.h.vc5 .\simgear\simgear_config.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
|
||||
|
||||
# Begin Custom Build - Creating config.h
|
||||
InputPath=.\simgear\simgear_config.h.vc5
|
||||
|
||||
".\simgear\simgear_config.h": $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
copy .\simgear\simgear_config.h.vc5 .\simgear\simgear_config.h
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
|
||||
@@ -184,12 +184,6 @@
|
||||
/* Define if you have the wait3 system call. */
|
||||
#undef HAVE_WAIT3
|
||||
|
||||
/* Define if you have gdbm installed system wide. */
|
||||
/* #undef HAVE_GDBM */
|
||||
|
||||
/* Define if you have zlib installed system wide. */
|
||||
#undef HAVE_ZLIB
|
||||
|
||||
/* Define as __inline if that's what the C compiler calls it. */
|
||||
#undef inline
|
||||
|
||||
|
||||
140
aclocal.m4
vendored
140
aclocal.m4
vendored
@@ -1,140 +0,0 @@
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.4
|
||||
|
||||
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl This program is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
dnl PARTICULAR PURPOSE.
|
||||
|
||||
# Do all the work for Automake. This macro actually does too much --
|
||||
# some checks are only needed if your package does certain things.
|
||||
# But this isn't really a big deal.
|
||||
|
||||
# serial 1
|
||||
|
||||
dnl Usage:
|
||||
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
|
||||
|
||||
AC_DEFUN(AM_INIT_AUTOMAKE,
|
||||
[AC_REQUIRE([AC_PROG_INSTALL])
|
||||
PACKAGE=[$1]
|
||||
AC_SUBST(PACKAGE)
|
||||
VERSION=[$2]
|
||||
AC_SUBST(VERSION)
|
||||
dnl test to see if srcdir already configured
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
ifelse([$3],,
|
||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
|
||||
AC_REQUIRE([AM_SANITY_CHECK])
|
||||
AC_REQUIRE([AC_ARG_PROGRAM])
|
||||
dnl FIXME This is truly gross.
|
||||
missing_dir=`cd $ac_aux_dir && pwd`
|
||||
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])])
|
||||
|
||||
#
|
||||
# Check to make sure that the build environment is sane.
|
||||
#
|
||||
|
||||
AC_DEFUN(AM_SANITY_CHECK,
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftestfile
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
|
||||
if test "[$]*" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftestfile`
|
||||
fi
|
||||
if test "[$]*" != "X $srcdir/configure conftestfile" \
|
||||
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
|
||||
|
||||
# If neither matched, then we have a broken ls. This can happen
|
||||
# if, for instance, CONFIG_SHELL is bash and it inherits a
|
||||
# broken ls alias from the environment. This has actually
|
||||
# happened. Such a system could not be considered "sane".
|
||||
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
|
||||
alias in your environment])
|
||||
fi
|
||||
|
||||
test "[$]2" = conftestfile
|
||||
)
|
||||
then
|
||||
# Ok.
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||
Check your system clock])
|
||||
fi
|
||||
rm -f conftest*
|
||||
AC_MSG_RESULT(yes)])
|
||||
|
||||
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
|
||||
dnl The program must properly implement --version.
|
||||
AC_DEFUN(AM_MISSING_PROG,
|
||||
[AC_MSG_CHECKING(for working $2)
|
||||
# Run test in a subshell; some versions of sh will print an error if
|
||||
# an executable is not found, even if stderr is redirected.
|
||||
# Redirect stdin to placate older versions of autoconf. Sigh.
|
||||
if ($2 --version) < /dev/null > /dev/null 2>&1; then
|
||||
$1=$2
|
||||
AC_MSG_RESULT(found)
|
||||
else
|
||||
$1="$3/missing $2"
|
||||
AC_MSG_RESULT(missing)
|
||||
fi
|
||||
AC_SUBST($1)])
|
||||
|
||||
# Define a conditional.
|
||||
|
||||
AC_DEFUN(AM_CONDITIONAL,
|
||||
[AC_SUBST($1_TRUE)
|
||||
AC_SUBST($1_FALSE)
|
||||
if $2; then
|
||||
$1_TRUE=
|
||||
$1_FALSE='#'
|
||||
else
|
||||
$1_TRUE='#'
|
||||
$1_FALSE=
|
||||
fi])
|
||||
|
||||
# Like AC_CONFIG_HEADER, but automatically create stamp file.
|
||||
|
||||
AC_DEFUN(AM_CONFIG_HEADER,
|
||||
[AC_PREREQ([2.12])
|
||||
AC_CONFIG_HEADER([$1])
|
||||
dnl When config.status generates a header, we must update the stamp-h file.
|
||||
dnl This file resides in the same directory as the config header
|
||||
dnl that is generated. We must strip everything past the first ":",
|
||||
dnl and everything past the last "/".
|
||||
AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
|
||||
ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
|
||||
<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
|
||||
<<am_indx=1
|
||||
for am_file in <<$1>>; do
|
||||
case " <<$>>CONFIG_HEADERS " in
|
||||
*" <<$>>am_file "*<<)>>
|
||||
echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
|
||||
;;
|
||||
esac
|
||||
am_indx=`expr "<<$>>am_indx" + 1`
|
||||
done<<>>dnl>>)
|
||||
changequote([,]))])
|
||||
|
||||
35
am2dsp.cfg
35
am2dsp.cfg
@@ -1,5 +1,40 @@
|
||||
exclude_dir = threads
|
||||
|
||||
include_path = .
|
||||
include_path = ..
|
||||
include_path = .\SimGear
|
||||
#include_path = \usr\include
|
||||
|
||||
define = HAVE_CONFIG_H
|
||||
|
||||
#add_project = .\SimGear\simgear\metakit\win\msvc60\mklib.dsp
|
||||
|
||||
# Rule to create simgear_config.h
|
||||
add_source_file = \
|
||||
# Begin Source File\
|
||||
\
|
||||
SOURCE = .\simgear\simgear_config.h.vc5\
|
||||
\
|
||||
!IF "$(CFG)" == "FlightGear - Win32 Release"\
|
||||
\
|
||||
# Begin Custom Build - Creating config.h\
|
||||
InputPath=.\simgear\simgear_config.h.vc5\
|
||||
\
|
||||
".\simgear\simgear_config.h": $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\
|
||||
copy .\simgear\simgear_config.h.vc5 .\simgear\simgear_config.h\
|
||||
\
|
||||
# End Custom Build\
|
||||
\
|
||||
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"\
|
||||
\
|
||||
# Begin Custom Build - Creating config.h\
|
||||
InputPath=.\simgear\simgear_config.h.vc5\
|
||||
\
|
||||
".\simgear\simgear_config.h": $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\
|
||||
copy .\simgear\simgear_config.h.vc5 .\simgear\simgear_config.h\
|
||||
\
|
||||
# End Custom Build\
|
||||
\
|
||||
!ENDIF\
|
||||
\
|
||||
# End Source File
|
||||
|
||||
57
autogen.sh
Executable file
57
autogen.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
OSTYPE=`uname -s`
|
||||
MACHINE=`uname -m`
|
||||
AUTO_MAKE_VERSION=`automake --version | head -1 | awk '{print $4}' | sed -e 's/\-p[0-9]$//' | sed -e 's/\.//'`
|
||||
|
||||
echo "Host info: $OSTYPE $MACHINE"
|
||||
echo -n " automake: `automake --version | head -1 | awk '{print $4}'`"
|
||||
echo " ($AUTO_MAKE_VERSION)"
|
||||
echo ""
|
||||
|
||||
ACLOCAL_OPTS=""
|
||||
if [ $AUTO_MAKE_VERSION -ge 14 ]; then
|
||||
if [ $OSTYPE = "IRIX" -o $OSTYPE = "IRIX64" ]; then echo " -I ."
|
||||
ACLOCAL_OPTS="-I ."
|
||||
fi
|
||||
fi
|
||||
echo "Running aclocal $ACLOCAL_OPTS"
|
||||
aclocal $ACLOCAL_OPTS
|
||||
|
||||
echo "Running autoheader"
|
||||
autoheader
|
||||
|
||||
echo -n "Running automake"
|
||||
if [ $OSTYPE = "IRIX" -o $OSTYPE = "IRIX64" ]; then
|
||||
echo " --add-missing --include-deps"
|
||||
automake --add-missing --include-deps
|
||||
else
|
||||
echo " --add-missing"
|
||||
automake --add-missing
|
||||
fi
|
||||
|
||||
echo "Running autoconf"
|
||||
autoconf
|
||||
|
||||
# fixup Makefiles for Irix
|
||||
if test "$OSTYPE" = "IRIX" -o "$OSTYPE" = "IRIX64"; then
|
||||
echo "Fixing Makefiles for Irix"
|
||||
for n in `find . -name Makefile.in`; do \
|
||||
mv -f $n $n.ar-new; \
|
||||
sed 's/$(AR) cru /$(AR) -o /g' $n.ar-new > $n; \
|
||||
rm -f $n.ar-new; \
|
||||
done;
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "======================================"
|
||||
|
||||
if [ -f config.cache ]; then
|
||||
echo "config.cache exists. Removing the config.cache file will force"
|
||||
echo "the ./configure script to rerun all it's tests rather than using"
|
||||
echo "the previously cached values."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "Now you are ready to run './configure'"
|
||||
echo "======================================"
|
||||
168
configure.in
168
configure.in
@@ -5,8 +5,11 @@ dnl $Id$
|
||||
|
||||
AC_INIT(simgear/bucket/newbucket.cxx)
|
||||
|
||||
# Require at least automake 2.13
|
||||
AC_PREREQ(2.13)
|
||||
|
||||
dnl Initialize the automake stuff
|
||||
AM_INIT_AUTOMAKE(SimGear, 0.0.16)
|
||||
AM_INIT_AUTOMAKE(SimGear, 0.0.18pre1)
|
||||
|
||||
dnl Specify KAI C++ compiler and flags.
|
||||
dnl Borrowed with slight modification from blitz distribution.
|
||||
@@ -49,7 +52,12 @@ else
|
||||
includedir="${includedir}/simgear"
|
||||
echo "includedir changed to" $includedir "libdir is" $libdir
|
||||
fi
|
||||
|
||||
|
||||
# Determine version of automake ... important because of
|
||||
# incompatibilities between versions
|
||||
AUTO_MAKE_VERSION=`automake --version | head -1 | awk '{print $4}' | sed -e 's/\-p[[0-9]]$//' | sed -e 's/\.//'`
|
||||
AM_CONDITIONAL(ANCIENT_AUTOMAKE, test $AUTO_MAKE_VERSION -lt 14)
|
||||
AM_CONDITIONAL(OLD_AUTOMAKE, test $AUTO_MAKE_VERSION -lt 15)
|
||||
|
||||
# set logging default value
|
||||
# with_logging=yes
|
||||
@@ -58,7 +66,7 @@ if test "x$with_logging" = "xno" ; then
|
||||
AC_DEFINE(FG_NDEBUG)
|
||||
fi
|
||||
|
||||
dnl specify if we are building with "checker"
|
||||
dnl specify if we are building with "electric fence"
|
||||
AC_ARG_WITH(efence, [ --with-efence Specify if we are building with "electric-fence"])
|
||||
|
||||
if test "x$with_efence" = "xyes" ; then
|
||||
@@ -66,21 +74,59 @@ if test "x$with_efence" = "xyes" ; then
|
||||
LIBS="$LIBS -lefence"
|
||||
fi
|
||||
|
||||
# Specify if we want to build with Norman's jpeg image server support.
|
||||
# This requires libjpeg to be installed and available.
|
||||
# Default to with_jpeg_server=no
|
||||
JPEGLIB=''
|
||||
AC_ARG_WITH(jpeg_factory, [ --with-jpeg-factory Include Norman's jpeg image factory support code])
|
||||
if test "x$with_jpeg_factory" = "xyes" ; then
|
||||
echo "Building with Norman's jpeg image factory support"
|
||||
AC_CHECK_LIB(jpeg, jpeg_start_compress)
|
||||
if test "x$ac_cv_lib_jpeg_jpeg_start_compress" != "xyes" ; then
|
||||
echo
|
||||
echo "In order to build the jpeg factory code you need libjpeg installed."
|
||||
echo "otherwise please configure with the --with-jpeg-sever=no option"
|
||||
echo
|
||||
echo "libjpeg is available at :"
|
||||
echo " ftp://ftp.uu.net in the directory graphics/jpeg"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Building without Norman's jpeg image server support"
|
||||
fi
|
||||
AM_CONDITIONAL(ENABLE_JPEG_SERVER, test "x$with_jpeg_factory" = "xyes")
|
||||
|
||||
|
||||
dnl Check for MS Windows environment
|
||||
AC_CHECK_HEADER(windows.h)
|
||||
|
||||
dnl extra library and include directories
|
||||
EXTRA_DIRS="/usr/local /usr/local/plib /usr/X11R6"
|
||||
AC_EGREP_CPP(yes,
|
||||
[#ifdef __MINGW32__
|
||||
yes
|
||||
#endif
|
||||
],is_mingw=yes, is_mingw=no)
|
||||
|
||||
if test -d /opt/X11R6 ; then
|
||||
EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6"
|
||||
echo "IS_MINGW = $is_mingw"
|
||||
AM_CONDITIONAL(IS_MINGW, test "x$is_mingw" = "xyes")
|
||||
|
||||
AC_EGREP_CPP(yes,
|
||||
[#ifdef __CYGWIN__
|
||||
yes
|
||||
#endif
|
||||
],is_cygwin=yes, is_cygwin=no)
|
||||
|
||||
echo "IS_CYGWIN = $is_cygwin"
|
||||
AM_CONDITIONAL(IS_CYGWIN, test "x$is_cygwin" = "xyes")
|
||||
|
||||
if test "x$HOSTTYPE" != "xmacintosh" -a "x$is_mingw" != "xyes"; then
|
||||
dnl extra library and include directories
|
||||
EXTRA_DIRS="/usr/local /usr/local/plib /usr/X11R6"
|
||||
|
||||
if test -d /opt/X11R6 ; then
|
||||
EXTRA_DIRS="$EXTRA_DIRS /opt/X11R6"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_header_windows_h" = "xyes" ; then
|
||||
EXTRA_DIRS="${EXTRA_DIRS} `pwd`/Win32"
|
||||
# elif test `uname -s` = "SunOS" ; then
|
||||
# EXTRA_DIRS="${EXTRA_DIRS} `pwd`/SunOS"
|
||||
fi
|
||||
wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
|
||||
|
||||
dnl Using AM_CONDITIONAL is a step out of the protected little
|
||||
@@ -93,8 +139,11 @@ dnl includes, compile alternative source files, etc.
|
||||
dnl Enable serial support on Unix type systems
|
||||
AM_CONDITIONAL(ENABLE_UNIX_SERIAL, true)
|
||||
|
||||
dnl Check for X11 (fancy)
|
||||
AC_PATH_XTRA
|
||||
dnl X11 might be installed on Mac OS X, don't want to use it if it is.
|
||||
if test "x$HOSTTYPE" != "xmacintosh" ; then
|
||||
dnl Check for X11 (fancy)
|
||||
AC_PATH_XTRA
|
||||
fi
|
||||
|
||||
dnl Checks for libraries.
|
||||
|
||||
@@ -114,18 +163,25 @@ fi
|
||||
AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
|
||||
|
||||
AC_CHECK_LIB(socket, socket)
|
||||
AC_CHECK_LIB(X11, XCreateWindow)
|
||||
AC_CHECK_LIB(Xext, XShmCreateImage)
|
||||
AC_CHECK_LIB(Xi, XGetExtensionVersion)
|
||||
AC_CHECK_LIB(ICE, IceOpenConnection)
|
||||
AC_CHECK_LIB(SM, SmcOpenConnection)
|
||||
AC_CHECK_LIB(Xt, XtMalloc)
|
||||
AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
|
||||
|
||||
dnl X11 might be installed, but we don't want to use it for OSX -dw-
|
||||
if test "x$HOSTTYPE" != "xmacintosh" ; then
|
||||
AC_CHECK_LIB(X11, XCreateWindow)
|
||||
AC_CHECK_LIB(Xext, XShmCreateImage)
|
||||
AC_CHECK_LIB(Xi, XGetExtensionVersion)
|
||||
AC_CHECK_LIB(ICE, IceOpenConnection)
|
||||
AC_CHECK_LIB(SM, SmcOpenConnection)
|
||||
AC_CHECK_LIB(Xt, XtMalloc)
|
||||
AC_CHECK_LIB(Xmu, XmuLookupStandardColormap)
|
||||
fi
|
||||
|
||||
dnl check for OpenGL related libraries
|
||||
|
||||
if test "x$ac_cv_header_windows_h" != "xyes" ; then
|
||||
dnl Reasonable stuff for non-windoze variants ... :-)
|
||||
if test "x$HOSTTYPE" = "xmacintosh" ; then
|
||||
dnl Macintosh OSX
|
||||
LIBS="$LIBS -framework OpenGL -framework GLUT"
|
||||
elif test "x$ac_cv_header_windows_h" != "xyes" ; then
|
||||
dnl Reasonable stuff for X-Windows based machines
|
||||
|
||||
AC_CHECK_LIB(GLcore, glNewList)
|
||||
if test "x$ac_cv_lib_GLcore_glNewList" = "xno" ; then
|
||||
@@ -142,8 +198,8 @@ if test "x$ac_cv_header_windows_h" != "xyes" ; then
|
||||
|
||||
dnl if using mesa, check for xmesa.h
|
||||
if test "x$ac_cv_lib_MesaGL_glNewList" = "xyes" ; then
|
||||
AC_CHECK_HEADER(GL/xmesa.h)
|
||||
if test "x$ac_cv_header_GL_xmesa_h" = "xyes"; then
|
||||
AC_CHECK_HEADER(GL/fxmesa.h)
|
||||
if test "x$ac_cv_header_GL_fxmesa_h" = "xyes"; then
|
||||
AC_DEFINE( XMESA )
|
||||
AC_DEFINE( FX )
|
||||
fi
|
||||
@@ -164,8 +220,7 @@ if test "x$ac_cv_header_windows_h" != "xyes" ; then
|
||||
AC_CHECK_LIB(glut, glutGameModeString)
|
||||
LIBS="$save_LIBS"
|
||||
else
|
||||
dnl Win32 is a little wierd because it has to try to handle the various
|
||||
dnl winbloze-isms. We'll just do this manually for now.
|
||||
dnl Win32 libs
|
||||
|
||||
echo Win32 specific hacks...
|
||||
AC_DEFINE(WIN32)
|
||||
@@ -191,6 +246,9 @@ else
|
||||
|
||||
LIBS="$LIBS -l${WIN32_GLUT} -l${WIN32_GLU} -l${WIN32_OPENGL}"
|
||||
LIBS="$LIBS -luser32 -lgdi32"
|
||||
if test "x$is_mingw" = "xyes" ; then
|
||||
EXTRA_DIRS="${EXTRA_DIRS}"
|
||||
fi
|
||||
echo "Will link apps with $LIBS"
|
||||
fi
|
||||
|
||||
@@ -231,35 +289,26 @@ if test "x$ac_cv_header_plib_pu_h" != "xyes"; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# dnl Check for system installed gdbm
|
||||
# AC_CHECK_HEADER(gdbm.h)
|
||||
# if test "x$ac_cv_header_gdbm_h" = "xyes"; then
|
||||
# AC_DEFINE( HAVE_GDBM )
|
||||
# else
|
||||
# echo "no gdbm found, configuring and building."
|
||||
# fi
|
||||
# AM_CONDITIONAL(HAVE_GDBM, test "x$ac_cv_header_gdbm_h" = "xyes" )
|
||||
|
||||
dnl Check for system installed metakit
|
||||
AC_CHECK_HEADER(mk4.h)
|
||||
if test "x$ac_cv_header_mk4_h" != "xyes"; then
|
||||
echo "no metakit found, configuring and building."
|
||||
# Run configure in the metakit subdir
|
||||
AC_CONFIG_SUBDIRS( simgear/metakit/unix )
|
||||
echo
|
||||
echo "Metakit not found, you will need to install this first."
|
||||
echo "Please read the README.metakit for more information."
|
||||
exit
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_METAKIT, test "x$ac_cv_header_mk4_h" = "xyes" )
|
||||
|
||||
|
||||
dnl Specify if we want logging (testing build) or not (release build)
|
||||
|
||||
dnl Check for system installed zlib
|
||||
AC_CHECK_HEADER(zlib.h)
|
||||
if test "x$ac_cv_header_zlib_h" = "xyes"; then
|
||||
AC_DEFINE( HAVE_ZLIB )
|
||||
else
|
||||
echo "no zlib found, building."
|
||||
if test "x$ac_cv_header_zlib_h" != "xyes"; then
|
||||
echo
|
||||
echo "zlib not found, you will need to install this first."
|
||||
echo "Please read the README.zlib for more information."
|
||||
exit
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_ZLIB, test "x$ac_cv_header_zlib_h" = "xyes" )
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
@@ -288,6 +337,7 @@ AM_CONFIG_HEADER(simgear/simgear_config.h)
|
||||
AC_OUTPUT( \
|
||||
Makefile \
|
||||
SimGear.spec \
|
||||
src-libs/Makefile \
|
||||
simgear/Makefile \
|
||||
simgear/version.h \
|
||||
simgear/bucket/Makefile \
|
||||
@@ -306,14 +356,9 @@ AC_OUTPUT( \
|
||||
simgear/timing/Makefile \
|
||||
simgear/xgl/Makefile \
|
||||
simgear/xml/Makefile \
|
||||
simgear/zlib/Makefile \
|
||||
)
|
||||
|
||||
AC_OUTPUT_COMMANDS([
|
||||
# if test "x$ac_cv_header_windows_h" = "xyes" ; then
|
||||
# cp simgear/gdbm/autoconf.h.cygwin32 simgear/gdbm/autoconf.h
|
||||
# fi
|
||||
])
|
||||
# AC_OUTPUT_COMMANDS([])
|
||||
|
||||
echo ""
|
||||
echo "Configure Summary"
|
||||
@@ -333,16 +378,13 @@ else
|
||||
echo "Electric fence: no"
|
||||
fi
|
||||
|
||||
# if test "x$ac_cv_header_gdbm_h" != "xyes"; then
|
||||
# echo "Building gdbm"
|
||||
# fi
|
||||
echo -n "Automake version: ($AUTO_MAKE_VERSION) "
|
||||
automake --version | head -1
|
||||
|
||||
if test "x$ac_cv_header_mk4_h" != "xyes"; then
|
||||
echo "Building metakit"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_header_zlib_h" != "xyes"; then
|
||||
echo "Building zlib"
|
||||
if test "x$with_jpeg_factory" = "xyes"; then
|
||||
echo "With JPEG Factory support"
|
||||
else
|
||||
echo "Without JPEG Factory support"
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
|
||||
@@ -350,9 +392,3 @@ if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h
|
||||
else
|
||||
echo "Threads: no threads (pthread lib not found.)"
|
||||
fi
|
||||
|
||||
if test "$OS" = "IRIX" -o "$OS" = "IRIX64"; then
|
||||
if test "$CXX" = "CC"; then
|
||||
echo "\nRemember to run: sh ../FlightGear/irix-hack.sh!\07\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
6
simgear/.cvsignore
Normal file
6
simgear/.cvsignore
Normal file
@@ -0,0 +1,6 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
simgear_config.h
|
||||
stamp-h
|
||||
stamp-h.in
|
||||
version.h
|
||||
@@ -4,18 +4,6 @@ else
|
||||
SERIAL_DIRS =
|
||||
endif
|
||||
|
||||
# if HAVE_GDBM
|
||||
# GDBM_DIRS =
|
||||
# else
|
||||
# GDBM_DIRS = gdbm
|
||||
# endif
|
||||
|
||||
if HAVE_ZLIB
|
||||
ZLIB_DIRS =
|
||||
else
|
||||
ZLIB_DIRS = zlib
|
||||
endif
|
||||
|
||||
if HAVE_THREADS
|
||||
SGTHREAD_DIR = threads
|
||||
else
|
||||
@@ -25,13 +13,12 @@ endif
|
||||
# METAR_DIRS =
|
||||
METAR_DIRS = metar
|
||||
|
||||
EXTRA_DIST = version.h.in
|
||||
EXTRA_DIST = simgear_config.h.vc5 version.h.in
|
||||
|
||||
include_HEADERS = \
|
||||
compiler.h constants.h sg_inlines.h sg_traits.hxx sg_zlib.h version.h
|
||||
|
||||
SUBDIRS = \
|
||||
$(ZLIB_DIRS) \
|
||||
xml \
|
||||
debug \
|
||||
misc \
|
||||
|
||||
3
simgear/bucket/.cvsignore
Normal file
3
simgear/bucket/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -14,4 +14,8 @@ libsgbucket_a_SOURCES = newbucket.cxx
|
||||
# $(top_builddir)/bucket/libsgbucket.a \
|
||||
# $(top_builddir)/misc/libsgmisc.a
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -139,6 +139,11 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( __MINGW32__ )
|
||||
# define bcopy(from, to, n) memcpy(to, from, n)
|
||||
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
|
||||
#endif
|
||||
|
||||
/* KAI C++ */
|
||||
#if defined(__KCC)
|
||||
|
||||
@@ -278,6 +283,19 @@
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream.h>
|
||||
|
||||
// # define __STL_FUNCTION_TMPL_PARTIAL_ORDER
|
||||
// typedef void PFNGLPOINTPARAMETERFEXTPROC
|
||||
|
||||
#define glPointParameterfEXT glPointParameterfSGIS
|
||||
#define glPointParameterfvEXT glPointParameterfvSGIS
|
||||
|
||||
#pragma set woff 1001,1012,1014,1116,1155,1172,1174
|
||||
#pragma set woff 1401,1460,1551,1552,1681
|
||||
|
||||
#ifdef __cplusplus
|
||||
#pragma set woff 1682,3303
|
||||
#endif
|
||||
|
||||
#endif // Native SGI compilers
|
||||
|
||||
|
||||
@@ -294,6 +312,27 @@
|
||||
# endif // __cplusplus
|
||||
#endif // sun
|
||||
|
||||
//
|
||||
// Intel C++ Compiler
|
||||
//
|
||||
#if defined(__ICC)
|
||||
# define SG_NAMESPACES
|
||||
# define SG_HAVE_STD
|
||||
# define SG_HAVE_STREAMBUF
|
||||
# define SG_HAVE_TRAITS
|
||||
# define SG_HAVE_STD_INCLUDES
|
||||
|
||||
# define STL_ALGORITHM <algorithm>
|
||||
# define STL_FUNCTIONAL <functional>
|
||||
# define STL_IOMANIP <iomanip>
|
||||
# define STL_IOSTREAM <iostream>
|
||||
# define STL_ITERATOR <iterator>
|
||||
# define STL_FSTREAM <fstream>
|
||||
# define STL_STDEXCEPT <stdexcept>
|
||||
# define STL_STRING <string>
|
||||
# define STL_STRSTREAM <strstream>
|
||||
#endif // __ICC
|
||||
|
||||
//
|
||||
// No user modifiable definitions beyond here.
|
||||
//
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
|
||||
/** Highest binobj format version we know how to read/write. This starts at
|
||||
* 0 and can go up to 65535 */
|
||||
#define SG_BINOBJ_VERSION 5
|
||||
#define SG_BINOBJ_VERSION 6
|
||||
|
||||
/** for backwards compatibility */
|
||||
#define SG_SCENERY_FILE_FORMAT "0.4"
|
||||
|
||||
3
simgear/debug/.cvsignore
Normal file
3
simgear/debug/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -8,4 +8,8 @@ include_HEADERS = debug_types.h logstream.hxx
|
||||
|
||||
libsgdebug_a_SOURCES = logstream.cxx
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -56,6 +56,30 @@ logbuf::set_log_level( sgDebugClass c, sgDebugPriority p )
|
||||
logPriority = p;
|
||||
}
|
||||
|
||||
void
|
||||
logbuf::set_log_classes (sgDebugClass c)
|
||||
{
|
||||
logClass = c;
|
||||
}
|
||||
|
||||
sgDebugClass
|
||||
logbuf::get_log_classes ()
|
||||
{
|
||||
return logClass;
|
||||
}
|
||||
|
||||
void
|
||||
logbuf::set_log_priority (sgDebugPriority p)
|
||||
{
|
||||
logPriority = p;
|
||||
}
|
||||
|
||||
sgDebugPriority
|
||||
logbuf::get_log_priority ()
|
||||
{
|
||||
return logPriority;
|
||||
}
|
||||
|
||||
void
|
||||
logstream::setLogLevels( sgDebugClass c, sgDebugPriority p )
|
||||
{
|
||||
|
||||
@@ -105,6 +105,35 @@ public:
|
||||
*/
|
||||
static void set_log_level( sgDebugClass c, sgDebugPriority p );
|
||||
|
||||
|
||||
/**
|
||||
* Set the allowed logging classes.
|
||||
* @param c All enabled logging classes anded together.
|
||||
*/
|
||||
static void set_log_classes (sgDebugClass c);
|
||||
|
||||
|
||||
/**
|
||||
* Get the logging classes currently enabled.
|
||||
* @return All enabled debug logging anded together.
|
||||
*/
|
||||
static sgDebugClass get_log_classes ();
|
||||
|
||||
|
||||
/**
|
||||
* Set the logging priority.
|
||||
* @param c The priority cutoff for logging messages.
|
||||
*/
|
||||
static void set_log_priority (sgDebugPriority p);
|
||||
|
||||
|
||||
/**
|
||||
* Get the current logging priority.
|
||||
* @return The priority cutoff for logging messages.
|
||||
*/
|
||||
static sgDebugPriority get_log_priority ();
|
||||
|
||||
|
||||
/**
|
||||
* Set the stream buffer
|
||||
* @param sb stream buffer
|
||||
|
||||
3
simgear/ephemeris/.cvsignore
Normal file
3
simgear/ephemeris/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -31,4 +31,8 @@ libsgephem_a_SOURCES = \
|
||||
uranus.cxx \
|
||||
venus.cxx
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -32,10 +32,14 @@
|
||||
#endif
|
||||
|
||||
// Constructor
|
||||
SGStarData::SGStarData() {
|
||||
SGStarData::SGStarData() :
|
||||
nstars(0)
|
||||
{
|
||||
}
|
||||
|
||||
SGStarData::SGStarData( SGPath path ) {
|
||||
SGStarData::SGStarData( SGPath path ) :
|
||||
nstars(0)
|
||||
{
|
||||
data_path = SGPath( path );
|
||||
load();
|
||||
}
|
||||
|
||||
6
simgear/io/.cvsignore
Normal file
6
simgear/io/.cvsignore
Normal file
@@ -0,0 +1,6 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
decode_binobj
|
||||
lowtest
|
||||
socktest
|
||||
@@ -8,7 +8,8 @@ include_HEADERS = \
|
||||
sg_binobj.hxx \
|
||||
sg_file.hxx \
|
||||
sg_serial.hxx \
|
||||
sg_socket.hxx
|
||||
sg_socket.hxx \
|
||||
sg_socket_udp.hxx
|
||||
|
||||
libsgio_a_SOURCES = \
|
||||
iochannel.cxx \
|
||||
@@ -16,9 +17,20 @@ libsgio_a_SOURCES = \
|
||||
sg_binobj.cxx \
|
||||
sg_file.cxx \
|
||||
sg_serial.cxx \
|
||||
sg_socket.cxx
|
||||
sg_socket.cxx \
|
||||
sg_socket_udp.cxx
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
if IS_MINGW
|
||||
NETWORK_LIB = -lwsock32
|
||||
else
|
||||
NETWORK_LIB =
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = decode_binobj socktest lowtest
|
||||
|
||||
@@ -45,4 +57,4 @@ decode_binobj_LDADD = \
|
||||
$(top_builddir)/simgear/misc/libsgmisc.a \
|
||||
$(top_builddir)/simgear/debug/libsgdebug.a \
|
||||
$(top_builddir)/simgear/xml/libsgxml.a \
|
||||
-lz
|
||||
$(NETWORK_LIB) -lz
|
||||
|
||||
@@ -58,25 +58,49 @@ int main( int argc, char **argv ) {
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
cout << "# triangle groups" << endl;
|
||||
cout << "# geometry groups" << endl;
|
||||
cout << endl;
|
||||
|
||||
string material;
|
||||
int_list vertex_index;
|
||||
int_list normal_index;
|
||||
int_list tex_index;
|
||||
|
||||
// generate points
|
||||
string_list pt_materials = obj.get_pt_materials();
|
||||
group_list pts_v = obj.get_pts_v();
|
||||
group_list pts_n = obj.get_pts_n();
|
||||
for ( i = 0; i < (int)pts_v.size(); ++i ) {
|
||||
material = pt_materials[i];
|
||||
vertex_index = pts_v[i];
|
||||
normal_index = pts_n[i];
|
||||
cout << "# usemtl " << material << endl;
|
||||
cout << "pt ";
|
||||
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
|
||||
cout << vertex_index[j] << "/" << normal_index[j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
// generate triangles
|
||||
string_list tri_materials = obj.get_tri_materials();
|
||||
group_list tris_v = obj.get_tris_v();
|
||||
group_list tris_n = obj.get_tris_n();
|
||||
group_list tris_tc = obj.get_tris_tc();
|
||||
for ( i = 0; i < (int)tris_v.size(); ++i ) {
|
||||
material = tri_materials[i];
|
||||
vertex_index = tris_v[i];
|
||||
normal_index = tris_n[i];
|
||||
tex_index = tris_tc[i];
|
||||
cout << "# usemtl " << material << endl;
|
||||
cout << "f ";
|
||||
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
|
||||
cout << vertex_index[j] << "/" << tex_index[j] << " ";
|
||||
cout << vertex_index[j];
|
||||
if ( normal_index.size() ) {
|
||||
cout << "/" << normal_index[j];
|
||||
}
|
||||
cout << "/" << tex_index[j];
|
||||
cout << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
@@ -84,15 +108,21 @@ int main( int argc, char **argv ) {
|
||||
// generate strips
|
||||
string_list strip_materials = obj.get_strip_materials();
|
||||
group_list strips_v = obj.get_strips_v();
|
||||
group_list strips_n = obj.get_strips_n();
|
||||
group_list strips_tc = obj.get_strips_tc();
|
||||
for ( i = 0; i < (int)strips_v.size(); ++i ) {
|
||||
material = strip_materials[i];
|
||||
vertex_index = strips_v[i];
|
||||
normal_index = strips_n[i];
|
||||
tex_index = strips_tc[i];
|
||||
cout << "# usemtl " << material << endl;
|
||||
cout << "ts ";
|
||||
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
|
||||
cout << vertex_index[j] << "/" << tex_index[j] << " ";
|
||||
cout << vertex_index[j];
|
||||
if ( normal_index.size() ) {
|
||||
cout << "/" << normal_index[j];
|
||||
}
|
||||
cout << "/" << tex_index[j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
@@ -100,15 +130,21 @@ int main( int argc, char **argv ) {
|
||||
// generate fans
|
||||
string_list fan_materials = obj.get_fan_materials();
|
||||
group_list fans_v = obj.get_fans_v();
|
||||
group_list fans_n = obj.get_fans_n();
|
||||
group_list fans_tc = obj.get_fans_tc();
|
||||
for ( i = 0; i < (int)fans_v.size(); ++i ) {
|
||||
material = fan_materials[i];
|
||||
vertex_index = fans_v[i];
|
||||
normal_index = fans_n[i];
|
||||
tex_index = fans_tc[i];
|
||||
cout << "# usemtl " << material << endl;
|
||||
cout << "tf ";
|
||||
for ( j = 0; j < (int)vertex_index.size(); ++j ) {
|
||||
cout << vertex_index[j] << "/" << tex_index[j] << " ";
|
||||
cout << vertex_index[j];
|
||||
if ( normal_index.size() ) {
|
||||
cout << "/" << normal_index[j];
|
||||
}
|
||||
cout << "/" << tex_index[j] << " ";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
@@ -158,6 +158,7 @@ public:
|
||||
inline void set_dir( const SGProtocolDir d ) { dir = d; }
|
||||
inline SGProtocolDir get_dir() const { return dir; }
|
||||
inline bool isvalid() const { return valid; }
|
||||
inline void set_valid( const bool v ) { valid = v; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -29,12 +29,7 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
# include <zlib.h>
|
||||
#else
|
||||
# include <simgear/zlib/zlib.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ int main() {
|
||||
}
|
||||
cout << "endian" << endl;
|
||||
|
||||
cout << "sizeof(short) = " << sizeof(short) << endl;
|
||||
|
||||
short s = 1111;
|
||||
cout << "short s = " << s << endl;
|
||||
sgEndianSwap((unsigned short *)&s);
|
||||
|
||||
@@ -49,17 +49,29 @@ enum {
|
||||
SG_BOUNDING_SPHERE = 0,
|
||||
|
||||
SG_VERTEX_LIST = 1,
|
||||
SG_COLOR_LIST = 4,
|
||||
SG_NORMAL_LIST = 2,
|
||||
SG_TEXCOORD_LIST = 3,
|
||||
|
||||
SG_POINTS = 9,
|
||||
|
||||
SG_TRIANGLE_FACES = 10,
|
||||
SG_TRIANGLE_STRIPS = 11,
|
||||
SG_TRIANGLE_FANS = 12
|
||||
} tgObjectTypes;
|
||||
} sgObjectTypes;
|
||||
|
||||
enum {
|
||||
SG_MATERIAL = 0
|
||||
} tgPropertyTypes;
|
||||
SG_IDX_VERTICES = 0x01,
|
||||
SG_IDX_NORMALS = 0x02,
|
||||
SG_IDX_COLORS = 0x04,
|
||||
SG_IDX_TEXCOORDS = 0x08
|
||||
} sgIndexTypes;
|
||||
|
||||
enum {
|
||||
SG_MATERIAL = 0,
|
||||
SG_INDEX_TYPES = 1
|
||||
} sgPropertyTypes;
|
||||
|
||||
|
||||
|
||||
class sgSimpleBuffer {
|
||||
@@ -145,11 +157,131 @@ double sgCalcBoundingRadius( Point3D center, point_list& wgs84_nodes ) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// read object properties
|
||||
static void read_object( gzFile fp,
|
||||
int obj_type,
|
||||
int nproperties,
|
||||
int nelements,
|
||||
group_list *vertices,
|
||||
group_list *normals,
|
||||
group_list *colors,
|
||||
group_list *texcoords,
|
||||
string_list *materials )
|
||||
{
|
||||
unsigned int nbytes;
|
||||
unsigned char idx_mask;
|
||||
int idx_size;
|
||||
bool do_vertices, do_normals, do_colors, do_texcoords;
|
||||
int j, k, idx;
|
||||
static sgSimpleBuffer buf( 32768 ); // 32 Kb
|
||||
char material[256];
|
||||
|
||||
// default values
|
||||
if ( obj_type == SG_POINTS ) {
|
||||
idx_size = 1;
|
||||
idx_mask = SG_IDX_VERTICES;
|
||||
do_vertices = true;
|
||||
do_normals = false;
|
||||
do_colors = false;
|
||||
do_texcoords = false;
|
||||
} else {
|
||||
idx_size = 2;
|
||||
idx_mask = (char)(SG_IDX_VERTICES | SG_IDX_TEXCOORDS);
|
||||
do_vertices = true;
|
||||
do_normals = false;
|
||||
do_colors = false;
|
||||
do_texcoords = true;
|
||||
}
|
||||
|
||||
for ( j = 0; j < nproperties; ++j ) {
|
||||
char prop_type;
|
||||
sgReadChar( fp, &prop_type );
|
||||
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "property size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
if ( prop_type == SG_MATERIAL ) {
|
||||
strncpy( material, ptr, nbytes );
|
||||
material[nbytes] = '\0';
|
||||
// cout << "material type = " << material << endl;
|
||||
} else if ( prop_type == SG_INDEX_TYPES ) {
|
||||
idx_mask = ptr[0];
|
||||
// cout << "idx_mask = " << (int)idx_mask << endl;
|
||||
idx_size = 0;
|
||||
do_vertices = false;
|
||||
do_normals = false;
|
||||
do_colors = false;
|
||||
do_texcoords = false;
|
||||
if ( idx_mask & SG_IDX_VERTICES ) {
|
||||
do_vertices = true;
|
||||
++idx_size;
|
||||
}
|
||||
if ( idx_mask & SG_IDX_NORMALS ) {
|
||||
do_normals = true;
|
||||
++idx_size;
|
||||
}
|
||||
if ( idx_mask & SG_IDX_COLORS ) {
|
||||
do_colors = true;
|
||||
++idx_size;
|
||||
}
|
||||
if ( idx_mask & SG_IDX_TEXCOORDS ) {
|
||||
do_texcoords = true;
|
||||
++idx_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( j = 0; j < nelements; ++j ) {
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "element size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
int count = nbytes / (idx_size * sizeof(short));
|
||||
short *sptr = (short *)ptr;
|
||||
int_list vs; vs.clear();
|
||||
int_list ns; ns.clear();
|
||||
int_list cs; cs.clear();
|
||||
int_list tcs; tcs.clear();
|
||||
for ( k = 0; k < count; ++k ) {
|
||||
if ( sgIsBigEndian() ) {
|
||||
for ( idx = 0; idx < idx_size; ++idx ) {
|
||||
sgEndianSwap( (unsigned short *)&(sptr[idx]) );
|
||||
}
|
||||
}
|
||||
idx = 0;
|
||||
if ( do_vertices ) {
|
||||
vs.push_back( sptr[idx++] );
|
||||
}
|
||||
if ( do_normals ) {
|
||||
ns.push_back( sptr[idx++] );
|
||||
}
|
||||
if ( do_colors ) {
|
||||
cs.push_back( sptr[idx++] );
|
||||
}
|
||||
if ( do_texcoords ) {
|
||||
tcs.push_back( sptr[idx++] );
|
||||
}
|
||||
// cout << sptr[0] << " ";
|
||||
sptr += idx_size;
|
||||
}
|
||||
// cout << endl;
|
||||
vertices->push_back( vs );
|
||||
normals->push_back( ns );
|
||||
colors->push_back( cs );
|
||||
texcoords->push_back( tcs );
|
||||
materials->push_back( material );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// read a binary file and populate the provided structures.
|
||||
bool SGBinObject::read_bin( const string& file ) {
|
||||
Point3D p;
|
||||
int i, j, k;
|
||||
char material[256];
|
||||
unsigned int nbytes;
|
||||
static sgSimpleBuffer buf( 32768 ); // 32 Kb
|
||||
|
||||
@@ -161,15 +293,27 @@ bool SGBinObject::read_bin( const string& file ) {
|
||||
normals.clear();
|
||||
texcoords.clear();
|
||||
|
||||
pts_v.clear();
|
||||
pts_n.clear();
|
||||
pts_c.clear();
|
||||
pts_tc.clear();
|
||||
pt_materials.clear();
|
||||
|
||||
tris_v.clear();
|
||||
tris_n.clear();
|
||||
tris_c.clear();
|
||||
tris_tc.clear();
|
||||
tri_materials.clear();
|
||||
|
||||
strips_v.clear();
|
||||
strips_n.clear();
|
||||
strips_c.clear();
|
||||
strips_tc.clear();
|
||||
strip_materials.clear();
|
||||
|
||||
fans_v.clear();
|
||||
fans_n.clear();
|
||||
fans_c.clear();
|
||||
fans_tc.clear();
|
||||
fan_materials.clear();
|
||||
|
||||
@@ -177,8 +321,8 @@ bool SGBinObject::read_bin( const string& file ) {
|
||||
if ( (fp = gzopen( file.c_str(), "rb" )) == NULL ) {
|
||||
string filegz = file + ".gz";
|
||||
if ( (fp = gzopen( filegz.c_str(), "rb" )) == NULL ) {
|
||||
// cout << "ERROR: opening " << file << " or " << filegz
|
||||
// << "for reading!" << endl;
|
||||
cout << "ERROR: opening " << file << " or " << filegz
|
||||
<< "for reading!" << endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -205,11 +349,18 @@ bool SGBinObject::read_bin( const string& file ) {
|
||||
// read creation time
|
||||
time_t calendar_time;
|
||||
sgReadLong( fp, &calendar_time );
|
||||
|
||||
#if 0
|
||||
// The following code has a global effect on the host application
|
||||
// and can screws up the time elsewhere. It should be avoided
|
||||
// unless you need this for debugging in which case you should
|
||||
// disable it again once the debugging task is finished.
|
||||
struct tm *local_tm;
|
||||
local_tm = localtime( &calendar_time );
|
||||
char time_str[256];
|
||||
strftime( time_str, 256, "%a %b %d %H:%M:%S %Z %Y", local_tm);
|
||||
// cout << "File created on " << time_str << endl;
|
||||
cout << "File created on " << time_str << endl;
|
||||
#endif
|
||||
|
||||
// read number of top level objects
|
||||
short nobjects;
|
||||
@@ -300,6 +451,41 @@ bool SGBinObject::read_bin( const string& file ) {
|
||||
fptr += 3;
|
||||
}
|
||||
}
|
||||
} else if ( obj_type == SG_COLOR_LIST ) {
|
||||
// read color list properties
|
||||
for ( j = 0; j < nproperties; ++j ) {
|
||||
char prop_type;
|
||||
sgReadChar( fp, &prop_type );
|
||||
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "property size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
}
|
||||
|
||||
// read color list elements
|
||||
for ( j = 0; j < nelements; ++j ) {
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "element size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
int count = nbytes / (sizeof(float) * 4);
|
||||
float *fptr = (float *)ptr;
|
||||
for ( k = 0; k < count; ++k ) {
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned int *)&(fptr[0]) );
|
||||
sgEndianSwap( (unsigned int *)&(fptr[1]) );
|
||||
sgEndianSwap( (unsigned int *)&(fptr[2]) );
|
||||
sgEndianSwap( (unsigned int *)&(fptr[3]) );
|
||||
}
|
||||
p = Point3D( fptr[0], fptr[1], fptr[2] );
|
||||
// cout << "node = " << p << endl;
|
||||
colors.push_back( p );
|
||||
fptr += 4;
|
||||
}
|
||||
}
|
||||
} else if ( obj_type == SG_NORMAL_LIST ) {
|
||||
// read normal list properties
|
||||
for ( j = 0; j < nproperties; ++j ) {
|
||||
@@ -368,138 +554,23 @@ bool SGBinObject::read_bin( const string& file ) {
|
||||
fptr += 2;
|
||||
}
|
||||
}
|
||||
} else if ( obj_type == SG_POINTS ) {
|
||||
// read point elements
|
||||
read_object( fp, SG_POINTS, nproperties, nelements,
|
||||
&pts_v, &pts_n, &pts_c, &pts_tc, &pt_materials );
|
||||
} else if ( obj_type == SG_TRIANGLE_FACES ) {
|
||||
// read triangle face properties
|
||||
for ( j = 0; j < nproperties; ++j ) {
|
||||
char prop_type;
|
||||
sgReadChar( fp, &prop_type );
|
||||
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "property size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
if ( prop_type == SG_MATERIAL ) {
|
||||
strncpy( material, ptr, nbytes );
|
||||
material[nbytes] = '\0';
|
||||
// cout << "material type = " << material << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// read triangle face elements
|
||||
for ( j = 0; j < nelements; ++j ) {
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "element size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
int count = nbytes / (sizeof(short) * 2);
|
||||
short *sptr = (short *)ptr;
|
||||
int_list vs, tcs;
|
||||
vs.clear(); tcs.clear();
|
||||
for ( k = 0; k < count; ++k ) {
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned short *)&(sptr[0]) );
|
||||
sgEndianSwap( (unsigned short *)&(sptr[1]) );
|
||||
}
|
||||
vs.push_back( sptr[0] );
|
||||
tcs.push_back( sptr[1] );
|
||||
// cout << sptr[0] << "/" << sptr[1] << " ";
|
||||
sptr += 2;
|
||||
}
|
||||
// cout << endl;
|
||||
tris_v.push_back( vs );
|
||||
tris_tc.push_back( tcs );
|
||||
tri_materials.push_back( material );
|
||||
}
|
||||
read_object( fp, SG_TRIANGLE_FACES, nproperties, nelements,
|
||||
&tris_v, &tris_n, &tris_c, &tris_tc, &tri_materials );
|
||||
} else if ( obj_type == SG_TRIANGLE_STRIPS ) {
|
||||
// read triangle strip properties
|
||||
for ( j = 0; j < nproperties; ++j ) {
|
||||
char prop_type;
|
||||
sgReadChar( fp, &prop_type );
|
||||
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "property size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
if ( prop_type == SG_MATERIAL ) {
|
||||
strncpy( material, ptr, nbytes );
|
||||
material[nbytes] = '\0';
|
||||
// cout << "material type = " << material << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// read triangle strip elements
|
||||
for ( j = 0; j < nelements; ++j ) {
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "element size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
int count = nbytes / (sizeof(short) * 2);
|
||||
short *sptr = (short *)ptr;
|
||||
int_list vs, tcs;
|
||||
vs.clear(); tcs.clear();
|
||||
for ( k = 0; k < count; ++k ) {
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned short *)&(sptr[0]) );
|
||||
sgEndianSwap( (unsigned short *)&(sptr[1]) );
|
||||
}
|
||||
vs.push_back( sptr[0] );
|
||||
tcs.push_back( sptr[1] );
|
||||
// cout << sptr[0] << "/" << sptr[1] << " ";
|
||||
sptr += 2;
|
||||
}
|
||||
// cout << endl;
|
||||
strips_v.push_back( vs );
|
||||
strips_tc.push_back( tcs );
|
||||
strip_materials.push_back( material );
|
||||
}
|
||||
read_object( fp, SG_TRIANGLE_STRIPS, nproperties, nelements,
|
||||
&strips_v, &strips_n, &strips_c, &strips_tc,
|
||||
&strip_materials );
|
||||
} else if ( obj_type == SG_TRIANGLE_FANS ) {
|
||||
// read triangle fan properties
|
||||
for ( j = 0; j < nproperties; ++j ) {
|
||||
char prop_type;
|
||||
sgReadChar( fp, &prop_type );
|
||||
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "property size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
if ( prop_type == SG_MATERIAL ) {
|
||||
strncpy( material, ptr, nbytes );
|
||||
material[nbytes] = '\0';
|
||||
// cout << "material type = " << material << endl;
|
||||
}
|
||||
}
|
||||
|
||||
// read triangle fan elements
|
||||
for ( j = 0; j < nelements; ++j ) {
|
||||
sgReadUInt( fp, &nbytes );
|
||||
// cout << "element size = " << nbytes << endl;
|
||||
if ( nbytes > buf.get_size() ) { buf.resize( nbytes ); }
|
||||
char *ptr = buf.get_ptr();
|
||||
sgReadBytes( fp, nbytes, ptr );
|
||||
int count = nbytes / (sizeof(short) * 2);
|
||||
short *sptr = (short *)ptr;
|
||||
int_list vs, tcs;
|
||||
vs.clear(); tcs.clear();
|
||||
for ( k = 0; k < count; ++k ) {
|
||||
if ( sgIsBigEndian() ) {
|
||||
sgEndianSwap( (unsigned short *)&(sptr[0]) );
|
||||
sgEndianSwap( (unsigned short *)&(sptr[1]) );
|
||||
}
|
||||
vs.push_back( sptr[0] );
|
||||
tcs.push_back( sptr[1] );
|
||||
// cout << sptr[0] << "/" << sptr[1] << " ";
|
||||
sptr += 2;
|
||||
}
|
||||
// cout << endl;
|
||||
fans_v.push_back( vs );
|
||||
fans_tc.push_back( tcs );
|
||||
fan_materials.push_back( material );
|
||||
}
|
||||
read_object( fp, SG_TRIANGLE_FANS, nproperties, nelements,
|
||||
&fans_v, &fans_n, &fans_c, &fans_tc, &fan_materials );
|
||||
} else {
|
||||
// unknown object type, just skip
|
||||
|
||||
@@ -547,11 +618,14 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
Point3D p;
|
||||
sgVec2 t;
|
||||
sgVec3 pt;
|
||||
sgVec4 color;
|
||||
int i, j;
|
||||
unsigned char idx_mask;
|
||||
int idx_size;
|
||||
|
||||
string dir = base + "/" + b.gen_base_path();
|
||||
string command = "mkdir -p " + dir;
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
system( (string("mkdir ") + dir).c_str() );
|
||||
#else
|
||||
system(command.c_str());
|
||||
@@ -568,6 +642,8 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
|
||||
sgClearWriteError();
|
||||
|
||||
cout << "points size = " << pts_v.size() << " pt_materials = "
|
||||
<< pt_materials.size() << endl;
|
||||
cout << "triangles size = " << tris_v.size() << " tri_materials = "
|
||||
<< tri_materials.size() << endl;
|
||||
cout << "strips size = " << strips_v.size() << " strip_materials = "
|
||||
@@ -575,7 +651,9 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
cout << "fans size = " << fans_v.size() << " fan_materials = "
|
||||
<< fan_materials.size() << endl;
|
||||
|
||||
cout << "points = " << wgs84_nodes.size() << endl;
|
||||
cout << "nodes = " << wgs84_nodes.size() << endl;
|
||||
cout << "colors = " << colors.size() << endl;
|
||||
cout << "normals = " << normals.size() << endl;
|
||||
cout << "tex coords = " << texcoords.size() << endl;
|
||||
|
||||
// write header magic
|
||||
@@ -590,9 +668,24 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
short nobjects = 0;
|
||||
nobjects++; // for gbs
|
||||
nobjects++; // for vertices
|
||||
nobjects++; // for colors
|
||||
nobjects++; // for normals
|
||||
nobjects++; // for texcoords
|
||||
|
||||
// points
|
||||
short npts = 0;
|
||||
start = 0; end = 1;
|
||||
while ( start < (int)pt_materials.size() ) {
|
||||
material = pt_materials[start];
|
||||
while ( (end < (int)pt_materials.size()) &&
|
||||
(material == pt_materials[end]) ) {
|
||||
end++;
|
||||
}
|
||||
npts++;
|
||||
start = end; end = start + 1;
|
||||
}
|
||||
nobjects += npts;
|
||||
|
||||
// tris
|
||||
short ntris = 0;
|
||||
start = 0; end = 1;
|
||||
@@ -660,6 +753,20 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
sgWriteVec3( fp, pt );
|
||||
}
|
||||
|
||||
// dump vertex color list
|
||||
sgWriteChar( fp, (char)SG_COLOR_LIST ); // type
|
||||
sgWriteShort( fp, 0 ); // nproperties
|
||||
sgWriteShort( fp, 1 ); // nelements
|
||||
sgWriteUInt( fp, colors.size() * sizeof(float) * 4 ); // nbytes
|
||||
for ( i = 0; i < (int)colors.size(); ++i ) {
|
||||
p = colors[i];
|
||||
// Right now we have a place holder for color alpha but we
|
||||
// need to update the interface so the calling program can
|
||||
// provide the info.
|
||||
sgSetVec4( color, p.x(), p.y(), p.z(), 1.0 );
|
||||
sgWriteVec4( fp, color );
|
||||
}
|
||||
|
||||
// dump vertex normal list
|
||||
sgWriteChar( fp, (char)SG_NORMAL_LIST ); // type
|
||||
sgWriteShort( fp, 0 ); // nproperties
|
||||
@@ -685,6 +792,66 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
sgWriteVec2( fp, t );
|
||||
}
|
||||
|
||||
// dump point groups if they exist
|
||||
if ( pts_v.size() > 0 ) {
|
||||
int start = 0;
|
||||
int end = 1;
|
||||
string material;
|
||||
while ( start < (int)pt_materials.size() ) {
|
||||
// find next group
|
||||
material = pt_materials[start];
|
||||
while ( (end < (int)pt_materials.size()) &&
|
||||
(material == pt_materials[end]) )
|
||||
{
|
||||
// cout << "end = " << end << endl;
|
||||
end++;
|
||||
}
|
||||
// cout << "group = " << start << " to " << end - 1 << endl;
|
||||
|
||||
// write group headers
|
||||
sgWriteChar( fp, (char)SG_POINTS ); // type
|
||||
sgWriteShort( fp, 2 ); // nproperties
|
||||
sgWriteShort( fp, end - start ); // nelements
|
||||
|
||||
sgWriteChar( fp, (char)SG_MATERIAL ); // property
|
||||
sgWriteUInt( fp, material.length() ); // nbytes
|
||||
sgWriteBytes( fp, material.length(), material.c_str() );
|
||||
|
||||
idx_mask = 0;
|
||||
idx_size = 0;
|
||||
if ( pts_v.size() ) { idx_mask |= SG_IDX_VERTICES; ++idx_size; }
|
||||
if ( pts_n.size() ) { idx_mask |= SG_IDX_NORMALS; ++idx_size; }
|
||||
if ( pts_c.size() ) { idx_mask |= SG_IDX_COLORS; ++idx_size; }
|
||||
if ( pts_tc.size() ) { idx_mask |= SG_IDX_TEXCOORDS; ++idx_size; }
|
||||
sgWriteChar( fp, (char)SG_INDEX_TYPES ); // property
|
||||
sgWriteUInt( fp, 1 ); // nbytes
|
||||
sgWriteChar( fp, idx_mask );
|
||||
|
||||
// write strips
|
||||
for ( i = start; i < end; ++i ) {
|
||||
// nbytes
|
||||
sgWriteUInt( fp, pts_v[i].size() * idx_size * sizeof(short) );
|
||||
for ( j = 0; j < (int)pts_v[i].size(); ++j ) {
|
||||
if ( pts_v.size() ) {
|
||||
sgWriteShort( fp, (short)pts_v[i][j] );
|
||||
}
|
||||
if ( pts_n.size() ) {
|
||||
sgWriteShort( fp, (short)pts_n[i][j] );
|
||||
}
|
||||
if ( pts_c.size() ) {
|
||||
sgWriteShort( fp, (short)pts_c[i][j] );
|
||||
}
|
||||
if ( pts_tc.size() ) {
|
||||
sgWriteShort( fp, (short)pts_tc[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
start = end;
|
||||
end = start + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// dump individual triangles if they exist
|
||||
if ( tris_v.size() > 0 ) {
|
||||
int start = 0;
|
||||
@@ -703,20 +870,41 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
|
||||
// write group headers
|
||||
sgWriteChar( fp, (char)SG_TRIANGLE_FACES ); // type
|
||||
sgWriteShort( fp, 1 ); // nproperties
|
||||
sgWriteShort( fp, 2 ); // nproperties
|
||||
sgWriteShort( fp, 1 ); // nelements
|
||||
|
||||
sgWriteChar( fp, (char)SG_MATERIAL ); // property
|
||||
sgWriteUInt( fp, material.length() ); // nbytes
|
||||
sgWriteBytes( fp, material.length(), material.c_str() );
|
||||
|
||||
sgWriteUInt( fp, (end - start) * 3 * 2 * sizeof(short) ); // nbytes
|
||||
idx_mask = 0;
|
||||
idx_size = 0;
|
||||
if ( tris_v.size() ) { idx_mask |= SG_IDX_VERTICES; ++idx_size; }
|
||||
if ( tris_n.size() ) { idx_mask |= SG_IDX_NORMALS; ++idx_size; }
|
||||
if ( tris_c.size() ) { idx_mask |= SG_IDX_COLORS; ++idx_size; }
|
||||
if ( tris_tc.size() ) { idx_mask |= SG_IDX_TEXCOORDS; ++idx_size; }
|
||||
sgWriteChar( fp, (char)SG_INDEX_TYPES ); // property
|
||||
sgWriteUInt( fp, 1 ); // nbytes
|
||||
sgWriteChar( fp, idx_mask );
|
||||
|
||||
// nbytes
|
||||
sgWriteUInt( fp, (end - start) * 3 * idx_size * sizeof(short) );
|
||||
|
||||
// write group
|
||||
for ( i = start; i < end; ++i ) {
|
||||
for ( j = 0; j < 3; ++j ) {
|
||||
sgWriteShort( fp, (short)tris_v[i][j] );
|
||||
sgWriteShort( fp, (short)tris_tc[i][j] );
|
||||
if ( tris_v.size() ) {
|
||||
sgWriteShort( fp, (short)tris_v[i][j] );
|
||||
}
|
||||
if ( tris_n.size() ) {
|
||||
sgWriteShort( fp, (short)tris_n[i][j] );
|
||||
}
|
||||
if ( tris_c.size() ) {
|
||||
sgWriteShort( fp, (short)tris_c[i][j] );
|
||||
}
|
||||
if ( tris_tc.size() ) {
|
||||
sgWriteShort( fp, (short)tris_tc[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,20 +931,40 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
|
||||
// write group headers
|
||||
sgWriteChar( fp, (char)SG_TRIANGLE_STRIPS ); // type
|
||||
sgWriteShort( fp, 1 ); // nproperties
|
||||
sgWriteShort( fp, 2 ); // nproperties
|
||||
sgWriteShort( fp, end - start ); // nelements
|
||||
|
||||
sgWriteChar( fp, (char)SG_MATERIAL ); // property
|
||||
sgWriteUInt( fp, material.length() ); // nbytes
|
||||
sgWriteBytes( fp, material.length(), material.c_str() );
|
||||
|
||||
idx_mask = 0;
|
||||
idx_size = 0;
|
||||
if ( strips_v.size() ) { idx_mask |= SG_IDX_VERTICES; ++idx_size; }
|
||||
if ( strips_n.size() ) { idx_mask |= SG_IDX_NORMALS; ++idx_size; }
|
||||
if ( strips_c.size() ) { idx_mask |= SG_IDX_COLORS; ++idx_size; }
|
||||
if ( strips_tc.size() ) { idx_mask |= SG_IDX_TEXCOORDS; ++idx_size;}
|
||||
sgWriteChar( fp, (char)SG_INDEX_TYPES ); // property
|
||||
sgWriteUInt( fp, 1 ); // nbytes
|
||||
sgWriteChar( fp, idx_mask );
|
||||
|
||||
// write strips
|
||||
for ( i = start; i < end; ++i ) {
|
||||
// nbytes
|
||||
sgWriteUInt( fp, strips_v[i].size() * 2 * sizeof(short) );
|
||||
sgWriteUInt( fp, strips_v[i].size() * idx_size * sizeof(short));
|
||||
for ( j = 0; j < (int)strips_v[i].size(); ++j ) {
|
||||
sgWriteShort( fp, (short)strips_v[i][j] );
|
||||
sgWriteShort( fp, (short)strips_tc[i][j] );
|
||||
if ( strips_v.size() ) {
|
||||
sgWriteShort( fp, (short)strips_v[i][j] );
|
||||
}
|
||||
if ( strips_n.size() ) {
|
||||
sgWriteShort( fp, (short)strips_n[i][j] );
|
||||
}
|
||||
if ( strips_c.size() ) {
|
||||
sgWriteShort( fp, (short)strips_c[i][j] );
|
||||
}
|
||||
if ( strips_tc.size() ) {
|
||||
sgWriteShort( fp, (short)strips_tc[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,20 +991,40 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
|
||||
// write group headers
|
||||
sgWriteChar( fp, (char)SG_TRIANGLE_FANS ); // type
|
||||
sgWriteShort( fp, 1 ); // nproperties
|
||||
sgWriteShort( fp, 2 ); // nproperties
|
||||
sgWriteShort( fp, end - start ); // nelements
|
||||
|
||||
sgWriteChar( fp, (char)SG_MATERIAL ); // property
|
||||
sgWriteUInt( fp, material.length() ); // nbytes
|
||||
sgWriteBytes( fp, material.length(), material.c_str() );
|
||||
|
||||
idx_mask = 0;
|
||||
idx_size = 0;
|
||||
if ( fans_v.size() ) { idx_mask |= SG_IDX_VERTICES; ++idx_size; }
|
||||
if ( fans_n.size() ) { idx_mask |= SG_IDX_NORMALS; ++idx_size; }
|
||||
if ( fans_c.size() ) { idx_mask |= SG_IDX_COLORS; ++idx_size; }
|
||||
if ( fans_tc.size() ) { idx_mask |= SG_IDX_TEXCOORDS; ++idx_size; }
|
||||
sgWriteChar( fp, (char)SG_INDEX_TYPES ); // property
|
||||
sgWriteUInt( fp, 1 ); // nbytes
|
||||
sgWriteChar( fp, idx_mask );
|
||||
|
||||
// write fans
|
||||
for ( i = start; i < end; ++i ) {
|
||||
// nbytes
|
||||
sgWriteUInt( fp, fans_v[i].size() * 2 * sizeof(short) );
|
||||
sgWriteUInt( fp, fans_v[i].size() * idx_size * sizeof(short) );
|
||||
for ( j = 0; j < (int)fans_v[i].size(); ++j ) {
|
||||
sgWriteShort( fp, (short)fans_v[i][j] );
|
||||
sgWriteShort( fp, (short)fans_tc[i][j] );
|
||||
if ( fans_v.size() ) {
|
||||
sgWriteShort( fp, (short)fans_v[i][j] );
|
||||
}
|
||||
if ( fans_n.size() ) {
|
||||
sgWriteShort( fp, (short)fans_n[i][j] );
|
||||
}
|
||||
if ( fans_c.size() ) {
|
||||
sgWriteShort( fp, (short)fans_c[i][j] );
|
||||
}
|
||||
if ( fans_tc.size() ) {
|
||||
sgWriteShort( fp, (short)fans_tc[i][j] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,7 +1056,7 @@ bool SGBinObject::write_ascii( const string& base, const string& name,
|
||||
|
||||
string dir = base + "/" + b.gen_base_path();
|
||||
string command = "mkdir -p " + dir;
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
system( (string("mkdir ") + dir).c_str() );
|
||||
#else
|
||||
system(command.c_str());
|
||||
|
||||
@@ -70,7 +70,7 @@ typedef group_list::const_iterator const_group_list_iterator;
|
||||
* - property: prop_typecode, nbytes, BYTE+
|
||||
*
|
||||
* - obj_typecode: bounding sphere | vertices | normals | texcoords |
|
||||
* triangles | fans | strips
|
||||
* points | triangles | fans | strips
|
||||
*
|
||||
* - prop_typecode: material_name | ???
|
||||
*
|
||||
@@ -91,18 +91,35 @@ class SGBinObject {
|
||||
|
||||
Point3D gbs_center;
|
||||
float gbs_radius;
|
||||
point_list wgs84_nodes;
|
||||
point_list normals;
|
||||
point_list texcoords;
|
||||
group_list tris_v;
|
||||
group_list tris_tc;
|
||||
string_list tri_materials;
|
||||
group_list strips_v;
|
||||
group_list strips_tc;
|
||||
string_list strip_materials;
|
||||
group_list fans_v;
|
||||
group_list fans_tc;
|
||||
string_list fan_materials;
|
||||
|
||||
point_list wgs84_nodes; // vertex list
|
||||
point_list colors; // color list
|
||||
point_list normals; // normal list
|
||||
point_list texcoords; // texture coordinate list
|
||||
|
||||
group_list pts_v; // points vertex index
|
||||
group_list pts_n; // points normal index
|
||||
group_list pts_c; // points color index
|
||||
group_list pts_tc; // points texture coordinate index
|
||||
string_list pt_materials; // points materials
|
||||
|
||||
group_list tris_v; // triangles vertex index
|
||||
group_list tris_n; // triangles normal index
|
||||
group_list tris_c; // triangles color index
|
||||
group_list tris_tc; // triangles texture coordinate index
|
||||
string_list tri_materials; // triangles materials
|
||||
|
||||
group_list strips_v; // tristrips vertex index
|
||||
group_list strips_n; // tristrips normal index
|
||||
group_list strips_c; // tristrips color index
|
||||
group_list strips_tc; // tristrips texture coordinate index
|
||||
string_list strip_materials;// tristrips materials
|
||||
|
||||
group_list fans_v; // fans vertex index
|
||||
group_list fans_n; // fans normal index
|
||||
group_list fans_c; // fans color index
|
||||
group_list fans_tc; // fans texture coordinate index
|
||||
string_list fan_materials; // fans materials
|
||||
|
||||
public:
|
||||
|
||||
@@ -117,14 +134,32 @@ public:
|
||||
inline point_list get_wgs84_nodes() const { return wgs84_nodes; }
|
||||
inline void set_wgs84_nodes( point_list n ) { wgs84_nodes = n; }
|
||||
|
||||
inline point_list get_colors() const { return colors; }
|
||||
inline void set_colors( point_list c ) { colors = c; }
|
||||
|
||||
inline point_list get_normals() const { return normals; }
|
||||
inline void set_normals( point_list n ) { normals = n; }
|
||||
|
||||
inline point_list get_texcoords() const { return texcoords; }
|
||||
inline void set_texcoords( point_list t ) { texcoords = t; }
|
||||
|
||||
inline group_list get_pts_v() const { return pts_v; }
|
||||
inline void set_pts_v( group_list g ) { pts_v = g; }
|
||||
inline group_list get_pts_n() const { return pts_n; }
|
||||
inline void set_pts_n( group_list g ) { pts_n = g; }
|
||||
inline group_list get_pts_c() const { return pts_c; }
|
||||
inline void set_pts_c( group_list g ) { pts_c = g; }
|
||||
inline group_list get_pts_tc() const { return pts_tc; }
|
||||
inline void set_pts_tc( group_list g ) { pts_tc = g; }
|
||||
inline string_list get_pt_materials() const { return pt_materials; }
|
||||
inline void set_pt_materials( string_list s ) { pt_materials = s; }
|
||||
|
||||
inline group_list get_tris_v() const { return tris_v; }
|
||||
inline void set_tris_v( group_list g ) { tris_v = g; }
|
||||
inline group_list get_tris_n() const { return tris_n; }
|
||||
inline void set_tris_n( group_list g ) { tris_n = g; }
|
||||
inline group_list get_tris_c() const { return tris_c; }
|
||||
inline void set_tris_c( group_list g ) { tris_c = g; }
|
||||
inline group_list get_tris_tc() const { return tris_tc; }
|
||||
inline void set_tris_tc( group_list g ) { tris_tc = g; }
|
||||
inline string_list get_tri_materials() const { return tri_materials; }
|
||||
@@ -132,6 +167,10 @@ public:
|
||||
|
||||
inline group_list get_strips_v() const { return strips_v; }
|
||||
inline void set_strips_v( group_list g ) { strips_v = g; }
|
||||
inline group_list get_strips_n() const { return strips_n; }
|
||||
inline void set_strips_n( group_list g ) { strips_n = g; }
|
||||
inline group_list get_strips_c() const { return strips_c; }
|
||||
inline void set_strips_c( group_list g ) { strips_c = g; }
|
||||
inline group_list get_strips_tc() const { return strips_tc; }
|
||||
inline void set_strips_tc( group_list g ) { strips_tc = g; }
|
||||
inline string_list get_strip_materials() const { return strip_materials; }
|
||||
@@ -139,6 +178,10 @@ public:
|
||||
|
||||
inline group_list get_fans_v() const { return fans_v; }
|
||||
inline void set_fans_v( group_list g ) { fans_v = g; }
|
||||
inline group_list get_fans_n() const { return fans_n; }
|
||||
inline void set_fans_n( group_list g ) { fans_n = g; }
|
||||
inline group_list get_fans_c() const { return fans_c; }
|
||||
inline void set_fans_c( group_list g ) { fans_c = g; }
|
||||
inline group_list get_fans_tc() const { return fans_tc; }
|
||||
inline void set_fans_tc( group_list g ) { fans_tc = g; }
|
||||
inline string_list get_fan_materials() const { return fan_materials; }
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,7 @@ bool SGFile::open( const SGProtocolDir d ) {
|
||||
set_dir( d );
|
||||
|
||||
if ( get_dir() == SG_IO_OUT ) {
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
int mode = 00666;
|
||||
#else
|
||||
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
# include <sys/time.h> // select()
|
||||
# include <sys/types.h> // socket(), bind(), select(), accept()
|
||||
# include <sys/socket.h> // socket(), bind(), listen(), accept()
|
||||
@@ -48,7 +48,7 @@ SGSocket::SGSocket( const string& host, const string& port,
|
||||
port_str(port),
|
||||
save_len(0)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
if (!wsock_init && !wsastartup()) {
|
||||
SG_LOG( SG_IO, SG_ALERT, "Winsock not available");
|
||||
}
|
||||
@@ -75,7 +75,7 @@ SGSocket::~SGSocket() {
|
||||
SGSocket::SocketType SGSocket::make_server_socket () {
|
||||
struct sockaddr_in name;
|
||||
|
||||
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ ) || defined( sgi ) || defined( _MSC_VER )
|
||||
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ ) || defined( sgi ) || defined( _MSC_VER ) || defined(__MINGW32__) || defined( __APPLE__ )
|
||||
int length;
|
||||
#else
|
||||
socklen_t length;
|
||||
@@ -161,7 +161,7 @@ SGSocket::SocketType SGSocket::make_client_socket () {
|
||||
|
||||
// Wrapper functions
|
||||
size_t SGSocket::readsocket( int fd, void *buf, size_t count ) {
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
return ::recv( fd, (char *)buf, count, 0 );
|
||||
#else
|
||||
return ::read( fd, buf, count );
|
||||
@@ -169,14 +169,14 @@ size_t SGSocket::readsocket( int fd, void *buf, size_t count ) {
|
||||
}
|
||||
|
||||
size_t SGSocket::writesocket( int fd, const void *buf, size_t count ) {
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
return ::send( fd, (const char*)buf, count, 0 );
|
||||
#else
|
||||
return ::write( fd, buf, count );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
int SGSocket::closesocket( int fd ) {
|
||||
return ::close( fd );
|
||||
}
|
||||
@@ -339,9 +339,8 @@ int SGSocket::readline( char *buf, int length ) {
|
||||
// cout << "sock_stream\n";
|
||||
if ( msgsock == INVALID_SOCKET ) {
|
||||
// cout << "msgsock == invalid\n";
|
||||
msgsock = accept(sock, 0, 0);
|
||||
closesocket(sock);
|
||||
sock = msgsock;
|
||||
msgsock = sock;
|
||||
sock = accept(msgsock, 0, 0);
|
||||
} else {
|
||||
// cout << "ready to read\n";
|
||||
char *buf_ptr = save_buf + save_len;
|
||||
@@ -361,8 +360,7 @@ int SGSocket::readline( char *buf, int length ) {
|
||||
if ( result == 0 && save_len == 0 && first_read == true ) {
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"Connection closed by foreign host." );
|
||||
closesocket(sock);
|
||||
open( get_dir() );
|
||||
close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -494,6 +492,10 @@ bool SGSocket::close() {
|
||||
}
|
||||
|
||||
closesocket( sock );
|
||||
if ( sock_style == SOCK_STREAM && msgsock != INVALID_SOCKET ) {
|
||||
sock = msgsock;
|
||||
msgsock = INVALID_SOCKET;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -504,7 +506,7 @@ bool SGSocket::nonblock() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
u_long arg = 1;
|
||||
if (ioctlsocket( sock, FIONBIO, &arg ) != 0) {
|
||||
int error_code = WSAGetLastError();
|
||||
@@ -519,7 +521,7 @@ bool SGSocket::nonblock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
|
||||
bool SGSocket::wsock_init = false;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
SG_USING_STD(string);
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
# include <winsock.h>
|
||||
#endif
|
||||
|
||||
@@ -53,7 +53,7 @@ SG_USING_STD(string);
|
||||
*/
|
||||
class SGSocket : public SGIOChannel {
|
||||
public:
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
typedef SOCKET SocketType;
|
||||
#else
|
||||
typedef int SocketType;
|
||||
@@ -83,11 +83,11 @@ private:
|
||||
// wrapper functions
|
||||
size_t readsocket( int fd, void *buf, size_t count );
|
||||
size_t writesocket( int fd, const void *buf, size_t count );
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
int closesocket(int fd);
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
// Ensure winsock has been initialised.
|
||||
static bool wsock_init;
|
||||
static bool wsastartup();
|
||||
|
||||
202
simgear/io/sg_socket_udp.cxx
Normal file
202
simgear/io/sg_socket_udp.cxx
Normal file
@@ -0,0 +1,202 @@
|
||||
// sg_socket.cxx -- Socket I/O routines
|
||||
//
|
||||
// Written by Curtis Olson, started November 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#if defined( sgi )
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "sg_socket_udp.hxx"
|
||||
|
||||
|
||||
SGSocketUDP::SGSocketUDP( const string& host, const string& port ) :
|
||||
hostname(host),
|
||||
port_str(port),
|
||||
save_len(0)
|
||||
{
|
||||
set_valid( false );
|
||||
}
|
||||
|
||||
|
||||
SGSocketUDP::~SGSocketUDP() {
|
||||
}
|
||||
|
||||
|
||||
// If specified as a server (in direction for now) open the master
|
||||
// listening socket. If specified as a client (out direction), open a
|
||||
// connection to a server.
|
||||
bool SGSocketUDP::open( const SGProtocolDir d ) {
|
||||
set_dir( d );
|
||||
|
||||
if ( ! sock.open( false ) ) { // open a UDP socket
|
||||
SG_LOG( SG_IO, SG_ALERT, "error opening socket" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( port_str == "" || port_str == "any" ) {
|
||||
port = 0;
|
||||
} else {
|
||||
port = atoi( port_str.c_str() );
|
||||
}
|
||||
|
||||
// client_connections.clear();
|
||||
|
||||
if ( get_dir() == SG_IO_IN ) {
|
||||
// this means server
|
||||
|
||||
// bind ...
|
||||
if ( sock.bind( hostname.c_str(), port ) == -1 ) {
|
||||
SG_LOG( SG_IO, SG_ALERT, "error binding to port" << port_str );
|
||||
return false;
|
||||
}
|
||||
} else if ( get_dir() == SG_IO_OUT ) {
|
||||
// this means client
|
||||
|
||||
// connect ...
|
||||
if ( sock.connect( hostname.c_str(), port ) == -1 ) {
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"error connecting to " << hostname << port_str );
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
SG_LOG( SG_IO, SG_ALERT,
|
||||
"Error: bidirection mode not available for UDP sockets." );
|
||||
return false;
|
||||
}
|
||||
|
||||
set_valid( true );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// read data from socket (server)
|
||||
// read a block of data of specified size
|
||||
int SGSocketUDP::read( char *buf, int length ) {
|
||||
if ( ! isvalid() ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int result;
|
||||
|
||||
if ( (result = sock.recv(buf, SG_IO_MAX_MSG_SIZE, 0)) >= 0 ) {
|
||||
buf[result] = '\0';
|
||||
// printf("msg received = %s\n", buf);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// read a line of data, length is max size of input buffer
|
||||
int SGSocketUDP::readline( char *buf, int length ) {
|
||||
if ( ! isvalid() ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cout << "sock = " << sock << endl;
|
||||
|
||||
char *buf_ptr = save_buf + save_len;
|
||||
int result = sock.recv(buf_ptr, SG_IO_MAX_MSG_SIZE, 0);
|
||||
// printf("msg received = %s\n", buf);
|
||||
save_len += result;
|
||||
|
||||
// look for the end of line in save_buf
|
||||
int i;
|
||||
for ( i = 0; i < save_len && save_buf[i] != '\n'; ++i );
|
||||
if ( save_buf[i] == '\n' ) {
|
||||
result = i + 1;
|
||||
} else {
|
||||
// no end of line yet
|
||||
// cout << "no eol found" << endl;
|
||||
return 0;
|
||||
}
|
||||
// cout << "line length = " << result << endl;
|
||||
|
||||
// we found an end of line
|
||||
|
||||
// copy to external buffer
|
||||
strncpy( buf, save_buf, result );
|
||||
buf[result] = '\0';
|
||||
// cout << "sg_socket line = " << buf << endl;
|
||||
|
||||
// shift save buffer
|
||||
for ( i = result; i < save_len; ++i ) {
|
||||
save_buf[ i - result ] = save_buf[i];
|
||||
}
|
||||
save_len -= result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// write data to socket (client)
|
||||
int SGSocketUDP::write( const char *buf, const int length ) {
|
||||
if ( ! isvalid() ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool error_condition = false;
|
||||
|
||||
if ( sock.send( buf, length, 0 ) < 0 ) {
|
||||
SG_LOG( SG_IO, SG_ALERT, "Error writing to socket: " << port );
|
||||
error_condition = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
// write null terminated string to socket (server)
|
||||
int SGSocketUDP::writestring( const char *str ) {
|
||||
if ( !isvalid() ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int length = strlen( str );
|
||||
return write( str, length );
|
||||
}
|
||||
|
||||
|
||||
// close the port
|
||||
bool SGSocketUDP::close() {
|
||||
if ( !isvalid() ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sock.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// configure the socket as non-blocking
|
||||
bool SGSocketUDP::setBlocking( bool value ) {
|
||||
sock.setBlocking( value );
|
||||
|
||||
return true;
|
||||
}
|
||||
138
simgear/io/sg_socket_udp.hxx
Normal file
138
simgear/io/sg_socket_udp.hxx
Normal file
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* \file sg_socket_udp.hxx
|
||||
* UDP Socket I/O routines.
|
||||
*/
|
||||
|
||||
// Written by Curtis Olson, started November 2001.
|
||||
//
|
||||
// Copyright (C) 2001 Curtis L. Olson - curt@flightgear.org
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#ifndef _SG_SOCKET_UDP_HXX
|
||||
#define _SG_SOCKET_UDP_HXX
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
||||
#include <plib/netSocket.h>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
#include <simgear/math/sg_types.hxx>
|
||||
#include <simgear/io/iochannel.hxx>
|
||||
|
||||
SG_USING_STD(string);
|
||||
|
||||
/**
|
||||
* A UDP socket I/O class based on SGIOChannel and plib/net.
|
||||
*/
|
||||
class SGSocketUDP : public SGIOChannel {
|
||||
|
||||
private:
|
||||
|
||||
netSocket sock;
|
||||
|
||||
string hostname;
|
||||
string port_str;
|
||||
|
||||
char save_buf[ 2 * SG_IO_MAX_MSG_SIZE ];
|
||||
int save_len;
|
||||
|
||||
short unsigned int port;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create an instance of SGSocketUDP.
|
||||
*
|
||||
* When calling the constructor you need to provide a host name, and a
|
||||
* port number. The convention used by the
|
||||
* SGSocketUDP class is that the server side listens and the client
|
||||
* side sends. For a server socket, the host name should be
|
||||
* empty. For a server, the port number is optional, if you do not
|
||||
* specify a port, the system will assign one. For a client
|
||||
* socket, you need to specify both a destination host and
|
||||
* destination port.
|
||||
*
|
||||
* UDP sockets are a lower level protocol than TCP sockets and are
|
||||
* "connectionless" in the sense that either client or server can
|
||||
* exist, or not exist, startup, quit, etc. in any order and
|
||||
* whenever both ends are alive, the communication succeeds. With
|
||||
* UDP sockets, the server end just sits and listens for incoming
|
||||
* packets from anywhere. The client end sends it's message and
|
||||
* forgets about it. It doesn't care if there isn't even a server
|
||||
* out there listening and all the packets are getting
|
||||
* lost. Although systems/networks usually do a pretty good job
|
||||
* (statistically) of getting your UDP packets to their
|
||||
* destination, there is no guarantee that any particular packet
|
||||
* will make it. But, because of this low level implementation and
|
||||
* lack of error checking, UDP packets are much faster and
|
||||
* efficient. UDP packets are good for sending positional
|
||||
* information to synchronize two applications. In this case, you
|
||||
* want the information to arrive as quickly as possible, and if
|
||||
* you lose a packet, you'd rather get new updated information
|
||||
* rather than have the system waste time resending a packet that
|
||||
* is becoming older and older with every retry.
|
||||
* @param host name of host if direction is SG_IO_OUT or SG_IO_BI
|
||||
* @param port port number if we care to choose one.
|
||||
* @param style specify "udp" or "tcp" */
|
||||
SGSocketUDP( const string& host, const string& port );
|
||||
|
||||
/** Destructor */
|
||||
~SGSocketUDP();
|
||||
|
||||
// If specified as a server (in direction for now) open the master
|
||||
// listening socket. If specified as a client (out direction),
|
||||
// open a connection to a server.
|
||||
bool open( const SGProtocolDir d );
|
||||
|
||||
// read data from socket
|
||||
int read( char *buf, int length );
|
||||
|
||||
// read data from socket
|
||||
int readline( char *buf, int length );
|
||||
|
||||
// write data to a socket
|
||||
int write( const char *buf, const int length );
|
||||
|
||||
// write null terminated string to a socket
|
||||
int writestring( const char *str );
|
||||
|
||||
// close file
|
||||
bool close();
|
||||
|
||||
/**
|
||||
* Set blocking true or false
|
||||
* @return success/failure
|
||||
*/
|
||||
bool setBlocking( bool value );
|
||||
|
||||
/** @return the remote host name */
|
||||
inline string get_hostname() const { return hostname; }
|
||||
|
||||
/** @return the port number (in string form) */
|
||||
inline string get_port_str() const { return port_str; }
|
||||
};
|
||||
|
||||
|
||||
#endif // _SG_SOCKET_UDP_HXX
|
||||
@@ -41,6 +41,10 @@ int main() {
|
||||
if ( s.readline( buf, 256 ) > 0 ) {
|
||||
cout << "result = " << buf;
|
||||
}
|
||||
#ifdef __MINGW32__
|
||||
Sleep(100);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
4
simgear/magvar/.cvsignore
Normal file
4
simgear/magvar/.cvsignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
testmagvar
|
||||
@@ -14,4 +14,8 @@ testmagvar_SOURCES = testmagvar.cxx
|
||||
|
||||
testmagvar_LDADD = $(top_builddir)/simgear/magvar/libsgmagvar.a
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -45,9 +45,9 @@ if (argc == 8){
|
||||
var = calc_magvar( SGD_DEGREES_TO_RADIANS * lat_deg, SGD_DEGREES_TO_RADIANS * lon_deg, h,
|
||||
yymmdd_to_julian_days(yy,mm,dd), field );
|
||||
|
||||
fprintf(stdout,"%6.0lf %6.0lf %6.0lf\n", field[0], field[1], field[2] );
|
||||
fprintf(stdout,"%6.0lf %6.0lf %6.0lf\n", field[3], field[4], field[5] );
|
||||
fprintf(stdout,"%6.0lf %6.0lf %6.0lf %4.2lf %4.2lf \n",
|
||||
fprintf(stdout,"%6.0f %6.0f %6.0f\n", field[0], field[1], field[2] );
|
||||
fprintf(stdout,"%6.0f %6.0f %6.0f\n", field[3], field[4], field[5] );
|
||||
fprintf(stdout,"%6.0f %6.0f %6.0f %4.2f %4.2f \n",
|
||||
field[3],field[4],field[5],
|
||||
SGD_RADIANS_TO_DEGREES * (atan(field[5]/pow(field[3]*field[3]+field[4]*field[4],0.5))),
|
||||
SGD_RADIANS_TO_DEGREES * var);
|
||||
|
||||
3
simgear/math/.cvsignore
Normal file
3
simgear/math/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,11 +1,5 @@
|
||||
includedir = @includedir@/math
|
||||
|
||||
if HAVE_ZLIB
|
||||
ZLIB_INCL =
|
||||
else
|
||||
ZLIB_INCL = -I$(top_srcdir)/src/zlib
|
||||
endif
|
||||
|
||||
lib_LIBRARIES = libsgmath.a
|
||||
|
||||
include_HEADERS = \
|
||||
@@ -30,4 +24,8 @@ libsgmath_a_SOURCES = \
|
||||
sg_random.c \
|
||||
vector.cxx
|
||||
|
||||
INCLUDES += -I$(top_srcdir) $(ZLIB_INCL)
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
3
simgear/metar/.cvsignore
Normal file
3
simgear/metar/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,13 +1,5 @@
|
||||
#pragma comment(compiler)
|
||||
#pragma comment(date)
|
||||
#pragma comment(timestamp)
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#pragma title("antoi - char array to integer")
|
||||
#pragma pagesize (80)
|
||||
|
||||
#pragma page(1)
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: antoi */
|
||||
@@ -78,4 +70,3 @@ int antoi(char * string, int len)
|
||||
|
||||
} /* end antoi */
|
||||
|
||||
#pragma page(1)
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
#pragma comment (compiler)
|
||||
//#pragma comment (date)
|
||||
//#pragma comment (timestamp)
|
||||
#pragma pagesize(80)
|
||||
|
||||
#include "Local.h" /* standard header file */
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("charcmp - characters compare with patterns ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: charcmp */
|
||||
@@ -34,7 +26,6 @@
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
bool charcmp(char *str, char *pattern)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
#pragma comment (compiler)
|
||||
//#pragma comment (date)
|
||||
//#pragma comment (timestamp)
|
||||
#pragma pagesize(80)
|
||||
|
||||
|
||||
#include "Local.h" /* standard header file */
|
||||
#include "Metar.h" /* standard header file */
|
||||
|
||||
@@ -11,9 +5,6 @@ float fracPart( char * );
|
||||
void DcdMTRmk( char **, Decoded_METAR * );
|
||||
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma subtitle("subtitle - Decode METAR report. ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: SaveTokenString */
|
||||
@@ -46,7 +37,6 @@ void DcdMTRmk( char **, Decoded_METAR * );
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static char **SaveTokenString ( char *string , char *delimeters )
|
||||
{
|
||||
@@ -99,9 +89,6 @@ static char **SaveTokenString ( char *string , char *delimeters )
|
||||
return token;
|
||||
|
||||
}
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma subtitle("subtitle - Decode METAR report. ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: freeTokens */
|
||||
@@ -124,7 +111,6 @@ static char **SaveTokenString ( char *string , char *delimeters )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static void freeTokens( char **token )
|
||||
{
|
||||
@@ -138,9 +124,6 @@ static void freeTokens( char **token )
|
||||
}
|
||||
return;
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: InitDcdMETAR */
|
||||
@@ -163,7 +146,6 @@ static void freeTokens( char **token )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static void InitDcdMETAR( Decoded_METAR *Mptr )
|
||||
{
|
||||
|
||||
@@ -439,9 +421,6 @@ static void InitDcdMETAR( Decoded_METAR *Mptr )
|
||||
return;
|
||||
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: ResetMETARGroup */
|
||||
@@ -475,8 +454,7 @@ static void InitDcdMETAR( Decoded_METAR *Mptr )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static int ResetMETARGroup( int StartGroup,
|
||||
/*static int ResetMETARGroup( int StartGroup,
|
||||
int SaveStartGroup )
|
||||
{
|
||||
|
||||
@@ -495,11 +473,8 @@ static int ResetMETARGroup( int StartGroup,
|
||||
return (++SaveStartGroup);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: CodedHgt2Meters */
|
||||
@@ -523,7 +498,6 @@ static int ResetMETARGroup( int StartGroup,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static int CodedHgt2Meters( char *token, Decoded_METAR *Mptr )
|
||||
{
|
||||
@@ -537,10 +511,6 @@ static int CodedHgt2Meters( char *token, Decoded_METAR *Mptr )
|
||||
return (hgt*30);
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPartObscur */
|
||||
@@ -574,7 +544,6 @@ static int CodedHgt2Meters( char *token, Decoded_METAR *Mptr )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isPartObscur( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -617,10 +586,6 @@ static bool isPartObscur( char **string, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isCldLayer */
|
||||
@@ -650,7 +615,6 @@ static bool isPartObscur( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isCldLayer( char *token )
|
||||
{
|
||||
@@ -671,10 +635,6 @@ static bool isCldLayer( char *token )
|
||||
nisdigit((token+3),3)) ? TRUE:FALSE;
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isCAVOK */
|
||||
@@ -701,7 +661,6 @@ static bool isCldLayer( char *token )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isCAVOK( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
@@ -718,9 +677,6 @@ static bool isCAVOK( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
}
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: parseCldData */
|
||||
@@ -742,7 +698,6 @@ static bool isCAVOK( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static void parseCldData( char *token, Decoded_METAR *Mptr, int next)
|
||||
{
|
||||
@@ -766,9 +721,6 @@ static void parseCldData( char *token, Decoded_METAR *Mptr, int next)
|
||||
}
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isSkyCond */
|
||||
@@ -790,7 +742,6 @@ static void parseCldData( char *token, Decoded_METAR *Mptr, int next)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isSkyCond( char **skycond, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -989,9 +940,6 @@ static bool isSkyCond( char **skycond, Decoded_METAR *Mptr,
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: prevailVSBY */
|
||||
@@ -1013,7 +961,6 @@ static bool isSkyCond( char **skycond, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static float prevailVSBY( char *visibility )
|
||||
{
|
||||
float Miles_vsby;
|
||||
@@ -1061,9 +1008,6 @@ static float prevailVSBY( char *visibility )
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isVisibility */
|
||||
@@ -1086,7 +1030,6 @@ static float prevailVSBY( char *visibility )
|
||||
/* */
|
||||
/********************************************************************/
|
||||
|
||||
#pragma page(1)
|
||||
|
||||
static bool isVisibility( char **visblty, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
@@ -1329,9 +1272,6 @@ static bool isVisibility( char **visblty, Decoded_METAR *Mptr,
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: vrblVsby */
|
||||
@@ -1353,13 +1293,12 @@ static bool isVisibility( char **visblty, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool vrblVsby( char *string1, char *string2,
|
||||
Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
char buf[ 6 ];
|
||||
int numerator,
|
||||
denominator;
|
||||
/* int numerator,
|
||||
denominator; */
|
||||
char *slash,
|
||||
*V_char,
|
||||
*temp;
|
||||
@@ -1431,9 +1370,6 @@ static bool vrblVsby( char *string1, char *string2,
|
||||
}
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isMinMaxWinDir */
|
||||
@@ -1455,7 +1391,6 @@ static bool vrblVsby( char *string1, char *string2,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isMinMaxWinDir( char *string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -1488,9 +1423,6 @@ static bool isMinMaxWinDir( char *string, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isRVR */
|
||||
@@ -1512,7 +1444,6 @@ static bool isMinMaxWinDir( char *string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isRVR( char *token, Decoded_METAR *Mptr, int *NDEX,
|
||||
int ndex )
|
||||
@@ -1575,9 +1506,6 @@ static bool isRVR( char *token, Decoded_METAR *Mptr, int *NDEX,
|
||||
}
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isAltimStng */
|
||||
@@ -1599,7 +1527,6 @@ static bool isRVR( char *token, Decoded_METAR *Mptr, int *NDEX,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isAltimStng( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
@@ -1648,9 +1575,6 @@ static bool isAltimStng( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
}
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isTempGroup */
|
||||
@@ -1672,7 +1596,6 @@ static bool isAltimStng( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isTempGroup( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -1768,9 +1691,6 @@ static bool isTempGroup( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isWxToken */
|
||||
@@ -1792,27 +1712,23 @@ static bool isTempGroup( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isWxToken( char *token )
|
||||
/*static bool isWxToken( char *token )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( token == NULL )
|
||||
return FALSE;
|
||||
for( i = 0; i < strlen(token); i++ )
|
||||
for( i = 0; i < (int)strlen(token); i++ )
|
||||
{
|
||||
if( !(isalpha(*(token+i)) || *(token+i) == '+' ||
|
||||
*(token+i) == '-' ) )
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPresentWX */
|
||||
@@ -1834,7 +1750,6 @@ static bool isWxToken( char *token )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isPresentWX( char *token, Decoded_METAR *Mptr,
|
||||
int *NDEX, int *next )
|
||||
@@ -1929,9 +1844,6 @@ static bool isPresentWX( char *token, Decoded_METAR *Mptr,
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isStnID */
|
||||
@@ -1953,7 +1865,6 @@ static bool isPresentWX( char *token, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isStnId( char *stnID, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -1976,9 +1887,6 @@ static bool isStnId( char *stnID, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isCodeName */
|
||||
@@ -2000,7 +1908,6 @@ static bool isStnId( char *stnID, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isCodeName( char *codename, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -2020,9 +1927,6 @@ static bool isCodeName( char *codename, Decoded_METAR *Mptr, int *NDEX)
|
||||
}
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isNIL */
|
||||
@@ -2044,7 +1948,6 @@ static bool isCodeName( char *codename, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isNIL( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -2063,9 +1966,6 @@ static bool isNIL( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isAUTO */
|
||||
@@ -2087,7 +1987,6 @@ static bool isNIL( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isAUTO( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -2106,9 +2005,6 @@ static bool isAUTO( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isCOR */
|
||||
@@ -2130,7 +2026,6 @@ static bool isAUTO( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isCOR ( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -2149,9 +2044,6 @@ static bool isCOR ( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isTimeUTC */
|
||||
@@ -2173,7 +2065,6 @@ static bool isCOR ( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isTimeUTC( char *UTC, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
@@ -2228,9 +2119,6 @@ static bool isTimeUTC( char *UTC, Decoded_METAR *Mptr, int *NDEX )
|
||||
}
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isWindData */
|
||||
@@ -2252,7 +2140,6 @@ static bool isTimeUTC( char *UTC, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isWindData( char *wind, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
@@ -2322,9 +2209,6 @@ static bool isWindData( char *wind, Decoded_METAR *Mptr, int *NDEX )
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma subtitle("subtitle - Decode METAR report. ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: DcdMETAR */
|
||||
@@ -2349,7 +2233,6 @@ static bool isWindData( char *wind, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
|
||||
int DcdMETAR( char *string , Decoded_METAR *Mptr )
|
||||
@@ -2365,17 +2248,14 @@ int DcdMETAR( char *string , Decoded_METAR *Mptr )
|
||||
CAVOK, visibility,
|
||||
RVR, presentWX, PartialObscur,
|
||||
skyCond, tempGroup,
|
||||
altimStng, NotIDed = 99} StartGroup,
|
||||
SaveStartGroup,
|
||||
MetarGroup;
|
||||
altimStng, NotIDed = 99 }
|
||||
StartGroup, SaveStartGroup, MetarGroup;
|
||||
|
||||
WindStruct *WinDataPtr;
|
||||
// WindStruct *WinDataPtr;
|
||||
|
||||
int ndex,
|
||||
NDEX,
|
||||
i,
|
||||
jkj,
|
||||
j;
|
||||
int ndex;
|
||||
int NDEX;
|
||||
// int i, jkj, j;
|
||||
|
||||
|
||||
char **token,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include "Local.h" /* standard header file */
|
||||
#include "Metar.h"
|
||||
|
||||
#define SKY1_len 50
|
||||
float fracPart( char * );
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isTS_LOC */
|
||||
@@ -46,7 +45,6 @@ float fracPart( char * );
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isTS_LOC( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
@@ -132,9 +130,6 @@ static bool isTS_LOC( char **string, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isDVR */
|
||||
@@ -156,7 +151,6 @@ static bool isTS_LOC( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isDVR( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
@@ -215,9 +209,6 @@ static bool isDVR( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
}
|
||||
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isTornadicActiv */
|
||||
@@ -258,7 +249,6 @@ static bool isDVR( char *token, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isTornadicActiv( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
@@ -529,9 +519,6 @@ static bool isTornadicActiv( char **string, Decoded_METAR *Mptr,
|
||||
}
|
||||
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPartObscur */
|
||||
@@ -574,7 +561,6 @@ static bool isTornadicActiv( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isPartObscur( char **string, Decoded_METAR *Mptr,
|
||||
int ndex, int *NDEX )
|
||||
{
|
||||
@@ -675,9 +661,6 @@ static bool isPartObscur( char **string, Decoded_METAR *Mptr,
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isA0indicator */
|
||||
@@ -718,7 +701,6 @@ static bool isPartObscur( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isA0indicator( char *indicator, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
@@ -761,9 +743,6 @@ static bool isA0indicator( char *indicator, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPeakWind */
|
||||
@@ -803,7 +782,6 @@ static bool isA0indicator( char *indicator, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isPeakWind( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -896,9 +874,6 @@ static bool isPeakWind( char **string, Decoded_METAR *Mptr,
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isWindShift */
|
||||
@@ -938,7 +913,6 @@ static bool isPeakWind( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isWindShift( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX)
|
||||
{
|
||||
@@ -1028,9 +1002,6 @@ static bool isWindShift( char **string, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isTowerVsby */
|
||||
@@ -1069,7 +1040,6 @@ static bool isWindShift( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isTowerVsby( char **token, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
|
||||
@@ -1184,9 +1154,6 @@ static bool isTowerVsby( char **token, Decoded_METAR *Mptr, int *NDEX)
|
||||
}
|
||||
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isSurfaceVsby */
|
||||
@@ -1225,7 +1192,6 @@ static bool isTowerVsby( char **token, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isSurfaceVsby( char **token, Decoded_METAR *Mptr,
|
||||
int *NDEX)
|
||||
{
|
||||
@@ -1342,9 +1308,6 @@ static bool isSurfaceVsby( char **token, Decoded_METAR *Mptr,
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isVariableVsby */
|
||||
@@ -1384,7 +1347,6 @@ static bool isSurfaceVsby( char **token, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isVariableVsby( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -1393,9 +1355,9 @@ static bool isVariableVsby( char **string, Decoded_METAR *Mptr,
|
||||
/* DECLARE LOCAL VARIABLES */
|
||||
/***************************/
|
||||
|
||||
char *slash,
|
||||
*slash1,
|
||||
*slash2,
|
||||
char *slash = NULL,
|
||||
*slash1 = NULL,
|
||||
*slash2 = NULL,
|
||||
buf[ 5 ],
|
||||
*V_char;
|
||||
float minimumVsby,
|
||||
@@ -1594,9 +1556,6 @@ static bool isVariableVsby( char **string, Decoded_METAR *Mptr,
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isVsby2ndSite */
|
||||
@@ -1640,7 +1599,6 @@ static bool isVariableVsby( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isVsby2ndSite( char **token, Decoded_METAR *Mptr,
|
||||
int *NDEX)
|
||||
{
|
||||
@@ -1799,9 +1757,6 @@ static bool isVsby2ndSite( char **token, Decoded_METAR *Mptr,
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isLTGfreq */
|
||||
@@ -1845,7 +1800,6 @@ static bool isVsby2ndSite( char **token, Decoded_METAR *Mptr,
|
||||
/* */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
bool static isLTGfreq( char **string, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
@@ -2086,16 +2040,8 @@ bool static isLTGfreq( char **string, Decoded_METAR *Mptr, int *NDEX )
|
||||
|
||||
|
||||
|
||||
#pragma comment (compiler)
|
||||
//#pragma comment (date)
|
||||
//#pragma comment (timestamp)
|
||||
#pragma pagesize(80)
|
||||
|
||||
#include "Metar.h" /* standard header file */
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isRecentWx */
|
||||
@@ -2139,7 +2085,6 @@ bool static isLTGfreq( char **string, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isRecentWX( char **token, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -2476,9 +2421,6 @@ static bool isRecentWX( char **token, Decoded_METAR *Mptr,
|
||||
}
|
||||
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isVariableCIG */
|
||||
@@ -2509,7 +2451,6 @@ static bool isRecentWX( char **token, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isVariableCIG( char **token, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -2542,9 +2483,6 @@ static bool isVariableCIG( char **token, Decoded_METAR *Mptr,
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isCeil2ndSite */
|
||||
@@ -2579,7 +2517,6 @@ static bool isVariableCIG( char **token, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isCIG2ndSite( char **token, Decoded_METAR *Mptr,
|
||||
int *NDEX)
|
||||
{
|
||||
@@ -2618,9 +2555,6 @@ static bool isCIG2ndSite( char **token, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPRESFR */
|
||||
@@ -2669,7 +2603,6 @@ static bool isCIG2ndSite( char **token, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isPRESFR( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -2686,9 +2619,6 @@ static bool isPRESFR( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
}
|
||||
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPRESRR */
|
||||
@@ -2737,7 +2667,6 @@ static bool isPRESFR( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isPRESRR( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -2755,9 +2684,6 @@ static bool isPRESRR( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isSLP */
|
||||
@@ -2779,7 +2705,6 @@ static bool isPRESRR( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isSLP( char **token, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
@@ -2788,8 +2713,8 @@ static bool isSLP( char **token, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* DECLARE LOCAL VARIABLES */
|
||||
/***************************/
|
||||
|
||||
int pressure,
|
||||
ndex;
|
||||
int pressure;
|
||||
// int ndex;
|
||||
|
||||
/*************************/
|
||||
/* BEGIN BODY OF ROUTINE */
|
||||
@@ -2853,7 +2778,6 @@ static bool isSLP( char **token, Decoded_METAR *Mptr, int *NDEX )
|
||||
}
|
||||
|
||||
}
|
||||
#pragma page(1)
|
||||
static bool isSectorVsby( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -2861,7 +2785,7 @@ static bool isSectorVsby( char **string, Decoded_METAR *Mptr,
|
||||
/* DECLARE LOCAL VARIABLES */
|
||||
/***************************/
|
||||
|
||||
float vsby;
|
||||
float vsby = 0.0f;
|
||||
char dd[3],
|
||||
*slash;
|
||||
|
||||
@@ -2931,9 +2855,6 @@ static bool isSectorVsby( char **string, Decoded_METAR *Mptr,
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isGR */
|
||||
@@ -2982,7 +2903,6 @@ static bool isSectorVsby( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isGR( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
char *slash;
|
||||
@@ -3065,9 +2985,6 @@ static bool isGR( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
}
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isVIRGA */
|
||||
@@ -3116,7 +3033,6 @@ static bool isGR( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isVIRGA( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -3152,7 +3068,6 @@ static bool isVIRGA( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
static bool isSfcObscuration( char *string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -3240,7 +3155,6 @@ static bool isSfcObscuration( char *string, Decoded_METAR *Mptr,
|
||||
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
static bool isCeiling( char *string, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
|
||||
@@ -3280,7 +3194,6 @@ static bool isCeiling( char *string, Decoded_METAR *Mptr, int *NDEX )
|
||||
}
|
||||
|
||||
}
|
||||
#pragma page(1)
|
||||
static bool isVrbSky( char **string, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
static char *cldPtr[] = {"FEW", "SCT", "BKN", "OVC", NULL };
|
||||
@@ -3384,7 +3297,6 @@ static bool isVrbSky( char **string, Decoded_METAR *Mptr, int *NDEX )
|
||||
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
static bool isObscurAloft( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -3468,7 +3380,6 @@ static bool isObscurAloft( char **string, Decoded_METAR *Mptr,
|
||||
}
|
||||
|
||||
}
|
||||
#pragma page(1)
|
||||
static bool isNOSPECI( char *string, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
|
||||
@@ -3483,7 +3394,6 @@ static bool isNOSPECI( char *string, Decoded_METAR *Mptr, int *NDEX )
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
#pragma page(1)
|
||||
static bool isLAST( char *string, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
|
||||
@@ -3498,9 +3408,6 @@ static bool isLAST( char *string, Decoded_METAR *Mptr, int *NDEX )
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isSynopClouds */
|
||||
@@ -3522,7 +3429,6 @@ static bool isLAST( char *string, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isSynopClouds( char *token, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -3555,7 +3461,6 @@ static bool isSynopClouds( char *token, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
static bool isSNINCR( char **string, Decoded_METAR *Mptr, int *NDEX )
|
||||
{
|
||||
|
||||
@@ -3594,9 +3499,6 @@ static bool isSNINCR( char **string, Decoded_METAR *Mptr, int *NDEX )
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isSnowDepth */
|
||||
@@ -3618,7 +3520,6 @@ static bool isSNINCR( char **string, Decoded_METAR *Mptr, int *NDEX )
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isSnowDepth( char *token, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -3642,7 +3543,6 @@ static bool isSnowDepth( char *token, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
static bool isWaterEquivSnow( char *string,
|
||||
Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
@@ -3664,7 +3564,6 @@ static bool isWaterEquivSnow( char *string,
|
||||
}
|
||||
|
||||
}
|
||||
#pragma page(1)
|
||||
static bool isSunshineDur( char *string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -3690,9 +3589,6 @@ static bool isSunshineDur( char *string, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isHourlyPrecip */
|
||||
@@ -3741,7 +3637,6 @@ static bool isSunshineDur( char *string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isHourlyPrecip( char **string, Decoded_METAR *Mptr,
|
||||
int *NDEX)
|
||||
@@ -3788,9 +3683,6 @@ static bool isHourlyPrecip( char **string, Decoded_METAR *Mptr,
|
||||
}
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isP6Precip */
|
||||
@@ -3839,7 +3731,6 @@ static bool isHourlyPrecip( char **string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isP6Precip( char *string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
@@ -3867,9 +3758,6 @@ static bool isP6Precip( char *string, Decoded_METAR *Mptr,
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isP24Precip */
|
||||
@@ -3918,7 +3806,6 @@ static bool isP6Precip( char *string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isP24Precip( char *string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
@@ -3944,9 +3831,6 @@ static bool isP24Precip( char *string, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isTTdTenths */
|
||||
@@ -3995,7 +3879,6 @@ static bool isP24Precip( char *string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isTTdTenths( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4056,9 +3939,6 @@ static bool isTTdTenths( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
}
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isMaxTemp */
|
||||
@@ -4080,7 +3960,6 @@ static bool isTTdTenths( char *token, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isMaxTemp(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
char buf[ 6 ];
|
||||
@@ -4120,9 +3999,6 @@ static bool isMaxTemp(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isMinTemp */
|
||||
@@ -4144,7 +4020,6 @@ static bool isMaxTemp(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isMinTemp(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
char buf[ 6 ];
|
||||
@@ -4183,9 +4058,6 @@ static bool isMinTemp(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isT24MaxMinTemp */
|
||||
@@ -4207,7 +4079,6 @@ static bool isMinTemp(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
static bool isT24MaxMinTemp( char *string, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
{
|
||||
@@ -4263,9 +4134,6 @@ static bool isT24MaxMinTemp( char *string, Decoded_METAR *Mptr,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPtendency */
|
||||
@@ -4287,7 +4155,6 @@ static bool isT24MaxMinTemp( char *string, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isPtendency(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4328,9 +4195,6 @@ static bool isPtendency(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPWINO */
|
||||
@@ -4352,7 +4216,6 @@ static bool isPtendency(char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isPWINO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4371,9 +4234,6 @@ static bool isPWINO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isPNO */
|
||||
@@ -4395,7 +4255,6 @@ static bool isPWINO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isPNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4414,9 +4273,6 @@ static bool isPNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isRVRNO */
|
||||
@@ -4438,7 +4294,6 @@ static bool isPNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isRVRNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4456,9 +4311,6 @@ static bool isRVRNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isCHINO */
|
||||
@@ -4480,7 +4332,6 @@ static bool isRVRNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isCHINO( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4518,9 +4369,6 @@ static bool isCHINO( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isVISNO */
|
||||
@@ -4542,7 +4390,6 @@ static bool isCHINO( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isVISNO( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4579,9 +4426,6 @@ static bool isVISNO( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isFZRANO */
|
||||
@@ -4603,7 +4447,6 @@ static bool isVISNO( char **string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isFZRANO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4622,9 +4465,6 @@ static bool isFZRANO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isTSNO */
|
||||
@@ -4673,7 +4513,6 @@ static bool isFZRANO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isTSNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
{
|
||||
@@ -4691,9 +4530,6 @@ static bool isTSNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
|
||||
}
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: isDollarSign */
|
||||
@@ -4715,7 +4551,6 @@ static bool isTSNO( char *string, Decoded_METAR *Mptr, int *NDEX)
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
static bool isDollarSign( char *indicator, Decoded_METAR *Mptr,
|
||||
int *NDEX )
|
||||
@@ -4734,9 +4569,6 @@ static bool isDollarSign( char *indicator, Decoded_METAR *Mptr,
|
||||
}
|
||||
}
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: DcdMTRmk */
|
||||
@@ -4766,7 +4598,6 @@ static bool isDollarSign( char *indicator, Decoded_METAR *Mptr,
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
void DcdMTRmk( char **token, Decoded_METAR *Mptr )
|
||||
{
|
||||
|
||||
@@ -4791,18 +4622,18 @@ void DcdMTRmk( char **token, Decoded_METAR *Mptr )
|
||||
FZRANO = 0, TSNO = 0, maintIndicator = 0, CHINO = 0, RVRNO = 0,
|
||||
VISNO = 0, PNO = 0, DVR = 0;
|
||||
|
||||
int NDEX,
|
||||
ndex,
|
||||
i;
|
||||
char *slash,
|
||||
*tokenX,
|
||||
*V_char,
|
||||
*temp_token;
|
||||
int NDEX;
|
||||
// int ndex;
|
||||
int i;
|
||||
// char *slash;
|
||||
// char *tokenX;
|
||||
// char *V_char;
|
||||
// char *temp_token;
|
||||
|
||||
bool extra_token,
|
||||
IS_NOT_RMKS;
|
||||
// bool extra_token;
|
||||
bool IS_NOT_RMKS;
|
||||
|
||||
float T_vsby;
|
||||
// float T_vsby;
|
||||
|
||||
/*************************/
|
||||
/* START BODY OF ROUTINE */
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#include "Metar.h"
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: dRVMETAR */
|
||||
@@ -29,10 +26,8 @@
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
main()
|
||||
int main()
|
||||
{
|
||||
char bltn_prefix[20];
|
||||
static char *string[] =
|
||||
{
|
||||
"KAST 221156Z COR 09005KT 7SM -RA OVC026 09/08 A2996 RMK "
|
||||
@@ -516,7 +511,6 @@ NULL,
|
||||
Decoded_METAR *Mptr = &Metar;
|
||||
int j,
|
||||
ErReturn;
|
||||
static char *synopRTRN = NULL;
|
||||
|
||||
|
||||
/***************************************************/
|
||||
@@ -541,4 +535,5 @@ NULL,
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
#include "Local.h" /* standard header file */
|
||||
#include "Metar.h"
|
||||
|
||||
#pragma subtitle(" ")
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: fracPart */
|
||||
@@ -26,7 +23,6 @@
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
float fracPart( char *string )
|
||||
{
|
||||
|
||||
@@ -1106,8 +1106,10 @@ char *strlwr(char *);
|
||||
char *rptstrip(char *);
|
||||
char *rptfmt(char *);
|
||||
char *rptfmti(char *, unsigned short int);
|
||||
|
||||
|
||||
#ifndef __FreeBSD__ // strnstr is already defined on FreeBSD
|
||||
char *strnstr(char *, char *, size_t);
|
||||
#endif
|
||||
|
||||
int stregion(int);
|
||||
int ccregion(char *);
|
||||
|
||||
@@ -11,4 +11,8 @@ libsgmetar_a_SOURCES = \
|
||||
MetarStation.cpp \
|
||||
Prtdmetr.cpp Stspack2.cpp Stspack3.cpp
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "Local.h" /* standard header file */
|
||||
#include "Metar.h"
|
||||
#pragma page(1)
|
||||
#pragma subtitle("subtitle - description ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: prtDMETR */
|
||||
@@ -25,7 +23,6 @@
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
void prtDMETR( Decoded_METAR *Mptr )
|
||||
{
|
||||
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
#pragma comment (compiler)
|
||||
//#pragma comment (date)
|
||||
//#pragma comment (timestamp)
|
||||
#pragma pagesize(80)
|
||||
|
||||
#include "Local.h" /* standard header file */
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma subtitle("stspack2 - Local string test functions ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: stspack2 */
|
||||
@@ -75,7 +67,6 @@
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
|
||||
int nisalnum(char *s, int n) {
|
||||
|
||||
@@ -208,4 +199,3 @@ int nisxdigi(char *s, int n) {
|
||||
|
||||
} /* end nisxdigi */
|
||||
|
||||
#pragma page(1)
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
#pragma comment (compiler)
|
||||
//#pragma comment (date)
|
||||
//#pragma comment (timestamp)
|
||||
#pragma pagesize(80)
|
||||
|
||||
#include "Local.h" /* standard header file */
|
||||
|
||||
#pragma page(1)
|
||||
#pragma subtitle(" ")
|
||||
#pragma subtitle("stspack3 - Local string test functions ")
|
||||
/********************************************************************/
|
||||
/* */
|
||||
/* Title: stspack3 */
|
||||
@@ -75,7 +67,6 @@
|
||||
/* None. */
|
||||
/* */
|
||||
/********************************************************************/
|
||||
#pragma page(1)
|
||||
char *nxtalnum(char *s) {
|
||||
|
||||
for (; !isalnum(*s) && *s; s++) ;
|
||||
@@ -208,4 +199,3 @@ char *nxtxdigi(char *s) {
|
||||
} /* end nxtxdigi */
|
||||
|
||||
|
||||
#pragma page(1)
|
||||
|
||||
4
simgear/misc/.cvsignore
Normal file
4
simgear/misc/.cvsignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
props_test
|
||||
@@ -1,16 +1,12 @@
|
||||
includedir = @includedir@/misc
|
||||
|
||||
if HAVE_ZLIB
|
||||
ZLIB_INCL =
|
||||
else
|
||||
ZLIB_INCL = -I$(top_srcdir)/src/zlib
|
||||
endif
|
||||
|
||||
lib_LIBRARIES = libsgmisc.a
|
||||
|
||||
include_HEADERS = \
|
||||
commands.hxx \
|
||||
exception.hxx \
|
||||
props.hxx \
|
||||
props_io.hxx \
|
||||
sg_path.hxx \
|
||||
sgstream.hxx \
|
||||
stopwatch.hxx \
|
||||
@@ -20,6 +16,7 @@ include_HEADERS = \
|
||||
|
||||
libsgmisc_a_SOURCES = \
|
||||
commands.cxx \
|
||||
exception.cxx \
|
||||
props.cxx \
|
||||
props_io.cxx \
|
||||
sg_path.cxx \
|
||||
@@ -33,4 +30,8 @@ noinst_PROGRAMS = props_test
|
||||
props_test_SOURCES = props_test.cxx
|
||||
props_test_LDADD = libsgmisc.a ../xml/libsgxml.a ../debug/libsgdebug.a
|
||||
|
||||
INCLUDES += -I$(top_srcdir) $(ZLIB_INCL)
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// $Id$
|
||||
|
||||
#include "commands.hxx"
|
||||
#include "props_io.hxx"
|
||||
|
||||
|
||||
|
||||
@@ -90,74 +91,4 @@ SGCommandMgr::execute (const string &name, const SGPropertyNode * arg,
|
||||
return (*command)(arg, state);
|
||||
}
|
||||
|
||||
|
||||
// bool
|
||||
// SGCommandMgr::execute (const string &name) const
|
||||
// {
|
||||
// // FIXME
|
||||
// SGPropertyNode node;
|
||||
// return execute(name, &node);
|
||||
// }
|
||||
|
||||
|
||||
// bool
|
||||
// SGCommandMgr::execute (const string &name, bool value) const
|
||||
// {
|
||||
// // FIXME
|
||||
// SGPropertyNode node;
|
||||
// node.setBoolValue(value);
|
||||
// return execute(name, &node);
|
||||
// }
|
||||
|
||||
|
||||
// bool
|
||||
// SGCommandMgr::execute (const string &name, int value) const
|
||||
// {
|
||||
// // FIXME
|
||||
// SGPropertyNode node;
|
||||
// node.setIntValue(value);
|
||||
// return execute(name, &node);
|
||||
// }
|
||||
|
||||
|
||||
// bool
|
||||
// SGCommandMgr::execute (const string &name, long value) const
|
||||
// {
|
||||
// // FIXME
|
||||
// SGPropertyNode node;
|
||||
// node.setLongValue(value);
|
||||
// return execute(name, &node);
|
||||
// }
|
||||
|
||||
|
||||
// bool
|
||||
// SGCommandMgr::execute (const string &name, float value) const
|
||||
// {
|
||||
// // FIXME
|
||||
// SGPropertyNode node;
|
||||
// node.setFloatValue(value);
|
||||
// return execute(name, &node);
|
||||
// }
|
||||
|
||||
|
||||
// bool
|
||||
// SGCommandMgr::execute (const string &name, double value) const
|
||||
// {
|
||||
// // FIXME
|
||||
// SGPropertyNode node;
|
||||
// node.setDoubleValue(value);
|
||||
// return execute(name, &node);
|
||||
// }
|
||||
|
||||
|
||||
// bool
|
||||
// SGCommandMgr::execute (const string &name, string value) const
|
||||
// {
|
||||
// // FIXME
|
||||
// SGPropertyNode node;
|
||||
// node.setStringValue(value);
|
||||
// return execute(name, &node);
|
||||
// }
|
||||
|
||||
|
||||
// end of commands.cxx
|
||||
|
||||
@@ -150,104 +150,6 @@ public:
|
||||
const SGPropertyNode * arg,
|
||||
SGCommandState ** state) const;
|
||||
|
||||
|
||||
// /**
|
||||
// * Execute a command with no argument.
|
||||
// *
|
||||
// * The command function will receive a pointer to a property node
|
||||
// * with no value and no children.
|
||||
// *
|
||||
// * @param name The name of the command.
|
||||
// * @return true if the command is present and executes successfully,
|
||||
// * false otherwise.
|
||||
// */
|
||||
// virtual bool execute (const string &name) const;
|
||||
|
||||
|
||||
// /**
|
||||
// * Execute a command with a single bool argument.
|
||||
// *
|
||||
// * The command function will receive a pointer to a property node
|
||||
// * with a bool value and no children.
|
||||
// *
|
||||
// * @param name The name of the command.
|
||||
// * @param arg The bool argument to the command.
|
||||
// * @return true if the command is present and executes successfully,
|
||||
// * false otherwise.
|
||||
// */
|
||||
// virtual bool execute (const string &name, bool arg) const;
|
||||
|
||||
|
||||
// /**
|
||||
// * Execute a command with a single int argument.
|
||||
// *
|
||||
// * The command function will receive a pointer to a property node
|
||||
// * with a int value and no children.
|
||||
// *
|
||||
// * @param name The name of the command.
|
||||
// * @param arg The int argument to the command.
|
||||
// * @return true if the command is present and executes successfully,
|
||||
// * false otherwise.
|
||||
// */
|
||||
// virtual bool execute (const string &name, int arg) const;
|
||||
|
||||
|
||||
// /**
|
||||
// * Execute a command with a single long argument.
|
||||
// *
|
||||
// * The command function will receive a pointer to a property node
|
||||
// * with a long value and no children.
|
||||
// *
|
||||
// * @param name The name of the command.
|
||||
// * @param arg The long argument to the command.
|
||||
// * @return true if the command is present and executes successfully,
|
||||
// * false otherwise.
|
||||
// */
|
||||
// virtual bool execute (const string &name, long arg) const;
|
||||
|
||||
|
||||
// /**
|
||||
// * Execute a command with a single float argument.
|
||||
// *
|
||||
// * The command function will receive a pointer to a property node
|
||||
// * with a float value and no children.
|
||||
// *
|
||||
// * @param name The name of the command.
|
||||
// * @param arg The float argument to the command.
|
||||
// * @return true if the command is present and executes successfully,
|
||||
// * false otherwise.
|
||||
// */
|
||||
// virtual bool execute (const string &name, float arg) const;
|
||||
|
||||
|
||||
// /**
|
||||
// * Execute a command with a single double argument.
|
||||
// *
|
||||
// * The command function will receive a pointer to a property node
|
||||
// * with a double value and no children.
|
||||
// *
|
||||
// * @param name The name of the command.
|
||||
// * @param arg The double argument to the command.
|
||||
// * @return true if the command is present and executes successfully,
|
||||
// * false otherwise.
|
||||
// */
|
||||
// virtual bool execute (const string &name, double arg) const;
|
||||
|
||||
|
||||
// /**
|
||||
// * Execute a command with a single string argument.
|
||||
// *
|
||||
// * The command function will receive a pointer to a property node
|
||||
// * with a string value and no children.
|
||||
// *
|
||||
// * @param name The name of the command.
|
||||
// * @param arg The string argument to the command.
|
||||
// * @return true if the command is present and executes successfully,
|
||||
// * false otherwise.
|
||||
// */
|
||||
// virtual bool execute (const string &name, string arg) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
typedef map<string,command_t> command_map;
|
||||
|
||||
307
simgear/misc/exception.cxx
Normal file
307
simgear/misc/exception.cxx
Normal file
@@ -0,0 +1,307 @@
|
||||
// exception.cxx - implementation of SimGear base exceptions.
|
||||
// Started Summer 2001 by David Megginson, david@megginson.com
|
||||
// This code is released into the Public Domain.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
|
||||
#include "exception.hxx"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of sg_location class.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sg_location::sg_location ()
|
||||
: _path(""),
|
||||
_line(-1),
|
||||
_column(-1),
|
||||
_byte(-1)
|
||||
{
|
||||
}
|
||||
|
||||
sg_location::sg_location (const string &path, int line, int column)
|
||||
: _path(path),
|
||||
_line(line),
|
||||
_column(column),
|
||||
_byte(-1)
|
||||
{
|
||||
}
|
||||
|
||||
sg_location::~sg_location ()
|
||||
{
|
||||
}
|
||||
|
||||
const string &
|
||||
sg_location::getPath () const
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
|
||||
void
|
||||
sg_location::setPath (const string &path)
|
||||
{
|
||||
_path = path;
|
||||
}
|
||||
|
||||
int
|
||||
sg_location::getLine () const
|
||||
{
|
||||
return _line;
|
||||
}
|
||||
|
||||
void
|
||||
sg_location::setLine (int line)
|
||||
{
|
||||
_line = line;
|
||||
}
|
||||
|
||||
int
|
||||
sg_location::getColumn () const
|
||||
{
|
||||
return _column;
|
||||
}
|
||||
|
||||
void
|
||||
sg_location::setColumn (int column)
|
||||
{
|
||||
_column = column;
|
||||
}
|
||||
|
||||
int
|
||||
sg_location::getByte () const
|
||||
{
|
||||
return _byte;
|
||||
}
|
||||
|
||||
void
|
||||
sg_location::setByte (int byte)
|
||||
{
|
||||
_byte = byte;
|
||||
}
|
||||
|
||||
string
|
||||
sg_location::asString () const
|
||||
{
|
||||
char buf[128];
|
||||
string out = "";
|
||||
if (_path != (string)"") {
|
||||
out += _path;
|
||||
if (_line != -1 || _column != -1)
|
||||
out += ",\n";
|
||||
}
|
||||
if (_line != -1) {
|
||||
sprintf(buf, "line %d", _line);
|
||||
out += buf;
|
||||
if (_column != -1)
|
||||
out += ", ";
|
||||
}
|
||||
if (_column != -1) {
|
||||
sprintf(buf, "column %d", _column);
|
||||
out += buf;
|
||||
}
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of sg_throwable class.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sg_throwable::sg_throwable ()
|
||||
: _message(""),
|
||||
_origin("")
|
||||
{
|
||||
}
|
||||
|
||||
sg_throwable::sg_throwable (const string &message, const string &origin)
|
||||
: _message(message),
|
||||
_origin(origin)
|
||||
{
|
||||
}
|
||||
|
||||
sg_throwable::~sg_throwable ()
|
||||
{
|
||||
}
|
||||
|
||||
const string &
|
||||
sg_throwable::getMessage () const
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
const string
|
||||
sg_throwable::getFormattedMessage () const
|
||||
{
|
||||
return getMessage();
|
||||
}
|
||||
|
||||
void
|
||||
sg_throwable::setMessage (const string &message)
|
||||
{
|
||||
_message = message;
|
||||
}
|
||||
|
||||
const string &
|
||||
sg_throwable::getOrigin () const
|
||||
{
|
||||
return _origin;
|
||||
}
|
||||
|
||||
void
|
||||
sg_throwable::setOrigin (const string &origin)
|
||||
{
|
||||
_origin = origin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of sg_error class.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sg_error::sg_error ()
|
||||
: sg_throwable ()
|
||||
{
|
||||
}
|
||||
|
||||
sg_error::sg_error (const string &message, const string &origin)
|
||||
: sg_throwable(message, origin)
|
||||
{
|
||||
}
|
||||
|
||||
sg_error::~sg_error ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of sg_exception class.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sg_exception::sg_exception ()
|
||||
: sg_throwable ()
|
||||
{
|
||||
}
|
||||
|
||||
sg_exception::sg_exception (const string &message, const string &origin)
|
||||
: sg_throwable(message, origin)
|
||||
{
|
||||
}
|
||||
|
||||
sg_exception::~sg_exception ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of sg_io_exception.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sg_io_exception::sg_io_exception ()
|
||||
: sg_exception()
|
||||
{
|
||||
}
|
||||
|
||||
sg_io_exception::sg_io_exception (const string &message, const string &origin)
|
||||
: sg_exception(message, origin)
|
||||
{
|
||||
}
|
||||
|
||||
sg_io_exception::sg_io_exception (const string &message,
|
||||
const sg_location &location,
|
||||
const string &origin)
|
||||
: sg_exception(message, origin),
|
||||
_location(location)
|
||||
{
|
||||
}
|
||||
|
||||
sg_io_exception::~sg_io_exception ()
|
||||
{
|
||||
}
|
||||
|
||||
const string
|
||||
sg_io_exception::getFormattedMessage () const
|
||||
{
|
||||
string ret = getMessage();
|
||||
ret += "\n at ";
|
||||
ret += getLocation().asString();
|
||||
return ret;
|
||||
}
|
||||
|
||||
const sg_location &
|
||||
sg_io_exception::getLocation () const
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
void
|
||||
sg_io_exception::setLocation (const sg_location &location)
|
||||
{
|
||||
_location = location;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of sg_format_exception.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sg_format_exception::sg_format_exception ()
|
||||
: sg_exception(),
|
||||
_text("")
|
||||
{
|
||||
}
|
||||
|
||||
sg_format_exception::sg_format_exception (const string &message,
|
||||
const string &text,
|
||||
const string &origin)
|
||||
: sg_exception(message, origin),
|
||||
_text(text)
|
||||
{
|
||||
}
|
||||
|
||||
sg_format_exception::~sg_format_exception ()
|
||||
{
|
||||
}
|
||||
|
||||
const string &
|
||||
sg_format_exception::getText () const
|
||||
{
|
||||
return _text;
|
||||
}
|
||||
|
||||
void
|
||||
sg_format_exception::setText (const string &text)
|
||||
{
|
||||
_text = text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of sg_range_exception.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
sg_range_exception::sg_range_exception ()
|
||||
: sg_exception()
|
||||
{
|
||||
}
|
||||
|
||||
sg_range_exception::sg_range_exception (const string &message,
|
||||
const string &origin)
|
||||
: sg_exception(message, origin)
|
||||
{
|
||||
}
|
||||
|
||||
sg_range_exception::~sg_range_exception ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// end of exception.cxx
|
||||
182
simgear/misc/exception.hxx
Normal file
182
simgear/misc/exception.hxx
Normal file
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* \file exception.hxx
|
||||
* Interface definition for SimGear base exceptions.
|
||||
* Started Spring 2001 by David Megginson, david@megginson.com
|
||||
* This code is released into the Public Domain.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __SIMGEAR_MISC_EXCEPTION_HXX
|
||||
#define __SIMGEAR_MISC_EXCEPTION_HXX 1
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include STL_STRING
|
||||
|
||||
SG_USING_STD(string);
|
||||
|
||||
|
||||
/**
|
||||
* Information encapsulating a single location in an external resource
|
||||
*
|
||||
* A position in the resource my optionally be provided, either by
|
||||
* line number, line number and column number, or byte offset from the
|
||||
* beginning of the resource.
|
||||
*/
|
||||
class sg_location
|
||||
{
|
||||
public:
|
||||
sg_location ();
|
||||
sg_location (const string &path, int line = -1, int column = -1);
|
||||
virtual ~sg_location ();
|
||||
virtual const string &getPath () const;
|
||||
virtual void setPath (const string &path);
|
||||
virtual int getLine () const;
|
||||
virtual void setLine (int line);
|
||||
virtual int getColumn () const;
|
||||
virtual void setColumn (int column);
|
||||
virtual int getByte () const;
|
||||
virtual void setByte (int byte);
|
||||
virtual string asString () const;
|
||||
private:
|
||||
string _path;
|
||||
int _line;
|
||||
int _column;
|
||||
int _byte;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class for all throwables.
|
||||
*/
|
||||
class sg_throwable
|
||||
{
|
||||
public:
|
||||
sg_throwable ();
|
||||
sg_throwable (const string &message, const string &origin = "");
|
||||
virtual ~sg_throwable ();
|
||||
virtual const string &getMessage () const;
|
||||
virtual const string getFormattedMessage () const;
|
||||
virtual void setMessage (const string &message);
|
||||
virtual const string &getOrigin () const;
|
||||
virtual void setOrigin (const string &origin);
|
||||
private:
|
||||
string _message;
|
||||
string _origin;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* An unexpected fatal error.
|
||||
*
|
||||
* Methods and functions show throw this exception when something
|
||||
* very bad has happened (such as memory corruption or
|
||||
* a totally unexpected internal value). Applications should catch
|
||||
* this exception only at the top level if at all, and should
|
||||
* normally terminate execution soon afterwards.
|
||||
*/
|
||||
class sg_error : public sg_throwable
|
||||
{
|
||||
public:
|
||||
sg_error ();
|
||||
sg_error (const string &message, const string &origin = "");
|
||||
virtual ~sg_error ();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for all SimGear exceptions.
|
||||
*
|
||||
* SimGear-based code should throw this exception only when no
|
||||
* more specific exception applies. It may not be caught until
|
||||
* higher up in the application, where it is not possible to
|
||||
* resume normal operations if desired.
|
||||
*
|
||||
* A caller can catch sg_exception by default to ensure that
|
||||
* all exceptions are caught. Every SimGear exception can contain
|
||||
* a human-readable error message and a human-readable string
|
||||
* indicating the part of the application causing the exception
|
||||
* (as an aid to debugging, only).
|
||||
*/
|
||||
class sg_exception : public sg_throwable
|
||||
{
|
||||
public:
|
||||
sg_exception ();
|
||||
sg_exception (const string &message, const string &origin = "");
|
||||
virtual ~sg_exception ();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* An I/O-related SimGear exception.
|
||||
*
|
||||
* SimGear-based code should throw this exception when it fails
|
||||
* to read from or write to an external resource, such as a file,
|
||||
* socket, URL, or database.
|
||||
*
|
||||
* In addition to the functionality of sg_exception, an
|
||||
* sg_io_exception may contain location information, such as the name
|
||||
* of a file or URL, and possible also a location in that file or URL.
|
||||
*/
|
||||
class sg_io_exception : public sg_exception
|
||||
{
|
||||
public:
|
||||
sg_io_exception ();
|
||||
sg_io_exception (const string &message, const string &origin = "");
|
||||
sg_io_exception (const string &message, const sg_location &location,
|
||||
const string &origin = "");
|
||||
virtual ~sg_io_exception ();
|
||||
virtual const string getFormattedMessage () const;
|
||||
virtual const sg_location &getLocation () const;
|
||||
virtual void setLocation (const sg_location &location);
|
||||
private:
|
||||
sg_location _location;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A format-related SimGear exception.
|
||||
*
|
||||
* SimGear-based code should throw this exception when a string
|
||||
* does not appear in the expected format (for example, a date
|
||||
* string does not conform to ISO 8601).
|
||||
*
|
||||
* In addition to the functionality of sg_exception, an
|
||||
* sg_format_exception can contain a copy of the original malformated
|
||||
* text.
|
||||
*/
|
||||
class sg_format_exception : public sg_exception
|
||||
{
|
||||
public:
|
||||
sg_format_exception ();
|
||||
sg_format_exception (const string &message, const string &text,
|
||||
const string &origin = "");
|
||||
virtual ~sg_format_exception ();
|
||||
virtual const string &getText () const;
|
||||
virtual void setText (const string &text);
|
||||
private:
|
||||
string _text;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A range-related SimGear exception.
|
||||
*
|
||||
* SimGear-based code should throw this exception when a value falls
|
||||
* outside the range where it can reasonably be handled; examples
|
||||
* include longitude outside the range -180:180, unrealistically high
|
||||
* forces or velocities, an illegal airport code, etc. A range
|
||||
* exception usually means that something has gone wrong internally.
|
||||
*/
|
||||
class sg_range_exception : public sg_exception
|
||||
{
|
||||
public:
|
||||
sg_range_exception ();
|
||||
sg_range_exception (const string &message, const string &origin = "");
|
||||
virtual ~sg_range_exception ();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// end of exception.hxx
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,14 +12,28 @@
|
||||
#ifndef __PROPS_HXX
|
||||
#define __PROPS_HXX
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#ifndef PROPS_STANDALONE
|
||||
#define PROPS_STANDALONE 0
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include STL_STRING
|
||||
#include <vector>
|
||||
#include STL_IOSTREAM
|
||||
|
||||
#if PROPS_STANDALONE
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::istream;
|
||||
using std::ostream;
|
||||
|
||||
#else
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include STL_STRING
|
||||
#include STL_IOSTREAM
|
||||
SG_USING_STD(string);
|
||||
SG_USING_STD(vector);
|
||||
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
@@ -27,6 +41,14 @@ SG_USING_STD(istream);
|
||||
SG_USING_STD(ostream);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NONE
|
||||
#pragma warn A sloppy coder has defined NONE as a macro!
|
||||
#undef NONE
|
||||
#endif
|
||||
|
||||
#ifdef ALIAS
|
||||
#pragma warn A sloppy coder has defined ALIAS as a macro!
|
||||
#undef ALIAS
|
||||
@@ -75,40 +97,50 @@ SG_USING_STD(ostream);
|
||||
// This is the mechanism that information-providing routines can
|
||||
// use to link their own values to the property manager. Any
|
||||
// SGValue can be tied to a raw value and then untied again.
|
||||
//
|
||||
// Note: we are forced to use inlined methods here to ensure
|
||||
// that the templates will be instantiated. We're probably taking
|
||||
// a small performance hit for that.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class for a raw value.
|
||||
*
|
||||
* The property manager is implemented in three layers. The {@link
|
||||
* <p>The property manager is implemented in two layers. The {@link
|
||||
* SGPropertyNode} is the highest and most abstract layer,
|
||||
* representing * an LValue/RValue pair: it * records the position
|
||||
* of the property in the property tree and * contains facilities
|
||||
* for navigation to other nodes. Each node * may contain an {@link
|
||||
* SGValue}, which is guaranteed persistent: the * {@link SGValue}
|
||||
* will not change during a session, even if the * property is bound
|
||||
* and unbound multiple times. The SGValue is the * abstraction of
|
||||
* an RValue: it allows for conversion among all of the different
|
||||
* types, and can be bound to external pointers, functions, methods,
|
||||
* or other data sources. Every SGValue contains an SGRawValue of
|
||||
* a specific type. The SGRawValue (this class) may change frequently
|
||||
* during a session as a value is retyped or bound and unbound to
|
||||
* various data source, but the abstract SGValue layer insulates
|
||||
* the application from those changes. The raw value contains no
|
||||
* facilities for data binding or for type conversion: it is simply
|
||||
* the abstraction of a primitive data type (or a compound data
|
||||
* type, in the case of a string).
|
||||
* representing an LValue/RValue pair: it records the position of the
|
||||
* property in the property tree and contains facilities for
|
||||
* navigation to other nodes. It is guaranteed to be persistent: the
|
||||
* {@link SGPropertyNode} will not change during a session, even if
|
||||
* the property is bound and unbound multiple times.</p>
|
||||
*
|
||||
* The SGValue class always keeps a *copy* of a raw value, not the
|
||||
* original one passed to it; if you override a derived class but do
|
||||
* not replace the {@link #clone} method, strange things will happen.
|
||||
* <p>When the property value is not managed internally in the
|
||||
* SGPropertyNode, the SGPropertyNode will contain a reference to an
|
||||
* SGRawValue (this class), which provides an abstract way to get,
|
||||
* set, and clone the underlying value. The SGRawValue may change
|
||||
* frequently during a session as a value is retyped or bound and
|
||||
* unbound to various data source, but the abstract SGPropertyNode
|
||||
* layer insulates the application from those changes. The raw value
|
||||
* contains no facilities for data binding or for type conversion: it
|
||||
* is simply the abstraction of a primitive data type (or a compound
|
||||
* data type, in the case of a string).</p>
|
||||
*
|
||||
* All raw values must implement {@link #getValue}, {@link #setValue},
|
||||
* and {@link #clone} for the appropriate type.
|
||||
* <p>The SGPropertyNode class always keeps a *copy* of a raw value,
|
||||
* not the original one passed to it; if you override a derived class
|
||||
* but do not replace the {@link #clone} method, strange things will
|
||||
* happen.</p>
|
||||
*
|
||||
* @see SGValue
|
||||
* @see SGPropertyNode */
|
||||
* <p>All derived SGRawValue classes must implement {@link #getValue},
|
||||
* {@link #setValue}, and {@link #clone} for the appropriate type.</p>
|
||||
*
|
||||
* @see SGPropertyNode
|
||||
* @see SGRawValuePointer
|
||||
* @see SGRawValueFunctions
|
||||
* @see SGRawValueFunctionsIndexed
|
||||
* @see SGRawValueMethods
|
||||
* @see SGRawValueMethodsIndexed
|
||||
*/
|
||||
template <class T>
|
||||
class SGRawValue
|
||||
{
|
||||
@@ -176,61 +208,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* An unbound raw value, stored internally.
|
||||
*
|
||||
* Instances of this class are created automatically, by default,
|
||||
* by the SGValue class; ordinarily the application should not
|
||||
* need to touch it.
|
||||
*/
|
||||
template <class T>
|
||||
class SGRawValueInternal : public SGRawValue<T>
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* Initialize with the default value for this type.
|
||||
*/
|
||||
SGRawValueInternal () {}
|
||||
|
||||
/**
|
||||
* Explicit value constructor.
|
||||
*
|
||||
* Initialize with the underlying value provided.
|
||||
*
|
||||
* @param value The initial value for this property.
|
||||
*/
|
||||
SGRawValueInternal (T value) : _value(value) {}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~SGRawValueInternal () {}
|
||||
|
||||
/**
|
||||
* Get the underlying value.
|
||||
*/
|
||||
virtual T getValue () const { return _value; }
|
||||
|
||||
/**
|
||||
* Set the underlying value.
|
||||
*/
|
||||
virtual bool setValue (T value) { _value = value; return true; }
|
||||
|
||||
/**
|
||||
* Create a deep copy of this raw value.
|
||||
*/
|
||||
virtual SGRawValue<T> * clone () const {
|
||||
return new SGRawValueInternal<T>(_value);
|
||||
}
|
||||
|
||||
private:
|
||||
T _value;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A raw value bound to a pointer.
|
||||
*
|
||||
@@ -375,6 +352,8 @@ private:
|
||||
* not have a getter. An indexed value is useful for binding one
|
||||
* of a list of possible values (such as multiple engines for a
|
||||
* plane). The index is hard-coded at creation time.
|
||||
*
|
||||
* @see SGRawValue
|
||||
*/
|
||||
template <class T>
|
||||
class SGRawValueFunctionsIndexed : public SGRawValue<T>
|
||||
@@ -477,9 +456,14 @@ private:
|
||||
*/
|
||||
class SGPropertyNode
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Public constants.
|
||||
*/
|
||||
enum {
|
||||
MAX_STRING_LEN = 1024
|
||||
};
|
||||
|
||||
/**
|
||||
* Property value types.
|
||||
@@ -506,7 +490,9 @@ public:
|
||||
enum Attribute {
|
||||
READ = 1,
|
||||
WRITE = 2,
|
||||
ARCHIVE = 4
|
||||
ARCHIVE = 4,
|
||||
TRACE_READ = 8,
|
||||
TRACE_WRITE = 16
|
||||
};
|
||||
|
||||
|
||||
@@ -542,7 +528,7 @@ public:
|
||||
/**
|
||||
* Get the node's simple (XML) name.
|
||||
*/
|
||||
const string &getName () const { return _name; }
|
||||
const char * getName () const { return _name; }
|
||||
|
||||
|
||||
/**
|
||||
@@ -589,26 +575,26 @@ public:
|
||||
/**
|
||||
* Get a child node by name and index.
|
||||
*/
|
||||
SGPropertyNode * getChild (const string &name, int index = 0,
|
||||
SGPropertyNode * getChild (const char * name, int index = 0,
|
||||
bool create = false);
|
||||
|
||||
|
||||
/**
|
||||
* Get a const child node by name and index.
|
||||
*/
|
||||
const SGPropertyNode * getChild (const string &name, int index = 0) const;
|
||||
const SGPropertyNode * getChild (const char * name, int index = 0) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get a vector of all children with the specified name.
|
||||
*/
|
||||
vector<SGPropertyNode *> getChildren (const string &name);
|
||||
vector<SGPropertyNode *> getChildren (const char * name);
|
||||
|
||||
|
||||
/**
|
||||
* Get a vector all all children (const) with the specified name.
|
||||
*/
|
||||
vector<const SGPropertyNode *> getChildren (const string &name) const;
|
||||
vector<const SGPropertyNode *> getChildren (const char * name) const;
|
||||
|
||||
|
||||
//
|
||||
@@ -625,7 +611,7 @@ public:
|
||||
/**
|
||||
* Alias this node's leaf value to another's by relative path.
|
||||
*/
|
||||
bool alias (const string &path);
|
||||
bool alias (const char * path);
|
||||
|
||||
|
||||
/**
|
||||
@@ -660,7 +646,7 @@ public:
|
||||
/**
|
||||
* Get the path to this node from the root.
|
||||
*/
|
||||
string getPath (bool simplify = false) const;
|
||||
const char * getPath (bool simplify = false) const;
|
||||
|
||||
|
||||
/**
|
||||
@@ -678,13 +664,37 @@ public:
|
||||
/**
|
||||
* Get a pointer to another node by relative path.
|
||||
*/
|
||||
SGPropertyNode * getNode (const string &relative_path, bool create = false);
|
||||
SGPropertyNode * getNode (const char * relative_path, bool create = false);
|
||||
|
||||
|
||||
/**
|
||||
* Get a pointer to another node by relative path.
|
||||
*
|
||||
* This method leaves the index off the last member of the path,
|
||||
* so that the user can specify it separately (and save some
|
||||
* string building). For example, getNode("/bar[1]/foo", 3) is
|
||||
* exactly equivalent to getNode("bar[1]/foo[3]"). The index
|
||||
* provided overrides any given in the path itself for the last
|
||||
* component.
|
||||
*/
|
||||
SGPropertyNode * getNode (const char * relative_path, int index,
|
||||
bool create = false);
|
||||
|
||||
|
||||
/**
|
||||
* Get a const pointer to another node by relative path.
|
||||
*/
|
||||
const SGPropertyNode * getNode (const string &relative_path) const;
|
||||
const SGPropertyNode * getNode (const char * relative_path) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get a const pointer to another node by relative path.
|
||||
*
|
||||
* This method leaves the index off the last member of the path,
|
||||
* so that the user can specify it separate.
|
||||
*/
|
||||
const SGPropertyNode * getNode (const char * relative_path,
|
||||
int index) const;
|
||||
|
||||
|
||||
//
|
||||
@@ -694,7 +704,7 @@ public:
|
||||
/**
|
||||
* Check a single mode attribute for the property node.
|
||||
*/
|
||||
bool getAttribute (Attribute attr) const { return (_attr & attr); }
|
||||
bool getAttribute (Attribute attr) const { return ((_attr & attr) != 0); }
|
||||
|
||||
|
||||
/**
|
||||
@@ -761,7 +771,7 @@ public:
|
||||
/**
|
||||
* Get a string value for this node.
|
||||
*/
|
||||
string getStringValue () const;
|
||||
const char * getStringValue () const;
|
||||
|
||||
|
||||
|
||||
@@ -798,13 +808,13 @@ public:
|
||||
/**
|
||||
* Set a string value for this node.
|
||||
*/
|
||||
bool setStringValue (string value);
|
||||
bool setStringValue (const char * value);
|
||||
|
||||
|
||||
/**
|
||||
* Set a value of unspecified type for this node.
|
||||
*/
|
||||
bool setUnspecifiedValue (string value);
|
||||
bool setUnspecifiedValue (const char * value);
|
||||
|
||||
|
||||
//
|
||||
@@ -851,7 +861,7 @@ public:
|
||||
/**
|
||||
* Bind this node to an external string source.
|
||||
*/
|
||||
bool tie (const SGRawValue<string> &rawValue, bool useDefault = true);
|
||||
bool tie (const SGRawValue<const char *> &rawValue, bool useDefault = true);
|
||||
|
||||
|
||||
/**
|
||||
@@ -869,151 +879,151 @@ public:
|
||||
/**
|
||||
* Get another node's type.
|
||||
*/
|
||||
Type getType (const string &relative_path) const;
|
||||
Type getType (const char * relative_path) const;
|
||||
|
||||
|
||||
/**
|
||||
* Test whether another node has a leaf value.
|
||||
*/
|
||||
bool hasValue (const string &relative_path) const;
|
||||
bool hasValue (const char * relative_path) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get another node's value as a bool.
|
||||
*/
|
||||
bool getBoolValue (const string &relative_path,
|
||||
bool getBoolValue (const char * relative_path,
|
||||
bool defaultValue = false) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get another node's value as an int.
|
||||
*/
|
||||
int getIntValue (const string &relative_path,
|
||||
int getIntValue (const char * relative_path,
|
||||
int defaultValue = 0) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get another node's value as a long int.
|
||||
*/
|
||||
long getLongValue (const string &relative_path,
|
||||
long getLongValue (const char * relative_path,
|
||||
long defaultValue = 0L) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get another node's value as a float.
|
||||
*/
|
||||
float getFloatValue (const string &relative_path,
|
||||
float getFloatValue (const char * relative_path,
|
||||
float defaultValue = 0.0) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get another node's value as a double.
|
||||
*/
|
||||
double getDoubleValue (const string &relative_path,
|
||||
double getDoubleValue (const char * relative_path,
|
||||
double defaultValue = 0.0L) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get another node's value as a string.
|
||||
*/
|
||||
string getStringValue (const string &relative_path,
|
||||
string defaultValue = "") const;
|
||||
const char * getStringValue (const char * relative_path,
|
||||
const char * defaultValue = "") const;
|
||||
|
||||
|
||||
/**
|
||||
* Set another node's value as a bool.
|
||||
*/
|
||||
bool setBoolValue (const string &relative_path, bool value);
|
||||
bool setBoolValue (const char * relative_path, bool value);
|
||||
|
||||
|
||||
/**
|
||||
* Set another node's value as an int.
|
||||
*/
|
||||
bool setIntValue (const string &relative_path, int value);
|
||||
bool setIntValue (const char * relative_path, int value);
|
||||
|
||||
|
||||
/**
|
||||
* Set another node's value as a long int.
|
||||
*/
|
||||
bool setLongValue (const string &relative_path, long value);
|
||||
bool setLongValue (const char * relative_path, long value);
|
||||
|
||||
|
||||
/**
|
||||
* Set another node's value as a float.
|
||||
*/
|
||||
bool setFloatValue (const string &relative_path, float value);
|
||||
bool setFloatValue (const char * relative_path, float value);
|
||||
|
||||
|
||||
/**
|
||||
* Set another node's value as a double.
|
||||
*/
|
||||
bool setDoubleValue (const string &relative_path, double value);
|
||||
bool setDoubleValue (const char * relative_path, double value);
|
||||
|
||||
|
||||
/**
|
||||
* Set another node's value as a string.
|
||||
*/
|
||||
bool setStringValue (const string &relative_path, string value);
|
||||
bool setStringValue (const char * relative_path, const char * value);
|
||||
|
||||
|
||||
/**
|
||||
* Set another node's value with no specified type.
|
||||
*/
|
||||
bool setUnspecifiedValue (const string &relative_path, string value);
|
||||
bool setUnspecifiedValue (const char * relative_path, const char * value);
|
||||
|
||||
|
||||
/**
|
||||
* Test whether another node is bound to an external data source.
|
||||
*/
|
||||
bool isTied (const string &relative_path) const;
|
||||
bool isTied (const char * relative_path) const;
|
||||
|
||||
|
||||
/**
|
||||
* Bind another node to an external bool source.
|
||||
*/
|
||||
bool tie (const string &relative_path, const SGRawValue<bool> &rawValue,
|
||||
bool tie (const char * relative_path, const SGRawValue<bool> &rawValue,
|
||||
bool useDefault = true);
|
||||
|
||||
|
||||
/**
|
||||
* Bind another node to an external int source.
|
||||
*/
|
||||
bool tie (const string &relative_path, const SGRawValue<int> &rawValue,
|
||||
bool tie (const char * relative_path, const SGRawValue<int> &rawValue,
|
||||
bool useDefault = true);
|
||||
|
||||
|
||||
/**
|
||||
* Bind another node to an external long int source.
|
||||
*/
|
||||
bool tie (const string &relative_path, const SGRawValue<long> &rawValue,
|
||||
bool tie (const char * relative_path, const SGRawValue<long> &rawValue,
|
||||
bool useDefault = true);
|
||||
|
||||
|
||||
/**
|
||||
* Bind another node to an external float source.
|
||||
*/
|
||||
bool tie (const string &relative_path, const SGRawValue<float> &rawValue,
|
||||
bool tie (const char * relative_path, const SGRawValue<float> &rawValue,
|
||||
bool useDefault = true);
|
||||
|
||||
|
||||
/**
|
||||
* Bind another node to an external double source.
|
||||
*/
|
||||
bool tie (const string &relative_path, const SGRawValue<double> &rawValue,
|
||||
bool tie (const char * relative_path, const SGRawValue<double> &rawValue,
|
||||
bool useDefault = true);
|
||||
|
||||
|
||||
/**
|
||||
* Bind another node to an external string source.
|
||||
*/
|
||||
bool tie (const string &relative_path, const SGRawValue<string> &rawValue,
|
||||
bool tie (const char * relative_path, const SGRawValue<const char *> &rawValue,
|
||||
bool useDefault = true);
|
||||
|
||||
|
||||
/**
|
||||
* Unbind another node from any external data source.
|
||||
*/
|
||||
bool untie (const string &relative_path);
|
||||
bool untie (const char * relative_path);
|
||||
|
||||
|
||||
protected:
|
||||
@@ -1022,23 +1032,60 @@ protected:
|
||||
/**
|
||||
* Protected constructor for making new nodes on demand.
|
||||
*/
|
||||
SGPropertyNode (const string &name, int index, SGPropertyNode * parent);
|
||||
SGPropertyNode (const char * name, int index, SGPropertyNode * parent);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Get the raw value
|
||||
bool get_bool () const;
|
||||
int get_int () const;
|
||||
long get_long () const;
|
||||
float get_float () const;
|
||||
double get_double () const;
|
||||
const char * get_string () const;
|
||||
|
||||
// Set the raw value
|
||||
bool set_bool (bool value);
|
||||
bool set_int (int value);
|
||||
bool set_long (long value);
|
||||
bool set_float (float value);
|
||||
bool set_double (double value);
|
||||
bool set_string (const char * value);
|
||||
|
||||
|
||||
/**
|
||||
* Clear any existing value and set the type to NONE.
|
||||
*/
|
||||
void clear_value ();
|
||||
|
||||
string _name;
|
||||
|
||||
/**
|
||||
* Get the value as a string.
|
||||
*/
|
||||
const char * make_string () const;
|
||||
|
||||
|
||||
/**
|
||||
* Trace a read access.
|
||||
*/
|
||||
void trace_read () const;
|
||||
|
||||
|
||||
/**
|
||||
* Trace a write access.
|
||||
*/
|
||||
void trace_write () const;
|
||||
|
||||
mutable char _buffer[MAX_STRING_LEN+1];
|
||||
|
||||
class hash_table;
|
||||
|
||||
char * _name;
|
||||
int _index;
|
||||
SGPropertyNode * _parent;
|
||||
vector<SGPropertyNode *> _children;
|
||||
|
||||
|
||||
hash_table * _path_cache;
|
||||
Type _type;
|
||||
bool _tied;
|
||||
int _attr;
|
||||
@@ -1051,49 +1098,70 @@ private:
|
||||
SGRawValue<long> * long_val;
|
||||
SGRawValue<float> * float_val;
|
||||
SGRawValue<double> * double_val;
|
||||
SGRawValue<string> * string_val;
|
||||
SGRawValue<const char *> * string_val;
|
||||
} _value;
|
||||
|
||||
|
||||
};
|
||||
union {
|
||||
bool bool_val;
|
||||
int int_val;
|
||||
long long_val;
|
||||
float float_val;
|
||||
double double_val;
|
||||
char * string_val;
|
||||
} _local_val;
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// I/O functions.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* A very simple hash table with no remove functionality.
|
||||
*/
|
||||
class hash_table {
|
||||
public:
|
||||
|
||||
/**
|
||||
* An entry in a bucket in a hash table.
|
||||
*/
|
||||
class entry {
|
||||
public:
|
||||
entry ();
|
||||
virtual ~entry ();
|
||||
virtual const char * get_key () { return _key; }
|
||||
virtual void set_key (const char * key);
|
||||
virtual SGPropertyNode * get_value () { return _value; }
|
||||
virtual void set_value (SGPropertyNode * value);
|
||||
private:
|
||||
char * _key;
|
||||
SGPropertyNode * _value;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Read properties from an XML input stream.
|
||||
*/
|
||||
bool readProperties (istream &input, SGPropertyNode * start_node,
|
||||
const string &base = "");
|
||||
/**
|
||||
* A bucket in a hash table.
|
||||
*/
|
||||
class bucket {
|
||||
public:
|
||||
bucket ();
|
||||
virtual ~bucket ();
|
||||
virtual entry * get_entry (const char * key, bool create = false);
|
||||
private:
|
||||
int _length;
|
||||
entry ** _entries;
|
||||
};
|
||||
|
||||
friend class bucket;
|
||||
|
||||
/**
|
||||
* Read properties from an XML file.
|
||||
*/
|
||||
bool readProperties (const string &file, SGPropertyNode * start_node);
|
||||
hash_table ();
|
||||
virtual ~hash_table ();
|
||||
virtual SGPropertyNode * get (const char * key);
|
||||
virtual void put (const char * key, SGPropertyNode * value);
|
||||
|
||||
private:
|
||||
unsigned int hashcode (const char * key);
|
||||
unsigned int _data_length;
|
||||
bucket ** _data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Write properties to an XML output stream.
|
||||
*/
|
||||
bool writeProperties (ostream &output, const SGPropertyNode * start_node);
|
||||
|
||||
|
||||
/**
|
||||
* Write properties to an XML file.
|
||||
*/
|
||||
bool writeProperties (const string &file, const SGPropertyNode * start_node);
|
||||
|
||||
|
||||
/**
|
||||
* Copy properties from one node to another.
|
||||
*/
|
||||
bool copyProperties (const SGPropertyNode *in, SGPropertyNode *out);
|
||||
|
||||
};
|
||||
|
||||
#endif // __PROPS_HXX
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "sg_path.hxx"
|
||||
#include "props.hxx"
|
||||
#include "props_io.hxx"
|
||||
|
||||
#include STL_IOSTREAM
|
||||
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
@@ -43,7 +44,9 @@ class PropsVisitor : public XMLVisitor
|
||||
public:
|
||||
|
||||
PropsVisitor (SGPropertyNode * root, const string &base)
|
||||
: _ok(true), _root(root), _level(0), _base(base) {}
|
||||
: _root(root), _level(0), _base(base), _hasException(false) {}
|
||||
|
||||
virtual ~PropsVisitor () {}
|
||||
|
||||
void startXML ();
|
||||
void endXML ();
|
||||
@@ -51,9 +54,13 @@ public:
|
||||
void endElement (const char * name);
|
||||
void data (const char * s, int length);
|
||||
void warning (const char * message, int line, int column);
|
||||
void error (const char * message, int line, int column);
|
||||
|
||||
bool isOK () const { return _ok; }
|
||||
bool hasException () const { return _hasException; }
|
||||
sg_io_exception &getException () { return _exception; }
|
||||
void setException (const sg_io_exception &exception) {
|
||||
_exception = exception;
|
||||
_hasException = true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -84,12 +91,13 @@ private:
|
||||
_level--;
|
||||
}
|
||||
|
||||
bool _ok;
|
||||
string _data;
|
||||
SGPropertyNode * _root;
|
||||
int _level;
|
||||
vector<State> _state_stack;
|
||||
string _base;
|
||||
sg_io_exception _exception;
|
||||
bool _hasException;
|
||||
};
|
||||
|
||||
void
|
||||
@@ -120,9 +128,11 @@ checkFlag (const char * flag, bool defaultState = true)
|
||||
else if (string(flag) == "n")
|
||||
return false;
|
||||
else {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Unrecognized flag value '" << flag
|
||||
<< "', assuming yes");
|
||||
return true;
|
||||
string message = "Unrecognized flag value '";
|
||||
message += flag;
|
||||
message += '\'';
|
||||
// FIXME: add location info
|
||||
throw sg_io_exception(message, "SimGear Property Reader");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,9 +143,10 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
|
||||
|
||||
if (_level == 0) {
|
||||
if (string(name) != (string)"PropertyList") {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Root element name is " <<
|
||||
name << "; expected PropertyList");
|
||||
_ok = false;
|
||||
string message = "Root element name is ";
|
||||
message += name;
|
||||
message += "; expected PropertyList";
|
||||
throw sg_io_exception(message, "SimGear Property Reader");
|
||||
}
|
||||
push_state(_root, "", DEFAULT_MODE);
|
||||
}
|
||||
@@ -171,6 +182,12 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
|
||||
attval = atts.getValue("archive");
|
||||
if (checkFlag(attval, false))
|
||||
mode |= SGPropertyNode::ARCHIVE;
|
||||
attval = atts.getValue("trace-read");
|
||||
if (checkFlag(attval, false))
|
||||
mode |= SGPropertyNode::TRACE_READ;
|
||||
attval = atts.getValue("trace-write");
|
||||
if (checkFlag(attval, false))
|
||||
mode |= SGPropertyNode::TRACE_WRITE;
|
||||
|
||||
// Check for an alias.
|
||||
attval = atts.getValue("alias");
|
||||
@@ -183,13 +200,11 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts)
|
||||
attval = atts.getValue("include");
|
||||
if (attval != 0) {
|
||||
SGPath path(SGPath(_base).dir());
|
||||
cerr << "Base is " << _base << endl;
|
||||
cerr << "Dir is " << SGPath(_base).dir() << endl;
|
||||
path.append(attval);
|
||||
if (!readProperties(path.str(), node)) {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Failed to read include file "
|
||||
<< attval);
|
||||
_ok = false;
|
||||
try {
|
||||
readProperties(path.str(), node);
|
||||
} catch (sg_io_exception &e) {
|
||||
setException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,13 +235,15 @@ PropsVisitor::endElement (const char * name)
|
||||
} else if (st.type == "double") {
|
||||
ret = st.node->setDoubleValue(strtod(_data.c_str(), 0));
|
||||
} else if (st.type == "string") {
|
||||
ret = st.node->setStringValue(_data);
|
||||
ret = st.node->setStringValue(_data.c_str());
|
||||
} else if (st.type == "unspecified") {
|
||||
ret = st.node->setUnspecifiedValue(_data);
|
||||
ret = st.node->setUnspecifiedValue(_data.c_str());
|
||||
} else {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Unrecognized data type " << st.type
|
||||
<< " assuming 'unspecified'");
|
||||
ret = st.node->setUnspecifiedValue(_data);
|
||||
string message = "Unrecognized data type '";
|
||||
message += st.type;
|
||||
message += '\'';
|
||||
// FIXME: add location information
|
||||
throw sg_io_exception(message, "SimGear Property Reader");
|
||||
}
|
||||
if (!ret)
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "readProperties: Failed to set "
|
||||
@@ -256,14 +273,6 @@ PropsVisitor::warning (const char * message, int line, int column)
|
||||
<< message << " at line " << line << ", column " << column);
|
||||
}
|
||||
|
||||
void
|
||||
PropsVisitor::error (const char * message, int line, int column)
|
||||
{
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "readProperties: FATAL: " <<
|
||||
message << " at line " << line << ", column " << column);
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@@ -279,12 +288,14 @@ PropsVisitor::error (const char * message, int line, int column)
|
||||
* @param base A base path for resolving external include references.
|
||||
* @return true if the read succeeded, false otherwise.
|
||||
*/
|
||||
bool
|
||||
void
|
||||
readProperties (istream &input, SGPropertyNode * start_node,
|
||||
const string &base)
|
||||
{
|
||||
PropsVisitor visitor(start_node, base);
|
||||
return readXML(input, visitor) && visitor.isOK();
|
||||
readXML(input, visitor, base);
|
||||
if (visitor.hasException())
|
||||
throw visitor.getException();
|
||||
}
|
||||
|
||||
|
||||
@@ -295,18 +306,13 @@ readProperties (istream &input, SGPropertyNode * start_node,
|
||||
* @param start_node The root node for reading properties.
|
||||
* @return true if the read succeeded, false otherwise.
|
||||
*/
|
||||
bool
|
||||
void
|
||||
readProperties (const string &file, SGPropertyNode * start_node)
|
||||
{
|
||||
cerr << "Reading properties from " << file << endl;
|
||||
ifstream input(file.c_str());
|
||||
if (input.good()) {
|
||||
return readProperties(input, start_node, file);
|
||||
} else {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Error reading property list from file "
|
||||
<< file);
|
||||
return false;
|
||||
}
|
||||
PropsVisitor visitor(start_node, file);
|
||||
readXML(file, visitor);
|
||||
if (visitor.hasException())
|
||||
throw visitor.getException();
|
||||
}
|
||||
|
||||
|
||||
@@ -338,6 +344,9 @@ getTypeName (SGPropertyNode::Type type)
|
||||
return "double";
|
||||
case SGPropertyNode::STRING:
|
||||
return "string";
|
||||
case SGPropertyNode::ALIAS:
|
||||
case SGPropertyNode::NONE:
|
||||
return "unspecified";
|
||||
}
|
||||
|
||||
// keep the compiler from squawking
|
||||
@@ -420,21 +429,21 @@ isArchivable (const SGPropertyNode * node)
|
||||
|
||||
|
||||
static bool
|
||||
writeNode (ostream &output, const SGPropertyNode * node, int indent)
|
||||
writeNode (ostream &output, const SGPropertyNode * node,
|
||||
bool write_all, int indent)
|
||||
{
|
||||
// Don't write the node or any of
|
||||
// its descendants unless it is
|
||||
// allowed to be archived.
|
||||
if (!isArchivable(node))
|
||||
if (!write_all && !isArchivable(node))
|
||||
return true; // Everything's OK, but we won't write.
|
||||
|
||||
const string &name = node->getName();
|
||||
int index = node->getIndex();
|
||||
const string name = node->getName();
|
||||
int nChildren = node->nChildren();
|
||||
|
||||
// If there is a literal value,
|
||||
// write it first.
|
||||
if (node->hasValue() && node->getAttribute(SGPropertyNode::ARCHIVE)) {
|
||||
if (node->hasValue() && (write_all || node->getAttribute(SGPropertyNode::ARCHIVE))) {
|
||||
doIndent(output, indent);
|
||||
output << '<' << name;
|
||||
writeAtts(output, node);
|
||||
@@ -450,15 +459,14 @@ writeNode (ostream &output, const SGPropertyNode * node, int indent)
|
||||
}
|
||||
}
|
||||
|
||||
// If there are children, write them
|
||||
// next.
|
||||
// If there are children, write them next.
|
||||
if (nChildren > 0 || node->isAlias()) {
|
||||
doIndent(output, indent);
|
||||
output << '<' << name;
|
||||
writeAtts(output, node);
|
||||
output << '>' << endl;
|
||||
for (int i = 0; i < nChildren; i++)
|
||||
writeNode(output, node->getChild(i), indent + INDENT_STEP);
|
||||
writeNode(output, node->getChild(i), write_all, indent + INDENT_STEP);
|
||||
doIndent(output, indent);
|
||||
output << "</" << name << '>' << endl;
|
||||
}
|
||||
@@ -467,15 +475,9 @@ writeNode (ostream &output, const SGPropertyNode * node, int indent)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write a property tree to an output stream in XML format.
|
||||
*
|
||||
* @param output The output stream.
|
||||
* @param start_node The root node to write.
|
||||
* @return true if the write succeeded, false otherwise.
|
||||
*/
|
||||
bool
|
||||
writeProperties (ostream &output, const SGPropertyNode * start_node)
|
||||
void
|
||||
writeProperties (ostream &output, const SGPropertyNode * start_node,
|
||||
bool write_all)
|
||||
{
|
||||
int nChildren = start_node->nChildren();
|
||||
|
||||
@@ -483,32 +485,22 @@ writeProperties (ostream &output, const SGPropertyNode * start_node)
|
||||
output << "<PropertyList>" << endl;
|
||||
|
||||
for (int i = 0; i < nChildren; i++) {
|
||||
writeNode(output, start_node->getChild(i), INDENT_STEP);
|
||||
writeNode(output, start_node->getChild(i), write_all, INDENT_STEP);
|
||||
}
|
||||
|
||||
output << "</PropertyList>" << endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write a property tree to a file in XML format.
|
||||
*
|
||||
* @param file The destination file.
|
||||
* @param start_node The root node to write.
|
||||
* @return true if the write succeeded, false otherwise.
|
||||
*/
|
||||
bool
|
||||
writeProperties (const string &file, const SGPropertyNode * start_node)
|
||||
void
|
||||
writeProperties (const string &file, const SGPropertyNode * start_node,
|
||||
bool write_all)
|
||||
{
|
||||
ofstream output(file.c_str());
|
||||
if (output.good()) {
|
||||
return writeProperties(output, start_node);
|
||||
writeProperties(output, start_node, write_all);
|
||||
} else {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Cannot write properties to file "
|
||||
<< file);
|
||||
return false;
|
||||
throw sg_io_exception("Cannot open file", sg_location(file));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -565,7 +557,9 @@ copyProperties (const SGPropertyNode *in, SGPropertyNode *out)
|
||||
retval = false;
|
||||
break;
|
||||
default:
|
||||
throw string("Unrecognized SGPropertyNode type");
|
||||
string message = "Unknown internal SGPropertyNode type";
|
||||
message += in->getType();
|
||||
throw sg_error(message, "SimGear Property Reader");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
68
simgear/misc/props_io.hxx
Normal file
68
simgear/misc/props_io.hxx
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* \file props_io.hxx
|
||||
* Interface definition for property list io.
|
||||
* Started Fall 2000 by David Megginson, david@megginson.com
|
||||
* This code is released into the Public Domain.
|
||||
*
|
||||
* See props.html for documentation [replace with URL when available].
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __PROPS_IO_HXX
|
||||
#define __PROPS_IO_HXX
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/misc/props.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include STL_STRING
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include STL_IOSTREAM
|
||||
|
||||
SG_USING_STD(string);
|
||||
SG_USING_STD(vector);
|
||||
SG_USING_STD(map);
|
||||
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
SG_USING_STD(istream);
|
||||
SG_USING_STD(ostream);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Read properties from an XML input stream.
|
||||
*/
|
||||
void readProperties (istream &input, SGPropertyNode * start_node,
|
||||
const string &base = "");
|
||||
|
||||
|
||||
/**
|
||||
* Read properties from an XML file.
|
||||
*/
|
||||
void readProperties (const string &file, SGPropertyNode * start_node);
|
||||
|
||||
|
||||
/**
|
||||
* Write properties to an XML output stream.
|
||||
*/
|
||||
void writeProperties (ostream &output, const SGPropertyNode * start_node,
|
||||
bool write_all = false);
|
||||
|
||||
|
||||
/**
|
||||
* Write properties to an XML file.
|
||||
*/
|
||||
void writeProperties (const string &file, const SGPropertyNode * start_node,
|
||||
bool write_all = false);
|
||||
|
||||
|
||||
/**
|
||||
* Copy properties from one node to another.
|
||||
*/
|
||||
bool copyProperties (const SGPropertyNode *in, SGPropertyNode *out);
|
||||
|
||||
|
||||
#endif // __PROPS_IO_HXX
|
||||
|
||||
// end of props_io.hxx
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include STL_IOSTREAM
|
||||
#include "props.hxx"
|
||||
#include "props_io.hxx"
|
||||
|
||||
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
SG_USING_STD(cout);
|
||||
@@ -52,7 +53,7 @@ static double getNum (int index) { return 1.0 / index; }
|
||||
static void
|
||||
show_values (const SGPropertyNode * node)
|
||||
{
|
||||
cout << "Bool: " << node->getBoolValue() << endl;
|
||||
cout << "Bool: " << (node->getBoolValue() ? "true" : "false") << endl;
|
||||
cout << "Int: " << node->getIntValue() << endl;
|
||||
cout << "Float: " << node->getFloatValue() << endl;
|
||||
cout << "Double: " << node->getDoubleValue() << endl;
|
||||
@@ -274,7 +275,7 @@ test_value ()
|
||||
static void
|
||||
dump_node (const SGPropertyNode * node)
|
||||
{
|
||||
writeProperties(cout, node);
|
||||
writeProperties(cout, node, true);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -332,13 +333,15 @@ int main (int ac, char ** av)
|
||||
test_property_nodes();
|
||||
|
||||
for (int i = 1; i < ac; i++) {
|
||||
cout << "Reading " << av[i] << endl;
|
||||
SGPropertyNode root;
|
||||
if (!readProperties(av[i], &root))
|
||||
cerr << "Failed to read properties from " << av[i] << endl;
|
||||
else
|
||||
writeProperties(cout, &root);
|
||||
cout << endl;
|
||||
try {
|
||||
cout << "Reading " << av[i] << endl;
|
||||
SGPropertyNode root;
|
||||
readProperties(av[i], &root);
|
||||
writeProperties(cout, &root, true);
|
||||
cout << endl;
|
||||
} catch (string &message) {
|
||||
cout << "Aborted with " << message << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
|
||||
#include <simgear_config.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sg_path.hxx"
|
||||
|
||||
@@ -33,34 +34,35 @@
|
||||
// should be used in file or directory names. In windoze, allow the
|
||||
// second character to be a ":" for things like c:\foo\bar
|
||||
|
||||
static string fix_path( const string path ) {
|
||||
string result = path;
|
||||
|
||||
for ( int i = 0; i < (int)path.size(); ++i ) {
|
||||
void
|
||||
SGPath::fix()
|
||||
{
|
||||
for ( string::size_type i = 0; i < path.size(); ++i ) {
|
||||
#if defined( WIN32 )
|
||||
// for windoze, don't replace the ":" for the second character
|
||||
if ( i == 1 ) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if ( result[i] == SG_BAD_PATH_SEP ) {
|
||||
result[i] = SG_PATH_SEP;
|
||||
if ( path[i] == SG_BAD_PATH_SEP ) {
|
||||
path[i] = SG_PATH_SEP;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// default constructor
|
||||
SGPath::SGPath() {
|
||||
path = "";
|
||||
SGPath::SGPath()
|
||||
: path("")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// create a path based on "path"
|
||||
SGPath::SGPath( const string p ) {
|
||||
set( p );
|
||||
SGPath::SGPath( const std::string& p )
|
||||
: path(p)
|
||||
{
|
||||
fix();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,36 +72,35 @@ SGPath::~SGPath() {
|
||||
|
||||
|
||||
// set path
|
||||
void SGPath::set( const string p ) {
|
||||
path = fix_path( p );
|
||||
void SGPath::set( const string& p ) {
|
||||
path = p;
|
||||
fix();
|
||||
}
|
||||
|
||||
|
||||
// append another piece to the existing path
|
||||
void SGPath::append( const string p ) {
|
||||
string part = fix_path( p );
|
||||
|
||||
void SGPath::append( const string& p ) {
|
||||
if ( path.size() == 0 ) {
|
||||
path = part;
|
||||
path = p;
|
||||
} else {
|
||||
if ( part[0] != SG_PATH_SEP ) {
|
||||
if ( p[0] != SG_PATH_SEP ) {
|
||||
path += SG_PATH_SEP;
|
||||
}
|
||||
path += part;
|
||||
path += p;
|
||||
}
|
||||
fix();
|
||||
}
|
||||
|
||||
|
||||
// concatenate a string to the end of the path without inserting a
|
||||
// path separator
|
||||
void SGPath::concat( const string p ) {
|
||||
string part = fix_path( p );
|
||||
|
||||
void SGPath::concat( const string& p ) {
|
||||
if ( path.size() == 0 ) {
|
||||
path = part;
|
||||
path = p;
|
||||
} else {
|
||||
path += part;
|
||||
path += p;
|
||||
}
|
||||
fix();
|
||||
}
|
||||
|
||||
|
||||
@@ -112,3 +113,12 @@ string SGPath::dir() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
bool SGPath::exists() const {
|
||||
FILE* fp = fopen( path.c_str(), "r");
|
||||
if (fp == 0) {
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
* Construct a path based on the starting path provided.
|
||||
* @param p initial path
|
||||
*/
|
||||
SGPath( const string p );
|
||||
SGPath( const string& p );
|
||||
|
||||
/** Destructor */
|
||||
~SGPath();
|
||||
@@ -78,20 +78,21 @@ public:
|
||||
* Set path to a new value
|
||||
* @param p new path
|
||||
*/
|
||||
void set( const string p );
|
||||
void set( const string& p );
|
||||
SGPath& operator= ( const char* p ) { this->set(p); return *this; }
|
||||
|
||||
/**
|
||||
* Append another piece to the existing path. Inserts a path
|
||||
* separator between the existing component and the new component.
|
||||
* @param p additional path component */
|
||||
void append( const string p );
|
||||
void append( const string& p );
|
||||
|
||||
/**
|
||||
* Concatenate a string to the end of the path without inserting a
|
||||
* path separator.
|
||||
* @param p addtional path suffix
|
||||
*/
|
||||
void concat( const string p );
|
||||
void concat( const string& p );
|
||||
|
||||
/**
|
||||
* Get the directory part of the path.
|
||||
@@ -102,12 +103,23 @@ public:
|
||||
/** Get the path string
|
||||
* @return path string
|
||||
*/
|
||||
inline string str() const { return path; }
|
||||
string str() const { return path; }
|
||||
|
||||
/** Get the path string
|
||||
* @return path in "C" string (ptr to char array) form.
|
||||
*/
|
||||
inline const char *c_str() { return path.c_str(); }
|
||||
const char* c_str() { return path.c_str(); }
|
||||
|
||||
/**
|
||||
* Determine if file exists by attempting to fopen it.
|
||||
* @return true if file exists, otherwise returns false.
|
||||
*/
|
||||
bool exists() const;
|
||||
|
||||
private:
|
||||
|
||||
void fix();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -30,11 +30,7 @@
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
# include <zlib.h>
|
||||
#else
|
||||
# include <simgear/zlib/zlib.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
// At least Irix needs this
|
||||
#ifdef SG_HAVE_NATIVE_SGI_COMPILERS
|
||||
|
||||
5
simgear/route/.cvsignore
Normal file
5
simgear/route/.cvsignore
Normal file
@@ -0,0 +1,5 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
routetest
|
||||
waytest
|
||||
@@ -8,7 +8,11 @@ libsgroute_a_SOURCES = \
|
||||
route.cxx \
|
||||
waypoint.cxx
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = waytest routetest
|
||||
|
||||
|
||||
@@ -38,11 +38,6 @@ SGWayPoint::SGWayPoint( const double lon, const double lat, const double alt,
|
||||
}
|
||||
|
||||
|
||||
SGWayPoint::SGWayPoint() {
|
||||
SGWayPoint( 0.0, 0.0, 0.0, WGS84, "" );
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
SGWayPoint::~SGWayPoint() {
|
||||
}
|
||||
|
||||
@@ -79,9 +79,6 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
/** Default constructor */
|
||||
SGWayPoint();
|
||||
|
||||
/**
|
||||
* Construct a waypoint
|
||||
* @param lon destination longitude
|
||||
@@ -90,8 +87,9 @@ public:
|
||||
* @param mode type of coordinates/math to use
|
||||
* @param s waypoint identifier
|
||||
*/
|
||||
SGWayPoint( const double lon, const double lat, const double alt,
|
||||
const modetype m = WGS84, const string s = "" );
|
||||
SGWayPoint( const double lon = 0.0, const double lat = 0.0,
|
||||
const double alt = 0.0, const modetype m = WGS84,
|
||||
const string s = "" );
|
||||
|
||||
/** Destructor */
|
||||
~SGWayPoint();
|
||||
|
||||
3
simgear/screen/.cvsignore
Normal file
3
simgear/screen/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -2,12 +2,25 @@ includedir = @includedir@/screen
|
||||
|
||||
lib_LIBRARIES = libsgscreen.a
|
||||
|
||||
include_HEADERS = screen-dump.hxx tr.h
|
||||
if ENABLE_JPEG_SERVER
|
||||
IMAGE_SERVER_INCL = jpgfactory.hxx
|
||||
IMAGE_SERVER_SRCS = jpgfactory.cxx
|
||||
else
|
||||
IMAGE_SERVER_INCL =
|
||||
IMAGE_SERVER_SRCS =
|
||||
endif
|
||||
|
||||
include_HEADERS = $(IMAGE_SERVER_INCL) screen-dump.hxx tr.h
|
||||
|
||||
libsgscreen_a_SOURCES = \
|
||||
GLBitmaps.cxx GLBitmaps.h \
|
||||
$(IMAGE_SERVER_SRCS) \
|
||||
screen-dump.cxx \
|
||||
tr.cxx \
|
||||
win32-printer.h
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
371
simgear/screen/jpgfactory.cxx
Normal file
371
simgear/screen/jpgfactory.cxx
Normal file
@@ -0,0 +1,371 @@
|
||||
// jpgfactory.cxx -- jpeg frontend for TR library
|
||||
//
|
||||
// Written by Norman Vine, started August 2001.
|
||||
//
|
||||
// Copyright (C) 2001 Norman Vine - nhv@yahoo.com
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id:
|
||||
|
||||
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#include "jpgfactory.hxx"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static void init_destination (j_compress_ptr cinfo);
|
||||
static void term_destination (j_compress_ptr cinfo);
|
||||
static boolean empty_output_buffer (j_compress_ptr cinfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct jpeg_destination_mgr pub; /* public fields */
|
||||
unsigned char * outfile; /* target stream */
|
||||
JOCTET * buffer; /* start of buffer */
|
||||
int numbytes; /* num bytes used */
|
||||
int maxsize; /* size of outfile */
|
||||
int error; /* error flag */
|
||||
} my_destination_mgr;
|
||||
|
||||
typedef my_destination_mgr * my_dest_ptr;
|
||||
|
||||
/* Where should this go <simgear/screen/tr.h> ?? */
|
||||
extern void trRenderFrame( void );
|
||||
|
||||
trJpgFactory::trJpgFactory() {
|
||||
imageWidth = imageHeight = 0;
|
||||
tile = NULL;
|
||||
buffer = NULL;
|
||||
IMAGE = NULL;
|
||||
tr = NULL;
|
||||
cinfo.dest = NULL;
|
||||
}
|
||||
|
||||
trJpgFactory::~trJpgFactory() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
/*
|
||||
* deallocate our dynamic parts
|
||||
*/
|
||||
|
||||
void trJpgFactory::destroy( int error )
|
||||
{
|
||||
if( error )
|
||||
printf( "!! Malloc Failure trJpgFactory ( %d )!!\n",
|
||||
error );
|
||||
|
||||
if( cinfo.dest ) jpeg_destroy_compress(&cinfo);
|
||||
if( tr ) trDelete(tr);
|
||||
if( IMAGE ) delete [] IMAGE;
|
||||
if( buffer ) delete [] buffer;
|
||||
if( tile ) delete [] tile;
|
||||
}
|
||||
|
||||
/*
|
||||
* allocate and initialize the jpeg compress struct
|
||||
* application needs to dealocate this
|
||||
*/
|
||||
|
||||
int trJpgFactory::jpeg_init()
|
||||
{
|
||||
j_compress_ptr cinfoPtr = &cinfo;
|
||||
|
||||
cinfoPtr->err = jpeg_std_error(&jerr);
|
||||
jpeg_create_compress(cinfoPtr);
|
||||
|
||||
/* following taken from jpeg library exaample code */
|
||||
cinfoPtr->dest = (struct jpeg_destination_mgr *)
|
||||
(*cinfoPtr->mem->alloc_small)
|
||||
((j_common_ptr)cinfoPtr,
|
||||
JPOOL_PERMANENT,
|
||||
sizeof(my_destination_mgr));
|
||||
|
||||
my_dest_ptr dest = (my_dest_ptr)cinfoPtr->dest;
|
||||
|
||||
if( !dest ) {
|
||||
destroy(5);
|
||||
return 5;
|
||||
}
|
||||
|
||||
dest->pub.init_destination = init_destination;
|
||||
dest->pub.empty_output_buffer = empty_output_buffer;
|
||||
dest->pub.term_destination = term_destination;
|
||||
dest->outfile = NULL;
|
||||
dest->numbytes = 0;
|
||||
dest->maxsize = 0;
|
||||
|
||||
cinfoPtr->image_width = imageWidth;
|
||||
cinfoPtr->image_height = imageHeight;
|
||||
cinfoPtr->input_components = 3;
|
||||
cinfoPtr->in_color_space = JCS_RGB;
|
||||
jpeg_set_defaults(cinfoPtr);
|
||||
jpeg_set_quality(cinfoPtr, (100 * 90) >> 8, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* may also be used as reinit() to change image size
|
||||
*/
|
||||
|
||||
int trJpgFactory::init(int width, int height )
|
||||
{
|
||||
destroy();
|
||||
|
||||
if( width <= 0 || height <= 0 ) {
|
||||
imageWidth = DEFAULT_XS;
|
||||
imageHeight = DEFAULT_YS;
|
||||
} else {
|
||||
imageWidth = width;
|
||||
imageHeight = height;
|
||||
}
|
||||
|
||||
int bufsize = imageWidth * imageHeight * 3 * sizeof(GLubyte);
|
||||
|
||||
/* allocate buffer large enough to store one tile */
|
||||
tile = new GLubyte[bufsize];
|
||||
if (!tile) {
|
||||
destroy(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* allocate buffer to hold a row of tiles */
|
||||
buffer = new GLubyte[ bufsize ];
|
||||
if (!buffer) {
|
||||
destroy(2);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* this should be big enough */
|
||||
IMAGESIZE = bufsize + 1024;
|
||||
IMAGE = new unsigned char[ IMAGESIZE ];
|
||||
if( !IMAGE ) {
|
||||
destroy(3);
|
||||
return 3;
|
||||
}
|
||||
|
||||
tr = trNew();
|
||||
if( !tr ) {
|
||||
destroy(4);
|
||||
return 4;
|
||||
}
|
||||
|
||||
trRowOrder(tr, TR_TOP_TO_BOTTOM);
|
||||
trTileSize(tr, imageWidth, imageHeight, 0);
|
||||
trImageSize(tr, imageWidth, imageHeight);
|
||||
trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
|
||||
|
||||
return jpeg_init();
|
||||
}
|
||||
|
||||
/*
|
||||
*compress the image
|
||||
*/
|
||||
|
||||
int trJpgFactory::compress()
|
||||
{
|
||||
JSAMPROW row_pointer[1];
|
||||
int row_stride;
|
||||
|
||||
/* to keep track of jpeg library routines */
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo.dest;
|
||||
|
||||
//printf("\tjpeg_start_compress(&cinfo, TRUE)\n");
|
||||
jpeg_start_compress(&cinfo, TRUE);
|
||||
if( !dest->error ) {
|
||||
dest->outfile = IMAGE;
|
||||
dest->maxsize = IMAGESIZE;
|
||||
row_stride = cinfo.image_width * 3;
|
||||
|
||||
while( cinfo.next_scanline < cinfo.image_height &&
|
||||
!dest->error )
|
||||
{
|
||||
row_pointer[0] = buffer + (cinfo.next_scanline * row_stride);
|
||||
jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
}
|
||||
}
|
||||
if( !dest->error ) {
|
||||
// printf("\n\tBEFORE: jpeg_finish_compress(&cinfo)\n");
|
||||
jpeg_finish_compress(&cinfo);
|
||||
// printf("\tAFTER: jpeg_finish_compress(&cinfo)\n");
|
||||
} else {
|
||||
printf("INTERNAL JPEG_FACTORY ERROR\n");
|
||||
jpeg_abort_compress(&cinfo);
|
||||
/* OK - I am paranoid */
|
||||
dest->numbytes = 0;
|
||||
}
|
||||
return dest->numbytes;
|
||||
}
|
||||
|
||||
/*
|
||||
* Makes the image then calls compress()
|
||||
*/
|
||||
|
||||
int trJpgFactory::render()
|
||||
{
|
||||
if( !tr ) {
|
||||
printf("!! NO tr !!\n trJpgFactory::render()\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make sure we have SSG projection primed for current view
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
sgFrustum *frustum = ssgGetFrustum();
|
||||
trFrustum(tr,
|
||||
frustum->getLeft(), frustum->getRight(),
|
||||
frustum->getBot(), frustum->getTop(),
|
||||
frustum->getNear(), frustum->getFar());
|
||||
|
||||
/* just to be safe... */
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
// printf("\ttrBeginTile(tr)\n");
|
||||
trBeginTile(tr);
|
||||
trRenderFrame();
|
||||
trEndTile(tr);
|
||||
|
||||
/* just to be safe */
|
||||
int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
|
||||
int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
|
||||
|
||||
/* reverse image top to bottom */
|
||||
int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
|
||||
int bytesPerTileRow = imageWidth * 3*sizeof(GLubyte);
|
||||
int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
|
||||
int i;
|
||||
for (i=0;i<imageHeight;i++) {
|
||||
memcpy(buffer + (curTileHeight-1-i) * bytesPerImageRow, /* Dest */
|
||||
tile + i*bytesPerTileRow, /* Src */
|
||||
bytesPerCurrentTileRow); /* Byte count*/
|
||||
}
|
||||
|
||||
// printf("exit trJpgFactory::render()\n");
|
||||
return compress();
|
||||
}
|
||||
|
||||
|
||||
#define OUTPUT_BUF_SIZE 4096
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialize destination --- called by jpeg_start_compress
|
||||
* before any data is actually written.
|
||||
*/
|
||||
|
||||
static void init_destination (j_compress_ptr cinfo)
|
||||
{
|
||||
// printf("enter init_destination()\n");
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
|
||||
/* following taken from jpeg library exaample code
|
||||
* Allocate the output buffer ---
|
||||
* it automaically will be released when done with image */
|
||||
|
||||
dest->buffer = (JOCTET *)(*cinfo->mem->alloc_small)
|
||||
((j_common_ptr)cinfo, JPOOL_IMAGE,
|
||||
OUTPUT_BUF_SIZE * sizeof(JOCTET) );
|
||||
|
||||
if( !dest->buffer ) {
|
||||
printf("MALLOC FAILED jpegFactory init_destination()\n");
|
||||
dest->error = TRUE;
|
||||
} else {
|
||||
dest->error = FALSE;
|
||||
}
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||
dest->numbytes = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Empty the output buffer --- called whenever buffer fills up.
|
||||
*/
|
||||
|
||||
static boolean empty_output_buffer (j_compress_ptr cinfo)
|
||||
{
|
||||
// printf("enter empty_output_buffer(%d)\n", OUTPUT_BUF_SIZE);
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
|
||||
if( (!dest->error) &&
|
||||
((dest->numbytes + OUTPUT_BUF_SIZE) < dest->maxsize) )
|
||||
{
|
||||
memcpy( dest->outfile+dest->numbytes, dest->buffer, (size_t)OUTPUT_BUF_SIZE);
|
||||
|
||||
dest->pub.next_output_byte = dest->buffer;
|
||||
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
||||
|
||||
dest->numbytes += OUTPUT_BUF_SIZE;
|
||||
} else {
|
||||
printf("BUFFER OVERFLOW jpegFactory empty_output_buffer()\n");
|
||||
dest->numbytes = 0;
|
||||
dest->error = TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Terminate destination --- called by jpeg_finish_compress
|
||||
* after all data has been written. Usually needs to flush buffer.
|
||||
*
|
||||
* NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
|
||||
* application must deal with any cleanup that should happen even
|
||||
* for error exit.
|
||||
*/
|
||||
|
||||
static void term_destination (j_compress_ptr cinfo)
|
||||
{
|
||||
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
|
||||
|
||||
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
|
||||
|
||||
if( (!dest->error) &&
|
||||
((dest->numbytes + datacount) < (unsigned int)dest->maxsize) )
|
||||
{
|
||||
memcpy( dest->outfile+dest->numbytes, dest->buffer, datacount);
|
||||
dest->numbytes += datacount;
|
||||
} else {
|
||||
printf("BUFFER OVERFLOW jpegFactory term_destination()\n");
|
||||
dest->numbytes = 0;
|
||||
dest->error = TRUE;
|
||||
}
|
||||
// printf(" term_destination(%d) total %d\n", datacount, dest->numbytes );
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
75
simgear/screen/jpgfactory.hxx
Normal file
75
simgear/screen/jpgfactory.hxx
Normal file
@@ -0,0 +1,75 @@
|
||||
// jpgfactory.hxx -- jpeg frontend for TR library
|
||||
//
|
||||
// Written by Norman Vine, started August 2001.
|
||||
//
|
||||
// Copyright (C) 2001 Norman Vine - nhv@yahoo.com
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License as
|
||||
// published by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id:
|
||||
|
||||
#ifndef _FG_JPGFACTORY_HXX
|
||||
#define _FG_JPGFACTORY_HXX
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <jpeglib.h>
|
||||
#include <jerror.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <simgear/screen/tr.h>
|
||||
|
||||
/* should look at how VNC does this */
|
||||
class trJpgFactory {
|
||||
private:
|
||||
int imageWidth;
|
||||
int imageHeight;
|
||||
GLubyte *tile;
|
||||
GLubyte *buffer;
|
||||
|
||||
TRcontext *tr;
|
||||
unsigned char *IMAGE;
|
||||
int IMAGESIZE;
|
||||
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
|
||||
int jpeg_init();
|
||||
int compress();
|
||||
|
||||
typedef enum {
|
||||
DEFAULT_XS = 320,
|
||||
DEFAULT_YS = 240
|
||||
} JPG_FACTORY_ENUM;
|
||||
|
||||
public:
|
||||
trJpgFactory();
|
||||
~trJpgFactory();
|
||||
|
||||
int init(int width = 0, int height = 0 );
|
||||
void destroy(int error = 0);
|
||||
|
||||
int render();
|
||||
unsigned char *data() { return IMAGE ; }
|
||||
|
||||
struct jpeg_compress_struct *JPGinfo() { return &cinfo ; }
|
||||
};
|
||||
|
||||
#endif // #ifndef _FG_JPGFACTORY_HXX
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
/*
|
||||
* $Log$
|
||||
* Revision 1.3 2001/07/30 20:34:21 curt
|
||||
* Various MSVC fixes.
|
||||
*
|
||||
* Revision 1.2 2001/06/27 02:48:01 curt
|
||||
* Fixed a type conversion bug that could trip up some of the pickier compilers
|
||||
* out there.
|
||||
@@ -47,6 +50,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
4
simgear/serial/.cvsignore
Normal file
4
simgear/serial/.cvsignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
testserial
|
||||
@@ -14,4 +14,8 @@ testserial_LDADD = \
|
||||
$(top_builddir)/simgear/serial/libsgserial.a \
|
||||
$(top_builddir)/simgear/debug/libsgdebug.a
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -28,11 +28,13 @@
|
||||
#ifndef _SG_INLINES_H
|
||||
#define _SG_INLINES_H
|
||||
|
||||
// return the sign of a value
|
||||
template <class T>
|
||||
inline const int SG_SIGN(const T x) {
|
||||
return x < T(0) ? -1 : 1;
|
||||
}
|
||||
|
||||
// return the minimum of two values
|
||||
template <class T>
|
||||
inline const T SG_MIN2(const T a, const T b) {
|
||||
return a < b ? a : b;
|
||||
@@ -44,6 +46,7 @@ inline const T SG_MIN3( const T a, const T b, const T c) {
|
||||
return (a < b ? SG_MIN2 (a, c) : SG_MIN2 (b, c));
|
||||
}
|
||||
|
||||
// return the maximum of two values
|
||||
template <class T>
|
||||
inline const T SG_MAX2(const T a, const T b) {
|
||||
return a > b ? a : b;
|
||||
@@ -55,10 +58,47 @@ inline const T SG_MAX3 (const T a, const T b, const T c) {
|
||||
return (a > b ? SG_MAX2 (a, c) : SG_MAX2 (b, c));
|
||||
}
|
||||
|
||||
//
|
||||
// return the minimum and maximum of three values
|
||||
template <class T>
|
||||
inline void SG_MIN_MAX3 ( T &min, T &max, const T a, const T b, const T c) {
|
||||
if( a > b ) {
|
||||
if( a > c ) {
|
||||
max = a;
|
||||
min = SG_MIN2 (b, c);
|
||||
} else {
|
||||
max = c;
|
||||
min = SG_MIN2 (a, b);
|
||||
}
|
||||
} else {
|
||||
if( b > c ) {
|
||||
max = b;
|
||||
min = SG_MIN2 (a, c);
|
||||
} else {
|
||||
max = c;
|
||||
min = SG_MIN2 (a, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// swap two values
|
||||
template <class T>
|
||||
inline void SG_SWAP( T &a, T &b) {
|
||||
T c = a; a = b; b = c;
|
||||
}
|
||||
|
||||
// clamp a value to lie between min and max
|
||||
template <class T>
|
||||
inline void SG_CLAMP_RANGE(T &x, const T min, const T max ) {
|
||||
if ( x < min ) { x = min; }
|
||||
if ( x > max ) { x = max; }
|
||||
}
|
||||
|
||||
// normalize a value to lie between min and max
|
||||
template <class T>
|
||||
inline void SG_NORMALIZE_RANGE( T &val, const T min, const T max ) {
|
||||
T step = max - min;
|
||||
while( val >= max ) val -= step;
|
||||
while( val < min ) val += step;
|
||||
};
|
||||
|
||||
#endif // _SG_INLINES_H
|
||||
|
||||
@@ -61,11 +61,7 @@
|
||||
#define sgclose(F) (fclose((F)))
|
||||
#else
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#include <zlib.h>
|
||||
#else
|
||||
#include <simgear/zlib/zlib.h>
|
||||
#endif
|
||||
|
||||
#define sgFile gzFile
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* simgear/simgear_config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
/* simgear/simgear_config.h.in. Generated automatically from configure.in by autoheader 2.13. */
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
#undef const
|
||||
@@ -50,9 +50,6 @@
|
||||
/* Define if you have the vprintf function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define if you have zlib installed system wide. */
|
||||
#undef HAVE_ZLIB
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
@@ -200,6 +197,9 @@
|
||||
/* Define if you have the glut library (-lglut). */
|
||||
#undef HAVE_LIBGLUT
|
||||
|
||||
/* Define if you have the jpeg library (-ljpeg). */
|
||||
#undef HAVE_LIBJPEG
|
||||
|
||||
/* Define if you have the m library (-lm). */
|
||||
#undef HAVE_LIBM
|
||||
|
||||
|
||||
3
simgear/sky/.cvsignore
Normal file
3
simgear/sky/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -20,4 +20,8 @@ libsgsky_a_SOURCES = \
|
||||
sphere.cxx \
|
||||
stars.cxx
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <simgear/math/point3d.hxx>
|
||||
#include <simgear/math/polar3d.hxx>
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "cloud.hxx"
|
||||
|
||||
@@ -204,12 +205,31 @@ bool SGCloudLayer::reposition( sgVec3 p, sgVec3 up, double lon, double lat,
|
||||
base = tl->get( 0 );
|
||||
|
||||
base[0] += xoff;
|
||||
while ( base[0] > 1.0 ) { base[0] -= 1.0; }
|
||||
while ( base[0] < 0.0 ) { base[0] += 1.0; }
|
||||
|
||||
// the while loops can lead to *long* pauses if base[0] comes
|
||||
// with a bogus value.
|
||||
// while ( base[0] > 1.0 ) { base[0] -= 1.0; }
|
||||
// while ( base[0] < 0.0 ) { base[0] += 1.0; }
|
||||
if ( base[0] > -10.0 && base[0] < 10.0 ) {
|
||||
base[0] -= (int)base[0];
|
||||
} else {
|
||||
base[0] = 0.0;
|
||||
SG_LOG(SG_ASTRO, SG_ALERT,
|
||||
"Error: base = " << base[0] << "," << base[1]);
|
||||
}
|
||||
|
||||
base[1] += yoff;
|
||||
while ( base[1] > 1.0 ) { base[1] -= 1.0; }
|
||||
while ( base[1] < 0.0 ) { base[1] += 1.0; }
|
||||
// the while loops can lead to *long* pauses if base[0] comes
|
||||
// with a bogus value.
|
||||
// while ( base[1] > 1.0 ) { base[1] -= 1.0; }
|
||||
// while ( base[1] < 0.0 ) { base[1] += 1.0; }
|
||||
if ( base[1] > -10.0 && base[1] < 10.0 ) {
|
||||
base[1] -= (int)base[1];
|
||||
} else {
|
||||
base[1] = 0.0;
|
||||
SG_LOG(SG_ASTRO, SG_ALERT,
|
||||
"Error: base = " << base[0] << "," << base[1]);
|
||||
}
|
||||
|
||||
// cout << "base = " << base[0] << "," << base[1] << endl;
|
||||
|
||||
|
||||
@@ -224,8 +224,8 @@ ssgBranch * SGSkyDome::build( ) {
|
||||
lower_ring_cl->add( color );
|
||||
|
||||
// force a repaint of the sky colors with ugly defaults
|
||||
sgVec3 fog_color;
|
||||
sgSetVec3( fog_color, 1.0, 1.0, 1.0 );
|
||||
sgVec4 fog_color;
|
||||
sgSetVec4( fog_color, 1.0, 1.0, 1.0, 1.0 );
|
||||
repaint( color, fog_color, 0.0, 5000.0 );
|
||||
|
||||
// build the ssg scene graph sub tree for the sky and connected
|
||||
@@ -342,6 +342,7 @@ bool SGSkyDome::repaint( sgVec4 sky_color, sgVec4 fog_color, double sun_angle,
|
||||
diff = sky_color[j] - fog_color[j];
|
||||
center_color[j] = sky_color[j] - diff * ( 1.0 - vis_factor );
|
||||
}
|
||||
center_color[3] = 1.0;
|
||||
|
||||
for ( i = 0; i < 6; i++ ) {
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
|
||||
@@ -57,12 +57,16 @@ static int sgMoonOrbPreDraw( ssgEntity *e ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static int sgMoonOrbPostDraw( ssgEntity *e ) {
|
||||
/* cout << endl << "Moon orb post draw" << endl << "----------------"
|
||||
<< endl << endl; */
|
||||
// glEnable( GL_DEPTH_TEST );
|
||||
// glEnable( GL_FOG );
|
||||
// glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
|
||||
// Some drivers don't properly reset glBendFunc with a
|
||||
// glPopAttrib() so we reset it to the 'default' here.
|
||||
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
|
||||
|
||||
glPopAttrib();
|
||||
// cout << "pop error = " << glGetError() << endl;
|
||||
@@ -78,6 +82,8 @@ static int sgMoonOrbPostDraw( ssgEntity *e ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static int sgMoonHaloPreDraw( ssgEntity *e ) {
|
||||
/* cout << endl << "Moon halo pre draw" << endl << "----------------"
|
||||
<< endl << endl; */
|
||||
@@ -107,6 +113,7 @@ static int sgMoonHaloPostDraw( ssgEntity *e ) {
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Constructor
|
||||
|
||||
3
simgear/threads/.cvsignore
Normal file
3
simgear/threads/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -10,4 +10,8 @@ include_HEADERS = \
|
||||
libsgthreads_a_SOURCES = \
|
||||
SGThread.cxx
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
# include <time.h>
|
||||
#else
|
||||
# include <sys/time.h>
|
||||
|
||||
3
simgear/timing/.cvsignore
Normal file
3
simgear/timing/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -16,4 +16,8 @@ libsgtiming_a_SOURCES = \
|
||||
timestamp.cxx \
|
||||
timezone.cxx
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <errno.h> // for errno
|
||||
|
||||
#ifdef SG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# include <cstdio>
|
||||
# include <cstdlib>
|
||||
# include <ctime>
|
||||
@@ -39,18 +38,19 @@
|
||||
# include <math.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h> // for get/setitimer, gettimeofday, struct timeval
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIMEB_H
|
||||
# include <sys/timeb.h> // for ftime() and struct timeb
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h> // for gettimeofday()
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h> // for get/setitimer, gettimeofday, struct timeval
|
||||
#endif
|
||||
|
||||
#include <math.h> // for NAN
|
||||
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
@@ -70,19 +70,25 @@ static const double J2000 = 2451545.0 - MJD0;
|
||||
static const double SIDRATE = 0.9972695677;
|
||||
|
||||
|
||||
SGTime::SGTime( double lon, double lat, const string& root )
|
||||
void SGTime::init( double lon, double lat,
|
||||
const string& root, time_t init_time )
|
||||
{
|
||||
SG_LOG( SG_EVENT, SG_INFO, "Initializing Time" );
|
||||
|
||||
gst_diff = -9999.0;
|
||||
|
||||
cur_time = time(NULL);
|
||||
if ( init_time ) {
|
||||
cur_time = init_time;
|
||||
} else {
|
||||
cur_time = time(NULL);
|
||||
}
|
||||
|
||||
cout << "Current greenwich mean time = " << asctime(gmtime(&cur_time))
|
||||
<< endl;
|
||||
cout << "Current local time = "
|
||||
<< asctime(localtime(&cur_time)) << endl;
|
||||
|
||||
if ( root != (string)"" ) {
|
||||
if ( !root.empty()) {
|
||||
SGPath zone( root );
|
||||
zone.append( "zone.tab" );
|
||||
SG_LOG( SG_EVENT, SG_INFO, "Reading timezone info from: "
|
||||
@@ -103,14 +109,19 @@ SGTime::SGTime( double lon, double lat, const string& root )
|
||||
}
|
||||
}
|
||||
|
||||
SGTime::SGTime( double lon, double lat, const string& root, time_t init_time )
|
||||
{
|
||||
init( lon, lat, root, init_time );
|
||||
}
|
||||
|
||||
|
||||
SGTime::SGTime( const string& root ) {
|
||||
SGTime( 0.0, 0.0, root );
|
||||
init( 0.0, 0.0, root, 0 );
|
||||
}
|
||||
|
||||
|
||||
SGTime::SGTime() {
|
||||
SGTime( 0.0, 0.0, "" );
|
||||
init( 0.0, 0.0, "", 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +136,7 @@ SGTime::~SGTime()
|
||||
if ( zonename != NULL ) {
|
||||
char *tmp = zonename;
|
||||
zonename = NULL;
|
||||
delete tmp;
|
||||
free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +164,7 @@ static double sidereal_precise( double mjd, double lng )
|
||||
|
||||
|
||||
// return a courser but cheaper estimate of sidereal time
|
||||
static double sidereal_course( time_t cur_time, struct tm *gmt, double lng )
|
||||
static double sidereal_course( time_t cur_time, const struct tm *gmt, double lng )
|
||||
{
|
||||
time_t start_gmt, now;
|
||||
double diff, part, days, hours, lstTmp;
|
||||
@@ -190,10 +201,10 @@ static double sidereal_course( time_t cur_time, struct tm *gmt, double lng )
|
||||
|
||||
|
||||
// Update the time related variables
|
||||
void SGTime::update( double lon, double lat, long int warp ) {
|
||||
void SGTime::update( double lon, double lat, time_t ct, long int warp ) {
|
||||
double gst_precise, gst_course;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
tm * gmt = &m_gmt;
|
||||
#endif
|
||||
|
||||
@@ -201,13 +212,17 @@ void SGTime::update( double lon, double lat, long int warp ) {
|
||||
|
||||
// get current Unix calendar time (in seconds)
|
||||
// warp += warp_delta;
|
||||
cur_time = time(NULL) + warp;
|
||||
if ( ct ) {
|
||||
cur_time = ct + warp;
|
||||
} else {
|
||||
cur_time = time(NULL) + warp;
|
||||
}
|
||||
SG_LOG( SG_EVENT, SG_DEBUG,
|
||||
" Current Unix calendar time = " << cur_time
|
||||
<< " warp = " << warp );
|
||||
|
||||
// get GMT break down for current time
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
memcpy( gmt, gmtime(&cur_time), sizeof(tm) );
|
||||
#else
|
||||
gmt = gmtime(&cur_time);
|
||||
@@ -219,7 +234,7 @@ void SGTime::update( double lon, double lat, long int warp ) {
|
||||
<< gmt->tm_sec );
|
||||
|
||||
// calculate modified Julian date starting with current
|
||||
mjd = sgTimeCurrentMJD( warp );
|
||||
mjd = sgTimeCurrentMJD( ct, warp );
|
||||
|
||||
// add in partial day
|
||||
mjd += (gmt->tm_hour / 24.0) + (gmt->tm_min / (24.0 * 60.0)) +
|
||||
@@ -259,6 +274,25 @@ void SGTime::update( double lon, double lat, long int warp ) {
|
||||
|
||||
// Given lon/lat, update timezone information and local_offset
|
||||
void SGTime::updateLocal( double lon, double lat, const string& root ) {
|
||||
// sanity checking
|
||||
if ( lon < -SGD_PI || lon > SGD_PI ) {
|
||||
// not within -180 ... 180
|
||||
lon = 0.0;
|
||||
}
|
||||
if ( lat < -SGD_PI * 0.5 || lat > SGD_PI * 0.5 ) {
|
||||
// not within -90 ... 90
|
||||
lat = 0.0;
|
||||
}
|
||||
if ( lon != lon ) {
|
||||
// only true if lon == nan
|
||||
SG_LOG( SG_EVENT, SG_ALERT, " Detected lon == nan, resetting to 0.0" );
|
||||
lon = 0.0;
|
||||
}
|
||||
if ( lat != lat ) {
|
||||
// only true if lat == nan
|
||||
SG_LOG( SG_EVENT, SG_ALERT, " Detected lat == nan, resetting to 0.0" );
|
||||
lat = 0.0;
|
||||
}
|
||||
time_t currGMT;
|
||||
time_t aircraftLocalTime;
|
||||
GeoCoord location( SGD_RADIANS_TO_DEGREES * lat, SGD_RADIANS_TO_DEGREES * lon );
|
||||
@@ -268,9 +302,17 @@ void SGTime::updateLocal( double lon, double lat, const string& root ) {
|
||||
if ( zonename ) {
|
||||
char *ptr = zonename;
|
||||
zonename = NULL;
|
||||
delete ptr;
|
||||
free(ptr);
|
||||
}
|
||||
zonename = strdup( zone.c_str() );
|
||||
|
||||
//Avoid troubles when zone.tab hasn't got the right line endings
|
||||
if (zonename[strlen(zonename)-1] == '\r')
|
||||
{
|
||||
zonename[strlen(zonename)-1]=0;
|
||||
zone.set( zonename );
|
||||
}
|
||||
|
||||
currGMT = sgTimeGetGMT( gmtime(&cur_time) );
|
||||
aircraftLocalTime = sgTimeGetGMT( (fgLocaltime(&cur_time, zone.c_str())) );
|
||||
local_offset = aircraftLocalTime - currGMT;
|
||||
@@ -332,26 +374,29 @@ double sgTimeCalcMJD(int mn, double dy, int yr) {
|
||||
|
||||
// return the current modified Julian date (number of days elapsed
|
||||
// since 1900 jan 0.5), mjd.
|
||||
double sgTimeCurrentMJD( long int warp ) {
|
||||
#ifdef _MSC_VER
|
||||
double sgTimeCurrentMJD( time_t ct, long int warp ) {
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
struct tm m_gmt; // copy of system gmtime(&time_t) structure
|
||||
struct tm *gmt = &m_gmt;
|
||||
#else
|
||||
struct tm *gmt;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
tm * gmt = &m_gmt;
|
||||
#endif
|
||||
|
||||
// get current Unix calendar time (in seconds)
|
||||
// warp += warp_delta;
|
||||
time_t cur_time = time(NULL) + warp;
|
||||
time_t cur_time;
|
||||
if ( ct ) {
|
||||
cur_time = ct + warp;
|
||||
} else {
|
||||
cur_time = time(NULL) + warp;
|
||||
}
|
||||
SG_LOG( SG_EVENT, SG_DEBUG,
|
||||
" Current Unix calendar time = " << cur_time
|
||||
<< " warp = " << warp );
|
||||
|
||||
// get GMT break down for current time
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
memcpy( gmt, gmtime(&cur_time), sizeof(tm) );
|
||||
#else
|
||||
gmt = gmtime(&cur_time);
|
||||
|
||||
@@ -78,7 +78,7 @@ private:
|
||||
time_t cur_time;
|
||||
|
||||
// Break down of equivalent GMT time
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
struct tm m_gmt; // copy of system gmtime(&time_t) structure
|
||||
#else
|
||||
struct tm *gmt;
|
||||
@@ -122,8 +122,10 @@ public:
|
||||
* 0).
|
||||
* @param lon current longitude
|
||||
* @param lat current latitude
|
||||
* @param root root path point to data file location (timezone, etc.) */
|
||||
SGTime( double lon, double lat, const string& root );
|
||||
* @param root root path point to data file location (timezone, etc.)
|
||||
* @param init_time provide an initialization time, 0 means use
|
||||
current clock time */
|
||||
SGTime( double lon, double lat, const string& root, time_t init_time /* = 0 */ );
|
||||
|
||||
/**
|
||||
* Create an instance given a data file path.
|
||||
@@ -134,6 +136,9 @@ public:
|
||||
/** Destructor */
|
||||
~SGTime();
|
||||
|
||||
/** init common constructor code */
|
||||
void init( double lon, double lat, const string& root, time_t init_time /* = 0 */ );
|
||||
|
||||
/**
|
||||
* Update the time related variables.
|
||||
* The update() method requires you to pass in your position and
|
||||
@@ -143,9 +148,11 @@ public:
|
||||
* every frame.
|
||||
* @param lon current longitude
|
||||
* @param lat current latitude
|
||||
* @param ct specify a unix time, otherwise specify 0 to use current
|
||||
clock time
|
||||
* @param warp an optional time offset specified in seconds. This
|
||||
* allows us to advance or rewind "time" if we choose to. */
|
||||
void update( double lon, double lat, long int warp = 0 );
|
||||
void update( double lon, double lat, time_t ct /* = 0 */, long int warp /* = 0 */ );
|
||||
|
||||
/**
|
||||
* Given lon/lat, update timezone information and local_offset
|
||||
@@ -166,7 +173,7 @@ public:
|
||||
inline char* get_zonename() const { return zonename; }
|
||||
|
||||
/** @return GMT in a "brokent down" tm structure */
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
inline struct tm* getGmt()const { return (struct tm *)&m_gmt; };
|
||||
#else
|
||||
inline struct tm* getGmt()const { return gmt; };
|
||||
@@ -235,10 +242,12 @@ double sgTimeCalcMJD(int mn, double dy, int yr);
|
||||
* \relates SGTime
|
||||
* Given an optional offset from current time calculate the current
|
||||
* modified julian date.
|
||||
* @param ct specify a unix time, otherwise specify 0 to use current
|
||||
clock time
|
||||
* @param warp number of seconds to offset from current time (0 if no offset)
|
||||
* @return current modified Julian date (number of days elapsed
|
||||
* since 1900 jan 0.5), mjd. */
|
||||
double sgTimeCurrentMJD( long int warp );
|
||||
double sgTimeCurrentMJD( time_t ct /* = 0 */, long int warp /* = 0 */ );
|
||||
|
||||
/**
|
||||
* \relates SGTime
|
||||
|
||||
@@ -105,7 +105,7 @@ void SGTimeStamp::stamp() {
|
||||
|
||||
// increment the time stamp by the number of microseconds (usec)
|
||||
SGTimeStamp operator + (const SGTimeStamp& t, const long& m) {
|
||||
#ifdef WIN32
|
||||
#if defined( WIN32 )
|
||||
return SGTimeStamp( 0, t.usec + m );
|
||||
#else
|
||||
return SGTimeStamp( t.seconds + ( t.usec + m ) / 1000000,
|
||||
|
||||
@@ -102,7 +102,10 @@ public:
|
||||
inline long get_usec() const { return usec; }
|
||||
};
|
||||
|
||||
inline SGTimeStamp::SGTimeStamp() {
|
||||
inline SGTimeStamp::SGTimeStamp() :
|
||||
seconds(0),
|
||||
usec(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline SGTimeStamp::SGTimeStamp( const long s, const long u ) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user