From 6ef1a1328b7f639055b8fd4862e67b873b5b8be0 Mon Sep 17 00:00:00 2001 From: fluffymormegil Date: Sat, 9 Apr 2011 10:46:20 +0100 Subject: [PATCH] Snapshot for 1.0.0 release. --- BSD-lite | 23 +++++++ CC0 | 122 +++++++++++++++++++++++++++++++++++++ COPYING | 0 Copyright | 6 +- Makefile | 97 +++++++++++++++++++----------- changelog | 3 + configure | 123 ++++++++++++++++++++++++++++++-------- include/libmormegil/Hci.hh | 24 ++++++++ include/libmormegil/Points.hh | 8 ++- include/libmormegil/stlwprintf.hh | 21 +++++++ man/libmormegil::Hci.3 | 17 ++++++ man/libmormegil::Points.3 | 61 +++++++++++++++++++ man/libmormegil::stlprintf.3 | 32 +++++++--- src/ordinaldate.cc | 1 + src/stlwprintf.cc | 75 +++++++++++++++++++++++ 15 files changed, 539 insertions(+), 74 deletions(-) create mode 100644 BSD-lite create mode 100644 CC0 create mode 100644 COPYING create mode 100644 changelog create mode 100644 include/libmormegil/stlwprintf.hh create mode 100644 man/libmormegil::Hci.3 create mode 100644 man/libmormegil::Points.3 create mode 100644 src/stlwprintf.cc diff --git a/BSD-lite b/BSD-lite new file mode 100644 index 0000000..e20968a --- /dev/null +++ b/BSD-lite @@ -0,0 +1,23 @@ +Copyright + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/CC0 b/CC0 new file mode 100644 index 0000000..6ca207e --- /dev/null +++ b/CC0 @@ -0,0 +1,122 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. + diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..e69de29 diff --git a/Copyright b/Copyright index 72c3b59..17381c2 100644 --- a/Copyright +++ b/Copyright @@ -2,9 +2,11 @@ The copyright disposition of individual files within libmormegil is indicated at the top of those files. Persons currently holding copyright to elements of libmormegil are: Martin Read (all files) - Stefan O'Rear (src/stlprintf.cc) + Stefan O'Rear (src/stlprintf.cc, src/stlwprintf.cc) See individual files for licensing terms. In general, header files are -released under the Creative Commons Public Domain Dedication (cc-0); source +released under the Creative Commons Public Domain Dedication (CC0); source files are released under a BSD-type licence. +The licences used are reproduced in the top-level directory of the source +distribution. diff --git a/Makefile b/Makefile index 21ef6b0..18dd80d 100644 --- a/Makefile +++ b/Makefile @@ -4,96 +4,121 @@ include dirs.mk include version.mk +# If your default shell is not sufficiently POSIXesque, you may need to set +# the SHELL makefile variable. + +# SHELL=/path/to/posixesque/shell + OBJ_BUILDDIR=obj LIB_BUILDDIR=lib -# By default, install as current user and group. -LIBMORMEGIL_OWNERSHIP= -LIBMORMEGIL_DATA_OWNERSHIP= -# For direct system-wide installation, comment previous line and uncomment this: -# LIBMORMEGIL_OWNERSHIP=-o root -g bin -# LIBMORMEGIL_DATA_OWNERSHIP=-o root -g bin +INC_DIR=include/libmormegil # LIB_REALNAME is exact name of the library # LIB_SONAME is majorversioned name of the library # LIB_SHORTNAME is unversioned name of the library -LIB_REALNAME=libmormegil.so.$(MAJOR_VER).$(MINOR_VER).$(COMPAT_DEPTH) -LIB_SONAME=libmormegil.so.$(MAJOR_VER) +LIB_REALNAME:=libmormegil.so.$(MAJOR_VER).$(MINOR_VER).$(COMPAT_DEPTH) +LIB_SONAME:=libmormegil.so.$(MAJOR_VER) LIB_SHORTNAME=libmormegil.so -LIBMORMEGIL_BUILT=$(LIB_BUILDDIR)/$(LIB_REALNAME) -LIBOBJS=$(OBJ_BUILDDIR)/stlprintf.o $(OBJ_BUILDDIR)/stlfgets.o $(OBJ_BUILDDIR)/points.o $(OBJ_BUILDDIR)/Appcfg.o +LIBMORMEGIL_BUILT:=$(LIB_BUILDDIR)/$(LIB_REALNAME) +LIBOBJS:=$(OBJ_BUILDDIR)/stlprintf.o $(OBJ_BUILDDIR)/stlwprintf.o $(OBJ_BUILDDIR)/stlfgets.o $(OBJ_BUILDDIR)/points.o $(OBJ_BUILDDIR)/Appcfg.o $(OBJ_BUILDDIR)/ordinaldate.o -LIB_REALNAME_C=libmormegil_c.so.$(MAJOR_VER).$(MINOR_VER).$(COMPAT_DEPTH) -LIB_SONAME_C=libmormegil_c.so.$(MAJOR_VER) -LIB_SHORTNAME_C=libmormegil_c.so -LIBMORMEGIL_BUILT_C=$(LIB_BUILDDIR)/$(LIB_REALNAME_C) -LIBOBJS_C=$(OBJ_BUILDDIR)/dice.o +LIB_REALNAME_C:=libmormegil_c.so.$(MAJOR_VER).$(MINOR_VER).$(COMPAT_DEPTH) +LIB_SONAME_C:=libmormegil_c.so.$(MAJOR_VER) +LIB_SHORTNAME_C:=libmormegil_c.so +LIBMORMEGIL_BUILT_C:=$(LIB_BUILDDIR)/$(LIB_REALNAME_C) +LIBOBJS_C:=$(OBJ_BUILDDIR)/dice.o -LIBS=$(LIB_BUILDDIR)/$(LIB_REALNAME) $(LIB_BUILDDIR)/$(LIB_REALNAME_C) -ALL_LIBOBJS=$(LIBOBJS) $(LIBOBJS_C) +LIBS:=$(LIB_BUILDDIR)/$(LIB_REALNAME) $(LIB_BUILDDIR)/$(LIB_REALNAME_C) +ALL_LIBOBJS:=$(LIBOBJS) $(LIBOBJS_C) MANPAGES=man/dice.3 man/libmormegil.3 man/libmormegil::Appcfg.3 man/libmormegil::Coord.3 man/libmormegil::S20prng.3 man/libmormegil::abs.3 man/libmormegil::divup.3 man/libmormegil::isotime.3 man/libmormegil::serialize.3 man/libmormegil::stlfgets.3 man/libmormegil::stlprintf.3 -SRCARCH_NAME=libmormegil-$(MAJOR_VER).$(MINOR_VER).$(COMPAT_DEPTH) +SRCARCH_NAME:=libmormegil-$(MAJOR_VER).$(MINOR_VER).$(COMPAT_DEPTH) +# The list of what goes in the deliverable source archive. Only subsystems +# which I deem "ready" get put into the deliverable archive. +SRCARCH_SRC:=src/Appcfg.cc src/dice.cc src/points.cc src/stlfgets.cc src/ordinaldate.cc src/stlprintf.cc src/stlwprintf.cc +SRCARCH_INC:=$(INC_DIR)/dice.h $(INC_DIR)/isotime.h $(INC_DIR)/Appcfg.hh $(INC_DIR)/Coord.hh $(INC_DIR)/Points.hh $(INC_DIR)/S20prng.hh $(INC_DIR)/abs.hh $(INC_DIR)/divup.hh $(INC_DIR)/serial.hh $(INC_DIR)/sign.hh $(INC_DIR)/stlfgets.hh $(INC_DIR)/stlprintf.hh $(INC_DIR)/stlwprintf.hh +SRCARCH_MAN=man/libmormegil.3 man/dice.3 man/libmormegil::Appcfg.3 man/libmormegil::Coord.3 man/libmormegil::Points.3 man/libmormegil::S20prng.3 man/libmormegil::abs.3 man/libmormegil::divup.3 man/libmormegil::isotime.3 man/libmormegil::serialize.3 man/libmormegil::sign.3 man/libmormegil::stlfgets.3 man/libmormegil::stlprintf.3 +SRCARCH_LIC=CC0 BSD-lite COPYING Copyright +SRCARCH_EXA=examples/dice-test.c examples/coord-test.cc +SRCARCH_TOP:=$(SRCARCH_LIC) README changelog version.mk Makefile Bugs # GCC flags # 1. This is a shared library, so we need -fPIC (position-independent code) # when building each of the modules. # 2. We need THIS version's headers to take precedence over the system # headers. -COMMON_FLAGS=-fPIC -I./include -DLIBMORMEGIL_MAJVER=$(MAJOR_VER) -DLIBMORMEGIL_MINVER=$(MINOR_VER) -DLIBMORMEGIL_COMPAT_DEPTH=$(COMPAT_DEPTH) -CXXFLAGS=$(COMMON_FLAGS) +# 3. CFLAGS and CXXFLAGS are for the user! +COMMON_FLAGS:=-fPIC -I./include -DLIBMORMEGIL_MAJVER=$(MAJOR_VER) -DLIBMORMEGIL_MINVER=$(MINOR_VER) -DLIBMORMEGIL_COMPAT_DEPTH=$(COMPAT_DEPTH) +CXXFLAGS= # 3. For linking, we have to specify that the output should be a shared # object and, as before, that we want position-independent code. LINKSTEP_FLAGS=-shared -fPIC -CFLAGS=$(COMMON_FLAGS) +CFLAGS= .PHONY: all clean install install-headers install-libs srcarchive all: $(LIBS) $(OBJ_BUILDDIR)/%.o: src/%.c - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CFLAGS) $(COMMON_FLAGS) -c $< -o $@ $(OBJ_BUILDDIR)/%.o: src/%.cc - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) $(COMMON_FLAGS) -c $< -o $@ $(LIBMORMEGIL_BUILT): $(LIBOBJS) - gcc $(LINKSTEP_FLAGS) $^ -o $@ + gcc -shared -fPIC -Wl,-soname,$(LIB_SONAME) $^ -o $@ $(LIBMORMEGIL_BUILT_C): $(LIBOBJS_C) - gcc $(LINKSTEP_FLAGS) $^ -o $@ + gcc -shared -fPIC -Wl,-soname,$(LIB_SONAME_C) $^ -o $@ clean: -rm -f $(LIBS) $(ALL_LIBOBJS) -rm -rf $(SRCARCH_NAME) $(SRCARCH_NAME).tar.gz +distclean: clean + -rm -f dirs.mk + install: install-headers install-libs install-docs +# Note that this does _not_ create symlinks. That's ldconfig's job install-libs: $(LIBMORMEGIL_BUILT) $(LIBMORMEGIL_BUILT_C) + mkdir -p $(DESTDIR)$(libdir) install -m 0755 $(LIBMORMEGIL_BUILT) $(DESTDIR)$(libdir)/$(LIB_REALNAME) - (cd $(DESTDIR)$(libdir) && ln -sf $(LIB_REALNAME) $(LIB_SONAME) && ln -sf $(LIB_SONAME) $(LIB_SHORTNAME) ) install -m 0755 $(LIBMORMEGIL_BUILT_C) $(DESTDIR)$(libdir)/$(LIB_REALNAME_C) - (cd $(DESTDIR)$(libdir) && ln -sf $(LIB_REALNAME_C) $(LIB_SONAME_C) && ln -sf $(LIB_SONAME_C) $(LIB_SHORTNAME_C) ) install-docs: - install -t $(DESTDIR)$(man3dir) -m 0644 $(LIBMORMEGIL_DATA_OWNERSHIP) $(MANPAGES) + mkdir -p $(DESTDIR)$(man3dir) + install -t $(DESTDIR)$(man3dir) -m 0644 $(MANPAGES) srcarchive: clean - mkdir $(SRCARCH_NAME) - cp -R include lib man obj src Makefile version.mk configure $(SRCARCH_NAME) - tar cvf $(SRCARCH_NAME).tar.gz $(SRCARCH_NAME) - rm -rf $(SRCARCH_NAME) + mkdir -p ./$(SRCARCH_NAME) + cp $(SRCARCH_TOP) ./$(SRCARCH_NAME) + mkdir -p ./$(SRCARCH_NAME)/src + cp $(SRCARCH_SRC) ./$(SRCARCH_NAME)/src + mkdir -p ./$(SRCARCH_NAME)/include/libmormegil + cp $(SRCARCH_INC) ./$(SRCARCH_NAME)/include/libmormegil + mkdir -p ./$(SRCARCH_NAME)/man + cp $(SRCARCH_MAN) ./$(SRCARCH_NAME)/man + mkdir -p ./$(SRCARCH_NAME)/examples + cp $(SRCARCH_EXA) ./$(SRCARCH_NAME)/examples + mkdir -p ./$(SRCARCH_NAME)/obj + touch ./$(SRCARCH_NAME)/obj/placeholder.txt + mkdir -p ./$(SRCARCH_NAME)/lib + touch ./$(SRCARCH_NAME)/lib/placeholder.txt + tar cvf ./$(SRCARCH_NAME).tar.gz ./$(SRCARCH_NAME) + rm -rf ./$(SRCARCH_NAME) ifeq ($(oldincludedir),"") install-headers: mkdir -p $(DESTDIR)$(oldincludedir)/libmormegil - cp include/libmormegil/* $(DESTDIR)$(oldincludedir)/libmormegil + install -t $(DESTDIR)$(oldincludedir)/libmormegil include/libmormegil/* mkdir -p $(DESTDIR)$(includedir)/libmormegil - cp include/libmormegil/* $(DESTDIR)$(includedir)/libmormegil + install -t $(DESTDIR)$(includedir)/libmormegil include/libmormegil/* else install-headers: mkdir -p $(DESTDIR)$(includedir)/libmormegil - cp include/libmormegil/* $(DESTDIR)$(includedir)/libmormegil + install -t $(DESTDIR)$(includedir)/libmormegil include/libmormegil/* endif -# vim:noexpandtab:fo=c +# vim:noexpandtab:fo=croq diff --git a/changelog b/changelog new file mode 100644 index 0000000..462e79c --- /dev/null +++ b/changelog @@ -0,0 +1,3 @@ +Version 1.0.0 (2011-04-09) +========================== +Initial release. diff --git a/configure b/configure index 165ec6b..10340d3 100755 --- a/configure +++ b/configure @@ -2,47 +2,118 @@ use strict; use Getopt::Long; +use English; +# Prefixes my $prefix='/usr/local'; -my $exec_prefix=''; -my $bindir=''; -my $libdir=''; -my $includedir=''; +my $exec_prefix='$(prefix)'; + +# Bin and lib dirs +my $bindir='$(exec_prefix)/bin'; +my $sbindir='$(exec_prefix)/sbin'; +my $libdir='$(exec_prefix)/lib'; +my $libexecdir='$(exec_prefix)/libexec'; + +my $datarootdir='$(prefix)/share'; +my $datadir='$(datarootdir)'; +my $sysconfdir='$(prefix)/etc'; +my $sharedstatedir='$(prefix)/com'; +my $localstatedir='$(prefix)/var'; + +my $includedir='$(prefix)/include'; my $oldincludedir='/usr/include'; -my $datarootdir=''; -my $mandir=''; -my $man3dir=''; -my $docdir=''; -my $verbose=''; + +my $docdir='$(datarootdir)/doc/libmormegil'; +my $htmldir='$(docdir)'; +my $dvidir='$(docdir)'; +my $pdfdir='$(docdir)'; +my $psdir='$(docdir)'; + +my $localedir='$(datarootdir)/locale'; + +my $infodir='$(datarootdir)/info'; + +my $mandir='$(datarootdir)/man'; +my $man1dir='$(mandir)/man1'; +my $man3dir='$(mandir)/man3'; +my $man5dir='$(mandir)/man5'; +my $man6dir='$(mandir)/man6'; +my $man7dir='$(mandir)/man7'; +my $man1ext='.1'; +my $man3ext='.3'; +my $man5ext='.5'; +my $man6ext='.6'; +my $man7ext='.7'; + +my $verbose=1; GetOptions( 'prefix=s' => \$prefix, 'exec_prefix=s' => \$exec_prefix, -'includedir=s' => \$includedir, 'oldincludedir=s' => \$oldincludedir, 'bindir=s' => \$bindir, 'libdir=s' => \$libdir, -'datarootdir=s' => \$datarootdir, 'mandir=s' => \$mandir, -'man3dir=s' => \$man3dir, 'docdir=s' => \$docdir, -'verbose' => \$verbose, 'quiet' => sub { $verbose = 0; } ); - -print "Configuring libmormegil build/install process...\n" if $verbose; - -if ($exec_prefix eq '') { $exec_prefix = "${prefix}"; } -if ($bindir eq '') { $bindir = "${exec_prefix}/bin"; } -if ($libdir eq '') { $libdir = "${prefix}/lib"; } -if ($includedir eq '') { $includedir = "${prefix}/include"; } -if ($datarootdir eq '') { $datarootdir = "${prefix}/share"; } -if ($mandir eq '') { $mandir = "${datarootdir}/man"; } -if ($man3dir eq '') { $man3dir = "${mandir}/man3"; } -if ($docdir eq '') { $docdir = "${datarootdir}/doc/libmormegil"; } +'includedir=s' => \$includedir, 'oldincludedir=s' => \$oldincludedir, +'datarootdir=s' => \$datarootdir, 'datadir=s' => \$datadir, +'sysconfdir=s' => \$sysconfdir, 'sharedstatedir=s' => \$sharedstatedir, +'localstatedir=s' => \$localstatedir, 'localedir=s' => \$localedir, +'mandir=s' => \$mandir, +'man1dir=s' => \$man1dir, 'man3dir=s' => \$man3dir, +'man5dir=s' => \$man5dir, 'man6dir=s' => \$man6dir, +'man7dir=s' => \$man7ext, +'man1ext=s' => \$man1ext, 'man3ext=s' => \$man3ext, +'man5ext=s' => \$man5ext, 'man6ext=s' => \$man6ext, +'man7ext=s' => \$man7ext, +'docdir=s' => \$docdir, 'htmldir=s' => \$htmldir, +'dvidir=s' => \$dvidir, 'pdfdir=s' => \$pdfdir, +'psdir=s' => \$psdir, 'infodir=s' => \$infodir, +'verbose' => \$verbose, +'quiet' => sub { $verbose = 0; } ); + +print STDOUT "Configuring libmormegil build/install process...\n" if $verbose; + +my $cmdresults; + +print STDOUT "Testing 'mkdir -p' ...\n" if $verbose; +rmdir "billy/bob"; +rmdir "billy"; +$cmdresults=`mkdir -p billy/bob 2>&1`; +if ($CHILD_ERROR != 0) { + print STDERR "mkdir -p billy/bob failed\n"; + rmdir "billy"; + die "Please install a POSIX-compliant mkdir.\n"; +} +rmdir "billy/bob"; +rmdir "billy"; + if ($includedir eq $oldincludedir) { $oldincludedir = ''; } -print "Writing dirs.mk...\n" if $verbose; +print STDOUT "Writing dirs.mk...\n" if $verbose; open(DIRS_MK, '>', "dirs.mk") or die $!; print DIRS_MK "prefix=${prefix}\n"; print DIRS_MK "exec_prefix=${exec_prefix}\n"; print DIRS_MK "bindir=${bindir}\n"; +print DIRS_MK "sbindir=${sbindir}\n"; print DIRS_MK "libdir=${libdir}\n"; +print DIRS_MK "libexecdir=${libexecdir}\n"; +print DIRS_MK "datarootdir=${datarootdir}\n"; +print DIRS_MK "datadir=${datadir}\n"; +print DIRS_MK "sysconfdir=${sysconfdir}\n"; +print DIRS_MK "sharedstatedir=${sharedstatedir}\n"; +print DIRS_MK "localstatedir=${localstatedir}\n"; +print DIRS_MK "localedir=${localedir}\n"; print DIRS_MK "includedir=${includedir}\n"; print DIRS_MK "oldincludedir=${oldincludedir}\n"; -print DIRS_MK "datarootdir=${datarootdir}\n"; print DIRS_MK "mandir=${mandir}\n"; +print DIRS_MK "man1dir=${man1dir}\n"; print DIRS_MK "man3dir=${man3dir}\n"; +print DIRS_MK "man5dir=${man5dir}\n"; +print DIRS_MK "man6dir=${man6dir}\n"; +print DIRS_MK "man7dir=${man7dir}\n"; +print DIRS_MK "man1ext=${man1ext}\n"; +print DIRS_MK "man3ext=${man3ext}\n"; +print DIRS_MK "man5ext=${man5ext}\n"; +print DIRS_MK "man6ext=${man6ext}\n"; +print DIRS_MK "man7ext=${man7ext}\n"; print DIRS_MK "docdir=${docdir}\n"; +print DIRS_MK "htmldir=${htmldir}\n"; +print DIRS_MK "dvidir=${dvidir}\n"; +print DIRS_MK "pdfdir=${pdfdir}\n"; +print DIRS_MK "psdir=${psdir}\n"; +print DIRS_MK "infodir=${infodir}\n"; close(DIRS_MK); diff --git a/include/libmormegil/Hci.hh b/include/libmormegil/Hci.hh index f92ca0b..fc24699 100644 --- a/include/libmormegil/Hci.hh +++ b/include/libmormegil/Hci.hh @@ -10,6 +10,30 @@ namespace libmormegil { + class Hci + { + protected: + Hci_tilemode my_tilemode; + public: + enum Hci_tilemode { + Hci_tile_invalid = -1, + Hci_tile_wchar, + Hci_tile_pixel + }; + Hci() : my_tilemode(Hci_tile_invalid) { } + virtual ~Hci() { } + Hci_tilemode tilemode() const { return my_tilemode; } + // Now for the interesting part of the interface. It's not nearly as + // ambitious as I _want_ it to be, but that's because I don't feel + // like writing the elaborate separation mechanisms required. + virtual void init() = 0; + virtual void cleanup() = 0; + virtual void emit_message(const std::string& msg) = 0; + virtual void emit_message_decorated(const std::string& msg) = 0; + virtual void set_tile(int tile_layer, int tile_id) = 0; + virtual int register_tile_data(int layer, void *data) = 0; + }; + } #endif // libmormegil_Hci_hh diff --git a/include/libmormegil/Points.hh b/include/libmormegil/Points.hh index 26f5c90..e885425 100644 --- a/include/libmormegil/Points.hh +++ b/include/libmormegil/Points.hh @@ -43,11 +43,13 @@ namespace libmormegil curr += amount; return amount; } - // gain() is non-inline because it's messy. - int32_t gain(int32_t amount, Gain_mode mode); - int32_t lose(int32_t amount) { amount = std::max(0, maxval); return amount; } + int32_t gain(int32_t amount, Gain_mode mode); // a bit too messy to inline + int32_t lose(int32_t amount) { amount = std::max(0, curr); curr -= amount; return amount; } int32_t current() const { return curr; } int32_t maximum() const { return maxval; } + void force_current(int32_t c) { curr = c; } + void force_maximum(int32_t m) { m = std::max(0, m); maxval = m; } + Points(int32_t mv = 0, int32_t c = 0) : maxval(mv), curr(c) { } }; } #endif // libmormegil_Points_hh diff --git a/include/libmormegil/stlwprintf.hh b/include/libmormegil/stlwprintf.hh new file mode 100644 index 0000000..3e8b663 --- /dev/null +++ b/include/libmormegil/stlwprintf.hh @@ -0,0 +1,21 @@ +// libmormegil/stlwprintf.hh - (v)sprintf-for-STL-strings +// +// In jurisdictions where this file would be adjuged to contain copyrightable +// material, it is copyright 2011 Martin Read, and released to the public +// under the terms of the Creative Commons Public Domain Dedication (cc-0). +// It is provided without any warranty, express or implied. + +#ifndef libmormegil_stlprintf_hh +#define libmormegil_stlprintf_hh +#include +#include + +namespace libmormegil +{ + extern std::wstring vstlwprintf(const wchar_t *fmt, va_list args); + extern std::wstring stlwprintf(const wchar_t *fmt, ...); +} +#endif + +// vim:ts=8:sw=4:fo=croq +// libmormegil/stlwprintf.hh diff --git a/man/libmormegil::Hci.3 b/man/libmormegil::Hci.3 new file mode 100644 index 0000000..9b33a21 --- /dev/null +++ b/man/libmormegil::Hci.3 @@ -0,0 +1,17 @@ +.TH "LIBMORMEGIL::HCI" 3 "April 6, 2011" "libmormegil Version 1.0" "libmormegil User Manual" +.SH NAME +libmormegil::Hci \- human-computer interface +.SH SYNOPSIS +#include + +.SH DESCRIPTION +.I libmormegil::Hci +is an abstract base class used as the basis for \fIlibmormegil::Hci_ncu\fP, +an \fIncursesw\fP-based human-computer interface class. + +.SH AUTHOR +Martin Read + +.SH SEE ALSO + +libmormegil::Hci_ncu(3) diff --git a/man/libmormegil::Points.3 b/man/libmormegil::Points.3 new file mode 100644 index 0000000..696db17 --- /dev/null +++ b/man/libmormegil::Points.3 @@ -0,0 +1,61 @@ +.TH "LIBMORMEGIL::POINTS" 3 "April 7, 2011" "libmormegil Version 1.0" "libmormegil User Manual" +.SH NAME +libmormegil::Points \- tracker object for hit points or similar +.SH SYNOPSIS +#include + +int32_t libmormegil::Points::gain(int32_t amount, libmormegil::Points::Gain_mode mode); + +int32_t libmormegil::Points::lose(int32_t amount); + +int32_t libmormegil::Points::boost(int32_t amount); + +int32_t libmormegil::Points::restore(int32_t amount); + +int32_t libmormegil::Points::current() const; + +int32_t libmormegil::Points::maximum() const; + +void libmormegil::Points::force_current(int32_t c); + +void libmormegil::Points::force_maximum(int32_t m); + +void libmormegil::Points::Points(int32_t mv = 0, int32_t c = 0); + +.SH DESCRIPTION +.I libmormegil::Points +is a class for tracking quantities like "hit points" in a game. + +The \fIgain\fP member function increases the maximum value by \fIamount\fP +(but not above 2^31-1), and adjusts the current value according to the mode +selected by \fImode\fP. The valid values for \fImode\fP are \fIGain_match\fP +(current value increases by the same amount as the maximum), +.I Gain_proportional +(current value increases in proportion to the increase in the maximum), and +.I Gain_norestore +(current value does not change). The return value is the actual change in +the maximum value. + +The \fIlose\fP member function reduces the current value by \fIamount\fP, but +not below zero. It returns a positive integer with magnitude equal to that of +the change in the current value. + +The \fIrestore\fP member function increases the current value by \fIamount\fP +but not above the maximum value. It returns the actual change in the current +value. + +The \fIboost\fP member function increases the current value by \fIamount\fP +but not above 2^31-1. It returns the actual change in the current value. + +The \fIcurrent\fP and \fImaximum\fP member functions return the current and +maximum values, respectively. + +The \fIforce_current\fP and \fIforce_maximum\fP set the current and maximum +value, respectively. + +.SH AUTHOR +Martin Read + +.SH SEE ALSO + +libmormegil(3) diff --git a/man/libmormegil::stlprintf.3 b/man/libmormegil::stlprintf.3 index 10a7fb4..b5e0358 100644 --- a/man/libmormegil::stlprintf.3 +++ b/man/libmormegil::stlprintf.3 @@ -1,28 +1,46 @@ .TH "LIBMORMEGIL::STLPRINTF" 3 "February 25, 2011" "libmormegil Version 1.0" "libmormegil User Manual" .SH NAME -libmormegil::stlprintf, libmormegil::vstlprintf \- sprintf-alikes for std::string +libmormegil::stlprintf, libmormegil::vstlprintf, libmormegil::stlwprintf, libmormegil::vstlwprintf \- (v)s(w)printf-alikes for std::string .SH SYNOPSIS #include +std::string libmormegil::vstlprintf(const char *fmt, va_list args); + +std::string libmormegil::stlprintf(const char *fmt, ...); + +#include + +std::string libmormegil::vstlwprintf(const char *fmt, va_list args); + +std::string libmormegil::stlwprintf(const char *fmt, ...); + .SH DESCRIPTION The \fIlibmormegil::stlprintf\fP and \fIlibmormegil::vstlprintf\fP functions are equivalent to the standard C library's \fIsprintf\fP and \fIvsprintf\fP functions, but operate on the standard C++ library's \fIstd::string\fP class rather than on C-style strings. +The \fIlibmormegil::stlwprintf\fP and \fIlibmormegil::vstlwprintf\fP functions +are equivalent to the standard C library's \fIswprintf\fP and \fIvswprintf\fP +functions, but operate on the standard C++ library's \fIstd::wstring\fP class +rather than on C-style wide strings. + .SH RETURNS -Both functions return a \fIstd::string\fP object containing the formatted -output. +The object returned is a \fIstd::string\fP or \fIstd::wstring\fP containing +the formatted output. .SH CAVEATS These functions are wrapped around your system's local implementation of -vsprintf. All bugs, health hazards, and other concerns which apply to the -local vsprintf apply to these functions as well. +vsprintf or vswprintf. All bugs, health hazards, and other concerns which +apply to those functions apply to these functions as well. .SH AUTHOR -Stefan O'Rear +The vstlprintf and stlprintf functions were written by Stefan O'Rear. Amendments were made by Martin Read in order to fit into libmormegil. +The vstlwprintf and stlwprintf functions were cloned by Martin Read from +the narrow versions as part of the libmormegil project. + .SH SEE ALSO -libmormegil(3), vsprintf(3) +libmormegil(3), vsprintf(3), vswprintf(3) diff --git a/src/ordinaldate.cc b/src/ordinaldate.cc index 18ecfe7..d2b5c17 100644 --- a/src/ordinaldate.cc +++ b/src/ordinaldate.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include #include diff --git a/src/stlwprintf.cc b/src/stlwprintf.cc new file mode 100644 index 0000000..93187cb --- /dev/null +++ b/src/stlwprintf.cc @@ -0,0 +1,75 @@ +/* stlwprintf.cc - (v)sprintf for STL wstrings + * + * Copyright 2011 Martin Read and Stefan O'Rear + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define STLWPRINTF_CC + +#include +#include +#include +#include + +std::wstring libmormegil::vstlwprintf(const wchar_t *fmt, va_list args) +{ + va_list ap; + int bsize = 80; + + do + { + wchar_t* buf = new wchar_t[bsize]; + + va_copy(ap, args); + int ret = vswprintf(buf, bsize, fmt, ap); + va_end(ap); + + // glibc2.0 compatibility; + if (ret == -1) + { + ret = bsize * 2; + } + + if (ret <= bsize) + { + std::wstring retv(buf, ret); + delete buf; + return retv; + } + + delete buf; + bsize = ret + 1; + } + while(1); +} + +std::wstring libmormegil::stlwprintf(const wchar_t *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + std::wstring ret = vstlwprintf(fmt, ap); + va_end(ap); + return ret; +} + +/* stlwprintf.cc */ -- 2.11.0