Compare commits
71 Commits
RELEASE_0_
...
RELEASE_0_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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.
|
||||
|
||||
109
Makefile.am
109
Makefile.am
@@ -1,104 +1,19 @@
|
||||
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 \
|
||||
metakit-2.4.2-32.tar.gz \
|
||||
zlib-1.1.3.tar.gz
|
||||
|
||||
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 = 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
|
||||
|
||||
|
||||
38
NEWS
38
NEWS
@@ -1,3 +1,41 @@
|
||||
New in 0.0.17 (final)
|
||||
* February 16, 2002
|
||||
|
||||
* Converted some cout's to SG_LOG's.
|
||||
* xplicitely 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
|
||||
|
||||
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. 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. 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.3 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
|
||||
ftp://ds.internic.net/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@quest.jpl.nasa.gov>, or to
|
||||
Gilles Vollant <info@winimage.com> for the Windows DLL version.
|
||||
The zlib home page is http://www.cdrom.com/pub/infozip/zlib/
|
||||
The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/
|
||||
Before reporting a problem, please check those sites to verify that
|
||||
you have the latest version of zlib; otherwise get the latest version and
|
||||
check whether the problem still exists or not.
|
||||
|
||||
Mark Nelson <markn@tiny.com> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available in
|
||||
http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm
|
||||
|
||||
The changes made in version 1.1.3 are documented in the file ChangeLog.
|
||||
The main changes since 1.1.2 are:
|
||||
|
||||
- fix "an inflate input buffer bug that shows up on rare but persistent
|
||||
occasions" (Mark)
|
||||
- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
|
||||
- fix gzseek(..., SEEK_SET) in write mode
|
||||
- fix crc check after a gzeek (Frank Faubert)
|
||||
- fix miniunzip when the last entry in a zip file is itself a zip file
|
||||
(J Lillge)
|
||||
- add contrib/asm586 and contrib/asm686 (Brian Raiter)
|
||||
See http://www.muppetlabs.com/~breadbox/software/assembly.html
|
||||
- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
|
||||
- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
|
||||
- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
|
||||
- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
|
||||
- added a FAQ file
|
||||
|
||||
plus many changes for portability.
|
||||
|
||||
Unsupported third party contributions are provided in directory "contrib".
|
||||
|
||||
A Java implementation of zlib is available in the Java Development Kit 1.1
|
||||
http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
|
||||
See the zlib home page http://www.cdrom.com/pub/infozip/zlib/ 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, such as:
|
||||
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib*
|
||||
|
||||
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-1998 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 "======================================"
|
||||
165
configure.in
165
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.17pre2)
|
||||
|
||||
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,24 @@ 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 "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 "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
|
||||
@@ -306,14 +353,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 +375,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 +389,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
|
||||
|
||||
BIN
metakit-2.4.2-32.tar.gz
Normal file
BIN
metakit-2.4.2-32.tar.gz
Normal file
Binary file not shown.
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.
|
||||
//
|
||||
|
||||
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
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -205,11 +205,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;
|
||||
@@ -551,7 +558,7 @@ bool SGBinObject::write_bin( 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());
|
||||
@@ -828,7 +835,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());
|
||||
|
||||
@@ -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
|
||||
@@ -1358,8 +1358,8 @@ 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;
|
||||
@@ -1800,7 +1800,7 @@ static bool isWxToken( char *token )
|
||||
|
||||
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) == '-' ) )
|
||||
@@ -2365,17 +2365,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,3 +1,5 @@
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include "Local.h" /* standard header file */
|
||||
#include "Metar.h"
|
||||
|
||||
@@ -1393,9 +1395,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,
|
||||
@@ -2788,8 +2790,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 */
|
||||
@@ -2861,7 +2863,7 @@ static bool isSectorVsby( char **string, Decoded_METAR *Mptr,
|
||||
/* DECLARE LOCAL VARIABLES */
|
||||
/***************************/
|
||||
|
||||
float vsby;
|
||||
float vsby = 0.0f;
|
||||
char dd[3],
|
||||
*slash;
|
||||
|
||||
@@ -4791,18 +4793,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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
4
simgear/misc/.cvsignore
Normal file
4
simgear/misc/.cvsignore
Normal file
@@ -0,0 +1,4 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
props_test
|
||||
@@ -1,15 +1,10 @@
|
||||
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 \
|
||||
sg_path.hxx \
|
||||
sgstream.hxx \
|
||||
@@ -20,6 +15,7 @@ include_HEADERS = \
|
||||
|
||||
libsgmisc_a_SOURCES = \
|
||||
commands.cxx \
|
||||
exception.cxx \
|
||||
props.cxx \
|
||||
props_io.cxx \
|
||||
sg_path.cxx \
|
||||
@@ -33,4 +29,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
|
||||
|
||||
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
|
||||
@@ -7,6 +7,7 @@
|
||||
// $Id$
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -42,6 +43,9 @@ public:
|
||||
#define TEST_READ(dflt) if (!getAttribute(READ)) return dflt
|
||||
#define TEST_WRITE if (!getAttribute(WRITE)) return false
|
||||
|
||||
#define DO_TRACE_READ(type) if(getAttribute(TRACE_READ)) trace_read(type)
|
||||
#define DO_TRACE_WRITE(type) if (getAttribute(TRACE_WRITE)) trace_write(type)
|
||||
|
||||
#define GET_BOOL (_value.bool_val->getValue())
|
||||
#define GET_INT (_value.int_val->getValue())
|
||||
#define GET_LONG (_value.long_val->getValue())
|
||||
@@ -295,6 +299,7 @@ SGPropertyNode::SGPropertyNode ()
|
||||
: _name(""),
|
||||
_index(0),
|
||||
_parent(0),
|
||||
_path_cache(0),
|
||||
_type(NONE),
|
||||
_tied(false),
|
||||
_attr(READ|WRITE)
|
||||
@@ -309,6 +314,7 @@ SGPropertyNode::SGPropertyNode (const SGPropertyNode &node)
|
||||
: _name(node._name),
|
||||
_index(node._index),
|
||||
_parent(0), // don't copy the parent
|
||||
_path_cache(0),
|
||||
_type(node._type),
|
||||
_tied(node._tied),
|
||||
_attr(node._attr)
|
||||
@@ -347,8 +353,13 @@ SGPropertyNode::SGPropertyNode (const SGPropertyNode &node)
|
||||
*/
|
||||
SGPropertyNode::SGPropertyNode (const string &name,
|
||||
int index, SGPropertyNode * parent)
|
||||
: _name(name), _index(index), _parent(parent), _type(NONE),
|
||||
_tied(false), _attr(READ|WRITE)
|
||||
: _name(name),
|
||||
_index(index),
|
||||
_parent(parent),
|
||||
_path_cache(0),
|
||||
_type(NONE),
|
||||
_tied(false),
|
||||
_attr(READ|WRITE)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -358,8 +369,10 @@ SGPropertyNode::SGPropertyNode (const string &name,
|
||||
*/
|
||||
SGPropertyNode::~SGPropertyNode ()
|
||||
{
|
||||
for (int i = 0; i < (int)_children.size(); i++)
|
||||
for (int i = 0; i < (int)_children.size(); i++) {
|
||||
delete _children[i];
|
||||
}
|
||||
delete _path_cache;
|
||||
clear_value();
|
||||
}
|
||||
|
||||
@@ -405,6 +418,67 @@ SGPropertyNode::clear_value ()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value as a string.
|
||||
*/
|
||||
string
|
||||
SGPropertyNode::get_string () const
|
||||
{
|
||||
TEST_READ("");
|
||||
char buf[128];
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->getStringValue();
|
||||
case BOOL:
|
||||
if (GET_BOOL)
|
||||
return "true";
|
||||
else
|
||||
return "false";
|
||||
case INT:
|
||||
sprintf(buf, "%d", GET_INT);
|
||||
return buf;
|
||||
case LONG:
|
||||
sprintf(buf, "%ld", GET_LONG);
|
||||
return buf;
|
||||
case FLOAT:
|
||||
sprintf(buf, "%f", GET_FLOAT);
|
||||
return buf;
|
||||
case DOUBLE:
|
||||
sprintf(buf, "%f", GET_DOUBLE);
|
||||
return buf;
|
||||
case STRING:
|
||||
case UNSPECIFIED:
|
||||
return GET_STRING;
|
||||
case NONE:
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trace a read access for a property.
|
||||
*/
|
||||
void
|
||||
SGPropertyNode::trace_read (SGPropertyNode::Type accessType) const
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "TRACE: Read node " << getPath()
|
||||
<< ", value \"" << get_string() << '"');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trace a write access for a property.
|
||||
*/
|
||||
void
|
||||
SGPropertyNode::trace_write (SGPropertyNode::Type accessType) const
|
||||
{
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "TRACE: Write node " << getPath()
|
||||
<< ", value\"" << get_string() << '"');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alias to another node.
|
||||
*/
|
||||
@@ -585,6 +659,7 @@ SGPropertyNode::getType () const
|
||||
bool
|
||||
SGPropertyNode::getBoolValue () const
|
||||
{
|
||||
DO_TRACE_READ(BOOL);
|
||||
TEST_READ(false);
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
@@ -602,14 +677,16 @@ SGPropertyNode::getBoolValue () const
|
||||
case STRING:
|
||||
case UNSPECIFIED:
|
||||
return (GET_STRING == "true" || getDoubleValue() != 0.0L);
|
||||
case NONE:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; // if NONE
|
||||
}
|
||||
|
||||
int
|
||||
SGPropertyNode::getIntValue () const
|
||||
{
|
||||
DO_TRACE_READ(INT);
|
||||
TEST_READ(0);
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
@@ -627,14 +704,16 @@ SGPropertyNode::getIntValue () const
|
||||
case STRING:
|
||||
case UNSPECIFIED:
|
||||
return atoi(GET_STRING.c_str());
|
||||
case NONE:
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0; // if NONE
|
||||
}
|
||||
|
||||
long
|
||||
SGPropertyNode::getLongValue () const
|
||||
{
|
||||
DO_TRACE_READ(LONG);
|
||||
TEST_READ(0L);
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
@@ -652,14 +731,16 @@ SGPropertyNode::getLongValue () const
|
||||
case STRING:
|
||||
case UNSPECIFIED:
|
||||
return strtol(GET_STRING.c_str(), 0, 0);
|
||||
case NONE:
|
||||
default:
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return 0L; // if NONE
|
||||
}
|
||||
|
||||
float
|
||||
SGPropertyNode::getFloatValue () const
|
||||
{
|
||||
DO_TRACE_READ(FLOAT);
|
||||
TEST_READ(0.0);
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
@@ -677,14 +758,16 @@ SGPropertyNode::getFloatValue () const
|
||||
case STRING:
|
||||
case UNSPECIFIED:
|
||||
return atof(GET_STRING.c_str());
|
||||
case NONE:
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return 0.0; // if NONE
|
||||
}
|
||||
|
||||
double
|
||||
SGPropertyNode::getDoubleValue () const
|
||||
{
|
||||
DO_TRACE_READ(DOUBLE);
|
||||
TEST_READ(0.0L);
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
@@ -702,48 +785,23 @@ SGPropertyNode::getDoubleValue () const
|
||||
case STRING:
|
||||
case UNSPECIFIED:
|
||||
return strtod(GET_STRING.c_str(), 0);
|
||||
case NONE:
|
||||
default:
|
||||
return 0.0L;
|
||||
}
|
||||
|
||||
return 0.0L; // if NONE
|
||||
}
|
||||
|
||||
string
|
||||
SGPropertyNode::getStringValue () const
|
||||
{
|
||||
TEST_READ("");
|
||||
char buf[128];
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->getStringValue();
|
||||
case BOOL:
|
||||
if (GET_BOOL)
|
||||
return "true";
|
||||
else
|
||||
return "false";
|
||||
case INT:
|
||||
sprintf(buf, "%d", GET_INT);
|
||||
return buf;
|
||||
case LONG:
|
||||
sprintf(buf, "%ld", GET_LONG);
|
||||
return buf;
|
||||
case FLOAT:
|
||||
sprintf(buf, "%f", GET_FLOAT);
|
||||
return buf;
|
||||
case DOUBLE:
|
||||
sprintf(buf, "%f", GET_DOUBLE);
|
||||
return buf;
|
||||
case STRING:
|
||||
case UNSPECIFIED:
|
||||
return GET_STRING;
|
||||
}
|
||||
|
||||
return ""; // if NONE
|
||||
DO_TRACE_READ(STRING);
|
||||
return get_string();
|
||||
}
|
||||
|
||||
bool
|
||||
SGPropertyNode::setBoolValue (bool value)
|
||||
{
|
||||
bool result = false;
|
||||
TEST_WRITE;
|
||||
if (_type == NONE || _type == UNSPECIFIED) {
|
||||
clear_value();
|
||||
@@ -753,27 +811,40 @@ SGPropertyNode::setBoolValue (bool value)
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->setBoolValue(value);
|
||||
result = _value.alias->setBoolValue(value);
|
||||
break;
|
||||
case BOOL:
|
||||
return SET_BOOL(value);
|
||||
result = SET_BOOL(value);
|
||||
break;
|
||||
case INT:
|
||||
return SET_INT(int(value));
|
||||
result = SET_INT(int(value));
|
||||
break;
|
||||
case LONG:
|
||||
return SET_LONG(long(value));
|
||||
result = SET_LONG(long(value));
|
||||
break;
|
||||
case FLOAT:
|
||||
return SET_FLOAT(float(value));
|
||||
result = SET_FLOAT(float(value));
|
||||
break;
|
||||
case DOUBLE:
|
||||
return SET_DOUBLE(double(value));
|
||||
result = SET_DOUBLE(double(value));
|
||||
break;
|
||||
case STRING:
|
||||
return SET_STRING(value ? "true" : "false");
|
||||
case UNSPECIFIED:
|
||||
result = SET_STRING(value ? "true" : "false");
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false; // should never happen
|
||||
DO_TRACE_WRITE(BOOL);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
SGPropertyNode::setIntValue (int value)
|
||||
{
|
||||
bool result = false;
|
||||
TEST_WRITE;
|
||||
if (_type == NONE || _type == UNSPECIFIED) {
|
||||
clear_value();
|
||||
@@ -783,30 +854,43 @@ SGPropertyNode::setIntValue (int value)
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->setIntValue(value);
|
||||
result = _value.alias->setIntValue(value);
|
||||
break;
|
||||
case BOOL:
|
||||
return SET_BOOL(value == 0 ? false : true);
|
||||
result = SET_BOOL(value == 0 ? false : true);
|
||||
break;
|
||||
case INT:
|
||||
return SET_INT(value);
|
||||
result = SET_INT(value);
|
||||
break;
|
||||
case LONG:
|
||||
return SET_LONG(long(value));
|
||||
result = SET_LONG(long(value));
|
||||
break;
|
||||
case FLOAT:
|
||||
return SET_FLOAT(float(value));
|
||||
result = SET_FLOAT(float(value));
|
||||
break;
|
||||
case DOUBLE:
|
||||
return SET_DOUBLE(double(value));
|
||||
case STRING: {
|
||||
result = SET_DOUBLE(double(value));
|
||||
break;
|
||||
case STRING:
|
||||
case UNSPECIFIED: {
|
||||
char buf[128];
|
||||
sprintf(buf, "%d", value);
|
||||
return SET_STRING(buf);
|
||||
result = SET_STRING(buf);
|
||||
break;
|
||||
}
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false; // should never happen
|
||||
DO_TRACE_WRITE(INT);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
SGPropertyNode::setLongValue (long value)
|
||||
{
|
||||
bool result = false;
|
||||
TEST_WRITE;
|
||||
if (_type == NONE || _type == UNSPECIFIED) {
|
||||
clear_value();
|
||||
@@ -816,30 +900,43 @@ SGPropertyNode::setLongValue (long value)
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->setLongValue(value);
|
||||
result = _value.alias->setLongValue(value);
|
||||
break;
|
||||
case BOOL:
|
||||
return SET_BOOL(value == 0L ? false : true);
|
||||
result = SET_BOOL(value == 0L ? false : true);
|
||||
break;
|
||||
case INT:
|
||||
return SET_INT(int(value));
|
||||
result = SET_INT(int(value));
|
||||
break;
|
||||
case LONG:
|
||||
return SET_LONG(value);
|
||||
result = SET_LONG(value);
|
||||
break;
|
||||
case FLOAT:
|
||||
return SET_FLOAT(float(value));
|
||||
result = SET_FLOAT(float(value));
|
||||
break;
|
||||
case DOUBLE:
|
||||
return SET_DOUBLE(double(value));
|
||||
case STRING: {
|
||||
result = SET_DOUBLE(double(value));
|
||||
break;
|
||||
case STRING:
|
||||
case UNSPECIFIED: {
|
||||
char buf[128];
|
||||
sprintf(buf, "%d", value);
|
||||
return SET_STRING(buf);
|
||||
sprintf(buf, "%ld", value);
|
||||
result = SET_STRING(buf);
|
||||
break;
|
||||
}
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false; // should never happen
|
||||
DO_TRACE_WRITE(LONG);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
SGPropertyNode::setFloatValue (float value)
|
||||
{
|
||||
bool result = false;
|
||||
TEST_WRITE;
|
||||
if (_type == NONE || _type == UNSPECIFIED) {
|
||||
clear_value();
|
||||
@@ -849,30 +946,43 @@ SGPropertyNode::setFloatValue (float value)
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->setFloatValue(value);
|
||||
result = _value.alias->setFloatValue(value);
|
||||
break;
|
||||
case BOOL:
|
||||
return SET_BOOL(value == 0.0 ? false : true);
|
||||
result = SET_BOOL(value == 0.0 ? false : true);
|
||||
break;
|
||||
case INT:
|
||||
return SET_INT(int(value));
|
||||
result = SET_INT(int(value));
|
||||
break;
|
||||
case LONG:
|
||||
return SET_LONG(long(value));
|
||||
result = SET_LONG(long(value));
|
||||
break;
|
||||
case FLOAT:
|
||||
return SET_FLOAT(value);
|
||||
result = SET_FLOAT(value);
|
||||
break;
|
||||
case DOUBLE:
|
||||
return SET_DOUBLE(double(value));
|
||||
case STRING: {
|
||||
result = SET_DOUBLE(double(value));
|
||||
break;
|
||||
case STRING:
|
||||
case UNSPECIFIED: {
|
||||
char buf[128];
|
||||
sprintf(buf, "%f", value);
|
||||
return SET_STRING(buf);
|
||||
result = SET_STRING(buf);
|
||||
break;
|
||||
}
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false; // should never happen
|
||||
DO_TRACE_WRITE(FLOAT);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
SGPropertyNode::setDoubleValue (double value)
|
||||
{
|
||||
bool result = false;
|
||||
TEST_WRITE;
|
||||
if (_type == NONE || _type == UNSPECIFIED) {
|
||||
clear_value();
|
||||
@@ -882,30 +992,43 @@ SGPropertyNode::setDoubleValue (double value)
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->setDoubleValue(value);
|
||||
result = _value.alias->setDoubleValue(value);
|
||||
break;
|
||||
case BOOL:
|
||||
return SET_BOOL(value == 0.0L ? false : true);
|
||||
result = SET_BOOL(value == 0.0L ? false : true);
|
||||
break;
|
||||
case INT:
|
||||
return SET_INT(int(value));
|
||||
result = SET_INT(int(value));
|
||||
break;
|
||||
case LONG:
|
||||
return SET_LONG(long(value));
|
||||
result = SET_LONG(long(value));
|
||||
break;
|
||||
case FLOAT:
|
||||
return SET_FLOAT(float(value));
|
||||
result = SET_FLOAT(float(value));
|
||||
break;
|
||||
case DOUBLE:
|
||||
return SET_DOUBLE(value);
|
||||
case STRING: {
|
||||
result = SET_DOUBLE(value);
|
||||
break;
|
||||
case STRING:
|
||||
case UNSPECIFIED: {
|
||||
char buf[128];
|
||||
sprintf(buf, "%lf", value);
|
||||
return SET_STRING(buf);
|
||||
sprintf(buf, "%f", value);
|
||||
result = SET_STRING(buf);
|
||||
break;
|
||||
}
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false; // should never happen
|
||||
DO_TRACE_WRITE(DOUBLE);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
SGPropertyNode::setStringValue (string value)
|
||||
{
|
||||
bool result = false;
|
||||
TEST_WRITE;
|
||||
if (_type == NONE || _type == UNSPECIFIED) {
|
||||
clear_value();
|
||||
@@ -915,27 +1038,40 @@ SGPropertyNode::setStringValue (string value)
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->setStringValue(value);
|
||||
result = _value.alias->setStringValue(value);
|
||||
break;
|
||||
case BOOL:
|
||||
return SET_BOOL((value == "true" || atoi(value.c_str())) ? true : false);
|
||||
result = SET_BOOL((value == "true" || atoi(value.c_str())) ? true : false);
|
||||
break;
|
||||
case INT:
|
||||
return SET_INT(atoi(value.c_str()));
|
||||
result = SET_INT(atoi(value.c_str()));
|
||||
break;
|
||||
case LONG:
|
||||
return SET_LONG(strtol(value.c_str(), 0, 0));
|
||||
result = SET_LONG(strtol(value.c_str(), 0, 0));
|
||||
break;
|
||||
case FLOAT:
|
||||
return SET_FLOAT(atof(value.c_str()));
|
||||
result = SET_FLOAT(atof(value.c_str()));
|
||||
break;
|
||||
case DOUBLE:
|
||||
return SET_DOUBLE(strtod(value.c_str(), 0));
|
||||
result = SET_DOUBLE(strtod(value.c_str(), 0));
|
||||
break;
|
||||
case STRING:
|
||||
return SET_STRING(value);
|
||||
case UNSPECIFIED:
|
||||
result = SET_STRING(value);
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false; // should never happen
|
||||
DO_TRACE_WRITE(STRING);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
SGPropertyNode::setUnspecifiedValue (string value)
|
||||
{
|
||||
bool result = false;
|
||||
TEST_WRITE;
|
||||
if (_type == NONE) {
|
||||
clear_value();
|
||||
@@ -945,23 +1081,34 @@ SGPropertyNode::setUnspecifiedValue (string value)
|
||||
|
||||
switch (_type) {
|
||||
case ALIAS:
|
||||
return _value.alias->setUnspecifiedValue(value);
|
||||
result = _value.alias->setUnspecifiedValue(value);
|
||||
break;
|
||||
case BOOL:
|
||||
return SET_BOOL((value == "true" || atoi(value.c_str())) ? true : false);
|
||||
result = SET_BOOL((value == "true" || atoi(value.c_str())) ? true : false);
|
||||
break;
|
||||
case INT:
|
||||
return SET_INT(atoi(value.c_str()));
|
||||
result = SET_INT(atoi(value.c_str()));
|
||||
break;
|
||||
case LONG:
|
||||
return SET_LONG(strtol(value.c_str(), 0, 0));
|
||||
result = SET_LONG(strtol(value.c_str(), 0, 0));
|
||||
break;
|
||||
case FLOAT:
|
||||
return SET_FLOAT(atof(value.c_str()));
|
||||
result = SET_FLOAT(atof(value.c_str()));
|
||||
break;
|
||||
case DOUBLE:
|
||||
return SET_DOUBLE(strtod(value.c_str(), 0));
|
||||
result = SET_DOUBLE(strtod(value.c_str(), 0));
|
||||
break;
|
||||
case STRING:
|
||||
case UNSPECIFIED:
|
||||
return SET_STRING(value);
|
||||
result = SET_STRING(value);
|
||||
break;
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false; // should never happen
|
||||
DO_TRACE_WRITE(UNSPECIFIED);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1012,7 +1159,7 @@ SGPropertyNode::tie (const SGRawValue<long> &rawValue, bool useDefault)
|
||||
if (_type == ALIAS || _tied)
|
||||
return false;
|
||||
|
||||
long old_val;
|
||||
long old_val = 0;
|
||||
if (useDefault)
|
||||
old_val = getLongValue();
|
||||
|
||||
@@ -1138,7 +1285,8 @@ SGPropertyNode::untie ()
|
||||
SET_DOUBLE(val);
|
||||
break;
|
||||
}
|
||||
case STRING: {
|
||||
case STRING:
|
||||
case UNSPECIFIED: {
|
||||
string val = getStringValue();
|
||||
clear_value();
|
||||
_type = STRING;
|
||||
@@ -1146,6 +1294,9 @@ SGPropertyNode::untie ()
|
||||
SET_STRING(val);
|
||||
break;
|
||||
}
|
||||
case NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
_tied = false;
|
||||
@@ -1172,21 +1323,42 @@ SGPropertyNode::getRootNode () const
|
||||
|
||||
SGPropertyNode *
|
||||
SGPropertyNode::getNode (const string &relative_path, bool create)
|
||||
{
|
||||
if (_path_cache == 0)
|
||||
_path_cache = new cache_map;
|
||||
|
||||
SGPropertyNode * result = (*_path_cache)[relative_path];
|
||||
if (result == 0) {
|
||||
vector<PathComponent> components;
|
||||
parse_path(relative_path, components);
|
||||
result = find_node(this, components, 0, create);
|
||||
(*_path_cache)[relative_path] = result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SGPropertyNode *
|
||||
SGPropertyNode::getNode (const string &relative_path, int index, bool create)
|
||||
{
|
||||
vector<PathComponent> components;
|
||||
parse_path(relative_path, components);
|
||||
if (components.size() > 0)
|
||||
components[components.size()-1].index = index;
|
||||
return find_node(this, components, 0, create);
|
||||
}
|
||||
|
||||
const SGPropertyNode *
|
||||
SGPropertyNode::getNode (const string &relative_path) const
|
||||
{
|
||||
vector<PathComponent> components;
|
||||
parse_path(relative_path, components);
|
||||
// FIXME: cast away const
|
||||
return find_node((SGPropertyNode *)this, components, 0, false);
|
||||
return ((SGPropertyNode *)this)->getNode(relative_path, false);
|
||||
}
|
||||
|
||||
const SGPropertyNode *
|
||||
SGPropertyNode::getNode (const string &relative_path, int index) const
|
||||
{
|
||||
return ((SGPropertyNode *)this)->getNode(relative_path, index, false);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -18,15 +18,22 @@
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
@@ -506,7 +513,9 @@ public:
|
||||
enum Attribute {
|
||||
READ = 1,
|
||||
WRITE = 2,
|
||||
ARCHIVE = 4
|
||||
ARCHIVE = 4,
|
||||
TRACE_READ = 8,
|
||||
TRACE_WRITE = 16
|
||||
};
|
||||
|
||||
|
||||
@@ -681,12 +690,36 @@ public:
|
||||
SGPropertyNode * getNode (const string &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 string &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;
|
||||
|
||||
|
||||
/**
|
||||
* 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 string &relative_path,
|
||||
int index) const;
|
||||
|
||||
|
||||
//
|
||||
// Access Mode.
|
||||
//
|
||||
@@ -694,7 +727,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); }
|
||||
|
||||
|
||||
/**
|
||||
@@ -1033,12 +1066,30 @@ private:
|
||||
*/
|
||||
void clear_value ();
|
||||
|
||||
|
||||
/**
|
||||
* Get the value as a string.
|
||||
*/
|
||||
string get_string () const;
|
||||
|
||||
|
||||
/**
|
||||
* Trace a read access.
|
||||
*/
|
||||
void trace_read (Type accessType) const;
|
||||
|
||||
|
||||
/**
|
||||
* Trace a write access.
|
||||
*/
|
||||
void trace_write (Type accessType) const;
|
||||
|
||||
string _name;
|
||||
int _index;
|
||||
SGPropertyNode * _parent;
|
||||
vector<SGPropertyNode *> _children;
|
||||
|
||||
|
||||
typedef map<const string,SGPropertyNode *> cache_map;
|
||||
cache_map * _path_cache;
|
||||
Type _type;
|
||||
bool _tied;
|
||||
int _attr;
|
||||
@@ -1067,26 +1118,26 @@ private:
|
||||
/**
|
||||
* Read properties from an XML input stream.
|
||||
*/
|
||||
bool readProperties (istream &input, SGPropertyNode * start_node,
|
||||
void readProperties (istream &input, SGPropertyNode * start_node,
|
||||
const string &base = "");
|
||||
|
||||
|
||||
/**
|
||||
* Read properties from an XML file.
|
||||
*/
|
||||
bool readProperties (const string &file, SGPropertyNode * start_node);
|
||||
void readProperties (const string &file, SGPropertyNode * start_node);
|
||||
|
||||
|
||||
/**
|
||||
* Write properties to an XML output stream.
|
||||
*/
|
||||
bool writeProperties (ostream &output, const SGPropertyNode * start_node);
|
||||
void writeProperties (ostream &output, const SGPropertyNode * start_node);
|
||||
|
||||
|
||||
/**
|
||||
* Write properties to an XML file.
|
||||
*/
|
||||
bool writeProperties (const string &file, const SGPropertyNode * start_node);
|
||||
void writeProperties (const string &file, const SGPropertyNode * start_node);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,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 +53,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 +90,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 +127,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 +142,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 +181,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 +199,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,9 +238,11 @@ PropsVisitor::endElement (const char * name)
|
||||
} else if (st.type == "unspecified") {
|
||||
ret = st.node->setUnspecifiedValue(_data);
|
||||
} 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 +272,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 +287,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 +305,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();
|
||||
}
|
||||
|
||||
|
||||
@@ -467,14 +472,7 @@ 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
|
||||
void
|
||||
writeProperties (ostream &output, const SGPropertyNode * start_node)
|
||||
{
|
||||
int nChildren = start_node->nChildren();
|
||||
@@ -487,28 +485,17 @@ writeProperties (ostream &output, const SGPropertyNode * start_node)
|
||||
}
|
||||
|
||||
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
|
||||
void
|
||||
writeProperties (const string &file, const SGPropertyNode * start_node)
|
||||
{
|
||||
ofstream output(file.c_str());
|
||||
if (output.good()) {
|
||||
return writeProperties(output, start_node);
|
||||
writeProperties(output, start_node);
|
||||
} 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 +552,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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -334,10 +334,8 @@ int main (int ac, char ** av)
|
||||
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);
|
||||
readProperties(av[i], &root);
|
||||
writeProperties(cout, &root);
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,13 +70,19 @@ 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 = "
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
@@ -271,6 +305,14 @@ void SGTime::updateLocal( double lon, double lat, const string& root ) {
|
||||
delete 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
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
3
simgear/xgl/.cvsignore
Normal file
3
simgear/xgl/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -6,4 +6,8 @@ include_HEADERS = xgl.h
|
||||
|
||||
libsgxgl_a_SOURCES = xgl.c xglUtils.c
|
||||
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#if !defined( WIN32 )
|
||||
# if !defined( HAVE_STL_SGI_PORT ) && !defined( __MWERKS__ )
|
||||
# if !defined( HAVE_STL_SGI_PORT ) && !defined( __MWERKS__ ) && !defined( __APPLE__ )
|
||||
// Avoid malloc with STLport and MSL
|
||||
# include <malloc.h>
|
||||
# endif
|
||||
|
||||
3
simgear/xml/.cvsignore
Normal file
3
simgear/xml/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
@@ -1,8 +1,4 @@
|
||||
if HAVE_ZLIB
|
||||
ZLIB_INCL =
|
||||
else
|
||||
XLIB_INCL = -I$(top_srcdir)/src/zlib
|
||||
endif
|
||||
includedir = @includedir@/xml
|
||||
|
||||
lib_LIBRARIES = libsgxml.a
|
||||
|
||||
@@ -22,4 +18,8 @@ libsgxml_a_SOURCES = \
|
||||
xmltok.h xmltok.c \
|
||||
xmltok_impl.h
|
||||
|
||||
INCLUDES += -I$(top_srcdir) $(ZLIB_INCL)
|
||||
if OLD_AUTOMAKE
|
||||
INCLUDES += -I$(top_srcdir)
|
||||
else
|
||||
INCLUDES = -I$(top_srcdir)
|
||||
endif
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
#include "easyxml.hxx"
|
||||
#include "xmlparse.h"
|
||||
|
||||
#include STL_FSTREAM
|
||||
|
||||
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||
SG_USING_STD(ifstream);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation of XMLAttributes.
|
||||
@@ -162,7 +169,7 @@ ExpatAtts::getValue (int i) const
|
||||
// Static callback functions for Expat.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define VISITOR (*((XMLVisitor*)userData))
|
||||
#define VISITOR (*((XMLVisitor *)userData))
|
||||
|
||||
static void
|
||||
start_element (void * userData, const char * name, const char ** atts)
|
||||
@@ -198,11 +205,9 @@ processing_instruction (void * userData,
|
||||
// Implementation of XMLReader.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool
|
||||
readXML (istream &input, XMLVisitor &visitor)
|
||||
void
|
||||
readXML (istream &input, XMLVisitor &visitor, const string &path)
|
||||
{
|
||||
bool retval = true;
|
||||
|
||||
XML_Parser parser = XML_ParserCreate(0);
|
||||
XML_SetUserData(parser, &visitor);
|
||||
XML_SetElementHandler(parser, start_element, end_element);
|
||||
@@ -214,26 +219,60 @@ readXML (istream &input, XMLVisitor &visitor)
|
||||
char buf[16384];
|
||||
while (!input.eof()) {
|
||||
|
||||
input.read(buf,16384);
|
||||
// TODO: deal with bad stream.
|
||||
if (!XML_Parse(parser, buf, input.gcount(), false)) {
|
||||
visitor.error(XML_ErrorString(XML_GetErrorCode(parser)),
|
||||
XML_GetCurrentColumnNumber(parser),
|
||||
XML_GetCurrentLineNumber(parser));
|
||||
retval = false;
|
||||
// FIXME: get proper error string from system
|
||||
if (!input.good()) {
|
||||
XML_ParserFree(parser);
|
||||
throw sg_io_exception("Problem reading file",
|
||||
sg_location(path,
|
||||
XML_GetCurrentLineNumber(parser),
|
||||
XML_GetCurrentColumnNumber(parser)),
|
||||
"SimGear XML Parser");
|
||||
}
|
||||
|
||||
input.read(buf,16384);
|
||||
if (!XML_Parse(parser, buf, input.gcount(), false)) {
|
||||
XML_ParserFree(parser);
|
||||
throw sg_io_exception(XML_ErrorString(XML_GetErrorCode(parser)),
|
||||
sg_location(path,
|
||||
XML_GetCurrentLineNumber(parser),
|
||||
XML_GetCurrentColumnNumber(parser)),
|
||||
"SimGear XML Parser");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Verify end of document.
|
||||
if (!XML_Parse(parser, buf, 0, true))
|
||||
retval = false;
|
||||
|
||||
if (retval)
|
||||
visitor.endXML();
|
||||
if (!XML_Parse(parser, buf, 0, true)) {
|
||||
XML_ParserFree(parser);
|
||||
throw sg_io_exception(XML_ErrorString(XML_GetErrorCode(parser)),
|
||||
sg_location(path,
|
||||
XML_GetCurrentLineNumber(parser),
|
||||
XML_GetCurrentColumnNumber(parser)),
|
||||
"SimGear XML Parser");
|
||||
}
|
||||
|
||||
XML_ParserFree(parser);
|
||||
}
|
||||
|
||||
return retval;
|
||||
void
|
||||
readXML (const string &path, XMLVisitor &visitor)
|
||||
{
|
||||
ifstream input(path.c_str());
|
||||
if (input.good()) {
|
||||
try {
|
||||
readXML(input, visitor, path);
|
||||
} catch (sg_io_exception &e) {
|
||||
input.close();
|
||||
throw e;
|
||||
} catch (sg_throwable &t) {
|
||||
input.close();
|
||||
throw t;
|
||||
}
|
||||
} else {
|
||||
throw sg_io_exception("Failed to open file", sg_location(path),
|
||||
"SimGear XML Parser");
|
||||
}
|
||||
input.close();
|
||||
}
|
||||
|
||||
// end of easyxml.cxx
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <simgear/misc/exception.hxx>
|
||||
|
||||
#include STL_IOSTREAM
|
||||
#include STL_STRING
|
||||
#include <vector>
|
||||
@@ -355,25 +357,6 @@ public:
|
||||
* the warning.
|
||||
*/
|
||||
virtual void warning (const char * message, int line, int column) {}
|
||||
|
||||
|
||||
/**
|
||||
* Callback for a fatal XML parsing error.
|
||||
*
|
||||
* The XML parser will use this method to report any fatal errors
|
||||
* during parsing. Once the first error callback is received,
|
||||
* normal processing will stop, though additional errors may be
|
||||
* reported. The application should take any appropriate
|
||||
* error-handling procedures when it receives this callback, and
|
||||
* should not attempt to use any of the data found in the XML
|
||||
* document.
|
||||
*
|
||||
* @param message The error message from the parser.
|
||||
* @param line The number of the line that generated the error.
|
||||
* @param column The character position in the line that generated
|
||||
* the error.
|
||||
*/
|
||||
virtual void error (const char * message, int line, int column) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -391,11 +374,34 @@ public:
|
||||
* @param input The byte input stream containing the XML document.
|
||||
* @param visitor An object that contains callbacks for XML parsing
|
||||
* events.
|
||||
* @return true if the parse succeeded, false if there was a fatal
|
||||
* error.
|
||||
* @param path A string describing the original path of the resource.
|
||||
* @exception Throws sg_io_exception or sg_xml_exception if there
|
||||
* is a problem reading the file.
|
||||
* @see XMLVisitor
|
||||
*/
|
||||
extern bool readXML (istream &input, XMLVisitor &visitor);
|
||||
extern void readXML (istream &input, XMLVisitor &visitor,
|
||||
const string &path="");
|
||||
|
||||
|
||||
/**
|
||||
* @relates XMLVisitor
|
||||
* Read an XML document.
|
||||
*
|
||||
* This function reads an XML document from the input stream provided,
|
||||
* and invokes the callback methods in the visitor object to pass the
|
||||
* parsing events back to the application. When this function
|
||||
* returns, the parser will have reported all of the data in the XML
|
||||
* document to the application through the visitor callback methods,
|
||||
* and XML processing will be complete.
|
||||
*
|
||||
* @param path The file name of the XML resource.
|
||||
* @param visitor An object that contains callbacks for XML parsing
|
||||
* events.
|
||||
* @exception Throws sg_io_exception or sg_xml_exception if there
|
||||
* is a problem reading the file.
|
||||
* @see XMLVisitor
|
||||
*/
|
||||
extern void readXML (const string &path, XMLVisitor &visitor);
|
||||
|
||||
|
||||
#endif // __EASYXML_HXX
|
||||
|
||||
BIN
zlib-1.1.3.tar.gz
Normal file
BIN
zlib-1.1.3.tar.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user