diff -Nru makenl-3.3.3/.cvsignore makenl-3.4.1/.cvsignore --- makenl-3.3.3/.cvsignore 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/.cvsignore 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,2 @@ +packages +binaries \ No newline at end of file diff -Nru makenl-3.3.3/CMakeLists.txt makenl-3.4.1/CMakeLists.txt --- makenl-3.3.3/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/CMakeLists.txt 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,14 @@ +# ########## Project setup ########## +PROJECT(makenl) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# ######### General setup ########## + +# Add source directory +ADD_SUBDIRECTORY(src) + +# Add documentation directory +ADD_SUBDIRECTORY(docs) + +# ######### Testing ########## + diff -Nru makenl-3.3.3/debian/TODO.Debian makenl-3.4.1/debian/TODO.Debian --- makenl-3.3.3/debian/TODO.Debian 2013-05-23 19:39:46.000000000 +0000 +++ makenl-3.4.1/debian/TODO.Debian 2013-11-16 16:20:31.000000000 +0000 @@ -1,7 +1,12 @@ -ToDo: makenl for Debian ------------------------ +ToDo: makenl for Ubuntu Lucid package +------------------------------------- -- Change debian/rules to use dh() style. -- Clarify makenl copyrights/licensing in debian/copyright? +- The docs Makefile uses asciidoc to create an makenl.html file. Add what + is necessary to use that in the packaging. - -- Robert James Clay Tue, 8 Jan 2013 12:07:11 -0500 ++++ lintian output +++ +W: makenl source: ancient-standards-version 3.8.0 (current is 3.8.4) +I: makenl: debian-news-entry-without-blank-line line 11 +I: makenl: hyphen-used-as-minus-sign usr/share/man/man1/makenl.1.gz:48 + + -- Robert James Clay Sat, 16 Nov 2013 10:53:14 -0400 diff -Nru makenl-3.3.3/debian/changelog makenl-3.4.1/debian/changelog --- makenl-3.3.3/debian/changelog 2013-05-23 19:39:46.000000000 +0000 +++ makenl-3.4.1/debian/changelog 2013-11-16 16:20:31.000000000 +0000 @@ -1,3 +1,9 @@ +makenl (3.4.1-0lucid1) lucid; urgency=low + + * New upstream release: see changelog.gz for changes from v3.3.3 to v3.4.1. + + -- Robert James Clay Sat, 16 Nov 2013 11:10:13 -0500 + makenl (3.3.3-0lucid1) lucid; urgency=low * Backport MakeNL v3.3.3 to Ubuntu v10.04 (lucid). diff -Nru makenl-3.3.3/debian/patches/00-KeywordSubstitutionNoise.patch makenl-3.4.1/debian/patches/00-KeywordSubstitutionNoise.patch --- makenl-3.3.3/debian/patches/00-KeywordSubstitutionNoise.patch 2013-05-23 19:39:46.000000000 +0000 +++ makenl-3.4.1/debian/patches/00-KeywordSubstitutionNoise.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,300 +0,0 @@ -Description: CVS Keyword substitution noise - Diff caused by CVS/RCS Keyword substitution related noise as compared against - the makenl_3.3.0.orig.tar.gz source archive file. -Author: Robert James Clay -Last-Update: <2013-01-10> - ---- a/docs/node.ctl -+++ b/docs/node.ctl -@@ -1,4 +1,4 @@ --; $Id: node.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ -+; $Id: node.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ - ; - ; Sample control file for an individual node - ---- a/docs/zone.ctl -+++ b/docs/zone.ctl -@@ -1,4 +1,4 @@ --; $Id: zone.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ -+; $Id: zone.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ - ; - ; This is a sample control for a the coordinator of a Zone. - ; Edit fields within angle brackets as necessary (removing the brackets) ---- a/docs/net-l.ctl -+++ b/docs/net-l.ctl -@@ -1,4 +1,4 @@ --; $Id: net-l.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ -+; $Id: net-l.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ - ; - ; This is a sample control for a the coordinator of a large Net, whose - ; Hub coordinators maintain their own segments. ---- a/docs/net-s.ctl -+++ b/docs/net-s.ctl -@@ -1,4 +1,4 @@ --; $Id: net-s.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ -+; $Id: net-s.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ - ; - ; This is a sample control for a the coordinator of a Hub or small Net. - ; Edit fields within angle brackets as necessary (removing the brackets). ---- a/docs/hub.ctl -+++ b/docs/hub.ctl -@@ -1,4 +1,4 @@ --; $Id: hub.ctl,v 1.1.1.1 2009/01/08 20:07:45 mbroek Exp $ -+; $Id: hub.ctl,v 1.1 2009/01/08 20:07:45 mbroek Exp $ - ; - ; This is a sample control for a the coordinator of a Hub or small Net. - ; Edit fields within angle brackets as necessary (removing the brackets). ---- a/docs/distrib.ctl -+++ b/docs/distrib.ctl -@@ -1,4 +1,4 @@ --; $Id: distrib.ctl,v 1.1.1.1 2009/01/08 20:07:45 mbroek Exp $ -+; $Id: distrib.ctl,v 1.1 2009/01/08 20:07:45 mbroek Exp $ - ; - ; This is a sample control for a coordinator who creates distribution files. - ; On process day, MakeNL is run a second time using this control file. ---- a/docs/regional.ctl -+++ b/docs/regional.ctl -@@ -1,4 +1,4 @@ --; $Id: regional.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ -+; $Id: regional.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ - ; - ; This is a sample control for a the coordinator of a Region. - ; Edit fields within angle brackets as necessary (removing the brackets) ---- a/slackware/Slackbuild -+++ b/slackware/Slackbuild -@@ -1,6 +1,6 @@ - #!/bin/sh - # --# $Id: Slackbuild,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ -+# $Id: Slackbuild,v 1.1 2009/01/08 20:07:46 mbroek Exp $ - # - # Build script for Slackware makenl package. - # ---- a/src/osmscful.c -+++ b/src/osmscful.c -@@ -1,4 +1,4 @@ --/* $Id: osmscful.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osmscful.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #define HAVE_OS_FULLPATH - ---- a/src/osgengtn.c -+++ b/src/osgengtn.c -@@ -1,4 +1,4 @@ --/* $Id: osgengtn.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osgengtn.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - char *os_file_getname(const char *path) - { ---- a/src/oswatfnd.c -+++ b/src/oswatfnd.c -@@ -1,4 +1,4 @@ --/* $Id: oswatfnd.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: oswatfnd.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #define HAVE_OS_FIND - #include ---- a/src/lsttool.h -+++ b/src/lsttool.h -@@ -1,4 +1,4 @@ --/* $Id: lsttool.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ -+/* $Id: lsttool.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ - - #define SEARCH_UPLOAD 0 - #define SEARCH_MAILFILE 1 ---- a/src/osdosfnd.c -+++ b/src/osdosfnd.c -@@ -1,4 +1,4 @@ --/* $Id: osdosfnd.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osdosfnd.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #include - #include "unused.h" ---- a/src/spawn.asm -+++ b/src/spawn.asm -@@ -1,4 +1,4 @@ --; $Id: spawn.asm,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ -+; $Id: spawn.asm,v 1.1 2009/01/08 20:07:47 mbroek Exp $ - - ;MODIFIED 5th October 1995 by Matthew Parker all changes are public domain. - ---- a/src/oswatful.c -+++ b/src/oswatful.c -@@ -1,4 +1,4 @@ --/* $Id: oswatful.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: oswatful.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - /* make an absolute path from given relative path */ - int os_fullpath(char *dst, const char *src, size_t bufsiz) ---- a/src/osgenaps.c -+++ b/src/osgenaps.c -@@ -1,4 +1,4 @@ --/* $Id: osgenaps.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osgenaps.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - /* normalize path */ - /* It is assumed that path has one more char allocated */ ---- a/src/spawn.h -+++ b/src/spawn.h -@@ -1,4 +1,4 @@ --/* $Id: spawn.h,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: spawn.h,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - /* - * SPAWN.H ---- a/src/osgencan.c -+++ b/src/osgencan.c -@@ -1,4 +1,4 @@ --/* $Id: osgencan.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osgencan.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - char *os_filecanonify(char *s) - { ---- a/src/oslnxdsl.c -+++ b/src/oslnxdsl.c -@@ -1,4 +1,4 @@ --/* $Id: oslnxdsl.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: oslnxdsl.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #define HAVE_OS_DESLASHIFY - ---- a/src/stack.h -+++ b/src/stack.h -@@ -1,4 +1,4 @@ --/* $Id: stack.h,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: stack.h,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - int addnumber(int maketype, int makenum, int markpos); - void unmarkstack(void); ---- a/src/osgenrms.c -+++ b/src/osgenrms.c -@@ -1,4 +1,4 @@ --/* $Id: osgenrms.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osgenrms.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - /* remove slash/backslash from last part of path name, if present */ - char *os_remove_slash(char *path1) ---- a/src/ignore.h -+++ b/src/ignore.h -@@ -1,3 +1,3 @@ --/* $Id: ignore.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ -+/* $Id: ignore.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ - - /* This file is used as substitute */ ---- a/src/crc16.h -+++ b/src/crc16.h -@@ -1,4 +1,4 @@ --/* $Id: crc16.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ -+/* $Id: crc16.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ - - unsigned short CRC16DoByte(unsigned char byte, unsigned short CRCnow); - unsigned short CRC16String(const char *str, unsigned short crc); ---- a/src/osemxful.c -+++ b/src/osemxful.c -@@ -1,4 +1,4 @@ --/* $Id: osemxful.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osemxful.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #define HAVE_OS_FULLPATH - ---- a/src/osgendsl.c -+++ b/src/osgendsl.c -@@ -1,4 +1,4 @@ --/* $Id: osgendsl.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osgendsl.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - /* converts slashes to backslashes for pathnames under DOS or EMX */ - char *os_deslashify(char *name) ---- a/src/strtool.c -+++ b/src/strtool.c -@@ -1,4 +1,4 @@ --/* $Id: strtool.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: strtool.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #include - #include ---- a/src/os.c -+++ b/src/os.c -@@ -1,6 +1,6 @@ - /* os.c -- Operating system dependant functions for makenl */ - --/* $Id: os.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: os.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #include - #include ---- a/src/exec.c -+++ b/src/exec.c -@@ -13,7 +13,7 @@ - BIXname: twagner - */ - --/* $Id: exec.c,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ -+/* $Id: exec.c,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ - - #include - #include ---- a/src/osd16exc.c -+++ b/src/osd16exc.c -@@ -1,4 +1,4 @@ --/* $Id: osd16exc.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osd16exc.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #include "exec.h" - ---- a/src/osgnufnd.c -+++ b/src/osgnufnd.c -@@ -1,4 +1,4 @@ --/* $Id: osgnufnd.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osgnufnd.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #define _GNU_SOURCE - #include ---- a/src/merge.h -+++ b/src/merge.h -@@ -1,4 +1,4 @@ --/* $Id: merge.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ -+/* $Id: merge.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ - - FILE *PrepareMerge(void); - void FinishMerge(void); ---- a/src/osgenupr.c -+++ b/src/osgenupr.c -@@ -1,4 +1,4 @@ --/* $Id: osgenupr.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osgenupr.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - #include - ---- a/src/proc.h -+++ b/src/proc.h -@@ -1,4 +1,4 @@ --/* $Id: proc.h,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: proc.h,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - /* Values for ShouldProcess */ - #define USUAL_PROCESSING 1 ---- a/src/osgenff.c -+++ b/src/osgenff.c -@@ -1,4 +1,4 @@ --/* $Id: osgenff.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: osgenff.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - char *os_findfile(struct _filefind *pff, const char *path, - const char *mask) ---- a/src/upcont.h -+++ b/src/upcont.h -@@ -1,4 +1,4 @@ --/* $Id: upcont.h,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ -+/* $Id: upcont.h,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ - - int UpdateContext(int level, int num, int makenum, int *ctxnum, - int *ctxlevel, int maketype); ---- a/src/exec.h -+++ b/src/exec.h -@@ -1,4 +1,4 @@ --/* $Id: exec.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ -+/* $Id: exec.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ - - #ifndef _EXEC_H - #define _EXEC_H diff -Nru makenl-3.3.3/debian/patches/series makenl-3.4.1/debian/patches/series --- makenl-3.3.3/debian/patches/series 2013-05-23 19:39:46.000000000 +0000 +++ makenl-3.4.1/debian/patches/series 2013-11-16 16:20:31.000000000 +0000 @@ -1 +0,0 @@ -00-KeywordSubstitutionNoise.patch diff -Nru makenl-3.3.3/docs/.cvsignore makenl-3.4.1/docs/.cvsignore --- makenl-3.3.3/docs/.cvsignore 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/docs/.cvsignore 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1 @@ +makenl.html diff -Nru makenl-3.3.3/docs/CMakeLists.txt makenl-3.4.1/docs/CMakeLists.txt --- makenl-3.3.3/docs/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/docs/CMakeLists.txt 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,31 @@ +# ########## MakeNL Documentation directory ########## + +# ########## MakeNL documentation ########## +# doc files: +SET(makenl_DOCS + cpyright.txt + distrib.ctl + epilog.txt + felten.txt + fts-5000.txt + hist31x.txt + history.txt + hub.ctl + karcher.eng + karcher.txt + makenl.prn + makenl.txt + net-l.ctl + net-s.ctl + node.ctl + prolog.txt + read.me + regional.ctl + whatsnew.txt + zone.ctl +) + +# ######### Installation ########## +# add install documentation: +INSTALL(FILES ${makenl_DOCS} DESTINATION share/doc/makenl) + diff -Nru makenl-3.3.3/docs/distrib.ctl makenl-3.4.1/docs/distrib.ctl --- makenl-3.3.3/docs/distrib.ctl 2009-01-08 20:07:45.000000000 +0000 +++ makenl-3.4.1/docs/distrib.ctl 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: distrib.ctl,v 1.1.1.1 2009/01/08 20:07:45 mbroek Exp $ +; $Id: distrib.ctl,v 1.1 2009/01/08 20:07:45 mbroek Exp $ ; ; This is a sample control for a coordinator who creates distribution files. ; On process day, MakeNL is run a second time using this control file. diff -Nru makenl-3.3.3/docs/frontier.txt makenl-3.4.1/docs/frontier.txt --- makenl-3.3.3/docs/frontier.txt 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/docs/frontier.txt 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,121 @@ +The Frontier Artistic License Version 1.0 +Derived from the Artistic License at OpenSource.org. +Submitted to OpenSource.org for Open Source Initiative certification. + +Preamble + +The intent of this document is to state the conditions under which a +Package may be copied, such that the Copyright Holder maintains some +semblance of artistic control over the development of the package, +while giving the users of the package the right to use and distribute +the Package in a more-or-less customary fashion, plus the right to +make reasonable modifications. + +Definitions + + "Package" refers to the script, suite, file, or collection of + scripts, suites, and/or files distributed by the Copyright Holder, + and to derivatives of that Package created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes of + the Copyright Holder. + + "Copyright Holder" is whoever is named in the copyright statement + or statements for the package. + + "You" is you, if you're thinking about copying or distributing + this Package. + + "Reasonable copying fee" is whatever you can justify on the basis + of media cost, duplication charges, time of people involved, and + so on. (You will not be required to justify it to the Copyright + Holder, but only to the computing community at large as a market + that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it under + the same conditions they received it. + + +Terms + +1. You may make and give away verbatim copies of the source form of +the Standard Version of this Package without restriction, provided +that you duplicate all of the original copyright notices and +associated disclaimers. + +2. You may apply bug fixes, portability fixes, and other modifications +derived from the Public Domain or from the Copyright Holder. A Package +modified in such a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, +provided that you insert a prominent notice in each changed script, +suite, or file stating how and when you changed that script, suite, +or file, and provided that you do at least ONE of the following: + + a) Use the modified Package only within your corporation or + organization, or retain the modified Package solely for personal use. + + b) Place your modifications in the Public Domain or otherwise make + them Freely Available, such as by posting said modifications to Usenet + or an equivalent medium, or placing the modifications on a major archive + site such as ftp.uu.net, or by allowing the Copyright Holder to include + your modifications in the Standard Version of the Package. + + c) Rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and provide + a separate manual page (or equivalent) for each non-standard executable + that clearly documents how it differs from the Standard Version. + + d) Make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or +executable form, provided that you do at least ONE of the following: + + a) Distribute a Standard Version of the executables and library + files, together with instructions (in the manual page or + equivalent) on where to get the Standard Version. + + b) Accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) Accompany any non-standard executables with their corresponding + Standard Version executables, give the non-standard executables + non-standard names, and clearly document the differences in manual + pages (or equivalent), together with instructions on where to get + the Standard Version. + + d) Make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of +this Package. You may charge any fee you choose for support of this +Package. You may not charge a fee for this Package itself. However, +you may distribute this Package in aggregate with other (possibly +commercial) programs as part of a larger (possibly commercial) +software distribution provided that you do not advertise this Package +as a product of your own. + +6. The scripts and library files supplied as input to or produced as +output from the programs of this Package do not automatically fall +under the copyright of this Package, but belong to whomever generated +them, and may be sold commercially, and may be aggregated with this +Package. + +7. Scripts, suites, or programs supplied by you that depend on or +otherwise make use of this Package shall not be considered part of +this Package. + +8. The name of the Copyright Holder may not be used to endorse or +promote products derived from this software without specific prior +written permission. + +9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End + + +http://www.spinwardstars.com/frontier/fal.html diff -Nru makenl-3.3.3/docs/history.txt makenl-3.4.1/docs/history.txt --- makenl-3.3.3/docs/history.txt 2013-01-17 14:31:42.000000000 +0000 +++ makenl-3.4.1/docs/history.txt 2013-10-11 17:07:33.000000000 +0000 @@ -1,9 +1,144 @@ -/* $Id: history.txt,v 1.17 2013/01/17 14:31:42 jame Exp $ */ +/* $Id: history.txt,v 1.29 2013/10/11 13:16:52 ajleary Exp $ */ MakeNL Revision History + + v3.4.1 -- October 11, 2013 + + Ignore CTRL-Z lines in COPyright, PROlog, and EPIlog files. + They were causing CRC errors in the Linux version. + -- Andrew Leary + + v3.4.0 -- October 6, 2013 + + Release version of v3.3.10 for wide distribution. Also fixed + the Slackware Slackbuild script for generating a Slackware + installation package. Added information on the new Allow8Bit + control file option to the whatsnew.txt. + -- Andrew Leary + + v3.3.10 -- September 29, 2013 + + Updated history.txt with a very brief synopsis of the changes + made since the last release. + -- Andrew Leary + + Added Microsoft C 6.0 for DOS port. + -- Andrew Clarke + + Switched to strlcpy() and strlcat() whereever possible, to + prevent crashes/segfaults related to buffer overflows. + -- Andrew Clarke + + Added missing os_fullpath() function to allow the Watcom DOS + 16-bit and DOS 32-bit versions to sucessfully build again. + -- Andrew Leary + + Switched to using portable snprintf(), Copyright 1999 by Mark + Martinec. + -- Andrew Clarke + + Added Solaris port. + -- Andrew Clarke + + v3.3.9 -- September 21, 2013 + + Moved all of the operating system specific code to src/os.c. + Added port to TinyCC. + -- Andrew Clarke + + Added support for changing drives when needed to the DOS, OS/2, + and Windows versions. + -- Andrew Leary + + v3.3.8 -- September 4, 2013 + + Fixed the OldExtensions processing again; I missed a couple + places... + Bump version to 3.3.8; this is a release candidate for 3.4.0. + -- Andrew Leary + + Revert my changes that tried to fix Watcom OS/2 version. + Fix code in src/msgtool.c that clang was complaining about. + -- Andrew Clarke + + v3.3.7 -- September 3, 2013 + + Fix OldExtensions processing in src/process.c to properly go + back 7 weeks. + Bump version to 3.3.7; this hopefully will be the last test + version before 3.4.0. + -- Andrew Leary + + Use Watcom's fnmatch() instead of patmat(). + Add CFLAGS to link stage in the BSD & Linux Makefiles. + free(WorkFile) sometimes fails because it's pointing to a (valid) + memory location instead of somewhere allocated with strdup() or + malloc(). + Add debug build with clang using AddressSanitizer. + Uncomment in src/process.c code suspected of causing a Segmentation. + Fault but may be fixed and shouldn't be simply commented out. + -- Andrew Clarke + + -- September 2, 2013 + + Reformat src/CMakeLists.txt and add creation of install targets + to it. + Import docs/CMakeLists.txt and top level CMakeLists.txt from my + local development branch. + -- Robert James Clay + + -- August 29, 2013 + + EMX fix: gcc 3.3 does not support mixed mode executables. + Remove the 'add_definitions' line from src/CMakeLists.txt as it + breaks the MSVC build. + -- Andrew Clarke + + -- August 28, 2013 + + Add clean up of the 'WorkFile' to /src/makenl.c + Create initial version of CMake build file src/CMakeLists.txt. + -- Andrew Clarke + + -- August 23, 2013 + + IBM VisualAge C/C++ for OS/2 port. + Fix OldExtensions[] array overrun segfault. + Correction to how the stack is getting fixed plus cosmetic fixes in + the src/msgtool.c file. + Possible fix for crash in the Watcom OS/2 version (bug #17), plus + patches for the IBM VisualAge C/C++, Borland C & Metaware High C + OS/2 versions. + -- Andrew Clarke + + -- August 11, 2013 + + Borland C++ for OS/2 port. + MetaWare High C for OS/2 port. Requires GNU Make. + EMX makefile for building a standalone binary not requiring EMX.DLL. + -- Andrew Clarke + + v3.3.6 -- May 25, 2013 + + Add new configuration option "Allow8Bit" which disables the + replacement of characters above 0x7f with question marks. This + option defaults to 0 (off); to enable it add Allow8Bit 1 to your + .CTL file. + -- Andrew Leary + + v3.3.5 -- Feb 07, 2013 + + Update docs/history.txt and src/version.h to UTF-8. + Update Tracker information in the docs/whatsnew.txt file. + -- Robert James Clay + + v3.3.4 -- Jan 30, 2013 + + Increase maximum nodelist segment age to 7 weeks. + -- Andrew Leary - v3.3.3 -- Jan 14, 2012 + v3.3.3 -- Jan 14, 2013 Update the docs/felten.txt file to UTF-8 Update docs/fts-5000.txt with current FTS-5000.004 version. @@ -354,7 +489,7 @@ ALPHaphone 1 (0 or not in CFG disables) - V2.52 -- April 16, 1998 -- Y2k patch (Bjorn Felten -- 2:203/0) + V2.52 -- April 16, 1998 -- Y2k patch (Björn Felten -- 2:203/0) Patched the year written in attach and receipt mail. Removed the check for Hi ASCII and "erroneous" baud rates. diff -Nru makenl-3.3.3/docs/hub.ctl makenl-3.4.1/docs/hub.ctl --- makenl-3.3.3/docs/hub.ctl 2009-01-08 20:07:45.000000000 +0000 +++ makenl-3.4.1/docs/hub.ctl 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: hub.ctl,v 1.1.1.1 2009/01/08 20:07:45 mbroek Exp $ +; $Id: hub.ctl,v 1.1 2009/01/08 20:07:45 mbroek Exp $ ; ; This is a sample control for a the coordinator of a Hub or small Net. ; Edit fields within angle brackets as necessary (removing the brackets). diff -Nru makenl-3.3.3/docs/license.txt makenl-3.4.1/docs/license.txt --- makenl-3.3.3/docs/license.txt 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/docs/license.txt 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff -Nru makenl-3.3.3/docs/net-l.ctl makenl-3.4.1/docs/net-l.ctl --- makenl-3.3.3/docs/net-l.ctl 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/docs/net-l.ctl 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: net-l.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ +; $Id: net-l.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ ; ; This is a sample control for a the coordinator of a large Net, whose ; Hub coordinators maintain their own segments. diff -Nru makenl-3.3.3/docs/net-s.ctl makenl-3.4.1/docs/net-s.ctl --- makenl-3.3.3/docs/net-s.ctl 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/docs/net-s.ctl 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: net-s.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ +; $Id: net-s.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ ; ; This is a sample control for a the coordinator of a Hub or small Net. ; Edit fields within angle brackets as necessary (removing the brackets). diff -Nru makenl-3.3.3/docs/node.ctl makenl-3.4.1/docs/node.ctl --- makenl-3.3.3/docs/node.ctl 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/docs/node.ctl 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: node.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ +; $Id: node.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ ; ; Sample control file for an individual node diff -Nru makenl-3.3.3/docs/regional.ctl makenl-3.4.1/docs/regional.ctl --- makenl-3.3.3/docs/regional.ctl 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/docs/regional.ctl 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: regional.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ +; $Id: regional.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ ; ; This is a sample control for a the coordinator of a Region. ; Edit fields within angle brackets as necessary (removing the brackets) diff -Nru makenl-3.3.3/docs/whatsnew.txt makenl-3.4.1/docs/whatsnew.txt --- makenl-3.3.3/docs/whatsnew.txt 2010-02-05 23:31:23.000000000 +0000 +++ makenl-3.4.1/docs/whatsnew.txt 2013-10-11 17:07:33.000000000 +0000 @@ -1,13 +1,14 @@ -$Id: whatsnew.txt,v 1.3 2010/02/05 23:31:23 jame Exp $ +$Id: whatsnew.txt,v 1.5 2013/10/06 19:44:49 ajleary Exp $ Support: ======== - Web: http://makenl.sourceforge.net/ - Fido: in the echomail area MAKENL_NG, available on most systems - that carry the Fidonet NAB and/or WWB areas. - Please report bugs only to the bugtracker on the web: - http://sourceforge.net/tracker/?group_id=191700&atid=938433 + Web: http://makenl.sourceforge.net/ + Fidonet: The echomail area MAKENL_NG, available to most systems + Trackers: Besides discussions in the echo, Bugs and Feature Requests + can be registered and tracked at: + http://sourceforge.net/p/makenl/bugs/ + http://sourceforge.net/p/makenl/feature-requests/ Important Changes since MakeNL 2.5x: @@ -95,13 +96,21 @@ Zoo: ARCOpen o zoo eq:0 Ha: ARCOpen h ha ey -ALLOwunpub: +ALLOW8bit: +---------- + ALLOW8bit is a new keyword that will cause MakeNL to allow char- + acters above 0x7F in nodelist entries. Normally, such characters + are replaced with question marks (?) when the file is processed. + This keyword is disabled by default. To enable it, add ALLOW8bit 1 + to your MAKENL.CTL file. + +ALLOWUnpub: ----------- - ALLOwunpub is a new keyword that will cause MakeNL to allow the + ALLOWUnpub is a new keyword that will cause MakeNL to allow the -Unpublished- string to be present in the sixth (phone number) field of node listings, without requiring the Pvt keyword to be present in the listing. This keyword is disabled by default. To - enable it, add ALLOwunpub 1 to your MAKENL.CTL file. + enable it, add ALLOWUnpub 1 to your MAKENL.CTL file. ALPHAphone: ----------- diff -Nru makenl-3.3.3/docs/zone.ctl makenl-3.4.1/docs/zone.ctl --- makenl-3.3.3/docs/zone.ctl 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/docs/zone.ctl 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: zone.ctl,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ +; $Id: zone.ctl,v 1.1 2009/01/08 20:07:46 mbroek Exp $ ; ; This is a sample control for a the coordinator of a Zone. ; Edit fields within angle brackets as necessary (removing the brackets) diff -Nru makenl-3.3.3/slackware/Slackbuild makenl-3.4.1/slackware/Slackbuild --- makenl-3.3.3/slackware/Slackbuild 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/slackware/Slackbuild 2013-10-11 17:07:33.000000000 +0000 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Slackbuild,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ +# $Id: Slackbuild,v 1.2 2013/10/03 16:19:51 ajleary Exp $ # # Build script for Slackware makenl package. # @@ -15,7 +15,7 @@ exit 1 fi -VERSION=`grep MAKENL_VERSION ../src/version.h | awk '{ print $3 }' | tr -d '"'` +VERSION=`grep -m 1 MAKENL_VERSION ../src/version.h | awk '{ print $3 }' | tr -d '"\r\n'` CWD=`pwd` if [ "$TMP" = "" ]; then TMP=/tmp diff -Nru makenl-3.3.3/src/.cvsignore makenl-3.4.1/src/.cvsignore --- makenl-3.3.3/src/.cvsignore 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/.cvsignore 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,2 @@ +makenl +makeall.bat diff -Nru makenl-3.3.3/src/CMakeLists.txt makenl-3.4.1/src/CMakeLists.txt --- makenl-3.3.3/src/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/CMakeLists.txt 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,26 @@ +# ########## MakeNL Source Directory ########## + +# ########## MakeNL Executable ########## +ADD_EXECUTABLE (makenl + config.c + crc16.c + fileutil.c + fts5.c + lsttool.c + makenl.c + merge.c + mkdiff.c + mklog.c + msgtool.c + output.c + procfile.c + stack.c + strtool.c + upcont.c + os.c +) + +# add install target for executable: +INSTALL(TARGETS makenl DESTINATION bin) +# add install target for man page: +INSTALL(FILES makenl.1 DESTINATION share/man/man1) diff -Nru makenl-3.3.3/src/config.c makenl-3.4.1/src/config.c --- makenl-3.3.3/src/config.c 2012-10-16 18:52:12.000000000 +0000 +++ makenl-3.4.1/src/config.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: config.c,v 1.18 2012/10/16 18:52:12 ozzmosis Exp $ */ +/* $Id: config.c,v 1.27 2013/09/26 19:29:20 ozzmosis Exp $ */ #include #include @@ -10,19 +10,13 @@ #include "msg.h" #include "config.h" #include "fts5.h" -#include "proc.h" +#include "procfile.h" #include "lsttool.h" #include "fileutil.h" #include "mklog.h" #include "version.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif +#include "strtool.h" +#include "snprintf.h" #define MF_EVERYWHERE(x) ((x) | ((x) << MF_SHIFT_ERRORS) | ((x) << MF_SHIFT_SUBMIT)) #define MAIL_CRASH MF_EVERYWHERE(MF_CRASH) @@ -69,13 +63,13 @@ { mklog(LOG_ERROR, "No directory for master files specified -- using '%s'", CurDir); - strcpy(MasterDir, CurDir); + strlcpy(MasterDir, CurDir, sizeof MasterDir); } if (OutDir[0] == 0) { mklog(LOG_ERROR, "No directory for output file specified -- using '%s'", MasterDir); - strcpy(OutDir, MasterDir); + strlcpy(OutDir, MasterDir, sizeof OutDir); } if (UploadDir[0] != 0 && !strcmp(UploadDir, MasterDir)) { @@ -107,7 +101,7 @@ mode = -1; } else if (UploadDir[0] != 0 && MailfileDir[0] != 0 - && !filecmp(UpdateDir, MailfileDir)) + && !filecmp(UploadDir, MailfileDir)) { mklog(LOG_ERROR, "UPLoads and MAIlfiles both specify '%s'", UploadDir); mode = -1; @@ -179,7 +173,7 @@ (*value)[0] = 0; /* Kill the '=' sign */ (*value)++; /* Point to the value */ } - return xlate_switch(strupr(argument), swstrings); + return xlate_switch(strupper(argument), swstrings); } unsigned int @@ -283,7 +277,7 @@ { tmpptr = "nodelist"; } - strcpy(MergeFilename, tmpptr); + strlcpy(MergeFilename, tmpptr, sizeof MergeFilename); break; case 'N': @@ -387,9 +381,10 @@ {"UPDATE", 3, CFG_UPDATE}, {"UPLOADS", 3, CFG_UPLOADS}, {"ALPHAPHONE", 4, CFG_ALPHAPHONE}, - {"ALLOWUNPUB", 4, CFG_ALLOWUNPUB}, + {"ALLOWUNPUB", 6, CFG_ALLOWUNPUB}, {"LOGFILE", 4, CFG_LOGFILE}, {"LOGLEVEL", 4, CFG_LOGLEVEL}, + {"ALLOW8BIT", 6, CFG_ALLOW8BIT}, {NULL, 0, -1} }; @@ -472,7 +467,8 @@ {2, 2}, /* ALLOwunpub 1 or 0 - default 0 */ {2, 2}, /* LOGFile pfile */ {2, 2}, /* LOGLevel 1..4 - default 1 */ - {2, 2} /* FORcesubmit 1 or 0 - default 0 */ + {2, 2}, /* FORcesubmit 1 or 0 - default 0 */ + {2, 2} /* ALLOW8BIT 1 or 0 - default 0 */ }; /* *INDENT-ON* */ @@ -514,11 +510,11 @@ if (workptr) *workptr = 0; cutspaces(cfgline); - strcpy(cfgSplit, cfgline); + strlcpy(cfgSplit, cfgline, sizeof cfgSplit); command = strtok(cfgSplit, cfgspacechars); /* Space and Tab */ if (!command) continue; - switchno = xlate_switch(strupr(command), CfgEntries); + switchno = xlate_switch(strupper(command), CfgEntries); if (switchno == -1) { mklog(LOG_ERROR, "'%s': Unknown keyword '%s'", cfgline, command); @@ -557,21 +553,21 @@ case CFG_ARCCOPY: ArcCopyExt[0] = args[0][0]; if (argcounter == 6) - sprintf(ArcCopyCmd, "%s %s %s %s", args[1], args[2], args[3], args[4]); + snprintf(ArcCopyCmd, sizeof ArcCopyCmd, "%s %s %s %s", args[1], args[2], args[3], args[4]); else if (argcounter == 5) - sprintf(ArcCopyCmd, "%s %s %s", args[1], args[2], args[3]); + snprintf(ArcCopyCmd, sizeof ArcCopyCmd, "%s %s %s", args[1], args[2], args[3]); else - sprintf(ArcCopyCmd, "%s %s", args[1], args[2]); + snprintf(ArcCopyCmd, sizeof ArcCopyCmd, "%s %s", args[1], args[2]); ArcCopySet = 1; break; case CFG_ARCMOVE: ArcMoveExt[0] = args[0][0]; if (argcounter == 6) - sprintf(ArcMoveCmd, "%s %s %s %s", args[1], args[2], args[3], args[4]); + snprintf(ArcMoveCmd, sizeof ArcMoveCmd, "%s %s %s %s", args[1], args[2], args[3], args[4]); else if (argcounter == 5) - sprintf(ArcMoveCmd, "%s %s %s", args[1], args[2], args[3]); + snprintf(ArcMoveCmd, sizeof ArcMoveCmd, "%s %s %s", args[1], args[2], args[3]); else - sprintf(ArcMoveCmd, "%s %s", args[1], args[2]); + snprintf(ArcMoveCmd, sizeof ArcMoveCmd, "%s %s", args[1], args[2]); ArcMoveSet = 1; break; case CFG_ARCOPEN: @@ -584,15 +580,15 @@ } ArcOpenExt[ArcOpenSet][0] = args[0][0]; if (argcounter == 6) - sprintf(ArcOpenCmd[ArcOpenSet], "%s %s %s %s", args[1], args[2], args[3], args[4]); + snprintf(ArcOpenCmd[ArcOpenSet], sizeof ArcOpenCmd[ArcOpenSet], "%s %s %s %s", args[1], args[2], args[3], args[4]); else if (argcounter == 5) - sprintf(ArcOpenCmd[ArcOpenSet], "%s %s %s", args[1], args[2], args[3]); + snprintf(ArcOpenCmd[ArcOpenSet], sizeof ArcOpenCmd[ArcOpenSet], "%s %s %s", args[1], args[2], args[3]); else - sprintf(ArcOpenCmd[ArcOpenSet], "%s %s", args[1], args[2]); + snprintf(ArcOpenCmd[ArcOpenSet], sizeof ArcOpenCmd[ArcOpenSet], "%s %s", args[1], args[2]); ArcOpenSet++; break; case CFG_BATCHFILE: - strcpy(BatchFile, args[0]); + strlcpy(BatchFile, args[0], sizeof BatchFile); break; case CFG_BAUDRATE: /* Parse comma separated list of baudrates, maximum twelve */ @@ -628,7 +624,7 @@ } break; case CFG_LOGFILE: - strcpy(LogFile, args[0]); + strlcpy(LogFile, args[0], sizeof LogFile); /* Now we know the logfile, start logging immediately */ mklog(LOG_LOGONLY, MAKENL_LONG_VERSION); mklog(LOG_INFO, "MakeNL started"); @@ -646,13 +642,13 @@ } break; case CFG_CALLEDBATCHFILE: - strcpy(CalledBatchFile, args[0]); + strlcpy(CalledBatchFile, args[0], sizeof CalledBatchFile); break; case CFG_CLEANUP: do_clean = 1; break; case CFG_COMMENTS: - strcpy(CommentsFile, args[0]); + strlcpy(CommentsFile, args[0], sizeof CommentsFile); break; case CFG_COPYRIGHT: workptr = CopyrightFile; @@ -664,7 +660,7 @@ sscanf(cfgline, "%*s %15s", namebuf); break; case CFG_MAKE: - MakeType = xlate_switch(strupr(args[0]), MakeTypes); + MakeType = xlate_switch(strupper(args[0]), MakeTypes); if (MakeType == -1) { mklog(LOG_ERROR, "%s -- Don't know how to make '%s'", @@ -685,7 +681,9 @@ if (argcounter == 4) /* Source file given */ { if (filenodir(args[2])) - strcpy(MakeSourceFile, args[2]); + { + strlcpy(MakeSourceFile, args[2], sizeof MakeSourceFile); + } else { mklog(LOG_ERROR, "%s -- Invalid file name -- '%s'", @@ -702,9 +700,13 @@ break; case CFG_MERGE: if (argcounter == 2) - strcpy(MergeFilename, args[0]); - else - strcpy(MergeFilename, "NODELIST"); + { + strlcpy(MergeFilename, args[0], sizeof MergeFilename); + } + else + { + strlcpy(MergeFilename, "NODELIST", sizeof MergeFilename); + } break; case CFG_MINPHONE: if (args[0][0] >= '1' && args[0][0] <= '9' && args[0][1] == 0) @@ -746,13 +748,23 @@ mode = -1; } break; + case CFG_ALLOW8BIT: + if (args[0][0] >= '0' && args[0][0] < '2' && args[0][1] == 0) + Allow8Bit = args[0][0] - '0'; + else + { + mklog(LOG_ERROR, "ALLOW8BIT argument '%s' must be 0 or 1", + args[0]); + mode = -1; + } + break; case CFG_NETADDRESS: if (ParseAddress(args[0], MyAddress) != 0) goto BadAddress; break; case CFG_PROCESS: if ((process_day = - xlate_switch(strupr(args[0]), DOWSwitchTab)) == -1) + xlate_switch(strupper(args[0]), DOWSwitchTab)) == -1) { mklog(LOG_ERROR, "%s -- Invalid day of week '%s'", cfgline, args[0]); @@ -765,7 +777,7 @@ ShouldProcess &= ~USUAL_PROCESSING; break; case CFG_PUBLISH: - NewExtWDay = xlate_switch(strupr(args[0]), DOWSwitchTab); + NewExtWDay = xlate_switch(strupper(args[0]), DOWSwitchTab); if (NewExtWDay == -1) { mklog(LOG_ERROR, "%s -- Invalid day of week '%s'", @@ -777,7 +789,7 @@ filextension day */ break; case CFG_POINTS: - PointLevel = xlate_switch(strupr(args[0]), PointDisp); + PointLevel = xlate_switch(strupper(args[0]), PointDisp); if (PointLevel == -1) { mklog(LOG_ERROR, "%s -- Invalid argument '%s'", @@ -787,7 +799,7 @@ } break; case CFG_PRIVATE: - PrivateLevel = xlate_switch(strupr(args[0]), PrivateDisp); + PrivateLevel = xlate_switch(strupper(args[0]), PrivateDisp); if (PrivateLevel == -1) { mklog(LOG_ERROR, "%s -- Invalid argument '%s'", @@ -824,7 +836,7 @@ case CFG_OUTPATH: case CFG_UPDATE: case CFG_UPLOADS: - os_filecanonify(args[0]); + os_dirsep(args[0]); if (GetPath(args[0], switchno) == 0) { mklog(LOG_ERROR, "%s -- Invalid Path -- '%s'", cfgline, args[0]); @@ -845,9 +857,11 @@ case CFG_PROLOG: workptr = PrologFile; OutputFile: - os_filecanonify(args[0]); + os_dirsep(args[0]); if (filenodir(args[0])) - strcpy(workptr, args[0]); + { + strlcpy(workptr, args[0], MYMAXFILE + MYMAXEXT); + } else { mklog(LOG_ERROR, "%s -- Invalid file name -- '%s'", @@ -866,7 +880,7 @@ do { notifybits |= - xlate_switch(strupr(*flagptr), MailFlags); + xlate_switch(strupper(*flagptr), MailFlags); if (notifybits == -1) workptr = *flagptr; flagptr++; @@ -887,7 +901,7 @@ } else { - switch (xlate_switch(strupr(args[0]), NotifyType)) + switch (xlate_switch(strupper(args[0]), NotifyType)) { case -1: mklog(LOG_ERROR, "%s -- Bad SEND parameter -- '%s'", @@ -927,18 +941,18 @@ */ if (ArcCopySet == 0) { - sprintf(ArcCopyExt, "a"); - sprintf(ArcCopyCmd, "arc a"); + snprintf(ArcCopyExt, sizeof ArcCopyExt, "a"); + snprintf(ArcCopyCmd, sizeof ArcCopyCmd, "arc a"); } if (ArcMoveSet == 0) { - sprintf(ArcMoveExt, "a"); - sprintf(ArcMoveCmd, "arc m"); + snprintf(ArcMoveExt, sizeof ArcMoveExt, "a"); + snprintf(ArcMoveCmd, sizeof ArcMoveCmd, "arc m"); } if (ArcOpenSet == 0) { - sprintf(ArcOpenExt[0], "a"); - sprintf(ArcOpenCmd[0], "arc ew"); + snprintf(ArcOpenExt[0], sizeof ArcOpenExt[0], "a"); + snprintf(ArcOpenCmd[0], sizeof ArcOpenCmd[0], "arc ew"); ArcOpenSet = 1; } ArcOpenCnt = ArcOpenSet; diff -Nru makenl-3.3.3/src/config.h makenl-3.4.1/src/config.h --- makenl-3.3.3/src/config.h 2012-10-16 09:07:34.000000000 +0000 +++ makenl-3.4.1/src/config.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: config.h,v 1.3 2012/10/16 09:07:34 ozzmosis Exp $ */ +/* $Id: config.h,v 1.4 2013/05/26 01:23:46 ajleary Exp $ */ /* Numbers of configuration options */ #define CFG_ARCCOPY 0 @@ -55,6 +55,9 @@ /* Force submit unchanged file */ #define CFG_FORCESUBMIT 38 +/* Allow 8-bit characters */ +#define CFG_ALLOW8BIT 39 + /* Valid baudrates */ #define MAX_BAUDRATES 12 diff -Nru makenl-3.3.3/src/crc16.h makenl-3.4.1/src/crc16.h --- makenl-3.3.3/src/crc16.h 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/src/crc16.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: crc16.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ +/* $Id: crc16.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ unsigned short CRC16DoByte(unsigned char byte, unsigned short CRCnow); unsigned short CRC16String(const char *str, unsigned short crc); diff -Nru makenl-3.3.3/src/exec.c makenl-3.4.1/src/exec.c --- makenl-3.3.3/src/exec.c 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/src/exec.c 2013-10-11 17:07:33.000000000 +0000 @@ -13,7 +13,7 @@ BIXname: twagner */ -/* $Id: exec.c,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ +/* $Id: exec.c,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ #include #include diff -Nru makenl-3.3.3/src/exec.h makenl-3.4.1/src/exec.h --- makenl-3.3.3/src/exec.h 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/src/exec.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: exec.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ +/* $Id: exec.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ #ifndef _EXEC_H #define _EXEC_H diff -Nru makenl-3.3.3/src/fileutil.c makenl-3.4.1/src/fileutil.c --- makenl-3.3.3/src/fileutil.c 2012-11-13 22:38:44.000000000 +0000 +++ makenl-3.4.1/src/fileutil.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: fileutil.c,v 1.8 2012/11/13 22:38:44 ozzmosis Exp $ */ +/* $Id: fileutil.c,v 1.13 2013/09/26 19:52:03 ozzmosis Exp $ */ #include #include @@ -11,16 +11,9 @@ #include "config.h" #include "fileutil.h" #include "mklog.h" +#include "strtool.h" -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -char OldExtensions[4][MYMAXEXT]; +char OldExtensions[8][MYMAXEXT]; int do_clean; char MakeSourceFile[MYMAXFILE + MYMAXEXT]; @@ -125,7 +118,7 @@ } if (lenleft && (*(output - 1) != '\\' && *(output - 1) != '/')) { - *(output++) = CHAR_DIRSEPARATOR; + *(output++) = DIRSEP[0]; lenleft--; } } @@ -288,7 +281,7 @@ extptr = OldExtensions + 1; do { - strcpy(ext, *extptr); + strlcpy(ext, *extptr, sizeof ext); if (OutDiff[0] != 0) { myfnmerge(delname, NULL, OutDir, OutDiff, ext); @@ -308,7 +301,7 @@ cleanfile(delname); extptr++; } - while (extptr < OldExtensions + 4); + while (extptr < OldExtensions + 8); } void CopyOrMove(int copy, char *source, char *destdir, char *destname) diff -Nru makenl-3.3.3/src/fileutil.h makenl-3.4.1/src/fileutil.h --- makenl-3.3.3/src/fileutil.h 2012-11-13 22:38:44.000000000 +0000 +++ makenl-3.4.1/src/fileutil.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: fileutil.h,v 1.2 2012/11/13 22:38:44 ozzmosis Exp $ */ +/* $Id: fileutil.h,v 1.3 2013/08/23 15:47:33 ozzmosis Exp $ */ #include "os.h" @@ -35,7 +35,7 @@ char *ext); long os_filesize(const char *filename); extern int do_clean; -extern char OldExtensions[4][MYMAXEXT]; +extern char OldExtensions[8][MYMAXEXT]; void cleanit(void); void cleanold(char *path, char *filename, char *ext); diff -Nru makenl-3.3.3/src/fts5.c makenl-3.4.1/src/fts5.c --- makenl-3.3.3/src/fts5.c 2012-12-29 04:38:59.000000000 +0000 +++ makenl-3.4.1/src/fts5.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,365 +1,360 @@ -/* $Id: fts5.c,v 1.7 2012/12/29 04:38:59 ajleary Exp $ */ - -#include -#include -#include -#include "config.h" -#include "makenl.h" -#include "fts5.h" -#include "unused.h" -#include "mklog.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -extern int nl_baudrate[]; - -static struct switchstruct FTS5KWords[] = { - {"", 0, 5}, - {"GLOBAL", 6, LEVEL_TOP}, - {"ZONE", 4, LEVEL_ZONE}, - {"REGION", 6, LEVEL_REGION}, - {"HOST", 4, LEVEL_HOST}, - {"HUB", 3, LEVEL_HUB}, - {"PRIVATE", 7, LEVEL_PRIVATE}, - {"PVT", 3, LEVEL_PRIVATE}, - {"OGATE", 5, LEVEL_OGATE}, - {"DOWN", 4, LEVEL_DOWN}, - {"HOLD", 4, LEVEL_HOLD}, - {"POINT", 5, LEVEL_POINT}, - {"KENNEL", 6, LEVEL_DOWN}, - {"KENL", 4, LEVEL_DOWN}, - {NULL, 0, -1} -}; - -const int Level4DPos[] = { -/* LEVEL_TOP --> */ A_ZONE, -/* LEVEL_ZONE --> */ A_ZONE, -/* LEVEL_REGION--> */ A_NET, -/* LEVEL_HOST --> */ A_NET, -/* LEVEL_HUB --> */ A_NODE, -/* LEVEL_NODE --> */ A_NODE, -/* LEVEL_OGATE --> */ A_NODE, -/* LEVEL_PRIVATE-> */ A_NODE, -/* LEVEL_DOWN --> */ A_NODE, -/* LEVEL_HOLD --> */ A_NODE, -/* LEVEL_POINT --> */ A_POINT, -/* LEVEL_COMMENT-> */ 127, -/* LEVEL_COMMENT-> */ 127 -}; -const char *const LevelsSimple[] = - { "", "Zone", "Region", "Network", "Hub", "Node" }; -char namebuf[16]; - -/* Original */ - -/* char *Levels[] = - { namebuf, "Zone", "Region", "Host", "Hub", "", "Ogate", "Pvt", "Down", - "Hold", "Point" -}; -*/ - -char *Levels[] = - { namebuf, "Zone", "Region", "Host", "Hub", "", "Hold", "Down", "Ogate", - "Pvt", "Point" -}; - -int Minphone = 1; -int Alphaphone = 0; -int Allowunpub = 0; -int PrivateLevel; -int PointLevel = -2; /* don't allow points */ -char *FTS5Line[8]; - -static void Space2Under(char *string) -{ - for (; *string; string++) - if (*string == ' ') - *string = '_'; -} - -static int getkeyword(char **instring, int *linelevel, int *linenum) -{ - unused(linenum); - - if ((*linelevel = xlate_switch(strupr(*instring), FTS5KWords)) == -1) - { - sprintf(ErrorMessage, "Invalid keyword -- '%s'", *instring); - return 1; - } - - return 0; -} - -int getnodenum(char **instring, int *linelevel, int *linenum) -{ - int addrlen; - const char *type; - - addrlen = strlen(*instring); - if (addrlen != 0) - if (getnumber(*instring, linenum) == addrlen) - if (*linenum != 0) - { - while (**instring == '0') - ++(*instring); - return 0; - } - - if (*linelevel == LEVEL_POINT) - { - type = "Point"; - } - else if (*linelevel > LEVEL_HUB) - { - type = "Node"; - } - else - { - if (*linelevel == -1) - { - type = "Node"; - } - else - { - type = LevelsSimple[*linelevel]; - } - } - sprintf(ErrorMessage, "Invalid %s number -- '%s'", type, *instring); - return 1; -} - -static int getstring(char **instring, int *linelevel, int *linenum) -{ - char *workptr; - - unused(linelevel); - unused(linenum); - - workptr = *instring; - if (strlen(workptr) != 0) - { - Space2Under(workptr--); - while (*(++workptr) != 0) - { - if (*workptr & 0x80) - *workptr = '?'; - } - } - else - { - mklog(LOG_INFO, "*WARNING Empty field has been replaced with -Unknown-"); - *instring = "-Unknown-"; - } - return 0; -} - -static int getphone(char **instring, int *linelevel, int *linenum) -{ - int parts; - int digit_seen; - char *phoneno; - char *phonewalk; - char phonechar; - int brackets; - - unused(linenum); - - /* Mini spellchecker */ - if ((strcasecmp(*instring, "-Unpublished-") == 0) && strcmp(*instring, "-Unpublished-")) - { - mklog(LOG_INFO, "*WARNING '%s' has been replaced with '-Unpublished-'", *instring); - *instring = "-Unpublished-"; - } - - switch (*linelevel) - { - case LEVEL_PRIVATE: - *instring = "-Unpublished-"; - break; - case LEVEL_HOLD: - /* - * Hold should allow -Unpublished- per FTS5000.002 - */ - if (Allowunpub == 0 && (strcmp(*instring, "-Unpublished-") == 0)) - return 0; - break; - case LEVEL_DOWN: - /* - * Allow -Unpublished- when the node is Down. - * All other things are allowed and not checked. - */ - if (Allowunpub == 0 && (strcmp(*instring, "-Unpublished-") == 0)) - return 0; - /* Hold and down nodes don't need a valid number */ - break; - case LEVEL_POINT: - /* Points may have unpublished phones */ - if (!strcmp(*instring, "-Unpublished-")) - return 0; - /* Fall thru */ - default: - if (Allowunpub == 1 && (strcmp(*instring, "-Unpublished-") == 0)) - return 0; - if (Alphaphone == 1) - { - if (Allowunpub == 0 && (strcmp(*instring, "-Unpublished-") == 0)) - return 1; - - /* Check if this is alpha, if not do a normal phone check. */ - phoneno = *instring; - phonewalk = phoneno; - do - { - phonechar = *phonewalk; - phonewalk++; - if (isalpha((unsigned char)phonechar)) - return 0; - } - while (phonechar); - } - phoneno = *instring; - phonewalk = phoneno; - brackets = 0; - digit_seen = 0; - parts = 0; - do - { - phonechar = *phonewalk; - phonewalk++; - if (isdigit((unsigned char)phonechar)) - digit_seen = 1; - else if (digit_seen != 0) - { - switch (phonechar) - { - BadPhone: - default: - sprintf(ErrorMessage, "Invalid phone number -- '%s'", - phoneno); - return 1; - case '[': - if (parts + 1 < Minphone) - goto FewParts; - parts = -1; - case ']': - brackets++; - case 0: - case '-': - digit_seen = 0; - parts++; - } - } - else if (!(phonechar == '\0' && brackets == 2)) /* Allow \0 - directly - after ] */ - goto BadPhone; - } - while (phonechar); - if (parts < Minphone) - { - FewParts: - sprintf(ErrorMessage, - "Phone number '%s' has fewer than %d parts", phoneno, - Minphone); - return 1; - } - break; - } - - return 0; -} - -static int getbaud(char **instring, int *linelevel, int *linenum) -{ - int e_len, i, good; - char *baud_no; - - unused(linelevel); - unused(linenum); - - e_len = 0; - good = 0; - baud_no = *instring; - - while ((unsigned char)baud_no[e_len] != 0) - { - if (!isdigit((unsigned char)baud_no[e_len])) - { - sprintf(ErrorMessage, "Invalid baud rate -- '%s'", - *instring); - return 1; - } - e_len++; - } - - if (e_len == 0) - { - sprintf(ErrorMessage, "Invalid baud rate -- '%s'", *instring); - return 1; - } - - /* Check with table */ - for (i = 0; i < MAX_BAUDRATES; i++) - { - if (nl_baudrate[i] == 0) - break; - if (nl_baudrate[i] == atoi(*instring)) - { - good = 1; - break; - } - } - - if (good == 0) - { - sprintf(ErrorMessage, "Invalid baud rate -- '%s'", *instring); - return 1; - } - - return 0; -} - -typedef int (*handlefunc) (char **instring, int *linelevel, int *linenum); -static handlefunc HandleFields[] = - { getkeyword, getnodenum, getstring, getstring, getstring, getphone, - getbaud -}; - -int ParseFTS5(char *line, int *a, int *b) -{ - int fieldno; - int hiterror; - char **ElementPPtr = &FTS5Keyword; - handlefunc *y = HandleFields; - - if (strlen(cutspaces(line)) == 0) - { - *a = LEVEL_EMPTY; - return 0; - } - if (line[0] == ';') - { - *a = LEVEL_COMMENT; - return 0; - } - hiterror = 0; - for (fieldno = 0; *ElementPPtr = skipspaces(line), fieldno < 7; - fieldno++, ElementPPtr++) - { - line += strcspn(line, ",\r\n"); - if (*line != 0) - *(line++) = 0; - cutspaces(*ElementPPtr); - if (!hiterror) - hiterror = (*(y++)) (ElementPPtr, a, b); - } - if (!hiterror) - FTS5Keyword = Levels[*a]; - return hiterror; -} +/* $Id: fts5.c,v 1.11 2013/09/25 19:29:56 ozzmosis Exp $ */ + +#include +#include +#include +#include "config.h" +#include "makenl.h" +#include "fts5.h" +#include "unused.h" +#include "mklog.h" +#include "strtool.h" +#include "snprintf.h" + +extern int nl_baudrate[]; + +static struct switchstruct FTS5KWords[] = { + {"", 0, 5}, + {"GLOBAL", 6, LEVEL_TOP}, + {"ZONE", 4, LEVEL_ZONE}, + {"REGION", 6, LEVEL_REGION}, + {"HOST", 4, LEVEL_HOST}, + {"HUB", 3, LEVEL_HUB}, + {"PRIVATE", 7, LEVEL_PRIVATE}, + {"PVT", 3, LEVEL_PRIVATE}, + {"OGATE", 5, LEVEL_OGATE}, + {"DOWN", 4, LEVEL_DOWN}, + {"HOLD", 4, LEVEL_HOLD}, + {"POINT", 5, LEVEL_POINT}, + {"KENNEL", 6, LEVEL_DOWN}, + {"KENL", 4, LEVEL_DOWN}, + {NULL, 0, -1} +}; + +const int Level4DPos[] = { +/* LEVEL_TOP --> */ A_ZONE, +/* LEVEL_ZONE --> */ A_ZONE, +/* LEVEL_REGION--> */ A_NET, +/* LEVEL_HOST --> */ A_NET, +/* LEVEL_HUB --> */ A_NODE, +/* LEVEL_NODE --> */ A_NODE, +/* LEVEL_OGATE --> */ A_NODE, +/* LEVEL_PRIVATE-> */ A_NODE, +/* LEVEL_DOWN --> */ A_NODE, +/* LEVEL_HOLD --> */ A_NODE, +/* LEVEL_POINT --> */ A_POINT, +/* LEVEL_COMMENT-> */ 127, +/* LEVEL_COMMENT-> */ 127 +}; +const char *const LevelsSimple[] = + { "", "Zone", "Region", "Network", "Hub", "Node" }; +char namebuf[16]; + +/* Original */ + +/* char *Levels[] = + { namebuf, "Zone", "Region", "Host", "Hub", "", "Ogate", "Pvt", "Down", + "Hold", "Point" +}; +*/ + +char *Levels[] = + { namebuf, "Zone", "Region", "Host", "Hub", "", "Hold", "Down", "Ogate", + "Pvt", "Point" +}; + +int Minphone = 1; +int Alphaphone = 0; +int Allowunpub = 0; +int Allow8Bit = 0; +int PrivateLevel; +int PointLevel = -2; /* don't allow points */ +char *FTS5Line[8]; + +static void Space2Under(char *string) +{ + for (; *string; string++) + if (*string == ' ') + *string = '_'; +} + +static int getkeyword(char **instring, int *linelevel, int *linenum) +{ + unused(linenum); + + if ((*linelevel = xlate_switch(strupper(*instring), FTS5KWords)) == -1) + { + snprintf(ErrorMessage, sizeof ErrorMessage, "Invalid keyword -- '%s'", *instring); + return 1; + } + + return 0; +} + +int getnodenum(char **instring, int *linelevel, int *linenum) +{ + int addrlen; + const char *type; + + addrlen = strlen(*instring); + if (addrlen != 0) + if (getnumber(*instring, linenum) == addrlen) + if (*linenum != 0) + { + while (**instring == '0') + ++(*instring); + return 0; + } + + if (*linelevel == LEVEL_POINT) + { + type = "Point"; + } + else if (*linelevel > LEVEL_HUB) + { + type = "Node"; + } + else + { + if (*linelevel == -1) + { + type = "Node"; + } + else + { + type = LevelsSimple[*linelevel]; + } + } + snprintf(ErrorMessage, sizeof ErrorMessage, "Invalid %s number -- '%s'", type, *instring); + return 1; +} + +static int getstring(char **instring, int *linelevel, int *linenum) +{ + char *workptr; + + unused(linelevel); + unused(linenum); + + workptr = *instring; + if (strlen(workptr) != 0) + { + Space2Under(workptr--); + while (*(++workptr) != 0) + { + if (*workptr & 0x80 && !Allow8Bit) + *workptr = '?'; + } + } + else + { + mklog(LOG_INFO, "*WARNING Empty field has been replaced with -Unknown-"); + *instring = "-Unknown-"; + } + return 0; +} + +static int getphone(char **instring, int *linelevel, int *linenum) +{ + int parts; + int digit_seen; + char *phoneno; + char *phonewalk; + char phonechar; + int brackets; + + unused(linenum); + + /* Mini spellchecker */ + if ((strcasecmp(*instring, "-Unpublished-") == 0) && strcmp(*instring, "-Unpublished-")) + { + mklog(LOG_INFO, "*WARNING '%s' has been replaced with '-Unpublished-'", *instring); + *instring = "-Unpublished-"; + } + + switch (*linelevel) + { + case LEVEL_PRIVATE: + *instring = "-Unpublished-"; + break; + case LEVEL_HOLD: + /* + * Hold should allow -Unpublished- per FTS5000.002 + */ + if (Allowunpub == 0 && (strcmp(*instring, "-Unpublished-") == 0)) + return 0; + break; + case LEVEL_DOWN: + /* + * Allow -Unpublished- when the node is Down. + * All other things are allowed and not checked. + */ + if (Allowunpub == 0 && (strcmp(*instring, "-Unpublished-") == 0)) + return 0; + /* Hold and down nodes don't need a valid number */ + break; + case LEVEL_POINT: + /* Points may have unpublished phones */ + if (!strcmp(*instring, "-Unpublished-")) + return 0; + /* Fall thru */ + default: + if (Allowunpub == 1 && (strcmp(*instring, "-Unpublished-") == 0)) + return 0; + if (Alphaphone == 1) + { + if (Allowunpub == 0 && (strcmp(*instring, "-Unpublished-") == 0)) + return 1; + + /* Check if this is alpha, if not do a normal phone check. */ + phoneno = *instring; + phonewalk = phoneno; + do + { + phonechar = *phonewalk; + phonewalk++; + if (isalpha((unsigned char)phonechar)) + return 0; + } + while (phonechar); + } + phoneno = *instring; + phonewalk = phoneno; + brackets = 0; + digit_seen = 0; + parts = 0; + do + { + phonechar = *phonewalk; + phonewalk++; + if (isdigit((unsigned char)phonechar)) + digit_seen = 1; + else if (digit_seen != 0) + { + switch (phonechar) + { + BadPhone: + default: + snprintf(ErrorMessage, sizeof ErrorMessage, "Invalid phone number -- '%s'", + phoneno); + return 1; + case '[': + if (parts + 1 < Minphone) + goto FewParts; + parts = -1; + case ']': + brackets++; + case 0: + case '-': + digit_seen = 0; + parts++; + } + } + else if (!(phonechar == '\0' && brackets == 2)) /* Allow \0 + directly + after ] */ + goto BadPhone; + } + while (phonechar); + if (parts < Minphone) + { + FewParts: + snprintf(ErrorMessage, sizeof ErrorMessage, + "Phone number '%s' has fewer than %d parts", phoneno, + Minphone); + return 1; + } + break; + } + + return 0; +} + +static int getbaud(char **instring, int *linelevel, int *linenum) +{ + int e_len, i, good; + char *baud_no; + + unused(linelevel); + unused(linenum); + + e_len = 0; + good = 0; + baud_no = *instring; + + while ((unsigned char)baud_no[e_len] != 0) + { + if (!isdigit((unsigned char)baud_no[e_len])) + { + snprintf(ErrorMessage, sizeof ErrorMessage, "Invalid baud rate -- '%s'", + *instring); + return 1; + } + e_len++; + } + + if (e_len == 0) + { + snprintf(ErrorMessage, sizeof ErrorMessage, "Invalid baud rate -- '%s'", *instring); + return 1; + } + + /* Check with table */ + for (i = 0; i < MAX_BAUDRATES; i++) + { + if (nl_baudrate[i] == 0) + break; + if (nl_baudrate[i] == atoi(*instring)) + { + good = 1; + break; + } + } + + if (good == 0) + { + snprintf(ErrorMessage, sizeof ErrorMessage, "Invalid baud rate -- '%s'", *instring); + return 1; + } + + return 0; +} + +typedef int (*handlefunc) (char **instring, int *linelevel, int *linenum); +static handlefunc HandleFields[] = + { getkeyword, getnodenum, getstring, getstring, getstring, getphone, + getbaud +}; + +int ParseFTS5(char *line, int *a, int *b) +{ + int fieldno; + int hiterror; + char **ElementPPtr = &FTS5Keyword; + handlefunc *y = HandleFields; + + if (strlen(cutspaces(line)) == 0) + { + *a = LEVEL_EMPTY; + return 0; + } + if (line[0] == ';') + { + *a = LEVEL_COMMENT; + return 0; + } + hiterror = 0; + for (fieldno = 0; *ElementPPtr = skipspaces(line), fieldno < 7; + fieldno++, ElementPPtr++) + { + line += strcspn(line, ",\r\n"); + if (*line != 0) + *(line++) = 0; + cutspaces(*ElementPPtr); + if (!hiterror) + hiterror = (*(y++)) (ElementPPtr, a, b); + } + if (!hiterror) + FTS5Keyword = Levels[*a]; + return hiterror; +} diff -Nru makenl-3.3.3/src/fts5.h makenl-3.4.1/src/fts5.h --- makenl-3.3.3/src/fts5.h 2012-10-16 09:07:34.000000000 +0000 +++ makenl-3.4.1/src/fts5.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: fts5.h,v 1.2 2012/10/16 09:07:34 ozzmosis Exp $ */ +/* $Id: fts5.h,v 1.3 2013/05/26 01:23:46 ajleary Exp $ */ /* Indices for 3D-Addresses */ #define A_ZONE 0 @@ -36,6 +36,9 @@ /* Allow -Unpublished w/o Pvt */ extern int Allowunpub; +/* Allow 8-bit characters */ +extern int Allow8Bit; + extern char namebuf[16]; extern const char *const LevelsSimple[]; extern char *Levels[]; diff -Nru makenl-3.3.3/src/ignore.h makenl-3.4.1/src/ignore.h --- makenl-3.3.3/src/ignore.h 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/src/ignore.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -/* $Id: ignore.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ - -/* This file is used as substitute */ diff -Nru makenl-3.3.3/src/lsttool.c makenl-3.4.1/src/lsttool.c --- makenl-3.3.3/src/lsttool.c 2012-11-13 22:38:44.000000000 +0000 +++ makenl-3.4.1/src/lsttool.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,9 +1,10 @@ -/* $Id: lsttool.c,v 1.12 2012/11/13 22:38:44 ozzmosis Exp $ */ +/* $Id: lsttool.c,v 1.25 2013/09/26 19:52:03 ozzmosis Exp $ */ #include #include #include #include +#include #include "makenl.h" #include "fileutil.h" @@ -11,15 +12,10 @@ #include "lsttool.h" #include "msg.h" #include "mklog.h" -#include "proc.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif +#include "procfile.h" +#include "strtool.h" +#include "snprintf.h" +#include "os.h" long ARCThreshold = 10000; long DIFFThreshold = 16666; @@ -53,27 +49,27 @@ return 0; } - strcpy(fullpath, filename); + strlcpy(fullpath, filename, sizeof fullpath); myfnsplit(filename, NULL, NULL, name, ext); if (toupper((int) ext[0]) == 'D') /* Autogenerated diff - can always be moved */ { ext[1] = 'd'; - strcpy(arccommand, ArcMoveCmd); /* move instead of add */ + strlcpy(arccommand, ArcMoveCmd, sizeof arccommand); /* move instead of add */ ext[0] = ArcMoveExt[0]; } else { - strcpy(arccommand, (move < 1) ? ArcCopyCmd : ArcMoveCmd); + strlcpy(arccommand, (move < 1) ? ArcCopyCmd : ArcMoveCmd, sizeof arccommand); ext[0] = (move < 1) ? ArcCopyExt[0] : ArcMoveExt[0]; } myfnmerge(fullpath, NULL, OutDir, name, ext); - os_filecanonify(fullpath); - os_filecanonify(filename); + os_dirsep(fullpath); + os_dirsep(filename); mklog(LOG_INFO, "Creating archive '%s' containing '%s'", fullpath, filename); - sprintf(cmdlinebuf, "%s %s", fullpath, filename); + snprintf(cmdlinebuf, sizeof cmdlinebuf, "%s %s", fullpath, filename); if (os_spawn(arccommand, cmdlinebuf) != 0) die(253, "Unable to create archive '%s'", fullpath); - strcpy(filename, fullpath); + strlcpy(filename, fullpath, MYMAXPATH); return 1; } @@ -95,7 +91,7 @@ char tmpline[linelength]; char oldline[linelength]; - for (extptr = OldExtensions; extptr < OldExtensions + 3; extptr++) + for (extptr = OldExtensions; extptr < OldExtensions + 7; extptr++) { outext = getext(extbfr, OutFile) ? NULL : *extptr; myfnmerge(filename, NULL, OutDir, OutFile, outext); @@ -145,10 +141,10 @@ { swapext(tmpname, filename, OldExtensions[0]); rename(filename, tmpname); - strcpy(filename, tmpname); + strlcpy(filename, tmpname, MYMAXPATH); } for (extptr = OldExtensions + weeksold + 1; - extptr < OldExtensions + 3; extptr++) + extptr < OldExtensions + 7; extptr++) { swapext(tmpname, filename, *extptr); unlink(tmpname); @@ -238,7 +234,7 @@ { /* DiffLine now contains the new header including CRC */ cutspaces(DiffLine); - strcat(DiffLine, "\r\n"); + strlcat(DiffLine, "\r\n", sizeof DiffLine); crcptr = DiffLine + strlen(DiffLine); while (*(--crcptr) != ' ') @@ -253,7 +249,7 @@ while (dodiffline(0, oldFILE, diffFILE) == 0) { cutspaces(DiffLine); - strcat(DiffLine, "\r\n"); + strlcat(DiffLine, "\r\n", sizeof DiffLine); fputs(DiffLine, outFILE); DiffCRC = CRC16String(DiffLine, DiffCRC); } @@ -345,7 +341,7 @@ mklog(LOG_DEBUG, "searchlistfile(): found '%s'", findresult); getext(extbuf, findresult); myfnmerge(foundfile, NULL, path, findresult, NULL); - os_deslashify(foundfile); + os_dirsep(foundfile); if ((unarc = unpacker(foundfile)) != NULL) /* Compressed file */ { /* Search decompressor */ @@ -354,7 +350,7 @@ { if (toupper((unsigned char)unarc[0]) == toupper((unsigned char)ArcOpenExt[i][0])) { - strcpy(ArcOpen, ArcOpenCmd[i]); + strlcpy(ArcOpen, ArcOpenCmd[i], sizeof ArcOpen); break; } } @@ -367,25 +363,25 @@ mklog(LOG_INFO, "Attempting to unpack archive '%s'", foundfile); } myfnmerge(fnamebuf, NULL, path, NULL, NULL); - os_deslashify(fnamebuf); + os_dirsep(fnamebuf); /* * We need to chdir to the directory where the archive is found * so that the file is hopefully unpacked in the that directory. */ - if (chdir(fnamebuf)) + if (os_chdir(fnamebuf) != 0) { - mklog(LOG_ERROR, "Can't chdir to '%s'", fnamebuf); + mklog(LOG_ERROR, "Can't chdir to '%s': %s", fnamebuf, strerror(errno)); } else { /* Some archivers don't work well when the filename is given */ - /* sprintf(cmdlinebuf, "%s %s.%s", foundfile, name, ext); */ - sprintf(cmdlinebuf, "%s", foundfile); + /* snprintf(cmdlinebuf, sizeof cmdlinebuf, "%s %s.%s", foundfile, name, ext); */ + snprintf(cmdlinebuf, sizeof cmdlinebuf, "%s", foundfile); if ((ArcOpen[0] == '\0') || (os_spawn(ArcOpen, cmdlinebuf) != 0)) { mklog(LOG_ERROR, "Unable to unpack archive '%s'", foundfile); WorkFile = os_file_getname(foundfile); - os_filecanonify(WorkFile); + os_dirsep(WorkFile); *file = OpenMSGFile(NotifyAddress, NULL); if (*file != NULL) { @@ -394,9 +390,16 @@ CloseMSGFile(1); } } - chdir(CurDir); + if (os_chdir(CurDir) != 0) + { + mklog(LOG_ERROR, "Can't chdir to '%s': %s", CurDir, strerror(errno)); + } + } + + if (unlink(foundfile) != 0) + { + mklog(LOG_ERROR, "Can't unlink '%s': %s", foundfile, strerror(errno)); } - unlink(foundfile); } else if (ext[0] == 0 && toupper((unsigned char)extbuf[0]) == 'D') /* DIFFed file @@ -423,14 +426,14 @@ } extptr++; } - while (extptr < OldExtensions + 3); + while (extptr < OldExtensions + 7); out_of_loops: unlink(foundfile); if (searchwhere == 0) { mklog(LOG_INFO, "Unable to apply difference file '%s'", foundfile); WorkFile = os_file_getname(foundfile); - os_filecanonify(WorkFile); + os_dirsep(WorkFile); *file = OpenMSGFile(NotifyAddress, NULL); if (*file) { @@ -445,20 +448,20 @@ goto justthisfile; } } - for (extptr = OldExtensions; extptr < OldExtensions + 3; extptr++) + for (extptr = OldExtensions; extptr < OldExtensions + 7; extptr++) { myfnmerge(foundfile, NULL, NULL, name, *extptr); if (os_findfile(&f, path, foundfile) != NULL) { myfnmerge(foundfile, NULL, path, name, *extptr); - os_deslashify(foundfile); + os_dirsep(foundfile); justthisfile: mklog(LOG_DEBUG, "searchlistfile: justthisfile, foundfile='%s'", foundfile); *file = fopen(foundfile, "rb"); if (!*file) return -1; WorkFile = os_file_getname(foundfile); - os_filecanonify(WorkFile); + os_dirsep(WorkFile); return 1; } } diff -Nru makenl-3.3.3/src/lsttool.h makenl-3.4.1/src/lsttool.h --- makenl-3.3.3/src/lsttool.h 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/src/lsttool.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: lsttool.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ +/* $Id: lsttool.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ #define SEARCH_UPLOAD 0 #define SEARCH_MAILFILE 1 diff -Nru makenl-3.3.3/src/makefile.bcd makenl-3.4.1/src/makefile.bcd --- makenl-3.3.3/src/makefile.bcd 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/makefile.bcd 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,34 @@ +# MakeNL makefile for Borland C++ 3.1 for DOS +# +# $Id: makefile.bcd,v 1.6 2013/09/25 18:24:10 ozzmosis Exp $ +# +# Build with: +# +# make -fmakefile.bcd (release) +# make -fmakefile.bcd clean (remove temp files) + +CC=bcc +CFLAGS=-w -ml + +!ifdef DEBUG +CFLAGS=$(CFLAGS) -v +!endif + +!ifdef TESTING +CFLAGS=$(CFLAGS) -DTESTING +OBJS=testing.obj +!endif + +OBJS=$(OBJS) config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj +OBJS=$(OBJS) merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj +OBJS=$(OBJS) procfile.obj stack.obj strtool.obj upcont.obj snprintf.obj + +.c.obj: + $(CC) $(CFLAGS) -c $< + +makenl.exe: $(OBJS) + $(CC) $(CFLAGS) -emakenl.exe *.obj + +clean: + del *.obj + del makenl.exe diff -Nru makenl-3.3.3/src/makefile.bco makenl-3.4.1/src/makefile.bco --- makenl-3.3.3/src/makefile.bco 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/makefile.bco 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,36 @@ +# MakeNL makefile for Borland C++ for OS/2 +# Tested with Borland C++ 2.0 for OS/2 +# +# $Id: makefile.bco,v 1.7 2013/09/25 18:24:10 ozzmosis Exp $ +# +# Build with: +# +# make -f makefile.bco (release) +# make -f makefile.bco DEBUG=1 (debug) +# make -f makefile.bco clean (remove temp files) + +CFLAGS=-w +RM=del + +!ifdef DEBUG +CFLAGS=$(CFLAGS) -v +!endif + +!ifdef TESTING +CFLAGS=$(CFLAGS) -DTESTING +OBJS=testing.obj +!endif + +OBJS=$(OBJS) config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj +OBJS=$(OBJS) merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj +OBJS=$(OBJS) procfile.obj stack.obj strtool.obj upcont.obj snprintf.obj + +.c.obj: + $(CC) $(CFLAGS) -e$@ -c $< + +makenl.exe: $(OBJS) + $(CC) $(CFLAGS) -e$@ $(OBJS) + +clean: + $(RM) *.obj + $(RM) makenl.exe diff -Nru makenl-3.3.3/src/makefile.bcw makenl-3.4.1/src/makefile.bcw --- makenl-3.3.3/src/makefile.bcw 2012-10-17 11:36:54.000000000 +0000 +++ makenl-3.4.1/src/makefile.bcw 2013-10-11 17:07:33.000000000 +0000 @@ -1,20 +1,29 @@ # MakeNL makefile for Borland C++ Builder for Windows # Tested with bcc32 5.6 for Win32 (Borland C++ Builder 6) # -# $Id: makefile.bcw,v 1.3 2012/10/17 11:36:54 ozzmosis Exp $ +# $Id: makefile.bcw,v 1.5 2013/09/23 09:18:59 ozzmosis Exp $ # # Build with: # -# make -f makefile.bcw (release) -# make -f makefile.bcw clean (remove temp files) +# make -f makefile.bcw (release) +# make -f makefile.bcw DEBUG=1 (debug) +# make -f makefile.bcw clean (remove temp files) CC=bcc32 - CFLAGS=-w -OBJS=config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj +!ifdef DEBUG +CFLAGS=$(CFLAGS) -v +!endif + +!ifdef TESTING +CFLAGS=$(CFLAGS) -DTESTING +OBJS=testing.obj +!endif + +OBJS=$(OBJS) config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj OBJS=$(OBJS) merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj -OBJS=$(OBJS) process.obj stack.obj strtool.obj upcont.obj +OBJS=$(OBJS) procfile.obj stack.obj strtool.obj upcont.obj .c.obj: $(CC) $(CFLAGS) -c $< diff -Nru makenl-3.3.3/src/makefile.bsd makenl-3.4.1/src/makefile.bsd --- makenl-3.3.3/src/makefile.bsd 2012-10-27 23:26:12.000000000 +0000 +++ makenl-3.4.1/src/makefile.bsd 2013-10-11 17:07:33.000000000 +0000 @@ -1,6 +1,6 @@ # MakeNL makefile for FreeBSD, NetBSD, OpenBSD, Apple Darwin & Minix. # -# $Id: makefile.bsd,v 1.3 2012/10/27 23:26:12 ozzmosis Exp $ +# $Id: makefile.bsd,v 1.10 2013/09/21 15:40:07 ozzmosis Exp $ # # Tested with: # @@ -19,6 +19,13 @@ .ifdef DEBUG CFLAGS+= -g +.else +LDFLAGS+= -s +.endif + +.ifdef TESTING +CFLAGS+= -DTESTING +OBJS+=testing.o .endif .ifdef EFENCE @@ -35,7 +42,7 @@ .endif OBJS+=config.o crc16.o fileutil.o fts5.o lsttool.o makenl.o merge.o -OBJS+=mkdiff.o mklog.o msgtool.o output.o process.o stack.o strtool.o +OBJS+=mkdiff.o mklog.o msgtool.o output.o procfile.o stack.o strtool.o OBJS+=upcont.o os.o .ifdef RMALLOC @@ -46,7 +53,7 @@ $(CC) $(CFLAGS) -c $< makenl: $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) clean: rm -f $(OBJS) makenl diff -Nru makenl-3.3.3/src/makefile.devc makenl-3.4.1/src/makefile.devc --- makenl-3.3.3/src/makefile.devc 2012-11-12 18:35:31.000000000 +0000 +++ makenl-3.4.1/src/makefile.devc 2013-10-11 17:07:33.000000000 +0000 @@ -1,30 +1,37 @@ -# MakeNL makefile for Dev-C++ 5.0 -# Tested with GNU Make 3.79.1 & GNU C 3.2 +# MakeNL makefile for Orwell Dev-C++ 5.4 +# Tested with GNU Make 3.82.90 & GNU C 4.7.2 # -# $Id: makefile.devc,v 1.2 2012/11/12 18:35:31 ozzmosis Exp $ +# $Id: makefile.devc,v 1.7 2013/09/21 16:38:49 ozzmosis Exp $ # # Build with: # -# make -f makefile.devc (release) or -# make -f makefile.devc DEBUG=1 (debug) -# make -f makefile.devc clean (remove temp files) +# mingw32-make -f makefile.devc (release) or +# mingw32-make -f makefile.devc DEBUG=1 (debug) +# mingw32-make -f makefile.devc clean (remove temp files) CC=gcc CFLAGS+= -W -Wall ifdef DEBUG CFLAGS+= -g +else +LFLAGS+= -s +endif + +ifdef TESTING +CFLAGS+= -DTESTING +OBJS+=testing.o endif OBJS+=config.o crc16.o fileutil.o fts5.o lsttool.o makenl.o merge.o -OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o process.o stack.o +OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o procfile.o stack.o OBJS+=strtool.o upcont.o .c.o: $(CC) $(CFLAGS) -c $< makenl.exe: $(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) clean: del $(OBJS) diff -Nru makenl-3.3.3/src/makefile.djgpp makenl-3.4.1/src/makefile.djgpp --- makenl-3.3.3/src/makefile.djgpp 2012-11-12 18:35:31.000000000 +0000 +++ makenl-3.4.1/src/makefile.djgpp 2013-10-11 17:07:33.000000000 +0000 @@ -1,7 +1,7 @@ # MakeNL makefile for DJGPP 2.03 # Tested with GNU Make 3.79 & GCC 2.95 # -# $Id: makefile.djgpp,v 1.2 2012/11/12 18:35:31 ozzmosis Exp $ +# $Id: makefile.djgpp,v 1.7 2013/09/25 18:24:10 ozzmosis Exp $ # # Build with: # @@ -15,18 +15,23 @@ ifdef DEBUG CFLAGS+= -g else -CFLAGS+= -s +LFLAGS+= -s +endif + +ifdef TESTING +CFLAGS+= -DTESTING +OBJS+=testing.o endif OBJS+=config.o crc16.o fileutil.o fts5.o lsttool.o makenl.o merge.o -OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o process.o stack.o -OBJS+=strtool.o upcont.o +OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o procfile.o stack.o +OBJS+=strtool.o upcont.o snprintf.o .c.o: $(CC) $(CFLAGS) -c $< makenl.exe: $(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) clean: del *.o diff -Nru makenl-3.3.3/src/makefile.dmc makenl-3.4.1/src/makefile.dmc --- makenl-3.3.3/src/makefile.dmc 2012-11-13 22:38:44.000000000 +0000 +++ makenl-3.4.1/src/makefile.dmc 2013-10-11 17:07:33.000000000 +0000 @@ -1,7 +1,7 @@ # MakeNL makefile for Digital Mars C for Windows # Tested with Digital Mars C 8.42n # -# $Id: makefile.dmc,v 1.1 2012/11/13 22:38:44 ozzmosis Exp $ +# $Id: makefile.dmc,v 1.3 2013/09/25 20:23:57 ozzmosis Exp $ # # Build with: # @@ -13,7 +13,7 @@ OBJS=config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj OBJS=$(OBJS) merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj -OBJS=$(OBJS) process.obj stack.obj strtool.obj upcont.obj +OBJS=$(OBJS) procfile.obj stack.obj strtool.obj upcont.obj snprintf.obj .c.obj: $(CC) $(CFLAGS) -c $< diff -Nru makenl-3.3.3/src/makefile.emx makenl-3.4.1/src/makefile.emx --- makenl-3.3.3/src/makefile.emx 2012-11-13 20:01:51.000000000 +0000 +++ makenl-3.4.1/src/makefile.emx 2013-10-11 17:07:33.000000000 +0000 @@ -1,7 +1,7 @@ # MakeNL makefile for EMX 0.9d # Tested with GNU Make 3.79.1 & GNU C 2.8.1 # -# $Id: makefile.emx,v 1.3 2012/11/13 20:01:51 ozzmosis Exp $ +# $Id: makefile.emx,v 1.7 2013/09/21 15:02:06 ozzmosis Exp $ # # Build with: # @@ -14,17 +14,24 @@ ifdef DEBUG CFLAGS+= -g +else +LFLAGS+= -s +endif + +ifdef TESTING +CFLAGS+= -DTESTING +OBJS+=testing.o endif OBJS+=config.o crc16.o fileutil.o fts5.o lsttool.o makenl.o merge.o -OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o process.o stack.o +OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o procfile.o stack.o OBJS+=strtool.o upcont.o .c.o: $(CC) $(CFLAGS) -c $< makenl.exe: $(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) clean: del *.o diff -Nru makenl-3.3.3/src/makefile.emxomf makenl-3.4.1/src/makefile.emxomf --- makenl-3.3.3/src/makefile.emxomf 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/makefile.emxomf 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,39 @@ +# MakeNL makefile for EMX 0.9d +# for building a standalone binary not requiring EMX.DLL +# Tested with GNU Make 3.79.1 & GNU C 2.8.1 +# +# $Id: makefile.emxomf,v 1.4 2013/09/21 15:02:07 ozzmosis Exp $ +# +# Build with: +# +# make -f makefile.emxomf (release) or +# make -f makefile.emxomf DEBUG=1 (debug) or +# make -f makefile.emxomf clean (remove temp files) + +CC=gcc +CFLAGS+= -W -Wall -Zomf -Zsys + +ifdef DEBUG +CFLAGS+= -g +else +LFLAGS+= -s +endif + +ifdef TESTING +CFLAGS+= -DTESTING +OBJS+=testing.obj +endif + +OBJS+=config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj merge.obj +OBJS+=mkdiff.obj mklog.obj msgtool.obj os.obj output.obj procfile.obj stack.obj +OBJS+=strtool.obj upcont.obj + +.c.obj: + $(CC) $(CFLAGS) -c $< + +makenl.exe: $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LFLAGS) + +clean: + del *.obj + del makenl.exe diff -Nru makenl-3.3.3/src/makefile.hcos2 makenl-3.4.1/src/makefile.hcos2 --- makenl-3.3.3/src/makefile.hcos2 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/makefile.hcos2 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,39 @@ +# MakeNL makefile for MetaWare High C for OS/2 +# Tested with MetaWare High C R3.2 +# Requires GNU Make +# +# $Id: makefile.hcos2,v 1.8 2013/09/25 18:24:10 ozzmosis Exp $ +# +# Build with: +# +# make -f makefile.hcos2 (release) or +# make -f makefile.hcos2 DEBUG=1 (debug) or +# make -f makefile.hcos2 clean (remove temp files) + +CC=hc +RM=del + +ifdef DEBUG +CFLAGS+=-g +else +LDFLAGS+=-s +endif + +ifdef TESTING +CFLAGS+= -DTESTING +OBJS+= testing.obj +endif + +OBJS+= config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj +OBJS+= merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj +OBJS+= procfile.obj stack.obj strtool.obj upcont.obj snprintf.obj + +.c.obj: + $(CC) $(CFLAGS) -c $< + +makenl.exe: $(OBJS) + $(CC) $(CFLAGS) -o makenl.exe $(OBJS) $(LDFLAGS) + +clean: + $(RM) $(OBJS) + $(RM) makenl.exe diff -Nru makenl-3.3.3/src/makefile.icc makenl-3.4.1/src/makefile.icc --- makenl-3.3.3/src/makefile.icc 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/makefile.icc 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,35 @@ +# MakeNL makefile for IBM VisualAge C/C++ +# Tested with VisualAge 3.6 +# +# $Id: makefile.icc,v 1.5 2013/09/25 18:24:10 ozzmosis Exp $ +# +# Build with: +# +# nmake -f makefile.icc (release) +# nmake -f makefile.icc DEBUG=1 (debug) +# nmame -f makefile.icc clean (remove temp files) + +CFLAGS=-Q+ + +!ifdef DEBUG +CFLAGS= $(CFLAGS) -Ti+ +!endif + +!ifdef TESTING +CFLAGS= $(CFLAGS) -DTESTING +OBJS= $(OBJS) testing.obj +!endif + +OBJS= $(OBJS) config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj +OBJS= $(OBJS) merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj +OBJS= $(OBJS) procfile.obj stack.obj strtool.obj upcont.obj snprintf.obj + +.c.obj: + $(CC) $(CFLAGS) -fo$@ -c $< + +makenl.exe: $(OBJS) + $(CC) $(CFLAGS) -fe$@ $(OBJS) + +clean: + del $(OBJS) + del makenl.exe diff -Nru makenl-3.3.3/src/makefile.lcc makenl-3.4.1/src/makefile.lcc --- makenl-3.3.3/src/makefile.lcc 2012-10-17 11:36:54.000000000 +0000 +++ makenl-3.4.1/src/makefile.lcc 2013-10-11 17:07:33.000000000 +0000 @@ -1,7 +1,7 @@ # MakeNL makefile for lcc-win32 for Windows # Tested with lcc 3.8. # -# $Id: makefile.lcc,v 1.1 2012/10/17 11:36:54 ozzmosis Exp $ +# $Id: makefile.lcc,v 1.4 2013/09/23 09:45:28 ozzmosis Exp $ # # Build with: # @@ -9,17 +9,18 @@ # make -f makefile.lcc clean (remove temp files) CC=lc -CFLAGS=-DWIN32 +CFLAGS= +LFLAGS=-s OBJS=config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj \ -merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj process.obj \ +merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj procfile.obj \ stack.obj strtool.obj upcont.obj .c.obj: $(CC) $(CFLAGS) -c $< makenl.exe: $(OBJS) - $(CC) $(CFLAGS) $(OBJS) -o $@ + $(CC) $(CFLAGS) $(OBJS) -o $@ $(LFLAGS) clean: del $(OBJS) diff -Nru makenl-3.3.3/src/makefile.linux makenl-3.4.1/src/makefile.linux --- makenl-3.3.3/src/makefile.linux 2012-10-13 00:13:27.000000000 +0000 +++ makenl-3.4.1/src/makefile.linux 2013-10-11 17:07:33.000000000 +0000 @@ -1,20 +1,45 @@ # MakeNL makefile for Linux # Tested with GNU Make 3.81 & GNU C 4.4.3 # -# $Id: makefile.linux,v 1.3 2012/10/13 00:13:27 ozzmosis Exp $ +# $Id: makefile.linux,v 1.13 2013/10/03 18:01:38 ozzmosis Exp $ # # Build with: # # make -f makefile.linux (release) or # make -f makefile.linux DEBUG=1 (debug) +# make -f makefile.linux STATIC=1 (build statically-linked binary) +# make -f makefile.linux I386=1 (build 32-bit binary on 64-bit Linux) # make -f makefile.linux clean (remove temp files) # make -f makefile.linux CC=clang (build with clang) +# make -f makefile.linux ASAN=1 (debug build with clang using AddressSanitizer) CC=gcc CFLAGS+= -Wall -W +ifdef ASAN +CC=clang +CFLAGS+= -g -fsanitize=address -fno-omit-frame-pointer +endif + ifdef DEBUG CFLAGS+= -g +else +ifndef STATIC +LDFLAGS+= -s +endif +endif + +ifdef STATIC +LDFLAGS+= -static +endif + +ifdef I386 +CFLAGS+= -m32 +endif + +ifdef TESTING +CFLAGS+= -DTESTING +OBJS+=testing.o endif ifdef EFENCE @@ -23,21 +48,18 @@ ifdef RMALLOC CFLAGS+= -DMALLOC_DEBUG +OBJS+=rmalloc.o endif OBJS+=config.o crc16.o fileutil.o fts5.o lsttool.o makenl.o merge.o -OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o process.o stack.o +OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o procfile.o stack.o OBJS+=strtool.o upcont.o -ifdef RMALLOC -OBJS+= rmalloc.o -endif - .c.o: $(CC) $(CFLAGS) -c $< makenl: $(OBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) clean: rm -f $(OBJS) makenl diff -Nru makenl-3.3.3/src/makefile.msvc makenl-3.4.1/src/makefile.msvc --- makenl-3.3.3/src/makefile.msvc 2012-10-17 01:24:43.000000000 +0000 +++ makenl-3.4.1/src/makefile.msvc 2013-10-11 17:07:33.000000000 +0000 @@ -1,23 +1,34 @@ # MakeNL makefile for Microsoft Visual C/C++ for Windows # Tested with Visual C++ 2.0 (cl.exe 9.0) # -# $Id: makefile.msvc,v 1.2 2012/10/17 01:24:43 ozzmosis Exp $ +# $Id: makefile.msvc,v 1.7 2013/09/25 20:13:37 ozzmosis Exp $ # # Build with: # -# nmake -f makefile.msvc -# nmake -f makefile.msvc clean (remove temp files) +# nmake -f makefile.msvc (release version) +# nmake -f makefile.msvc MSVCRT=1 (link with MSVC runtime DLL for smaller .exe) +# nmake -f makefile.msvc DEBUG=1 (debug version) +# nmake -f makefile.msvc clean (remove temp files) CC=cl -CFLAGS= -nologo -W3 -DWIN32 +CFLAGS= -nologo -W3 !ifdef DEBUG CFLAGS= $(CFLAGS) -Zd !endif -OBJS=config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj +!ifdef MSVCRT +CFLAGS= $(CFLAGS) -MD +!endif + +!ifdef TESTING +CFLAGS= $(CFLAGS) -DTESTING +OBJS=$(OBJS) testing.obj +!endif + +OBJS=$(OBJS) config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj OBJS=$(OBJS) merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj -OBJS=$(OBJS) process.obj stack.obj strtool.obj upcont.obj +OBJS=$(OBJS) procfile.obj stack.obj strtool.obj upcont.obj snprintf.obj .c.obj: $(CC) $(CFLAGS) -c $< diff -Nru makenl-3.3.3/src/makefile.osx makenl-3.4.1/src/makefile.osx --- makenl-3.3.3/src/makefile.osx 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/makefile.osx 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,53 @@ +# MakeNL makefile for OS X (Darwin) +# Tested with GNU Make 3.81 & GNU C 4.2.1 +# +# $Id: makefile.osx,v 1.3 2013/09/22 08:13:59 ozzmosis Exp $ +# +# Build with: +# +# make -f makefile.osx (release) or +# make -f makefile.osx DEBUG=1 (debug) +# make -f makefile.osx clean (remove temp files) +# make -f makefile.osx CC=clang (build with clang) +# make -f makefile.osx ASAN=1 (debug build with clang using AddressSanitizer) + +CC=gcc +CFLAGS+= -Wall -W + +ifdef ASAN +CC=clang +CFLAGS+= -g -fsanitize=address -fno-omit-frame-pointer +endif + +ifdef DEBUG +CFLAGS+= -g +else +LDFLAGS+= -s +endif + +ifdef TESTING +CFLAGS+= -DTESTING +OBJS+=testing.o +endif + +ifdef EFENCE +LDFLAGS+= -lefence +endif + +ifdef RMALLOC +CFLAGS+= -DMALLOC_DEBUG +OBJS+=rmalloc.o +endif + +OBJS+=config.o crc16.o fileutil.o fts5.o lsttool.o makenl.o merge.o +OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o procfile.o stack.o +OBJS+=strtool.o upcont.o + +.c.o: + $(CC) $(CFLAGS) -c $< + +makenl: $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) + +clean: + rm -f $(OBJS) makenl diff -Nru makenl-3.3.3/src/makefile.sun makenl-3.4.1/src/makefile.sun --- makenl-3.3.3/src/makefile.sun 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/makefile.sun 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,26 @@ +# MakeNL makefile for Solaris +# Tested with OpenSolaris 2009.06 +# +# $Id: makefile.sun,v 1.1 2013/10/02 08:58:03 ozzmosis Exp $ +# +# Build with: +# +# make -f makefile.sun (release) or +# make -f makefile.sun clean (remove temp files) + +CC=gcc +CFLAGS=-Wall -W +LDFLAGS=-s + +OBJS=config.o crc16.o fileutil.o fts5.o lsttool.o makenl.o merge.o \ + mkdiff.o mklog.o msgtool.o os.o output.o procfile.o stack.o \ + strtool.o upcont.o + +.c.o: + $(CC) $(CFLAGS) -c $< + +makenl: $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) + +clean: + rm -f $(OBJS) makenl diff -Nru makenl-3.3.3/src/makefile.tcc makenl-3.4.1/src/makefile.tcc --- makenl-3.3.3/src/makefile.tcc 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/makefile.tcc 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,57 @@ +# MakeNL makefile for TinyCC on Linux +# Tested with GNU Make 3.81 & TinyCC 0.9.26 +# +# $Id: makefile.tcc,v 1.2 2013/09/26 20:43:45 ozzmosis Exp $ +# +# Build with: +# +# make -f makefile.tcc (release) or +# make -f makefile.tcc DEBUG=1 (debug) +# make -f makefile.tcc clean (remove temp files) +# make -f makefile.tcc I386=1 (32-bit build) +# make -f makefile.tcc WIN32=1 (cross-compile to Win32) +# make -f makefile.tcc WIN64=1 (cross-compile to Win64) + +TCCROOT=/opt/tcc +CC=$(TCCROOT)/bin/tcc +INTLIB=$(TCCROOT)/lib/tcc + +ifdef I386 +CC=$(TCCROOT)/bin/i386-tcc +endif + +ifdef WIN32 +CC=$(TCCROOT)/bin/i386-win32-tcc +INTLIB=$(TCCROOT)/lib/tcc/win32 +endif + +ifdef WIN64 +CC=$(TCCROOT)/bin/x86_64-win32-tcc +INTLIB=$(TCCROOT)/lib/tcc/win32 +endif + +CFLAGS+= -Wall -W -B$(INTLIB) -O2 + +ifdef DEBUG +CFLAGS+= -g +else +LDFLAGS+= -s +endif + +ifdef TESTING +CFLAGS+= -DTESTING +OBJS+=testing.o +endif + +OBJS+=config.o crc16.o fileutil.o fts5.o lsttool.o makenl.o merge.o +OBJS+=mkdiff.o mklog.o msgtool.o os.o output.o procfile.o stack.o +OBJS+=strtool.o upcont.o + +.c.o: + $(CC) $(CFLAGS) -c $< + +makenl: $(OBJS) + $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) + +clean: + rm -f $(OBJS) makenl diff -Nru makenl-3.3.3/src/makefile.tcd makenl-3.4.1/src/makefile.tcd --- makenl-3.3.3/src/makefile.tcd 2012-11-12 17:30:01.000000000 +0000 +++ makenl-3.4.1/src/makefile.tcd 2013-10-11 17:07:33.000000000 +0000 @@ -1,6 +1,6 @@ # MakeNL makefile for Borland Turbo C++ 1.0 for DOS # -# $Id: makefile.tcd,v 1.2 2012/11/12 17:30:01 ozzmosis Exp $ +# $Id: makefile.tcd,v 1.4 2013/09/25 18:24:10 ozzmosis Exp $ # # Build with: # @@ -12,7 +12,7 @@ OBJS=config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj OBJS=$(OBJS) merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj -OBJS=$(OBJS) process.obj stack.obj strtool.obj upcont.obj +OBJS=$(OBJS) procfile.obj stack.obj strtool.obj upcont.obj snprintf.obj .c.obj: $(CC) $(CFLAGS) -c $< diff -Nru makenl-3.3.3/src/makefile.watcom makenl-3.4.1/src/makefile.watcom --- makenl-3.3.3/src/makefile.watcom 2012-11-13 20:09:22.000000000 +0000 +++ makenl-3.4.1/src/makefile.watcom 2013-10-11 17:07:33.000000000 +0000 @@ -1,7 +1,9 @@ # MakeNL makefile for Watcom C/C++ # Tested with OpenWatcom 1.9 # -# $Id: makefile.watcom,v 1.6 2012/11/13 20:09:22 ozzmosis Exp $ +# Defaults to building OS/2 32-bit target. +# +# $Id: makefile.watcom,v 1.16 2013/09/28 11:52:58 ozzmosis Exp $ # # Build with: # @@ -31,7 +33,7 @@ !ifeq OS OS2 CC=wcl386 -CFLAGS+= -bt=os2v2 -l=os2v2 +CFLAGS+= -bt=os2 -l=os2v2 !endif !ifeq OS O16 @@ -48,7 +50,8 @@ !ifeq OS D32 CC=wcl386 -CFLAGS+= -bt=dos4g -l=dos4g +CFLAGS+= -bt=dos -l=dos4g +CFLAGS+= -k32768 !endif !ifeq OS WIN @@ -58,7 +61,7 @@ !ifeq OS LNX CC=wcl386 -CFLAGS+= -bcl=linux +CFLAGS+= -bt=linux -l=linux RM=rm -f !endif @@ -66,13 +69,20 @@ CFLAGS+= -d2 -hw !endif -!ifndef RM +!ifdef TESTING +CFLAGS+= -DTESTING +OBJS+= testing.obj +!endif + +!ifdef __UNIX__ +RM=rm +!else RM=del !endif OBJS+= config.obj crc16.obj fileutil.obj fts5.obj lsttool.obj makenl.obj OBJS+= merge.obj mkdiff.obj mklog.obj msgtool.obj os.obj output.obj -OBJS+= process.obj stack.obj strtool.obj upcont.obj +OBJS+= procfile.obj stack.obj strtool.obj upcont.obj snprintf.obj .c.obj: $(CC) $(CFLAGS) -fo=$@ -c $< diff -Nru makenl-3.3.3/src/makenl.c makenl-3.4.1/src/makenl.c --- makenl-3.3.3/src/makenl.c 2012-10-14 15:24:21.000000000 +0000 +++ makenl-3.4.1/src/makenl.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: makenl.c,v 1.14 2012/10/14 15:24:21 ozzmosis Exp $ */ +/* $Id: makenl.c,v 1.26 2013/09/25 19:46:00 ozzmosis Exp $ */ #include #include @@ -13,19 +13,13 @@ #include "fileutil.h" #include "merge.h" #include "msg.h" -#include "proc.h" +#include "procfile.h" #include "crc16.h" #include "version.h" #include "unused.h" #include "mklog.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif +#include "strtool.h" +#include "snprintf.h" #if defined(__MSDOS__) && defined(__TURBOC__) extern unsigned _stklen = 16384; @@ -118,7 +112,7 @@ va_list arg; va_start(arg, format); - vsprintf(buf, format, arg); + vsnprintf(buf, sizeof buf, format, arg); va_end(arg); mklog(LOG_ERROR, "%s", buf); @@ -137,13 +131,13 @@ if (argv[0] == NULL) { /* empty command-line and no program name (unlikely but possible) */ - strcat(tmp, "(null)"); + strlcat(tmp, "(null)", sizeof tmp); return tmp; } /* argv[0] is a special case, no quotes around it */ - strcat(tmp, argv[0]); + strlcat(tmp, argv[0], sizeof tmp); /* now loop over each argument */ @@ -154,13 +148,13 @@ if (strlen(tmp) + strlen(*p) + 3 > sizeof tmp) { /* command-line too long, avoid segfault */ - strcat(tmp, " ..."); + strlcat(tmp, " ...", sizeof tmp); return tmp; } - strcat(tmp, " \""); - strcat(tmp, *p); - strcat(tmp, "\""); + strlcat(tmp, " \"", sizeof tmp); + strlcat(tmp, *p, sizeof tmp); + strlcat(tmp, "\"", sizeof tmp); p++; } @@ -173,6 +167,10 @@ mklog(LOG_INFO, MAKENL_LONG_VERSION); +#ifdef TESTING + testing(); +#endif + DoCmdLine(argv, &CfgFile); if (!getext(NULL, CfgFile)) { @@ -182,21 +180,21 @@ CFG_file = fopen(CfgFile, "r"); check_fp(CFG_file, CfgFile, "r"); WorkFile = strdup(CfgFile); - os_filecanonify(WorkFile); + os_dirsep(WorkFile); os_getcwd(CurDir, MYMAXDIR - 1); - os_filecanonify(CurDir); + os_dirsep(CurDir); WorkMode = parsecfgfile(CFG_file); mklog(LOG_INFO, "Cmdline: %s", cmdline_to_str(argv)); mklog(LOG_INFO, "Using '%s' in '%s'", CfgFile, CurDir); - for (OldWeeks = 3; OldWeeks >= 0; OldWeeks--) + for (OldWeeks = 7; OldWeeks >= 0; OldWeeks--) { searchdow(NewExtWDay, -7 * OldWeeks + 6, &SplitTimePtr); - sprintf(OldExtensions[OldWeeks], "%03d", + snprintf(OldExtensions[OldWeeks], sizeof OldExtensions[OldWeeks], "%03d", SplitTimePtr->tm_yday + 1); } - sprintf(YearBuf, "%d", 1900 + SplitTimePtr->tm_year); - sprintf(HeaderLine, + snprintf(YearBuf, sizeof YearBuf, "%d", 1900 + SplitTimePtr->tm_year); + snprintf(HeaderLine, sizeof HeaderLine, ";A %s Nodelist for %s, %s %d, %s -- Day number %s : ", Levels[MakeType], DOWLongnames[SplitTimePtr->tm_wday], MonthLongnames[SplitTimePtr->tm_mon], SplitTimePtr->tm_mday, @@ -271,19 +269,19 @@ { char cmdbuf[1024]; /* space for CalledBatchfile */ - sprintf(cmdbuf, "%s %s" STR_DIRSEPARATOR "%s ", + snprintf(cmdbuf, sizeof cmdbuf, "%s %s" DIRSEP "%s ", CalledBatchFile, OutDir, OutFile); WorkMode = 0; /* Why that?! see three lines above! */ if (OutExt[0] == 0) /* If output is generic, we could diff and ARC */ { - cleanold(OutDir, OutFile, OldExtensions[2]); + cleanold(OutDir, OutFile, OldExtensions[7]); WorkMode = makediff(NewFile); makearc(NewFile, 0); if (WorkMode & CAUSE_OUTDIFF) { - sprintf(cmdbuf + strlen(cmdbuf), - "%s" STR_DIRSEPARATOR "%s ", OutDir, OutDiff); + snprintf(cmdbuf + strlen(cmdbuf), (sizeof cmdbuf) - strlen(cmdbuf), + "%s" DIRSEP "%s ", OutDir, OutDiff); myfnmerge(CfgFilenameBuf, NULL, OutDir, OutDiff, OldExtensions[0]); makearc(CfgFilenameBuf, 1); @@ -295,22 +293,25 @@ } } else - strcat(cmdbuf, "no-diff "); + { + strlcat(cmdbuf, "no-diff ", sizeof cmdbuf); + } } else { - strcat(cmdbuf, "no-diff "); + strlcat(cmdbuf, "no-diff ", sizeof cmdbuf); /* * New feature: compress hub and host segments. * Added in 2004 when file size doesn't matter anymore. */ myfnmerge(CfgFilenameBuf, NULL, OutDir, OutFile, NULL); makearc(CfgFilenameBuf, 1); - strcpy(NewFile, CfgFilenameBuf); + strlcpy(NewFile, CfgFilenameBuf, sizeof NewFile); mklog(LOG_DEBUG, "main(): NewFile == '%s'", NewFile); } - sprintf(cmdbuf + strlen(cmdbuf), "%c %c %c %c %c %c\n", + snprintf(cmdbuf + strlen(cmdbuf), (sizeof cmdbuf) - strlen(cmdbuf), + "%c %c %c %c %c %c\n", OldExtensions[0][0], OldExtensions[0][1], OldExtensions[0][2], OldExtensions[1][0], OldExtensions[1][1], OldExtensions[1][2]); @@ -320,20 +321,20 @@ if (fp) { - fputs(os_deslashify(cmdbuf), fp); + fputs(os_dirsep(cmdbuf), fp); fclose(fp); } } - os_filecanonify(NewFile); + os_dirsep(NewFile); if (MailerFlags & MF_SUBMIT && SubmitFile && OpenMSGFile(SubmitAddress, NewFile)) { if (MyAddress[A_ZONE] == SubmitAddress[A_ZONE]) - sprintf(SubAddrText, "%d/%d", SubmitAddress[A_NET], + snprintf(SubAddrText, sizeof SubAddrText, "%d/%d", SubmitAddress[A_NET], SubmitAddress[A_NODE]); else - sprintf(SubAddrText, "%d:%d/%d", SubmitAddress[A_ZONE], + snprintf(SubAddrText, sizeof SubAddrText, "%d:%d/%d", SubmitAddress[A_ZONE], SubmitAddress[A_NET], SubmitAddress[A_NODE]); mklog(LOG_INFO, "Sending '%s' to %s", NewFile, SubAddrText); } diff -Nru makenl-3.3.3/src/makenl.dev makenl-3.4.1/src/makenl.dev --- makenl-3.3.3/src/makenl.dev 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/src/makenl.dev 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ -[Project] -FileName=makenl.dev -Name=Project1 -UnitCount=15 -Type=1 -Ver=1 -ObjFiles= -Includes= -Libs= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Compiler= -CppCompiler= -Linker= -IsCpp=0 -Icon= -ExeOutput= -ObjectOutput= -OverrideOutput=0 -OverrideOutputName=makenl.exe -HostApplication= -Folders= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=000000000000000100 - -[Unit1] -FileName=makenl.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=config.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit3] -FileName=crc16.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit4] -FileName=lsttool.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit5] -FileName=mkdiff.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit6] -FileName=msgtool.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit7] -FileName=output.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit8] -FileName=process.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit9] -FileName=stack.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit10] -FileName=strtool.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit11] -FileName=upcont.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit12] -FileName=fts5.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit13] -FileName=fileutil.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit14] -FileName=merge.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit15] -FileName=os.c -CompileCpp=0 -Folder=Project1 -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -AutoIncBuildNr=0 - diff -Nru makenl-3.3.3/src/makenl.h makenl-3.4.1/src/makenl.h --- makenl-3.3.3/src/makenl.h 2012-10-16 19:57:43.000000000 +0000 +++ makenl-3.4.1/src/makenl.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,7 @@ -/* $Id: makenl.h,v 1.6 2012/10/16 19:57:43 ozzmosis Exp $ */ +/* $Id: makenl.h,v 1.8 2013/09/05 15:07:51 ozzmosis Exp $ */ + +#ifndef __MAKENL_H__ +#define __MAKENL_H__ #include "os.h" @@ -32,14 +35,9 @@ /* the die function from makenl.c */ void die(int exitcode, const char *format, ...); -/* the utility functions from strtool.c */ -int getnumber(const char *string, int *output); -char *skipspaces(char *ptr); -char *cutspaces(char *string); - -/* necessary for some C implementations where printf("%s\n", NULL) would cause a segfault */ +/* testing() in testing.c */ -#define make_str_safe(x) (x)?(x):"(null)" +void testing(void); #ifndef max #define max(a,b) (((a) > (b)) ? (a) : (b)) @@ -48,3 +46,13 @@ #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif + +#ifdef MALLOC_DEBUG +#include "rmalloc.h" +#endif + +#ifdef DMALLOC +#include "dmalloc.h" +#endif + +#endif diff -Nru makenl-3.3.3/src/merge.c makenl-3.4.1/src/merge.c --- makenl-3.3.3/src/merge.c 2012-10-14 14:56:24.000000000 +0000 +++ makenl-3.4.1/src/merge.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: merge.c,v 1.6 2012/10/14 14:56:24 ozzmosis Exp $ */ +/* $Id: merge.c,v 1.10 2013/09/26 19:52:03 ozzmosis Exp $ */ #include #include @@ -10,14 +10,7 @@ #include "msg.h" #include "fileutil.h" #include "mklog.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif +#include "strtool.h" static FILE *MergeInFILE, *MergeOutFILE; static int MergeListAddr[4]; @@ -40,7 +33,7 @@ mklog(LOG_INFO, "WARNING - Your Net or Region number is unknown, Merge cancelled"); return 0; } - for (extptr = OldExtensions; extptr < OldExtensions + 3; extptr++) + for (extptr = OldExtensions; extptr < OldExtensions + 7; extptr++) { swapext(MergeFilename, MergeFilename, *extptr); MergeInFILE = fopen(MergeFilename, "rb"); @@ -66,7 +59,7 @@ { swapext(MergeFilename, MergeFilename, NULL); /* Kill any extension */ - mklog(LOG_INFO, "Unable to find distribution file '%s' less than 3 weeks old.", MergeFilename); + mklog(LOG_INFO, "Unable to find distribution file '%s' less than 7 weeks old.", MergeFilename); mklog(LOG_INFO, "Processing continues without merging"); return 0; } @@ -88,7 +81,7 @@ MergeInFILE = NULL; return MergeOutFILE; } - strcpy(MergeLine, linebuf); + strlcpy(MergeLine, linebuf, sizeof MergeLine); ParseFTS5(linebuf, &linelevel, &linenum); if (Level4DPos[linelevel] <= matchparts) return MergeOutFILE; @@ -128,7 +121,7 @@ return MergeOutFILE; while (fgets(linebuf, linelength, MergeInFILE) != NULL) { - strcpy(MergeLine, linebuf); + strlcpy(MergeLine, linebuf, sizeof MergeLine); ParseFTS5(linebuf, &linelevel, &linenum); if (linelevel <= MakeType) return MergeOutFILE; diff -Nru makenl-3.3.3/src/merge.h makenl-3.4.1/src/merge.h --- makenl-3.3.3/src/merge.h 2009-01-08 20:07:46.000000000 +0000 +++ makenl-3.4.1/src/merge.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: merge.h,v 1.1.1.1 2009/01/08 20:07:46 mbroek Exp $ */ +/* $Id: merge.h,v 1.1 2009/01/08 20:07:46 mbroek Exp $ */ FILE *PrepareMerge(void); void FinishMerge(void); diff -Nru makenl-3.3.3/src/mkdiff.c makenl-3.4.1/src/mkdiff.c --- makenl-3.3.3/src/mkdiff.c 2012-11-13 22:38:44.000000000 +0000 +++ makenl-3.4.1/src/mkdiff.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: mkdiff.c,v 1.9 2012/11/13 22:38:44 ozzmosis Exp $ */ +/* $Id: mkdiff.c,v 1.15 2013/09/26 19:52:03 ozzmosis Exp $ */ #include #include @@ -8,30 +8,24 @@ #include "fileutil.h" #include "lsttool.h" #include "mklog.h" +#include "os.h" +#include "strtool.h" -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -#ifdef __FLAT__ -#define COLLTBLSIZE ((65536 * 2) / 8) -#define COLLTBLBYTEPOS(idx) (idx >> 2) -#define COLLTBLBITPOS(idx) ((idx & 3) << 1) -#define MAXHASHLISTENTRIES 16200 -#define MINHASHLISTENTRIES 40 -#else +#ifdef MEM_SEG +/* smaller table size for 16-bit DOS & 16-bit OS/2 builds */ #define COLLTBLSIZE ((int)((32768L * 2) / 8)) #define COLLTBLBYTEPOS(idx) (idx >> 3) #define COLLTBLBITPOS(idx) (idx & 6) #define MAXHASHLISTENTRIES 2050 #define MINHASHLISTENTRIES 20 +#else +#define COLLTBLSIZE ((65536 * 2) / 8) +#define COLLTBLBYTEPOS(idx) (idx >> 2) +#define COLLTBLBITPOS(idx) ((idx & 3) << 1) +#define MAXHASHLISTENTRIES 16200 +#define MINHASHLISTENTRIES 40 #endif - #define ISHASH(entry) (entry.hash < 0) #define ISLINENO(entry) (entry.hash >= 0) #define ISCONNECTED(entry) ISLINENO(entry) @@ -39,12 +33,19 @@ union _hashentry { unsigned short hashlow; - /* Make sure hash is allways 32 bits */ -#if defined(__DOS16__) || defined(__OS2__) + + /* + * FIXME: int will be 64-bits on most modern BSD/Linux systems... + * -- ozzmosis 2013-09-12 + */ + + /* Make sure hash is always 32 bits */ +#ifdef MEM_SEG long hash; #else int hash; #endif + int lineno; }; @@ -65,16 +66,22 @@ static FILE *DiffFILE; static struct DiffingInfo OldFile, NowFile; -/* Collision table handling */ -/* The collision table has 32768 2-bit entries. Index into the table is */ -/* a 16-bit hash (in fact: only higher 15 bit of an unsigned short). */ -/* On 32-bit systems the collision table is 65536 entries with full 16-bit */ -/* index. */ -/* entry: 0=hash not used, 1=hash uniquely used, 2=hash collision */ - -/* Get2Bit/Set2Bit: */ -/* bitno: the lower 16 bit of the hash value; index into the table */ -/* bitptr: pointer to the collision table */ +/* + * Collision table handling + * + * The collision table has 32768 2-bit entries. Index into the table is + * a 16-bit hash (in fact: only higher 15 bit of an unsigned short). + * + * On 32-bit systems the collision table is 65536 entries with full 16-bit + * index. + * + * entry: 0=hash not used, 1=hash uniquely used, 2=hash collision + * + * Get2Bit/Set2Bit: + * + * bitno: the lower 16 bit of the hash value; index into the table + * bitptr: pointer to the collision table + */ static int Get2Bit(char *bitptr, unsigned short bitno) { @@ -92,16 +99,27 @@ static int lineread(char *linebuf, int currentline, struct DiffingInfo *f) { if (f->lineno > currentline) + { return 1; + } + do { if (fgets(linebuf, linelength, f->theFILE) == NULL) + { return 0; - if (linebuf[0] == '\032') /* Ignore EOF line */ + } + + if (linebuf[0] == '\032') + { + /* Ignore EOF line */ return 0; + } + f->lineno++; } while (f->lineno <= currentline); + return 1; } @@ -112,8 +130,12 @@ while (*linebuf) { hashval <<= 1; + if (hashval < 0) + { hashval |= 1; + } + hashval ^= *linebuf; linebuf++; } @@ -130,6 +152,7 @@ f->hashentries = 0; pos = ftell(f->theFILE); + while (lineread(linebuf, f->lineno, f)) { if (f->hashentries >= maxhashes) @@ -141,6 +164,7 @@ f->HashList[f->hashentries].hash = hashstr(linebuf); hashlow = f->HashList[f->hashentries].hashlow; f->hashentries++; + switch (Get2Bit(f->CollTbl, hashlow)) { case 0: @@ -151,6 +175,7 @@ break; } } + fseek(f->theFILE, pos, SEEK_SET); f->lineno = 0; return f->hashentries; @@ -163,25 +188,38 @@ int aktline, linecount; char mybuf[linelength]; - /* Make the Copyright appear in the diff */ - /* if the copyright has more lines than the hashbuffer, then let only */ - /* as much lines appear as fit in the hash buffer. */ - /* FIXED BUG from makenl 2.51: it crashes if the copyright has more */ - /* lines than the hashbuffer. */ + /* + * Make the Copyright appear in the diff + * + * If the copyright has more lines than the hashbuffer, then let only + * as much lines appear as fit in the hash buffer. + * + * FIXED BUG from makenl 2.51: it crashes if the copyright has more + * lines than the hashbuffer. + */ + if (CopyrightLines >= maxhashes) + { CopyrightLines = maxhashes - 1; + } for (i = 1; i <= CopyrightLines; i++) { if (ISCONNECTED(NowFile.HashList[i])) - NowFile.HashList[i].hash = -1; /* remove connection */ + { + /* remove connection */ + NowFile.HashList[i].hash = -1; + } } + CopyrightLines = 0; idxnow = idxold = 0; + while (idxold < OldFile.hashentries && idxnow < NowFile.hashentries) { /* count matching lines, and do a real line compare on them */ + for (linecount = 0; idxold < OldFile.hashentries && idxnow < NowFile.hashentries && @@ -190,15 +228,20 @@ { lineread(mybuf, idxold, &OldFile); lineread(linebuf, idxnow, &NowFile); + if (strcmp(mybuf, linebuf) != 0) { - /* Remove false connections - after comparing input lines, - you can be sure, whether the lines are equal */ + /* + * Remove false connections - after comparing input lines, + * you can be sure, whether the lines are equal. + */ + NowFile.HashList[idxnow].hash = -1; OldFile.HashList[idxold].hash = -1; break; } } + if (linecount) { /* There is at least one copyable line */ @@ -206,16 +249,19 @@ continue; } - /* Count unmatched lines in the old file, or lines matched against - some lines in the new file already written */ + /* + * Count unmatched lines in the old file, or lines matched against + * some lines in the new file already written. + */ + linecount = 0; while (idxold < OldFile.hashentries && - (ISHASH(OldFile.HashList[idxold]) || - OldFile.HashList[idxold].lineno < idxnow)) + (ISHASH(OldFile.HashList[idxold]) || OldFile.HashList[idxold].lineno < idxnow)) { linecount++; idxold++; } + if (linecount) { /* Throw them away! */ @@ -223,62 +269,79 @@ continue; } - /* Count lines in the new file that were not matched or matched - against lines already read and copied/deleted */ + /* + * Count lines in the new file that were not matched or matched + * against lines already read and copied/deleted. + */ linecount = 0; while (idxnow < NowFile.hashentries && - (ISHASH(NowFile.HashList[idxnow]) || - NowFile.HashList[idxnow].lineno < idxold)) + (ISHASH(NowFile.HashList[idxnow]) || NowFile.HashList[idxnow].lineno < idxold)) { linecount++; idxnow++; } + if (linecount) { /* There are such lines - put them into the diff */ fprintf(DiffFILE, "A%d\r\n", linecount); aktline = idxnow - linecount; + while (linecount--) { lineread(linebuf, aktline++, &NowFile); fputs(linebuf, DiffFILE); } } - /* There seems to be a change in the order of the lines... Look - which number is larger a) the numbers of line in the input till - the expected line comes OR b) the numbers of lines in the - output, till the next input line appears */ + + /* + * There seems to be a change in the order of the lines... Look + * which number is larger a) the numbers of line in the input till + * the expected line comes OR b) the numbers of lines in the + * output, till the next input line appears + */ else if (NowFile.HashList[idxnow].lineno - idxold >= - OldFile.HashList[idxold].lineno - idxnow) + OldFile.HashList[idxold].lineno - idxnow) { - /* a) is larger - so emit the lines till the input line - appears in output */ + /* + * a) is larger - so emit the lines till the input line + * appears in output. + */ + linecount = OldFile.HashList[idxold].lineno - idxnow; fprintf(DiffFILE, "A%d\r\n", linecount); aktline = idxnow; + for (; linecount != 0; linecount--) { lineread(linebuf, aktline++, &NowFile); fputs(linebuf, DiffFILE); } + idxnow = OldFile.HashList[idxold].lineno; } else { - /* b) is larger, so tell the reader to ignore input lines up - to the matching line */ + /* + * b) is larger, so tell the reader to ignore input lines up + * to the matching line + */ fprintf(DiffFILE, "D%d\r\n", NowFile.HashList[idxnow].lineno - idxold); + idxold = NowFile.HashList[idxnow].lineno; } } - /* this was not the last data block... Put the filepointers into - correct position for next block */ + /* + * This was not the last data block... Put the filepointers into + * correct position for next block. + */ + if (StillData) { NowFile.hashentries = idxnow; @@ -287,17 +350,26 @@ return; } - /* we have to clean up... if there are lines left in the old file - - DELETE them! */ + /* + * We have to clean up... if there are lines left in the old file - + * DELETE them! + */ + if (idxold < OldFile.hashentries) + { fprintf(DiffFILE, "D%d\r\n", OldFile.hashentries - idxold); + } + + /* + * If there are additional lines in the new file, they have to appear + * in the diff! + */ - /* if there are additional lines in the new file, they have to appear - in the diff! */ if (idxnow < NowFile.hashentries) { fprintf(DiffFILE, "A%d\r\n", NowFile.hashentries - idxnow); aktline = idxnow; + for (; idxnow < NowFile.hashentries; idxnow++) { lineread(linebuf, aktline++, &NowFile); @@ -319,22 +391,27 @@ char linebuf[linelength]; swapext(oldname, filename, OldExtensions[1]); + if (os_filesize(filename) > DIFFThreshold && DIFFThreshold != -1) { cause = CAUSE_THRESHOLD; - strcpy(newext, OldExtensions[0]); + strlcpy(newext, OldExtensions[0], sizeof newext); newext[0] = 'd'; /* foo.206 --> foo.d06 */ myfnmerge(diffname, NULL, OutDir, OutFile, newext); } else { if (OutDiff[0] == 0) + { return 0; + } + cause = CAUSE_OUTDIFF; myfnmerge(diffname, NULL, OutDir, OutDiff, OldExtensions[0]); } OldFile.theFILE = fopen(oldname, "rb"); + if (!OldFile.theFILE) { mklog(LOG_ERROR, "Old file '%s' does not exist, no difference file made", oldname); @@ -342,14 +419,21 @@ } NowFile.theFILE = fopen(filename, "rb"); + if (!NowFile.theFILE) + { die(254, "Unable to open new node list -- '%s'\n", filename); + } DiffFILE = fopen(diffname, "wb"); + if (!DiffFILE) + { die(254, "Unable to create difference file -- '%s'\n", diffname); + } /* skip first line of new file */ + if (!fgets(linebuf, linelength, NowFile.theFILE)) { fclose(OldFile.theFILE); @@ -360,6 +444,7 @@ } /* get first line of old file */ + if (!fgets(linebuf, linelength, OldFile.theFILE)) { fclose(OldFile.theFILE); @@ -368,24 +453,33 @@ unlink(diffname); return 0; } + fputs(linebuf, DiffFILE); mklog(LOG_INFO, "Creating difference file '%s' from '%s' and '%s'", diffname, oldname, filename); /* allocate buffer memory for diff-hashing */ + OldFile.CollTbl = NULL; maxhashes = MAXHASHLISTENTRIES; while (maxhashes >= MINHASHLISTENTRIES) { - OldFile.CollTbl = - malloc(2 * COLLTBLSIZE + 2 * maxhashes * sizeof(long)); + OldFile.CollTbl = malloc(2 * COLLTBLSIZE + 2 * maxhashes * sizeof(long)); + if (OldFile.CollTbl) + { break; - else /* no memory: */ - maxhashes -= 100; /* shorten hash table by 100 entries */ + } + else + { + /* no memory; shorten hash table by 100 entries */ + maxhashes -= 100; + } + } + if (!OldFile.CollTbl) { mklog(LOG_ERROR, "Unable to allocate memory -- no difference file generated"); @@ -396,18 +490,26 @@ return 0; } - /* order of buffers in allocated memory: */ - /* OldFile.CollTbl, NowFile.CollTbl, OldFile.HashList, - NowFile.HashList */ + /* + * Order of buffers in allocated memory: + * + * OldFile.CollTbl + * NowFile.CollTbl + * OldFile.HashList + * NowFile.HashList + */ + NowFile.CollTbl = OldFile.CollTbl + COLLTBLSIZE; - OldFile.HashList = - (union _hashentry *)((char *)NowFile.CollTbl + COLLTBLSIZE); - NowFile.HashList = OldFile.HashList + maxhashes; + OldFile.HashList = (union _hashentry *)((char *)NowFile.CollTbl + COLLTBLSIZE); + + NowFile.HashList = OldFile.HashList + maxhashes; /* begin diff process */ + fseek(OldFile.theFILE, 0L, SEEK_SET); fseek(NowFile.theFILE, 0L, SEEK_SET); + do { int idxold; @@ -418,31 +520,40 @@ primebuffer(&OldFile, linebuf); run1 = OldFile.CollTbl; run2 = NowFile.CollTbl; + for (i = 0; i < COLLTBLSIZE; i++) + { *(run1++) &= *(run2++); + } /* Step 1: connect all lines with unique hash value */ + idxnow = idxold = 0; - while (idxold < OldFile.hashentries) /* Walk old file line-by-line - */ + + while (idxold < OldFile.hashentries) { - if (idxnow < NowFile.hashentries) /* try walking in new file - also */ + /* Walk old file line-by-line */ + + if (idxnow < NowFile.hashentries) + { + /* try walking in new file also */ idxnow++; + } - if (Get2Bit(OldFile.CollTbl, OldFile.HashList[idxold].hashlow) - == 1) + if (Get2Bit(OldFile.CollTbl, OldFile.HashList[idxold].hashlow) == 1) { int searchforw = idxnow; int searchback = idxnow; - /* If the hash value is unique in both files... */ - /* ...search the line in the new file */ + /* + * If the hash value is unique in both files... + * ...search the line in the new file. + */ + while (searchforw < NowFile.hashentries || searchback > 0) { if (searchforw < NowFile.hashentries && - NowFile.HashList[searchforw++].hash == - OldFile.HashList[idxold].hash) + NowFile.HashList[searchforw++].hash == OldFile.HashList[idxold].hash) { idxnow = searchforw - 1; NowFile.HashList[idxnow].hash = 0; @@ -451,9 +562,9 @@ OldFile.HashList[idxold].lineno = idxnow; break; } + if (searchback > 0 && - NowFile.HashList[--searchback].hash == - OldFile.HashList[idxold].hash) + NowFile.HashList[--searchback].hash == OldFile.HashList[idxold].hash) { idxnow = searchback; NowFile.HashList[idxnow].hash = 0; @@ -467,31 +578,37 @@ idxold++; } - /* Step 2: Walk through the lines of the old file. If you hit an - unconnected line after connected lines, test whether in both - files the lines have the same hash value (it need not to be - unique, we just guess that lines with a non-unique hash value - after connected lines are also equal. In a second iteration, - connect lines before already connected lines. */ + /* + * Step 2: Walk through the lines of the old file. If you hit an + * unconnected line after connected lines, test whether in both + * files the lines have the same hash value (it need not to be + * unique, we just guess that lines with a non-unique hash value + * after connected lines are also equal. In a second iteration, + * connect lines before already connected lines. + */ /* Step 2a: go forward */ + synced = 1; idxold = idxnow = -1; - while (++idxold < OldFile.hashentries) /* Again, walk old file - step by step */ + + while (++idxold < OldFile.hashentries) { + /* Again, walk old file step by step */ + /* This line connected to a line in the new file? */ + if (ISCONNECTED(OldFile.HashList[idxold])) { - synced = 1; /* if yes, resynchronize... */ + /* if yes, resynchronize... */ + synced = 1; idxnow = OldFile.HashList[idxold].lineno; } else if (synced) { /* Do the hashes match? */ if (++idxnow < NowFile.hashentries && - NowFile.HashList[idxnow].hash == - OldFile.HashList[idxold].hash) + NowFile.HashList[idxnow].hash == OldFile.HashList[idxold].hash) { /* Yes, connect the lines! */ OldFile.HashList[idxold].hash = 0; @@ -500,19 +617,24 @@ NowFile.HashList[idxnow].lineno = idxold; } else + { /* No, fell out of sync */ synced = 0; + } } } - /* Step 2b: Now do the same thing again backwards, and test, - whether there are any connections - we need this information - later */ + /* + * Step 2b: Now do the same thing again backwards, and test, + * whether there are any connections - we need this information + * later. + */ synced = 1; foundConns = 0; idxold = OldFile.hashentries; idxnow = NowFile.hashentries; + while (--idxold >= 0) { if (ISCONNECTED(OldFile.HashList[idxold])) @@ -524,8 +646,7 @@ else if (synced) { if (--idxnow >= 0 && - NowFile.HashList[idxnow].hash == - OldFile.HashList[idxold].hash) + NowFile.HashList[idxnow].hash == OldFile.HashList[idxold].hash) { OldFile.HashList[idxold].hash = 0; NowFile.HashList[idxnow].hash = 0; @@ -533,38 +654,55 @@ NowFile.HashList[idxnow].lineno = idxold; } else + { synced = 0; + } } } - /* If you found connections, try in the next iteration with - datablocks directly after the last connection. */ + /* + * If you found connections, try in the next iteration with + * datablocks directly after the last connection. + */ if (StillData && foundConns) { while (!ISCONNECTED(OldFile.HashList[--OldFile.hashentries])) - ; + { + /* do nothing */ + } + OldFile.hashentries++; + while (!ISCONNECTED(NowFile.HashList[--NowFile.hashentries])) - ; + { + /* do nothing */ + } + NowFile.hashentries++; } WriteDiffPart(linebuf); } while (StillData); - free(OldFile.CollTbl); /* The start of the memory area */ + + /* The start of the memory area */ + free(OldFile.CollTbl); + fclose(OldFile.theFILE); fclose(NowFile.theFILE); fclose(DiffFILE); + if (cause == CAUSE_THRESHOLD) { - strcpy(filename, diffname); + strlcpy(filename, diffname, MYMAXPATH); + if (OutDiff[0] != 0) { cause = CAUSE_THRESHOLD | CAUSE_OUTDIFF; CopyOrMove(1, diffname, OutDir, OutDiff); } } + return cause; } diff -Nru makenl-3.3.3/src/mklog.c makenl-3.4.1/src/mklog.c --- makenl-3.3.3/src/mklog.c 2012-10-17 11:36:54.000000000 +0000 +++ makenl-3.4.1/src/mklog.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,145 +1,138 @@ -/* $Id: mklog.c,v 1.21 2012/10/17 11:36:54 ozzmosis Exp $ */ - -#include -#include -#include -#include -#include -#include - -#include "makenl.h" -#include "mklog.h" -#include "fileutil.h" -#include "os.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -int loglevel = 1; - -static char *logmark = "?+-dD"; - -static char *date_str(void) -{ - time_t now; - struct tm ptm; - static char buf[128]; - - now = time(NULL); - ptm = *localtime(&now); - strftime(buf, sizeof buf, "%d-%b-%Y %H:%M:%S", &ptm); - return buf; -} - -static void logwrite(int level, char *outstr) -{ - static int logopened = 0; - - FILE *log_fp; - FILE *std_fp; - int need_strerror; - - std_fp = stderr; - need_strerror = 0; - - if (*outstr == '$') - { - need_strerror = 1; - outstr++; - } - - /* write to stderr/stdout */ - - if (level == LOG_INFO) - { - std_fp = stdout; - } - - if (level < LOG_LOGONLY || debug_mode) - { - fprintf(std_fp, "%s", outstr); - - if (need_strerror) - { - fprintf(std_fp, ": %s\n", strerror(errno)); - } - else - { - fputc('\n', std_fp); - } - } - - if (!debug_mode && level == LOG_DEBUG && loglevel < 2) - { - /* - * if we're not running in debug mode (makenl -d), don't write - * debugging messages to the log file unless loglevel set to >1 - */ - return; - } - - if (*LogFile == '\0') - { - /* log filename was not set */ - return; - } - - /* write to logfile */ - - log_fp = fopen(LogFile, "a"); - - if (log_fp == NULL) - { - fprintf(stderr, "Cannot open logfile '%s'\n", LogFile); - exit(255); - } - - if (logopened == 0) - { - /* if this is the first log entry, write an empty line before it */ - logopened = 1; - fputc('\n', log_fp); - } - -#ifdef HAVE_GETPID - fprintf(log_fp, "%c %s makenl[%d] ", logmark[level], date_str(), getpid()); -#else - fprintf(log_fp, "%c %s makenl: ", logmark[level], date_str()); -#endif - - fprintf(log_fp, "%s", outstr); - - if (need_strerror) - { - fprintf(log_fp, ": %s\n", strerror(errno)); - } - else - { - fputc('\n', log_fp); - } - - fclose(log_fp); -} - -void mklog(int level, const char *format, ...) -{ - char outstr[4096]; - va_list va_ptr; - - if (format == NULL) - { - fprintf(stderr, "NULL format string for va_start()\n"); - exit(255); - } - - va_start(va_ptr, format); - vsnprintf(outstr, sizeof outstr, format, va_ptr); - va_end(va_ptr); - - logwrite(level, outstr); -} +/* $Id: mklog.c,v 1.24 2013/09/25 18:24:10 ozzmosis Exp $ */ + +#include +#include +#include +#include +#include +#include + +#include "makenl.h" +#include "mklog.h" +#include "fileutil.h" +#include "os.h" +#include "snprintf.h" + +int loglevel = 1; + +static char *logmark = "?+-dD"; + +static char *date_str(void) +{ + time_t now; + struct tm ptm; + static char buf[128]; + + now = time(NULL); + ptm = *localtime(&now); + strftime(buf, sizeof buf, "%d-%b-%Y %H:%M:%S", &ptm); + return buf; +} + +static void logwrite(int level, char *outstr) +{ + static int logopened = 0; + + FILE *log_fp; + FILE *std_fp; + int need_strerror; + + std_fp = stderr; + need_strerror = 0; + + if (*outstr == '$') + { + need_strerror = 1; + outstr++; + } + + /* write to stderr/stdout */ + + if (level == LOG_INFO) + { + std_fp = stdout; + } + + if (level < LOG_LOGONLY || debug_mode) + { + fprintf(std_fp, "%s", outstr); + + if (need_strerror) + { + fprintf(std_fp, ": %s\n", strerror(errno)); + } + else + { + fputc('\n', std_fp); + } + } + + if (!debug_mode && level == LOG_DEBUG && loglevel < 2) + { + /* + * if we're not running in debug mode (makenl -d), don't write + * debugging messages to the log file unless loglevel set to >1 + */ + return; + } + + if (*LogFile == '\0') + { + /* log filename was not set */ + return; + } + + /* write to logfile */ + + log_fp = fopen(LogFile, "a"); + + if (log_fp == NULL) + { + fprintf(stderr, "Cannot open logfile '%s'\n", LogFile); + exit(255); + } + + if (logopened == 0) + { + /* if this is the first log entry, write an empty line before it */ + logopened = 1; + fputc('\n', log_fp); + } + +#ifdef HAVE_GETPID + fprintf(log_fp, "%c %s makenl[%d] ", logmark[level], date_str(), (int) getpid()); +#else + fprintf(log_fp, "%c %s makenl: ", logmark[level], date_str()); +#endif + + fprintf(log_fp, "%s", outstr); + + if (need_strerror) + { + fprintf(log_fp, ": %s\n", strerror(errno)); + } + else + { + fputc('\n', log_fp); + } + + fclose(log_fp); +} + +void mklog(int level, const char *format, ...) +{ + char outstr[4096]; + va_list va_ptr; + + if (format == NULL) + { + fprintf(stderr, "NULL format string for va_start()\n"); + exit(255); + } + + va_start(va_ptr, format); + vsnprintf(outstr, sizeof outstr, format, va_ptr); + va_end(va_ptr); + + logwrite(level, outstr); +} diff -Nru makenl-3.3.3/src/msgtool.c makenl-3.4.1/src/msgtool.c --- makenl-3.3.3/src/msgtool.c 2012-10-23 04:48:29.000000000 +0000 +++ makenl-3.4.1/src/msgtool.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,334 +1,344 @@ -/* $Id: msgtool.c,v 1.14 2012/10/23 04:48:29 ajleary Exp $ */ - -#include -#include -#include -#include - -#include "makenl.h" -#include "fts5.h" -#include "msg.h" -#include "fileutil.h" -#include "mklog.h" -#include "version.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -#define MSG_CRASH 0x0002 -#define MSG_PRIVATE 0x0001 -#define MSG_FILE 0x0010 -#define MSG_KILLSENT 0x0080 -#define MSG_LOCAL 0x0100 -#define MSG_HOLD 0x0200 - - - -int UsualMSGFlags; -int MailerFlags; -int NotifyAddress[3]; -int SubmitAddress[3]; -int MyAddress[3]; - -static int MSGnum; -static FILE *MailFILE; -int *FixStack; -static int MSGFlags; -static unsigned char msgbuf[0xbe]; - -/* - * Get unique sequence number - */ -static unsigned long GetSequence(void) -{ - unsigned long seq; - char seqfile[MYMAXDIR]; - FILE *fp; - sprintf(seqfile, "%s/sequence.dat", MasterDir); - - if ((fp = fopen(seqfile, "r+")) == NULL) { - seq = (unsigned long)time(NULL); - if ((fp = fopen(seqfile, "w+")) == NULL) { - mklog(LOG_ERROR, "Can't create %s", seqfile); - return seq; - } else { - fwrite(&seq, 1, sizeof(seq), fp); - fclose(fp); - return seq; - } - } else { - fread(&seq, 1, sizeof(seq), fp); - seq++; - fseek(fp, 0, SEEK_SET); - fwrite(&seq, 1, sizeof(seq), fp); - fclose(fp); - } - return seq; -} - - - -// static -int SearchMaxMSG(const char *path) -{ - char *filename; - int maxnum = 0; - int aktnum; - struct _filefind f; - char searchmask[MYMAXDIR]; - - myfnmerge(searchmask, NULL, NULL, "*", "msg"); - for (filename = os_findfirst(&f, path, searchmask); - filename != NULL; filename = os_findnext(&f)) - { - getnumber(filename, &aktnum); - if (aktnum > maxnum) - maxnum = aktnum; - } - os_findclose(&f); - - mklog(LOG_DEBUG, "SearchMaxMSG: path=%s, result=%d", make_str_safe(path), maxnum); - return maxnum; -} - - -int ParseAddress(const char *string, int out[3]) -{ - char foo[2]; - int temp[3]; - - foo[0] = 0; - if (sscanf - (string, "%d:%d/%d%1s", &temp[A_ZONE], &temp[A_NET], &temp[A_NODE], - foo) == 3) - { - if (foo[0] != 0 || temp[A_ZONE] == 0 || temp[A_NET] == 0) - return -1; - } - else if (sscanf(string, "%d/%d%1s", &temp[A_NET], &temp[A_NODE], foo) - == 2) - { - temp[A_ZONE] = 0; - if (foo[0] != 0) - return -1; - if (temp[A_NET] == 0) - return -1; - } - else if (sscanf(string, "%d%1s", &temp[A_NODE], foo) != 0) - { - if (foo[0] != 0) - return -1; - temp[A_NET] = 0; - temp[A_ZONE] = 0; - } - else - return -1; - memcpy(out, temp, 3 * sizeof(int)); - - return 0; -} - -static char *MakeMSGFilename(char *outbuf, int num) -{ - char buffer[6]; - - sprintf(buffer, "%u", num); - myfnmerge(outbuf, NULL, MessageDir, buffer, "msg"); - mklog(LOG_DEBUG, "MakeMSGFilenam: num=%d MSGnum=%d", num, MSGnum); - return outbuf; -} - -FILE *OpenMSGFile(int address[3], char *filename) -{ - /* static char *DOWNames[] = - { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; */ - /* Unused - now using FTS-1 date/time field vs. SEAdog format */ - static char *MonthNames[12] = - { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - time_t akt_time; - struct tm *the_time; - char intlline[46]; - char filenamebuf[MYMAXDIR], subject[72], date[21]; - int intl, temp; - - FixStack = NULL; /* BUGFIXED 2012-06-28 us filepointer/stack fix */ - - mklog(LOG_DEBUG, "OpenMSGFile entered"); // MB - mklog(LOG_DEBUG, "OpenMSGFile: %d:%d/%d filename=%s", address[A_ZONE], - address[A_NET], address[A_NODE], make_str_safe(filename)); - - mklog(LOG_DEBUG, "SearchMaxMSG(%s)", MessageDir); // MB - MSGnum = SearchMaxMSG(MessageDir); - mklog(LOG_DEBUG, "OpenMSGFile: MSGnum is set to %d", MSGnum); - - memset(&filenamebuf, 0, sizeof(filenamebuf)); - memset(&msgbuf, 0, sizeof(msgbuf)); - - memcpy(&msgbuf[0x00], (char *)"MakeNL ", 7); - memcpy(&msgbuf[0x07], MAKENL_VERSION, sizeof(MAKENL_VERSION)); - memcpy(&msgbuf[0x24], (char *)"Coordinator", 11); - - if (filename) - { - sprintf(subject, "%s", filename); - MSGFlags = (MailerFlags & MF_SUBMIT) >> MF_SHIFT_SUBMIT; - temp = (MSGFlags & MF_CRASH ? MSG_CRASH : 0) | - (MSGFlags & MF_HOLD ? MSG_HOLD : 0) | - MSG_PRIVATE | MSG_FILE | MSG_KILLSENT | MSG_LOCAL; - } - else - { - temp = MSG_PRIVATE | MSG_KILLSENT | MSG_LOCAL; - sprintf(subject, "%s received", WorkFile); - MSGFlags = UsualMSGFlags; - } - memcpy(&msgbuf[0x48], subject, strlen(subject)); - - time(&akt_time); - the_time = localtime(&akt_time); - /* BUG FIXED: Y2K-bug changed tm_year to tm_year % 100 and its format - * to %02d */ - sprintf(date, "%02d %s %02d %02d:%02d:%02d", - the_time->tm_mday, MonthNames[the_time->tm_mon], - the_time->tm_year % 100, the_time->tm_hour, the_time->tm_min, - the_time->tm_sec); /* Switch to FTS-1 date/time vs. SEAdog */ - memcpy(&msgbuf[0x90], date, 20); - msgbuf[0xba] = (unsigned char)(temp & 0x00ff); /* Attribute */ - msgbuf[0xbb] = (unsigned char)((temp & 0xff00) >> 8); - - if (!MSGFlags) - return (MailFILE = NULL); - if (!address[A_ZONE]) - address[A_ZONE] = MyAddress[A_ZONE]; - if (MyAddress[A_ZONE] == address[A_ZONE]) - { - intlline[0] = 0; - msgbuf[0xae] = (unsigned char)(address[A_NET] & 0x00ff); /* destNet */ - msgbuf[0xaf] = (unsigned char)((address[A_NET] & 0xff00) >> 8); - msgbuf[0xa6] = (unsigned char)(address[A_NODE] & 0x00ff); /* destNode */ - msgbuf[0xa7] = (unsigned char)((address[A_NODE] & 0xff00) >> 8); - msgbuf[0xb0] = (unsigned char)(address[A_ZONE] & 0x00ff); /* destZone */ - msgbuf[0xb1] = (unsigned char)((address[A_ZONE] & 0xff00) >> 8); - intl = MailerFlags & (MF_INTL | - (MF_INTL << MF_SHIFT_ERRORS) | - (MF_INTL << MF_SHIFT_SUBMIT)); - } - else - { - msgbuf[0xae] = (unsigned char)(MyAddress[A_ZONE] & 0x00ff); /* destNet */ - msgbuf[0xaf] = (unsigned char)((MyAddress[A_ZONE] & 0xff00) >> 8); - msgbuf[0xa6] = (unsigned char)(address[A_ZONE] & 0x00ff); /* destNode */ - msgbuf[0xa7] = (unsigned char)((address[A_ZONE] & 0xff00) >> 8); - msgbuf[0xb0] = (unsigned char)(MyAddress[A_ZONE] & 0x00ff); /* destZone */ - msgbuf[0xb1] = (unsigned char)((MyAddress[A_ZONE] & 0xff00) >> 8); - intl = 1; - } - - msgbuf[0xa8] = (unsigned char)(MyAddress[A_NODE] & 0x00ff); /* origNode */ - msgbuf[0xa9] = (unsigned char)((MyAddress[A_NODE] & 0xff00) >> 8); - msgbuf[0xac] = (unsigned char)(MyAddress[A_NET] & 0x00ff); /* origNet */ - msgbuf[0xad] = (unsigned char)((MyAddress[A_NET] & 0xff00) >> 8); - msgbuf[0xb2] = (unsigned char)(MyAddress[A_ZONE] & 0x00ff); /* origZone */ - msgbuf[0xb3] = (unsigned char)((MyAddress[A_ZONE] & 0xff00) >> 8); - - if (intl) - { - if (MyAddress[A_ZONE] == 0) - { - mklog(LOG_INFO, "WARNING -- Don't know your zone, can't send interzone message to %d:%d/%d", - address[A_ZONE], address[A_NET], address[A_NODE]); - return (MailFILE = NULL); - } - sprintf(intlline, "\x01INTL %d:%d/%d %d:%d/%d\r\n", address[A_ZONE], - address[A_NET], address[A_NODE], MyAddress[A_ZONE], - MyAddress[A_NET], MyAddress[A_NODE]); - } - MailFILE = fopen(MakeMSGFilename(filenamebuf, MSGnum + 1), "wb"); - if (!MailFILE) - die(254, "Cannot create %s", filenamebuf); - MSGnum++; - mklog(LOG_DEBUG, "OpenMSGFile: opened %s, MSGnum %d", filenamebuf, MSGnum); - - fwrite(&msgbuf, sizeof(msgbuf), 1, MailFILE); - fputs(intlline, MailFILE); - fprintf(MailFILE, "\x01MSGID: %d:%d/%d %08lx\r\n", MyAddress[A_ZONE], - MyAddress[A_NET], MyAddress[A_NODE], GetSequence()); - if (!filename) - { - mklog(LOG_DEBUG, "OpenMSGFile: return with open MailFILE"); - return MailFILE; - } - fclose(MailFILE); - mklog(LOG_DEBUG, "OpenMSGFile: closed, seems Ok"); - return (FILE *) ! NULL; /* Just say OK - but it *smells* */ -} - - - -FILE *CloseMSGFile(int status) -{ - char filename[MYMAXDIR]; - int i, temp; - - mklog(LOG_DEBUG, "CloseMSGFile: status=%d", status); - - if (MailFILE != NULL) - { - mklog(LOG_DEBUG, "CloseMSGFile: MailFILE is open"); - if (status >= 0) - { - if (status != 0) - { - MSGFlags >>= MF_SHIFT_ERRORS; /* Use the error flags */ - for (i = 0x48; i; i++) /* Search end of subject */ - { - if (msgbuf[i] == '\0') - { - break; - } - } - memcpy(&msgbuf[i], " with errors\0", 13); - } - else - { - MSGFlags &= MF_RECEIPT; - } - if (MSGFlags) - { - mklog(LOG_DEBUG, "CloseMSGFile: MSGFlags != 0"); - putc(0, MailFILE); - fseek(MailFILE, 0L, SEEK_SET); - temp = (msgbuf[0xbb] << 8) + msgbuf[0xba]; /* Get current - .MSG flags */ - temp |= - (MSGFlags & MF_CRASH ? MSG_CRASH : 0) | (MSGFlags & - MF_HOLD ? - MSG_HOLD : 0); - /* Add CRASH - or HOLD - if needed */ - msgbuf[0xba] = (unsigned char)(temp & 0x00ff); /* Attribute */ - msgbuf[0xbb] = (unsigned char)((temp & 0xff00) >> 8); - fwrite(&msgbuf, sizeof(msgbuf), 1, MailFILE); - } - else - status = -1; - } - mklog(LOG_DEBUG, "CloseMSGFile: closing file, status is now %d, MSGnum=%d", status, MSGnum); - fclose(MailFILE); - if (status < 0) - { - unlink(MakeMSGFilename(filename, MSGnum--)); - mklog(LOG_DEBUG, "CloseMSGFile: unlink %s", filename); - } - } - mklog(LOG_DEBUG, "CloseMSGFile: MSGnum=%d", MSGnum); - MailFILE = NULL; - return MailFILE; -} +/* $Id: msgtool.c,v 1.21 2013/09/25 19:29:56 ozzmosis Exp $ */ + +#include +#include +#include +#include + +#include "makenl.h" +#include "fts5.h" +#include "msg.h" +#include "fileutil.h" +#include "mklog.h" +#include "version.h" +#include "strtool.h" +#include "snprintf.h" + +#define MSG_CRASH 0x0002 +#define MSG_PRIVATE 0x0001 +#define MSG_FILE 0x0010 +#define MSG_KILLSENT 0x0080 +#define MSG_LOCAL 0x0100 +#define MSG_HOLD 0x0200 + +int UsualMSGFlags; +int MailerFlags; +int NotifyAddress[3]; +int SubmitAddress[3]; +int MyAddress[3]; + +static int MSGnum; +static FILE *MailFILE; +static int MSGFlags; +static unsigned char msgbuf[0xbe]; + +/* + * Get unique sequence number + */ +static unsigned long GetSequence(void) +{ + unsigned long seq; + char seqfile[MYMAXDIR]; + FILE *fp; + snprintf(seqfile, sizeof seqfile, "%s/sequence.dat", MasterDir); + + if ((fp = fopen(seqfile, "r+")) == NULL) { + seq = (unsigned long)time(NULL); + if ((fp = fopen(seqfile, "w+")) == NULL) { + mklog(LOG_ERROR, "Can't create %s", seqfile); + return seq; + } else { + fwrite(&seq, 1, sizeof(seq), fp); + fclose(fp); + return seq; + } + } else { + fread(&seq, 1, sizeof(seq), fp); + seq++; + fseek(fp, 0, SEEK_SET); + fwrite(&seq, 1, sizeof(seq), fp); + fclose(fp); + } + return seq; +} + + + +static int SearchMaxMSG(const char *path) +{ + char *filename; + int maxnum; + int aktnum; + struct _filefind f; + char searchmask[MYMAXDIR]; + + maxnum = 0; + myfnmerge(searchmask, NULL, NULL, "*", "msg"); + filename = os_findfirst(&f, path, searchmask); + + while (filename != NULL) + { + getnumber(filename, &aktnum); + if (aktnum > maxnum) + { + maxnum = aktnum; + } + filename = os_findnext(&f); + } + os_findclose(&f); + + mklog(LOG_DEBUG, "SearchMaxMSG: path=%s, result=%d", make_str_safe(path), maxnum); + + return maxnum; +} + + +int ParseAddress(const char *string, int out[3]) +{ + char foo[2]; + int temp[3]; + + foo[0] = 0; + if (sscanf + (string, "%d:%d/%d%1s", &temp[A_ZONE], &temp[A_NET], &temp[A_NODE], + foo) == 3) + { + if (foo[0] != 0 || temp[A_ZONE] == 0 || temp[A_NET] == 0) + return -1; + } + else if (sscanf(string, "%d/%d%1s", &temp[A_NET], &temp[A_NODE], foo) + == 2) + { + temp[A_ZONE] = 0; + if (foo[0] != 0) + return -1; + if (temp[A_NET] == 0) + return -1; + } + else if (sscanf(string, "%d%1s", &temp[A_NODE], foo) != 0) + { + if (foo[0] != 0) + return -1; + temp[A_NET] = 0; + temp[A_ZONE] = 0; + } + else + return -1; + memcpy(out, temp, 3 * sizeof(int)); + + return 0; +} + +static char *MakeMSGFilename(char *outbuf, int num) +{ + char buffer[MYMAXDIR]; + + snprintf(buffer, sizeof buffer, "%u", num); + myfnmerge(outbuf, NULL, MessageDir, buffer, "msg"); + mklog(LOG_DEBUG, "MakeMSGFilename: num=%d MSGnum=%d", num, MSGnum); + return outbuf; +} + +FILE *OpenMSGFile(int address[3], char *filename) +{ + /* static char *DOWNames[] = + { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; */ + /* Unused - now using FTS-1 date/time field vs. SEAdog format */ + static char *MonthNames[12] = + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + time_t akt_time; + struct tm *the_time; + char intlline[46]; + char filenamebuf[MYMAXDIR], subject[72], date[21]; + int intl, temp; + + mklog(LOG_DEBUG, "OpenMSGFile entered"); + mklog(LOG_DEBUG, "OpenMSGFile: %d:%d/%d filename=%s", address[A_ZONE], + address[A_NET], address[A_NODE], make_str_safe(filename)); + + mklog(LOG_DEBUG, "SearchMaxMSG('%s')", MessageDir); + MSGnum = SearchMaxMSG(MessageDir); + mklog(LOG_DEBUG, "OpenMSGFile: MSGnum is set to %d", MSGnum); + + memset(&filenamebuf, 0, sizeof(filenamebuf)); + memset(&msgbuf, 0, sizeof(msgbuf)); + + memcpy(&msgbuf[0x00], (char *)"MakeNL ", 7); + memcpy(&msgbuf[0x07], MAKENL_VERSION, sizeof(MAKENL_VERSION)); + memcpy(&msgbuf[0x24], (char *)"Coordinator", 11); + + if (filename) + { + snprintf(subject, sizeof subject, "%s", filename); + MSGFlags = (MailerFlags & MF_SUBMIT) >> MF_SHIFT_SUBMIT; + temp = (MSGFlags & MF_CRASH ? MSG_CRASH : 0) | + (MSGFlags & MF_HOLD ? MSG_HOLD : 0) | + MSG_PRIVATE | MSG_FILE | MSG_KILLSENT | MSG_LOCAL; + } + else + { + temp = MSG_PRIVATE | MSG_KILLSENT | MSG_LOCAL; + snprintf(subject, sizeof subject, "%s received", WorkFile); + MSGFlags = UsualMSGFlags; + } + memcpy(&msgbuf[0x48], subject, strlen(subject)); + + time(&akt_time); + the_time = localtime(&akt_time); + /* BUG FIXED: Y2K-bug changed tm_year to tm_year % 100 and its format + * to %02d */ + snprintf(date, sizeof date, "%02d %s %02d %02d:%02d:%02d", + the_time->tm_mday, MonthNames[the_time->tm_mon], + the_time->tm_year % 100, the_time->tm_hour, the_time->tm_min, + the_time->tm_sec); /* Switch to FTS-1 date/time vs. SEAdog */ + memcpy(&msgbuf[0x90], date, 20); + msgbuf[0xba] = (unsigned char)(temp & 0x00ff); /* Attribute */ + msgbuf[0xbb] = (unsigned char)((temp & 0xff00) >> 8); + + if (!MSGFlags) + return (MailFILE = NULL); + if (!address[A_ZONE]) + address[A_ZONE] = MyAddress[A_ZONE]; + if (MyAddress[A_ZONE] == address[A_ZONE]) + { + intlline[0] = 0; + msgbuf[0xae] = (unsigned char)(address[A_NET] & 0x00ff); /* destNet */ + msgbuf[0xaf] = (unsigned char)((address[A_NET] & 0xff00) >> 8); + msgbuf[0xa6] = (unsigned char)(address[A_NODE] & 0x00ff); /* destNode */ + msgbuf[0xa7] = (unsigned char)((address[A_NODE] & 0xff00) >> 8); + msgbuf[0xb0] = (unsigned char)(address[A_ZONE] & 0x00ff); /* destZone */ + msgbuf[0xb1] = (unsigned char)((address[A_ZONE] & 0xff00) >> 8); + intl = MailerFlags & (MF_INTL | + (MF_INTL << MF_SHIFT_ERRORS) | + (MF_INTL << MF_SHIFT_SUBMIT)); + } + else + { + msgbuf[0xae] = (unsigned char)(MyAddress[A_ZONE] & 0x00ff); /* destNet */ + msgbuf[0xaf] = (unsigned char)((MyAddress[A_ZONE] & 0xff00) >> 8); + msgbuf[0xa6] = (unsigned char)(address[A_ZONE] & 0x00ff); /* destNode */ + msgbuf[0xa7] = (unsigned char)((address[A_ZONE] & 0xff00) >> 8); + msgbuf[0xb0] = (unsigned char)(MyAddress[A_ZONE] & 0x00ff); /* destZone */ + msgbuf[0xb1] = (unsigned char)((MyAddress[A_ZONE] & 0xff00) >> 8); + intl = 1; + } + + msgbuf[0xa8] = (unsigned char)(MyAddress[A_NODE] & 0x00ff); /* origNode */ + msgbuf[0xa9] = (unsigned char)((MyAddress[A_NODE] & 0xff00) >> 8); + msgbuf[0xac] = (unsigned char)(MyAddress[A_NET] & 0x00ff); /* origNet */ + msgbuf[0xad] = (unsigned char)((MyAddress[A_NET] & 0xff00) >> 8); + msgbuf[0xb2] = (unsigned char)(MyAddress[A_ZONE] & 0x00ff); /* origZone */ + msgbuf[0xb3] = (unsigned char)((MyAddress[A_ZONE] & 0xff00) >> 8); + + if (intl) + { + if (MyAddress[A_ZONE] == 0) + { + mklog(LOG_INFO, "WARNING -- Don't know your zone, can't send interzone message to %d:%d/%d", + address[A_ZONE], address[A_NET], address[A_NODE]); + return (MailFILE = NULL); + } + snprintf(intlline, sizeof intlline, "\x01INTL %d:%d/%d %d:%d/%d\r\n", address[A_ZONE], + address[A_NET], address[A_NODE], MyAddress[A_ZONE], + MyAddress[A_NET], MyAddress[A_NODE]); + } + MailFILE = fopen(MakeMSGFilename(filenamebuf, MSGnum + 1), "wb"); + if (!MailFILE) + die(254, "Cannot create %s", filenamebuf); + MSGnum++; + mklog(LOG_DEBUG, "OpenMSGFile: opened %s, MSGnum %d", filenamebuf, MSGnum); + + fwrite(&msgbuf, sizeof(msgbuf), 1, MailFILE); + fputs(intlline, MailFILE); + fprintf(MailFILE, "\x01MSGID: %d:%d/%d %08lx\r\n", MyAddress[A_ZONE], + MyAddress[A_NET], MyAddress[A_NODE], GetSequence()); + if (!filename) + { + mklog(LOG_DEBUG, "OpenMSGFile: return with open MailFILE"); + return MailFILE; + } + fclose(MailFILE); + mklog(LOG_DEBUG, "OpenMSGFile: closed, seems Ok"); + + /* + * Fell through. The file is now closed but we still want to return + * "success" using a non-NULL pointer, so we'll use stdout. This + * replaces an awful hack with a slightly less-awful hack. + * + * At least now, if the calling function tries to write to the file + * pointed to by the returned value it should just send output to the + * screen, instead of segfaulting. + * + * The program may still segfault if the code tries to read input + * from stdout. I'd need to check the C Standard about that... + * + * - ozzmosis 2013-09-04 + */ + + return stdout; +} + + + +FILE *CloseMSGFile(int status) +{ + char filename[MYMAXDIR]; + int i, temp; + + mklog(LOG_DEBUG, "CloseMSGFile: status=%d", status); + + if (MailFILE != NULL) + { + mklog(LOG_DEBUG, "CloseMSGFile: MailFILE is open"); + if (status >= 0) + { + if (status != 0) + { + MSGFlags >>= MF_SHIFT_ERRORS; /* Use the error flags */ + for (i = 0x48; i; i++) /* Search end of subject */ + { + if (msgbuf[i] == '\0') + { + break; + } + } + memcpy(&msgbuf[i], " with errors\0", 13); + } + else + { + MSGFlags &= MF_RECEIPT; + } + if (MSGFlags) + { + mklog(LOG_DEBUG, "CloseMSGFile: MSGFlags != 0"); + putc(0, MailFILE); + fseek(MailFILE, 0L, SEEK_SET); + temp = (msgbuf[0xbb] << 8) + msgbuf[0xba]; /* Get current + .MSG flags */ + temp |= + (MSGFlags & MF_CRASH ? MSG_CRASH : 0) | (MSGFlags & + MF_HOLD ? + MSG_HOLD : 0); + /* Add CRASH + or HOLD + if needed */ + msgbuf[0xba] = (unsigned char)(temp & 0x00ff); /* Attribute */ + msgbuf[0xbb] = (unsigned char)((temp & 0xff00) >> 8); + fwrite(&msgbuf, sizeof(msgbuf), 1, MailFILE); + } + else + status = -1; + } + mklog(LOG_DEBUG, "CloseMSGFile: closing file, status is now %d, MSGnum=%d", status, MSGnum); + fclose(MailFILE); + if (status < 0) + { + unlink(MakeMSGFilename(filename, MSGnum--)); + mklog(LOG_DEBUG, "CloseMSGFile: unlink %s", filename); + } + } + mklog(LOG_DEBUG, "CloseMSGFile: MSGnum=%d", MSGnum); + MailFILE = NULL; + return MailFILE; +} diff -Nru makenl-3.3.3/src/os.c makenl-3.4.1/src/os.c --- makenl-3.3.3/src/os.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/os.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,62 +1,1187 @@ -/* os.c -- Operating system dependant functions for makenl */ - -/* $Id: os.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ +/* $Id: os.c,v 1.48 2013/09/29 15:53:50 ozzmosis Exp $ */ #include +#include #include -#include "fileutil.h" -#include "makenl.h" +#include +#include +#include +#include + #include "os.h" + +#if defined(OS_UNIX) || defined(__DJGPP__) || defined(__EMX__) +#include +#ifdef __linux__ +/* _GNU_SOURCE needed for FNM_CASEFOLD */ +#define _GNU_SOURCE +#endif +#include +#endif + +#ifdef __TURBOC__ +#include +#endif + +#ifdef __BORLANDC__ +#include +#include +#endif + +#include "fileutil.h" +#include "snprintf.h" +#include "strtool.h" #include "mklog.h" +#include "unused.h" -#ifdef MALLOC_DEBUG -#include "rmalloc.h" +char *os_file_getname(const char *path) +{ +#ifdef __EMX__ + return _getname(path); +#else + const char *p; + + p = path; + + while (*path != 0) + { + switch (*path++) + { + case ':': + case '/': + case '\\': + p = path; /* Note that PATH has been incremented */ + break; + } + } + + return (char *)p; #endif +} + +/* + * os_chdir() + * + * Workaround for systems where chdir() will not accept a trailing \ character unless + * it's the root of the drive. + */ + +#if defined(OS_DOS) || defined(OS_OS2) || defined(OS_WIN) + +static char driveletters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +static int isvaliddriveletter(int drive) +{ + return strchr(driveletters, toupper(drive)) != NULL; +} + +static int drvlet2num(char drvletter) +{ + return (strchr(driveletters, toupper(drvletter)) - driveletters + 1); +} + +int os_getdrive(void) +{ + /* Returns the current drive number (A:=1, B:=2, etc.) */ + #if defined (__EMX__) + return drvlet2num(_getdrive()); + #elif defined (__DJGPP__) || defined (__TURBOC__) + return getdisk() + 1; /* DJGPP/TC getdisk() drive numbers are 0 based. */ + #elif defined (__WATCOMC__) + unsigned drive; + _dos_getdrive(&drive); + return drive; + #else + return _getdrive(); + #endif +} + +int os_chdrive(int newdrv) +{ + /* EMX _chdrive() needs drive letter instead of number */ + #if defined (__EMX__) + char reqdrv; + int rc; + reqdrv = driveletters[newdrv - 1]; + rc = _chdrive(reqdrv); + return (_getdrive() != reqdrv); /* Check to make sure disk change + succeeded - return 0 for success + or 1 for failure. */ + + #elif defined (__DJGPP__) || (defined (__TURBOC__) && !defined (__BORLANDC__)) + setdisk(newdrv - 1); + return (getdisk() != (newdrv - 1)); /* Check to make sure disk change + succeeded - return 0 for success + or 1 for failure. */ + + #elif defined (__WATCOMC__) + unsigned drive, total; + _dos_setdrive(newdrv, &total); + _dos_getdrive(&drive); + return (drive != newdrv); + + #else + return _chdrive(newdrv); + #endif +} + + +int os_chdir(char *path) +{ + char *newpath; + int rc; + int curdrv; + int newdrv; + + mklog(LOG_DEBUG, "os_chdir(): path='%s'", path); + + if (path == NULL || path[0] == '\0') + { + /* null pointer or empty string; do nothing */ + return 0; + } + + if (path[0] == '\\' && path[1] == '\0') + { + /* lone '\' path is OK */ + return chdir(path); + } + /* Get the current drive */ + curdrv = os_getdrive(); + mklog(LOG_DEBUG, "os_chdir(): curdrv='%d' (%c:)", curdrv, driveletters[curdrv - 1]); + + if (isvaliddriveletter(path[0]) && path[1] == ':' && path[2] == '\\' && path[3] == '\0') + { + /* "x:\" is OK too, but we need to check if we are changing drives. */ + + if (drvlet2num(path[0]) != curdrv) + { + /* Path specified is not on current drive. */ + + newdrv = drvlet2num(path[0]); + mklog(LOG_DEBUG, "os_chdir(): newdrv='%d' (%c:)", newdrv, driveletters[curdrv - 1]); + if (os_chdrive(newdrv)) + { + /* Failed to change drives! */ + + mklog(LOG_DEBUG, "os_chdir(): os_chdrive('%d') failed!", newdrv); + return 1; + } + } + return chdir(path); + } + + /* copy path and modify it */ + + newpath = malloc(strlen(path) + 1); + + if (newpath == NULL) + { + /* out of memory */ + return 1; + } + + strlcpy(newpath, path, strlen(path) + 1); + + /* strip trailing \ */ + os_remove_slash(newpath); + + mklog(LOG_DEBUG, "os_chdir(): newpath='%s'", newpath); + + /* Check if we are changing drives. */ + + if (isvaliddriveletter(newpath[0]) && newpath[1] == ':') + { + /* Drive letter at start of path. */ + + if (drvlet2num(newpath[0]) != curdrv) + { + /* We are changing drives. */ + + newdrv = drvlet2num(newpath[0]); + mklog(LOG_DEBUG, "os_chdir(): newdrv='%d' (%c:)", newdrv, driveletters[newdrv - 1]); + if (os_chdrive(newdrv)) + { + /* Failed to change drives! */ + + mklog(LOG_DEBUG, "os_chdir(): os_chdrive('%d') failed!", newdrv); + return 1; + } + } + } + rc = chdir(newpath); + free(newpath); + return rc; +} + +#else + +int os_chdir(char *path) +{ + return chdir(path); +} -#ifdef DMALLOC -#include "dmalloc.h" #endif -/* Definitions for: */ -/* __GNUC__ GNU C Compiler under DOS and OS/2 and linux */ -/* __unix__ GNU C Compiler under Unix (tested with linux) */ -/* __EMX__ emx+gcc for DOS/OS2 */ -/* __WATCOMC__ Watcom C Compiler 10.0b under DOS, OS/2 and Win32 */ -/* __TURBOC__ Turbo C 2.00 and above, Borland C, under DOS */ +/* + * os_append_slash() + * + * It is assumed that path has enough room for the slash. + */ -#ifndef OSFUL -#error "No os_fullpath for this compiler/OS, giving up!" +char *os_append_slash(char *path) +{ + char *p; + + if (path == NULL) + { + return NULL; + } + + p = strchr(path, '\0'); + + if (p > path) + { + p--; + + if (*p != '\\' && *p != '/') + { + *(++p) = DIRSEP[0]; + *(++p) = '\0'; + } + } + + return path; +} + + +/* + * os_remove_slash() + * + * Remove slash/backslash from last part of path name, if present. + */ + +char *os_remove_slash(char *path) +{ + char *new_path, *p; + + if (path == NULL) + { + return NULL; + } + + new_path = path; + +#if defined(OS_DOS) || defined(OS_OS2) || defined(OS_WIN) + if (*new_path && new_path[1] == ':') + { + /* skip drive letter */ + new_path += 2; + } #endif -#include OSFUL -#ifndef OSFND -#error "No os_findfirst/os_findnext/os_findclose for this compiler/OS, giving up!" + p = strchr(new_path, '\0'); + + if (p > new_path) + { + p--; + + if (p > new_path && (*p == '\\' || *p == '/')) + { + *p = '\0'; + } + } + + return path; +} + + +/* + * os_dirsep() + * + * On DOS, OS/2 & Windows systems this converts / slashes to \ backslashes + * in pathnames. On other systems it does nothing. + */ + +char *os_dirsep(char *path) +{ +#if defined(OS_DOS) || defined(OS_OS2) || defined(OS_WIN) + char *p; + + if (path == NULL) + { + return NULL; + } + + p = path; + + while (*p != 0) + { + if (*p == '/') + { + *p = '\\'; + } + p++; + } #endif -#include OSFND + return path; +} + +int os_spawn(const char *command, const char *cmdline) +{ +#ifdef __EMX__ + char execfn[_MAX_PATH]; + char tmpfn[_MAX_PATH]; + char *pext; + char *cmd; + int bufsize; + int rc; + + /* search for command */ + strlcpy(tmpfn, command, sizeof tmpfn); + pext = strchr(tmpfn, '\0'); + + mklog(LOG_DEBUG, "os_spawn(): trying `%s'", tmpfn); + rc = _path(execfn, tmpfn); + + if (rc != 0) + { + strcpy(pext, ".EXE"); + mklog(LOG_DEBUG, "os_spawn(): trying `%s'", tmpfn); + rc = _path(execfn, tmpfn); + } + else if (rc != 0 && _osmode == OS2_MODE) + { + strcpy(pext, ".CMD"); + mklog(LOG_DEBUG, "os_spawn(): trying `%s'", tmpfn); + rc = _path(execfn, tmpfn); + } + else if (rc != 0 && _osmode != OS2_MODE) + { + strcpy(pext, ".COM"); + mklog(LOG_DEBUG, "os_spawn(): trying `%s'", tmpfn); + rc = _path(execfn, tmpfn); + } + else if (rc != 0 && _osmode != OS2_MODE) + { + strcpy(pext, ".BAT"); + mklog(LOG_DEBUG, "os_spawn(): trying `%s'", tmpfn); + rc = _path(execfn, tmpfn); + } + else if (rc != 0) + { + mklog(LOG_ERROR, "os_spawn(): program not found"); + return -1; + } + + bufsize = strlen(command) + 1 + strlen(cmdline) + 1; + cmd = malloc(bufsize); -/* os_deslashify */ -#include OSDSL -/* os_fulldir */ -#include OSFLD -/* os_findfile */ -#include OSFF -/* os_append_slash */ -#include OSAPS -/* os_remove_slash */ -#include OSRMS -/* os_file_getname */ -#include OSGTN -/* os_spawn */ -#include OSEXC -/* os_file_canonify */ -#include OSCAN + if (!cmd) + { + return -1; + } -#ifndef HAVE_STRUPR -#include "osgenupr.c" + snprintf(cmd, bufsize, "%s %s", command, cmdline); + mklog(LOG_DEBUG, "found: executing `%s'", cmd); + rc = system(cmd); + mklog(LOG_DEBUG, "os_spawn() rc=%d", rc); + + free(cmd); + return rc; +#else + char *cmd; + int rc; + int bufsize; + + bufsize = strlen(command) + 1 + strlen(cmdline) + 1; + cmd = malloc(bufsize); + + if (!cmd) + { + mklog(LOG_ERROR, "os_spawn(): out of memory for command line buffer"); + return -1; + } + + snprintf(cmd, bufsize, "%s %s", command, cmdline); + mklog(LOG_DEBUG, "os_spawn(): %s", cmd); + rc = system(cmd); + mklog(LOG_DEBUG, "os_spawn(): rc=%d", rc); + + free(cmd); + return rc; #endif +} + +char *os_findfile(struct _filefind *pff, const char *path, const char *mask) +{ + char *p; + + p = os_findfirst(pff, path, mask); + + if (p != NULL) + { + strcpy(pff->path, p); + os_findclose(pff); + return pff->path; + } + + return NULL; +} + +/* + * os_fulldir() + * + * Make an absolute path from given relative path. + * src should specify an existing directory name. + */ + +int os_fulldir(char *dst, const char *src, size_t bufsiz) +{ + char tmp[MYMAXPATH]; + struct stat st; + int rc; + + mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): called with src='%s'", src); + + strlcpy(tmp, src, sizeof tmp); + os_remove_slash(tmp); + mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): after removing slash: '%s'", tmp); + + if (os_fullpath(dst, tmp, bufsiz) != 0) + { + mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): os_fullpath() failed!"); + return -1; + } + + mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): absolute path '%s'", dst); + + rc = stat(dst, &st); + + if (rc != 0) + { + mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): stat('%s') rc=%d!", dst, rc); + return -1; + } + + mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): st_mode is now %o", st.st_mode); + +#ifdef __TURBOC__ +#ifndef S_ISDIR +#define S_ISDIR(m) ((m) & S_IFDIR) +#endif + return S_ISDIR(st.st_mode) ? 0 : -1; +#elif defined(__IBMC__) + return st.st_mode & S_IFDIR ? 0 : -1; +#else + return ((st.st_mode & S_IFMT) == S_IFDIR) ? 0 : -1; +#endif +} + +#if defined(OS_UNIX) + +char *os_fgets(char *buffer, size_t len, FILE * f) +{ + char *result; + + result = fgets(buffer, len, f); + + /* + * If we see an EOF at the beinning of a line, then make it look as + * if we didn't read anything. + */ + + if (result != NULL && buffer[0] == ('Z' & 0x1F)) + { + return NULL; + } + + /* + * This should not happen, EOF should always be at the beginning of a line. + */ + + if (result != NULL && buffer[strlen(buffer) - 1] == ('Z' & 0x1F)) + { + buffer[strlen(buffer) - 1] = 0; + } + + return result; +} + +#else + +char *os_fgets(char *buffer, size_t len, FILE * f) +{ + return fgets(buffer, len, f); +} + +#endif + +#if defined(OS_UNIX) || defined(__DJGPP__) || defined(__EMX__) + +char *os_findfirst(struct _filefind *pff, const char *path, + const char *mask) +{ + strcpy(pff->path, path); + os_remove_slash(pff->path); + strcpy(pff->mask, mask); + pff->flags = FNM_NOESCAPE; + +#if defined(__EMX__) && defined(_FNM_OS2) + pff->flags |= (_osmode == OS2_MODE) ? _FNM_OS2 : _FNM_DOS; + pff->flags |= _FNM_IGNORECASE; +#endif + +#ifdef __DJGPP__ + pff->flags |= FNM_CASEFOLD; +#endif + + pff->dirp = opendir(pff->path); + + if (pff->dirp != NULL) + { + char *p; + + p = os_findnext(pff); + if (p != NULL) + { + return p; + } + } + + closedir(pff->dirp); + pff->dirp = NULL; + return NULL; +} + +char *os_findnext(struct _filefind *pff) +{ + int matchresult; + + while (1) + { + pff->pentry = readdir(pff->dirp); + + if (pff->pentry == NULL) + { + return NULL; + } + + matchresult = fnmatch(pff->mask, pff->pentry->d_name, pff->flags); + + if (matchresult == 0) + { + return pff->pentry->d_name; + } + } +} + +void os_findclose(struct _filefind *pff) +{ + if (pff->dirp) + { + closedir(pff->dirp); + } + + pff->dirp = NULL; +} + +#endif + +char *os_getcwd(char *buf, size_t size) +{ +#ifdef __EMX__ + return _getcwd2(buf, size); +#else + return getcwd(buf, size); +#endif +} + +#ifdef OS_UNIX + +int os_fullpath(char *dst, const char *src, size_t bufsize) +{ + char olddir[MYMAXDIR]; + char dir[MYMAXDIR]; + char name[MYMAXFILE]; + char ext[MYMAXEXT]; + + myfnsplit(src, NULL, dir, name, ext); + mklog(LOG_DEBUG, "os_fullpath(): dir=%s, name=%s, ext=%s", dir, name, ext); + getcwd(olddir, sizeof olddir); + mklog(LOG_DEBUG, "os_fullpath(): old directory=%s", olddir); + + if (dir[0] && chdir(dir) == -1) + { + mklog(LOG_ERROR, "os_fullpath(): change directory to '%s' failed!", dir); + return -1; + } + + if (getcwd(dir, MYMAXDIR) == NULL || strlen(dir) + strlen(name) + strlen(ext) > bufsize) + { + mklog(LOG_ERROR, "os_fullpath(): Directory name for '%s' too long!", src); + chdir(olddir); + return -1; + } + + myfnmerge(dst, NULL, dir, name, ext); + mklog(LOG_DEBUG, "os_fullpath(): complete filename: %s", dst); + chdir(olddir); + return 0; +} + +#endif + +#if defined(OS_DOS) || defined(OS_OS2) || defined(OS_WIN) + +#if defined(__WATCOMC__) || (defined(OS_OS2) && (defined(__BORLANDC__) || defined(__HIGHC__) || defined(__IBMC__))) + +#if defined(OS_OS2) && defined(__IBMC__) + +#define INCL_BASE +#define INCL_DOS +#include + +/* file attribute constants for attr field of _dos_findfirst() */ + +#define _A_NORMAL 0x00 /* normal file, read/write permitted */ +#define _A_RDONLY 0x01 /* read-only file */ +#define _A_HIDDEN 0x02 /* hidden file */ +#define _A_SYSTEM 0x04 /* system file */ +#define _A_VOLID 0x08 /* volume label */ +#define _A_SUBDIR 0x10 /* subdirectory */ +#define _A_ARCH 0x20 /* archive file */ + +#define BAD_HANDLE ((HDIR)(~0)) +#define HANDLE_OF(__find) (*(HDIR *)(&(__find)->reserved[0])) + +#define FF_LEVEL 1 +#define FF_BUFFER FILEFINDBUF3 + +struct name +{ + char buf[NAME_MAX + 1]; +}; + +static void copydir(struct find_t *buf, FF_BUFFER *dir_buff) +{ + buf->attrib = dir_buff->attrFile; + buf->wr_time = *(unsigned short *)&dir_buff->ftimeLastWrite; + buf->wr_date = *(unsigned short *)&dir_buff->fdateLastWrite; + buf->size = dir_buff->cbFile; + *(struct name *)buf->name = *(struct name *)dir_buff->achName; +} + +static unsigned _dos_findfirst( const char *path, unsigned attr, struct find_t *buf) +{ + APIRET rc; + FF_BUFFER dir_buff; + HDIR handle = BAD_HANDLE; + ULONG searchcount; + + searchcount = 1; /* only one at a time */ + + rc = DosFindFirst((PSZ)path, (PHFILE)&handle, attr, (PVOID)&dir_buff, sizeof dir_buff, &searchcount, FF_LEVEL); + + if (rc != 0 && rc != ERROR_EAS_DIDNT_FIT) + { + HANDLE_OF(buf) = BAD_HANDLE; + errno = ENOENT; + return 1; + } + + HANDLE_OF(buf) = handle; + copydir(buf, &dir_buff); /* copy in other fields */ + + return 0; +} + +static unsigned _dos_findnext( struct find_t *buf ) +{ + APIRET rc; + FF_BUFFER dir_buff; + ULONG searchcount = 1; + + rc = DosFindNext(HANDLE_OF(buf), (PVOID)&dir_buff, sizeof dir_buff, &searchcount); + + if (rc != 0) + { + errno = ENOENT; + return 1; + } + + copydir( buf, &dir_buff ); + + return 0; +} + +unsigned _dos_findclose( struct find_t *buf ) +{ + APIRET rc; + + if (HANDLE_OF(buf) != BAD_HANDLE) + { + rc = DosFindClose(HANDLE_OF(buf)); + + if (rc != 0) + { + errno = ENOENT; + return 1; + } + } + + return 0; +} + +#endif + +char *os_findfirst(struct _filefind *pff, const char *path, const char *mask) +{ + unsigned rc; + char tmp[MYMAXPATH]; + + strlcpy(tmp, path, sizeof tmp); + os_append_slash(tmp); + strlcat(tmp, mask, sizeof tmp); + + rc = _dos_findfirst(tmp, _A_NORMAL | _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH, &pff->fileinfo); + + if (rc == 0) + { + return pff->fileinfo.name; + } + + return NULL; +} + +char *os_findnext(struct _filefind *pff) +{ + if (_dos_findnext(&pff->fileinfo) == 0) + { + return pff->fileinfo.name; + } + + return NULL; +} + +void os_findclose(struct _filefind *pff) +{ +#ifdef __BORLANDC__ + /* Borland C++ for OS/2 doesn't have _dos_findclose */ + unused(pff); +#else + _dos_findclose(&pff->fileinfo); +#endif +} + +#elif defined(OS_DOS) && defined(__TURBOC__) + +char *os_findfirst(struct _filefind *pff, const char *path, const char *mask) +{ + int rc; + char tmp[MAXPATH]; + + strlcpy(tmp, path, sizeof tmp); + os_append_slash(tmp); + strlcat(tmp, mask, sizeof tmp); + + rc = findfirst(tmp, &pff->fileinfo, FA_RDONLY | FA_HIDDEN | FA_SYSTEM | FA_ARCH); + + if (rc == 0) + { + return pff->fileinfo.ff_name; + } + + return NULL; +} + +char *os_findnext(struct _filefind *pff) +{ + if (findnext(&pff->fileinfo) == 0) + { + return pff->fileinfo.ff_name; + } + + return NULL; +} + +void os_findclose(struct _filefind *pff) +{ + unused(pff); +} + +#elif defined(_MSC_VER) && defined(OS_DOS) + +char *os_findfirst(struct _filefind *pff, const char *path, const char *mask) +{ + unsigned rc; + char tmp[MYMAXPATH]; + + strlcpy(tmp, path, sizeof tmp); + os_append_slash(tmp); + strlcat(tmp, mask, sizeof tmp); + + rc = _dos_findfirst(tmp, _A_NORMAL | _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH, &pff->fileinfo); + + if (rc == 0) + { + return pff->fileinfo.name; + } + + return NULL; +} + +char *os_findnext(struct _filefind *pff) +{ + if (_dos_findnext(&pff->fileinfo) == 0) + { + return pff->fileinfo.name; + } + + return NULL; +} + +void os_findclose(struct _filefind *pff) +{ + unused(pff); +} + +#elif defined(__BORLANDC__) || defined(_MSC_VER) || defined(__DMC__) || defined(__LCC__) || defined(__MINGW32__) + +char *os_findfirst(struct _filefind *pff, const char *path, const char *mask) +{ + char tmp[FILENAME_MAX]; + + strlcpy(tmp, path, sizeof tmp); + os_append_slash(tmp); + strlcat(tmp, mask, sizeof tmp); + pff->handle = _findfirst(tmp, &pff->fileinfo); + + if (pff->handle == -1) + { + return NULL; + } + + return pff->fileinfo.name; +} + +char *os_findnext(struct _filefind *pff) +{ + if (_findnext(pff->handle, &pff->fileinfo) == 0) + { + return pff->fileinfo.name; + } + + return NULL; +} + +void os_findclose(struct _filefind *pff) +{ + _findclose(pff->handle); +} + +#endif + +#if defined(OS_DOS) + +/* + * os_fullpath() + * + * Make an absolute path from given relative path. + */ + +#if defined(__TURBOC__) || defined(__DJGPP__) + +int os_fullpath(char *dst, const char *src, size_t bufsiz) +{ + int rc = -1; + char tmp[MYMAXDIR]; + char curdir[MYMAXDIR]; + int curdrnum; + int reqdrnum; + + curdrnum = getdisk(); + mklog(LOG_DEBUG, "os_fullpath(): Old drive number: %d", curdrnum); + + if (!src || !*src) + { + src = "."; + } + + if (src[1] == ':') + { + /* drive letter specified */ + + mklog(LOG_DEBUG, "os_fullpath(): You specified a drive letter"); + reqdrnum = toupper(src[0]) - 'A'; + + if (reqdrnum != curdrnum) + { + /* requested drive is not current drive */ + mklog(LOG_DEBUG, "os_fullpath(): Switching to drive %d", reqdrnum); + + /* set current disk */ + setdisk(reqdrnum); + + if (getdisk() != reqdrnum) + { + /* Specified drive does not exist */ + mklog(LOG_DEBUG, "os_fullpath(): This drive does not exist"); + return -1; + } + } + + /* Skip drive letter */ + src += 2; + } + + mklog(LOG_DEBUG, "os_fullpath(): Searching for '%s' on current drive", src); + + if (getcwd(curdir, bufsiz) != NULL) + { + char *fname; + char *dir = tmp; + + /* + * Requested drive is now current drive, curdrnum is the original drive + * reqdrnum is the requested drive curdir is the original directory on + * the current drive src is the requested relative path without drive. + */ + + strcpy(dir, src); + fname = strrchr(dir, '\\'); + if (!fname) + { + fname = strrchr(dir, '/'); + } + + if (!fname) + { + /* no backslash */ + + mklog(LOG_DEBUG, "os_fullpath(): You don't have any backslash in the file name."); + + if (!(dir[0] == '.' && (dir[1] == '.' || dir[1] == '\0'))) + { + mklog(LOG_DEBUG, "os_fullpath(): I assume this file is relative to cwd."); + fname = dir; + dir = "."; + } + else + { + mklog(LOG_DEBUG, "os_fullpath(): Looks like relative directory only"); + fname = ""; + } + } + else + { + *fname++ = '\0'; + } + + mklog(LOG_DEBUG, "os_fullpath(): Directory is now %s, File name is now %s", dir, fname); + + /* fname = pure file name */ + /* dir = relative path, only directory */ + + /* If dir is empty it means root directory */ + + if (chdir((*dir) ? dir : "\\") == 0) + { + mklog(LOG_DEBUG, "os_fullpath(): chdir() suceeded. The directory exists."); + + if (getcwd(dst, bufsiz) != NULL) + { + rc = 0; + + if (fname && *fname) + { + if (strlen(dst) != 3) + { + /* Does not look like "C:\" */ + strcat(dst, "\\"); + } + + strcat(dst, fname); + } + + mklog(LOG_DEBUG, "os_fullpath(): Final full name is %s", fname); + } + } + + chdir(curdir); + } + + setdisk(curdrnum); + os_dirsep(dst); + + return rc; +} + +#endif + +#if defined (__WATCOMC__) || defined(_MSC_VER) + +int os_fullpath(char *dst, const char *src, size_t bufsiz) +{ + int rc = -1; + char tmp[MYMAXDIR]; + char curdir[MYMAXDIR]; + unsigned curdrnum; + unsigned reqdrnum; + unsigned total; + unsigned temp; + + _dos_getdrive(&curdrnum); + mklog(LOG_DEBUG, "os_fullpath(): Old drive number: %d", curdrnum); + + if (!src || !*src) + { + src = "."; + } + + if (src[1] == ':') + { + /* drive letter specified */ + + mklog(LOG_DEBUG, "os_fullpath(): You specified a drive letter"); + reqdrnum = toupper(src[0]) - 'A' + 1; + + if (reqdrnum != curdrnum) + { + /* requested drive is not current drive */ + mklog(LOG_DEBUG, "os_fullpath(): Switching to drive %d", reqdrnum); + + /* set current disk */ + _dos_setdrive(reqdrnum, &total); + _dos_getdrive(&temp); + + if (temp != reqdrnum) + { + /* Specified drive does not exist */ + mklog(LOG_DEBUG, "os_fullpath(): This drive does not exist"); + return -1; + } + } + + /* Skip drive letter */ + src += 2; + } + + mklog(LOG_DEBUG, "os_fullpath(): Searching for '%s' on current drive", src); + + if (getcwd(curdir, bufsiz) != NULL) + { + char *fname; + char *dir = tmp; + + /* + * Requested drive is now current drive, curdrnum is the original drive + * reqdrnum is the requested drive curdir is the original directory on + * the current drive src is the requested relative path without drive. + */ + + strcpy(dir, src); + fname = strrchr(dir, '\\'); + if (!fname) + { + fname = strrchr(dir, '/'); + } + + if (!fname) + { + /* no backslash */ + + mklog(LOG_DEBUG, "os_fullpath(): You don't have any backslash in the file name."); + + if (!(dir[0] == '.' && (dir[1] == '.' || dir[1] == '\0'))) + { + mklog(LOG_DEBUG, "os_fullpath(): I assume this file is relative to cwd."); + fname = dir; + dir = "."; + } + else + { + mklog(LOG_DEBUG, "os_fullpath(): Looks like relative directory only"); + fname = ""; + } + } + else + { + *fname++ = '\0'; + } + + mklog(LOG_DEBUG, "os_fullpath(): Directory is now %s, File name is now %s", dir, fname); + + /* fname = pure file name */ + /* dir = relative path, only directory */ + + /* If dir is empty it means root directory */ + + if (chdir((*dir) ? dir : "\\") == 0) + { + mklog(LOG_DEBUG, "os_fullpath(): chdir() suceeded. The directory exists."); + + if (getcwd(dst, bufsiz) != NULL) + { + rc = 0; + + if (fname && *fname) + { + if (strlen(dst) != 3) + { + /* Does not look like "C:\" */ + strcat(dst, "\\"); + } + + strcat(dst, fname); + } + + mklog(LOG_DEBUG, "os_fullpath(): Final full name is %s", fname); + } + } + + chdir(curdir); + } + + _dos_setdrive(curdrnum, &total); + os_dirsep(dst); + + return rc; +} +#endif + +#elif defined(__EMX__) + +/* EMX's _fullpath() is not like the others... */ + +int os_fullpath(char *dst, const char *src, size_t bufsiz) +{ + int result; + result = _fullpath(dst, src, bufsiz); + os_dirsep(dst); + return result; +} + +#else + +int os_fullpath(char *dst, const char *src, size_t bufsiz) +{ + char *path; + + path = _fullpath(dst, src, bufsiz); + + if (path == NULL) + { + return -1; + } + + os_dirsep(dst); + + return 0; +} + +#endif -#ifdef USE_OWN_FGETS -#include USE_OWN_FGETS #endif diff -Nru makenl-3.3.3/src/os.h makenl-3.4.1/src/os.h --- makenl-3.3.3/src/os.h 2012-11-13 22:38:44.000000000 +0000 +++ makenl-3.4.1/src/os.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,153 +1,441 @@ -/* $Id: os.h,v 1.11 2012/11/13 22:38:44 ozzmosis Exp $ */ +/* $Id: os.h,v 1.57 2013/10/02 08:58:03 ozzmosis Exp $ */ -#ifndef _OS_H -#define _OS_H +#ifndef __OS_H__ +#define __OS_H__ -/* Defaults for overwriteable functions */ -#define OSAPS "osgenaps.c" -#define OSRMS "osgenrms.c" -#define OSCAN "osgencan.c" -#define OSDSL "osgendsl.c" -#define OSEXC "osgenexc.c" -#define OSFF "osgenff.c" -#define OSFLD "osgenfld.c" -#define OSGTN "osgengtn.c" +#include +#include + +/* + * OS-specific #defines + * + * OS_DOS MS-DOS target + * OS_OS2 OS/2 target + * OS_WIN Windows target + * OS_UNIX UNIX target; includes FreeBSD, Linux, Apple OS X (Darwin), etc. + * + * + * Memory model defines + * + * MEM_FLAT Flat memory model + * MEM_SEG Segmented memory model (not flat) + * + * + * Compiler & OS #define strings (informational only) + * + * CC_NAME Compiler name + * OS_NAME Operating system name + */ + +#if defined(MSDOS) || defined(__MSDOS__) || defined(__DOS__) +#define OS_DOS 1 +#elif defined(__OS2__) || defined(_OS2) || defined(__EMX__) +#define OS_OS2 1 +#elif defined(__WIN32__) || defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) || defined(__NT__) +#define OS_WIN 1 +#else +#define OS_UNIX 1 +#endif + +#if defined(OS_DOS) +#if defined(__386__) || defined(__DJGPP__) +#define MEM_FLAT 1 +#else +#define MEM_SEG 1 +#endif +#endif + +#if defined(OS_OS2) +#if defined(__386__) || defined(__BORLANDC__) || defined(__HIGHC__) || defined(__EMX__) || defined(__IBMC__) +#define MEM_FLAT 1 +#else +#define MEM_SEG 1 +#endif +#endif + +#if !defined(MEM_FLAT) && !defined(MEM_SEG) +/* default to flat memory model */ +#define MEM_FLAT 1 +#endif #if defined(__clang__) -#define __FLAT__ -#define MAKENL_CC "Clang" +#define CC_NAME "Clang" +#elif defined(__DJGPP__) +#define CC_NAME "DJGPP" +#elif defined(__EMX__) +#define CC_NAME "EMX" +#elif defined(__MINGW64__) +#define CC_NAME "MinGW64" +#elif defined(__MINGW32__) +#define CC_NAME "MinGW32" #elif defined(__GNUC__) -#define __FLAT__ /* flat memory model */ -#define MAKENL_CC "GNU C" -#elif defined(__TURBOC__) && defined(__MSDOS__) -#include "ostbcdos.h" -#define MAKENL_CC "Turbo C" -#elif defined(__WATCOMC__) && defined(__LINUX__) -#define __linux__ -#include "osgnulnx.h" -#define MAKENL_CC "Watcom C" +#define CC_NAME "GNU C" +#elif defined(__BORLANDC__) +#define CC_NAME "Borland C" #elif defined(__WATCOMC__) -#include "oswatxxx.h" -#define MAKENL_CC "Watcom C" -#elif defined(_MSC_VER) && defined(WIN32) -#include "osmscwin.h" -#define MAKENL_CC "MSVC" +#define CC_NAME "Watcom C" +#elif defined(__TURBOC__) +#define CC_NAME "Turbo C" +#elif defined(__HIGHC__) +#define CC_NAME "MetaWare High C" +#elif defined(__IBMC__) +#define CC_NAME "VisualAge C" +#elif defined(_MSC_VER) +#if _MSC_VER <= 900 +#define CC_NAME "MSC" +#else +#define CC_NAME "MSVC" +#endif #elif defined(__LCC__) -#include "osmscwin.h" -#define MAKENL_CC "LCC" +#define CC_NAME "LCC" #elif defined(__DMC__) -#include "osmscwin.h" -#define MAKENL_CC "DMC" -#elif defined(__BORLANDC__) && defined(__WIN32__) -#include "osborwin.h" -#define MAKENL_CC "Borland C" +#define CC_NAME "DMC" +#elif defined(__TINYC__) +#define CC_NAME "TinyCC" +#else +#define CC_NAME "Unknown" +#error "CC_NAME not defined. Unknown compiler detected." #endif -#if defined(__GNUC__) -#if defined(__EMX__) -#include "osgnuemx.h" -#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__minix) -#include "osgnulnx.h" -#elif defined(__DJGPP__) -#include "osgnudjg.h" -#elif defined(__MINGW32__) -/* use Microsoft Visual C++ headers */ -#include "osmscwin.h" +#if defined(OS_DOS) +#ifdef MEM_SEG +#define OS_NAME "DOS 16-bit" +#else +#define OS_NAME "DOS 32-bit" #endif +#elif defined(OS_WIN) +#if defined(WIN64) || defined(_WIN64) +#define OS_NAME "Win64" +#else +#define OS_NAME "Win32" #endif - -#ifndef MAKENL_CC -#error "Unknown compiler detected. MAKENL_CC was not defined." +#elif defined(OS_OS2) +#ifdef MEM_SEG +#define OS_NAME "OS/2 16-bit" +#else +#define OS_NAME "OS/2 32-bit" #endif - -#if defined(__DOS16__) -#define MAKENL_OS "DOS16" -#elif defined(__DOS4G__) -#define MAKENL_OS "DOS32" -#elif defined(__EMX__) -#define MAKENL_OS "EMX" -#elif defined(__OS2__) -#define MAKENL_OS "OS/2 16-bit" -#elif defined(__OS2V2__) -#define MAKENL_OS "OS/2 32-bit" -#elif defined(WIN32) -#define MAKENL_OS "Win32" -#elif defined(__MSDOS__) -#define MAKENL_OS "MS-DOS" -#elif defined(__linux__) -#define MAKENL_OS "Linux" +#elif defined(__linux__) || defined(__LINUX__) +#define OS_NAME "Linux" #elif defined(__FreeBSD__) -#define MAKENL_OS "FreeBSD" +#define OS_NAME "FreeBSD" #elif defined(__APPLE__) -#define MAKENL_OS "Darwin" +#define OS_NAME "OS X" #elif defined(__NetBSD__) -#define MAKENL_OS "NetBSD" +#define OS_NAME "NetBSD" #elif defined(__OpenBSD__) -#define MAKENL_OS "OpenBSD" +#define OS_NAME "OpenBSD" +#elif defined(__sun) +#define OS_NAME "Solaris" #elif defined(__minix) -#define MAKENL_OS "Minix" +#define OS_NAME "Minix" +#elif defined(__HAIKU__) +#define OS_NAME "Haiku" #else -#error "Unknown build target detected. MAKENL_OS was not defined." +#error "OS_NAME was not defined. Unknown build target detected." +#define OS_NAME "Unknown" #endif -#ifndef STR_DIRSEPARATOR -#error "No one defined STR_DIRSEPARATOR!" +#if defined(OS_DOS) || defined(OS_OS2) || defined(OS_WIN) +#define DIRSEP "\\" #else -#define CHAR_DIRSEPARATOR STR_DIRSEPARATOR[0] +#define DIRSEP "/" #endif -/* os-independant global function declarations */ +#if defined(OS_UNIX) -char *os_findfirst(struct _filefind *pff, const char *path, const char *mask); -char *os_findnext(struct _filefind *pff); -void os_findclose(struct _filefind *pff); -char *os_findfile(struct _filefind *pff, const char *path, const char *mask); +#include +#include +#include +#include -char *os_file_getname(const char *path); -int os_fullpath(char *dst, const char *src, size_t bufsiz); -int os_fulldir(char *dst, const char *src, size_t bufsiz); -char *os_append_slash(char *path); -char *os_remove_slash(char *path); -char *os_deslashify(char *name); -char *os_filecanonify(char *s); +#define MYMAXFILE 64 +#define MYMAXDIR 1024 +#define MYMAXPATH 1088 +#define MYMAXEXT 12 +#define MYMAXDRIVE 3 -int os_spawn(const char *command, const char *cmdline); +#define filecmp strcmp +#define filenodir(x) (strchr(x,'/') == NULL) -#ifndef os_getcwd -#define os_getcwd getcwd -#endif +#define HAVE_GETPID 1 -#ifdef USE_OWN_FGETS -#include -char *os_fgets(char *buf, size_t len, FILE * f); -#define fgets os_fgets +struct _filefind +{ + char path[MYMAXDIR]; + char mask[MYMAXFILE]; + DIR *dirp; + struct dirent *pentry; + int flags; +}; + +#elif defined(OS_OS2) && defined(__BORLANDC__) + +#include +#include +#include +#include +#include + +#define HAVE_OS_FULLPATH +#define HAVE_OS_FGETS +#define HAVE_STRUPR +#define HAVE_GETPID + +#define MYMAXFILE _MAX_FNAME +#define MYMAXDIR _MAX_DIR +#define MYMAXPATH _MAX_PATH +#define MYMAXEXT _MAX_EXT +#define MYMAXDRIVE _MAX_DRIVE + +struct _filefind +{ + char path[MYMAXFILE]; + struct find_t fileinfo; +}; + +#define filecmp stricmp +#define filenodir(x) (strpbrk(x,"\\/") == NULL) +#define strcasecmp stricmp + +#define NEED_SNPRINTF 1 + +#elif defined(OS_DOS) && defined(_MSC_VER) + +#include +#include +#include +#include + +#define MYMAXFILE _MAX_FNAME +#define MYMAXDIR _MAX_DIR +#define MYMAXPATH _MAX_PATH +#define MYMAXEXT _MAX_EXT +#define MYMAXDRIVE _MAX_DRIVE +#define filecmp stricmp +#define filenodir(x) (strchr(x,'/') == NULL) + +#define strcasecmp stricmp + +#define HAVE_GETPID 1 + +struct _filefind +{ + char path[MYMAXFILE]; + struct find_t fileinfo; +}; + +#define NEED_SNPRINTF 1 + +#elif defined(__WATCOMC__) || defined(__HIGHC__) + +#include +#include +#include +#include + +#define MYMAXFILE _MAX_FNAME +#define MYMAXDIR _MAX_DIR +#define MYMAXPATH _MAX_PATH +#define MYMAXEXT _MAX_EXT +#define MYMAXDRIVE _MAX_DRIVE + +#define HAVE_GETPID 1 + +#if __WATCOMC__ <= 1100 +#define NEED_SNPRINTF 1 #endif -#ifndef HAVE_STRUPR -char *strupr(char *string); +struct _filefind +{ + char path[MYMAXFILE + MYMAXEXT]; + struct find_t fileinfo; +}; + +#define filecmp stricmp +#define filenodir(x) (strpbrk(x,"\\/") == NULL) +#define strcasecmp stricmp + +#elif defined(OS_OS2) && defined(__IBMC__) + +#include +#include +#include + +#define MYMAXFILE _MAX_FNAME +#define MYMAXDIR _MAX_DIR +#define MYMAXPATH _MAX_PATH +#define MYMAXEXT _MAX_EXT +#define MYMAXDRIVE _MAX_DRIVE + +#define NAME_MAX 255 + +struct find_t +{ + char reserved[21]; + char attrib; + unsigned short wr_time; + unsigned short wr_date; + unsigned long size; + char name[NAME_MAX + 1]; +}; + +struct _filefind +{ + char path[MYMAXFILE + MYMAXEXT]; + struct find_t fileinfo; +}; + +#define filecmp stricmp +#define filenodir(x) (strpbrk(x,"\\/") == NULL) +#define strcasecmp stricmp + +#define HAVE_GETPID 1 +#define NEED_SNPRINTF 1 + +#elif defined(OS_WIN) +#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__DMC__) || defined(__LCC__) || defined(__MINGW32__) + +#include +#include +#include + +#define MYMAXFILE FILENAME_MAX +#define MYMAXDIR MYMAXFILE +#define MYMAXPATH MYMAXFILE +#define MYMAXEXT 13 +#define MYMAXDRIVE 3 + +#define filecmp stricmp +#define filenodir(x) (strchr(x,'/') == NULL) + +#ifndef __MINGW64__ +#define strcasecmp stricmp #endif -/* some sanity checks for compiler defines */ +#define HAVE_GETPID 1 + +struct _filefind +{ + char path[MYMAXDIR]; + int handle; + struct _finddata_t fileinfo; +}; -#if defined(__FLAT__) && defined(__SMALL__) -#error "Both __FLAT__ and __SMALL__ defined!" +#if _MSC_VER <= 900 +#define NEED_SNPRINTF 1 #endif -#if defined(__DOS16__) && defined(__FLAT__) -#error "Both __DOS16__ and __FLAT defined!" +#ifdef __DMC__ +#define NEED_SNPRINTF 1 +#define NEED_SNPRINTF_ONLY 1 #endif -#if defined(__DOS16__) && defined(__DOS32__) -#error "Both __DOS16__ and __DOS32__ defined!" #endif -#if defined(__DOS16__) && defined(__DOS4G__) -#error "Both __DOS16__ and __DOS4G__ defined!" +#elif defined(OS_DOS) && defined(__TURBOC__) + +#include +#include +#include + +#define MYMAXFILE MAXFILE +#define MYMAXDIR MAXDIR +#define MYMAXPATH MAXPATH +#define MYMAXEXT MAXEXT +#define MYMAXDRIVE MAXDRIVE + +struct _filefind +{ + char path[MYMAXFILE + MYMAXEXT]; + struct ffblk fileinfo; +}; + +#define filecmp stricmp +#define filenodir(x) (strpbrk((x),"\\/") == NULL) +#define strcasecmp stricmp + +#define HAVE_GETPID 1 +#define NEED_SNPRINTF 1 + +#elif defined(__DJGPP__) + +#include +#include +#include +#include + +#define MYMAXFILE MAXFILE +#define MYMAXDIR MAXDIR +#define MYMAXPATH MAXPATH +#define MYMAXEXT MAXEXT +#define MYMAXDRIVE MAXDRIVE + +struct _filefind +{ + char path[MYMAXDIR]; + char mask[MYMAXFILE]; + DIR *dirp; + struct dirent *pentry; + int flags; +}; + +#define filecmp stricmp +#define filenodir(x) (strpbrk((x),"\\/") == NULL) +#define strcasecmp stricmp + +#define HAVE_GETPID 1 +#define NEED_SNPRINTF 1 + +#elif defined(__EMX__) + +#include +#include +#include +#include + +#define MYMAXFILE _MAX_FNAME +#define MYMAXDIR _MAX_DIR +#define MYMAXPATH _MAX_PATH +#define MYMAXEXT _MAX_EXT +#define MYMAXDRIVE _MAX_DRIVE + +#define HAVE_GETPID 1 + +#define filecmp stricmp +#define filenodir(x) (strpbrk(x,"\\/") == NULL) +#define strcasecmp stricmp + +struct _filefind +{ + char path[MYMAXDIR]; + char mask[MYMAXFILE]; + DIR *dirp; + struct dirent *pentry; + int flags; +}; + #endif -#if defined(__MSDOS__) + defined(__OS2__) + defined(__OS2V2__) + defined(WIN32) > 1 -#error "Ambiguous OS specification!" +#ifndef NEED_SNPRINTF +#define HAVE_SNPRINTF 1 #endif +char *os_findfirst(struct _filefind *pff, const char *path, const char *mask); +char *os_findnext(struct _filefind *pff); +void os_findclose(struct _filefind *pff); +char *os_findfile(struct _filefind *pff, const char *path, const char *mask); + +char *os_file_getname(const char *path); +int os_fullpath(char *dst, const char *src, size_t bufsiz); +int os_fulldir(char *dst, const char *src, size_t bufsiz); +int os_chdir(char *path); +char *os_append_slash(char *path); +char *os_remove_slash(char *path); +char *os_dirsep(char *path); +int os_spawn(const char *command, const char *cmdline); +char *os_fgets(char *buf, size_t len, FILE *f); +char *os_getcwd(char *buf, size_t size); + #endif diff -Nru makenl-3.3.3/src/osborwin.h makenl-3.4.1/src/osborwin.h --- makenl-3.3.3/src/osborwin.h 2012-11-12 16:33:15.000000000 +0000 +++ makenl-3.4.1/src/osborwin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* $Id: osborwin.h,v 1.5 2012/11/12 16:33:15 ozzmosis Exp $ */ - -#include -#include -#include -#include -#include - -#ifdef __WIN32__ -#ifndef WIN32 -#define WIN32 1 -#endif -#endif - -#define STR_DIRSEPARATOR "\\" - -#define MYMAXFILE FILENAME_MAX -#define MYMAXDIR MYMAXFILE -#define MYMAXPATH MYMAXFILE -#define MYMAXEXT 13 -#define MYMAXDRIVE 3 -#define filecmp stricmp -#define filenodir(x) (strchr(x,'/') == NULL) -#define strcasecmp stricmp - -/* Needed definitions */ -#define OSFND "osmscfnd.c" -#define OSFUL "osmscful.c" -/* Overrides over defaults */ -#undef OSCWD -#define OSCWD "osmsccwd.c" - -#define HAVE_STRUPR -#define HAVE_GETPID - -struct _filefind -{ - char path[MYMAXDIR]; - int handle; - struct _finddata_t fileinfo; -}; diff -Nru makenl-3.3.3/src/osd16exc.c makenl-3.4.1/src/osd16exc.c --- makenl-3.3.3/src/osd16exc.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osd16exc.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: osd16exc.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ +/* $Id: osd16exc.c,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ #include "exec.h" diff -Nru makenl-3.3.3/src/osdosfnd.c makenl-3.4.1/src/osdosfnd.c --- makenl-3.3.3/src/osdosfnd.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osdosfnd.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* $Id: osdosfnd.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -#include -#include "unused.h" - -char *os_findfirst(struct _filefind *pff, const char *path, - const char *mask) -{ - int rc; - char tmp[MAXPATH]; - - strcpy(tmp, path); - os_append_slash(tmp); - strcat(tmp, mask); - rc = findfirst(tmp, &pff->fileinfo, - FA_RDONLY | FA_HIDDEN | FA_SYSTEM | FA_ARCH); - if (rc == 0) - return pff->fileinfo.ff_name; - - return NULL; -} - - -char *os_findnext(struct _filefind *pff) -{ - if (findnext(&pff->fileinfo) == 0) - return pff->fileinfo.ff_name; - - return NULL; -} - - -void os_findclose(struct _filefind *pff) -{ - unused(pff); -} diff -Nru makenl-3.3.3/src/osdosful.c makenl-3.4.1/src/osdosful.c --- makenl-3.3.3/src/osdosful.c 2012-11-12 17:30:01.000000000 +0000 +++ makenl-3.4.1/src/osdosful.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/* $Id: osdosful.c,v 1.4 2012/11/12 17:30:01 ozzmosis Exp $ */ - -#define HAVE_OS_FULLPATH - -#include - -#define FUNCNAME "[dos] os_fullpath" -/* make an absolute path from given relative path */ -int os_fullpath(char *dst, const char *src, size_t bufsiz) -{ - int rc = -1; - char tmp[MYMAXDIR]; - char curdir[MYMAXDIR]; - int curdrnum; - int reqdrnum; - - curdrnum = getdisk(); - mklog(LOG_DEBUG, "Old drive number: %d", curdrnum); - if (!src || !*src) - src = "."; - - if (src[1] == ':') /* drive letter specified */ - { - mklog(LOG_DEBUG, "You specified a drive letter"); - reqdrnum = toupper(src[0]) - 'A'; - if (reqdrnum != curdrnum) /* requested drive is not current drive */ - { - mklog(LOG_DEBUG, "Switching to drive %d", reqdrnum); - setdisk(reqdrnum); /* set current disk */ - if (getdisk() != reqdrnum) /* Specified drive does not exist */ - { - mklog(LOG_DEBUG, "This drive does not exist"); - return -1; - } - } - src += 2; /* Skip drive letter */ - } - - mklog(LOG_DEBUG, "Searching for '%s' on current drive", src); - if (getcwd(curdir, bufsiz) != NULL) - { - char *fname; - char *dir = tmp; - - /* requested drive is now current drive, curdrnum is the original - drive reqdrnum is the requested drive curdir is the original - directory on the current drive src is the requested relative - path without drive */ - strcpy(dir, src); - fname = strrchr(dir, '\\'); - if (!fname) - fname = strrchr(dir, '/'); - if (!fname) /* no backslash */ - { - mklog(LOG_DEBUG, "You don't have any backslash in the file name."); - if (!(dir[0] == '.' && (dir[1] == '.' || dir[1] == '\0'))) - { - mklog(LOG_DEBUG, "I assume this file is relative to cwd."); - fname = dir; - dir = "."; - } - else - { - mklog(LOG_DEBUG, "Looks like relative directory only"); - fname = ""; - } - } - else - *fname++ = '\0'; - - mklog(LOG_DEBUG, "Directory is now %s, File name is now %s", dir, fname); - /* fname = pure file name */ - /* dir = relative path, only directory */ - - /* If dir is empty it means root directory */ - if (chdir((*dir) ? dir : "\\") == 0) - { - mklog(LOG_DEBUG, "chdir() suceeded. The directory exists."); - if (getcwd(dst, bufsiz) != NULL) - { - rc = 0; - if (fname && *fname) - { - if (strlen(dst) != 3) /* Does not look like "C:\" */ - strcat(dst, "\\"); - strcat(dst, fname); - } - mklog(LOG_DEBUG, "final full name is %s", fname); - } - } - chdir(curdir); - } - setdisk(curdrnum); - os_filecanonify(dst); - return rc; -} - -#undef FUNCNAME diff -Nru makenl-3.3.3/src/osemxexc.c makenl-3.4.1/src/osemxexc.c --- makenl-3.3.3/src/osemxexc.c 2012-11-12 18:27:13.000000000 +0000 +++ makenl-3.4.1/src/osemxexc.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/* $Id: osemxexc.c,v 1.5 2012/11/12 18:27:13 ozzmosis Exp $ */ - -#include -#include "mklog.h" - -/* spawn sub-process (currently used for compress/decompress tool) */ -int os_spawn(const char *command, const char *cmdline) -{ - char execfn[_MAX_PATH]; - char tmpfn[_MAX_PATH]; - char *pext; - char *cmd; - int rc; - - /* search for command */ - strcpy(tmpfn, command); - pext = strchr(tmpfn, '\0'); - - mklog(LOG_DEBUG, "os_spawn: trying `%s'", tmpfn); - rc = _path(execfn, tmpfn); - if (rc != 0) - { - strcpy(pext, ".EXE"); - mklog(LOG_DEBUG, "os_spawn: trying `%s'", tmpfn); - rc = _path(execfn, tmpfn); - } - else if (rc != 0 && _osmode == OS2_MODE) - { - strcpy(pext, ".CMD"); - mklog(LOG_DEBUG, "os_spawn: trying `%s'", tmpfn); - rc = _path(execfn, tmpfn); - } - else if (rc != 0 && _osmode != OS2_MODE) - { - strcpy(pext, ".COM"); - mklog(LOG_DEBUG, "os_spawn: trying `%s'", tmpfn); - rc = _path(execfn, tmpfn); - } - else if (rc != 0 && _osmode != OS2_MODE) - { - strcpy(pext, ".BAT"); - mklog(LOG_DEBUG, "os_spawn: trying `%s'", tmpfn); - rc = _path(execfn, tmpfn); - } - else if (rc != 0) - { - mklog(LOG_ERROR, "os_spawn(): program not found"); - return -1; - } - - cmd = malloc(strlen(command) + 1 + strlen(cmdline) + 1); - if (!cmd) - return -1; - - sprintf(cmd, "%s %s", command, cmdline); - mklog(LOG_DEBUG, "found: executing `%s'", cmd); - rc = system(cmd); - mklog(LOG_DEBUG, "os_spawn rc=%d", rc); - - free(cmd); - return rc; -} diff -Nru makenl-3.3.3/src/osemxful.c makenl-3.4.1/src/osemxful.c --- makenl-3.3.3/src/osemxful.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osemxful.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* $Id: osemxful.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -#define HAVE_OS_FULLPATH - -/* make an absolute path from given relative path */ -int os_fullpath(char *dst, const char *src, size_t bufsiz) -{ - int result; - - result = _fullpath(dst, src, bufsiz); - os_filecanonify(dst); - return result; -} diff -Nru makenl-3.3.3/src/osgenaps.c makenl-3.4.1/src/osgenaps.c --- makenl-3.3.3/src/osgenaps.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osgenaps.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* $Id: osgenaps.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -/* normalize path */ -/* It is assumed that path has one more char allocated */ -/* then strlen+1. */ -char *os_append_slash(char *path) -{ - char *p; - - if (!path) - return NULL; - - if ((p = strchr(path, '\0')) > path) - { - p--; - if (*p != '\\' && *p != '/') - { - *(++p) = CHAR_DIRSEPARATOR; - *(++p) = '\0'; - } - } - return path; -} diff -Nru makenl-3.3.3/src/osgencan.c makenl-3.4.1/src/osgencan.c --- makenl-3.3.3/src/osgencan.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osgencan.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -/* $Id: osgencan.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -char *os_filecanonify(char *s) -{ - os_deslashify(s); - return s; -} diff -Nru makenl-3.3.3/src/osgendsl.c makenl-3.4.1/src/osgendsl.c --- makenl-3.3.3/src/osgendsl.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osgendsl.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* $Id: osgendsl.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -/* converts slashes to backslashes for pathnames under DOS or EMX */ -char *os_deslashify(char *name) -{ - char *p; - - p = name; - while (*p != 0) - if (*p == '/') - *p++ = '\\'; - else - ++p; - - return name; -} diff -Nru makenl-3.3.3/src/osgenexc.c makenl-3.4.1/src/osgenexc.c --- makenl-3.3.3/src/osgenexc.c 2012-10-14 14:49:17.000000000 +0000 +++ makenl-3.4.1/src/osgenexc.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* $Id: osgenexc.c,v 1.4 2012/10/14 14:49:17 ozzmosis Exp $ */ - -#include "mklog.h" - -int os_spawn(const char *command, const char *cmdline) -{ - char *cmd; - int rc; - - cmd = malloc(strlen(command) + 1 + strlen(cmdline) + 1); - if (!cmd) - { - mklog(LOG_ERROR, "os_spawn(): out of memory for command line buffer"); - return -1; - } - - sprintf(cmd, "%s %s", command, cmdline); - mklog(LOG_DEBUG, "os_spawn: %s", cmd); - rc = system(cmd); - mklog(LOG_DEBUG, "os_spawn: rc=%d", rc); - - free(cmd); - return rc; -} diff -Nru makenl-3.3.3/src/osgenff.c makenl-3.4.1/src/osgenff.c --- makenl-3.3.3/src/osgenff.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osgenff.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* $Id: osgenff.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -char *os_findfile(struct _filefind *pff, const char *path, - const char *mask) -{ - char *p; - - p = os_findfirst(pff, path, mask); - if (p) - { - strcpy(pff->path, p); - os_findclose(pff); - return pff->path; - } - return NULL; -} diff -Nru makenl-3.3.3/src/osgenfld.c makenl-3.4.1/src/osgenfld.c --- makenl-3.3.3/src/osgenfld.c 2012-10-14 14:49:17.000000000 +0000 +++ makenl-3.4.1/src/osgenfld.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* $Id: osgenfld.c,v 1.3 2012/10/14 14:49:17 ozzmosis Exp $ */ - -#include -#include - -/* make an absolute path from given relative path */ -/* src is supposed to specify an existing directory name */ -#define FUNCNAME "[generic] os_fulldir" -int os_fulldir(char *dst, const char *src, size_t bufsiz) -{ - char tmp[MYMAXPATH]; - struct stat st; - - mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): called with src='%s'", src); - strcpy(tmp, src); - os_remove_slash(tmp); - mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): after removing slash: '%s'", tmp); - if (os_fullpath(dst, tmp, bufsiz) != 0) - { - mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): os_fullpath failed!"); - return -1; - } - mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): absolute path '%s'", dst); - if (stat(dst, &st) != 0) - { - mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): stat failed!"); - return -1; - } - mklog(LOG_DEBUG, __FILE__ ": os_fulldir(): st_mode is now %o", st.st_mode); - return ((st.st_mode & S_IFMT) == S_IFDIR) ? 0 : -1; -} diff -Nru makenl-3.3.3/src/osgengtn.c makenl-3.4.1/src/osgengtn.c --- makenl-3.3.3/src/osgengtn.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osgengtn.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* $Id: osgengtn.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -char *os_file_getname(const char *path) -{ - const char *p; - - p = path; - while (*path != 0) - switch (*path++) - { - case ':': - case '/': - case '\\': - p = path; /* Note that PATH has been incremented */ - break; - } - return (char *)p; -} diff -Nru makenl-3.3.3/src/osgenrms.c makenl-3.4.1/src/osgenrms.c --- makenl-3.3.3/src/osgenrms.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osgenrms.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* $Id: osgenrms.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -/* remove slash/backslash from last part of path name, if present */ -char *os_remove_slash(char *path1) -{ - char *p; - char *path = path1; - - if (!path) - return NULL; - - if (*path && path[1] == ':') - path += 2; /* skip drive letter */ - - if ((p = strchr(path, '\0')) > path) - { - p--; - if (p > path && (*p == '\\' || *p == '/')) - *p = '\0'; - } - return path1; -} diff -Nru makenl-3.3.3/src/osgenupr.c makenl-3.4.1/src/osgenupr.c --- makenl-3.3.3/src/osgenupr.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osgenupr.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -/* $Id: osgenupr.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -#include - -char *strupr(char *string) -{ - char *mystr = string; - - while (*string) - { - *string = toupper((unsigned char)*string); - string++; - } - return mystr; -} diff -Nru makenl-3.3.3/src/osgnudjg.h makenl-3.4.1/src/osgnudjg.h --- makenl-3.3.3/src/osgnudjg.h 2012-11-13 20:40:16.000000000 +0000 +++ makenl-3.4.1/src/osgnudjg.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* $Id: osgnudjg.h,v 1.4 2012/11/13 20:40:16 ozzmosis Exp $ */ - -#include -#include /* for size_t */ -#include -#include /* for chdir, getcwd */ -#include - -#define STR_DIRSEPARATOR "\\" - -/* Needed definitions */ -#define OSFND "osgnufnd.c" -#define OSFUL "osdosful.c" - -#define HAVE_STRUPR - -#define MYMAXFILE MAXFILE -#define MYMAXDIR MAXDIR -#define MYMAXPATH MAXPATH -#define MYMAXEXT MAXEXT -#define MYMAXDRIVE MAXDRIVE - -struct _filefind -{ - char path[MYMAXDIR]; - char mask[MYMAXFILE]; - DIR *dirp; - struct dirent *pentry; - int flags; -}; - - -#define filecmp stricmp -#define filenodir(x) (strpbrk((x),"\\/") == NULL) -#define strcasecmp stricmp - -/* vsnprintf() unavailable in DJGPP, so use insecure vsprintf() */ -#define vsnprintf(str, n, fmt, ap) vsprintf(str, fmt, ap) diff -Nru makenl-3.3.3/src/osgnuemx.h makenl-3.4.1/src/osgnuemx.h --- makenl-3.3.3/src/osgnuemx.h 2012-11-13 20:02:17.000000000 +0000 +++ makenl-3.4.1/src/osgnuemx.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* $Id: osgnuemx.h,v 1.4 2012/11/13 20:02:17 ozzmosis Exp $ */ - -#include -#include -#include -#include - -#define STR_DIRSEPARATOR "/" - -#define MYMAXFILE _MAX_FNAME -#define MYMAXDIR _MAX_DIR -#define MYMAXPATH _MAX_PATH -#define MYMAXEXT _MAX_EXT -#define MYMAXDRIVE _MAX_DRIVE -#define HAVE_OS_FILE_GETNAME -#define HAVE_OS_GETCWD -#define HAVE_OS_FGETS -#define HAVE_STRUPR -#define HAVE_GETPID - -#define filecmp stricmp -#define filenodir(x) (strpbrk(x,"\\/") == NULL) -#define strcasecmp stricmp - -/* Needed definitions */ -#define OSFND "osgnufnd.c" -#define OSFUL "osemxful.c" -/* Overrides over defaults */ -#undef OSEXC -#define OSEXC "osemxexc.c" -#undef OSGTN -#define OSGTN "ignore.h" -#define os_file_getname(path) _getname(path) - -#define os_getcwd _getcwd2 - -struct _filefind -{ - char path[MYMAXDIR]; - char mask[MYMAXFILE]; - DIR *dirp; - struct dirent *pentry; - int flags; -}; diff -Nru makenl-3.3.3/src/osgnufnd.c makenl-3.4.1/src/osgnufnd.c --- makenl-3.3.3/src/osgnufnd.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osgnufnd.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* $Id: osgnufnd.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -#define _GNU_SOURCE -#include -#include -#include -char *os_findfirst(struct _filefind *pff, const char *path, - const char *mask) -{ - strcpy(pff->path, path); - os_remove_slash(pff->path); - strcpy(pff->mask, mask); - pff->flags = FNM_NOESCAPE; - -#ifdef __EMX__ - pff->flags |= (_osmode == OS2_MODE) ? _FNM_OS2 : _FNM_DOS; - pff->flags |= _FNM_IGNORECASE; -#endif - -#if defined(__unix__) || defined(__MSDOS__) - pff->flags |= FNM_CASEFOLD; -#endif - - if ((pff->dirp = opendir(pff->path)) != NULL) - { - char *p; - - if ((p = os_findnext(pff)) != NULL) - return p; - } - - closedir(pff->dirp); - pff->dirp = NULL; - return NULL; -} - - -char *os_findnext(struct _filefind *pff) -{ - int matchresult; - - for (;;) - { - if ((pff->pentry = readdir(pff->dirp)) == NULL) - return NULL; - - matchresult = fnmatch(pff->mask, pff->pentry->d_name, pff->flags); - if (matchresult == 0) - return pff->pentry->d_name; - } -} - - -void os_findclose(struct _filefind *pff) -{ - if (pff->dirp) - closedir(pff->dirp); - pff->dirp = NULL; -} diff -Nru makenl-3.3.3/src/osgnulnx.h makenl-3.4.1/src/osgnulnx.h --- makenl-3.3.3/src/osgnulnx.h 2012-11-13 19:41:13.000000000 +0000 +++ makenl-3.4.1/src/osgnulnx.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* $Id: osgnulnx.h,v 1.4 2012/11/13 19:41:13 ozzmosis Exp $ */ - -#include -#include -#include -#include - -#define STR_DIRSEPARATOR "/" - -#define MYMAXFILE 64 -#define MYMAXDIR 1024 -#define MYMAXPATH 1088 -#define MYMAXEXT 12 -#define MYMAXDRIVE 3 - -#define filecmp strcmp -#define filenodir(x) (strchr(x,'/') == NULL) - -/* Needed definitions */ -#define OSFND "osgnufnd.c" -#define OSFUL "oslnxful.c" -/* Overrides over defaults */ -#undef OSCWD -#define OSCWD "oslnxcwd.c" -#undef OSDSL -#define OSDSL "oslnxdsl.c" - -#define USE_OWN_FGETS "oslnxget.c" - -#define HAVE_GETPID - -struct _filefind -{ - char path[MYMAXDIR]; - char mask[MYMAXFILE]; - DIR *dirp; - struct dirent *pentry; - int flags; -}; diff -Nru makenl-3.3.3/src/oslnxdsl.c makenl-3.4.1/src/oslnxdsl.c --- makenl-3.3.3/src/oslnxdsl.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/oslnxdsl.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -/* $Id: oslnxdsl.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -#define HAVE_OS_DESLASHIFY - -char *os_deslashify(char *name) -{ - return name; -} diff -Nru makenl-3.3.3/src/oslnxful.c makenl-3.4.1/src/oslnxful.c --- makenl-3.3.3/src/oslnxful.c 2012-10-14 14:49:17.000000000 +0000 +++ makenl-3.4.1/src/oslnxful.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* $Id: oslnxful.c,v 1.4 2012/10/14 14:49:17 ozzmosis Exp $ */ - -#define HAVE_OS_FULLPATH -#include - -#include "mklog.h" - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -int os_fullpath(char *dst, const char *src, size_t bufsize) -{ - char olddir[MYMAXDIR]; - char dir[MYMAXDIR]; - char name[MYMAXFILE]; - char ext[MYMAXEXT]; - - myfnsplit(src, NULL, dir, name, ext); - mklog(LOG_DEBUG, "os_fullpath(): dir=%s, name=%s, ext=%s", dir, name, ext); - getcwd(olddir, sizeof olddir); - mklog(LOG_DEBUG, "os_fullpath(): old directory=%s", olddir); - if (dir[0] && chdir(dir) == -1) - { - mklog(LOG_ERROR, "os_fullpath(): change directory to '%s' failed!", dir); - return -1; - } - if (getcwd(dir, MYMAXDIR) == NULL || strlen(dir) + strlen(name) + strlen(ext) > bufsize) - { - mklog(LOG_ERROR, "os_fullpath(): Directory name for '%s' too long!", src); - chdir(olddir); - return -1; - } - myfnmerge(dst, NULL, dir, name, ext); - mklog(LOG_DEBUG, "os_fullpath(): complete filename: %s", dst); - chdir(olddir); - return 0; -} diff -Nru makenl-3.3.3/src/oslnxget.c makenl-3.4.1/src/oslnxget.c --- makenl-3.3.3/src/oslnxget.c 2012-10-14 13:47:56.000000000 +0000 +++ makenl-3.4.1/src/oslnxget.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* $Id: oslnxget.c,v 1.2 2012/10/14 13:47:56 ozzmosis Exp $ */ - -char *os_fgets(char *buffer, size_t len, FILE * f) -{ - char *result; - -#undef fgets - result = fgets(buffer, len, f); - /* - * If we see a EOF at the beinning of a line, then make it look as - * if we didn't read anything. - */ - if (result != NULL && buffer[0] == ('Z' & 0x1F)) - return NULL; - /* - * This should not happen, EOF should allways be at the begin of a line. - */ - if (result != NULL && buffer[strlen(buffer) - 1] == ('Z' & 0x1F)) - buffer[strlen(buffer) - 1] = 0; - return result; -} - diff -Nru makenl-3.3.3/src/osmscfnd.c makenl-3.4.1/src/osmscfnd.c --- makenl-3.3.3/src/osmscfnd.c 2012-11-09 05:03:39.000000000 +0000 +++ makenl-3.4.1/src/osmscfnd.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* $Id: osmscfnd.c,v 1.2 2012/11/09 05:03:39 ajleary Exp $ */ - -#include - -char *os_findfirst(struct _filefind *pff, const char *path, - const char *mask) -{ - char tmp[FILENAME_MAX]; - - strcpy(tmp, path); - os_append_slash(tmp); - strcat(tmp, mask); - pff->handle = _findfirst(tmp, &pff->fileinfo); - - if (pff->handle == -1) - { - return NULL; - } - - return pff->fileinfo.name; -} - - -char *os_findnext(struct _filefind *pff) -{ - if (_findnext(pff->handle, &pff->fileinfo) == 0) - return pff->fileinfo.name; - - return NULL; -} - - -void os_findclose(struct _filefind *pff) -{ - _findclose(pff->handle); -} diff -Nru makenl-3.3.3/src/osmscful.c makenl-3.4.1/src/osmscful.c --- makenl-3.3.3/src/osmscful.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/osmscful.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/* $Id: osmscful.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -#define HAVE_OS_FULLPATH - -/* make an absolute path from given relative path */ -int os_fullpath(char *dst, const char *src, size_t bufsiz) -{ - if (!_fullpath(dst, src, bufsiz)) - { - return -1; - } - os_filecanonify(dst); - return 0; -} diff -Nru makenl-3.3.3/src/osmscwin.h makenl-3.4.1/src/osmscwin.h --- makenl-3.3.3/src/osmscwin.h 2012-10-17 01:24:43.000000000 +0000 +++ makenl-3.4.1/src/osmscwin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* $Id: osmscwin.h,v 1.3 2012/10/17 01:24:43 ozzmosis Exp $ */ - -#include -#include -#include -#include -#include - -#define STR_DIRSEPARATOR "\\" - -#define MYMAXFILE FILENAME_MAX -#define MYMAXDIR MYMAXFILE -#define MYMAXPATH MYMAXFILE -#define MYMAXEXT 13 -#define MYMAXDRIVE 3 -#define filecmp stricmp -#define filenodir(x) (strchr(x,'/') == NULL) -#define strcasecmp stricmp - -/* Needed definitions */ -#define OSFND "osmscfnd.c" -#define OSFUL "osmscful.c" -/* Overrides over defaults */ -#undef OSCWD -#define OSCWD "osmsccwd.c" - -#define HAVE_STRUPR -#define HAVE_GETPID - -struct _filefind -{ - char path[MYMAXDIR]; - int handle; - struct _finddata_t fileinfo; -}; - -#if (_MSC_VER <= 900) -/* vsnprintf() unavailable on very old version of MSVC, so use insecure vsprintf() */ -#define vsnprintf(str, n, fmt, ap) vsprintf(str, fmt, ap) -#endif diff -Nru makenl-3.3.3/src/ostbcdos.h makenl-3.4.1/src/ostbcdos.h --- makenl-3.3.3/src/ostbcdos.h 2012-11-12 18:04:01.000000000 +0000 +++ makenl-3.4.1/src/ostbcdos.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* $Id: ostbcdos.h,v 1.4 2012/11/12 18:04:01 ozzmosis Exp $ */ - -#include -#include /* for size_t */ -#include -#include - -#define STR_DIRSEPARATOR "\\" - -/* Needed definitions */ -#define OSFND "osdosfnd.c" -#define OSFUL "osdosful.c" - -#ifdef USE_DO_EXEC -/* Thomas Wagner's do_exec() isn't working yet... */ -/* Overrides over defaults */ -#undef OSEXC -#define OSEXC "osd16exc.c" -#endif - -#define HAVE_STRUPR -#define HAVE_GETPID - -#define __DOS16__ -#define F_OK 0 - -#define MYMAXFILE MAXFILE -#define MYMAXDIR MAXDIR -#define MYMAXPATH MAXPATH -#define MYMAXEXT MAXEXT -#define MYMAXDRIVE MAXDRIVE - -struct _filefind -{ - char path[MYMAXFILE + MYMAXEXT]; - struct ffblk fileinfo; -}; - -#define filecmp stricmp -#define filenodir(x) (strpbrk((x),"\\/") == NULL) -#define strcasecmp stricmp - -/* vsnprintf() unavailable on very old version of Turbo C, so use insecure vsprintf() */ -#define vsnprintf(str, n, fmt, ap) vsprintf(str, fmt, ap) diff -Nru makenl-3.3.3/src/oswatfnd.c makenl-3.4.1/src/oswatfnd.c --- makenl-3.3.3/src/oswatfnd.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/oswatfnd.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* $Id: oswatfnd.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -#define HAVE_OS_FIND -#include - -char *os_findfirst(struct _filefind *pff, const char *path, - const char *mask) -{ - unsigned rc; - char tmp[MYMAXPATH]; - - strcpy(tmp, path); - os_append_slash(tmp); - strcat(tmp, mask); - rc = _dos_findfirst(tmp, - _A_NORMAL | _A_RDONLY | _A_HIDDEN | _A_SYSTEM | - _A_ARCH, &pff->fileinfo); - if (rc == 0) - return pff->fileinfo.name; - - return NULL; -} - - -char *os_findnext(struct _filefind *pff) -{ - if (_dos_findnext(&pff->fileinfo) == 0) - return pff->fileinfo.name; - - return NULL; -} - - -void os_findclose(struct _filefind *pff) -{ - _dos_findclose(&pff->fileinfo); -} diff -Nru makenl-3.3.3/src/oswatful.c makenl-3.4.1/src/oswatful.c --- makenl-3.3.3/src/oswatful.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/oswatful.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -/* $Id: oswatful.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -/* make an absolute path from given relative path */ -int os_fullpath(char *dst, const char *src, size_t bufsiz) -{ - if (!_fullpath(dst, src, bufsiz)) - return -1; - os_filecanonify(dst); - return 0; -} diff -Nru makenl-3.3.3/src/oswatxxx.h makenl-3.4.1/src/oswatxxx.h --- makenl-3.3.3/src/oswatxxx.h 2012-10-17 01:24:43.000000000 +0000 +++ makenl-3.4.1/src/oswatxxx.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* $Id: oswatxxx.h,v 1.5 2012/10/17 01:24:43 ozzmosis Exp $ */ - -#include -#include -#include -#include -#include - -#define STR_DIRSEPARATOR "\\" - -/* Needed definitions */ -#define OSFND "oswatfnd.c" -#define OSFUL "oswatful.c" - -#ifdef USE_DO_EXEC -/* Thomas Wagner's do_exec() isn't working yet... */ -/* Overrides over defaults */ -#undef OSEXC -#define OSEXC "osd16exc.c" -#endif - -#ifdef __DOS__ -#define __MSDOS__ -#ifdef __386__ -#define __DOS32__ -#else -#define __DOS16__ -#endif -#endif - -#ifdef __NT__ -#ifndef WIN32 -#define WIN32 1 -#endif -#endif - -#define HAVE_OS_FULLPATH -#define HAVE_OS_FGETS -#define HAVE_STRUPR -#define HAVE_GETPID - -#define MYMAXFILE _MAX_FNAME -#define MYMAXDIR _MAX_DIR -#define MYMAXPATH _MAX_PATH -#define MYMAXEXT _MAX_EXT -#define MYMAXDRIVE _MAX_DRIVE - -struct _filefind -{ -#if defined(__OS2V2__) - char path[512]; -#else - char path[MYMAXFILE + MYMAXEXT]; -#endif - struct find_t fileinfo; -}; - -#define filecmp stricmp -#define filenodir(x) (strpbrk(x,"\\/") == NULL) -#define strcasecmp stricmp diff -Nru makenl-3.3.3/src/output.c makenl-3.4.1/src/output.c --- makenl-3.3.3/src/output.c 2012-12-26 04:21:08.000000000 +0000 +++ makenl-3.4.1/src/output.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: output.c,v 1.7 2012/12/26 04:21:08 ajleary Exp $ */ +/* $Id: output.c,v 1.11 2013/10/11 13:16:53 ajleary Exp $ */ #include #include @@ -9,14 +9,8 @@ #include "crc16.h" #include "fileutil.h" #include "mklog.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif +#include "strtool.h" +#include "snprintf.h" char ErrorMessage[linelength]; @@ -24,6 +18,7 @@ const char *post, unsigned short *crc) { char *linebuf; + int bufsize; int fputs_result; if (FTS5Keyword) /* Do we have an Nodelist line to be @@ -31,12 +26,11 @@ if (OutputFTS5Line(file, pre, post, crc) == EOF) return EOF; - linebuf = malloc(strlen(pre) + - strlen(wrongy) + 4 + - strlen(ErrorMessage) + strlen(post) + 1); + bufsize = strlen(pre) + strlen(wrongy) + 4 + strlen(ErrorMessage) + strlen(post) + 1; + linebuf = malloc(bufsize); if (!linebuf) die(253, "No memory left for error message buffer!\n"); - sprintf(linebuf, "%s%s -- %s%s", pre, wrongy, ErrorMessage, post); + snprintf(linebuf, bufsize, "%s%s -- %s%s", pre, wrongy, ErrorMessage, post); if (crc) *crc = CRC16String(linebuf, *crc); fputs_result = fputs(linebuf, file); @@ -50,18 +44,22 @@ unsigned short *crc) { char *linebuf; + int bufsize; int fputs_result; - linebuf = malloc(strlen(prefix) + - strlen(FTS5Keyword) + 1 + - strlen(FTS5Number) + 1 + - strlen(FTS5Nodename) + 1 + - strlen(FTS5Sysopname) + 1 + - strlen(FTS5Location) + 1 + - strlen(FTS5Phone) + 1 + - strlen(FTS5Baud) + 1 + - strlen(FTS5Flags) + strlen(postfix) + 1); - sprintf(linebuf, "%s%s,%s,%s,%s,%s,%s,%s,%s%s", prefix, + bufsize = strlen(prefix) + + strlen(FTS5Keyword) + 1 + + strlen(FTS5Number) + 1 + + strlen(FTS5Nodename) + 1 + + strlen(FTS5Sysopname) + 1 + + strlen(FTS5Location) + 1 + + strlen(FTS5Phone) + 1 + + strlen(FTS5Baud) + 1 + + strlen(FTS5Flags) + + strlen(postfix) + 1; + + linebuf = malloc(bufsize); + snprintf(linebuf, bufsize, "%s%s,%s,%s,%s,%s,%s,%s,%s%s", prefix, FTS5Keyword, FTS5Number, FTS5Nodename, FTS5Location, FTS5Sysopname, FTS5Phone, FTS5Baud, FTS5Flags, postfix); if (crc != NULL) @@ -92,7 +90,7 @@ if (!Copyfile) return lineno; myfnmerge(fullname, NULL, MasterDir, Copyfile, NULL); - strcpy(linebuf, ";S"); + strlcpy(linebuf, ";S", sizeof linebuf); CopyFILE = fopen(fullname, "r"); if (!CopyFILE) { @@ -106,6 +104,10 @@ while ((linebegin = fgets(linebuf + 3, linelength - 3, CopyFILE)) != NULL) { + if (linebegin[0] == '\x1a') /* CTRL-Z at beginning of line. */ + { + return lineno; + } if (linebegin[0] != ';') { linebegin = linebuf; diff -Nru makenl-3.3.3/src/proc.h makenl-3.4.1/src/proc.h --- makenl-3.3.3/src/proc.h 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/proc.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -/* $Id: proc.h,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ - -/* Values for ShouldProcess */ -#define USUAL_PROCESSING 1 -#define FORCED_PROCESSING 2 - -extern int ShouldProcess; -extern int SubmitFile; -extern int IsLinux; - -void ProcessFILES(int WorkMode, FILE * CfgFILE, FILE * OutFILE, - FILE * CommentsFILE, FILE * MergeOutFILE, - unsigned short *crc); - -int processfile(int myMakeType, int myMakeNum, FILE * InputFILE, - FILE * OutFILE, FILE * FooFile, FILE * MergOutFILE, - FILE * SelfMsgFILE, unsigned short *OutCRC, int *WorkMode); diff -Nru makenl-3.3.3/src/process.c makenl-3.4.1/src/process.c --- makenl-3.3.3/src/process.c 2012-10-16 18:52:12.000000000 +0000 +++ makenl-3.4.1/src/process.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,369 +0,0 @@ -/* $Id: process.c,v 1.7 2012/10/16 18:52:12 ozzmosis Exp $ */ - -#include -#include -#include - -#include "makenl.h" -#include "crc16.h" -#include "proc.h" -#include "msg.h" -#include "fts5.h" -#include "lsttool.h" -#include "fileutil.h" -#include "upcont.h" -#include "stack.h" -#include "config.h" -#include "mklog.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -int ShouldProcess = USUAL_PROCESSING; -int SubmitFile; - -static int LogError(int now, int prev, FILE * OutFILE, FILE * SelfMsgFILE, - unsigned short *crc); - -void -ProcessFILES(int WorkMode, FILE * CfgFILE, FILE * OutFILE, - FILE * CommentsFILE, FILE * MergeOutFILE, unsigned short *crc) -{ - char *tmpptr; - int fieldno; - int searchwhere; - int mustbenew; - FILE *commFILE; - int subfile_level; - int num; - FILE *listFILE; - FILE *NotifyMsgFILE = 0; - int processstatus = 0; - char command[8]; - char filename[MYMAXFILE + MYMAXEXT]; - char notifyaddr[18]; - char foundfile[MYMAXDIR]; - char linebuf[linelength]; - const char *const *subleveltxt; - - /* another function may have already closed the file... */ - - if (feof(CfgFILE)) - { - return; - } - - while (fgets(linebuf, linelength, CfgFILE) != NULL) - { - UsualMSGFlags = MailerFlags & (MF_ERRORS | MF_RECEIPT); - tmpptr = strchr(linebuf, ';'); - if (tmpptr) - *tmpptr = 0; - if (*cutspaces(linebuf) == 0) - continue; - fieldno = - sscanf(linebuf, "%7s %d %12s %17s", command, &num, filename, - notifyaddr); - strupr(command); - if (fieldno < 3) /* "Net 2410 NET_2410" is minimum... */ - die(255, "%s\n -- Too few parameters -- Statement ignored\n", linebuf); - subfile_level = xlate_switch(command, MakeTypes); - if (MakeType >= subfile_level) - die(255, "%s\n -- '%s' is invalid list type -- Statement ignored\n", - linebuf, command); - if (subfile_level < LEVEL_HOST) - { - NotifyAddress[A_NET] = num; - NotifyAddress[A_NODE] = 0; - } - else if (MakeType <= LEVEL_HOST) - { - NotifyAddress[A_NET] = MakeNum; - NotifyAddress[A_NODE] = num; - } - else - UsualMSGFlags = 0; - if (fieldno >= 4) - { - if (ParseAddress(notifyaddr, NotifyAddress) != 0) - die(255, "Invalid NOTIFY address '%s' ignored\n", notifyaddr); - UsualMSGFlags = MailerFlags & (MF_ERRORS | MF_RECEIPT); - } - else - NotifyAddress[A_ZONE] = MyAddress[A_ZONE]; - if (num < 0) - die(255, "%s\n -- \"%d\" is invalid list number -- Statement ignored\n", - linebuf, num); - subleveltxt = LevelsSimple + subfile_level; - searchwhere = 0; - foundfile[0] = '\0'; - do - { - if (ShouldProcess == 0 && MergeOutFILE == 0) /* Process only - new files */ - mustbenew = 1; - else - mustbenew = 0; - searchwhere = - openlist(&listFILE, filename, foundfile, searchwhere, - mustbenew); - os_filecanonify(filename); - os_filecanonify(foundfile); - if (searchwhere > 0) - { - mklog(LOG_INFO, "Processing %-8s%5d -- file '%s'", *subleveltxt, num, foundfile); - if (UsualMSGFlags != 0 && searchwhere < SEARCH_UPDATE + 1) - { - /* newly received file */ - NotifyMsgFILE = OpenMSGFile(NotifyAddress, NULL); - if (NotifyMsgFILE) - { - fprintf(NotifyMsgFILE, "Your nodelist update '%s' has been received", WorkFile); - } - } - commFILE = - (searchwhere == - SEARCH_MASTER + 1) ? NULL : CommentsFILE; - processstatus = - processfile(subfile_level, num, listFILE, OutFILE, - commFILE, MergeOutFILE, NotifyMsgFILE, crc, - &WorkMode); - - /* Segmentation fault cause is here, Andrew */ - - #ifndef __unix__ - fclose(listFILE); - #endif - if (processstatus != 2) /* No fatal error */ - { - if (processstatus > ExitCode) - ExitCode = processstatus; - break; - } - ExitCode = processstatus; - NotifyMsgFILE = CloseMSGFile(ExitCode); - if (BadDir[0] != 0) - CopyOrMove(0, foundfile, BadDir, WorkFile); - else - unlink(foundfile); - } - } - while (searchwhere > 0); - switch (searchwhere) - { - case 0: /* not found */ - if (!ShouldProcess) - break; - mklog(LOG_INFO, "No file found for %s %d file '%s'", LevelsSimple[subfile_level], num, filename); - break; - case SEARCH_UPLOAD + 1: - cleanold(MailfileDir, filename, NULL); - /* FALLTHROUGH */ - case SEARCH_MAILFILE + 1: - CloseMSGFile(processstatus); - cleanold(UpdateDir, filename, NULL); - if (!ShouldProcess) - { - CopyOrMove(0, foundfile, UpdateDir, filename); - break; - } - CopyOrMove(0, foundfile, MasterDir, filename); - break; - case SEARCH_MASTER + 1: - if (!ShouldProcess) - break; - if (getext(NULL, filename)) /* explicit name */ - break; - myfnmerge(linebuf, NULL, MasterDir, filename, - OldExtensions[0]); - if (filecmp(foundfile, linebuf)) - rename(foundfile, linebuf); /* new extension */ - cleanold(MasterDir, filename, OldExtensions[2]); - break; - case SEARCH_UPDATE + 1: - if (!ShouldProcess) - break; - cleanold(MasterDir, filename, OldExtensions[2]); - CopyOrMove(0, foundfile, MasterDir, filename); - } - } - - fclose(CfgFILE); -} - -int -processfile(int myMakeType, int myMakeNum, FILE * InputFILE, - FILE * OutFILE, FILE * FooFILE, FILE * MergeOutFILE, - FILE * SelfMsgFILE, unsigned short *OutCRC, int *WorkMode) -{ - long outpos = 0; - long mergeoutpos = 0; - int error; - int level; - int num; - int contextlevel; - int contextnum; - int totalerror = 0; - unsigned short oldcrc; - static char InputLine[linelength]; - - oldcrc = *OutCRC; - if (OutFILE) - { - outpos = ftell(OutFILE); - if (myMakeType < LEVEL_HUB) - { - *OutCRC = CRC16String(";\r\n", *OutCRC); - fputs(";\r\n", OutFILE); - } - } - if (MergeOutFILE) - mergeoutpos = ftell(MergeOutFILE); - if (FooFILE) - fprintf(FooFILE, "\nComments from %s:\n\n", WorkFile); - while ((fgets(InputLine, linelength, InputFILE) != NULL) - && (InputLine[0] != '\032')) - { - error = ParseFTS5(InputLine, &level, &num); - if (level >= LEVEL_COMMENT) - { - if (level == LEVEL_COMMENT && FooFILE && InputLine[1] != 0) - { - fputs(InputLine, FooFILE); - putc('\n', FooFILE); - } - } - else - { - if (addnumber(myMakeType, myMakeNum, 1) != 0) - error = 2; - contextlevel = level; /* Initialize the context level */ - if (!error) - error = - UpdateContext(level, num, myMakeNum, &contextnum, - &contextlevel, myMakeType); - if (error) - { - contextlevel = myMakeType; - totalerror = LogError(2, 0, OutFILE, SelfMsgFILE, OutCRC); - } - if (OutFILE) - OutputFTS5Line(OutFILE, "", "\r\n", OutCRC); - if (MergeOutFILE) - OutputFTS5Line(MergeOutFILE, "", "\r\n", NULL); - break; - } - } - while ((fgets(InputLine, linelength, InputFILE) != NULL) - && (InputLine[0] != '\032')) - { - error = ParseFTS5(InputLine, &level, &num); - if (error && *WorkMode == CFG_DATA - && !strncmp(FTS5Keyword, "FILES", 5)) - { - *WorkMode = error = CFG_FILES; - break; - } - if (level < LEVEL_COMMENT) - { - if (!error) - error = - UpdateContext(level, num, 0, &contextnum, - &contextlevel, myMakeType); - if (!error) - error = addnumber(level, num, 0); - if (error) - { - totalerror = - LogError(error, totalerror, OutFILE, SelfMsgFILE, - OutCRC); - continue; - } - if (OutFILE) - { - if (level < LEVEL_HUB) - /* Make it more readable - empty lines before NET, - REGION and ZONE */ - { - *OutCRC = CRC16String(";\r\n", *OutCRC); - fputs(";\r\n", OutFILE); - } - OutputFTS5Line(OutFILE, "", "\r\n", OutCRC); - } - if (MergeOutFILE) - { - if (level < LEVEL_HUB) - /* Make it more readable - see above */ - fputs(";\r\n", MergeOutFILE); - OutputFTS5Line(MergeOutFILE, "", "\r\n", NULL); - } - } - else if (level == LEVEL_COMMENT && InputLine[1] != 0) - { - if (FooFILE) - { - fputs(InputLine, FooFILE); - putc('\n', FooFILE); - } - if (InputLine[1] == 'E' && OutFILE) /* Pass through only - errors */ - { - strcat(InputLine, "\r\n"); - *OutCRC = CRC16String(InputLine, *OutCRC); - fputs(InputLine, OutFILE); - } - } - } - if (totalerror == 2) /* 2 means fatal */ - { - unmarkstack(); /* Throw away any numbers of this file */ - sprintf(InputLine, - "Fatal error(s) caused file '%s' to be rejected\r\n", - WorkFile); - fputs(InputLine, stdout); - if (SelfMsgFILE) - fputs(InputLine, SelfMsgFILE); - *OutCRC = oldcrc; - if (OutFILE) - fseek(OutFILE, outpos, SEEK_SET); - if (MergeOutFILE) - fseek(MergeOutFILE, mergeoutpos, SEEK_SET); - } - else - { - if (OutFILE) - SubmitFile = 1; - if (MergeOutFILE && myMakeType < LEVEL_HUB) - fputs(";\r\n", MergeOutFILE); - } - - if (SelfMsgFILE && totalerror == 0) - { - fputs(" and processed without error.\r\n", SelfMsgFILE); - } - return totalerror; -} - -static int -LogError(int now, int prev, FILE * OutFILE, FILE * SelfMsgFILE, - unsigned short *crc) -{ - OutputErrorLine(stdout, "", WorkFile, "\n", NULL); - if (OutFILE) - OutputErrorLine(OutFILE, ";E ", "", "\r\n", crc); - if (SelfMsgFILE) - { - if (prev == 0) /* First Error */ - fputs - (". Please correct the following errors and resubmit.\r\n\r\n", - SelfMsgFILE); - OutputErrorLine(SelfMsgFILE, "", "", "\r\n", NULL); - fputs("\r\n", SelfMsgFILE); - } - return max(now, prev); -} diff -Nru makenl-3.3.3/src/procfile.c makenl-3.4.1/src/procfile.c --- makenl-3.3.3/src/procfile.c 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/procfile.c 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,360 @@ +/* $Id: procfile.c,v 1.4 2013/10/11 13:16:53 ajleary Exp $ */ + +#include +#include +#include + +#include "makenl.h" +#include "crc16.h" +#include "msg.h" +#include "fts5.h" +#include "lsttool.h" +#include "fileutil.h" +#include "upcont.h" +#include "stack.h" +#include "config.h" +#include "mklog.h" +#include "strtool.h" +#include "snprintf.h" +#include "procfile.h" + +int ShouldProcess = USUAL_PROCESSING; +int SubmitFile; + +static int LogError(int now, int prev, FILE * OutFILE, FILE * SelfMsgFILE, + unsigned short *crc); + +void +ProcessFILES(int WorkMode, FILE * CfgFILE, FILE * OutFILE, + FILE * CommentsFILE, FILE * MergeOutFILE, unsigned short *crc) +{ + char *tmpptr; + int fieldno; + int searchwhere; + int mustbenew; + FILE *commFILE; + int subfile_level; + int num; + FILE *listFILE; + FILE *NotifyMsgFILE = 0; + int processstatus = 0; + char command[8]; + char filename[MYMAXFILE + MYMAXEXT]; + char notifyaddr[18]; + char foundfile[MYMAXDIR]; + char linebuf[linelength]; + const char *const *subleveltxt; + + /* another function may have already closed the file... */ + + if (feof(CfgFILE)) + { + return; + } + + while (fgets(linebuf, linelength, CfgFILE) != NULL) + { + UsualMSGFlags = MailerFlags & (MF_ERRORS | MF_RECEIPT); + tmpptr = strchr(linebuf, ';'); + if (tmpptr) + *tmpptr = 0; + if (*cutspaces(linebuf) == 0) + continue; + fieldno = + sscanf(linebuf, "%7s %d %12s %17s", command, &num, filename, + notifyaddr); + strupper(command); + if (fieldno < 3) /* "Net 2410 NET_2410" is minimum... */ + die(255, "%s\n -- Too few parameters -- Statement ignored\n", linebuf); + subfile_level = xlate_switch(command, MakeTypes); + if (MakeType >= subfile_level) + die(255, "%s\n -- '%s' is invalid list type -- Statement ignored\n", + linebuf, command); + if (subfile_level < LEVEL_HOST) + { + NotifyAddress[A_NET] = num; + NotifyAddress[A_NODE] = 0; + } + else if (MakeType <= LEVEL_HOST) + { + NotifyAddress[A_NET] = MakeNum; + NotifyAddress[A_NODE] = num; + } + else + UsualMSGFlags = 0; + if (fieldno >= 4) + { + if (ParseAddress(notifyaddr, NotifyAddress) != 0) + die(255, "Invalid NOTIFY address '%s' ignored\n", notifyaddr); + UsualMSGFlags = MailerFlags & (MF_ERRORS | MF_RECEIPT); + } + else + NotifyAddress[A_ZONE] = MyAddress[A_ZONE]; + if (num < 0) + die(255, "%s\n -- \"%d\" is invalid list number -- Statement ignored\n", + linebuf, num); + subleveltxt = LevelsSimple + subfile_level; + searchwhere = 0; + foundfile[0] = '\0'; + do + { + if (ShouldProcess == 0 && MergeOutFILE == 0) /* Process only + new files */ + mustbenew = 1; + else + mustbenew = 0; + searchwhere = + openlist(&listFILE, filename, foundfile, searchwhere, + mustbenew); + os_dirsep(filename); + os_dirsep(foundfile); + if (searchwhere > 0) + { + mklog(LOG_INFO, "Processing %-8s%5d -- file '%s'", *subleveltxt, num, foundfile); + if (UsualMSGFlags != 0 && searchwhere < SEARCH_UPDATE + 1) + { + /* newly received file */ + NotifyMsgFILE = OpenMSGFile(NotifyAddress, NULL); + if (NotifyMsgFILE) + { + fprintf(NotifyMsgFILE, "Your nodelist update '%s' has been received", WorkFile); + } + } + commFILE = + (searchwhere == + SEARCH_MASTER + 1) ? NULL : CommentsFILE; + processstatus = + processfile(subfile_level, num, listFILE, OutFILE, + commFILE, MergeOutFILE, NotifyMsgFILE, crc, + &WorkMode); + + fclose(listFILE); + + if (processstatus != 2) /* No fatal error */ + { + if (processstatus > ExitCode) + ExitCode = processstatus; + break; + } + ExitCode = processstatus; + NotifyMsgFILE = CloseMSGFile(ExitCode); + if (BadDir[0] != 0) + CopyOrMove(0, foundfile, BadDir, WorkFile); + else + unlink(foundfile); + } + } + while (searchwhere > 0); + switch (searchwhere) + { + case 0: /* not found */ + if (!ShouldProcess) + break; + mklog(LOG_INFO, "No file found for %s %d file '%s'", LevelsSimple[subfile_level], num, filename); + break; + case SEARCH_UPLOAD + 1: + cleanold(MailfileDir, filename, NULL); + /* FALLTHROUGH */ + case SEARCH_MAILFILE + 1: + CloseMSGFile(processstatus); + cleanold(UpdateDir, filename, NULL); + if (!ShouldProcess) + { + CopyOrMove(0, foundfile, UpdateDir, filename); + break; + } + CopyOrMove(0, foundfile, MasterDir, filename); + break; + case SEARCH_MASTER + 1: + if (!ShouldProcess) + break; + if (getext(NULL, filename)) /* explicit name */ + break; + myfnmerge(linebuf, NULL, MasterDir, filename, + OldExtensions[0]); + if (filecmp(foundfile, linebuf)) + rename(foundfile, linebuf); /* new extension */ + cleanold(MasterDir, filename, OldExtensions[7]); + break; + case SEARCH_UPDATE + 1: + if (!ShouldProcess) + break; + cleanold(MasterDir, filename, OldExtensions[7]); + CopyOrMove(0, foundfile, MasterDir, filename); + } + } + + fclose(CfgFILE); +} + +int +processfile(int myMakeType, int myMakeNum, FILE * InputFILE, + FILE * OutFILE, FILE * FooFILE, FILE * MergeOutFILE, + FILE * SelfMsgFILE, unsigned short *OutCRC, int *WorkMode) +{ + long outpos = 0; + long mergeoutpos = 0; + int error; + int level; + int num; + int contextlevel; + int contextnum; + int totalerror = 0; + unsigned short oldcrc; + static char InputLine[linelength]; + + oldcrc = *OutCRC; + if (OutFILE) + { + outpos = ftell(OutFILE); + if (myMakeType < LEVEL_HUB) + { + *OutCRC = CRC16String(";\r\n", *OutCRC); + fputs(";\r\n", OutFILE); + } + } + if (MergeOutFILE) + mergeoutpos = ftell(MergeOutFILE); + if (FooFILE) + fprintf(FooFILE, "\nComments from %s:\n\n", WorkFile); + while ((fgets(InputLine, linelength, InputFILE) != NULL) + && (InputLine[0] != '\x1a')) + { + error = ParseFTS5(InputLine, &level, &num); + if (level >= LEVEL_COMMENT) + { + if (level == LEVEL_COMMENT && FooFILE && InputLine[1] != 0) + { + fputs(InputLine, FooFILE); + putc('\n', FooFILE); + } + } + else + { + if (addnumber(myMakeType, myMakeNum, 1) != 0) + error = 2; + contextlevel = level; /* Initialize the context level */ + if (!error) + error = + UpdateContext(level, num, myMakeNum, &contextnum, + &contextlevel, myMakeType); + if (error) + { + contextlevel = myMakeType; + totalerror = LogError(2, 0, OutFILE, SelfMsgFILE, OutCRC); + } + if (OutFILE) + OutputFTS5Line(OutFILE, "", "\r\n", OutCRC); + if (MergeOutFILE) + OutputFTS5Line(MergeOutFILE, "", "\r\n", NULL); + break; + } + } + while ((fgets(InputLine, linelength, InputFILE) != NULL) + && (InputLine[0] != '\x1a')) + { + error = ParseFTS5(InputLine, &level, &num); + if (error && *WorkMode == CFG_DATA + && !strncmp(FTS5Keyword, "FILES", 5)) + { + *WorkMode = error = CFG_FILES; + break; + } + if (level < LEVEL_COMMENT) + { + if (!error) + error = + UpdateContext(level, num, 0, &contextnum, + &contextlevel, myMakeType); + if (!error) + error = addnumber(level, num, 0); + if (error) + { + totalerror = + LogError(error, totalerror, OutFILE, SelfMsgFILE, + OutCRC); + continue; + } + if (OutFILE) + { + if (level < LEVEL_HUB) + /* Make it more readable - empty lines before NET, + REGION and ZONE */ + { + *OutCRC = CRC16String(";\r\n", *OutCRC); + fputs(";\r\n", OutFILE); + } + OutputFTS5Line(OutFILE, "", "\r\n", OutCRC); + } + if (MergeOutFILE) + { + if (level < LEVEL_HUB) + /* Make it more readable - see above */ + fputs(";\r\n", MergeOutFILE); + OutputFTS5Line(MergeOutFILE, "", "\r\n", NULL); + } + } + else if (level == LEVEL_COMMENT && InputLine[1] != 0) + { + if (FooFILE) + { + fputs(InputLine, FooFILE); + putc('\n', FooFILE); + } + if (InputLine[1] == 'E' && OutFILE) /* Pass through only + errors */ + { + strlcat(InputLine, "\r\n", sizeof InputLine); + *OutCRC = CRC16String(InputLine, *OutCRC); + fputs(InputLine, OutFILE); + } + } + } + if (totalerror == 2) /* 2 means fatal */ + { + unmarkstack(); /* Throw away any numbers of this file */ + snprintf(InputLine, sizeof InputLine, + "Fatal error(s) caused file '%s' to be rejected\r\n", + WorkFile); + fputs(InputLine, stdout); + if (SelfMsgFILE) + fputs(InputLine, SelfMsgFILE); + *OutCRC = oldcrc; + if (OutFILE) + fseek(OutFILE, outpos, SEEK_SET); + if (MergeOutFILE) + fseek(MergeOutFILE, mergeoutpos, SEEK_SET); + } + else + { + if (OutFILE) + SubmitFile = 1; + if (MergeOutFILE && myMakeType < LEVEL_HUB) + fputs(";\r\n", MergeOutFILE); + } + + if (SelfMsgFILE && totalerror == 0) + { + fputs(" and processed without error.\r\n", SelfMsgFILE); + } + return totalerror; +} + +static int +LogError(int now, int prev, FILE * OutFILE, FILE * SelfMsgFILE, + unsigned short *crc) +{ + OutputErrorLine(stdout, "", WorkFile, "\n", NULL); + if (OutFILE) + OutputErrorLine(OutFILE, ";E ", "", "\r\n", crc); + if (SelfMsgFILE) + { + if (prev == 0) /* First Error */ + fputs + (". Please correct the following errors and resubmit.\r\n\r\n", + SelfMsgFILE); + OutputErrorLine(SelfMsgFILE, "", "", "\r\n", NULL); + fputs("\r\n", SelfMsgFILE); + } + return max(now, prev); +} diff -Nru makenl-3.3.3/src/procfile.h makenl-3.4.1/src/procfile.h --- makenl-3.3.3/src/procfile.h 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/procfile.h 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,21 @@ +/* $Id: procfile.h,v 1.1 2013/09/21 12:09:41 ozzmosis Exp $ */ + +#ifndef __PROCFILE_H__ +#define __PROCFILE_H__ + +/* Values for ShouldProcess */ + +#define USUAL_PROCESSING 1 +#define FORCED_PROCESSING 2 + +extern int ShouldProcess; +extern int SubmitFile; + +void ProcessFILES(int WorkMode, FILE * CfgFILE, FILE * OutFILE, + FILE * CommentsFILE, FILE * MergeOutFILE, unsigned short *crc); + +int processfile(int myMakeType, int myMakeNum, FILE * InputFILE, + FILE * OutFILE, FILE * FooFile, FILE * MergOutFILE, FILE * SelfMsgFILE, + unsigned short *OutCRC, int *WorkMode); + +#endif diff -Nru makenl-3.3.3/src/snprintf.c makenl-3.4.1/src/snprintf.c --- makenl-3.3.3/src/snprintf.c 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/snprintf.c 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,1032 @@ +#include "os.h" +#include "unused.h" + +/* + * snprintf.c - a portable implementation of snprintf + * + * AUTHOR + * Mark Martinec , April 1999. + * + * Copyright 1999, Mark Martinec. All rights reserved. + * + * TERMS AND CONDITIONS + * This program is free software; you can redistribute it and/or modify + * it under the terms of the "Frontier Artistic License" which comes + * with this Kit. + * + * 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 Frontier Artistic License for more details. + * + * You should have received a copy of the Frontier Artistic License + * with this Kit in the file named LICENSE.txt . + * If not, I'll be glad to provide one. + * + * FEATURES + * - careful adherence to specs regarding flags, field width and precision; + * - good performance for large string handling (large format, large + * argument or large paddings). Performance is similar to system's sprintf + * and in several cases significantly better (make sure you compile with + * optimizations turned on, tell the compiler the code is strict ANSI + * if necessary to give it more freedom for optimizations); + * - return value semantics per ISO/IEC 9899:1999 ("ISO C99"); + * - written in standard ISO/ANSI C - requires an ANSI C compiler. + * + * SUPPORTED CONVERSION SPECIFIERS AND DATA TYPES + * + * This snprintf only supports the following conversion specifiers: + * s, c, d, u, o, x, X, p (and synonyms: i, D, U, O - see below) + * with flags: '-', '+', ' ', '0' and '#'. + * An asterisk is supported for field width as well as precision. + * + * Length modifiers 'h' (short int), 'l' (long int), + * and 'll' (long long int) are supported. + * NOTE: + * If macro SNPRINTF_LONGLONG_SUPPORT is not defined (default) the + * length modifier 'll' is recognized but treated the same as 'l', + * which may cause argument value truncation! Defining + * SNPRINTF_LONGLONG_SUPPORT requires that your system's sprintf also + * handles length modifier 'll'. long long int is a language extension + * which may not be portable. + * + * Conversion of numeric data (conversion specifiers d, u, o, x, X, p) + * with length modifiers (none or h, l, ll) is left to the system routine + * sprintf, but all handling of flags, field width and precision as well as + * c and s conversions is done very carefully by this portable routine. + * If a string precision (truncation) is specified (e.g. %.8s) it is + * guaranteed the string beyond the specified precision will not be referenced. + * + * Length modifiers h, l and ll are ignored for c and s conversions (data + * types wint_t and wchar_t are not supported). + * + * The following common synonyms for conversion characters are supported: + * - i is a synonym for d + * - D is a synonym for ld, explicit length modifiers are ignored + * - U is a synonym for lu, explicit length modifiers are ignored + * - O is a synonym for lo, explicit length modifiers are ignored + * The D, O and U conversion characters are nonstandard, they are supported + * for backward compatibility only, and should not be used for new code. + * + * The following is specifically NOT supported: + * - flag ' (thousands' grouping character) is recognized but ignored + * - numeric conversion specifiers: f, e, E, g, G and synonym F, + * as well as the new a and A conversion specifiers + * - length modifier 'L' (long double) and 'q' (quad - use 'll' instead) + * - wide character/string conversions: lc, ls, and nonstandard + * synonyms C and S + * - writeback of converted string length: conversion character n + * - the n$ specification for direct reference to n-th argument + * - locales + * + * It is permitted for str_m to be zero, and it is permitted to specify NULL + * pointer for resulting string argument if str_m is zero (as per ISO C99). + * + * The return value is the number of characters which would be generated + * for the given input, excluding the trailing null. If this value + * is greater or equal to str_m, not all characters from the result + * have been stored in str, output bytes beyond the (str_m-1) -th character + * are discarded. If str_m is greater than zero it is guaranteed + * the resulting string will be null-terminated. + * + * NOTE that this matches the ISO C99, OpenBSD, and GNU C library 2.1, + * but is different from some older and vendor implementations, + * and is also different from XPG, XSH5, SUSv2 specifications. + * For historical discussion on changes in the semantics and standards + * of snprintf see printf(3) man page in the Linux programmers manual. + * + * Routines asprintf and vasprintf return a pointer (in the ptr argument) + * to a buffer sufficiently large to hold the resulting string. This pointer + * should be passed to free(3) to release the allocated storage when it is + * no longer needed. If sufficient space cannot be allocated, these functions + * will return -1 and set ptr to be a NULL pointer. These two routines are a + * GNU C library extensions (glibc). + * + * Routines asnprintf and vasnprintf are similar to asprintf and vasprintf, + * yet, like snprintf and vsnprintf counterparts, will write at most str_m-1 + * characters into the allocated output string, the last character in the + * allocated buffer then gets the terminating null. If the formatted string + * length (the return value) is greater than or equal to the str_m argument, + * the resulting string was truncated and some of the formatted characters + * were discarded. These routines present a handy way to limit the amount + * of allocated memory to some sane value. + * + * AVAILABILITY + * http://www.ijs.si/software/snprintf/ + * + * REVISION HISTORY + * 1999-04 V0.9 Mark Martinec + * - initial version, some modifications after comparing printf + * man pages for Digital Unix 4.0, Solaris 2.6 and HPUX 10, + * and checking how Perl handles sprintf (differently!); + * 1999-04-09 V1.0 Mark Martinec + * - added main test program, fixed remaining inconsistencies, + * added optional (long long int) support; + * 1999-04-12 V1.1 Mark Martinec + * - support the 'p' conversion (pointer to void); + * - if a string precision is specified + * make sure the string beyond the specified precision + * will not be referenced (e.g. by strlen); + * 1999-04-13 V1.2 Mark Martinec + * - support synonyms %D=%ld, %U=%lu, %O=%lo; + * - speed up the case of long format string with few conversions; + * 1999-06-30 V1.3 Mark Martinec + * - fixed runaway loop (eventually crashing when str_l wraps + * beyond 2^31) while copying format string without + * conversion specifiers to a buffer that is too short + * (thanks to Edwin Young for + * spotting the problem); + * - added macros PORTABLE_SNPRINTF_VERSION_(MAJOR|MINOR) + * to snprintf.h + * 2000-02-14 V2.0 (never released) Mark Martinec + * - relaxed license terms: The Artistic License now applies. + * You may still apply the GNU GENERAL PUBLIC LICENSE + * as was distributed with previous versions, if you prefer; + * - changed REVISION HISTORY dates to use ISO 8601 date format; + * - added vsnprintf (patch also independently proposed by + * Caolan McNamara 2000-05-04, and Keith M Willenson 2000-06-01) + * 2000-06-27 V2.1 Mark Martinec + * - removed POSIX check for str_m<1; value 0 for str_m is + * allowed by ISO C99 (and GNU C library 2.1) - (pointed out + * on 2000-05-04 by Caolan McNamara, caolan@ csn dot ul dot ie). + * Besides relaxed license this change in standards adherence + * is the main reason to bump up the major version number; + * - added nonstandard routines asnprintf, vasnprintf, asprintf, + * vasprintf that dynamically allocate storage for the + * resulting string; these routines are not compiled by default, + * see comments where NEED_V?ASN?PRINTF macros are defined; + * - autoconf contributed by Caolan McNamara + * 2000-10-06 V2.2 Mark Martinec + * - BUG FIX: the %c conversion used a temporary variable + * that was no longer in scope when referenced, + * possibly causing incorrect resulting character; + * - BUG FIX: make precision and minimal field width unsigned + * to handle huge values (2^31 <= n < 2^32) correctly; + * also be more careful in the use of signed/unsigned/size_t + * internal variables - probably more careful than many + * vendor implementations, but there may still be a case + * where huge values of str_m, precision or minimal field + * could cause incorrect behaviour; + * - use separate variables for signed/unsigned arguments, + * and for short/int, long, and long long argument lengths + * to avoid possible incompatibilities on certain + * computer architectures. Also use separate variable + * arg_sign to hold sign of a numeric argument, + * to make code more transparent; + * - some fiddling with zero padding and "0x" to make it + * Linux compatible; + * - systematically use macros fast_memcpy and fast_memset + * instead of case-by-case hand optimization; determine some + * breakeven string lengths for different architectures; + * - terminology change: 'format' -> 'conversion specifier', + * 'C9x' -> 'ISO/IEC 9899:1999 ("ISO C99")', + * 'alternative form' -> 'alternate form', + * 'data type modifier' -> 'length modifier'; + * - several comments rephrased and new ones added; + * - make compiler not complain about 'credits' defined but + * not used; + */ + + +/* Define HAVE_SNPRINTF if your system already has snprintf and vsnprintf. + * + * If HAVE_SNPRINTF is defined this module will not produce code for + * snprintf and vsnprintf, unless PREFER_PORTABLE_SNPRINTF is defined as well, + * causing this portable version of snprintf to be called portable_snprintf + * (and portable_vsnprintf). + */ +/* #define HAVE_SNPRINTF */ + +/* Define PREFER_PORTABLE_SNPRINTF if your system does have snprintf and + * vsnprintf but you would prefer to use the portable routine(s) instead. + * In this case the portable routine is declared as portable_snprintf + * (and portable_vsnprintf) and a macro 'snprintf' (and 'vsnprintf') + * is defined to expand to 'portable_v?snprintf' - see file snprintf.h . + * Defining this macro is only useful if HAVE_SNPRINTF is also defined, + * but does does no harm if defined nevertheless. + */ +/* #define PREFER_PORTABLE_SNPRINTF */ + +/* Define SNPRINTF_LONGLONG_SUPPORT if you want to support + * data type (long long int) and length modifier 'll' (e.g. %lld). + * If undefined, 'll' is recognized but treated as a single 'l'. + * + * If the system's sprintf does not handle 'll' + * the SNPRINTF_LONGLONG_SUPPORT must not be defined! + * + * This is off by default as (long long int) is a language extension. + */ +/* #define SNPRINTF_LONGLONG_SUPPORT */ + +/* Define NEED_SNPRINTF_ONLY if you only need snprintf, and not vsnprintf. + * If NEED_SNPRINTF_ONLY is defined, the snprintf will be defined directly, + * otherwise both snprintf and vsnprintf routines will be defined + * and snprintf will be a simple wrapper around vsnprintf, at the expense + * of an extra procedure call. + */ +/* #define NEED_SNPRINTF_ONLY */ + +/* Define NEED_V?ASN?PRINTF macros if you need library extension + * routines asprintf, vasprintf, asnprintf, vasnprintf respectively, + * and your system library does not provide them. They are all small + * wrapper routines around portable_vsnprintf. Defining any of the four + * NEED_V?ASN?PRINTF macros automatically turns off NEED_SNPRINTF_ONLY + * and turns on PREFER_PORTABLE_SNPRINTF. + * + * Watch for name conflicts with the system library if these routines + * are already present there. + * + * NOTE: vasprintf and vasnprintf routines need va_copy() from stdarg.h, as + * specified by C99, to be able to traverse the same list of arguments twice. + * I don't know of any other standard and portable way of achieving the same. + * With some versions of gcc you may use __va_copy(). You might even get away + * with "ap2 = ap", in this case you must not call va_end(ap2) ! + * #define va_copy(ap2,ap) ap2 = ap + */ +/* #define NEED_ASPRINTF */ +/* #define NEED_ASNPRINTF */ +/* #define NEED_VASPRINTF */ +/* #define NEED_VASNPRINTF */ + + +/* Define the following macros if desired: + * SOLARIS_COMPATIBLE, SOLARIS_BUG_COMPATIBLE, + * HPUX_COMPATIBLE, HPUX_BUG_COMPATIBLE, LINUX_COMPATIBLE, + * DIGITAL_UNIX_COMPATIBLE, DIGITAL_UNIX_BUG_COMPATIBLE, + * PERL_COMPATIBLE, PERL_BUG_COMPATIBLE, + * + * - For portable applications it is best not to rely on peculiarities + * of a given implementation so it may be best not to define any + * of the macros that select compatibility and to avoid features + * that vary among the systems. + * + * - Selecting compatibility with more than one operating system + * is not strictly forbidden but is not recommended. + * + * - 'x'_BUG_COMPATIBLE implies 'x'_COMPATIBLE . + * + * - 'x'_COMPATIBLE refers to (and enables) a behaviour that is + * documented in a sprintf man page on a given operating system + * and actually adhered to by the system's sprintf (but not on + * most other operating systems). It may also refer to and enable + * a behaviour that is declared 'undefined' or 'implementation specific' + * in the man page but a given implementation behaves predictably + * in a certain way. + * + * - 'x'_BUG_COMPATIBLE refers to (and enables) a behaviour of system's sprintf + * that contradicts the sprintf man page on the same operating system. + * + * - I do not claim that the 'x'_COMPATIBLE and 'x'_BUG_COMPATIBLE + * conditionals take into account all idiosyncrasies of a particular + * implementation, there may be other incompatibilities. + */ + + + +/* ============================================= */ +/* NO USER SERVICABLE PARTS FOLLOWING THIS POINT */ +/* ============================================= */ + +#define PORTABLE_SNPRINTF_VERSION_MAJOR 2 +#define PORTABLE_SNPRINTF_VERSION_MINOR 2 + +#if defined(NEED_ASPRINTF) || defined(NEED_ASNPRINTF) || defined(NEED_VASPRINTF) || defined(NEED_VASNPRINTF) +# if defined(NEED_SNPRINTF_ONLY) +# undef NEED_SNPRINTF_ONLY +# endif +# if !defined(PREFER_PORTABLE_SNPRINTF) +# define PREFER_PORTABLE_SNPRINTF +# endif +#endif + +#if defined(SOLARIS_BUG_COMPATIBLE) && !defined(SOLARIS_COMPATIBLE) +#define SOLARIS_COMPATIBLE +#endif + +#if defined(HPUX_BUG_COMPATIBLE) && !defined(HPUX_COMPATIBLE) +#define HPUX_COMPATIBLE +#endif + +#if defined(DIGITAL_UNIX_BUG_COMPATIBLE) && !defined(DIGITAL_UNIX_COMPATIBLE) +#define DIGITAL_UNIX_COMPATIBLE +#endif + +#if defined(PERL_BUG_COMPATIBLE) && !defined(PERL_COMPATIBLE) +#define PERL_COMPATIBLE +#endif + +#if defined(LINUX_BUG_COMPATIBLE) && !defined(LINUX_COMPATIBLE) +#define LINUX_COMPATIBLE +#endif + +#include +#include +#include +#include +#include +#include +#include + +#ifdef isdigit +#undef isdigit +#endif +#define isdigit(c) ((c) >= '0' && (c) <= '9') + +/* For copying strings longer or equal to 'breakeven_point' + * it is more efficient to call memcpy() than to do it inline. + * The value depends mostly on the processor architecture, + * but also on the compiler and its optimization capabilities. + * The value is not critical, some small value greater than zero + * will be just fine if you don't care to squeeze every drop + * of performance out of the code. + * + * Small values favor memcpy, large values favor inline code. + */ +#if defined(__alpha__) || defined(__alpha) +# define breakeven_point 2 /* AXP (DEC Alpha) - gcc or cc or egcs */ +#endif +#if defined(__i386__) || defined(__i386) +# define breakeven_point 12 /* Intel Pentium/Linux - gcc 2.96 */ +#endif +#if defined(__hppa) +# define breakeven_point 10 /* HP-PA - gcc */ +#endif +#if defined(__sparc__) || defined(__sparc) +# define breakeven_point 33 /* Sun Sparc 5 - gcc 2.8.1 */ +#endif + +/* some other values of possible interest: */ +/* #define breakeven_point 8 */ /* VAX 4000 - vaxc */ +/* #define breakeven_point 19 */ /* VAX 4000 - gcc 2.7.0 */ + +#ifndef breakeven_point +# define breakeven_point 6 /* some reasonable one-size-fits-all value */ +#endif + +#define fast_memcpy(d,s,n) \ + { register size_t nn = (size_t)(n); \ + if (nn >= breakeven_point) memcpy((d), (s), nn); \ + else if (nn > 0) { /* proc call overhead is worth only for large strings*/\ + register char *dd; register const char *ss; \ + for (ss=(s), dd=(d); nn>0; nn--) *dd++ = *ss++; } } + +#define fast_memset(d,c,n) \ + { register size_t nn = (size_t)(n); \ + if (nn >= breakeven_point) memset((d), (int)(c), nn); \ + else if (nn > 0) { /* proc call overhead is worth only for large strings*/\ + register char *dd; register const int cc=(int)(c); \ + for (dd=(d); nn>0; nn--) *dd++ = cc; } } + +/* prototypes */ + +#if defined(NEED_ASPRINTF) +int asprintf (char **ptr, const char *fmt, /*args*/ ...); +#endif +#if defined(NEED_VASPRINTF) +int vasprintf (char **ptr, const char *fmt, va_list ap); +#endif +#if defined(NEED_ASNPRINTF) +int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...); +#endif +#if defined(NEED_VASNPRINTF) +int vasnprintf (char **ptr, size_t str_m, const char *fmt, va_list ap); +#endif + +#if defined(HAVE_SNPRINTF) +/* declare our portable snprintf routine under name portable_snprintf */ +/* declare our portable vsnprintf routine under name portable_vsnprintf */ +#else +/* declare our portable routines under names snprintf and vsnprintf */ +#define portable_snprintf snprintf +#if !defined(NEED_SNPRINTF_ONLY) +#define portable_vsnprintf vsnprintf +#endif +#endif + +#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF) +int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...); +#if !defined(NEED_SNPRINTF_ONLY) +int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap); +#endif +#endif + +/* declarations */ + +#if !defined(HAVE_SNPRINTF) + +static char credits[] = "\n\ +@(#)snprintf.c, v2.2: Mark Martinec, \n\ +@(#)snprintf.c, v2.2: Copyright 1999, Mark Martinec. Frontier Artistic License applies.\n\ +@(#)snprintf.c, v2.2: http://www.ijs.si/software/snprintf/\n"; + +#endif + +#if defined(NEED_ASPRINTF) +int asprintf(char **ptr, const char *fmt, /*args*/ ...) { + va_list ap; + size_t str_m; + int str_l; + + *ptr = NULL; + va_start(ap, fmt); /* measure the required size */ + str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap); + va_end(ap); + assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ + *ptr = (char *) malloc(str_m = (size_t)str_l + 1); + if (*ptr == NULL) { errno = ENOMEM; str_l = -1; } + else { + int str_l2; + va_start(ap, fmt); + str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); + va_end(ap); + assert(str_l2 == str_l); + } + return str_l; +} +#endif + +#if defined(NEED_VASPRINTF) +int vasprintf(char **ptr, const char *fmt, va_list ap) { + size_t str_m; + int str_l; + + *ptr = NULL; + { va_list ap2; + va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */ + str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/ + va_end(ap2); + } + assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ + *ptr = (char *) malloc(str_m = (size_t)str_l + 1); + if (*ptr == NULL) { errno = ENOMEM; str_l = -1; } + else { + int str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); + assert(str_l2 == str_l); + } + return str_l; +} +#endif + +#if defined(NEED_ASNPRINTF) +int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...) { + va_list ap; + int str_l; + + *ptr = NULL; + va_start(ap, fmt); /* measure the required size */ + str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap); + va_end(ap); + assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ + if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */ + /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */ + if (str_m == 0) { /* not interested in resulting string, just return size */ + } else { + *ptr = (char *) malloc(str_m); + if (*ptr == NULL) { errno = ENOMEM; str_l = -1; } + else { + int str_l2; + va_start(ap, fmt); + str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); + va_end(ap); + assert(str_l2 == str_l); + } + } + return str_l; +} +#endif + +#if defined(NEED_VASNPRINTF) +int vasnprintf (char **ptr, size_t str_m, const char *fmt, va_list ap) { + int str_l; + + *ptr = NULL; + { va_list ap2; + va_copy(ap2, ap); /* don't consume the original ap, we'll need it again */ + str_l = portable_vsnprintf(NULL, (size_t)0, fmt, ap2);/*get required size*/ + va_end(ap2); + } + assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ + if ((size_t)str_l + 1 < str_m) str_m = (size_t)str_l + 1; /* truncate */ + /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */ + if (str_m == 0) { /* not interested in resulting string, just return size */ + } else { + *ptr = (char *) malloc(str_m); + if (*ptr == NULL) { errno = ENOMEM; str_l = -1; } + else { + int str_l2 = portable_vsnprintf(*ptr, str_m, fmt, ap); + assert(str_l2 == str_l); + } + } + return str_l; +} +#endif + +/* + * If the system does have snprintf and the portable routine is not + * specifically required, this module produces no code for snprintf/vsnprintf. + */ +#if !defined(HAVE_SNPRINTF) || defined(PREFER_PORTABLE_SNPRINTF) + +#if !defined(NEED_SNPRINTF_ONLY) +int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...) { + va_list ap; + int str_l; + + va_start(ap, fmt); + str_l = portable_vsnprintf(str, str_m, fmt, ap); + va_end(ap); + return str_l; +} +#endif + +#if defined(NEED_SNPRINTF_ONLY) +int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...) { +#else +int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) { +#endif + +#if defined(NEED_SNPRINTF_ONLY) + va_list ap; +#endif + size_t str_l = 0; + const char *p = fmt; + +/* In contrast with POSIX, the ISO C99 now says + * that str can be NULL and str_m can be 0. + * This is more useful than the old: if (str_m < 1) return -1; */ + +#if defined(NEED_SNPRINTF_ONLY) + va_start(ap, fmt); +#endif + if (!p) p = ""; + while (*p) { + if (*p != '%') { + /* if (str_l < str_m) str[str_l++] = *p++; -- this would be sufficient */ + /* but the following code achieves better performance for cases + * where format string is long and contains few conversions */ + const char *q = strchr(p+1,'%'); + size_t n = !q ? strlen(p) : (q-p); + if (str_l < str_m) { + size_t avail = str_m-str_l; + fast_memcpy(str+str_l, p, (n>avail?avail:n)); + } + p += n; str_l += n; + } else { + const char *starting_p; + size_t min_field_width = 0, precision = 0; + int zero_padding = 0, precision_specified = 0, justify_left = 0; + int alternate_form = 0, force_sign = 0; + int space_for_positive = 1; /* If both the ' ' and '+' flags appear, + the ' ' flag should be ignored. */ + char length_modifier = '\0'; /* allowed values: \0, h, l, L */ + char tmp[32];/* temporary buffer for simple numeric->string conversion */ + + const char *str_arg; /* string address in case of string argument */ + size_t str_arg_l; /* natural field width of arg without padding + and sign */ + unsigned char uchar_arg; + /* unsigned char argument value - only defined for c conversion. + N.B. standard explicitly states the char argument for + the c conversion is unsigned */ + + size_t number_of_zeros_to_pad = 0; + /* number of zeros to be inserted for numeric conversions + as required by the precision or minimal field width */ + + size_t zero_padding_insertion_ind = 0; + /* index into tmp where zero padding is to be inserted */ + + char fmt_spec = '\0'; + /* current conversion specifier character */ + + unused(credits);/* just to make compiler happy (defined but not used)*/ + str_arg = NULL; + starting_p = p; p++; /* skip '%' */ + /* parse flags */ + while (*p == '0' || *p == '-' || *p == '+' || + *p == ' ' || *p == '#' || *p == '\'') { + switch (*p) { + case '0': zero_padding = 1; break; + case '-': justify_left = 1; break; + case '+': force_sign = 1; space_for_positive = 0; break; + case ' ': force_sign = 1; + /* If both the ' ' and '+' flags appear, the ' ' flag should be ignored */ +#ifdef PERL_COMPATIBLE + /* ... but in Perl the last of ' ' and '+' applies */ + space_for_positive = 1; +#endif + break; + case '#': alternate_form = 1; break; + case '\'': break; + } + p++; + } + /* If the '0' and '-' flags both appear, the '0' flag should be ignored. */ + + /* parse field width */ + if (*p == '*') { + int j; + p++; j = va_arg(ap, int); + if (j >= 0) min_field_width = j; + else { min_field_width = -j; justify_left = 1; } + } else if (isdigit((int)(*p))) { + /* size_t could be wider than unsigned int; + make sure we treat argument like common implementations do */ + unsigned int uj = *p++ - '0'; + while (isdigit((int)(*p))) uj = 10*uj + (unsigned int)(*p++ - '0'); + min_field_width = uj; + } + /* parse precision */ + if (*p == '.') { + p++; precision_specified = 1; + if (*p == '*') { + int j = va_arg(ap, int); + p++; + if (j >= 0) precision = j; + else { + precision_specified = 0; precision = 0; + /* NOTE: + * Solaris 2.6 man page claims that in this case the precision + * should be set to 0. Digital Unix 4.0, HPUX 10 and BSD man page + * claim that this case should be treated as unspecified precision, + * which is what we do here. + */ + } + } else if (isdigit((int)(*p))) { + /* size_t could be wider than unsigned int; + make sure we treat argument like common implementations do */ + unsigned int uj = *p++ - '0'; + while (isdigit((int)(*p))) uj = 10*uj + (unsigned int)(*p++ - '0'); + precision = uj; + } + } + /* parse 'h', 'l' and 'll' length modifiers */ + if (*p == 'h' || *p == 'l') { + length_modifier = *p; p++; + if (length_modifier == 'l' && *p == 'l') { /* double l = long long */ +#ifdef SNPRINTF_LONGLONG_SUPPORT + length_modifier = '2'; /* double l encoded as '2' */ +#else + length_modifier = 'l'; /* treat it as a single 'l' */ +#endif + p++; + } + } + fmt_spec = *p; + /* common synonyms: */ + switch (fmt_spec) { + case 'i': fmt_spec = 'd'; break; + case 'D': fmt_spec = 'd'; length_modifier = 'l'; break; + case 'U': fmt_spec = 'u'; length_modifier = 'l'; break; + case 'O': fmt_spec = 'o'; length_modifier = 'l'; break; + default: break; + } + /* get parameter value, do initial processing */ + switch (fmt_spec) { + case '%': /* % behaves similar to 's' regarding flags and field widths */ + case 'c': /* c behaves similar to 's' regarding flags and field widths */ + case 's': + length_modifier = '\0'; /* wint_t and wchar_t not supported */ + /* the result of zero padding flag with non-numeric conversion specifier*/ + /* is undefined. Solaris and HPUX 10 does zero padding in this case, */ + /* Digital Unix and Linux does not. */ +#if !defined(SOLARIS_COMPATIBLE) && !defined(HPUX_COMPATIBLE) + zero_padding = 0; /* turn zero padding off for string conversions */ +#endif + str_arg_l = 1; + switch (fmt_spec) { + case '%': + str_arg = p; break; + case 'c': { + int j = va_arg(ap, int); + uchar_arg = (unsigned char) j; /* standard demands unsigned char */ + str_arg = (const char *) &uchar_arg; + break; + } + case 's': + str_arg = va_arg(ap, const char *); + if (!str_arg) str_arg_l = 0; + /* make sure not to address string beyond the specified precision !!! */ + else if (!precision_specified) str_arg_l = strlen(str_arg); + /* truncate string if necessary as requested by precision */ + else if (precision == 0) str_arg_l = 0; + else { + /* memchr on HP does not like n > 2^31 !!! */ + const char *q = memchr(str_arg, '\0', + precision <= 0x7fffffff ? precision : 0x7fffffff); + str_arg_l = !q ? precision : (q-str_arg); + } + break; + default: break; + } + break; + case 'd': case 'u': case 'o': case 'x': case 'X': case 'p': { + /* NOTE: the u, o, x, X and p conversion specifiers imply + the value is unsigned; d implies a signed value */ + + int arg_sign = 0; + /* 0 if numeric argument is zero (or if pointer is NULL for 'p'), + +1 if greater than zero (or nonzero for unsigned arguments), + -1 if negative (unsigned argument is never negative) */ + + int int_arg = 0; unsigned int uint_arg = 0; + /* only defined for length modifier h, or for no length modifiers */ + + long int long_arg = 0; unsigned long int ulong_arg = 0; + /* only defined for length modifier l */ + + void *ptr_arg = NULL; + /* pointer argument value -only defined for p conversion */ + +#ifdef SNPRINTF_LONGLONG_SUPPORT + long long int long_long_arg = 0; + unsigned long long int ulong_long_arg = 0; + /* only defined for length modifier ll */ +#endif + if (fmt_spec == 'p') { + /* HPUX 10: An l, h, ll or L before any other conversion character + * (other than d, i, u, o, x, or X) is ignored. + * Digital Unix: + * not specified, but seems to behave as HPUX does. + * Solaris: If an h, l, or L appears before any other conversion + * specifier (other than d, i, u, o, x, or X), the behavior + * is undefined. (Actually %hp converts only 16-bits of address + * and %llp treats address as 64-bit data which is incompatible + * with (void *) argument on a 32-bit system). + */ +#ifdef SOLARIS_COMPATIBLE +# ifdef SOLARIS_BUG_COMPATIBLE + /* keep length modifiers even if it represents 'll' */ +# else + if (length_modifier == '2') length_modifier = '\0'; +# endif +#else + length_modifier = '\0'; +#endif + ptr_arg = va_arg(ap, void *); + if (ptr_arg != NULL) arg_sign = 1; + } else if (fmt_spec == 'd') { /* signed */ + switch (length_modifier) { + case '\0': + case 'h': + /* It is non-portable to specify a second argument of char or short + * to va_arg, because arguments seen by the called function + * are not char or short. C converts char and short arguments + * to int before passing them to a function. + */ + int_arg = va_arg(ap, int); + if (int_arg > 0) arg_sign = 1; + else if (int_arg < 0) arg_sign = -1; + break; + case 'l': + long_arg = va_arg(ap, long int); + if (long_arg > 0) arg_sign = 1; + else if (long_arg < 0) arg_sign = -1; + break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + long_long_arg = va_arg(ap, long long int); + if (long_long_arg > 0) arg_sign = 1; + else if (long_long_arg < 0) arg_sign = -1; + break; +#endif + } + } else { /* unsigned */ + switch (length_modifier) { + case '\0': + case 'h': + uint_arg = va_arg(ap, unsigned int); + if (uint_arg) arg_sign = 1; + break; + case 'l': + ulong_arg = va_arg(ap, unsigned long int); + if (ulong_arg) arg_sign = 1; + break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': + ulong_long_arg = va_arg(ap, unsigned long long int); + if (ulong_long_arg) arg_sign = 1; + break; +#endif + } + } + str_arg = tmp; str_arg_l = 0; + /* NOTE: + * For d, i, u, o, x, and X conversions, if precision is specified, + * the '0' flag should be ignored. This is so with Solaris 2.6, + * Digital UNIX 4.0, HPUX 10, Linux, FreeBSD, NetBSD; but not with Perl. + */ +#ifndef PERL_COMPATIBLE + if (precision_specified) zero_padding = 0; +#endif + if (fmt_spec == 'd') { + if (force_sign && arg_sign >= 0) + tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; + /* leave negative numbers for sprintf to handle, + to avoid handling tricky cases like (short int)(-32768) */ +#ifdef LINUX_COMPATIBLE + } else if (fmt_spec == 'p' && force_sign && arg_sign > 0) { + tmp[str_arg_l++] = space_for_positive ? ' ' : '+'; +#endif + } else if (alternate_form) { + if (arg_sign != 0 && (fmt_spec == 'x' || fmt_spec == 'X') ) + { tmp[str_arg_l++] = '0'; tmp[str_arg_l++] = fmt_spec; } + /* alternate form should have no effect for p conversion, but ... */ +#ifdef HPUX_COMPATIBLE + else if (fmt_spec == 'p' + /* HPUX 10: for an alternate form of p conversion, + * a nonzero result is prefixed by 0x. */ +#ifndef HPUX_BUG_COMPATIBLE + /* Actually it uses 0x prefix even for a zero value. */ + && arg_sign != 0 +#endif + ) { tmp[str_arg_l++] = '0'; tmp[str_arg_l++] = 'x'; } +#endif + } + zero_padding_insertion_ind = str_arg_l; + if (!precision_specified) precision = 1; /* default precision is 1 */ + if (precision == 0 && arg_sign == 0 +#if defined(HPUX_BUG_COMPATIBLE) || defined(LINUX_COMPATIBLE) + && fmt_spec != 'p' + /* HPUX 10 man page claims: With conversion character p the result of + * converting a zero value with a precision of zero is a null string. + * Actually HP returns all zeroes, and Linux returns "(nil)". */ +#endif + ) { + /* converted to null string */ + /* When zero value is formatted with an explicit precision 0, + the resulting formatted string is empty (d, i, u, o, x, X, p). */ + } else { + char f[5]; int f_l = 0; + f[f_l++] = '%'; /* construct a simple format string for sprintf */ + if (!length_modifier) { } + else if (length_modifier=='2') { f[f_l++] = 'l'; f[f_l++] = 'l'; } + else f[f_l++] = length_modifier; + f[f_l++] = fmt_spec; f[f_l++] = '\0'; + if (fmt_spec == 'p') str_arg_l += sprintf(tmp+str_arg_l, f, ptr_arg); + else if (fmt_spec == 'd') { /* signed */ + switch (length_modifier) { + case '\0': + case 'h': str_arg_l+=sprintf(tmp+str_arg_l, f, int_arg); break; + case 'l': str_arg_l+=sprintf(tmp+str_arg_l, f, long_arg); break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': str_arg_l+=sprintf(tmp+str_arg_l,f,long_long_arg); break; +#endif + } + } else { /* unsigned */ + switch (length_modifier) { + case '\0': + case 'h': str_arg_l+=sprintf(tmp+str_arg_l, f, uint_arg); break; + case 'l': str_arg_l+=sprintf(tmp+str_arg_l, f, ulong_arg); break; +#ifdef SNPRINTF_LONGLONG_SUPPORT + case '2': str_arg_l+=sprintf(tmp+str_arg_l,f,ulong_long_arg);break; +#endif + } + } + /* include the optional minus sign and possible "0x" + in the region before the zero padding insertion point */ + if (zero_padding_insertion_ind < str_arg_l && + tmp[zero_padding_insertion_ind] == '-') { + zero_padding_insertion_ind++; + } + if (zero_padding_insertion_ind+1 < str_arg_l && + tmp[zero_padding_insertion_ind] == '0' && + (tmp[zero_padding_insertion_ind+1] == 'x' || + tmp[zero_padding_insertion_ind+1] == 'X') ) { + zero_padding_insertion_ind += 2; + } + } + { size_t num_of_digits = str_arg_l - zero_padding_insertion_ind; + if (alternate_form && fmt_spec == 'o' +#ifdef HPUX_COMPATIBLE /* ("%#.o",0) -> "" */ + && (str_arg_l > 0) +#endif +#ifdef DIGITAL_UNIX_BUG_COMPATIBLE /* ("%#o",0) -> "00" */ +#else + /* unless zero is already the first character */ + && !(zero_padding_insertion_ind < str_arg_l + && tmp[zero_padding_insertion_ind] == '0') +#endif + ) { /* assure leading zero for alternate-form octal numbers */ + if (!precision_specified || precision < num_of_digits+1) { + /* precision is increased to force the first character to be zero, + except if a zero value is formatted with an explicit precision + of zero */ + precision = num_of_digits+1; precision_specified = 1; + } + } + /* zero padding to specified precision? */ + if (num_of_digits < precision) + number_of_zeros_to_pad = precision - num_of_digits; + } + /* zero padding to specified minimal field width? */ + if (!justify_left && zero_padding) { + int n = min_field_width - (str_arg_l+number_of_zeros_to_pad); + if (n > 0) number_of_zeros_to_pad += n; + } + break; + } + default: /* unrecognized conversion specifier, keep format string as-is*/ + zero_padding = 0; /* turn zero padding off for non-numeric convers. */ +#ifndef DIGITAL_UNIX_COMPATIBLE + justify_left = 1; min_field_width = 0; /* reset flags */ +#endif +#if defined(PERL_COMPATIBLE) || defined(LINUX_COMPATIBLE) + /* keep the entire format string unchanged */ + str_arg = starting_p; str_arg_l = p - starting_p; + /* well, not exactly so for Linux, which does something inbetween, + * and I don't feel an urge to imitate it: "%+++++hy" -> "%+y" */ +#else + /* discard the unrecognized conversion, just keep * + * the unrecognized conversion character */ + str_arg = p; str_arg_l = 0; +#endif + if (*p) str_arg_l++; /* include invalid conversion specifier unchanged + if not at end-of-string */ + break; + } + if (*p) p++; /* step over the just processed conversion specifier */ + /* insert padding to the left as requested by min_field_width; + this does not include the zero padding in case of numerical conversions*/ + if (!justify_left) { /* left padding with blank or zero */ + int n = min_field_width - (str_arg_l+number_of_zeros_to_pad); + if (n > 0) { + if (str_l < str_m) { + size_t avail = str_m-str_l; + fast_memset(str+str_l, (zero_padding?'0':' '), (n>avail?avail:n)); + } + str_l += n; + } + } + /* zero padding as requested by the precision or by the minimal field width + * for numeric conversions required? */ + if (number_of_zeros_to_pad <= 0) { + /* will not copy first part of numeric right now, * + * force it to be copied later in its entirety */ + zero_padding_insertion_ind = 0; + } else { + /* insert first part of numerics (sign or '0x') before zero padding */ + int n = zero_padding_insertion_ind; + if (n > 0) { + if (str_l < str_m) { + size_t avail = str_m-str_l; + fast_memcpy(str+str_l, str_arg, (n>avail?avail:n)); + } + str_l += n; + } + /* insert zero padding as requested by the precision or min field width */ + n = number_of_zeros_to_pad; + if (n > 0) { + if (str_l < str_m) { + size_t avail = str_m-str_l; + fast_memset(str+str_l, '0', (n>avail?avail:n)); + } + str_l += n; + } + } + /* insert formatted string + * (or as-is conversion specifier for unknown conversions) */ + { int n = str_arg_l - zero_padding_insertion_ind; + if (n > 0) { + if (str_l < str_m) { + size_t avail = str_m-str_l; + fast_memcpy(str+str_l, str_arg+zero_padding_insertion_ind, + (n>avail?avail:n)); + } + str_l += n; + } + } + /* insert right padding */ + if (justify_left) { /* right blank padding to the field width */ + int n = min_field_width - (str_arg_l+number_of_zeros_to_pad); + if (n > 0) { + if (str_l < str_m) { + size_t avail = str_m-str_l; + fast_memset(str+str_l, ' ', (n>avail?avail:n)); + } + str_l += n; + } + } + } + } +#if defined(NEED_SNPRINTF_ONLY) + va_end(ap); +#endif + if (str_m > 0) { /* make sure the string is null-terminated + even at the expense of overwriting the last character + (shouldn't happen, but just in case) */ + str[str_l <= str_m-1 ? str_l : str_m-1] = '\0'; + } + /* Return the number of characters formatted (excluding trailing null + * character), that is, the number of characters that would have been + * written to the buffer if it were large enough. + * + * The value of str_l should be returned, but str_l is of unsigned type + * size_t, and snprintf is int, possibly leading to an undetected + * integer overflow, resulting in a negative return value, which is illegal. + * Both XSH5 and ISO C99 (at least the draft) are silent on this issue. + * Should errno be set to EOVERFLOW and EOF returned in this case??? + */ + return (int) str_l; +} +#endif diff -Nru makenl-3.3.3/src/snprintf.h makenl-3.4.1/src/snprintf.h --- makenl-3.3.3/src/snprintf.h 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/snprintf.h 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,30 @@ +#ifndef _PORTABLE_SNPRINTF_H_ +#define _PORTABLE_SNPRINTF_H_ + +#include + +#include "os.h" + +#define PORTABLE_SNPRINTF_VERSION_MAJOR 2 +#define PORTABLE_SNPRINTF_VERSION_MINOR 2 + +#ifdef HAVE_SNPRINTF +#include +#else +extern int snprintf(char *, size_t, const char *, /*args*/ ...); +extern int vsnprintf(char *, size_t, const char *, va_list); +#endif + +#if defined(HAVE_SNPRINTF) && defined(PREFER_PORTABLE_SNPRINTF) +extern int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...); +extern int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap); +#define snprintf portable_snprintf +#define vsnprintf portable_vsnprintf +#endif + +extern int asprintf (char **ptr, const char *fmt, /*args*/ ...); +extern int vasprintf (char **ptr, const char *fmt, va_list ap); +extern int asnprintf (char **ptr, size_t str_m, const char *fmt, /*args*/ ...); +extern int vasnprintf(char **ptr, size_t str_m, const char *fmt, va_list ap); + +#endif diff -Nru makenl-3.3.3/src/spawn.asm makenl-3.4.1/src/spawn.asm --- makenl-3.3.3/src/spawn.asm 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/spawn.asm 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -; $Id: spawn.asm,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ +; $Id: spawn.asm,v 1.1 2009/01/08 20:07:47 mbroek Exp $ ;MODIFIED 5th October 1995 by Matthew Parker all changes are public domain. diff -Nru makenl-3.3.3/src/spawn.h makenl-3.4.1/src/spawn.h --- makenl-3.3.3/src/spawn.h 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/spawn.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: spawn.h,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ +/* $Id: spawn.h,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ /* * SPAWN.H diff -Nru makenl-3.3.3/src/stack.c makenl-3.4.1/src/stack.c --- makenl-3.3.3/src/stack.c 2012-10-16 09:01:54.000000000 +0000 +++ makenl-3.4.1/src/stack.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: stack.c,v 1.5 2012/10/16 09:01:54 ozzmosis Exp $ */ +/* $Id: stack.c,v 1.7 2013/09/25 19:29:56 ozzmosis Exp $ */ #include #include @@ -12,16 +12,9 @@ #include "fts5.h" #include "msg.h" #include "stack.h" +#include "snprintf.h" #include "mklog.h" -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - static int *NumberStackPtr = NULL; static int NStackWritePtr, NStackReadPtr, NumberListValid, NStackNotFull = 1, NumberStackLen; @@ -78,7 +71,7 @@ { if (*numberptr == makenum) { - sprintf(ErrorMessage, "Duplicate %s number -- '%d'", + snprintf(ErrorMessage, sizeof ErrorMessage, "Duplicate %s number -- '%d'", Describe4D[NumberListValid], makenum); if (NumberListValid >= A_NODE) status = 1; diff -Nru makenl-3.3.3/src/stack.h makenl-3.4.1/src/stack.h --- makenl-3.3.3/src/stack.h 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/stack.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: stack.h,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ +/* $Id: stack.h,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ int addnumber(int maketype, int makenum, int markpos); void unmarkstack(void); diff -Nru makenl-3.3.3/src/strtool.c makenl-3.4.1/src/strtool.c --- makenl-3.3.3/src/strtool.c 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/strtool.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,17 +1,9 @@ -/* $Id: strtool.c,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ +/* $Id: strtool.c,v 1.7 2013/09/25 19:39:07 ozzmosis Exp $ */ #include #include #include -#include "makenl.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif +#include "strtool.h" int getnumber(const char *string, int *output) { @@ -67,3 +59,88 @@ *(p + 1) = 0; return string; } + +char *strupper(char *string) +{ + char *orig; + + if (string == NULL) + { + return NULL; + } + + orig = string; + + while (*string != '\0') + { + *string = (char) toupper((int) *string); + string++; + } + + return orig; +} + + +/* + * strlcpy() and strlcat() + * + * From http://www.di-mgt.com.au/cprog.html#strlcpy + * + * It is not wise to use the ANSI standard strcpy and strcat functions + * because of the possibility of unchecked buffer overflows. The strncpy + * function has the problem that it may not properly terminate the string. + * The following strlcpy and strlcat functions are simple implementations + * that overcome the problems of their original ANSI ancestors + * (last updated 2011-12-11). + * + * These functions are guaranteed not to cause a buffer overflow and the + * result is always null-terminated. If there is not enough room in the + * destination buffer, then it truncates the output. The return value is + * the number of bytes it should have copied, so you have a roundabout + * way of checking. The value of bufsize is the actual allocated size of + * the buffer, so you can use sizeof(buf) (providing buf is not a pointer). + * + * For more on the background to these functions see strlcpy and strlcat - + * consistent, safe, string copy and concatenation by Todd C. Miller and + * Theo de Raadt. + * + * The above solutions do have the disadvantage that they always do at + * least a double pass along the strings, and so are only half as + * efficient as the originals which don't. This is really only a problem + * for very long strings. + */ + +size_t strlcpy(char *d, const char *s, size_t bufsize) +{ + size_t len; + size_t ret; + + if (!d || !s || (int)bufsize <= 0) return 0; + len = strlen(s); + ret = len; + if (len >= bufsize) len = bufsize-1; + memcpy(d, s, len); + d[len] = 0; + + return ret; +} + +size_t strlcat(char *d, const char *s, size_t bufsize) +{ + size_t len1; + size_t len2; + size_t ret; + + if (!d || !s || (int)bufsize <= 0) return 0; + len1 = strlen(d); + len2 = strlen(s); + ret = len1 + len2; + if (len1+len2 >= bufsize) + len2 = bufsize - (len1 + 1); + if (len2 > 0) + { + memcpy(d+len1, s, len2); + d[len1+len2] = 0; + } + return ret; +} diff -Nru makenl-3.3.3/src/strtool.h makenl-3.4.1/src/strtool.h --- makenl-3.3.3/src/strtool.h 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/strtool.h 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,18 @@ +/* $Id: strtool.h,v 1.4 2013/09/25 19:46:00 ozzmosis Exp $ */ + +#ifndef __STRTOOL_H__ +#define __STRTOOL_H__ + +int getnumber(const char *string, int *output); +char *skipspaces(char *ptr); +char *cutspaces(char *string); +char *strupper(char *string); + +size_t strlcpy(char *d, const char *s, size_t bufsize); +size_t strlcat(char *d, const char *s, size_t bufsize); + +/* necessary for some C implementations where printf("%s\n", NULL) would cause a segfault */ + +#define make_str_safe(x) (x)?(x):"(null)" + +#endif diff -Nru makenl-3.3.3/src/testing.c makenl-3.4.1/src/testing.c --- makenl-3.3.3/src/testing.c 1970-01-01 00:00:00.000000000 +0000 +++ makenl-3.4.1/src/testing.c 2013-10-11 17:07:33.000000000 +0000 @@ -0,0 +1,138 @@ +#include +#include + +#include "makenl.h" +#include "mklog.h" +#include "os.h" +#include "strtool.h" + +#if defined(OS_DOS) +#define OS_WILDCARD "*.*" +#else +#define OS_WILDCARD "*" +#endif + +static void test_exit(int rc) +{ + mklog(LOG_INFO, "test_exit(%d)", rc); + exit(rc); +} + +static void test_findfirst(void) +{ + struct _filefind pff; + char *p; + mklog(LOG_INFO, "test_findfirst() begin"); + p = os_findfirst(&pff, DIRSEP, OS_WILDCARD); + while (p != NULL) + { + mklog(LOG_INFO, " p == '%s'", p); + p = os_findnext(&pff); + } + os_findclose(&pff); + mklog(LOG_INFO, "test_findfirst() end"); +} + +static void test_findfile(void) +{ + struct _filefind pff; + char *p; + mklog(LOG_INFO, "test_findfile() begin"); + p = os_findfile(&pff, ".", "m" OS_WILDCARD); + mklog(LOG_INFO, " os_findfile(): rc == '%s'", p); + mklog(LOG_INFO, "test_findfile() end"); +} + +static void test_file_getname(void) +{ + char *p; + mklog(LOG_INFO, "test_file_getname() begin"); + p = os_file_getname("/makenl"); + mklog(LOG_INFO, " os_file_getname(): rc == '%s'", p); + mklog(LOG_INFO, "test_file_getname() end"); +} + +static void test_fullpath(void) +{ + int rc; + char buf[MYMAXPATH]; + mklog(LOG_INFO, "test_fullpath() begin"); + rc = os_fullpath(buf, "./makenl", sizeof buf); + mklog(LOG_INFO, " os_fullpath(): rc == %d, buf == '%s'", rc, buf); + mklog(LOG_INFO, "test_fullpath() end"); +} + +static void test_fulldir(void) +{ + int rc; + char buf[MYMAXPATH]; + mklog(LOG_INFO, "test_fulldir() begin"); + rc = os_fulldir(buf, "./makenl", sizeof buf); + mklog(LOG_INFO, " os_fulldir(): rc == %d, buf == '%s'", rc, buf); + mklog(LOG_INFO, "test_fulldir() end"); +} + +static void test_slash(void) +{ + char *p, buf[MYMAXPATH]; + mklog(LOG_INFO, "test_slash() begin"); + + strlcpy(buf, "makenl", sizeof buf); + mklog(LOG_INFO, " buf == '%s'", buf); + + p = os_append_slash(buf); + mklog(LOG_INFO, " os_append_slash(buf): rc == '%s'", p); + + p = os_remove_slash(p); + mklog(LOG_INFO, " os_remove_slash(p): rc == '%s'", p); + + strlcpy(buf, "makenl/", sizeof buf); + mklog(LOG_INFO, " buf == '%s'", buf); + + /* + * os_dirsep() converts / to \ in pathnames on DOS/OS2/Win systems, + * otherwise this should be a no-op + */ + + p = os_dirsep(buf); + mklog(LOG_INFO, " os_dirsep(buf): rc == '%s'", p); + + mklog(LOG_INFO, "test_slash() end"); +} + +static void do_chdir(char *path) +{ + int rc = os_chdir(path); + mklog(LOG_INFO, " os_chdir('%s'): rc == %d", path, rc); +} + +static void test_chdir(void) +{ + mklog(LOG_INFO, "test_chdir() begin"); + +#if defined(OS_DOS) || defined(OS_OS2) || defined(OS_WIN) + do_chdir("c:\\"); + do_chdir("c:\\os2\\"); + do_chdir("c:\\windows\\"); + do_chdir("d:\\"); + do_chdir("z:\\"); + do_chdir("c:\\src\\makenl\\src\\"); +#else + do_chdir("/"); + do_chdir("/bin/"); +#endif + + mklog(LOG_INFO, "test_chdir() end"); +} + +void testing(void) +{ + test_findfirst(); + test_findfile(); + test_file_getname(); + test_fullpath(); + test_fulldir(); + test_slash(); + test_chdir(); + test_exit(0); +} diff -Nru makenl-3.3.3/src/unused.h makenl-3.4.1/src/unused.h --- makenl-3.3.3/src/unused.h 2012-10-17 11:36:54.000000000 +0000 +++ makenl-3.4.1/src/unused.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: unused.h,v 1.2 2012/10/17 11:36:54 ozzmosis Exp $ */ +/* $Id: unused.h,v 1.3 2013/09/25 20:42:16 ozzmosis Exp $ */ /* * Suppress warning about unused parameter. Written by Paul Edwards and @@ -6,11 +6,11 @@ */ #ifndef unused -#if defined(PACIFIC) || defined(_MSC_VER) || defined(__LCC__) + +#if defined(PACIFIC) || defined(_MSC_VER) || defined(__LCC__) || defined(__HIGHC__) #define unused(x) -#elif defined(__HIGHC__) -#define unused(x) ((x) = (x)) #else #define unused(x) ((void)(x)) #endif + #endif diff -Nru makenl-3.3.3/src/upcont.c makenl-3.4.1/src/upcont.c --- makenl-3.3.3/src/upcont.c 2012-10-16 09:01:54.000000000 +0000 +++ makenl-3.4.1/src/upcont.c 2013-10-11 17:07:33.000000000 +0000 @@ -1,19 +1,13 @@ -/* $Id: upcont.c,v 1.3 2012/10/16 09:01:54 ozzmosis Exp $ */ +/* $Id: upcont.c,v 1.7 2013/09/26 19:53:47 ozzmosis Exp $ */ #include #include #include "makenl.h" -#include "upcont.h" #include "fts5.h" - -#ifdef MALLOC_DEBUG -#include "rmalloc.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif +#include "snprintf.h" +#include "strtool.h" +#include "upcont.h" /* *INDENT-OFF* */ /* Don't indent this array, keep it this way (you could try what indent @@ -62,19 +56,19 @@ makeleveltxt = Node; else makeleveltxt = Levels[maketype]; - sprintf(ErrorMessage, "Expected '%s %d', got '%s %d'", + snprintf(ErrorMessage, sizeof ErrorMessage, "Expected '%s %d', got '%s %d'", makeleveltxt, makenum, leveltxt, num); return 2; } if (maketype > level) { - sprintf(ErrorMessage, "Unexpected '%s' statement in %s file", + snprintf(ErrorMessage, sizeof ErrorMessage, "Unexpected '%s' statement in %s file", Levels[level], LevelsSimple[maketype]); return 2; } if (level == maketype && maketype != LEVEL_NODE) { - sprintf(ErrorMessage, "Multiple '%s' statememts", + snprintf(ErrorMessage, sizeof ErrorMessage, "Multiple '%s' statememts", (maketype > LEVEL_HUB) ? "Node" : Levels[maketype]); return 2; } @@ -84,7 +78,7 @@ if (*ctxlevel > LEVEL_NODE) /* Catch private, hold and down nodes with points */ { - sprintf(ErrorMessage, "%s nodes may not have points\n", + snprintf(ErrorMessage, sizeof ErrorMessage, "%s nodes may not have points\n", Levels[*ctxlevel]); return 1; } @@ -93,7 +87,7 @@ case 0: /* OK */ break; case -2: /* NONE */ - strcpy(ErrorMessage, "Points not allowed in this list"); + strlcpy(ErrorMessage, "Points not allowed in this list", sizeof ErrorMessage); return 1; case -3: /* HIDE */ FTS5Phone = "-Unpublished-"; @@ -102,8 +96,7 @@ possible */ if (PointPhoneNoHolder[0] == 0) { - strcpy(ErrorMessage, - "No phone number translation available"); + strlcpy(ErrorMessage, "No phone number translation available", sizeof ErrorMessage); return 1; } if (!strcmp(FTS5Phone, "-Unpublished-")) @@ -116,21 +109,26 @@ case 0: /* OK */ break; case -2: /* NONE */ - strcpy(ErrorMessage, - "Private nodes not allowed in this network"); + strlcpy(ErrorMessage, "Private nodes not allowed in this network", sizeof ErrorMessage); return 1; default: if (PhoneNoHolder[0] == 0) { - strcpy(ErrorMessage, - "No phone number translation available"); + strlcpy(ErrorMessage, "No phone number translation available", sizeof ErrorMessage); return 1; } + FTS5Phone = PhoneNoHolder; + if (FTS5Flags[0] != 0) + { strcat(FTS5Flags, PVT); + } else + { FTS5Flags = PVT + 1; + } + return 0; } /* FALLTHROUGH */ @@ -144,7 +142,7 @@ check_level: if (OnTop[level] > *ctxlevel) { - sprintf(ErrorMessage, "'%s' not allowed in a %s", + snprintf(ErrorMessage, sizeof ErrorMessage, "'%s' not allowed in a %s", Levels[level], LevelsSimple[*ctxlevel]); if (level > LEVEL_HOST) return 1; @@ -153,9 +151,15 @@ } out: if (level <= PrivateLevel) - strcpy(PhoneNoHolder, FTS5Phone); + { + strlcpy(PhoneNoHolder, FTS5Phone, sizeof PhoneNoHolder); + } + if (level <= PointLevel) - strcpy(PointPhoneNoHolder, FTS5Phone); + { + strlcpy(PointPhoneNoHolder, FTS5Phone, sizeof PointPhoneNoHolder); + } + if (level < LEVEL_POINT) /* Points don't start a context... */ { *ctxnum = num; diff -Nru makenl-3.3.3/src/upcont.h makenl-3.4.1/src/upcont.h --- makenl-3.3.3/src/upcont.h 2009-01-08 20:07:47.000000000 +0000 +++ makenl-3.4.1/src/upcont.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,4 +1,4 @@ -/* $Id: upcont.h,v 1.1.1.1 2009/01/08 20:07:47 mbroek Exp $ */ +/* $Id: upcont.h,v 1.1 2009/01/08 20:07:47 mbroek Exp $ */ int UpdateContext(int level, int num, int makenum, int *ctxnum, int *ctxlevel, int maketype); diff -Nru makenl-3.3.3/src/version.h makenl-3.4.1/src/version.h --- makenl-3.3.3/src/version.h 2013-01-17 14:41:26.000000000 +0000 +++ makenl-3.4.1/src/version.h 2013-10-11 17:07:33.000000000 +0000 @@ -1,13 +1,16 @@ -/* $Id: version.h,v 1.18 2013/01/17 14:41:26 jame Exp $ */ +/* $Id: version.h,v 1.30 2013/10/11 13:16:53 ajleary Exp $ */ #include "os.h" -#define MAKENL_VERSION "3.3.3" +#define MAKENL_VERSION "3.4.1" -#define MAKENL_LONG_VERSION "MakeNL " MAKENL_VERSION " (" MAKENL_OS ") compiled with " MAKENL_CC " on " __DATE__ " " __TIME__ +#define MAKENL_LONG_VERSION "MakeNL " MAKENL_VERSION " (" OS_NAME ") compiled with " CC_NAME " on " __DATE__ " " __TIME__ #define MAKENL_CREDITS \ - "This version of MakeNL is based upon work by Michael Karcher with\n" \ - "modifications by Bjorn Felten, Robert Couture, Andrew Clarke,\n" \ - "Michiel Broek, Malcolm Miles, Johan Billing & others.\n\n" \ - "Dedicated to Ben Baker - The author of the original MakeNL.\n\n" + "\n" \ + "This version of MakeNL is based upon work by Michael Karcher with" "\n" \ + "modifications by Björn Felten, Robert Couture, Andrew Clarke," "\n" \ + "Michiel Broek, Malcolm Miles, Johan Billing, Andrew Leary & others." "\n" \ + "\n" \ + "Dedicated to Ben Baker - The author of the original MakeNL.\n" \ + "\n"