Refactoring!

This commit is contained in:
Ianos Gnatiuc 2006-05-13 16:15:35 +00:00
parent 48908d77d9
commit 40cd10db65
89 changed files with 7944 additions and 28800 deletions

View File

@ -312,10 +312,6 @@ LNK_OBJS= \
$(OBJ_DIR)\gmoxbbs3.obj \
$(OBJ_DIR)\gmoxbbs4.obj \
$(OBJ_DIR)\gmoxbbs5.obj \
$(OBJ_DIR)\fexist.obj \
$(OBJ_DIR)\ffind.obj \
$(OBJ_DIR)\genmsgid.obj \
$(OBJ_DIR)\patmat.obj \
$(OBJ_DIR)\lzh.obj \
$(OBJ_DIR)\smblib.obj \
$(OBJ_DIR)\fptools.obj \
@ -356,7 +352,6 @@ LNK_OBJS= \
$(OBJ_DIR)\gefind.obj \
$(OBJ_DIR)\geglob.obj \
$(OBJ_DIR)\gehdre.obj \
$(OBJ_DIR)\gehdrs.obj \
$(OBJ_DIR)\gehtml.obj \
$(OBJ_DIR)\geinit.obj \
$(OBJ_DIR)\geline.obj \
@ -365,7 +360,6 @@ LNK_OBJS= \
$(OBJ_DIR)\gemlst.obj \
$(OBJ_DIR)\gemnus.obj \
$(OBJ_DIR)\gemrks.obj \
$(OBJ_DIR)\gemsgid.obj \
$(OBJ_DIR)\gemsgs.obj \
$(OBJ_DIR)\genode.obj \
$(OBJ_DIR)\geplay.obj \
@ -398,14 +392,14 @@ GOLDNODE_OBJS=$(OBJ_DIR)\goldnode.obj
ALL_OBJS=$(LNK_OBJS) $(GOLDED_OBJS) $(RDDT_OBJS) $(GOLDNODE_OBJS)
CPP_FLAGS=/nologo /c /J /W3 /Gi /EHac /FD /Igolded3 /Igoldlib\gall /Igoldlib\gcfg /Igoldlib\glibc /Igoldlib\gmb3 /Igoldlib\msgidlib /Igoldlib\smblib /Igoldlib\uulib /Igoldlib\myspell /DWIN32 /D_CONSOLE /DHAVE_CONFIG_H /Fo$(OBJ_DIR)\\ /Fd$(OBJ_DIR)\\
CPP_FLAGS=/nologo /c /J /W3 /Gi /EHac /FD /Igolded3 /Igoldlib\gall /Igoldlib\gcfg /Igoldlib\glibc /Igoldlib\gmb3 /Igoldlib\msgidlib /Igoldlib\smblib /Igoldlib\uulib /Igoldlib\hunspell /DWIN32 /D_CONSOLE /DHAVE_CONFIG_H /Fo$(OBJ_DIR)\\ /Fd$(OBJ_DIR)\\
RSC_FLAGS=/igolded3 /fo$(OBJ_DIR)\gedcyg.res
LNK_FLAGS=advapi32.lib winmm.lib user32.lib /nologo /subsystem:console /machine:I386
!IF "$(CFG)" == "Release"
CPP_PROJ=$(CPP_FLAGS) /MD /O1 /DNDEBUG $(CPP_EXTRA_FLAGS)
CPP_PROJ=$(CPP_FLAGS) /Gy /MD /O1 /DNDEBUG $(CPP_EXTRA_FLAGS)
RSC_PROJ=$(RSC_FLAGS) /dNDEBUG
LNK_PROJ=$(LNK_FLAGS) /incremental:no
LNK_PROJ=$(LNK_FLAGS) /incremental:no /OPT:REF,ICF,NOWIN98
!ELSEIF "$(CFG)" == "Debug"
CPP_PROJ=$(CPP_FLAGS) /MDd /Gm /ZI /GZ /Od /D_DEBUG $(CPP_EXTRA_FLAGS)
RSC_PROJ=$(RSC_FLAGS) /d_DEBUG
@ -508,7 +502,7 @@ $(ALL_OBJS):
$(CPP_PROJ) $<
<<
{goldlib\myspell}.cxx{$(OBJ_DIR)}.obj:
{goldlib\hunspell}.cxx{$(OBJ_DIR)}.obj:
$(CPP) @<<
$(CPP_PROJ) $<
<<

View File

@ -821,7 +821,7 @@ void CookieIndex(char* textfile, char* indexfile)
{
ifp.SetvBuf(NULL, _IOFBF, 32000);
gfile ofp(indexfile, "wb", CFG->sharemode);
if (ofp)
if (ofp.isopen())
{
ofp.SetvBuf(NULL, _IOFBF, 16000);
char buf[256];

View File

@ -23,8 +23,12 @@
// ------------------------------------------------------------------
// The main GoldED configuration structure.
// ------------------------------------------------------------------
#ifndef __GECFGG__H
#define __GECFGG__H
#include <list>
#include <gmo_msg.h>
#include <geall.h>
// ------------------------------------------------------------------
@ -109,6 +113,88 @@ private:
};
// ------------------------------------------------------------------
struct Win {
int btype; // Border type
vattr c[16]; // Colors
int w; // Window handle
};
// ------------------------------------------------------------------
// Combined name/address structure
struct Node
{
Name name;
Addr addr;
Node &operator=(const Node &a) { strxcpy(name, a.name, ARRAYSIZE(name)); addr=a.addr; return *this; }
};
// ------------------------------------------------------------------
// Filename aliases
struct FileAlias {
char alias[9];
Path file;
FileAlias& operator=(const FileAlias& a) {
strxcpy(alias, a.alias, sizeof(alias));
strxcpy(file, a.file, sizeof(Path));
return *this;
}
};
// ------------------------------------------------------------------
// Template typedefs
struct Tpl {
Path file;
Desc name;
Addr match;
};
// ------------------------------------------------------------------
// Address macro record
struct AddrMacro {
char macro[20];
IAdr name;
Addr addr;
Subj subj;
Attr attr;
};
// ------------------------------------------------------------------
struct AkaMatchG {
Addr mask;
Addr aka;
};
// ------------------------------------------------------------------
struct MailList {
Echo echoid;
IAdr sender;
IAdr contribution;
bool sender_is_pattern;
};
// ------------------------------------------------------------------
struct FrqNodeMap {
Addr from;
Addr to;
};
// ------------------------------------------------------------------
class CfgGed {
@ -559,3 +645,4 @@ public:
// ------------------------------------------------------------------
#endif

View File

@ -232,8 +232,9 @@ static void WriteMsgs(GMsg* msg) {
update_statuslinef(LNG->WritingMsg, "ST_WRITINGMSG", n+1, AA->Mark.Count());
w_progress(MODE_UPDATE, C_INFOW, n+1, AA->Mark.Count(), LNG->Writing);
AA->LoadMsg(msg, AA->Mark[n], prnmargin);
if(target & WRITE_PRINTER) {
if(prnfp)
if (target & WRITE_PRINTER)
{
if (prnfp.isopen())
SaveLines(MODE_WRITE, "\001PRN", msg, prnmargin);
}
else {

View File

@ -2013,7 +2013,7 @@ void IEclass::savefile(int __status) {
const char* editorfile = AddPath(CFG->goldpath, EDIT->File());
remove(editorfile);
gfile _fp(editorfile, "wb", CFG->sharemode);
if (_fp)
if (_fp.isopen())
{
// Find the first line
Line* _saveline = findfirstline();
@ -2863,7 +2863,7 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
// Check if there is an unfinished backup message
gfile _fp(AddPath(CFG->goldpath, EDIT->File()), "rt", CFG->sharemode);
if (_fp)
if (_fp.isopen())
{
char _buf[EDIT_BUFLEN];
_fp.Fgets(_buf, sizeof(_buf));

View File

@ -799,7 +799,7 @@ void IEclass::LoadFile() {
// Open the file to load
gfile _fp(AddPath(CFG->goldpath, EDIT->File()), "rb", CFG->sharemode);
if (_fp)
if (_fp.isopen())
{
XlatName __oldxlatimport;

View File

@ -395,7 +395,7 @@ static void w_brag() {
wprints(5, 12, C_BRAGW, "http://golded-plus.sourceforge.net");
wprints(0, 48, C_BRAGW, " GoldED+ Message Editor ");
sprintf(buf, " Copyright (C) 1990-%s ",__gver_date__+7);
gsprintf(PRINTF_DECLARE_BUFFER(buf), " Copyright (C) 1990-%s ",__gver_date__+7);
wprints(1, 48, C_BRAGW, buf);
wprints(2, 48, C_BRAGW, " by Odinn Sorensen, ");
wprints(3, 48, C_BRAGW, " Alexander Aganichev, ");

View File

@ -2986,7 +2986,7 @@ static bool CheckLevel(const char* imp, const char* imp2, int n, int &current_ta
if (!CharTable) CharTable = (Chs*)throw_calloc(1, sizeof(Chs));
fp.FseekSet(n, sizeof(Chs));
fp.Fread(CharTable, sizeof(Chs));
ChsTP = CharTable->t;
current_table = n;

View File

@ -74,7 +74,24 @@ inline void mlst_with_date(int with_date) {
// ------------------------------------------------------------------
class GMsgList : public gwinpick {
class GMsgList : public gwinpick
{
struct MLst
{
uint32_t msgno;
byte high;
char num[8];
char marks[3];
char by[sizeof(Name)+20];
char to[sizeof(Name)+20];
Subj re;
time32_t written;
time32_t arrived;
time32_t received;
char goldmark;
vattr colorby;
vattr colorto;
};
gwindow window;
GMsg msg;

View File

@ -1,57 +0,0 @@
// ------------------------------------------------------------------
// GoldED+
// Copyright (C) 2003 Alexander Reznikov, 2:4600/220@fidonet,
// <homebrewer@yandex.ru>
// ------------------------------------------------------------------
// 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., 59 Temple Place, Suite 330, Boston,
// MA 02111-1307 USA
// ------------------------------------------------------------------
// $Id$
// ------------------------------------------------------------------
// Generate MSGID.
// ------------------------------------------------------------------
#include <golded.h>
#include <genmsgid.h>
// ------------------------------------------------------------------
static uint32_t msgcount = 0;
// ------------------------------------------------------------------
uint32_t getClassicMsgId() {
return gtime(NULL)+(msgcount++);
}
// ------------------------------------------------------------------
uint32_t getMsgId() {
uint32_t id;
char *err;
if((CFG->seqmsgid == YES) or ((CFG->seqmsgid == MAYBE) and (*CFG->seqdir != NUL))) {
id = GenMsgIdEx(CFG->seqdir, CFG->seqoutrun, getClassicMsgId, &err);
if(err) {
LOG.printf("* Warning, SeqMsgId failed: %s, fall to classic algorythm!", err);
}
return id;
}
return getClassicMsgId();
}
// ------------------------------------------------------------------

View File

@ -1248,7 +1248,7 @@ void CheckNodelists() {
update_statusline(LNG->CheckingNodelists);
gfile fp(file, "rt", CFG->sharemode);
if (fp)
if (fp.isopen())
{
// Read the list index
char buf[256];

View File

@ -31,6 +31,7 @@
// ------------------------------------------------------------------
#include <vector>
#include <gecfgg.h>
#include <gmoarea.h>

View File

@ -28,9 +28,11 @@
/* --------------------------------------------------------------- */
/* Check if type "char" is unsigned or signed */
#define GOLD_CANPACK
#define NW(x) x=x
#if '\x80' < 0
#error Goldware Library requires -funsigned-char to operate properly
#endif
/* --------------------------------------------------------------- */
@ -90,17 +92,6 @@
#define __inline__ __inline
#define __extension__
#define __MSVCRT__
/* C4786: 'identifier' : identifier was truncated to 'number' characters
in the debug information
*/
#pragma warning(disable: 4786)
#endif
/* --------------------------------------------------------------- */
/* Check if type "char" is unsigned or signed */
#if '\x80' < 0
#error Goldware Library requires -funsigned-char to operate properly
#endif
@ -126,4 +117,11 @@
/* --------------------------------------------------------------- */
#define GOLD_CANPACK
#define NW(x) x=x
/* --------------------------------------------------------------- */
#endif

View File

@ -31,18 +31,17 @@
#define __goldall_h
/* ------------------------------------------------------------------ */
#include <tchar.h>
#ifdef __cplusplus
#include <cstddef>
#endif
#include <gcmpall.h>
#include <tchar.h>
#ifdef __cplusplus
# include <cstddef>
#endif
#ifdef _MSC_VER
#include <windows.h>
#include <limits.h>
# include <windows.h>
# include <limits.h>
#elif defined(__MINGW32__) || defined(__CYGWIN__)
#include <stdint.h>
#else
# include <stdint.h>
#endif
#if !defined(ARRAYSIZE)

View File

@ -23,6 +23,10 @@
// ------------------------------------------------------------------
// Definition of system-wide sizes and structures.
// ------------------------------------------------------------------
#ifndef __GEALL__H
#define __GEALL__H
#include <gdefs.h>
// ------------------------------------------------------------------
@ -324,20 +328,15 @@ const int REPLYRE_NUMERIC = 2;
// ------------------------------------------------------------------
// Name typedefs
typedef TCHAR Name[36];
const int MAX_DESC = 81; // Area descriptions
const int MAX_ECHO = 81; // Echoids
// ------------------------------------------------------------------
// Combined name/address structure
// Name typedefs
struct Node
{
Name name;
Addr addr;
Node &operator=(const Node &a) { strxcpy(name, a.name, ARRAYSIZE(name)); addr=a.addr; return *this; }
};
typedef TCHAR Name[36];
// ------------------------------------------------------------------
@ -365,13 +364,15 @@ typedef char XlatName[17];
// ------------------------------------------------------------------
// Template typedefs
// Echoid typedefs
struct Tpl {
Path file;
Desc name;
Addr match;
};
typedef char Echo[MAX_ECHO];
// ------------------------------------------------------------------
// Description typedefs
typedef char Desc[MAX_DESC];
// ------------------------------------------------------------------
@ -388,32 +389,6 @@ public:
};
// ------------------------------------------------------------------
// Filename aliases
struct FileAlias {
char alias[9];
Path file;
FileAlias& operator=(const FileAlias& a) {
strxcpy(alias, a.alias, sizeof(alias));
strxcpy(file, a.file, sizeof(Path));
return *this;
}
};
// ------------------------------------------------------------------
// Address macro record
struct AddrMacro {
char macro[20];
IAdr name;
Addr addr;
Subj subj;
Attr attr;
};
// ------------------------------------------------------------------
// Sound effect defines
@ -548,26 +523,6 @@ enum {
};
// ------------------------------------------------------------------
// The Message Browser
struct MLst {
uint32_t msgno;
byte high;
char num[8];
char marks[3];
char by[sizeof(Name)+20];
char to[sizeof(Name)+20];
Subj re;
time32_t written;
time32_t arrived;
time32_t received;
char goldmark;
vattr colorby;
vattr colorto;
};
// ------------------------------------------------------------------
// Structure for GOLDNODE.IXL
@ -873,16 +828,6 @@ struct SaveUtil {
#define W_BCFG GC_CFG_.btype
#define W_BCFGB GC_CFGB_.btype
// ------------------------------------------------------------------
// Window structure
struct Win {
int btype; // Border type
vattr c[16]; // Colors
int w; // Window handle
};
// ------------------------------------------------------------------
// Charset translation table structure
@ -969,32 +914,6 @@ struct Semaphore {
};
// ------------------------------------------------------------------
struct AkaMatchG {
Addr mask;
Addr aka;
};
// ------------------------------------------------------------------
struct MailList {
Echo echoid;
IAdr sender;
IAdr contribution;
bool sender_is_pattern;
};
// ------------------------------------------------------------------
struct FrqNodeMap {
Addr from;
Addr to;
};
// ------------------------------------------------------------------
typedef char BarList[45];
@ -1041,15 +960,6 @@ const uint TO_ALL = 16;
#endif
// ------------------------------------------------------------------
// Include various GoldED structures
#include <gehelp.h>
#include <gekeys.h>
#include <gelang.h>
#include <gmarea.h>
#include <gecfgg.h>
// ------------------------------------------------------------------
#endif

View File

@ -65,7 +65,7 @@ public:
int okay() { return (0 == status); }
bool isopen(); // true if the file is open
operator bool() { return isopen(); }
// operator bool() { return isopen(); }
// --------------------------------------------------------------

View File

@ -138,6 +138,11 @@ inline char * stpcpy(char* dest, const char* src) {
char* strcvtc(char* s);
// ------------------------------------------------------------------
#define PRINTF_DECLARE_BUFFER(b) b, ARRAYSIZE(b), __FILE__, __LINE__
int gsprintf(TCHAR* buffer, size_t sizeOfBuffer, const TCHAR* __file, int __line, const TCHAR* format, ...);
// ------------------------------------------------------------------
// String tokenizer class

View File

@ -28,6 +28,10 @@
#include <cstdio>
#include <stdarg.h>
#include <gstrall.h>
#include <glog.h>
#include <gdbgerr.h>
extern glog LOG;
// ------------------------------------------------------------------
@ -617,6 +621,41 @@ char *strxmerge(char *dest, size_t max, ...)
}
// ------------------------------------------------------------------
int gsprintf(TCHAR* buffer, size_t sizeOfBuffer, const TCHAR* __file, int __line, const TCHAR* format, ...)
{
int ret = -1;
va_list argptr;
va_start(argptr, format);
if (sizeOfBuffer)
{
#ifdef _vstprintf_s
ret = _vstprintf_s(buffer, sizeOfBuffer, format, argptr);
if (ret < 0)
#else
buffer[sizeOfBuffer-1] = 0;
ret = _vsntprintf(buffer, sizeOfBuffer, format, argptr);
if ((ret < 0) || buffer[sizeOfBuffer-1])
#endif
{
LOG.errpointer(__file, __line);
LOG.printf("! Buffer overflow or parameter is NULL.");
MemoryErrorExit();
}
}
else
{
LOG.errpointer(__file, __line);
LOG.printf("! Buffer size is 0.");
MemoryErrorExit();
}
return ret;
}
// ------------------------------------------------------------------
GTok::GTok(char* sep) {

View File

@ -32,9 +32,9 @@
// ------------------------------------------------------------------
GUser::GUser() {
fh = -1;
GUser::GUser()
{
gufh = -1;
found = false;
index = 0;
name = NULL;
@ -98,11 +98,12 @@ void GUser::recinit(const char* __name) {
// ------------------------------------------------------------------
int GUser::moveto(uint __rec) {
if(fh != -1) {
int GUser::moveto(uint __rec)
{
if (gufh != -1)
{
if(__rec <= records) {
lseek(fh, (long)__rec*(long)recsize, SEEK_SET);
lseek(gufh, (long)__rec*(long)recsize, SEEK_SET);
recno = __rec;
return true;
}
@ -130,22 +131,24 @@ int GUser::prev() {
// ------------------------------------------------------------------
void GUser::seekread() {
if(fh != -1) {
lseek(fh, (long)recno*(long)recsize, SEEK_SET);
::read(fh, recptr, recsize);
void GUser::seekread()
{
if (gufh != -1)
{
lseek(gufh, (long)recno*(long)recsize, SEEK_SET);
::read(gufh, recptr, recsize);
}
}
// ------------------------------------------------------------------
void GUser::seekwrite() {
if(fh != -1) {
lseek(fh, (long)recno*(long)recsize, SEEK_SET);
::write(fh, recptr, recsize);
void GUser::seekwrite()
{
if (gufh != -1)
{
lseek(gufh, (long)recno*(long)recsize, SEEK_SET);
::write(gufh, recptr, recsize);
}
}
@ -160,13 +163,13 @@ int GUser::find(const char* __name, char* __result, int __wildcards) {
found = false;
// If userfile is open
if(fh != -1) {
if (gufh != -1)
{
// Rewind file to start
lseek(fh, 0, SEEK_SET);
lseek(gufh, 0, SEEK_SET);
// Get number of records in the userfile
records = (uint)(filelength(fh)/recsize);
records = (uint)(filelength(gufh)/recsize);
// Searching loop
for(recno=0; recno<records; recno++) {

View File

@ -43,7 +43,7 @@ public:
// ----------------------------------------------------------------
// Variables
int fh; // File handle
int gufh; // File handle
int found; // User found
uint index; // User index number
char* name; // Pointer to name in user record

View File

@ -95,11 +95,11 @@ int EzycomUser::isvalid() {
// ------------------------------------------------------------------
int EzycomUser::read() {
if(fh != -1) {
::read(fh, record, sizeof(EzycUsers));
int EzycomUser::read()
{
if (gufh != -1)
{
::read(gufh, record, sizeof(EzycUsers));
STRNP2C(record->name);
return isvalid();

View File

@ -69,11 +69,11 @@ int GoldbaseUser::isvalid() {
// ------------------------------------------------------------------
int GoldbaseUser::read() {
if(fh != -1) {
::read(fh, record, sizeof(GoldUsers));
int GoldbaseUser::read()
{
if (gufh != -1)
{
::read(gufh, record, sizeof(GoldUsers));
STRNP2C(record->name);
return isvalid();

View File

@ -69,11 +69,11 @@ int HudsonUser::isvalid() {
// ------------------------------------------------------------------
int HudsonUser::read() {
if(fh != -1) {
::read(fh, record, sizeof(HudsUsers));
int HudsonUser::read()
{
if (gufh != -1)
{
::read(gufh, record, sizeof(HudsUsers));
STRNP2C(record->name);
return isvalid();

View File

@ -65,14 +65,17 @@ int MaximusUser::isvalid() {
// ------------------------------------------------------------------
int MaximusUser::read() {
if(fh != -1) {
if(firstread) {
int MaximusUser::read()
{
if (gufh != -1)
{
if (firstread)
{
firstread = false;
if(filelength(fh) >= 180) {
::read(fh, record, recsize);
lseek(fh, -(long)recsize, SEEK_CUR);
if (filelength(gufh) >= 180)
{
::read(gufh, record, recsize);
lseek(gufh, -(long)recsize, SEEK_CUR);
uint _tmp = record->struct_len ? record->struct_len*20 : 180;
if(_tmp != recsize) {
recsize = _tmp;
@ -83,8 +86,9 @@ int MaximusUser::read() {
}
}
}
::read(fh, record, recsize);
if(isvalid()) {
::read(gufh, record, recsize);
if (isvalid())
{
index = record->lastread_ptr;
maxindex = maximum_of_two(index, maxindex);
return true;

View File

@ -61,10 +61,11 @@ int PcbUser::isvalid() {
// ------------------------------------------------------------------
int PcbUser::read() {
if(fh != -1) {
::read(fh, record, sizeof(PcbUsers));
int PcbUser::read()
{
if (gufh != -1)
{
::read(gufh, record, sizeof(PcbUsers));
return isvalid();
}

View File

@ -24,7 +24,7 @@
// RemoteAccess 2.x userfile class implementation.
// ------------------------------------------------------------------
#include <gfilutil.h>
#include <gfile.h>
#include <gcrcall.h>
#include <gmemdbg.h>
#include <gstrall.h>
@ -33,11 +33,10 @@
// ------------------------------------------------------------------
RA2User::RA2User() {
RA2User::RA2User()
{
xifh = idxfh = 0;
xifh = -1;
idxfh = -1;
recsize = sizeof(RA2Users);
record = new RA2Users; throw_new(record);
@ -79,11 +78,11 @@ int RA2User::isvalid() {
// ------------------------------------------------------------------
int RA2User::read() {
if(fh != -1) {
::read(fh, record, sizeof(RA2Users));
int RA2User::read()
{
if (gufh != -1)
{
::read(gufh, record, sizeof(RA2Users));
STRNP2C(record->name);
return isvalid();
@ -129,22 +128,22 @@ void RA2User::add(const char* __name) {
GUser::add(__name);
if(idxfh != -1) {
if (idxfh && idxfh->isopen())
{
char _namebuf[36];
strupr(strcpy(_namebuf, __name));
idxrec->namecrc32 = idxrec->handlecrc32 = strCrc32(_namebuf, NO, CRC32_MASK_CCITT);
lseek(idxfh, (long)recno*(long)sizeof(RA2UsersIdx), SEEK_SET);
::write(idxfh, idxrec, sizeof(RA2UsersIdx));
idxfh->LseekSet((long)recno*(long)sizeof(RA2UsersIdx));
idxfh->Write(idxrec, sizeof(RA2UsersIdx));
}
if(xifh != -1) {
if (xifh && xifh->isopen())
{
memset(xirec, 0, sizeof(RA2UsersXi));
lseek(xifh, (long)recno*(long)sizeof(RA2UsersXi), SEEK_SET);
::write(xifh, xirec, sizeof(RA2UsersXi));
xifh->LseekSet((long)recno*(long)sizeof(RA2UsersXi));
xifh->Write(xirec, sizeof(RA2UsersXi));
}
}

View File

@ -125,12 +125,12 @@ struct RA2UsersXi {
// ------------------------------------------------------------------
// RemoteAccess 2.x userfile class
class RA2User : public GUser {
class RA2User : public GUser
{
public:
int xifh;
int idxfh;
gfile* xifh;
gfile* idxfh;
RA2Users* record;
RA2UsersXi* xirec;

View File

@ -58,10 +58,11 @@ int XbbsUser::isvalid() {
// ------------------------------------------------------------------
int XbbsUser::read() {
if(fh != -1) {
::read(fh, record, sizeof(XbbsUsers));
int XbbsUser::read()
{
if (gufh != -1)
{
::read(gufh, record, sizeof(XbbsUsers));
return isvalid();
}

View File

@ -318,9 +318,8 @@ int EchoListClass::GetEcho(int n, char** echoid, char** path, char** desc) {
// ------------------------------------------------------------------
// Read AREAS.BBS (any flavor!) and store echoid, path and desc.
void gareafile::GetAreasBBS(char* name, char* origin, char* options) {
FILE* fp;
void gareafile::GetAreasBBS(char* name, char* origin, char* options)
{
char buf[256];
Path areafile;
char* ptr;
@ -332,17 +331,18 @@ void gareafile::GetAreasBBS(char* name, char* origin, char* options) {
strcpy(areafile, name);
MakePathname(areafile, areapath, areafile);
fp = fsopen(areafile, "rt", sharemode);
if (fp)
gfile fp(areafile, "rt", sharemode);
if (fp.isopen())
{
setvbuf(fp, NULL, _IOFBF, 8192);
fp.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << areafile);
bool firstline = true;
while(fgets(buf, 255, fp)) {
while (fp.Fgets(buf, 255))
{
ptr = strskip_wht(buf);
if(*ptr != ';' and *ptr != '%' and *ptr != '-' and *ptr != '#' and *ptr != '@' and strnicmp(ptr, "P ", 2) and strnicmp(ptr, "PASSTHRU", 8) and *ptr) {
@ -383,7 +383,6 @@ void gareafile::GetAreasBBS(char* name, char* origin, char* options) {
}
}
}
fclose(fp);
}
}

View File

@ -33,28 +33,11 @@
#include <iostream>
#include <iomanip>
#include <gftnall.h>
#include <gfilutil.h>
#include <string>
#include <gftnall.h>
#include <gfile.h>
#include <gmsgattr.h>
// ------------------------------------------------------------------
const int MAX_DESC = 81; // Area descriptions
const int MAX_ECHO = 81; // Echoids
// ------------------------------------------------------------------
// Echoid typedefs
typedef char Echo[MAX_ECHO];
// ------------------------------------------------------------------
// Description typedefs
typedef char Desc[MAX_DESC];
#include <geall.h>
// ------------------------------------------------------------------
@ -221,8 +204,8 @@ protected:
void ReadDB2011(char* file, int reclen, char* tag);
#endif
#ifndef GCFG_NOEZY
void ReadEzycom102(FILE* fp, char* path, char* file, char* options);
void ReadEzycom110(FILE* fp, char* path, char* file, char* options);
void ReadEzycom102(gfile &fp, char* path, char* file, char* options);
void ReadEzycom110(gfile &fp, char* path, char* file, char* options);
#endif
#ifndef GCFG_NOFE
void ReadFastecho11x(int fh);
@ -230,13 +213,13 @@ protected:
void ReadFastecho142(int fh);
#endif
#ifndef GCFG_NOFMAIL
void ReadFMail092(FILE* fp, char* path, char* file, char* options);
void ReadFMail098(FILE* fp, char* path, char* file, char* options);
void ReadFMail116(FILE* fp, char* path, char* file, char* options);
void ReadFMail092(gfile &fp, char* path, char* file, char* options);
void ReadFMail098(gfile &fp, char* path, char* file, char* options);
void ReadFMail116(gfile &fp, char* path, char* file, char* options);
#endif
#ifndef GCFG_NOFIDOCONF
AreaCfg echoareadefaults;
bool ReadHPTLine(FILE* f, std::string* s, bool add=false, int state=0);
bool ReadHPTLine(gfile &f, std::string* s, bool add=false, int state=0);
void ReadHPTFile(char* path, char* file, char* origin, int group);
#endif
#ifndef GCFG_NOIMAIL
@ -270,7 +253,7 @@ protected:
void ReadTmailFile(char* file, char* options, char* origin);
#endif
#ifndef GCFG_NOWATERGATE
void ReadWtrGteFile(char* options, FILE* fp);
void ReadWtrGteFile(char* options, gfile &fp);
#endif
#ifndef GCFG_NOXBBS
void ReadAdeptXbbsFile(char* path, char* file, char* options);

View File

@ -77,12 +77,12 @@ bool gareafile::jbstrcpy(char *dest, char *src, size_t maxlen, size_t *jbc) {
// ------------------------------------------------------------------
// Read areas from Crashmail II/CrashEcho (echomail processor)
void gareafile::ReadCrashmailCfg(const char* file) {
FILE* fp = fsopen(file, "rt", sharemode);
if (fp)
void gareafile::ReadCrashmailCfg(const char* file)
{
gfile fp(file, "rt", sharemode);
if (fp.isopen())
{
setvbuf(fp, NULL, _IOFBF, 8192);
fp.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << file);
@ -121,7 +121,8 @@ void gareafile::ReadCrashmailCfg(const char* file) {
word crc16;
while(fgets(buf, 4000, fp) != NULL) {
while (fp.Fgets(buf, 4000))
{
jbcpos=0;
jbstrcpy(key, buf, 30, &jbcpos);
switch(crc16 = strCrc16(key)) {
@ -240,7 +241,6 @@ void gareafile::ReadCrashmailCfg(const char* file) {
strxmerge(tmp, 100, address, "@", domain, NULL);
CfgAddress(tmp);
}
fclose(fp);
}
}

View File

@ -39,38 +39,38 @@
// ------------------------------------------------------------------
// Read D'Bridge 1.30
void gareafile::ReadDB130(char* tag, char* dbpath) {
void gareafile::ReadDB130(char* /*tag*/, char* dbpath)
{
AreaCfg aa;
DB130_AA1 AA1;
DB130_AA2 AA2;
FILE *fp1, *fp2;
Path file1, file2;
MakePathname(file1, dbpath, "dbridge.aa1");
MakePathname(file2, dbpath, "dbridge.aa2");
fp1 = fsopen(file1, "rb", sharemode);
if (fp1)
gfile fp1(file1, "rb", sharemode);
if (fp1.isopen())
{
setvbuf(fp1, NULL, _IOFBF, 8192);
fp1.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << file1);
fp2 = fsopen(file2, "rb", sharemode);
if (fp2)
gfile fp2(file2, "rb", sharemode);
if (fp2.isopen())
{
setvbuf(fp2, NULL, _IOFBF, 8192);
fp2.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << file2);
while(fread(&AA1, sizeof(DB130_AA1), 1, fp1) == 1) {
while (fp1.Fread(&AA1, sizeof(DB130_AA1)))
{
fp2.Fread(&AA2, sizeof(DB130_AA2));
fread(&AA2, sizeof(DB130_AA2), 1, fp2);
if(AA1.allocated and strchr("QFqf", AA2.msgbase)) {
if (AA1.allocated and strchr("QFqf", AA2.msgbase))
{
aa.reset();
switch(g_toupper(AA2.msgbase)) {
case 'Q':
@ -105,11 +105,7 @@ void gareafile::ReadDB130(char* tag, char* dbpath) {
AddNewArea(aa);
}
}
fclose(fp2);
}
fclose(fp1);
}
}
@ -117,20 +113,21 @@ void gareafile::ReadDB130(char* tag, char* dbpath) {
// ------------------------------------------------------------------
// Read D'Bridge B1046
void gareafile::ReadDB1046(char* file, char* tag) {
void gareafile::ReadDB1046(char* file, char* /*tag*/)
{
AreaCfg aa;
DB1046_ADF* ADF = (DB1046_ADF*)throw_calloc(1, sizeof(DB1046_ADF));
FILE* fp = fsopen(file, "rb", sharemode);
if (fp)
gfile fp(file, "rb", sharemode);
if (fp.isopen())
{
setvbuf(fp, NULL, _IOFBF, 8192);
fp.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << file);
while(fread(ADF, sizeof(DB1046_ADF), 1, fp) == 1) {
while (fp.Fread(ADF, sizeof(DB1046_ADF)))
{
if(ADF->allocated and strchr("QFqf", ADF->msgbase)) {
aa.reset();
switch(g_toupper(ADF->msgbase)) {
@ -166,8 +163,6 @@ void gareafile::ReadDB1046(char* file, char* tag) {
AddNewArea(aa);
}
}
fclose(fp);
}
throw_free(ADF);
@ -177,25 +172,25 @@ void gareafile::ReadDB1046(char* file, char* tag) {
// ------------------------------------------------------------------
// Read D'Bridge B1047.A22 and B1047.A27+
void gareafile::ReadDB1047A22(char* file, int reclen, char* tag) {
void gareafile::ReadDB1047A22(char* file, int reclen, char* /*tag*/)
{
AreaCfg aa;
FILE* fp;
DB1047A22_ADF* ADF;
DB1047A22_ADF* ADF = (DB1047A22_ADF *)throw_malloc(reclen);
ADF = (DB1047A22_ADF *)throw_malloc(reclen);
if(ADF) {
fp = fsopen(file, "rb", sharemode);
if (fp)
if (ADF)
{
gfile fp(file, "rb", sharemode);
if (fp.isopen())
{
setvbuf(fp, NULL, _IOFBF, 8192);
fp.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << file);
while(fread(ADF, reclen, 1, fp) == 1) {
if(ADF->allocated and strchr("QFqf", ADF->msgbase)) {
while (fp.Fread(ADF, reclen))
{
if (ADF->allocated and strchr("QFqf", ADF->msgbase))
{
aa.reset();
switch(g_toupper(ADF->msgbase)) {
case 'Q':
@ -230,8 +225,6 @@ void gareafile::ReadDB1047A22(char* file, int reclen, char* tag) {
AddNewArea(aa);
}
}
fclose(fp);
}
throw_free(ADF);
@ -242,25 +235,25 @@ void gareafile::ReadDB1047A22(char* file, int reclen, char* tag) {
// ------------------------------------------------------------------
// Read D'Bridge B2011
void gareafile::ReadDB2011(char* file, int reclen, char* tag) {
void gareafile::ReadDB2011(char* file, int reclen, char* /*tag*/)
{
AreaCfg aa;
FILE* fp;
DB2011_ADF* ADF;
DB2011_ADF* ADF = (DB2011_ADF *)throw_malloc(reclen);
ADF = (DB2011_ADF *)throw_malloc(reclen);
if(ADF) {
fp = fsopen(file, "rb", sharemode);
if (fp)
if (ADF)
{
gfile fp(file, "rb", sharemode);
if (fp.isopen())
{
setvbuf(fp, NULL, _IOFBF, 8192);
fp.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << file);
while(fread(ADF, reclen, 1, fp) == 1) {
if(ADF->allocated and strchr("QFqf", ADF->msgbase)) {
while (fp.Fread(ADF, reclen))
{
if (ADF->allocated and strchr("QFqf", ADF->msgbase))
{
aa.reset();
switch(g_toupper(ADF->msgbase)) {
case 'Q':
@ -297,8 +290,6 @@ void gareafile::ReadDB2011(char* file, int reclen, char* tag) {
AddNewArea(aa);
}
}
fclose(fp);
}
throw_free(ADF);
@ -309,10 +300,9 @@ void gareafile::ReadDB2011(char* file, int reclen, char* tag) {
// ------------------------------------------------------------------
// Read D'Bridge areas, various versions...
void gareafile::ReadDBridge(char* tag) {
void gareafile::ReadDBridge(char* tag)
{
AreaCfg aa;
FILE* fp;
char* ptr;
int line;
char buf[256], type, options[80];
@ -341,50 +331,50 @@ void gareafile::ReadDBridge(char* tag) {
MakePathname(file, dbpath, "dbridge.prm");
fp = fsopen(file, "rt", sharemode);
if (fp)
gfile fp(file, "rt", sharemode);
if (fp.isopen())
{
if (not quiet)
STD_PRINTNL("* Reading " << file);
// Read netmail storage method etc
for(line=1; line <= 2; line++)
fgets(buf, 255, fp);
for (line = 1; line <= 2; line++)
fp.Fgets(buf, 255);
type = (char)g_toupper(*buf);
// Fido-style netmail path
line++;
fgets(buf, 255, fp);
fp.Fgets(buf, 255);
strtrim(buf);
strcpy(netpath, buf);
// BADECHO area
for(; line <= 8; line++)
fgets(buf, 255, fp);
fp.Fgets(buf, 255);
strtrim(buf);
strcpy(badecho, buf);
// Hudson path
for(; line <= 11; line++)
fgets(buf, 255, fp);
fp.Fgets(buf, 255);
strtrim(buf);
CfgHudsonpath(buf);
// Primary address
for(; line <= 15; line++)
fgets(buf, 255, fp);
fp.Fgets(buf, 255);
strtrim(buf);
CfgAddress(buf);
// Username
for(; line <= 17; line++)
fgets(buf, 255, fp);
fp.Fgets(buf, 255);
strtrim(buf);
//CfgUsername(buf);
// Hudson netmail board
for(; line <= 20; line++) // NOTE: was 17 in older versions
fgets(buf, 255, fp);
fp.Fgets(buf, 255);
// Address/misc field
if(type == 'F' or type == 'Q') {
@ -417,7 +407,7 @@ void gareafile::ReadDBridge(char* tag) {
AddNewArea(aa);
}
fclose(fp);
fp.Fclose();
}
// Read the areafile from the correct version

View File

@ -37,10 +37,9 @@
// ------------------------------------------------------------------
// Read Dutchie DUTCHIE.ARE
void gareafile::ReadDutchie(char* tag) {
void gareafile::ReadDutchie(char* tag)
{
AreaCfg aa;
FILE* fp;
char* ptr;
char* ptr2;
Path dupath, file;
@ -66,16 +65,16 @@ void gareafile::ReadDutchie(char* tag) {
MakePathname(file, dupath, "dutchie.are");
fp = fsopen(file, "rb", sharemode);
if (fp)
gfile fp(file, "rb", sharemode);
if (fp.isopen())
{
setvbuf(fp, NULL, _IOFBF, 8192);
fp.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << file);
while(fgets(buf, 255, fp)) {
while (fp.Fgets(buf, 255))
{
ptr = strbtrim(buf);
if(*ptr != ';' and *ptr != '-' and strnicmp(ptr, "PASSTHRU", 8) and *ptr != '\x1A' and *ptr) {
@ -96,8 +95,6 @@ void gareafile::ReadDutchie(char* tag) {
AddNewArea(aa);
}
}
fclose(fp);
}
}

View File

@ -37,8 +37,8 @@
// ------------------------------------------------------------------
void gareafile::ReadEzycom102(FILE* fp, char* path, char* file, char* options) {
void gareafile::ReadEzycom102(gfile &fp, char* path, char* file, char* options)
{
int n;
AreaCfg aa;
char abuf[40];
@ -47,18 +47,18 @@ void gareafile::ReadEzycom102(FILE* fp, char* path, char* file, char* options) {
CONSTANTRECORD* constant = new CONSTANTRECORD; throw_new(constant);
MESSAGERECORD* messages = new MESSAGERECORD; throw_new(messages);
fread(config, sizeof(CONFIGRECORD), 1, fp);
fclose(fp);
fp.Fread(config, sizeof(CONFIGRECORD));
fp.Fclose();
MakePathname(file, path, "constant.ezy");
fp = fsopen(file, "rb", sharemode);
if (fp)
fp.Fopen(file, "rb", sharemode);
if (fp.isopen())
{
if (not quiet)
STD_PRINTNL("* Reading " << file);
fread(constant, sizeof(CONSTANTRECORD), 1, fp);
fclose(fp);
fp.Fread(constant, sizeof(CONSTANTRECORD));
fp.Fclose();
STRNP2C(config->defaultorigin);
STRNP2C(config->userbasepath);
@ -192,16 +192,16 @@ void gareafile::ReadEzycom102(FILE* fp, char* path, char* file, char* options) {
}
MakePathname(file, path, "messages.ezy");
fp = fsopen(file, "rb", sharemode);
if (fp)
fp.Fopen(file, "rb", sharemode);
if (fp.isopen())
{
if (not quiet)
STD_PRINTNL("* Reading " << file);
int record = 1;
while(fread(messages, sizeof(MESSAGERECORD), 1, fp) == 1) {
while (fp.Fread(messages, sizeof(MESSAGERECORD)))
{
if(record <= constant->maxmess) {
if(*messages->name) {
@ -266,7 +266,8 @@ void gareafile::ReadEzycom102(FILE* fp, char* path, char* file, char* options) {
record++;
}
fclose(fp);
fp.Fclose();
}
}

View File

@ -38,8 +38,8 @@
// ------------------------------------------------------------------
void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
void gareafile::ReadEzycom110(gfile &fp, char* path, char* file, char* options)
{
int n;
AreaCfg aa;
char abuf[40];
@ -48,18 +48,18 @@ void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
CONSTANTRECORD* constant = new CONSTANTRECORD; throw_new(constant);
MESSAGERECORD* messages = new MESSAGERECORD; throw_new(messages);
fread(config, sizeof(CONFIGRECORD), 1, fp);
fclose(fp);
fp.Fread(config, sizeof(CONFIGRECORD));
fp.Fclose();
MakePathname(file, path, "constant.ezy");
fp = fsopen(file, "rb", sharemode);
if (fp)
fp.Fopen(file, "rb", sharemode);
if (fp.isopen())
{
if (not quiet)
STD_PRINTNL("* Reading " << file);
fread(constant, sizeof(CONSTANTRECORD), 1, fp);
fclose(fp);
fp.Fread(constant, sizeof(CONSTANTRECORD));
fp.Fclose();
STRNP2C(config->defaultorigin);
STRNP2C(config->userbasepath);
@ -193,22 +193,22 @@ void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
}
MakePathname(file, path, "MESSAGES.EZY");
fp = fsopen(file, "rb", sharemode);
if (fp)
fp.Fopen(file, "rb", sharemode);
if (fp.isopen())
{
if (not quiet)
STD_PRINTNL("* Reading " << file);
int record = 1;
while(fread(messages, sizeof(MESSAGERECORD), 1, fp) == 1) {
if(record <= constant->maxmess) {
if(*messages->name) {
switch(messages->typ) {
while (fp.Fread(messages, sizeof(MESSAGERECORD)))
{
if (record <= constant->maxmess)
{
if (*messages->name)
{
switch (messages->typ)
{
case 0: // localmail
case 1: // netmail
case 2: // echomail
@ -266,7 +266,8 @@ void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
record++;
}
fclose(fp);
fp.Fclose();
}
}
@ -278,9 +279,8 @@ void gareafile::ReadEzycom110(FILE* fp, char* path, char* file, char* options) {
// ------------------------------------------------------------------
void gareafile::ReadEzycom(char* tag) {
FILE* fp;
void gareafile::ReadEzycom(char* tag)
{
char* ptr;
Path path, file;
char options[80], abuf[40];
@ -311,15 +311,16 @@ void gareafile::ReadEzycom(char* tag) {
}
if(not fexist(file))
MakePathname(file, path, "config.ezy");
fp = fsopen(file, "rb", sharemode);
if (fp)
gfile fp(file, "rb", sharemode);
if (fp.isopen())
{
if (not quiet)
STD_PRINTNL("* Reading " << file);
char _verstr[9];
fread(_verstr, 9, 1, fp);
rewind(fp);
fp.Fread(_verstr, 9);
fp.Rewind();
strp2c(_verstr);

View File

@ -33,14 +33,14 @@
// ------------------------------------------------------------------
void gareafile::ReadFMail092(FILE* fp, char* path, char* file, char* options) {
void gareafile::ReadFMail092(gfile &fp, char* path, char* file, char* options)
{
AreaCfg aa;
configType* cfg = new configType; throw_new(cfg);
fread(cfg, sizeof(configType), 1, fp);
fclose(fp);
fp.Fread(cfg, sizeof(configType));
fp.Fclose();
// Get Hudson msgbase path
CfgHudsonpath(cfg->bbsPath);
@ -159,11 +159,11 @@ void gareafile::ReadFMail092(FILE* fp, char* path, char* file, char* options) {
MakePathname(file, path, "fmail.ar");
fp = fsopen(file, "rb", sharemode);
if(fp) {
while(fread(ar, sizeof(rawEchoType), 1, fp) == 1) {
fp.Fopen(file, "rb", sharemode);
if (fp.isopen())
{
while (fp.Fread(ar, sizeof(rawEchoType)))
{
if(ar->options.active and ar->board and ar->board < 201) {
aa.reset();
@ -197,7 +197,7 @@ void gareafile::ReadFMail092(FILE* fp, char* path, char* file, char* options) {
}
}
fclose(fp);
fp.Fclose();
}
throw_delete(ar);

View File

@ -34,14 +34,14 @@
// ------------------------------------------------------------------
void gareafile::ReadFMail098(FILE* fp, char* path, char* file, char* options) {
void gareafile::ReadFMail098(gfile &fp, char* path, char* file, char* options)
{
AreaCfg aa;
configType* cfg = new configType; throw_new(cfg);
fread(cfg, sizeof(configType), 1, fp);
fclose(fp);
fp.Fread(cfg, sizeof(configType));
fp.Fclose();
// Get Hudson msgbase path
CfgHudsonpath(cfg->bbsPath);
@ -161,18 +161,17 @@ void gareafile::ReadFMail098(FILE* fp, char* path, char* file, char* options) {
MakePathname(file, path, "fmail.ar");
fp = fsopen(file, "rb", sharemode);
if(fp) {
fread(&hdr, sizeof(headerType), 1, fp);
fseek(fp, hdr.headerSize, SEEK_SET);
fp.Fopen(file, "rb", sharemode);
if (fp.isopen())
{
fp.Fread(&hdr, sizeof(headerType));
fp.FseekSet(hdr.headerSize);
ar = (rawEchoType*)throw_calloc(1, hdr.recordSize);
if(ar) {
while(fread(ar, hdr.recordSize, 1, fp) == 1) {
if (ar)
{
while (fp.Fread(ar, hdr.recordSize))
{
if(ar->options.active) {
aa.reset();
@ -226,7 +225,7 @@ void gareafile::ReadFMail098(FILE* fp, char* path, char* file, char* options) {
throw_free(ar);
fclose(fp);
fp.Fclose();
}
throw_delete(cfg);

View File

@ -38,14 +38,14 @@
// ------------------------------------------------------------------
void gareafile::ReadFMail116(FILE* fp, char* path, char* file, char* options) {
void gareafile::ReadFMail116(gfile &fp, char* path, char* file, char* options)
{
AreaCfg aa;
configType* cfg = new configType; throw_new(cfg);
fread(cfg, sizeof(configType), 1, fp);
fclose(fp);
fp.Fread(cfg, sizeof(configType));
fp.Fclose();
// Get Hudson msgbase path
CfgHudsonpath(cfg->bbsPath);
@ -165,22 +165,21 @@ void gareafile::ReadFMail116(FILE* fp, char* path, char* file, char* options) {
MakePathname(file, path, "fmail.ar");
fp = fsopen(file, "rb", sharemode);
if(fp) {
fread(&hdr, sizeof(headerType), 1, fp);
fp.Fopen(file, "rb", sharemode);
if (fp.isopen())
{
fp.Fread(&hdr, sizeof(headerType));
uint headerSize = hdr.headerSize;
uint recordSize = hdr.recordSize;
fseek(fp, headerSize, SEEK_SET);
fp.FseekSet(headerSize);
ar = (rawEchoType116*)throw_calloc(1, recordSize);
if(ar) {
while(fread(ar, recordSize, 1, fp) == 1) {
if (ar)
{
while(fp.Fread(ar, recordSize))
{
if(ar->options.active) {
aa.reset();
@ -234,7 +233,7 @@ void gareafile::ReadFMail116(FILE* fp, char* path, char* file, char* options) {
throw_free(ar);
fclose(fp);
fp.Fclose();
}
throw_delete(cfg);
@ -243,10 +242,9 @@ void gareafile::ReadFMail116(FILE* fp, char* path, char* file, char* options) {
// ------------------------------------------------------------------
void gareafile::ReadFMail(char* tag) {
void gareafile::ReadFMail(char* tag)
{
char* ptr;
FILE* fp;
char options[80];
Path path, file;
@ -271,16 +269,16 @@ void gareafile::ReadFMail(char* tag) {
MakePathname(file, path, "fmail.cfg");
fp = fsopen(file, "rb", sharemode);
if(fp) {
gfile fp(file, "rb", sharemode);
if (fp.isopen())
{
struct {
byte vmajor;
byte vminor;
} _rev;
fread(&_rev, sizeof(_rev), 1, fp);
rewind(fp);
fp.Fread(&_rev, sizeof(_rev));
fp.Rewind();
uint fmver = (_rev.vmajor << 8) | _rev.vminor;

View File

@ -43,20 +43,21 @@ static char comment_char = '#';
// ------------------------------------------------------------------
bool gareafile::ReadHPTLine(FILE* f, std::string* s, bool add, int state) {
bool gareafile::ReadHPTLine(gfile &f, std::string* s, bool add, int state)
{
std::string str;
char buf[81];
if(fgets(buf, 81, f) == NULL)
return false; // eof
if (!f.Fgets(buf, 81)) return false; // eof
str = buf;
if(buf[strlen(buf)-1] != '\n') {
while(fgets(buf, 81, f) != NULL) {
if (buf[strlen(buf)-1] != '\n')
{
while (f.Fgets(buf, 81))
{
str += buf;
if(buf[strlen(buf)-1] == '\n')
if (buf[strlen(buf)-1] == '\n')
break;
}
}
@ -178,10 +179,10 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
AreaCfg aa;
Path buf2;
FILE* fp = fsopen(file, "rb", sharemode);
if (fp)
gfile fp(file, "rb", sharemode);
if (fp.isopen())
{
setvbuf(fp, NULL, _IOFBF, 8192);
fp.SetvBuf(NULL, _IOFBF, 8192);
if (not quiet)
STD_PRINTNL("* Reading " << file);
@ -192,8 +193,8 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
aa.groupid = group;
std::string s;
while(ReadHPTLine(fp, &s)) {
while (ReadHPTLine(fp, &s))
{
if(not s.empty()) {
char *alptr = throw_xstrdup(s.c_str());
@ -378,9 +379,10 @@ void gareafile::ReadHPTFile(char* path, char* file, char* origin, int group) {
}
}
skip_config:
fclose(fp);
}else{
skip_config:;
}
else
{
STD_PRINTNL(" * AREAFILE FIDOCONFIG: Can't open file '" << path << '/' << file << ": " << strerror(errno) );
}
}

View File

@ -27,7 +27,6 @@
#include <cstring>
#include <cstdlib>
#include <gmemdbg.h>
#include <gfile.h>
#if defined(__GOLD_GUI__)
#include <gvidall.h>
#include <gvidgui.h>

View File

@ -26,7 +26,6 @@
#include <cstdlib>
#include <gmemdbg.h>
#include <gfile.h>
#include <gstrall.h>
#if defined(__GOLD_GUI__)
#include <gvidall.h>

View File

@ -26,7 +26,6 @@
#include <cstdlib>
#include <gmemdbg.h>
#include <gfile.h>
#include <gstrall.h>
#if defined(__GOLD_GUI__)
#include <gvidall.h>

View File

@ -53,12 +53,12 @@ const char *gareafile::gettype(const char *msgtype, const byte wtrtype) {
// ------------------------------------------------------------------
// Read WaterGate v0.93
void gareafile::ReadWtrGteFile(char* options, FILE* fp) {
void gareafile::ReadWtrGteFile(char* options, gfile &fp)
{
AreaCfg aa;
ConfigRecord* _tmp = new ConfigRecord; throw_new(_tmp);
ConfigRecord& c = *_tmp;
fread(&c, sizeof(ConfigRecord), 1, fp);
fp.Fread(&c, sizeof(ConfigRecord));
strp2c(c.systemdir);
CfgJampath(c.systemdir);
@ -161,9 +161,8 @@ void gareafile::ReadWtrGteFile(char* options, FILE* fp) {
// ------------------------------------------------------------------
void gareafile::ReadWtrGte(char* tag) {
FILE* fp;
void gareafile::ReadWtrGte(char* tag)
{
char* ptr;
char options[80];
Path wtrpath, file;
@ -188,21 +187,20 @@ void gareafile::ReadWtrGte(char* tag) {
strcpy(wtrpath, areapath);
MakePathname(file, wtrpath, "wtrcfg.tdb");
fp = fsopen(file, "rb", sharemode);
if (fp)
gfile fp(file, "rb", sharemode);
if (fp.isopen())
{
if (not quiet)
STD_PRINTNL("* Reading " << file);
char header[26];
fread(header, 26, 1, fp); strp2c(header);
fp.Fread(header, 26);
strp2c(header);
if(streql(header, ConfigHeader))
ReadWtrGteFile(options, fp);
else
STD_PRINTNL("* Error: WaterGate \"" << header << "\" is not supported - Skipping.");
fclose(fp);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -302,9 +302,11 @@ void EzycomInit(const char* msgbasepath, const char* userbasepath, int userno) {
const char* _username = WideUsername[0];
ezycomwide->user->ver = ezycomwide->ver;
if(ezycomwide->userno == -1) {
ezycomwide->user->fh = ::sopen(AddPath(ezycomwide->userbasepath, "USERS.BBS"), O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
if(ezycomwide->user->fh != -1) {
if (ezycomwide->userno == -1)
{
ezycomwide->user->gufh = ::sopen(AddPath(ezycomwide->userbasepath, "USERS.BBS"), O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
if (ezycomwide->user->gufh != -1)
{
ezycomwide->user->extfh = ::sopen(AddPath(ezycomwide->userbasepath, "USERSEXT.BBS"), O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
if(ezycomwide->user->extfh != -1) {
ezycomwide->user->find(_username);
@ -315,7 +317,7 @@ void EzycomInit(const char* msgbasepath, const char* userbasepath, int userno) {
}
close(ezycomwide->user->extfh);
}
close(ezycomwide->user->fh);
close(ezycomwide->user->gufh);
}
ezycomwide->userno = ezycomwide->user->index;
}

View File

@ -32,12 +32,13 @@
// ------------------------------------------------------------------
char* EzycomArea::user_lookup(char* __lookfor) {
wide->user->fh = ::sopen(AddPath(wide->userbasepath, "USERS.BBS"), O_RDWR|O_BINARY, WideSharemode, S_STDRW);
if(wide->user->fh) {
char* EzycomArea::user_lookup(char* __lookfor)
{
wide->user->gufh = ::sopen(AddPath(wide->userbasepath, "USERS.BBS"), O_RDWR|O_BINARY, WideSharemode, S_STDRW);
if (wide->user->gufh)
{
wide->user->findwild(__lookfor, __lookfor);
::close(wide->user->fh);
::close(wide->user->gufh);
}
if(wide->user->found)

View File

@ -139,15 +139,16 @@ void FidoInit(const char* fidolastread, int fidohwmarks, int fidonullfix, int fi
if(fidowide->userno == -1) {
Path userfile;
strxcpy(userfile, AddPath(fidowide->squishuserpath, "USER.BBS"), sizeof(Path));
fidowide->user->fh = ::sopen(userfile, O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
if(fidowide->user->fh != -1) {
fidowide->user->gufh = ::sopen(userfile, O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
if (fidowide->user->gufh != -1)
{
fidowide->user->find(_username);
if(not fidowide->user->found) {
WideLog->printf("* User \"%s\" not found in %s.", _username, userfile);
fidowide->user->add(_username);
WideLog->printf("* Now added with user number %u.", fidowide->user->index);
}
::close(fidowide->user->fh);
::close(fidowide->user->gufh);
}
fidowide->userno = fidowide->user->index;
}

View File

@ -33,13 +33,13 @@
// ------------------------------------------------------------------
char* FidoArea::user_lookup(char* __lookfor) {
char* FidoArea::user_lookup(char* __lookfor)
{
Path userfile;
strxcpy(userfile, AddPath(fidowide->squishuserpath, "USER.BBS"), sizeof(Path));
wide->user->fh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
wide->user->gufh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
wide->user->findwild(__lookfor, __lookfor);
::close(wide->user->fh);
::close(wide->user->gufh);
if(wide->user->found)
return __lookfor;

View File

@ -199,15 +199,15 @@ struct _HudsWide {
#pragma pack()
#endif
int fhtxt;
int fhhdr;
int fhidx;
int fhinf;
int fhlrd;
int fhtoi;
int fhusr;
int fhuix;
int fhuxi;
gfile fhtxt;
gfile fhhdr;
gfile fhidx;
gfile fhinf;
gfile fhlrd;
gfile fhtoi;
gfile fhusr;
gfile fhuix;
gfile fhuxi;
int isopen;
int islocked;
int timesposted;
@ -246,7 +246,7 @@ struct _HudsWide {
void update_netecho(char* __name, msgn_t __hdridx, int __delete);
int test_open(char* __file, int __oaccess);
void test_open(gfile &__file, char* __fname, int __oaccess);
void raw_open(int __oaccess=0, int __all=true);
void raw_close();
void refresh();

View File

@ -66,12 +66,9 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
GFTRK("HudsInit");
if(WideDebug)
if (WideDebug)
WideLog->printf("- Begin init for %s.", path);
fhusr = -1;
fhtxt = fhhdr = fhidx = -1;
fhinf = fhlrd = fhtoi = -1;
isopen = 0;
islocked = false;
timesposted = 0;
@ -81,16 +78,20 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
scn = NULL;
// Open complete msgbase, create if none exists
if(not fexist(AddPath(path, __HUDSON ? "msghdr" HUDS_EXT : "msghdr" GOLD_EXT))) {
if (not fexist(AddPath(path, __HUDSON ? "msghdr" HUDS_EXT : "msghdr" GOLD_EXT)))
{
WideLog->printf("* Creating new msgbase at %s", path);
raw_open(O_CREAT);
if(filelength(fhinf) == 0) {
if (fhinf.FileLength() == 0)
{
memset(&msginfo, 0, sizeof(HudsInfo));
write(fhinf, &msginfo, sizeof(HudsInfo));
fhinf.Write(&msginfo, sizeof(HudsInfo));
}
if(filelength(fhlrd) == 0) {
if (fhlrd.FileLength() == 0)
{
memset(lastrec, 0, sizeof(HudsLast));
write(fhlrd, lastrec, sizeof(HudsLast));
fhlrd.Write(lastrec, sizeof(HudsLast));
}
}
else {
@ -101,14 +102,15 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
lock();
// Check if MSGTXT.BBS is approaching dangerous size
if(__HUDSON and (filelength(fhtxt) > sizewarn))
if (__HUDSON and (fhtxt.FileLength() > sizewarn))
HudsSizewarn();
// Check for mismatch between the header and the index files
uint _hdrsize = filelength(fhhdr)/sizeof(HudsHdr);
uint _idxsize = filelength(fhidx)/sizeof(HudsIdx);
uint _toisize = filelength(fhtoi)/sizeof(HudsToIdx);
if((_hdrsize != _idxsize) or (_hdrsize != _toisize)) {
uint _hdrsize = fhhdr.FileLength()/sizeof(HudsHdr);
uint _idxsize = fhidx.FileLength()/sizeof(HudsIdx);
uint _toisize = fhtoi.FileLength()/sizeof(HudsToIdx);
if ((_hdrsize != _idxsize) or (_hdrsize != _toisize))
{
raw_close();
HGWarnRebuild();
WideLog->ErrIndex();
@ -124,7 +126,7 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
if(__HUDSON and (ra2usersbbs == 0)) {
// Get size of USERS.BBS
int len = filelength(fhusr);
int len = fhusr.FileLength();
// Does size match Hudson format?
int hudsmatch = (len % sizeof(HudsUsers)) == 0;
@ -137,23 +139,23 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
ra2usersbbs = 2;
// If it matches both of them
if(hudsmatch and ra2match) {
if (hudsmatch and ra2match)
{
// Check version in CONFIG.RA to make sure
Path rapath, file;
char* ptr = getenv("RA");
if(ptr)
AddBackslash(strcpy(rapath, ptr));
if (ptr) AddBackslash(strcpy(rapath, ptr));
MakePathname(file, rapath, "messages.ra");
int fh = ::sopen(file, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
if(fh != -1) {
gfile fh(file, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
if (fh.isopen())
{
word VersionID = 0;
read(fh, &VersionID, sizeof(word));
if(VersionID >= 0x200)
fh.Read(&VersionID, sizeof(word));
if (VersionID >= 0x200)
ra2usersbbs = 2;
else
ra2usersbbs = 1;
::close(fh);
}
}
@ -171,10 +173,11 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
}
}
if(__HUDSON) {
fhuix = fhuxi = -1;
if(ra2usersbbs == 2) {
if(WideDebug)
if (__HUDSON)
{
if (ra2usersbbs == 2)
{
if (WideDebug)
WideLog->printf("- Using a RA2 format userbase.");
user = new RA2User;
}
@ -189,16 +192,20 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
throw_new(user);
// Open RA2 files
if(__HUDSON and (ra2usersbbs == 2)) {
if (__HUDSON and (ra2usersbbs == 2))
{
RA2User* _user2 = (RA2User*)user;
_user2->idxfh = fhuix = test_open("usersidx.bbs", O_CREAT);
_user2->xifh = fhuxi = test_open("usersxi.bbs", O_CREAT);
test_open(fhuix, "usersidx.bbs", O_CREAT);
test_open(fhuxi, "usersxi.bbs", O_CREAT);
_user2->idxfh = &fhuix;
_user2->xifh = &fhuxi;
}
// Find user
const char* _username = WideUsername[0];
if(userno == -1) {
user->fh = fhusr;
if (userno == -1)
{
user->gufh = fhusr.fh;
user->find(_username);
if(not user->found) {
WideLog->printf("* User \"%s\" not found in %susers%s.", _username, path, __HUDSON ? HUDS_EXT : GOLD_EXT);
@ -212,9 +219,10 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::init() {
WideLog->printf("- Using user record number %u.", userno);
// Close RA2 files
if(__HUDSON and (ra2usersbbs == 2)) {
::close(fhuix);
::close(fhuxi);
if (__HUDSON and (ra2usersbbs == 2))
{
fhuix.Close();
fhuxi.Close();
}
// Unlock and close
@ -237,15 +245,16 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_lastread(
// Update lastread record
msgn_t _lastread = lastrec[board-1] = msgno;
lseekset(fhlrd, userno*sizeof(HudsLast));
write(fhlrd, lastrec, sizeof(HudsLast));
fhlrd.LseekSet(userno*sizeof(HudsLast));
fhlrd.Write(lastrec, sizeof(HudsLast));
// Update user record
user->fh = fhusr;
user->gufh = fhusr.fh;
user->moveto(userno);
if(user->lastread() < _lastread)
if (user->lastread() < _lastread)
user->lastread(_lastread);
if(timesposted) {
if (timesposted)
{
user->inctimesposted(timesposted);
timesposted = 0;
}

View File

@ -29,17 +29,17 @@
// ------------------------------------------------------------------
template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON>
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::raw_close() {
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::raw_close()
{
GFTRK("HudsRawClose");
if(fhtxt != -1) ::close(fhtxt); fhtxt = -1;
if(fhhdr != -1) ::close(fhhdr); fhhdr = -1;
if(fhidx != -1) ::close(fhidx); fhidx = -1;
if(fhinf != -1) ::close(fhinf); fhinf = -1;
if(fhlrd != -1) ::close(fhlrd); fhlrd = -1;
if(fhtoi != -1) ::close(fhtoi); fhtoi = -1;
if(fhusr != -1) ::close(fhusr); fhusr = -1;
fhtxt.Close();
fhhdr.Close();
fhidx.Close();
fhinf.Close();
fhlrd.Close();
fhtoi.Close();
fhusr.Close();
GFTRK(NULL);
}
@ -48,25 +48,26 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::raw_close() {
// ------------------------------------------------------------------
template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON>
int _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::test_open(char* __file, int __oaccess) {
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::test_open(gfile &__file, char* __fname, int __oaccess)
{
GFTRK("HudsTestOpen");
int _fh;
long _tries = 0;
__oaccess |= O_RDWR|O_BINARY;
do {
do
{
Path _testfn;
strcpy(_testfn, AddPath(path, __file));
strcpy(_testfn, AddPath(path, __fname));
int _omode = (__oaccess & O_CREAT) ? S_STDRW : S_STDRD;
_fh = ::sopen(_testfn, __oaccess, WideSharemode, _omode);
if(_fh == -1) {
if(errno == ENOENT) {
if(_tries == 0) {
__file.Open(_testfn, __oaccess, WideSharemode, _omode);
if (!__file.isopen())
{
if (errno == ENOENT)
{
if (_tries == 0)
{
__oaccess |= O_CREAT;
_tries++;
continue;
@ -74,12 +75,12 @@ int _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::test_open(char*
}
// Request the other program to unlock
if(errno != ENOENT)
if (errno != ENOENT)
TouchFile(AddPath(path, "mbunlock.now"));
// Tell the world
if(PopupLocked(++_tries, false, _testfn) == false) {
if (PopupLocked(++_tries, false, _testfn) == false)
{
// User requested to exit
WideLog->ErrOpen();
raw_close();
@ -89,15 +90,14 @@ int _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::test_open(char*
OpenErrorExit();
}
}
} while(_fh == -1);
}
while (!__file.isopen());
// Remove the popup window
if(_tries)
if (_tries)
PopupLocked(0, 0, NULL);
GFTRK(NULL);
return _fh;
}
@ -108,14 +108,15 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::raw_open(int _
GFTRK("HudsRawOpen");
fhidx = test_open(__HUDSON ? "msgidx" HUDS_EXT : "msgidx" GOLD_EXT, __oaccess);
fhinf = test_open(__HUDSON ? "msginfo" HUDS_EXT : "msginfo" GOLD_EXT, __oaccess);
fhlrd = test_open(__HUDSON ? "lastread" HUDS_EXT : "lastread" GOLD_EXT, __oaccess);
fhtoi = test_open(__HUDSON ? "msgtoidx" HUDS_EXT : "msgtoidx" GOLD_EXT, __oaccess);
if(__all) {
fhhdr = test_open(__HUDSON ? "msghdr" HUDS_EXT : "msghdr" GOLD_EXT, __oaccess);
fhtxt = test_open(__HUDSON ? "msgtxt" HUDS_EXT : "msgtxt" GOLD_EXT, __oaccess);
fhusr = test_open(__HUDSON ? "users" HUDS_EXT : "users" GOLD_EXT, __oaccess);
test_open(fhidx, __HUDSON ? "msgidx" HUDS_EXT : "msgidx" GOLD_EXT, __oaccess);
test_open(fhinf, __HUDSON ? "msginfo" HUDS_EXT : "msginfo" GOLD_EXT, __oaccess);
test_open(fhlrd, __HUDSON ? "lastread" HUDS_EXT : "lastread" GOLD_EXT, __oaccess);
test_open(fhtoi, __HUDSON ? "msgtoidx" HUDS_EXT : "msgtoidx" GOLD_EXT, __oaccess);
if (__all)
{
test_open(fhhdr, __HUDSON ? "msghdr" HUDS_EXT : "msghdr" GOLD_EXT, __oaccess);
test_open(fhtxt, __HUDSON ? "msgtxt" HUDS_EXT : "msgtxt" GOLD_EXT, __oaccess);
test_open(fhusr, __HUDSON ? "users" HUDS_EXT : "users" GOLD_EXT, __oaccess);
}
GFTRK(NULL);
@ -143,20 +144,20 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::refresh() {
GFTRK("HudsRefresh");
// (Re)Allocate memory to hold the complete MSGIDX.BBS/DAT
msgidxsize = filelength(fhidx);
msgidxsize = fhidx.FileLength();
msgidxptr = (HudsIdx*)throw_realloc(msgidxptr, (uint)(msgidxsize+sizeof(HudsIdx)));
// Load MSGIDX.BBS/DAT
lseek(fhidx, 0, SEEK_SET);
read(fhidx, msgidxptr, (uint)msgidxsize);
fhidx.LseekSet(0);
fhidx.Read(msgidxptr, (uint)msgidxsize);
// Load MSGINFO.BBS/DAT
lseek(fhinf, 0, SEEK_SET);
read(fhinf, &msginfo, sizeof(HudsInfo));
fhinf.LseekSet(0);
fhinf.Read(&msginfo, sizeof(HudsInfo));
// Load LASTREAD.BBS/DAT
lseek(fhlrd, userno*sizeof(HudsLast), SEEK_SET);
read(fhlrd, lastrec, sizeof(HudsLast));
fhlrd.LseekSet(userno*sizeof(HudsLast));
fhlrd.Read(lastrec, sizeof(HudsLast));
GFTRK(NULL);
}
@ -211,8 +212,8 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::lock() {
long _tries = 0;
// Try to get the lock
while(::lock(fhinf, sizeof(HudsInfo)+1, 1) == -1) {
while (fhinf.Lock(sizeof(HudsInfo)+1, 1) == -1)
{
// Tell the world
if(PopupLocked(++_tries, true, AddPath(path, __HUDSON ? "msginfo" HUDS_EXT : "msginfo" GOLD_EXT)) == false) {
@ -251,8 +252,9 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::unlock() {
GFTRK("HudsUnlock");
if(islocked and WideCanLock) {
::unlock(fhinf, sizeof(HudsInfo)+1, 1);
if (islocked and WideCanLock)
{
fhinf.Unlock(sizeof(HudsInfo)+1, 1);
islocked = false;
}
@ -578,7 +580,7 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::scan_pm() {
ispmscanned = true;
HudsToIdx* toidxbuf = (HudsToIdx*)throw_calloc(TOIDXBUFSZ, sizeof(HudsToIdx));
uint totrecs = (uint)(filelength(fhtoi) / sizeof(HudsToIdx));
uint totrecs = (uint)(fhtoi.FileLength() / sizeof(HudsToIdx));
HudsIdx* idxptr = msgidxptr;
throw_release(pmscan);
pmscantotal = 0;
@ -592,7 +594,7 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::scan_pm() {
rec = 0;
gotpm = false;
getrecs = MinV(TOIDXBUFSZ, totrecs);
read(fhtoi, toidxbuf, getrecs*sizeof(HudsToIdx));
fhtoi.Read(toidxbuf, getrecs*sizeof(HudsToIdx));
for(toidx=toidxbuf; rec<getrecs; idxptr++,toidx++,rec++) {

View File

@ -97,8 +97,8 @@ int _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::load_message(in
// Read header
msgn_t _hdridx = get_hdr_idx(__msg, __FILE__, __LINE__);
lseek(wide->fhhdr, (int32_t)_hdridx*(int32_t)sizeof(HudsHdr), SEEK_SET);
read(wide->fhhdr, &__hdr, sizeof(HudsHdr));
wide->fhhdr.LseekSet((int32_t)_hdridx*(int32_t)sizeof(HudsHdr));
wide->fhhdr.Read(&__hdr, sizeof(HudsHdr));
__msg->msgno = __hdr.msgno;
__msg->link.to_set(__hdr.replyto);
@ -174,8 +174,8 @@ int _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::load_message(in
if(_numrecs) {
// Seek to, and read the raw text
lseek(wide->fhtxt, (int32_t)__hdr.startrec*256L, SEEK_SET);
read(wide->fhtxt, __msg->txt, _numrecs*256);
wide->fhtxt.LseekSet((int32_t)__hdr.startrec*256L);
wide->fhtxt.Read(__msg->txt, _numrecs*256);
// Set up loop variables
char* _src = __msg->txt;

View File

@ -29,25 +29,27 @@
// ------------------------------------------------------------------
template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON>
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::update_netecho(char* __name, msgn_t __hdridx, int __delete) {
void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::update_netecho(char* __name, msgn_t __hdridx, int __delete)
{
GFTRK("HudsUpdateNetEcho");
Path name;
strcpy(name, AddPath(syspath, __name));
int _fh = test_open(name, O_CREAT);
gfile _fh;
test_open(_fh, name, O_CREAT);
// Get size of the file
uint _total = (uint)(filelength(_fh)/sizeof(msgn_t));
uint _total = (uint)(_fh.FileLength()/sizeof(msgn_t));
// Allocate memory for the scanning index
msgn_t* _scanidx = (msgn_t*)throw_calloc(_total+5, sizeof(msgn_t));
// Read the scanning index
read(_fh, _scanidx, _total*sizeof(msgn_t));
_fh.Read(_scanidx, _total*sizeof(msgn_t));
// Close the file
::close(_fh);
_fh.Close();
// Search for the specified header index
uint _pos = 0;
@ -85,10 +87,11 @@ void _HudsWide<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::update_netecho
}
// Write the changed scanning file from scratch
if(_total) {
_fh = test_open(__name, O_CREAT|O_TRUNC);
write(_fh, _scanidx, _total*sizeof(msgn_t));
::close(_fh);
if (_total)
{
test_open(_fh, __name, O_CREAT|O_TRUNC);
_fh.Write(_scanidx, _total*sizeof(msgn_t));
_fh.Close();
}
else {
// If the last header index was removed, delete the file
@ -114,9 +117,10 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
// Find header index
msgn_t _hdridx;
if(__mode & GMSG_NEW) {
if (__mode & GMSG_NEW)
{
__msg->msgno = wide->msginfo.high + 1;
_hdridx = (msgn_t)(filelength(wide->fhhdr)/sizeof(HudsHdr));
_hdridx = (msgn_t)(wide->fhhdr.FileLength()/sizeof(HudsHdr));
}
else {
_hdridx = get_hdr_idx(__msg, __FILE__, __LINE__);
@ -182,7 +186,7 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
// If the msg is new or the text is too large to fit
uint _txtlen = strlen(__msg->txt)+1;
if((__mode & GMSG_NEW) or (_txtlen > __msg->txtlength*255L))
__hdr.startrec = (msgn_t)(filelength(wide->fhtxt)/256L);
__hdr.startrec = (msgn_t)(wide->fhtxt.FileLength()/256L);
// Calculate the number of text records to write
register uint _fullrecs = _txtlen / 255;
@ -190,7 +194,7 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
__hdr.numrecs = (word)(_fullrecs + (_extrarec ? 1 : 0));
// Seek to the text write position
lseek(wide->fhtxt, __hdr.startrec*256L, SEEK_SET);
wide->fhtxt.LseekSet(__hdr.startrec*256L);
// Write the message text
register uint _count = 0;
@ -198,23 +202,25 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
char _txtbuf[256];
char* _txtptr = _txtbuf + 1;
*_txtbuf = 255;
while(_count < _fullrecs) {
while (_count < _fullrecs)
{
memcpy(_txtptr, _txt, 255);
write(wide->fhtxt, _txtbuf, 256);
wide->fhtxt.Write(_txtbuf, 256);
_txt += 255;
_count++;
}
if(_extrarec) {
if (_extrarec)
{
*_txtbuf = _extrarec;
memset(_txtptr, 0, 255);
memcpy(_txtptr, _txt, _extrarec);
write(wide->fhtxt, _txtbuf, 256);
wide->fhtxt.Write(_txtbuf, 256);
}
}
// Write to MSGHDR.BBS/DAT
lseek(wide->fhhdr, _hdridx*sizeof(HudsHdr), SEEK_SET);
write(wide->fhhdr, &__hdr, sizeof(HudsHdr));
wide->fhhdr.LseekSet(_hdridx*sizeof(HudsHdr));
wide->fhhdr.Write(&__hdr, sizeof(HudsHdr));
// Write to MSGIDX.BBS/DAT
if(__mode & GMSG_NEW) {
@ -224,17 +230,17 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
HudsIdx* _idxp = wide->msgidxptr + (uint)_hdridx;
_idxp->board = __hdr.board;
_idxp->msgno = (msgn_t)((__mode & GMSG_DELETE) ? (__HUDSON ? HUDS_DELETEDMSGNO : GOLD_DELETEDMSGNO) : __hdr.msgno);
lseek(wide->fhidx, _hdridx*sizeof(HudsIdx), SEEK_SET);
write(wide->fhidx, _idxp, sizeof(HudsIdx));
wide->fhidx.LseekSet(_hdridx*sizeof(HudsIdx));
wide->fhidx.Write(_idxp, sizeof(HudsIdx));
// Write to MSGTOIDX.BBS/DAT
lseek(wide->fhtoi, _hdridx*sizeof(HudsToIdx), SEEK_SET);
if(__mode & GMSG_DELETE)
write(wide->fhtoi, "\xB* Deleted *\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(HudsToIdx));
wide->fhtoi.LseekSet(_hdridx*sizeof(HudsToIdx));
if (__mode & GMSG_DELETE)
wide->fhtoi.Write("\xB* Deleted *\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(HudsToIdx));
else if(__hdr.msgattr & HUDS_RECEIVED)
write(wide->fhtoi, "\xC* Received *\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(HudsToIdx));
wide->fhtoi.Write("\xC* Received *\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(HudsToIdx));
else
write(wide->fhtoi, __hdr.to, sizeof(HudsToIdx));
wide->fhtoi.Write(__hdr.to, sizeof(HudsToIdx));
// Write to MSGINFO.BBS/DAT
if(__mode & GMSG_DELETE) {
@ -272,8 +278,8 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::save_message(i
if(__hdr.msgno > wide->msginfo.high)
wide->msginfo.high = __hdr.msgno;
}
lseek(wide->fhinf, 0, SEEK_SET);
write(wide->fhinf, &wide->msginfo, sizeof(HudsInfo));
wide->fhinf.LseekSet(0);
wide->fhinf.Write(&wide->msginfo, sizeof(HudsInfo));
// Update scanning files
if((__hdr.msgattr & HUDS_NETTRANS) or (__mode & GMSG_DELETE))
@ -357,15 +363,15 @@ void _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::update_timesre
lock();
msgn_t hdridx = get_hdr_idx(msg, __FILE__, __LINE__);
::lseekset(wide->fhhdr, hdridx*sizeof(HudsHdr));
wide->fhhdr.LseekSet(hdridx*sizeof(HudsHdr));
HudsHdr hdr;
::read(wide->fhhdr, &hdr, sizeof(HudsHdr));
wide->fhhdr.Read(&hdr, sizeof(HudsHdr));
hdr.timesread = (word)msg->timesread;
::lseekset(wide->fhhdr, hdridx*sizeof(HudsHdr));
::write(wide->fhhdr, &hdr, sizeof(HudsHdr));
wide->fhhdr.LseekSet(hdridx*sizeof(HudsHdr));
wide->fhhdr.Write(&hdr, sizeof(HudsHdr));
unlock();

View File

@ -29,9 +29,9 @@
// ------------------------------------------------------------------
template <class msgn_t, class rec_t, class attr_t, class board_t, class last_t, bool __HUDSON>
char* _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::user_lookup(char* __lookfor) {
wide->user->fh = wide->fhusr;
char* _HudsArea<msgn_t, rec_t, attr_t, board_t, last_t, __HUDSON>::user_lookup(char* __lookfor)
{
wide->user->gufh = wide->fhusr.fh;
wide->user->findwild(__lookfor, __lookfor);
if(wide->user->found)

View File

@ -132,8 +132,9 @@ void PcbInit(const char* path, int userno) {
fp.Fclose();
const char* _username = WideUsername[0];
pcbwide->user->fh = ::sopen(AddPath(_path, pcbwide->users), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
if(pcbwide->user->fh != -1) {
pcbwide->user->gufh = ::sopen(AddPath(_path, pcbwide->users), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
if (pcbwide->user->gufh != -1)
{
pcbwide->user->fhinf = ::sopen(AddPath(_path, pcbwide->usersinf), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
if(pcbwide->user->fhinf != -1) {
::read(pcbwide->user->fhinf, &pcbwide->usershdr, sizeof(PcbUsersInfHdr));
@ -151,7 +152,7 @@ void PcbInit(const char* path, int userno) {
}
close(pcbwide->user->fhinf);
}
close(pcbwide->user->fh);
close(pcbwide->user->gufh);
}
pcbwide->userno = pcbwide->user->index;
}

View File

@ -101,7 +101,7 @@ void PcbWideOpen() {
pcbwide->fhusr = PcbWideTestOpen(pcbwide->users);
pcbwide->fhinf = PcbWideTestOpen(pcbwide->usersinf);
pcbwide->user->fh = pcbwide->fhusr;
pcbwide->user->gufh = pcbwide->fhusr;
pcbwide->user->fhinf = pcbwide->fhinf;
// Read lastreads from USERS file

View File

@ -89,16 +89,18 @@ void SquishInit(const char* userpath, int userno, int direct, int recycle, int s
Path userfile;
strxcpy(userfile, AddPath(userpath, "USER.BBS"), sizeof(Path));
const char* _username = WideUsername[0];
if(squishwide->userno == -1) {
squishwide->user->fh = ::sopen(userfile, O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
if(squishwide->user->fh != -1) {
if (squishwide->userno == -1)
{
squishwide->user->gufh = ::sopen(userfile, O_RDWR|O_CREAT|O_BINARY, WideSharemode, S_STDRW);
if (squishwide->user->gufh != -1)
{
squishwide->user->find(_username);
if(not squishwide->user->found) {
WideLog->printf("* User \"%s\" not found in %s.", _username, userfile);
squishwide->user->add(_username);
WideLog->printf("* Now added with user number %u.", squishwide->user->index);
}
close(squishwide->user->fh);
close(squishwide->user->gufh);
}
squishwide->userno = squishwide->user->index;
}

View File

@ -33,13 +33,13 @@
// ------------------------------------------------------------------
char* SquishArea::user_lookup(char* __lookfor) {
char* SquishArea::user_lookup(char* __lookfor)
{
Path userfile;
strxcpy(userfile, AddPath(wide->userpath, "USER.BBS"), sizeof(Path));
wide->user->fh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
wide->user->gufh = ::sopen(userfile, O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
wide->user->findwild(__lookfor, __lookfor);
::close(wide->user->fh);
::close(wide->user->gufh);
if(wide->user->found)
return __lookfor;

View File

@ -64,11 +64,14 @@ void XbbsArea::raw_close() {
if(data->fhindex != -1) ::close(data->fhindex); data->fhindex = -1;
if(data->fhtext != -1) ::close(data->fhtext); data->fhtext = -1;
if(wide->isopen) {
if(wide->isopen == 1) {
if(wide->user->fh != -1) {
::close(wide->user->fh);
wide->user->fh= -1;
if (wide->isopen)
{
if (wide->isopen == 1)
{
if (wide->user->gufh != -1)
{
::close(wide->user->gufh);
wide->user->gufh = -1;
}
}
wide->isopen--;
@ -128,8 +131,8 @@ void XbbsArea::raw_open() {
data->fhindex = test_open(AddPath(real_path(), ".Index"));
data->fhtext = test_open(AddPath(real_path(), ".Text"));
wide->isopen++;
if(wide->isopen == 1)
wide->user->fh = ::sopen(AddPath(wide->path, "Users"), O_RDONLY|O_BINARY, WideSharemode, S_STDRW);
if (wide->isopen == 1)
wide->user->gufh = ::sopen(AddPath(wide->path, "Users"), O_RDONLY|O_BINARY, WideSharemode, S_STDRW);
GFTRK(NULL);
}
@ -159,15 +162,17 @@ void XbbsInit(const char* path, int userno) {
xbbswide->user = new XbbsUser;
throw_new(xbbswide->user);
xbbswide->user->fh = -1;
xbbswide->user->gufh = -1;
xbbswide->fhpmi = -1;
xbbswide->pmi = NULL;
xbbswide->isopen = 0;
const char* _username = WideUsername[0];
if(xbbswide->userno == -1) {
xbbswide->user->fh = ::sopen(AddPath(xbbswide->path, "Users"), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
if(xbbswide->user->fh != -1) {
if (xbbswide->userno == -1)
{
xbbswide->user->gufh = ::sopen(AddPath(xbbswide->path, "Users"), O_RDONLY|O_BINARY, WideSharemode, S_STDRD);
if (xbbswide->user->gufh != -1)
{
xbbswide->user->find(_username);
if(not xbbswide->user->found) {
xbbswide->userno = 0;
@ -175,7 +180,7 @@ void XbbsInit(const char* path, int userno) {
//xbbswide->user->add(_username);
//WideLog->printf("* Now added with user number %u.", xbbswide->user->index);
}
close(xbbswide->user->fh);
close(xbbswide->user->gufh);
}
xbbswide->userno = xbbswide->user->index;
}

View File

@ -31,12 +31,13 @@
// ------------------------------------------------------------------
char* XbbsArea::user_lookup(char* __lookfor) {
wide->user->fh = ::sopen(AddPath(wide->path, "Users"), O_RDWR|O_BINARY, WideSharemode, S_STDRD);
if(wide->user->fh) {
char* XbbsArea::user_lookup(char* __lookfor)
{
wide->user->gufh = ::sopen(AddPath(wide->path, "Users"), O_RDWR|O_BINARY, WideSharemode, S_STDRD);
if (wide->user->gufh)
{
wide->user->findwild(__lookfor, __lookfor);
::close(wide->user->fh);
::close(wide->user->gufh);
}
if(wide->user->found)

File diff suppressed because it is too large Load Diff

View File

@ -93,7 +93,7 @@ struct lang_map {
struct cs_info * get_current_cs(const char * es);
struct unicode_info * get_utf_cs();
struct unicode_info * get_utf_cs(bool what = true);
int get_utf_cs_len();

View File

@ -1,6 +1,10 @@
#include "csutil.hxx"
/* fields: Unicode letter, toupper, tolower */
struct unicode_info utf_lst[] = {
struct unicode_info * get_utf_cs(bool what)
{
static struct unicode_info utf_lst[] =
{
{ 0x0041, 0x0041, 0x0061 },
{ 0x0042, 0x0042, 0x0062 },
{ 0x0043, 0x0043, 0x0063 },
@ -8504,3 +8508,6 @@ struct unicode_info utf_lst[] = {
{ 0xFFDB, 0xFFDB, 0xFFDB },
{ 0xFFDC, 0xFFDC, 0xFFDC }
};
return what ? utf_lst : (unicode_info*)(sizeof(utf_lst) / sizeof(unicode_info));
}

View File

@ -1,628 +0,0 @@
----- scott-dudley.txt begins -----
From sdudley@idiom.com Wed Feb 12 02:32:00 2003
Return-Path: <sdudley@idiom.com>
Received: from server3.fastmail.fm (server3.internal [10.202.2.134])
by server2.fastmail.fm (Cyrus v2.1.9) with LMTP; Tue, 11 Feb 2003
20:32:00 -0500
X-Sieve: CMU Sieve 2.2
Received: from server3.fastmail.fm (server3.internal [10.202.2.134])
by server3.fastmail.fm (Cyrus v2.1.9) with LMTP; Tue, 11 Feb 2003
20:32:01 -0500
Received: from server3.fastmail.fm (localhost [127.0.0.1])
by fastmail.fm (Postfix) with ESMTP id A8C6C3E9CB
for <tobias_ernst@eml.cc>; Tue, 11 Feb 2003 20:32:01 -0500 (EST)
X-Attached: smime.p7s
Received: from 127.0.0.1 ([127.0.0.1] helo=server3.fastmail.fm) by fastmail.fm
with SMTP; Tue, 11 Feb 2003 20:32:01 -0500
X-Mail-from: sdudley@idiom.com
X-Delivered-to: <tobias_ernst@eml.cc>
Received: from idiom.com (idiom.com [216.240.32.1])
by server3.fastmail.fm (Postfix) with ESMTP id 4401D3CE82
for <tobias_ernst@eml.cc>; Tue, 11 Feb 2003 20:32:01 -0500 (EST)
Received: from idiom.com (1Cust11.tnt16.sfo8.da.uu.net [63.11.211.11])
by idiom.com (8.12.6/8.12.6) with ESMTP id h1C1VtAE098669
for <tobias_ernst@eml.cc>; Tue, 11 Feb 2003 17:31:56 -0800 (PST)
(envelope-from sdudley@idiom.com)
Message-ID: <3E49A3D4.1060905@idiom.com>
Date: Tue, 11 Feb 2003 17:31:00 -0800
From: Scott Dudley <sdudley@idiom.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1)
Gecko/20021130
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: Tobias Ernst <tobias_ernst@eml.cc>
Subject: MsgAPI licensing change notification
References: <20747336-3D1F-11D7-A3EB-0003931DA274@eml.cc>
In-Reply-To: <20747336-3D1F-11D7-A3EB-0003931DA274@eml.cc>
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature";
micalg=sha1; boundary="------------ms050204080905050402000901"
Status: RO
Content-Length: 32323
Lines: 584
This is a cryptographically signed message in MIME format.
--------------ms050204080905050402000901
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit
Tobias,
That sounds reasonable. I hereby notify you that the terms and
conditions of the MsgAPI source code release are changed to those of the
GNU Lesser General Public License, the text of which is included below.
You are free to use and redistribute any of the MsgAPI code (or its
derivatives) in a manner which is consistent with the aforementioned
license agreement.
This message is digitally signed to verify its authenticity.
Scott Dudley
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
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 and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, 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 library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete 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 distribute a copy of this License along with the
Library.
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 Library or any portion
of it, thus forming a work based on the Library, 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) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
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 Library, 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 Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you 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.
If distribution of 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 satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be 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.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library 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.
9. 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 Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
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 with
this License.
11. 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 Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library 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 Library.
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.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library 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.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser 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 Library
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 Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
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
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "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
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. 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 LIBRARY 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
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
--------------ms050204080905050402000901
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature
MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIPtDCC
BMgwggQxoAMCAQICBAIAApswDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCVVMxGDAWBgNV
BAoTD0dURSBDb3Jwb3JhdGlvbjEcMBoGA1UEAxMTR1RFIEN5YmVyVHJ1c3QgUm9vdDAeFw0w
MjA4MjcxOTA3MDBaFw0wNjAyMjMyMzU5MDBaMIHcMQswCQYDVQQGEwJHQjEXMBUGA1UEChMO
Q29tb2RvIExpbWl0ZWQxHTAbBgNVBAsTFENvbW9kbyBUcnVzdCBOZXR3b3JrMUYwRAYDVQQL
Ez1UZXJtcyBhbmQgQ29uZGl0aW9ucyBvZiB1c2U6IGh0dHA6Ly93d3cuY29tb2RvLm5ldC9y
ZXBvc2l0b3J5MR8wHQYDVQQLExYoYykyMDAyIENvbW9kbyBMaW1pdGVkMSwwKgYDVQQDEyND
b21vZG8gQ2xhc3MgMyBTZWN1cml0eSBTZXJ2aWNlcyBDQTCCASIwDQYJKoZIhvcNAQEBBQAD
ggEPADCCAQoCggEBALEeYGbgQwaeJ2gvApnHiN+F69tl7NRJZ3ouH83cFSzWHqzynUY6XQPA
PQUsWhgNWSVCo3LArSjSrTwx4ksH+16Y66gz1mmyWp7qLEmmJi5M8MyrQNKq3ixOgbW6e7hc
0Hu9R/XABtLA5NdH22JAr6EcUQMY27jQu5THPHnqJWSuJhnhPGZHZ5Kde1WrNMJ1btknjp2M
8B3aa5yGBKKQteqdjM/7OUOo8BgtnvcZECycL+HQsf/XWcTNQDL514HbURzyQVKBQbGDuMgJ
/pkiR4BPnMuu4CjVHKxwR7Alq6E4Qhdr+mpujV95+PYpAzCkbkbUhV2qQJk4dtseAX3lDKUC
AwEAAaOCAacwggGjMEUGA1UdHwQ+MDwwOqA4oDaGNGh0dHA6Ly93d3cucHVibGljLXRydXN0
LmNvbS9jZ2ktYmluL0NSTC8yMDA2L2NkcC5jcmwwHQYDVR0OBBYEFPZSIhcVEwgDWb8YlZ9I
tLnp/vhmMIGSBgNVHSAEgYowgYcwSQYKKoZIhvhjAQIBBTA7MDkGCCsGAQUFBwIBFi1odHRw
Oi8vd3d3LnB1YmxpYy10cnVzdC5jb20vQ1BTL09tbmlSb290Lmh0bWwwOgYMKwYBBAGyMQEC
AQMBMCowKAYIKwYBBQUHAgEWHGh0dHBzOi8vc2VjdXJlLmNvbW9kby5uZXQvQ1AwWAYDVR0j
BFEwT6FJpEcwRTELMAkGA1UEBhMCVVMxGDAWBgNVBAoTD0dURSBDb3Jwb3JhdGlvbjEcMBoG
A1UEAxMTR1RFIEN5YmVyVHJ1c3QgUm9vdIICAaMwKwYDVR0QBCQwIoAPMjAwMjA4MjcxOTA3
MzFagQ8yMDA1MDIyMzIzNTkwMFowDgYDVR0PAQH/BAQDAgHmMA8GA1UdEwQIMAYBAf8CAQAw
DQYJKoZIhvcNAQEFBQADgYEAtqewenGL4LqzgR42MnqGGNbxq005CHEGWmegSwHlMEBtibWe
Faqxx/QKxlwO6TfeqJfH3M7Ncft0AgfcXxUnCFMHdtS5BunCd1AeysmwwkaBgACtRKpc1iDZ
VTK+Vpbx6r2g47wNgDrqzPuaV+14pTY9VurR53TKNMPPsVHp4AwwggVwMIIEWKADAgECAhEA
gqh5rwlNvu/BrjIcZKPOBDANBgkqhkiG9w0BAQUFADCB3DELMAkGA1UEBhMCR0IxFzAVBgNV
BAoTDkNvbW9kbyBMaW1pdGVkMR0wGwYDVQQLExRDb21vZG8gVHJ1c3QgTmV0d29yazFGMEQG
A1UECxM9VGVybXMgYW5kIENvbmRpdGlvbnMgb2YgdXNlOiBodHRwOi8vd3d3LmNvbW9kby5u
ZXQvcmVwb3NpdG9yeTEfMB0GA1UECxMWKGMpMjAwMiBDb21vZG8gTGltaXRlZDEsMCoGA1UE
AxMjQ29tb2RvIENsYXNzIDMgU2VjdXJpdHkgU2VydmljZXMgQ0EwHhcNMDMwMTE3MDAwMDAw
WhcNMDQwMTE3MjM1OTU5WjCB2TE1MDMGA1UECxMsQ29tb2RvIFRydXN0IE5ldHdvcmsgLSBQ
RVJTT05BIE5PVCBWQUxJREFURUQxRjBEBgNVBAsTPVRlcm1zIGFuZCBDb25kaXRpb25zIG9m
IHVzZTogaHR0cDovL3d3dy5jb21vZG8ubmV0L3JlcG9zaXRvcnkxHzAdBgNVBAsTFihjKTIw
MDIgQ29tb2RvIExpbWl0ZWQxFTATBgNVBAMTDFNjb3R0IER1ZGxleTEgMB4GCSqGSIb3DQEJ
ARYRc2R1ZGxleUBpZGlvbS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALK6wZ0K
LHchdhyFQHkh3AuPcR81I5ung3Dj/KTsGEKPazdhOycmP58NRRqs/87uugN27fZn8Y4s/Kw6
lRIRNdJ0n66KMn/gEl+TtneSGQ+3qa5WEOKaqu7PQa7kPBKyUvw2l6Wt5KQB7hQok2fcqeL4
lHVDIqDbXz3Dk3f+HUN3AgMBAAGjggGwMIIBrDAfBgNVHSMEGDAWgBT2UiIXFRMIA1m/GJWf
SLS56f74ZjAdBgNVHQ4EFgQUUuzvk3Tmqvz07na9//80lnMmpXowDgYDVR0PAQH/BAQDAgWg
MAwGA1UdEwEB/wQCMAAwIAYDVR0lBBkwFwYIKwYBBQUHAwQGCysGAQQBsjEBAwUCMEYGA1Ud
IAQ/MD0wOwYMKwYBBAGyMQECAQEBMCswKQYIKwYBBQUHAgEWHWh0dHBzOi8vc2VjdXJlLmNv
bW9kby5uZXQvQ1BTMIGwBgNVHR8EgagwgaUwOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvLm5l
dC9DbGFzczNTZWN1cml0eVNlcnZpY2VzXzIuY3JsMDqgOKA2hjRodHRwOi8vY3JsLmNvbW9k
b2NhLmNvbS9DbGFzczNTZWN1cml0eVNlcnZpY2VzXzIuY3JsMC2gK6ApgSdDbGFzczNTZWN1
cml0eVNlcnZpY2VzXzJAY3JsLmNvbW9kby5uZXQwEQYJYIZIAYb4QgEBBAQDAgUgMBwGA1Ud
EQQVMBOBEXNkdWRsZXlAaWRpb20uY29tMA0GCSqGSIb3DQEBBQUAA4IBAQAGlpSAG30INsP2
eJnsSMLaJtVR2AyvnN/hN83XHPVAo3rX/7rWI0aHJ4uVHoev9LYutkJMW6CwIWVJ9M/U4R4k
nsJzUfc9moXiCvRUEesHTAAhCzuFwNd7ji8tBpZr0fmeLYBkCFa/WuohR7mZGPQ/zK14CDbz
8iogSI8s/ROsCt7XSk3zEYevTnihIzAAVW0o3aDFGlzhnHZSJZ/hkL6ERb80jcOSMoRcRRDV
d/mZq3lMA5btMQT6Xy5FsxZmettduVEV3q12/cHNjdtDTdcSZl+fbeYsfITlg5nt5sMrCAzQ
i2kg/poagqnR/Fqe0eS12PnrAk4J83F3c1IznjHuMIIFcDCCBFigAwIBAgIRAIKoea8JTb7v
wa4yHGSjzgQwDQYJKoZIhvcNAQEFBQAwgdwxCzAJBgNVBAYTAkdCMRcwFQYDVQQKEw5Db21v
ZG8gTGltaXRlZDEdMBsGA1UECxMUQ29tb2RvIFRydXN0IE5ldHdvcmsxRjBEBgNVBAsTPVRl
cm1zIGFuZCBDb25kaXRpb25zIG9mIHVzZTogaHR0cDovL3d3dy5jb21vZG8ubmV0L3JlcG9z
aXRvcnkxHzAdBgNVBAsTFihjKTIwMDIgQ29tb2RvIExpbWl0ZWQxLDAqBgNVBAMTI0NvbW9k
byBDbGFzcyAzIFNlY3VyaXR5IFNlcnZpY2VzIENBMB4XDTAzMDExNzAwMDAwMFoXDTA0MDEx
NzIzNTk1OVowgdkxNTAzBgNVBAsTLENvbW9kbyBUcnVzdCBOZXR3b3JrIC0gUEVSU09OQSBO
T1QgVkFMSURBVEVEMUYwRAYDVQQLEz1UZXJtcyBhbmQgQ29uZGl0aW9ucyBvZiB1c2U6IGh0
dHA6Ly93d3cuY29tb2RvLm5ldC9yZXBvc2l0b3J5MR8wHQYDVQQLExYoYykyMDAyIENvbW9k
byBMaW1pdGVkMRUwEwYDVQQDEwxTY290dCBEdWRsZXkxIDAeBgkqhkiG9w0BCQEWEXNkdWRs
ZXlAaWRpb20uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCyusGdCix3IXYchUB5
IdwLj3EfNSObp4Nw4/yk7BhCj2s3YTsnJj+fDUUarP/O7roDdu32Z/GOLPysOpUSETXSdJ+u
ijJ/4BJfk7Z3khkPt6muVhDimqruz0Gu5DwSslL8NpelreSkAe4UKJNn3Kni+JR1QyKg2189
w5N3/h1DdwIDAQABo4IBsDCCAawwHwYDVR0jBBgwFoAU9lIiFxUTCANZvxiVn0i0uen++GYw
HQYDVR0OBBYEFFLs75N05qr89O52vf//NJZzJqV6MA4GA1UdDwEB/wQEAwIFoDAMBgNVHRMB
Af8EAjAAMCAGA1UdJQQZMBcGCCsGAQUFBwMEBgsrBgEEAbIxAQMFAjBGBgNVHSAEPzA9MDsG
DCsGAQQBsjEBAgEBATArMCkGCCsGAQUFBwIBFh1odHRwczovL3NlY3VyZS5jb21vZG8ubmV0
L0NQUzCBsAYDVR0fBIGoMIGlMDigNqA0hjJodHRwOi8vY3JsLmNvbW9kby5uZXQvQ2xhc3Mz
U2VjdXJpdHlTZXJ2aWNlc18yLmNybDA6oDigNoY0aHR0cDovL2NybC5jb21vZG9jYS5jb20v
Q2xhc3MzU2VjdXJpdHlTZXJ2aWNlc18yLmNybDAtoCugKYEnQ2xhc3MzU2VjdXJpdHlTZXJ2
aWNlc18yQGNybC5jb21vZG8ubmV0MBEGCWCGSAGG+EIBAQQEAwIFIDAcBgNVHREEFTATgRFz
ZHVkbGV5QGlkaW9tLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEABpaUgBt9CDbD9niZ7EjC2ibV
UdgMr5zf4TfN1xz1QKN61/+61iNGhyeLlR6Hr/S2LrZCTFugsCFlSfTP1OEeJJ7Cc1H3PZqF
4gr0VBHrB0wAIQs7hcDXe44vLQaWa9H5ni2AZAhWv1rqIUe5mRj0P8yteAg28/IqIEiPLP0T
rAre10pN8xGHr054oSMwAFVtKN2gxRpc4Zx2UiWf4ZC+hEW/NI3DkjKEXEUQ1Xf5mat5TAOW
7TEE+l8uRbMWZnrbXblRFd6tdv3BzY3bQ03XEmZfn23mLHyE5YOZ7ebDKwgM0ItpIP6aGoKp
0fxantHktdj56wJOCfNxd3NSM54x7jGCBF4wggRaAgEBMIHyMIHcMQswCQYDVQQGEwJHQjEX
MBUGA1UEChMOQ29tb2RvIExpbWl0ZWQxHTAbBgNVBAsTFENvbW9kbyBUcnVzdCBOZXR3b3Jr
MUYwRAYDVQQLEz1UZXJtcyBhbmQgQ29uZGl0aW9ucyBvZiB1c2U6IGh0dHA6Ly93d3cuY29t
b2RvLm5ldC9yZXBvc2l0b3J5MR8wHQYDVQQLExYoYykyMDAyIENvbW9kbyBMaW1pdGVkMSww
KgYDVQQDEyNDb21vZG8gQ2xhc3MgMyBTZWN1cml0eSBTZXJ2aWNlcyBDQQIRAIKoea8JTb7v
wa4yHGSjzgQwCQYFKw4DAhoFAKCCAsEwGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkq
hkiG9w0BCQUxDxcNMDMwMjEyMDEzMTAxWjAjBgkqhkiG9w0BCQQxFgQUGU0CfZRc1F78c8vu
O6TJxnFEJ44wUgYJKoZIhvcNAQkPMUUwQzAKBggqhkiG9w0DBzAOBggqhkiG9w0DAgICAIAw
DQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYIKoZIhvcNAwICASgwggEDBgkrBgEEAYI3EAQx
gfUwgfIwgdwxCzAJBgNVBAYTAkdCMRcwFQYDVQQKEw5Db21vZG8gTGltaXRlZDEdMBsGA1UE
CxMUQ29tb2RvIFRydXN0IE5ldHdvcmsxRjBEBgNVBAsTPVRlcm1zIGFuZCBDb25kaXRpb25z
IG9mIHVzZTogaHR0cDovL3d3dy5jb21vZG8ubmV0L3JlcG9zaXRvcnkxHzAdBgNVBAsTFihj
KTIwMDIgQ29tb2RvIExpbWl0ZWQxLDAqBgNVBAMTI0NvbW9kbyBDbGFzcyAzIFNlY3VyaXR5
IFNlcnZpY2VzIENBAhEAgqh5rwlNvu/BrjIcZKPOBDCCAQUGCyqGSIb3DQEJEAILMYH1oIHy
MIHcMQswCQYDVQQGEwJHQjEXMBUGA1UEChMOQ29tb2RvIExpbWl0ZWQxHTAbBgNVBAsTFENv
bW9kbyBUcnVzdCBOZXR3b3JrMUYwRAYDVQQLEz1UZXJtcyBhbmQgQ29uZGl0aW9ucyBvZiB1
c2U6IGh0dHA6Ly93d3cuY29tb2RvLm5ldC9yZXBvc2l0b3J5MR8wHQYDVQQLExYoYykyMDAy
IENvbW9kbyBMaW1pdGVkMSwwKgYDVQQDEyNDb21vZG8gQ2xhc3MgMyBTZWN1cml0eSBTZXJ2
aWNlcyBDQQIRAIKoea8JTb7vwa4yHGSjzgQwDQYJKoZIhvcNAQEBBQAEgYAJA2vXBvQcmYe1
b17Nb9SjSmSnGNQ35W3F88Mg8SDQY0coMjSfLRV29jxl34bwhX4LxK/r/i+K3mtQ0ijTBabG
ncLTZD9b2NLpG8v0fVH8C4vWsVioKgpb1UZHmc8G2ZBva8706uZ8vkwiki/xASelNS4mZmnt
NHd0CauVQ/mUzgAAAAAAAA==
--------------ms050204080905050402000901--
----- scott-dudley.txt ends -----

View File

@ -1,16 +0,0 @@
# -*- makefile -*-
TOP=../..
TARGET=msgidlib
INCS=-I$(TOP)/goldlib/gall
include $(TOP)/GNUmakef.inc
include $(TOP)/GNUmakef.lib
ifeq ($(PLATFORM),lnx)
CFLAGS+=-DUNIX
endif
ifeq ($(PLATFORM),be)
CFLAGS+=-DUNIX=__BEOS__
endif

View File

@ -1,358 +0,0 @@
/* This is modifyed part of HUSKY project */
/*
* SMAPI; Modified Squish MSGAPI
*
* Squish MSGAPI0 is copyright 1991 by Scott J. Dudley. All rights reserved.
* Modifications released to the public domain.
*
* Use of this file is subject to the restrictions contain in the Squish
* MSGAPI0 licence agreement. Please refer to licence.txt for complete
* details of the licencing restrictions. If you do not find the text
* of this agreement in licence.txt, or if you do not have this file,
* you should contact Scott Dudley at FidoNet node 1:249/106 or Internet
* e-mail Scott.Dudley@f106.n249.z1.fidonet.org.
*
* In no event should you proceed to use any of the source files in this
* archive without having accepted the terms of the MSGAPI0 licensing
* agreement, or such other agreement as you are able to reach with the
* author.
*/
#if defined(UNIX) || defined(__MINGW32__) || defined(__EMX__) || defined(RSXNT) || defined(__DJGPP__) || defined(_MSC_VER)
/* These are compilers that have both a working stat() and (important!) the
S_ISREG and S_ISDIR macros. The problem is that while stat() is POSIX, those
macros are not. For compilers that do not provide these macros, we revert to
the old "ffind" method. */
#define USE_STAT_MACROS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(UNIX) || defined(__MINGW32__) || defined(__EMX__)
#include <unistd.h>
#endif
#ifdef USE_STAT_MACROS
#include <sys/types.h>
#include <sys/stat.h>
#else
#if !defined(__IBMC__) && !defined(MSDOS) && !defined(UNIX) && !defined(__MINGW32__) && !(defined(_MSC_VER) && (_MSC_VER >= 1200))
#include <dos.h>
#endif
#endif
#if defined(_MSC_VER)
#include <direct.h>
#include <sys/stat.h>
#endif
#include "hsksupp.h"
#include "ffind.h"
#ifdef USE_STAT_MACROS
/* This is the nice code that works on UNIX and every other decent platform.
It has been contributed by Alex S. Aganichev */
int fexist(const char *filename)
{
struct stat s;
if (stat (filename, &s))
return FALSE;
return S_ISREG(s.st_mode);
}
long fsize(const char *filename)
{
struct stat s;
if (stat (filename, &s))
return -1L;
return s.st_size;
}
int direxist(const char *directory)
{
struct stat s;
int rc;
#if !defined(__WATCOMC__) && !(defined(_MSC_VER) && (_MSC_VER >= 1200)) && !defined(__MINGW32__)
rc = stat (directory, &s);
#else
char *tempstr, *p;
size_t l;
tempstr = strdup(directory);
if (tempstr == NULL) {
return FALSE;
}
/* Root directory of any drive always exists! */
if ((isalpha((int)tempstr[0]) && tempstr[1] == ':' && (tempstr[2] == '\\' || tempstr[2] == '/') &&
!tempstr[3]) || eqstr(tempstr, "\\")) {
free(tempstr);
return TRUE;
}
l = strlen(tempstr);
if (tempstr[l - 1] == '\\' || tempstr[l - 1] == '/')
{
/* remove trailing backslash */
tempstr[l - 1] = '\0';
}
for (p=tempstr; *p; p++)
{
if (*p == '/')
*p='\\';
}
rc = stat (tempstr, &s);
free(tempstr);
#endif
if (rc)
return FALSE;
return S_ISDIR(s.st_mode);
}
#else
/* Here comes the ugly platform specific and sometimes even slow code. */
int fexist(const char *filename)
{
FFIND *ff;
ff = FFindOpen(filename, 0);
if (ff)
{
FFindClose(ff);
return TRUE;
}
else
{
return FALSE;
}
}
long fsize(const char *filename)
{
FFIND *ff;
FILE *fp;
long ret = -1L;
ff = FFindOpen(filename, 0);
if (ff)
{
#ifndef UNIX
ret = ff->ff_fsize;
if (ret != -1L) {
#endif
fp = fopen(filename, "rb");
fseek(fp, 0, SEEK_END);
ret = ftell(fp);
fclose(fp);
#ifndef UNIX
};
#endif
FFindClose(ff);
}
return ret;
}
#if defined(MSDOS) || defined(__DJGPP__) || (defined(__FLAT__) && defined(__WATCOMC__))
int direxist(const char *directory)
{
FFIND *ff;
char *tempstr;
int ret;
tempstr = (char *)malloc(strlen(directory) + 5);
if (tempstr == NULL)
{
return FALSE;
}
strcpy(tempstr, directory);
Add_Trailing(tempstr, '\\');
/* Root directory of any drive always exists! */
if ((isalpha(tempstr[0]) && tempstr[1] == ':' && ((tempstr[2] == '\0') || ((tempstr[2] == '\\' ||
tempstr[2] == '/') && tempstr[3] == '\0'))) || eqstri(tempstr, "\\"))
{
ret = TRUE;
}
else
{
Strip_Trailing(tempstr, '\\');
ff = FFindOpen(tempstr, MSDOS_SUBDIR | MSDOS_HIDDEN | MSDOS_READONLY);
ret = ff != NULL && (ff->ff_attrib & MSDOS_SUBDIR);
if (ff)
{
FFindClose(ff);
}
}
free(tempstr);
return ret;
}
#elif defined(OS2) || defined(__NT__) || defined(__MINGW32__)
#ifdef OS2
#define INCL_DOSFILEMGR
#include <os2.h>
#else
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#define NOUSER
#define NOMSG
/* mingw32 warnings */
#define NONAMELESSUNION
#include <windows.h>
#endif
int _fast direxist(const char *directory)
{
char *tempstr, *p;
size_t l;
#if defined(__NT__) || defined(__MINGW32__) || defined(__CYGWIN__)
DWORD attr;
#else
FILESTATUS3 s;
#endif
tempstr = strdup(directory);
if (tempstr == NULL)
{
return FALSE;
}
/* Root directory of any drive always exists! */
if ((isalpha((int)tempstr[0]) && tempstr[1] == ':' && (tempstr[2] == '\\' || tempstr[2] == '/') &&
!tempstr[3]) || eqstr(tempstr, "\\"))
{
free(tempstr);
return TRUE;
}
l = strlen(tempstr);
if (tempstr[l - 1] == '\\' || tempstr[l - 1] == '/')
{
/* remove trailing backslash */
tempstr[l - 1] = '\0';
}
for (p=tempstr; *p; p++)
{
if (*p == '/')
*p='\\';
}
#ifdef OS2
if (DosQueryPathInfo((PSZ)tempstr, FIL_STANDARD,
(PVOID)&s, sizeof(s)) == 0)
{
free (tempstr);
if (s.attrFile & FILE_DIRECTORY)
return TRUE;
else
return FALSE;
}
free (tempstr);
return FALSE;
#else
attr = GetFileAttributes(tempstr);
free(tempstr);
if ((attr != 0xFFFFFFFF) && (attr & FILE_ATTRIBUTE_DIRECTORY))
return TRUE;
else
return FALSE;
#endif
}
#elif defined(UNIX) || defined(SASC)
#include <stdio.h>
int _fast direxist(const char *directory)
{
FILE *fp;
fp = fopen(directory, "rb");
if (fp != NULL)
{
fclose(fp);
return 1;
}
return 0;
}
#else
#error Unknown compiler!
#endif
#endif
int _createDirectoryTree(const char *pathName) {
char *start, *slash;
char limiter=PATH_DELIM;
int i;
start = (char *) malloc(strlen(pathName)+2);
strcpy(start, pathName);
i = strlen(start)-1;
if (start[i] != limiter) {
start[i+1] = limiter;
start[i+2] = '\0';
}
slash = start;
#ifndef UNIX
/* if there is a drivename, jump over it */
if (slash[1] == ':') slash += 2;
#endif
/* jump over first limiter */
slash++;
while ((slash = strchr(slash, limiter)) != NULL) {
*slash = '\0';
if (!direxist(start)) {
if (!fexist(start)) {
/* this part of the path does not exist, create it */
if (mymkdir(start) != 0) {
free(start);
return 1;
}
} else {
free(start);
return 1;
}
}
*slash++ = limiter;
}
free(start);
return 0;
}

View File

@ -1,496 +0,0 @@
/* This is modifyed part of HUSKY project */
/*
* SMAPI; Modified Squish MSGAPI
*
* Squish MSGAPI0 is copyright 1991 by Scott J. Dudley. All rights reserved.
* Modifications released to the public domain.
*
* Use of this file is subject to the restrictions contain in the Squish
* MSGAPI0 licence agreement. Please refer to licence.txt for complete
* details of the licencing restrictions. If you do not find the text
* of this agreement in licence.txt, or if you do not have this file,
* you should contact Scott Dudley at FidoNet node 1:249/106 or Internet
* e-mail Scott.Dudley@f106.n249.z1.fidonet.org.
*
* In no event should you proceed to use any of the source files in this
* archive without having accepted the terms of the MSGAPI0 licensing
* agreement, or such other agreement as you are able to reach with the
* author.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hsksupp.h"
#if defined(__TURBOC__) || defined(__DJGPP__)
#include <dir.h>
#endif
#if !defined( __IBMC__) && !defined(UNIX) && !defined(__MINGW32__) && !(defined(_MSC_VER) && (_MSC_VER >= 1200))
#include <dos.h>
#endif
#include "ffind.h"
#ifdef OS2
#define INCL_NOPM
#define INCL_DOS
#include <os2.h>
#if defined(__386__) || defined(__FLAT__)
#undef DosQPathInfo
#define DosQPathInfo(a,b,c,d,e) DosQueryPathInfo(a,b,c,d)
#endif
#endif
/*#ifdef UNIX
#include "patmat.h"
#endif*/
/*
* FFindOpen; Use like MSDOS "find first" function, except be sure to
* release allocated system resources by caling FFindClose() with the
* handle returned by this function.
*
* Returns: NULL == File not found.
*/
FFIND *FFindOpen(const char *filespec, uint16_t attribute)
{
FFIND *ff;
ff = malloc(sizeof(FFIND));
if (ff != NULL)
{
#if defined(__TURBOC__) || defined(__DJGPP__)
if (findfirst(filespec, &(ff->ffbuf), attribute) != 0)
{
free(ff);
ff = NULL;
}
else
{
ff->ff_attrib = ff->ffbuf.ff_attrib;
ff->ff_ftime = ff->ffbuf.ff_ftime;
ff->ff_fdate = ff->ffbuf.ff_fdate;
ff->ff_fsize = ff->ffbuf.ff_fsize;
memcpy(ff->ff_name, ff->ffbuf.ff_name, sizeof(ff->ff_name));
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
}
#elif (defined(_MSC_VER) && (_MSC_VER < 1200)) || defined(__WATCOMC__)
if (_dos_findfirst(filespec, attribute, &(ff->ffbuf)) != 0)
{
free(ff);
ff = NULL;
}
else
{
ff->ff_attrib = ff->ffbuf.attrib;
ff->ff_ftime = ff->ffbuf.wr_time;
ff->ff_fdate = ff->ffbuf.wr_date;
ff->ff_fsize = ff->ffbuf.size;
memcpy(ff->ff_name, ff->ffbuf.name, sizeof(ff->ff_name));
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
}
#elif defined(OS2)
#if defined(__386__) || defined(__FLAT__)
ULONG SearchCount = 1;
FILEFINDBUF3 findbuf;
#else
USHORT SearchCount = 1;
FILEFINDBUF findbuf;
#endif
ff->hdir = HDIR_CREATE;
if (!DosFindFirst((PBYTE) filespec, &ff->hdir, attribute, &findbuf, sizeof(findbuf), &SearchCount, 1L))
{
ff->ff_attrib = (char)findbuf.attrFile;
ff->ff_fsize = findbuf.cbFile;
ff->ff_ftime = *((USHORT *) & findbuf.ftimeLastWrite);
ff->ff_fdate = *((USHORT *) & findbuf.fdateLastWrite);
strncpy(ff->ff_name, findbuf.achName, sizeof(ff->ff_name));
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
}
else
{
free(ff);
ff = NULL;
}
#elif defined(UNIX)
char *p;
int fin = 0;
struct dirent *de;
p = strrchr(filespec, '/');
if (p == NULL)
{
strcpy(ff->firstbit, ".");
strcpy(ff->lastbit, filespec);
}
else if (p == filespec)
{
strcpy(ff->firstbit, "/");
strcpy(ff->lastbit, filespec+1);
}
else
{
memcpy(ff->firstbit, filespec, p - filespec);
ff->firstbit[p - filespec] = '\0';
strcpy(ff->lastbit, p + 1);
}
ff->dir = opendir(ff->firstbit);
if (ff->dir != NULL)
{
while (!fin)
{
de = readdir(ff->dir);
if (de == NULL)
{
closedir(ff->dir);
free(ff);
ff = NULL;
fin = 1;
}
else
{
if (patmat(de->d_name, ff->lastbit))
{
strncpy(ff->ff_name, de->d_name, sizeof ff->ff_name);
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
ff->ff_fsize = -1L; /* All who wants to know it's size
* must read it by himself
*/
fin = 1;
}
}
}
}
else
{
free(ff);
ff = NULL;
}
#elif defined(SASC)
char *temp;
int error;
temp = strrchr(filespec, '/');
if (temp == NULL)
{
temp = strrchr(filespec, '\\');
}
if (temp == NULL)
{
temp = strrchr(filespec, ':');
}
if (temp == NULL)
{
strcpy(ff->prefix, "");
}
else
{
memcpy(ff->prefix, filespec, temp - filespec + 1);
*(ff->prefix + (temp - filespec + 1)) = '\0';
}
error = dfind(&ff->info, filespec, 0);
if (error == 0)
{
strcpy(ff->ff_name, ff->prefix);
strcat(ff->ff_name, ff->info.fib_FileName);
}
else
{
free(ff);
ff = NULL;
}
#elif defined(__RSXNT__) || defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1200))
ff->hDirA = FindFirstFile(filespec, &(ff->InfoBuf));
ff->attrib_srch = (char)attribute;
while (ff->hDirA != INVALID_HANDLE_VALUE)
{
if (strlen(ff->InfoBuf.cFileName) < sizeof(ff->ff_name))
{
if ((!(ff->InfoBuf.dwFileAttributes &
FILE_ATTRIBUTE_DIRECTORY)) ||
(ff->attrib_srch & MSDOS_SUBDIR))
{
break;
}
}
/* skip file for some reason */
if (!FindNextFile(ff->hDirA, &(ff->InfoBuf)))
{
if (ff->hDirA != INVALID_HANDLE_VALUE)
{
FindClose(ff->hDirA);
}
ff->hDirA = INVALID_HANDLE_VALUE;
}
}
if (ff->hDirA != INVALID_HANDLE_VALUE)
{
strcpy(ff->ff_name, ff->InfoBuf.cFileName);
ff->ff_fsize = ff->InfoBuf.nFileSizeLow;
ff->ff_attrib = 0;
if (ff->InfoBuf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
ff->ff_attrib |= MSDOS_SUBDIR;
}
}
else
{
free(ff);
ff = NULL;
}
#else
#error Unknown compiler!
#endif
}
return ff;
}
/*
* FFindNext: Returns 0 if next file was found, non-zero if it was not.
*/
int FFindNext(FFIND * ff)
{
int rc = -1;
if (ff != NULL)
{
#if defined(__TURBOC__) || defined(__DJGPP__)
rc = findnext(&(ff->ffbuf));
ff->ff_attrib = ff->ffbuf.ff_attrib;
ff->ff_ftime = ff->ffbuf.ff_ftime;
ff->ff_fdate = ff->ffbuf.ff_fdate;
ff->ff_fsize = ff->ffbuf.ff_fsize;
memcpy(ff->ff_name, ff->ffbuf.ff_name, sizeof(ff->ff_name));
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
#elif (defined(_MSC_VER) && (_MSC_VER < 1200)) || defined(__WATCOMC__)
rc = _dos_findnext(&(ff->ffbuf));
ff->ff_attrib = ff->ffbuf.attrib;
ff->ff_ftime = ff->ffbuf.wr_time;
ff->ff_fdate = ff->ffbuf.wr_date;
ff->ff_fsize = ff->ffbuf.size;
memcpy(ff->ff_name, ff->ffbuf.name, sizeof(ff->ff_name));
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
#elif defined(OS2)
#if defined(__386__) || defined(__FLAT__)
ULONG SearchCount = 1;
FILEFINDBUF3 findbuf;
#else
USHORT SearchCount = 1;
FILEFINDBUF findbuf;
#endif
if (ff->hdir && !DosFindNext(ff->hdir, &findbuf, sizeof(findbuf),
&SearchCount))
{
ff->ff_attrib = (char)findbuf.attrFile;
ff->ff_ftime = *((USHORT *) & findbuf.ftimeLastWrite);
ff->ff_fdate = *((USHORT *) & findbuf.fdateLastWrite);
ff->ff_fsize = findbuf.cbFile;
strncpy(ff->ff_name, findbuf.achName, sizeof(ff->ff_name));
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
rc = 0;
}
#elif defined(UNIX)
int fin = 0;
struct dirent *de;
while (!fin)
{
de = readdir(ff->dir);
if (de == NULL)
{
closedir(ff->dir);
ff->dir = NULL;
fin = 1;
}
else
{
if (patmat(de->d_name, ff->lastbit))
{
strncpy(ff->ff_name, de->d_name, sizeof ff->ff_name);
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
ff->ff_fsize = -1L; /* All who wants to know it's size
* must read it by himself
*/
fin = 1;
rc = 0;
}
}
}
#elif defined(SASC)
int error = 0;
error = dnext(&ff->info);
if (error == 0)
{
strcpy(ff->ff_name, ff->prefix);
strcat(ff->ff_name, ff->info.fib_FileName);
rc = 0;
}
#elif defined(__RSXNT__) || defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1200))
do
{
if (!FindNextFile(ff->hDirA, &(ff->InfoBuf)))
{
if (ff->hDirA != INVALID_HANDLE_VALUE)
{
FindClose(ff->hDirA);
}
ff->hDirA = INVALID_HANDLE_VALUE;
}
else
{
if (strlen(ff->InfoBuf.cFileName) < sizeof(ff->ff_name))
{
if ((!(ff->InfoBuf.dwFileAttributes &
FILE_ATTRIBUTE_DIRECTORY)) ||
(ff->attrib_srch & MSDOS_SUBDIR))
{
break;
}
}
}
} while (ff->hDirA != INVALID_HANDLE_VALUE);
if (ff->hDirA != INVALID_HANDLE_VALUE)
{
strcpy(ff->ff_name, ff->InfoBuf.cFileName);
ff->ff_fsize = ff->InfoBuf.nFileSizeLow;
ff->ff_attrib = 0;
if (ff->InfoBuf.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
ff->ff_attrib |= MSDOS_SUBDIR;
}
rc = 0;
}
#else
#error Unable to determine compiler and target operating system!
#endif
}
return rc;
}
/*
* FFindClose: End a directory search. Failure to call this function
* will result in unclosed file handles under OS/2, and unreleased
* memory in both DOS and OS/2.
*/
void FFindClose(FFIND * ff)
{
if (ff != NULL)
{
#if defined(__TURBOC__) || defined(__DJGPP__)
#elif (defined(__WATCOMC__) && defined (__NT__)) || (defined(_MSC_VER) && (_MSC_VER < 1200) && !defined(MSDOS))
_dos_findclose(&(ff->ffbuf));
#elif defined(OS2)
if (ff->hdir)
{
DosFindClose(ff->hdir);
}
#elif defined(UNIX)
if (ff->dir)
{
closedir(ff->dir);
}
#elif defined(SASC)
#elif defined(__RSXNT__) || defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1200))
if (ff->hDirA != INVALID_HANDLE_VALUE)
{
FindClose(ff->hDirA);
}
#endif
free(ff);
}
}
/*
* FindInfo: This function was added because it is SIGNIFICANTLY faster
* under OS/2 to call DosQPathInfo() rather than DosFindFirst() if all
* you are interested in is getting a specific file's date/time/size.
*
* PLF Thu 10-17-1991 18:12:37
*/
FFIND *FindInfo(const char *filespec)
{
#if !defined(OS2) && !defined(__OS2__)
return FFindOpen(filespec, 0);
#else
FFIND *ff;
FILESTATUS fs;
const char *f;
ff = malloc(sizeof *ff);
if (ff == NULL)
{
return NULL;
}
memset(ff, 0, sizeof *ff);
if (!DosQPathInfo((PBYTE) filespec, FIL_STANDARD, (PBYTE) &fs, sizeof fs, 0L))
{
ff->ff_attrib = (char)fs.attrFile;
ff->ff_ftime = *((USHORT *) & fs.ftimeLastWrite);
ff->ff_fdate = *((USHORT *) & fs.fdateLastWrite);
ff->ff_fsize = fs.cbFile;
/* isolate file name */
f = strrchr(filespec, '\\');
if (f == NULL)
{
f = filespec;
}
else
{
f++;
}
strncpy(ff->ff_name, f, sizeof(ff->ff_name));
ff->ff_name[sizeof(ff->ff_name) - 1] = '\0';
}
else
{
free(ff);
return NULL;
}
return ff;
#endif
}

View File

@ -1,145 +0,0 @@
/* This is modifyed part of HUSKY project */
/*
* SMAPI; Modified Squish MSGAPI
*
* Squish MSGAPI0 is copyright 1991 by Scott J. Dudley. All rights reserved.
* Modifications released to the public domain.
*
* Use of this file is subject to the restrictions contain in the Squish
* MSGAPI0 licence agreement. Please refer to licence.txt for complete
* details of the licencing restrictions. If you do not find the text
* of this agreement in licence.txt, or if you do not have this file,
* you should contact Scott Dudley at FidoNet node 1:249/106 or Internet
* e-mail Scott.Dudley@f106.n249.z1.fidonet.org.
*
* In no event should you proceed to use any of the source files in this
* archive without having accepted the terms of the MSGAPI0 licensing
* agreement, or such other agreement as you are able to reach with the
* author.
*/
#ifndef __FFIND_H__
#define __FFIND_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "hsksupp.h"
#ifdef UNIX
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
#endif
#ifdef SASC
#include <stdio.h>
#include <dos.h>
#endif
#if defined(__RSXNT__) || defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1200))
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#define NOUSER
#define NOMSG
#ifdef __RSXNT__
/* The RSXNT winsock.h conflicts with EMX
io.h. As we do not need sockets anyway, we
just prevent their inclusion. */
#define _WINSOCK_H
#endif
#if defined(__MINGW32__)
/* For HTick compatibility */
#define _WINUSER_H
/* mingw32 warnings */
#define NONAMELESSUNION
#endif
#include <windows.h>
#endif
#define FFIND struct ffind
#if defined(__DJGPP__) || defined(__TURBOC__)
#include <dir.h>
#endif
#if defined(__WATCOMC__) || defined(_MSC_VER)
#include <dos.h>
#endif
struct ffind
{
/* this is the public area of the struct */
char ff_attrib;
uint16_t ff_ftime;
uint16_t ff_fdate;
long ff_fsize;
char ff_name[256];
/* now comes the privat area where search handles or similiar are stored */
#if defined(__TURBOC__) || defined(__DJGPP__)
struct ffblk ffbuf;
#elif defined(__WATCOMC__) || (defined(_MSC_VER) && (_MSC_VER < 1200))
struct find_t ffbuf;
unsigned long hdir; /* directory handle from DosFindFirst */
#elif defined(OS2)
#if defined(__386__) || defined(__FLAT__)
unsigned long hdir; /* directory handle from DosFindFirst */
#else
uint16_t hdir; /* directory handle from DosFindFirst */
#endif
#elif defined(UNIX)
DIR *dir;
char firstbit[FILENAME_MAX];
char lastbit[FILENAME_MAX];
#elif defined(SASC)
struct FileInfoBlock info;
char newfile[FILENAME_MAX];
char prefix[FILENAME_MAX];
#elif defined(__RSXNT__) || defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1200))
WIN32_FIND_DATA InfoBuf;
HANDLE hDirA;
char attrib_srch;
#else
#error Unknown compiler!
#endif
};
/*
* I prefixed the functions below with an additional F in order to
* prevent name clashes with the Win32 API
*/
FFIND *FFindOpen(const char *filespec, uint16_t attribute);
FFIND *FFindInfo(const char *filespec);
int FFindNext(FFIND * ff);
void FFindClose(FFIND * ff);
#define MSDOS_READONLY 0x01
#define MSDOS_HIDDEN 0x02
#define MSDOS_SYSTEM 0x04
#define MSDOS_VOLUME 0x08
#define MSDOS_SUBDIR 0x10
#define MSDOS_ARCHIVE 0x20
#define MSDOS_RSVD1 0x40
#define MSDOS_RSVD2 0x80
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,185 +0,0 @@
/* This is modifyed part of HUSKY project */
/*
* HUSKYLIB: common defines, types and functions for HUSKY
*
* This is part of The HUSKY Fidonet Software project:
* see http://husky.sourceforge.net for details
*
*
* HUSKYLIB is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* HUSKYLIB 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 Lesser General Public
* License along with this library; see file COPYING. If not, write to the
* Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* See also http://www.gnu.org, license may be found here.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#if !defined(UNIX) && !defined(SASC)
# include <io.h>
#endif
#if defined(UNIX) || defined(__DJGPP__) || defined(__EMX__)
# include <unistd.h>
#endif
#if defined(UNIX)
#define stricmp strcasecmp
#endif
#include "hsksupp.h"
#include "ffind.h"
#define MAX_OUTRUN (3ul*365*24*60*60) /* 3 year */
#define GenMsgIdErr(a) { if (errstr!=NULL) { *errstr = a; } }
dword oldGenMsgId(void)
{
dword seq = (dword)time(NULL);
sleep(1);
return seq;
}
dword GenMsgIdEx(char *seqdir, unsigned long max_outrun, dword (*altGenMsgId)(void), char **errstr)
{
dword seq, n, curtime;
FFIND *ff;
char *seqpath, max_fname[13], *new_fname, *pname, *p;
int h, try;
if (altGenMsgId == NULL)
altGenMsgId = oldGenMsgId;
GenMsgIdErr(NULL);
if (seqdir == NULL || *seqdir == '\0') {
seqdir = getenv("SEQDIR");
if (seqdir == NULL || *seqdir == '\0') {
/* warning: no SEQDIR defined, fall to ugly old algorythm */
GenMsgIdErr("no SEQDIR defined");
return (*altGenMsgId)();
}
}
seqpath = malloc(strlen(seqdir)+13);
strcpy(seqpath, seqdir);
pname = seqpath + strlen(seqpath);
if (*seqpath && strchr("/\\", seqpath[strlen(seqpath)-1]) == NULL)
*pname++ = PATH_DELIM;
new_fname = NULL;
if (max_outrun == 0) {
p = getenv("SEQOUT");
if ( p && isdigit((int)(*p)) ) {
max_outrun = (unsigned long)atol(p);
switch (tolower(p[strlen(p) - 1])) {
case 'y': max_outrun *= 365;
case 'd': max_outrun *= 24;
case 'h': max_outrun *= 60*60;
break;
case 'w': max_outrun *= (7l*24*60*60);
break;
case 'm': max_outrun *= (31l*24*60*60);
break;
}
}
else max_outrun = MAX_OUTRUN;
}
for (try=0;;try++) {
curtime = (dword)time(NULL);
seq = 0;
max_fname[0] = '\0';
strcpy(pname, "*.*");
ff = FFindOpen(seqpath, 0);
if (ff == NULL) { /* file not found */
*pname = '\0';
if (try == 0) {
if (direxist(seqpath))
goto emptydir; /* directory exist & empty */
else if (_createDirectoryTree(seqpath) == 0)
goto emptydir; /* directory created */
} /* if directory not created at 1st time then use old alghorithm */
free(seqpath);
if (new_fname) free(new_fname);
GenMsgIdErr("can't open/create SEQDIR directory");
return (*altGenMsgId)();
}
do {
for (p=ff->ff_name; isxdigit((int)(*p)); p++);
if (stricmp(p, ".seq") != 0) continue;
if (strlen(ff->ff_name) > 12) continue;
n = strtol(ff->ff_name, NULL, 16);
if (n > curtime && n - curtime > max_outrun) {
/* counter too large, remove */
strcpy(pname, ff->ff_name);
unlink(seqpath);
continue;
}
if (n >= seq) {
if (max_fname[0]) {
strcpy(pname, max_fname);
unlink(seqpath);
}
strcpy(max_fname, ff->ff_name);
seq = n;
} else {
strcpy(pname, ff->ff_name);
unlink(seqpath);
}
} while (FFindNext(ff) == 0);
if (ff) FFindClose(ff);
emptydir:
if (seq < curtime) seq = curtime;
if (new_fname == NULL)
new_fname = malloc(strlen(seqpath) + 13);
*pname = '\0';
sprintf(new_fname, "%s%08lx.seq", seqpath, (unsigned long)(seq + 1));
if (max_fname[0] == '\0') {
/* No files found, create new */
h = open(new_fname, O_CREAT|O_BINARY|O_EXCL, 0666);
if (h != -1) {
/* ok, scan again */
close(h);
continue;
}
/* error creating file */
if (errno == EEXIST) continue;
free(seqpath);
free(new_fname);
GenMsgIdErr("error creating file in SEQDIR directory");
return (*altGenMsgId)();
}
/* rename max_fname to new_fname */
strcpy(pname, max_fname);
if (rename(seqpath, new_fname) == 0) {
free(seqpath);
free(new_fname);
return seq;
}
if (errno == ENOENT || errno == EEXIST ||
((errno == EPERM || errno == EACCES) && try < 16))
continue;
free(seqpath);
free(new_fname);
GenMsgIdErr("can't rename .seq file");
return (*altGenMsgId)();
}
}
dword GenMsgId(char *seqdir, unsigned long max_outrun)
{
return GenMsgIdEx(seqdir, max_outrun, NULL, NULL);
}

View File

@ -1,16 +0,0 @@
#ifndef __GENMSGID_H_
#define __GENMSGID_H_
#ifdef __cplusplus
extern "C" {
#endif
uint32_t GenMsgId(char *seqdir, uint32_t max_outrun);
uint32_t GenMsgIdEx(char *seqdir, uint32_t max_outrun, uint32_t (*altGenMsgId)(void), char **errstr);
uint32_t oldGenMsgId(void);
#ifdef __cplusplus
}
#endif
#endif /* __GENMSGID_H_ */

View File

@ -1,71 +0,0 @@
#ifndef __HSKSUPP_H_
#define __HSKSUPP_H_
#include <stdlib.h>
#include <time.h>
#include "typedefs.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#if defined(__EMX__)
#if !defined(OS2)
#define OS2 1
#endif
#if !defined(__FLAT__)
#define __FLAT__ 1
#endif
#endif
#if defined(__MINGW32__)
/* mingw32 warnings */
#define NONAMELESSUNION
#define sleep(sec) _sleep((sec)*1000l)
#endif
#if defined(SASC) || defined(UNIX)
#define PATH_DELIM '/'
#else
#define PATH_DELIM '\\'
#endif
#define eqstr(str1,str2) (strcmp(str1,str2)==0)
#if !defined(__GNUC__) || defined(__MINGW32__)
#define mymkdir(path) mkdir(path)
#else
#define mymkdir(path) mkdir(path, 0)
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
#if defined(_MSC_VER)
# define sleep(x) Sleep(1000L*(x))
#endif
# ifndef S_ISDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
# endif
# ifndef S_ISREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
# endif
/* fexists.c */
int fexist(const char *filename);
long fsize(const char *filename);
int direxist(const char *directory);
int _createDirectoryTree(const char *pathName);
/* patmat.c */
#ifdef UNIX
int patmat(char *raw, char *pat);
#endif
#endif /* __HSKSUPP_H_ */

View File

@ -1,7 +0,0 @@
## ------------------------------------------------------------------
## Master build file.
## ------------------------------------------------------------------
genmsgid c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg be sun
ffind c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg be sun
fexist c all ovl bcd bco bcx wcn wco wcx lnx emx djg rsx cyg be sun
patmat c all lnx be sun

View File

@ -1,63 +0,0 @@
/*
* PATMAT.C - Pattern matching. Taken from sh sources
*/
/*
* Written by Alexander S. Aganichev.
*
* Released to public domain.
*/
/*
* Returns true if the pattern matches the string.
*/
int patmat (char *tag, char *mask)
{
if (tag && mask) {
while (*tag && *mask)
if ((*tag == *mask) || (*mask == '?')) {
++ tag;
++ mask;
} else if (*mask == '*') {
while ((*mask == '*') || (*mask == '?')) {
if (*mask == '?') {
if (*tag)
++ tag;
else
return 0;
}
++ mask;
}
if (*mask) {
while (*tag && !patmat (tag, mask))
++ tag;
if (*tag)
return 1;
} else
return 1;
} else
return 0;
while (*mask == '*')
++ mask;
if (*mask)
return 0;
return (*tag) ? 0 : 1;
}
return 0;
}
#ifdef TEST
#include <stdio.h>
int main(void)
{
printf("patmat(\"abcdefghi\", \"*ghi\"): %d\n", patmat("abcdefghi", "*ghi"));
printf("patmat(\"abcdefghi\", \"??c??f*\"): %d\n", patmat("abcdefghi", "??c??f*"));
printf("patmat(\"abcdefghi\", \"*dh*\"): %d\n", patmat("abcdefghi", "*dh*"));
printf("patmat(\"abcdefghi\", \"*def\"): %d\n", patmat("abcdefghi", "*def"));
return 0;
}
#endif

View File

@ -1,9 +0,0 @@
/* Completely rewritten */
#ifndef __TYPEDEFS_H__
#define __TYPEDEFS_H__
#include <gdefs.h>
#include <gctype.h>
#endif /*#ifndef __TYPEDEFS_H__*/

View File

@ -1,12 +0,0 @@
#ifndef __filewrap_h
#define __filewrap_h
#if defined(_MSC_VER)
#include <io.h>
#else
#include <gfilutil.h>
#endif
#define sopen(fn,access,share) (sopen)((fn),(access),(share),S_IREAD|S_IWRITE)
#endif // __filewrap_h

View File

@ -1,28 +0,0 @@
#ifndef __genwrap_h
#define __genwrap_h
#if defined(_MSC_VER)
#include <windows.h>
#include <share.h>
#include <io.h>
#else
#include <gtimall.h>
#endif
#ifndef __BEOS__
#if defined(_MSC_VER)
#define SLEEP(a) Sleep(a)
#else
#define SLEEP(a) usleep(a)
#endif
#else
#include <OS.h>
#define SLEEP(a) snooze(a)
#endif
#if defined(_MSC_VER)
int lock(int handle, long offset, long length);
int unlock(int handle, long offset, long length);
#endif
#endif // __genwrap_h

View File

@ -1,813 +0,0 @@
/* lzh.c */
/* Synchronet LZH compression library */
/* $Id$ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Rob Swindell's conversion of 1988 LZH (LHarc) encoding functions *
* Based on Japanese version 29-NOV-1988 *
* LZSS coded by Haruhiko Okumura *
* Adaptive Huffman Coding coded by Haruyasu Yoshizaki *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* FreeBSD's malloc.h is deprecated, it drops a warning and */
/* #includes <stdlib.h>, which is already here. */
#if !defined(__FreeBSD__) && !defined(__APPLE__)
#include <malloc.h>
#endif
#include "lzh.h"
/****************************************************************************/
/* Memory allocation macros for various compilers and environments */
/* MALLOC is used for allocations of 64k or less */
/* FREE is used to free buffers allocated with MALLOC */
/* LMALLOC is used for allocations of possibly larger than 64k */
/* LFREE is used to free buffers allocated with LMALLOC */
/* REALLOC is used to re-size a previously MALLOCed or LMALLOCed buffer */
/****************************************************************************/
#if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
#if defined(__TURBOC__)
#define REALLOC(x,y) farrealloc(x,y)
#define LMALLOC(x) farmalloc(x)
#define MALLOC(x) farmalloc(x)
#define LFREE(x) farfree(x)
#define FREE(x) farfree(x)
#elif defined(__WATCOMC__)
#define REALLOC realloc
#define LMALLOC(x) halloc(x,1) /* far heap, but slow */
#define MALLOC malloc /* far heap, but 64k max */
#define LFREE hfree
#define FREE free
#else /* Other 16-bit Compiler */
#define REALLOC realloc
#define LMALLOC malloc
#define MALLOC malloc
#define LFREE free
#define FREE free
#endif
#else /* 32-bit Compiler or Small Memory Model */
#define REALLOC realloc
#define LMALLOC malloc
#define MALLOC malloc
#define LFREE free
#define FREE free
#endif
/* LZSS Parameters */
#define LZH_N 4096 /* Size of string buffer */
#define LZH_F 60 /* Size of look-ahead buffer */
#define LZH_THRESHOLD 2
#define LZH_NIL LZH_N /* End of tree's node */
#ifdef LZH_DYNAMIC_BUF
uint8_t *lzh_text_buf;
int16_t lzh_match_position, lzh_match_length,
*lzh_lson, *lzh_rson, *lzh_dad;
#else
uint8_t lzh_text_buf[LZH_N + LZH_F - 1];
int16_t lzh_match_position, lzh_match_length,
lzh_lson[LZH_N + 1], lzh_rson[LZH_N + 257], lzh_dad[LZH_N + 1];
#endif
void lzh_init_tree(void) /* Initializing tree */
{
int16_t i;
for (i = LZH_N + 1; i <= LZH_N + 256; i++)
lzh_rson[i] = LZH_NIL; /* root */
for (i = 0; i < LZH_N; i++)
lzh_dad[i] = LZH_NIL; /* node */
}
/******************************/
/* Inserting node to the tree */
/* Only used during encoding */
/******************************/
void lzh_insert_node(int16_t r)
{
int16_t i, p, cmp;
uint8_t *key;
uint32_t c;
cmp = 1;
key = lzh_text_buf+r;
p = LZH_N + 1 + key[0];
lzh_rson[r] = lzh_lson[r] = LZH_NIL;
lzh_match_length = 0;
for ( ; ; ) {
if (cmp >= 0) {
if (lzh_rson[p] != LZH_NIL)
p = lzh_rson[p];
else {
lzh_rson[p] = r;
lzh_dad[r] = p;
return;
}
} else {
if (lzh_lson[p] != LZH_NIL)
p = lzh_lson[p];
else {
lzh_lson[p] = r;
lzh_dad[r] = p;
return;
}
}
for (i = 1; i < LZH_F; i++)
if ((cmp = key[i] - lzh_text_buf[p + i]) != 0)
break;
if (i > LZH_THRESHOLD) {
if (i > lzh_match_length) {
lzh_match_position = ((r - p) & (LZH_N - 1)) - 1;
if ((lzh_match_length = i) >= LZH_F)
break;
}
if (i == lzh_match_length) {
if ((c = ((r - p) & (LZH_N - 1)) - 1)
< (uint32_t)lzh_match_position) {
lzh_match_position = c;
}
}
}
}
lzh_dad[r] = lzh_dad[p];
lzh_lson[r] = lzh_lson[p];
lzh_rson[r] = lzh_rson[p];
lzh_dad[lzh_lson[p]] = r;
lzh_dad[lzh_rson[p]] = r;
if (lzh_rson[lzh_dad[p]] == p)
lzh_rson[lzh_dad[p]] = r;
else
lzh_lson[lzh_dad[p]] = r;
lzh_dad[p] = LZH_NIL; /* remove p */
}
void lzh_delete_node(int16_t p) /* Deleting node from the tree */
{
int16_t q;
if (lzh_dad[p] == LZH_NIL)
return; /* unregistered */
if (lzh_rson[p] == LZH_NIL)
q = lzh_lson[p];
else
if (lzh_lson[p] == LZH_NIL)
q = lzh_rson[p];
else {
q = lzh_lson[p];
if (lzh_rson[q] != LZH_NIL) {
do {
q = lzh_rson[q];
} while (lzh_rson[q] != LZH_NIL);
lzh_rson[lzh_dad[q]] = lzh_lson[q];
lzh_dad[lzh_lson[q]] = lzh_dad[q];
lzh_lson[q] = lzh_lson[p];
lzh_dad[lzh_lson[p]] = q;
}
lzh_rson[q] = lzh_rson[p];
lzh_dad[lzh_rson[p]] = q;
}
lzh_dad[q] = lzh_dad[p];
if (lzh_rson[lzh_dad[p]] == p)
lzh_rson[lzh_dad[p]] = q;
else
lzh_lson[lzh_dad[p]] = q;
lzh_dad[p] = LZH_NIL;
}
/* Huffman coding parameters */
#define LZH_N_CHAR (256 - LZH_THRESHOLD + LZH_F)
/* character code (= 0..LZH_N_CHAR-1) */
#define LZH_T (LZH_N_CHAR * 2 - 1) /* Size of table */
#define LZH_R (LZH_T - 1) /* root position */
#define MAX_FREQ 0x8000
/* update when cumulative frequency */
/* reaches to this value */
/*
* Tables for encoding/decoding upper 6 bits of
* sliding dictionary pointer
*/
/* encoder table */
uint8_t lzh_p_len[64] = {
0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08
};
uint8_t lzh_p_code[64] = {
0x00, 0x20, 0x30, 0x40, 0x50, 0x58, 0x60, 0x68,
0x70, 0x78, 0x80, 0x88, 0x90, 0x94, 0x98, 0x9C,
0xA0, 0xA4, 0xA8, 0xAC, 0xB0, 0xB4, 0xB8, 0xBC,
0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0xCE,
0xD0, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA, 0xDC, 0xDE,
0xE0, 0xE2, 0xE4, 0xE6, 0xE8, 0xEA, 0xEC, 0xEE,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
};
/* decoder table */
uint8_t lzh_d_code[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D,
0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F,
0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11,
0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13,
0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15,
0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17,
0x18, 0x18, 0x19, 0x19, 0x1A, 0x1A, 0x1B, 0x1B,
0x1C, 0x1C, 0x1D, 0x1D, 0x1E, 0x1E, 0x1F, 0x1F,
0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23,
0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27,
0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B,
0x2C, 0x2C, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
};
uint8_t lzh_d_len[256] = {
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
};
#ifdef LZH_DYNAMIC_BUF
uint16_t *lzh_freq = NULL; /* cumulative freq table */
/*
* pointing parent nodes.
* area [LZH_T..(LZH_T + LZH_N_CHAR - 1)] are pointers for leaves
*/
int16_t *lzh_prnt = NULL;
/* pointing children nodes (son[], son[] + 1)*/
int16_t *lzh_son = NULL;
#else /* STATIC */
uint16_t lzh_freq[LZH_T + 1]; /* cumulative freq table */
int16_t lzh_prnt[LZH_T + LZH_N_CHAR];
int16_t lzh_son[LZH_T + 1]; /* bug fixed by Digital Dynamics */
#endif
uint16_t lzh_getbuf = 0; /* Was just "unsigned" fixed 04/12/95 */
uint8_t lzh_getlen = 0;
int lzh_getbit(uint8_t *inbuf, int32_t *incnt, int32_t inlen) /* get one bit */
{
int16_t i;
while (lzh_getlen <= 8) {
if((*incnt)>=inlen)
i=0;
else
i=inbuf[(*incnt)++];
lzh_getbuf |= i << (8 - lzh_getlen);
lzh_getlen += 8;
}
i = lzh_getbuf;
lzh_getbuf <<= 1;
lzh_getlen--;
return (i < 0);
}
int16_t lzh_getbyte(uint8_t *inbuf, int32_t *incnt, int32_t inlen) /* get a byte */
{
uint16_t i;
while (lzh_getlen <= 8) {
if((*incnt)>=inlen)
i=0;
else
i=inbuf[(*incnt)++];
lzh_getbuf |= i << (8 - lzh_getlen);
lzh_getlen += 8;
}
i = lzh_getbuf;
lzh_getbuf <<= 8;
lzh_getlen -= 8;
return i >> 8;
}
uint32_t lzh_putbuf = 0;
uint8_t lzh_putlen = 0;
/* output c bits */
void lzh_putcode(int16_t l, uint16_t c, uint8_t *outbuf, int32_t *outlen)
{
lzh_putbuf |= c >> lzh_putlen;
if ((lzh_putlen += l) >= 8) {
outbuf[(*outlen)++]=(lzh_putbuf >> 8);
if ((lzh_putlen -= 8) >= 8) {
outbuf[(*outlen)++]=lzh_putbuf;
lzh_putlen -= 8;
lzh_putbuf = c << (l - lzh_putlen);
} else {
lzh_putbuf <<= 8;
}
}
}
/* initialize freq tree */
void lzh_start_huff(void)
{
int16_t i, j;
lzh_getbuf = 0; /* Added by Digital Dynamics for repeating operations */
lzh_getlen = 0;
lzh_putbuf = 0;
lzh_putlen = 0;
for (i = 0; i < LZH_N_CHAR; i++) {
lzh_freq[i] = 1;
lzh_son[i] = i + LZH_T;
lzh_prnt[i + LZH_T] = i;
}
i = 0; j = LZH_N_CHAR;
while (j <= LZH_R) {
lzh_freq[j] = lzh_freq[i] + lzh_freq[i + 1];
lzh_son[j] = i;
lzh_prnt[i] = lzh_prnt[i + 1] = j;
i += 2; j++;
}
lzh_freq[LZH_T] = 0xffff;
lzh_prnt[LZH_R] = 0;
}
/* reconstruct freq tree */
void lzh_reconst(void)
{
int16_t i, j, k;
uint16_t f, l;
/* halven cumulative freq for leaf nodes */
j = 0;
for (i = 0; i < LZH_T; i++) {
if (lzh_son[i] >= LZH_T) {
lzh_freq[j] = (lzh_freq[i] + 1) / 2;
lzh_son[j] = lzh_son[i];
j++;
}
}
/* make a tree : first, connect children nodes */
for (i = 0, j = LZH_N_CHAR; j < LZH_T; i += 2, j++) {
k = i + 1;
f = lzh_freq[j] = lzh_freq[i] + lzh_freq[k];
for (k = j - 1; f < lzh_freq[k]; k--);
k++;
l = (j - k) * 2;
/* movmem() is Turbo-C dependent
rewritten to memmove() by Kenji */
/* movmem(&lzh_freq[k], &lzh_freq[k + 1], l); */
(void)memmove(lzh_freq+k+1,lzh_freq+k, l);
lzh_freq[k] = f;
/* movmem(&lzh_son[k], &lzh_son[k + 1], l); */
(void)memmove(lzh_son+k+1,lzh_son+k, l);
lzh_son[k] = i;
}
/* connect parent nodes */
for (i = 0; i < LZH_T; i++) {
if ((k = lzh_son[i]) >= LZH_T) {
lzh_prnt[k] = i;
} else {
lzh_prnt[k] = lzh_prnt[k + 1] = i;
}
}
}
/* update freq tree */
void lzh_update(int16_t c)
{
int16_t i, j, k, l;
if (lzh_freq[LZH_R] == MAX_FREQ) {
lzh_reconst();
}
c = lzh_prnt[c + LZH_T];
do {
k = ++lzh_freq[c];
/* swap nodes to keep the tree freq-ordered */
if (k > lzh_freq[l = c + 1]) {
while (k > lzh_freq[++l]);
l--;
lzh_freq[c] = lzh_freq[l];
lzh_freq[l] = k;
i = lzh_son[c];
lzh_prnt[i] = l;
if (i < LZH_T) lzh_prnt[i + 1] = l;
j = lzh_son[l];
lzh_son[l] = i;
lzh_prnt[j] = c;
if (j < LZH_T) lzh_prnt[j + 1] = c;
lzh_son[c] = j;
c = l;
}
} while ((c = lzh_prnt[c]) != 0); /* do it until reaching the root */
}
uint16_t lzh_code, lzh_len;
void lzh_encode_char(uint16_t c, uint8_t *outbuf, int32_t *outlen)
{
uint16_t i;
int16_t j, k;
i = 0;
j = 0;
k = lzh_prnt[c + LZH_T];
/* search connections from leaf node to the root */
do {
i >>= 1;
/*
if node's address is odd, output 1
else output 0
*/
if (k & 1) i += 0x8000;
j++;
} while ((k = lzh_prnt[k]) != LZH_R);
lzh_putcode(j, i, outbuf, outlen);
lzh_code = i;
lzh_len = j;
lzh_update(c);
}
void lzh_encode_position(uint16_t c, uint8_t *outbuf, int32_t *outlen)
{
uint16_t i;
/* output upper 6 bits with encoding */
i = c >> 6;
lzh_putcode(lzh_p_len[i], (uint16_t)(lzh_p_code[i] << 8), outbuf, outlen);
/* output lower 6 bits directly */
lzh_putcode(6, (uint16_t)((c & 0x3f) << 10), outbuf, outlen);
}
void lzh_encode_end(uint8_t *outbuf, int32_t *outlen)
{
if (lzh_putlen) {
outbuf[(*outlen)++]=(lzh_putbuf >> 8);
}
}
int16_t lzh_decode_char(uint8_t *inbuf, int32_t *incnt, int32_t inlen)
{
uint16_t c;
c = lzh_son[LZH_R];
/*
* start searching tree from the root to leaves.
* choose node #(lzh_son[]) if input bit == 0
* else choose #(lzh_son[]+1) (input bit == 1)
*/
while (c < LZH_T) {
c += lzh_getbit(inbuf,incnt,inlen);
c = lzh_son[c];
}
c -= LZH_T;
lzh_update(c);
return c;
}
int16_t lzh_decode_position(uint8_t *inbuf, int32_t *incnt, int32_t inlen)
{
uint16_t i, j, c;
/* decode upper 6 bits from given table */
i = lzh_getbyte(inbuf,incnt,inlen);
c = (uint32_t)lzh_d_code[i] << 6;
j = lzh_d_len[i];
/* input lower 6 bits directly */
j -= 2;
while (j--) {
i = (i << 1) + lzh_getbit(inbuf,incnt,inlen);
}
return c | (i & 0x3f);
}
/* Compression */
/* Encoding/Compressing */
/* Returns length of outbuf */
int32_t LZHCALL lzh_encode(uint8_t *inbuf, int32_t inlen, uint8_t *outbuf)
{
int16_t i, c, len, r, s, last_match_length;
int32_t incnt, outlen; /* textsize=0; */
#ifdef LZH_DYNAMIC_BUF
if((lzh_text_buf=(uint8_t *)MALLOC(LZH_N + LZH_F - 1))==NULL)
return(-1);
if((lzh_freq=(uint16_t *)MALLOC((LZH_T + 1)*sizeof(uint16_t)))==NULL) {
FREE(lzh_text_buf);
return(-1); }
if((lzh_prnt=(int16_t *)MALLOC((LZH_T + LZH_N_CHAR)*sizeof(int16_t)))==NULL) {
FREE(lzh_text_buf);
FREE(lzh_freq);
return(-1); }
if((lzh_son=(int16_t *)MALLOC((LZH_T + 1) * sizeof(int16_t)))==NULL) {
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
return(-1); }
if((lzh_lson=(int16_t *)MALLOC((LZH_N + 1)*sizeof(int16_t)))==NULL) {
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
FREE(lzh_son);
return(-1); }
if((lzh_rson=(int16_t *)MALLOC((LZH_N + 257)*sizeof(int16_t)))==NULL) {
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
FREE(lzh_son);
FREE(lzh_lson);
return(-1); }
if((lzh_dad=(int16_t *)MALLOC((LZH_N + 1)*sizeof(int16_t)))==NULL) {
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
FREE(lzh_son);
FREE(lzh_lson);
FREE(lzh_rson);
return(-1); }
#endif
incnt=0;
memcpy(outbuf,&inlen,sizeof(inlen));
outlen=sizeof(inlen);
if(!inlen) {
#ifdef LZH_DYNAMIC_BUF
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
FREE(lzh_son);
FREE(lzh_lson);
FREE(lzh_rson);
FREE(lzh_dad);
#endif
return(outlen); }
lzh_start_huff();
lzh_init_tree();
s = 0;
r = LZH_N - LZH_F;
for (i = s; i < r; i++)
lzh_text_buf[i] = ' ';
for (len = 0; len < LZH_F && incnt<inlen; len++)
lzh_text_buf[r + len] = inbuf[incnt++];
/* textsize = len; */
for (i = 1; i <= LZH_F; i++)
lzh_insert_node((int16_t)(r - i));
lzh_insert_node(r);
do {
if (lzh_match_length > len)
lzh_match_length = len;
if (lzh_match_length <= LZH_THRESHOLD) {
lzh_match_length = 1;
lzh_encode_char(lzh_text_buf[r],outbuf,&outlen);
} else {
lzh_encode_char((uint16_t)(255 - LZH_THRESHOLD + lzh_match_length)
,outbuf,&outlen);
lzh_encode_position(lzh_match_position
,outbuf,&outlen);
}
last_match_length = lzh_match_length;
for (i = 0; i < last_match_length && incnt<inlen; i++) {
lzh_delete_node(s);
c=inbuf[incnt++];
lzh_text_buf[s] = (uint8_t)c;
if (s < LZH_F - 1)
lzh_text_buf[s + LZH_N] = (uint8_t)c;
s = (s + 1) & (LZH_N - 1);
r = (r + 1) & (LZH_N - 1);
lzh_insert_node(r);
}
/***
if ((textsize += i) > printcount) {
printf("%12ld\r", textsize);
printcount += 1024;
}
***/
while (i++ < last_match_length) {
lzh_delete_node(s);
s = (s + 1) & (LZH_N - 1);
r = (r + 1) & (LZH_N - 1);
if (--len) lzh_insert_node(r);
}
} while (len > 0);
lzh_encode_end(outbuf,&outlen);
/*
printf("input: %ld (%ld) bytes\n", inlen,textsize);
printf("output: %ld bytes\n", outlen);
printf("output/input: %.3f\n", (double)outlen / inlen);
*/
#ifdef LZH_DYNAMIC_BUF
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
FREE(lzh_son);
FREE(lzh_lson);
FREE(lzh_rson);
FREE(lzh_dad);
#endif
return(outlen);
}
/* Decoding/Uncompressing */
/* Returns length of outbuf */
int32_t LZHCALL lzh_decode(uint8_t *inbuf, int32_t inlen, uint8_t *outbuf)
{
int16_t i, j, k, r, c;
uint32_t count;
int32_t incnt, textsize;
#ifdef LZH_DYNAMIC_BUF
if((lzh_text_buf=(uint8_t *)MALLOC((LZH_N + LZH_F - 1)*2))==NULL)
return(-1);
if((lzh_freq=(uint16_t *)MALLOC((LZH_T + 1)*sizeof(uint16_t)))
==NULL) {
FREE(lzh_text_buf);
return(-1); }
if((lzh_prnt=(int16_t *)MALLOC((LZH_T + LZH_N_CHAR)*sizeof(int16_t)))==NULL) {
FREE(lzh_text_buf);
FREE(lzh_freq);
return(-1); }
if((lzh_son=(int16_t *)MALLOC((LZH_T + 1) * sizeof(int16_t)))==NULL) {
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
return(-1); }
#endif
incnt=0;
memcpy(&textsize,inbuf,sizeof(textsize));
incnt+=sizeof(textsize);
if (textsize == 0) {
#ifdef LZH_DYNAMIC_BUF
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
FREE(lzh_son);
#endif
return(textsize); }
lzh_start_huff();
for (i = 0; i < LZH_N - LZH_F; i++)
*(lzh_text_buf+i) = ' ';
r = LZH_N - LZH_F;
for (count = 0; count < (uint32_t)textsize; ) {
c = lzh_decode_char(inbuf,&incnt,inlen);
if (c < 256) {
outbuf[count]=(uint8_t)c;
#if 0
if(r>(LZH_N + LZH_F - 1) || r<0) {
printf("Overflow! (%d)\n",r);
getch();
exit(-1); }
#endif
*(lzh_text_buf+r) = (uint8_t)c;
r++;
r &= (LZH_N - 1);
count++;
} else {
i = (r - lzh_decode_position(inbuf,&incnt,inlen) - 1)
& (LZH_N - 1);
j = c - 255 + LZH_THRESHOLD;
for (k = 0; k < j && count<(uint32_t)textsize; k++) {
c = lzh_text_buf[(i + k) & (LZH_N - 1)];
outbuf[count]=(uint8_t)c;
#if 0
if(r>(LZH_N + LZH_F - 1) || r<0) {
printf("Overflow! (%d)\n",r);
exit(-1); }
#endif
*(lzh_text_buf+r) = (uint8_t)c;
r++;
r &= (LZH_N - 1);
count++;
}
}
}
/***
printf("%12ld\n", count);
***/
#ifdef LZH_DYNAMIC_BUF
FREE(lzh_text_buf);
FREE(lzh_prnt);
FREE(lzh_freq);
FREE(lzh_son);
#endif
return(count);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +0,0 @@
#ifndef __crc32_h
#define __crc32_h
/* crc32.h */
/* wrapper for gall library */
typedef unsigned long crc32_t;
#define Z_NULL 0
#define byte(a) ((unsigned char)(a))
extern crc32_t __crc32_table[256];
static crc32_t updCrc32(unsigned char ch, crc32_t crc)
{
return (crc32_t)(__crc32_table[byte(crc) ^ byte(ch)] ^ (crc >> 8));
}
static crc32_t crc32(crc32_t crc, const unsigned char *buf, unsigned int len)
{
if (buf == Z_NULL) return 0L;
crc = crc ^ 0xffffffffL;
while (len--)
{
crc = updCrc32(*buf++, crc);
}
return crc ^ 0xffffffffL;
}
#endif /* __crc32_h */

View File

@ -1,514 +0,0 @@
/*
* fptools.c, some helper functions for getcgi.c and uu(en|de)view
*
* Distributed under the terms of the GNU General Public License.
* Use and be happy.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef SYSTEM_WINDLL
#include <windows.h>
#endif
#ifdef SYSTEM_OS2
#include <os2.h>
#endif
/*
* This file provides replacements for some handy functions that aren't
* available on all systems, like most of the <string.h> functions. They
* should behave exactly as their counterparts. There are also extensions
* that aren't portable at all (like strirstr etc.).
* The proper behaviour in a configure script is as follows:
* AC_CHECK_FUNC(strrchr,AC_DEFINE(strrchr,_FP_strrchr))
* This way, the (probably less efficient) replacements will only be used
* where it is not provided by the default libraries. Be aware that this
* does not work with replacements that just shadow wrong behaviour (like
* _FP_free) or provide extended functionality (_FP_gets).
* The above is not used in the uuenview/uudeview configuration script,
* since both only use the replacement functions in non-performance-cri-
* tical sections (except for _FP_tempnam and _FP_strerror, where some
* functionality of the original would be lost).
*/
#include <stdio.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <gdefs.h>
#include <gctype.h>
#include <fptools.h>
#if 0
#ifdef SYSTEM_WINDLL
BOOL _export WINAPI
DllEntryPoint (HINSTANCE hInstance, DWORD seginfo,
LPVOID lpCmdLine)
{
/* Don't do anything, so just return true */
return TRUE;
}
#endif
#endif
char * fptools_id = "$Id$";
/*
* some versions of free can't handle a NULL pointer properly
* (ANSI says, free ignores a NULL pointer, but some machines
* prefer to SIGSEGV on it)
*/
void TOOLEXPORT
_FP_free (void *ptr)
{
if (ptr) free (ptr);
}
/*
* This is non-standard, so I'm defining my own
*/
char * TOOLEXPORT
_FP_strdup (char *string)
{
char *result;
if (string == NULL)
return NULL;
if ((result = (char *) malloc (strlen (string) + 1)) == NULL)
return NULL;
strcpy (result, string);
return result;
}
/*
* limited-length string copy. this function behaves differently from
* the original in that the dest string is always terminated with a
* NULL character.
*/
char * TOOLEXPORT
_FP_strncpy (char *dest, char *src, int length)
{
char *odest=dest;
if (src == NULL || dest == NULL || length-- <= 0)
return dest;
while (length-- && *src)
*dest++ = *src++;
*dest++ = '\0';
return odest;
}
/*
* duplicate a memory area
*/
void * TOOLEXPORT
_FP_memdup (void *ptr, int len)
{
void *result;
if (ptr == NULL)
return NULL;
if ((result = malloc (len)) == NULL)
return NULL;
memcpy (result, ptr, len);
return result;
}
/*
* case-insensitive compare
*/
int TOOLEXPORT
_FP_stricmp (char *str1, char *str2)
{
if (str1==NULL || str2==NULL)
return -1;
while (*str1) {
if (g_tolower(*str1) != g_tolower(*str2))
break;
str1++;
str2++;
}
return (g_tolower (*str1) - g_tolower (*str2));
}
int TOOLEXPORT
_FP_strnicmp (char *str1, char *str2, int count)
{
if (str1==NULL || str2==NULL)
return -1;
while (*str1 && count) {
if (g_tolower(*str1) != g_tolower(*str2))
break;
str1++;
str2++;
count--;
}
return count ? (g_tolower (*str1) - g_tolower (*str2)) : 0;
}
/*
* autoconf says this function might be a compatibility problem
*/
char * TOOLEXPORT
_FP_strstr (char *str1, char *str2)
{
char *ptr1, *ptr2;
if (str1==NULL)
return NULL;
if (str2==NULL)
return str1;
while (*(ptr1=str1)) {
for (ptr2=str2;
*ptr1 && *ptr2 && *ptr1==*ptr2;
ptr1++, ptr2++)
/* empty loop */ ;
if (*ptr2 == '\0')
return str1;
str1++;
}
return NULL;
}
char * TOOLEXPORT
_FP_strpbrk (char *str, char *accept)
{
char *ptr;
if (str == NULL)
return NULL;
if (accept == NULL || *accept == '\0')
return str;
for (; *str; str++)
for (ptr=accept; *ptr; ptr++)
if (*str == *ptr)
return str;
return NULL;
}
/*
* autoconf also complains about this one
*/
char * TOOLEXPORT
_FP_strtok (char *str1, char *str2)
{
static char *optr;
char *ptr;
if (str2 == NULL)
return NULL;
if (str1) {
optr = str1;
}
else {
if (*optr == '\0')
return NULL;
}
while (*optr && strchr (str2, *optr)) /* look for beginning of token */
optr++;
if (*optr == '\0') /* no token found */
return NULL;
ptr = optr;
while (*optr && strchr (str2, *optr) == NULL) /* look for end of token */
optr++;
if (*optr) {
*optr++ = '\0';
}
return ptr;
}
/*
* case insensitive strstr.
*/
char * TOOLEXPORT
_FP_stristr (char *str1, char *str2)
{
char *ptr1, *ptr2;
if (str1==NULL)
return NULL;
if (str2==NULL)
return str1;
while (*(ptr1=str1)) {
for (ptr2=str2;
*ptr1 && *ptr2 && g_tolower(*ptr1)==g_tolower(*ptr2);
ptr1++, ptr2++)
/* empty loop */ ;
if (*ptr2 == '\0')
return str1;
str1++;
}
return NULL;
}
/*
* Nice fake of the real (non-standard) one
*/
char * TOOLEXPORT
_FP_strrstr (char *ptr, char *str)
{
char *found=NULL, *new, *iter=ptr;
if (ptr==NULL || str==NULL)
return NULL;
if (*str == '\0')
return ptr;
while ((new = _FP_strstr (iter, str)) != NULL) {
found = new;
iter = new + 1;
}
return found;
}
char * TOOLEXPORT
_FP_strirstr (char *ptr, char *str)
{
char *found=NULL, *iter=ptr, *new;
if (ptr==NULL || str==NULL)
return NULL;
if (*str == '\0')
return ptr;
while ((new = _FP_stristr (iter, str)) != NULL) {
found = new;
iter = new + 1;
}
return found;
}
/*
* convert whole string to case
*/
char * TOOLEXPORT
_FP_stoupper (char *input)
{
char *iter = input;
if (input == NULL)
return NULL;
while (*iter) {
*iter = g_toupper (*iter);
iter++;
}
return input;
}
char * TOOLEXPORT
_FP_stolower (char *input)
{
char *iter = input;
if (input == NULL)
return NULL;
while (*iter) {
*iter = g_tolower (*iter);
iter++;
}
return input;
}
/*
* string matching with wildcards
*/
int TOOLEXPORT
_FP_strmatch (char *string, char *pattern)
{
char *p1 = string, *p2 = pattern;
if (pattern==NULL || string==NULL)
return 0;
while (*p1 && *p2) {
if (*p2 == '?') {
p1++; p2++;
}
else if (*p2 == '*') {
if (*++p2 == '\0')
return 1;
while (*p1 && *p1 != *p2)
p1++;
}
else if (*p1 == *p2) {
p1++; p2++;
}
else
return 0;
}
if (*p1 || *p2)
return 0;
return 1;
}
char * TOOLEXPORT
_FP_strrchr (char *string, int tc)
{
char *ptr;
if (string == NULL)
return NULL;
ptr = string + strlen (string) - 1;
while (ptr != string && *ptr != tc)
ptr--;
if (*ptr == tc)
return ptr;
return NULL;
}
/*
* strip directory information from a filename. Works only on DOS and
* Unix systems so far ...
*/
char * TOOLEXPORT
_FP_cutdir (char *filename)
{
char *ptr;
if (filename == NULL)
return NULL;
if ((ptr = _FP_strrchr (filename, '/')) != NULL)
ptr++;
else if ((ptr = _FP_strrchr (filename, '\\')) != NULL)
ptr++;
else
ptr = filename;
return ptr;
}
/*
* My own fgets function. It handles all kinds of line terminators
* properly: LF (Unix), CRLF (DOS) and CR (Mac). In all cases, the
* terminator is replaced by a single LF
*/
char * TOOLEXPORT
_FP_fgets (char *buf, int n, FILE *stream)
{
char *obp = buf;
int c;
if (feof (stream))
return NULL;
while (--n) {
if ((c = fgetc (stream)) == EOF) {
if (ferror (stream))
return NULL;
else {
if (obp == buf)
return NULL;
*buf = '\0';
return obp;
}
}
if (c == '\015') { /* CR */
/*
* Peek next character. If it's no LF, push it back.
* ungetc(EOF, stream) is handled correctly according
* to the manual page
*/
if ((c = fgetc (stream)) != '\012')
if (!feof (stream))
ungetc (c, stream);
*buf++ = '\012';
*buf = '\0';
return obp;
}
else if (c == '\012') { /* LF */
*buf++ = '\012';
*buf = '\0';
return obp;
}
/*
* just another standard character
*/
*buf++ = c;
}
/*
* n-1 characters already transferred
*/
*buf = '\0';
return obp;
}
#if 0
/*
* A replacement strerror function that just returns the error code
*/
char * TOOLEXPORT
_FP_strerror (int errcode)
{
static char number[8];
sprintf (number, "%03d", errcode);
return number;
}
/*
* tempnam is not ANSI, but tmpnam is. Ignore the prefix here.
*/
char * TOOLEXPORT
_FP_tempnam (char *dir, char *pfx)
{
return _FP_strdup (tmpnam (NULL));
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,168 +0,0 @@
/*
* This file is part of uudeview, the simple and friendly multi-part multi-
* file uudecoder program (c) 1994-2001 by Frank Pilhofer. The author may
* be contacted at fp@fpx.de
*
* 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.
*/
/*
* Strings used in the library for easier translation etc.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef SYSTEM_WINDLL
#include <windows.h>
#endif
#ifdef SYSTEM_OS2
#include <os2.h>
#endif
#include <stdio.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#include <uudeview.h>
#include <uuint.h>
#include <uustring.h>
char * uustring_id = "$Id$";
typedef struct {
int code;
char * msg;
} stringmap;
/*
* Map of messages. This table is not exported, the messages must
* be retrieved via the below uustring() function.
*/
static stringmap messages[] = {
/* I/O related errors/messages. Last parameter is strerror() */
{ S_NOT_OPEN_SOURCE, "Could not open source file %s: %s" },
{ S_NOT_OPEN_TARGET, "Could not open target file %s for writing: %s" },
{ S_NOT_OPEN_FILE, "Could not open file %s: %s" },
{ S_NOT_STAT_FILE, "Could not stat file %s: %s" },
{ S_SOURCE_READ_ERR, "Read error on source file: %s" },
{ S_READ_ERROR, "Error reading from %s: %s" },
{ S_IO_ERR_TARGET, "I/O error on target file %s: %s" },
{ S_WR_ERR_TARGET, "Write error on target file %s: %s" },
{ S_WR_ERR_TEMP, "Write error on temp file: %s" },
{ S_TMP_NOT_REMOVED, "Could not remove temp file %s: %s (ignored)" },
/* some other problems */
{ S_OUT_OF_MEMORY, "Out of memory allocating %d bytes" },
{ S_TARGET_EXISTS, "Target file %s exists and overwriting is not allowed" },
{ S_NOT_RENAME, "Could not change name of %s to %s" },
{ S_ERR_ENCODING, "Error while encoding %s: %s" },
{ S_STAT_ONE_PART, "Could not stat input, encoding to one part only" },
{ S_PARM_CHECK, "Parameter check failed in %s" },
{ S_SHORT_BINHEX, "BinHex encoded file %s ended prematurely (%ld bytes left)" },
{ S_DECODE_CANCEL, "Decode operation canceled" },
{ S_ENCODE_CANCEL, "Encode operation canceled" },
{ S_SCAN_CANCEL, "Scanning canceled" },
{ S_SIZE_MISMATCH, "%s: Decoded size (%ld) does not match expected size (%ld)" },
{ S_PSIZE_MISMATCH, "%s part %d: Decoded size (%ld) does not match expected size (%ld)" },
{ S_CRC_MISMATCH, "CRC32 mismatch in %s. Decoded file probably corrupt." },
{ S_PCRC_MISMATCH, "PCRC32 mismatch in %s part %d. Decoded file probably corrupt." },
/* informational messages */
{ S_LOADED_PART, "Loaded from %s: '%s' (%s): %s part %d %s %s %s" },
{ S_NO_DATA_FOUND, "No encoded data found in %s" },
{ S_NO_BIN_FILE, "Oops, could not find decoded file?" },
{ S_STRIPPED_SETUID, "Stripped setuid/setgid bits from target file %s mode %d" },
{ S_DATA_SUSPICIOUS, "Data looks suspicious. Decoded file might be corrupt." },
{ S_NO_TEMP_NAME, "Could not get name for temporary file" },
{ S_BINHEX_SIZES, "BinHex file: data/resource fork sizes %ld/%ld" },
{ S_BINHEX_BOTH, "BinHex file: both forks non-empty, decoding data fork" },
{ S_SMERGE_MERGED, "Parts of '%s' merged with parts of '%s' (%d)" },
/* MIME-related messages */
{ S_MIME_NO_BOUNDARY, "Multipart message without boundary ignored" },
{ S_MIME_B_NOT_FOUND, "Boundary expected on Multipart message but found EOF" },
{ S_MIME_MULTI_DEPTH, "Multipart message nested too deep" },
{ S_MIME_PART_MULTI, "Handling partial multipart message as plain text" },
{ 0, "" }
};
/*
* description of the return values UURET_*
*/
char *uuretcodes[] = {
"OK",
"File I/O Error",
"Not Enough Memory",
"Illegal Value",
"No Data found",
"Unexpected End of File",
"Unsupported function",
"File exists",
"Continue -- no error", /* only to be seen internally */
"Operation Canceled"
};
/*
* Names of encoding types
*/
char *codenames[8] = {
"", "UUdata", "Base64", "XXdata", "Binhex", "Text", "Text", "yEnc"
};
/*
* Message types
*/
char *msgnames[6] = {
"", "Note: ", "Warning: ", "ERROR: ", "FATAL ERROR: ", "PANIC: "
};
/*
* Retrieve one of the messages. We never return NULL
* but instead escape to "oops".
*/
char *
uustring (int codeno)
{
static char * faileddef = "oops";
stringmap *ptr = messages;
while (ptr->code) {
if (ptr->code == codeno)
return ptr->msg;
ptr++;
}
UUMessage (uustring_id, __LINE__, UUMSG_ERROR,
"Could not retrieve string no %d",
codeno);
return faileddef;
}

View File

@ -1,481 +0,0 @@
/*
* This file is part of uudeview, the simple and friendly multi-part multi-
* file uudecoder program (c) 1994-2001 by Frank Pilhofer. The author may
* be contacted at fp@fpx.de
*
* 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.
*/
/*
* certain utilitarian functions that didn't fit anywhere else
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef SYSTEM_WINDLL
#include <windows.h>
#endif
#ifdef SYSTEM_OS2
#include <os2.h>
#endif
#include <stdio.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#include <string.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <uudeview.h>
#include <uuint.h>
#include <fptools.h>
#include <uustring.h>
char * uuutil_id = "$Id$";
/*
* Parts with different known extensions will not be merged by SPMS.
* if first character is '@', it is synonymous to the previous one.
*/
static char *knownexts[] = {
"mpg", "@mpeg", "avi", "mov",
"gif", "jpg", "@jpeg", "tif",
"voc", "wav", "@wave", "au",
"zip", "arj", "tar",
NULL
};
/*
* forward declarations of local functions
*/
static int UUSMPKnownExt _ANSI_ARGS_((char *filename));
static uulist * UU_smparts_r _ANSI_ARGS_((uulist *, int));
/*
* mallocable areas
*/
char *uuutil_bhwtmp;
/*
* free some memory
**/
void
UUkillfread (fileread *data)
{
if (data != NULL) {
_FP_free (data->subject);
_FP_free (data->filename);
_FP_free (data->origin);
_FP_free (data->mimeid);
_FP_free (data->mimetype);
_FP_free (data->sfname);
_FP_free (data);
}
}
void
UUkillfile (uufile *data)
{
uufile *next;
while (data) {
_FP_free (data->filename);
_FP_free (data->subfname);
_FP_free (data->mimeid);
_FP_free (data->mimetype);
UUkillfread (data->data);
next = data->NEXT;
_FP_free (data);
data = next;
}
}
void
UUkilllist (uulist *data)
{
uulist *next;
while (data) {
if (data->binfile != NULL)
if (unlink (data->binfile))
UUMessage (uuutil_id, __LINE__, UUMSG_WARNING,
uustring (S_TMP_NOT_REMOVED),
data->binfile, strerror (errno));
_FP_free (data->filename);
_FP_free (data->subfname);
_FP_free (data->mimeid);
_FP_free (data->mimetype);
_FP_free (data->binfile);
UUkillfile (data->thisfile);
_FP_free (data->haveparts);
_FP_free (data->misparts);
next = data->NEXT;
_FP_free (data);
data = next;
}
}
/*
* this kill function is an exception in that it doesn't kill data itself
*/
void
UUkillheaders (headers *data)
{
if (data != NULL) {
_FP_free (data->from);
_FP_free (data->subject);
_FP_free (data->rcpt);
_FP_free (data->date);
_FP_free (data->mimevers);
_FP_free (data->ctype);
_FP_free (data->ctenc);
_FP_free (data->fname);
_FP_free (data->boundary);
_FP_free (data->mimeid);
memset (data, 0, sizeof (headers));
}
}
/*
* checks for various well-known extensions. if two parts have different
* known extensions, we won't merge them.
*/
static int
UUSMPKnownExt (char *filename)
{
char **eiter = knownexts, *ptr=_FP_strrchr(filename, '.');
int count=0, where=0;
if (ptr == NULL)
return -1;
ptr++;
while (*eiter) {
if (_FP_stricmp (ptr, (**eiter=='@')?*eiter+1:*eiter) == 0)
return where;
else
eiter++;
if (*eiter == NULL)
break;
if (**eiter=='@')
count++;
else
where = ++count;
}
return -1;
}
/*
* de-compress a binhex RLE stream
* the data read from in is uncompressed, and at most maxcount bytes
* (or octets, as they say) are copied to out. Because an uncompression
* might not be completed because of this maximum number of bytes. There-
* for, the leftover character and repetition count is saved. If a marker
* has been read but not the repetition count, *rpc is set to -256.
*
* the function returns the number of bytes eaten from in. If opc is not
* NULL, the total number of characters stored in out is saved there
*
* with repetition counts, remember that we've already transferred *one*
* occurence
*/
int
UUbhdecomp (char *in, char *out, char *last, int *rpc,
size_t inc, size_t max, size_t *opc)
{
size_t count, used=0, dummy;
char marker = '\220' /* '\x90' */;
if (opc == NULL)
opc = &dummy;
else
*opc = 0;
if (*rpc == -256) {
if (inc == 0)
return 0;
*rpc = (int) (unsigned char) *in++; used++;
if (*rpc == 0) {
*last = *out++ = marker;
max--; *opc+=1;
}
else
*rpc-=1;
}
if (*rpc) {
count = (max > (size_t) *rpc) ? (size_t) *rpc : max;
memset (out, *last, count);
out += count;
*opc += count;
max -= count;
*rpc -= count;
}
while (used < inc && max) {
if (*in == marker) {
used++; in++;
if (used == inc) {
*rpc = -256;
return used;
}
*rpc = (int) (unsigned char) *in++; used++;
if (*rpc == 0) {
*last = *out++ = marker;
max--; *opc+=1;
continue;
}
else
*rpc -= 1;
count = (max > (size_t) *rpc) ? (size_t) *rpc : max;
memset (out, *last, count);
out += count;
*opc += count;
max -= count;
*rpc -= count;
}
else {
*last = *out++ = *in++;
used++; *opc+=1; max--;
}
}
return used;
}
/*
* write to binhex file
*/
size_t
UUbhwrite (char *ptr, size_t sel, size_t nel, FILE *file)
{
char *tmpstring=uuutil_bhwtmp;
static int rpc = 0;
static char lc;
int count, tc=0;
size_t opc;
if (ptr == NULL) { /* init */
rpc = 0;
return 0;
}
while (nel || (rpc != 0 && rpc != -256)) {
count = UUbhdecomp (ptr, tmpstring, &lc, &rpc,
nel, 256, &opc);
if (fwrite (tmpstring, 1, opc, file) != opc)
return 0;
if (ferror (file))
return 0;
nel -= count;
ptr += count;
tc += count;
}
return tc;
}
static uulist *
UU_smparts_r (uulist *addit, int pass)
{
uulist *iter = UUGlobalFileList;
uufile *fiter, *dest, *temp;
int count, flag, a, b;
while (iter) {
if ((iter->state & UUFILE_OK) || iter->uudet == 0) {
iter = iter->NEXT;
continue;
}
if (iter == addit) {
iter = iter->NEXT;
continue;
}
if ((iter->begin && addit->begin) || (iter->end && addit->end) ||
(iter->uudet != addit->uudet)) {
iter = iter->NEXT;
continue;
}
if ((a = UUSMPKnownExt (addit->subfname)) != -1 &&
(b = UUSMPKnownExt (iter->subfname)) != -1)
if (a != b) {
iter = iter->NEXT;
continue;
}
flag = count = 0;
fiter = iter->thisfile;
temp = addit->thisfile;
dest = NULL;
while (temp) {
if (!(temp->data->uudet)) {
temp = temp->NEXT;
continue;
}
while (fiter && fiter->partno < temp->partno) {
dest = fiter;
fiter = fiter->NEXT;
}
if (fiter && fiter->partno == temp->partno) {
flag = 0;
break;
}
else {
flag = 1;
count += ((dest) ? temp->partno - dest->partno - 1 : 0) +
((fiter) ? fiter->partno - temp->partno - 1 : 0);
}
temp = temp->NEXT;
}
if (flag == 0 ||
(pass == 0 && count > 0) ||
(pass == 1 && count > 5)) {
iter = iter->NEXT;
continue;
}
dest = iter->thisfile;
fiter = addit->thisfile;
if (iter->filename == NULL && addit->filename != NULL)
iter->filename = _FP_strdup (addit->filename);
if (addit->begin) iter->begin = 1;
if (addit->end) iter->end = 1;
if (addit->mode != 0 && iter->mode == 0)
iter->mode = addit->mode;
while (fiter) {
flag = 0;
if (fiter->partno == iter->thisfile->partno ||
(dest->NEXT != NULL && fiter->partno == dest->NEXT->partno)) {
temp = fiter->NEXT;
fiter->NEXT = NULL;
UUkillfile (fiter);
addit->thisfile= temp;
fiter = temp;
continue;
}
if (fiter->partno < iter->thisfile->partno) {
temp = fiter->NEXT;
fiter->NEXT = iter->thisfile;
iter->thisfile = fiter;
dest = fiter;
addit->thisfile= temp;
fiter = temp;
}
else if (dest->NEXT == NULL || fiter->partno < dest->NEXT->partno) {
temp = fiter->NEXT;
fiter->NEXT = dest->NEXT;
dest->NEXT = fiter;
addit->thisfile= temp;
fiter = temp;
}
else {
dest = dest->NEXT;
}
}
break;
}
return iter;
}
int UUEXPORT
UUSmerge (int pass)
{
uulist *iter = UUGlobalFileList, *last=NULL, *res, *temp;
int flag = 0;
while (iter) {
if ((iter->state & UUFILE_OK) || iter->uudet == 0) {
last = iter;
iter = iter->NEXT;
continue;
}
if ((res = UU_smparts_r (iter, pass)) != NULL) {
UUMessage (uuutil_id, __LINE__, UUMSG_MESSAGE,
uustring (S_SMERGE_MERGED),
(iter->subfname) ? iter->subfname : "",
(res->subfname) ? res->subfname : "", pass);
temp = iter->NEXT;
iter->NEXT = NULL;
UUkilllist (iter);
flag++;
if (last == NULL) {
UUGlobalFileList = temp;
iter = temp;
}
else {
last->NEXT = temp;
iter = temp;
}
continue;
}
last = iter;
iter = iter->NEXT;
}
/*
* check again
*/
UUCheckGlobalList ();
return flag;
}

View File

@ -577,10 +577,10 @@ inline void index_line(char* p, char* ptrs[5]) {
// ------------------------------------------------------------------
// Read the nodelists and userlists
static void read_nodelists() {
static void read_nodelists()
{
gfile lfp;
long pos;
FILE* lfp;
char* ptr;
_GEIdx nlst;
Addr nlstz;
@ -605,12 +605,12 @@ static void read_nodelists() {
// Compile nodelists
for(realfno=0, fno=nodelist.begin(), zno=nodezone.begin(); fno != nodelist.end(); fno++, zno++) {
if(nodes < maxnodes) {
lfp = fsopen(fno->fn, "rb", sh_mod);
if(lfp) {
setvbuf(lfp, NULL, _IOFBF, 32000);
if (nodes < maxnodes)
{
lfp.Fopen(fno->fn, "rb", sh_mod);
if (lfp.isopen())
{
lfp.SetvBuf(NULL, _IOFBF, 32000);
fno->ft = GetFiletime(fno->fn);
// Initialize for each nodelist file
@ -623,7 +623,8 @@ static void read_nodelists() {
name = CleanFilename(fno->fn);
// Read all nodes
while(fgets(buf, sizeof(buf), lfp)) {
while (lfp.Fgets(buf, sizeof(buf)))
{
line++;
// Break out if eof-marker is found
@ -783,7 +784,7 @@ static void read_nodelists() {
std::cout << "\r* " << ((fno == nodelist.end()-1) ? '\\' : '|') << "--" << name << std::setw((len > 0) ? len : 1) << " " << "Nodes read: " << (uint32_t)no << "\tTotal read: " << (uint32_t)nodes << ((nodes >= maxnodes) ? " (Limit reached)" : " ") << std::endl;
}
fclose(lfp);
lfp.Fclose();
++realfno;
}
else {
@ -804,17 +805,17 @@ static void read_nodelists() {
no = 0;
lfp = fsopen(fno->fn, "rt", sh_mod);
if(lfp) {
setvbuf(lfp, NULL, _IOFBF, 32000);
lfp.Fopen(fno->fn, "rt", sh_mod);
if (lfp.isopen())
{
lfp.SetvBuf(NULL, _IOFBF, 32000);
name = CleanFilename(fno->fn);
if(nodes < maxnodes) {
while(fgets(buf, sizeof(buf), lfp)) {
if (nodes < maxnodes)
{
while (lfp.Fgets(buf, sizeof(buf)))
{
// Get node data
strbtrim(buf);
ptr = buf + strlen(buf) - 1;
@ -889,7 +890,7 @@ static void read_nodelists() {
std::cout << "\r* " << ((fno == userlist.end()-1) ? '\\' : '|') << "--" << name << std::setw((len > 0) ? len : 1) << " " << "Nodes read: " << (uint32_t)no << "\tTotal read: " << (uint32_t)nodes << ((nodes >= maxnodes) ? " (Limit reached)" : " ") << std::endl;
}
fclose(lfp);
lfp.Fclose();
}
else {
if(not quiet) std::cout << "Error opening userlist " << fno->fn << '!' << std::endl;
@ -919,7 +920,6 @@ static void read_nodelists() {
else {
#endif
// At last, sort the nodes
FILE *fp, *fido;
geidxlist::iterator curr, prev;
std::map<long, dword> namepos;
@ -931,15 +931,17 @@ static void read_nodelists() {
#else
nodeidx.sort(cmp_nnlsts);
#endif
// Write the name-sorted .GXN
fp = fsopen(nodeindex.c_str(), "wb", sh_mod);
if(fp) {
gfile fp(nodeindex.c_str(), "wb", sh_mod);
if (fp.isopen())
{
name = CleanFilename(nodeindex.c_str());
fido = NULL;
if(fidouser)
fido = fsopen(fidouserlst, "wt", sh_mod);
if(fido == NULL) {
gfile fido;
if (fidouser) fido.Fopen(fidouserlst, "wt", sh_mod);
if (!fido.isopen())
{
if(not quiet) std::cout << "\b, writing " << name << ' ' << std::flush;
fidouser = false;
}
@ -966,19 +968,20 @@ static void read_nodelists() {
continue;
}
}
fwrite(&(*curr), sizeof(_GEIdx), 1, fp);
fp.Fwrite(&(*curr), sizeof(_GEIdx));
}
else
fwrite(&(*curr), sizeof(_GEIdx), 1, fp);
fp.Fwrite(&(*curr), sizeof(_GEIdx));
namepos[curr->pos] = nodenum++;
if(fidouser) {
if (fidouser)
{
char buf[256];
fprintf(fido, "%-36.36s%24.24s\n", curr->name, make_addr_str(buf, &curr->addr, ""));
fido.Printf("%-36.36s%24.24s\n", curr->name, make_addr_str(buf, &curr->addr, ""));
}
}
if(fido)
fclose(fido);
fclose(fp);
fp.Fclose();
}
// Sort by address
@ -991,29 +994,33 @@ static void read_nodelists() {
#endif
// Write the address-sorted .GXA
fp = fsopen(addrindex.c_str(), "wb", sh_mod);
if(fp) {
fp.Fopen(addrindex.c_str(), "wb", sh_mod);
if (fp.isopen())
{
name = CleanFilename(addrindex.c_str());
if(not quiet) std::cout << "\b, writing " << name << ' ' << std::flush;
int nn = 0;
for(curr = nodeidx.begin(); curr != nodeidx.end(); curr++) {
if(ISTWIRLY(nn++))
twirly();
fwrite(&namepos[curr->pos], sizeof(dword), 1, fp);
fp.Fwrite(&namepos[curr->pos], sizeof(dword));
}
fclose(fp);
fp.Fclose();
}
// Write the list index in .GXL
fp = fsopen(listindex.c_str(), "wt", sh_mod);
if(fp) {
fp.Fopen(listindex.c_str(), "wt", sh_mod);
if (fp.isopen())
{
name = CleanFilename(listindex.c_str());
if(not quiet) std::cout << ' ' << NL "* Writing " << name << std::endl;
for(fno=nodelist.begin(); fno != nodelist.end(); fno++) {
if(*(fno->fn))
fprintf(fp, "%s %u\n", fno->fn, fno->ft);
if (not quiet) std::cout << ' ' << NL "* Writing " << name << std::endl;
for (fno=nodelist.begin(); fno != nodelist.end(); fno++)
{
if (*(fno->fn))
fp.Printf("%s %u\n", fno->fn, fno->ft);
}
fclose(fp);
fp.Fclose();
}
// Note compile time
@ -1033,9 +1040,8 @@ static void read_nodelists() {
// ------------------------------------------------------------------
static void check_nodelists(bool force) {
FILE *fp;
static void check_nodelists(bool force)
{
uint n;
int compilen, compileu;
static Path buf, newpath;
@ -1066,9 +1072,11 @@ static void check_nodelists(bool force) {
}
// Get timestamps from .GXL file
fp = fsopen(listindex.c_str(), "rt", sh_mod);
if(fp) {
while(fgets(buf, sizeof(buf), fp)) {
gfile fp(listindex.c_str(), "rt", sh_mod);
if (fp.isopen())
{
while (fp.Fgets(buf, sizeof(buf)))
{
char* key;
char* val=buf;
getkeyval(&key, &val);
@ -1088,7 +1096,7 @@ static void check_nodelists(bool force) {
}
}
}
fclose(fp);
fp.Fclose();
} else
perror("error opening .gxl file");
@ -1172,6 +1180,14 @@ static int do_if(char* val) {
return false;
#endif
}
else if (strieql(val, "SPELL"))
{
#ifdef GCFG_SPELL_INCLUDED
return true;
#else
return false;
#endif
}
else if(strieql(val, "FIREBIRD"))
return true;
else if(strieql(val, "ASA") or strieql(val, "PLUS"))
@ -1200,7 +1216,7 @@ char* _MapPath(char* fmap, bool reverse) {
strxcpy(buf, fmap, sizeof(Path));
strxmerge(fmap, sizeof(Path), q, buf+strlen(p), NULL);
char sl1, sl2;
char* ptr;
const char* ptr;
ptr = strpbrk(p, "/\\");
sl1 = ptr ? *ptr : NUL;
@ -1219,9 +1235,8 @@ char* _MapPath(char* fmap, bool reverse) {
// ------------------------------------------------------------------
static int parse_config(const char *__configfile, Addr& zoneaddr) {
FILE* fp;
static int parse_config(const char *__configfile, Addr& zoneaddr)
{
char buf[512];
char* ptr;
char* key;
@ -1233,9 +1248,11 @@ static int parse_config(const char *__configfile, Addr& zoneaddr) {
static int in_else = NO;
static int cond_status = YES;
fp = fsopen(__configfile, "rt", sh_mod);
if(fp) {
while(fgets((ptr=buf), sizeof(buf), fp)) {
gfile fp(__configfile, "rt", sh_mod);
if (fp.isopen())
{
while (fp.Fgets((ptr=buf), sizeof(buf)))
{
line++;
// Replace TABs with SPACEs
ptr = strskip_wht(ptr);
@ -1384,7 +1401,6 @@ static int parse_config(const char *__configfile, Addr& zoneaddr) {
}
}
fclose(fp);
return(YES);
}
else {