Refactoring!
This commit is contained in:
@@ -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
|
||||
|
@@ -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)
|
||||
|
965
goldlib/gall/geall.h
Normal file
965
goldlib/gall/geall.h
Normal file
@@ -0,0 +1,965 @@
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// GoldED+
|
||||
// Copyright (C) 1990-1999 Odinn Sorensen
|
||||
// Copyright (C) 1999-2000 Alexander S. Aganichev
|
||||
// ------------------------------------------------------------------
|
||||
// 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$
|
||||
// ------------------------------------------------------------------
|
||||
// Definition of system-wide sizes and structures.
|
||||
// ------------------------------------------------------------------
|
||||
#ifndef __GEALL__H
|
||||
#define __GEALL__H
|
||||
|
||||
#include <gdefs.h>
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#if defined(GOLD_CANPACK)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// General data/list size limits
|
||||
|
||||
const uint MAX_COMM = 25; // Editor comments
|
||||
const uint MAX_FIND = 10; // Max number of search strings
|
||||
const uint MAXQUOTELEN = 40; // Max length of quote
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Header attach size types
|
||||
|
||||
const int ATTACH_BYTES = 1;
|
||||
const int ATTACH_KBYTES = 2;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Control info types
|
||||
|
||||
const int CI_NONE = 0x0000;
|
||||
const int CI_TEAR = 0x0001;
|
||||
const int CI_ORIG = 0x0002;
|
||||
const int CI_TAGL = 0x0004;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Misc mode types (ACK!! these need cleaning up!)
|
||||
|
||||
const int MODE_AREACONF = 100;
|
||||
const int MODE_CONFIRM = 101;
|
||||
const int MODE_COPY = 102;
|
||||
const int MODE_FORWARD = 103;
|
||||
const int MODE_MOVE = 108;
|
||||
const int MODE_QUOTE = 109;
|
||||
const int MODE_QUOTEBUF = 110;
|
||||
const int MODE_REPLY = 111;
|
||||
const int MODE_REPLYCOMMENT = 112;
|
||||
const int MODE_SAVE = 114;
|
||||
const int MODE_SAVENOCTRL = 115;
|
||||
const int MODE_VIEW = 116;
|
||||
const int MODE_WRITE = 117;
|
||||
const int MODE_PRINT = 118;
|
||||
const int MODE_APPEND = 119;
|
||||
const int MODE_WRITEHEADER = 120;
|
||||
const int MODE_HEADER = 121;
|
||||
|
||||
const int MODE_NEW = 0x0100;
|
||||
const int MODE_CHANGE = 0x0200;
|
||||
const int MODE_UPDATE = 0x0400;
|
||||
const int MODE_QUIT = 0x0800;
|
||||
|
||||
const int MODE_PREVIOUS = 2;
|
||||
const int MODE_MARKED = 1;
|
||||
const int MODE_CURRENT = 0;
|
||||
const int MODE_DONT = -1;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Scanning constants
|
||||
|
||||
const int SCAN_STARTUP = 0;
|
||||
const int SCAN_ALL = 1;
|
||||
const int SCAN_MARKED = 2;
|
||||
const int SCAN_CURRENT = 3;
|
||||
const int SCAN_MATCHING = 4;
|
||||
const int SCAN_UNSCANNED = 5;
|
||||
const int SCAN_EXPORTQWK = 6;
|
||||
const int SCAN_IMPORTQWK = 7;
|
||||
const int SCAN_EXPORTSOUP = 8;
|
||||
const int SCAN_IMPORTSOUP = 9;
|
||||
const int SCAN_LIST = 10;
|
||||
const int SCAN_GROUP = 11;
|
||||
const int SCAN_NETMAIL = 12;
|
||||
const int SCAN_QUIT = 99;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Exit errorcodes
|
||||
|
||||
const int EXIT_OK = 0x00;
|
||||
const int EXIT_LOCAL = 0x01;
|
||||
const int EXIT_NET = 0x02;
|
||||
const int EXIT_ECHO = 0x04;
|
||||
const int EXIT_NONAME = 0x20;
|
||||
const int EXIT_CFGERR = 0x21;
|
||||
const int EXIT_ERRORS = 0x22;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Direction defines
|
||||
|
||||
const int DIR_PREV = -1;
|
||||
const int DIR_NEXT = 1;
|
||||
|
||||
const int DIR_ABOVE = DIR_PREV;
|
||||
const int DIR_BELOW = DIR_NEXT;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Misc screen limits
|
||||
|
||||
#define MINROW 6
|
||||
#define MAXCOL gvid->numcols
|
||||
#define MAXROW gvid->numrows
|
||||
#define MAXMSGLINES (MAXROW-MINROW-1)
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Message marking
|
||||
|
||||
const char MMRK_MARK = '\x10';
|
||||
const char MMRK_BOOK = '\x11';
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Twit options
|
||||
|
||||
const int NOT_TWIT = 0;
|
||||
const int TWIT_SHOW = 1;
|
||||
const int TWIT_BLANK = 2;
|
||||
const int TWIT_SKIP = 3;
|
||||
const int TWIT_IGNORE = 4;
|
||||
const int TWIT_KILL = 5;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// CC list options
|
||||
|
||||
const int CC_REMOVE = 0;
|
||||
const int CC_HIDDEN = 1;
|
||||
const int CC_VISIBLE = 2;
|
||||
const int CC_NAMES = 3;
|
||||
const int CC_KEEP = 4;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Arealist types
|
||||
|
||||
const int AL_TOTLST = 0;
|
||||
const int AL_TOTNEW = 1;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Area R/O modes
|
||||
|
||||
const int READONLY_SOFT = 1;
|
||||
const int READONLY_HARD = 2;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Colorset types
|
||||
|
||||
const int CS_NORMAL = 0;
|
||||
const int CS_INTENSE = 1;
|
||||
const int CS_MONO = 2;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Lookup types
|
||||
|
||||
const int LOOK_DEST = 0;
|
||||
const int LOOK_ORIG = 1;
|
||||
const int LOOK_NAME = 2;
|
||||
const int LOOK_CITY1 = 3;
|
||||
const int LOOK_CITY2 = 4;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Squish scanning types
|
||||
|
||||
//const int SQS_API = 1;
|
||||
//const int SQS_QUICK = 2;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Quotebuffer modes
|
||||
|
||||
const int QBUF_ASK = 1;
|
||||
const int QBUF_APPEND = 2;
|
||||
const int QBUF_OVERWRITE = 3;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Screenblanker types
|
||||
|
||||
const int BLANK_ALLBLACK = 0;
|
||||
const int BLANK_SLIDEWIN = 1;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// DISPMSGSIZE types
|
||||
|
||||
const int DISPMSGSIZE_BYTES = 1;
|
||||
const int DISPMSGSIZE_KBYTES = 2;
|
||||
const int DISPMSGSIZE_LINES = 3;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Replylink types
|
||||
|
||||
const int REPLYLINK_CHAIN = 0;
|
||||
const int REPLYLINK_DIRECT = 1;
|
||||
|
||||
const int REPLYLINKLIST_FAST = 0;
|
||||
const int REPLYLINKLIST_FULL = 1;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
const int KEYB_BLOCK = 0;
|
||||
const int KEYB_POLL = 1;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Registration key valid OS
|
||||
|
||||
const int GKEY_VALID_DOS = 0x0001;
|
||||
const int GKEY_VALID_OS2 = 0x0002;
|
||||
const int GKEY_VALID_W32 = 0x0004;
|
||||
const int GKEY_VALID_LNX = 0x0008;
|
||||
const int GKEY_VALID_WIN = 0x0010;
|
||||
const int GKEY_VALID_OPM = 0x0020;
|
||||
const int GKEY_VALID_XWN = 0x0040;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// File request options
|
||||
|
||||
const int FREQ_SORT = 0x0001;
|
||||
const int FREQ_FROMTOP = 0x0002;
|
||||
const int FREQ_NOFILES = 0x0004;
|
||||
const int FREQ_FAST = 0x0008;
|
||||
const int FREQ_NOWAZOOMSG = 0x0010;
|
||||
const int FREQ_USEFLOWFILE = 0x0020;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Peek URLs options
|
||||
|
||||
const int PEEK_SORT = 0x0001;
|
||||
const int PEEK_FROMTOP = 0x0002;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Automatic echoid names
|
||||
|
||||
const int AUTOID_VERBOSE = 0;
|
||||
const int AUTOID_SHORT = 1;
|
||||
const int AUTOID_LONG = 2;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Values for EDITHEADERFIRST
|
||||
|
||||
const int EDITHEADERFIRST_NO = 0x0000;
|
||||
const int EDITHEADERFIRST_NEW = 0x0001;
|
||||
const int EDITHEADERFIRST_CHANGES = 0x0002;
|
||||
const int EDITHEADERFIRST_REPLIES = 0x0004;
|
||||
const int EDITHEADERFIRST_FORWARDS = 0x0008;
|
||||
const int EDITHEADERFIRST_YES = 0x000F;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Values for MSGLISTDATE
|
||||
|
||||
const int MSGLISTDATE_NONE = 0;
|
||||
const int MSGLISTDATE_WRITTEN = 1;
|
||||
const int MSGLISTDATE_ARRIVED = 2;
|
||||
const int MSGLISTDATE_RECEIVED = 3;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Write constants
|
||||
|
||||
const int WRITE_CURRENT = 0;
|
||||
const int WRITE_MARKED = 1;
|
||||
const int WRITE_QUIT = -1;
|
||||
const int WRITE_FILE = 1;
|
||||
const int WRITE_PRINTER = 2;
|
||||
const int WRITE_CLIPBRD = 4;
|
||||
const int WRITE_NO_HEADER = 8;
|
||||
const int WRITE_ONLY_HEADER = 16;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Values for REPLYRE
|
||||
|
||||
const int REPLYRE_NO = 0;
|
||||
const int REPLYRE_YES = 1;
|
||||
const int REPLYRE_NUMERIC = 2;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
const int MAX_DESC = 81; // Area descriptions
|
||||
const int MAX_ECHO = 81; // Echoids
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Name typedefs
|
||||
|
||||
typedef TCHAR Name[36];
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Tearline typedefs
|
||||
|
||||
typedef char Tear[77];
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Subject typedefs
|
||||
|
||||
typedef char Subj[128];
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Internet address typedefs
|
||||
|
||||
typedef char IAdr[128];
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Internet subject typedefs
|
||||
|
||||
typedef char XlatName[17];
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Echoid typedefs
|
||||
|
||||
typedef char Echo[MAX_ECHO];
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Description typedefs
|
||||
|
||||
typedef char Desc[MAX_DESC];
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Echo rename struct
|
||||
|
||||
class EchoRen {
|
||||
public:
|
||||
std::string from;
|
||||
std::string to;
|
||||
EchoRen() {}
|
||||
EchoRen(const char *_from, const char *_to) { from = _from; to = _to; }
|
||||
~EchoRen() {}
|
||||
EchoRen& operator=(const EchoRen& a) { from = a.from; to = a.to; return *this; }
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Sound effect defines
|
||||
|
||||
const int SND_THEEND = 0;
|
||||
const int SND_GOTIT = 1;
|
||||
const int SND_TOOBAD = 2;
|
||||
const int SND_TOYOU = 3;
|
||||
const int SND_S_O_S = 4;
|
||||
const int SND_SAYBIBI = 5;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Event command "Play". Types and structure
|
||||
|
||||
const byte PLAY_NO = 0; // * No sound
|
||||
const byte PLAY_DOS = 1; // + DOS beeping and effects
|
||||
const byte PLAY_VOC = 2; // * Creative Technology Voice samples
|
||||
const byte PLAY_CMF = 3; // + Creative Technology FM songs
|
||||
const byte PLAY_WAV = 4; // + MPIDS (Multimedia) WAVE samples
|
||||
const byte PLAY_SAM = 5; // + Raw sample without any header
|
||||
const byte PLAY_MID = 6; // - MIDI songs
|
||||
const byte PLAY_ROL = 7; // - Adlib songs
|
||||
const byte PLAY_SNG = 8; // - Sequencer plus Jr. songs
|
||||
const byte PLAY_MOD = 9; // - ProTracker MOD songs
|
||||
const byte PLAY_STM = 10; // - ScreamTracker STM/STX songs
|
||||
//
|
||||
// * = Supported in the current version
|
||||
// + = Planned for support "soon"
|
||||
// - = Will probably not be supported any time soon
|
||||
|
||||
struct GPlay {
|
||||
byte type;
|
||||
int effectno; // For the DOS sound effects SND_xxx
|
||||
Path file;
|
||||
int Play() const;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Event types (CRC16 values), commands and structure
|
||||
|
||||
const word EVTT_AREALIST = 0x445D;
|
||||
const word EVTT_ASKYESNO = 0xB26C;
|
||||
const word EVTT_ATTENTION = 0x0F21;
|
||||
const word EVTT_BLANKEROFF = 0x16EF;
|
||||
const word EVTT_BLANKERON = 0x819F;
|
||||
const word EVTT_DOSSHELL = 0x2111;
|
||||
const word EVTT_EDITCOMMENT = 0x662C;
|
||||
const word EVTT_EDITCOMPLETION = 0xDA45;
|
||||
const word EVTT_ENDOFMSGS = 0x95BC;
|
||||
const word EVTT_ERRORFATAL = 0xE9C1;
|
||||
const word EVTT_EXIT = 0x6090;
|
||||
const word EVTT_JOBDONE = 0xA81F;
|
||||
const word EVTT_JOBFAILED = 0xCC9A;
|
||||
const word EVTT_MSGCOMMENT = 0x0761;
|
||||
const word EVTT_MSGCOPYING = 0x087B;
|
||||
const word EVTT_MSGDELETING = 0x1AFF;
|
||||
const word EVTT_MSGFROMYOU = 0xBACB;
|
||||
const word EVTT_MSGISLOCAL = 0x2BD6;
|
||||
const word EVTT_MSGISTWIT = 0xC466;
|
||||
const word EVTT_MSGLIST = 0x84D0;
|
||||
const word EVTT_MSGMOVING = 0xAA1B;
|
||||
const word EVTT_MSGNEW = 0x2882;
|
||||
const word EVTT_MSGPRINTING = 0x29E0;
|
||||
const word EVTT_MSGREPLY = 0x3439;
|
||||
const word EVTT_MSGTOYOU = 0xFB77;
|
||||
const word EVTT_MSGWRITING = 0x0CA8;
|
||||
const word EVTT_NODEBROWSE = 0xB6B5;
|
||||
const word EVTT_SAYBIBI = 0xD39D;
|
||||
const word EVTT_SEARCHFAILED = 0xEB54;
|
||||
const word EVTT_SEARCHSUCCESS = 0x2EB2;
|
||||
const word EVTT_STARTUP = 0x494B;
|
||||
const word EVTT_TIMEOUT = 0x4065;
|
||||
|
||||
const word EVTT_BREAKLOOP = 0xFFFF;
|
||||
const word EVTT_STOPVOICE = 0xFFFE;
|
||||
const word EVTT_REMOVEVOCBUF = 0xFFFD;
|
||||
const word EVTT_INITCARD = 0xFFFC;
|
||||
|
||||
const int EVTC_DO_NOTHING = 0;
|
||||
const int EVTC_PLAY = 1;
|
||||
|
||||
struct GEvent {
|
||||
word type; // EVTT crc value
|
||||
int command; // EVTC value
|
||||
union {
|
||||
GPlay play;
|
||||
// Other event command structures can be added here
|
||||
};
|
||||
GEvent& operator=(const GEvent& a) {
|
||||
type = a.type;
|
||||
command = a.command;
|
||||
switch(command) {
|
||||
case EVTC_PLAY:
|
||||
memcpy(&play, &a.play, sizeof(play));
|
||||
break;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Sound device structure
|
||||
|
||||
const int SNDDEV_NONE = 0;
|
||||
const int SNDDEV_DOS = 1;
|
||||
const int SNDDEV_CARD = 2;
|
||||
|
||||
struct SoundDos {
|
||||
int type;
|
||||
// Doesn't need more data..
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Enums for the marking menu (GEMENU etc)
|
||||
|
||||
enum {
|
||||
TAG_MARKYOURMAIL=100,
|
||||
TAG_MARKHEADER,
|
||||
TAG_MARKTXTHDR,
|
||||
TAG_MARKTHREAD,
|
||||
TAG_MARKASREAD,
|
||||
TAG_MARKNEWMSGS,
|
||||
TAG_MARKOLDMSGS,
|
||||
TAG_MARKALLMSGS,
|
||||
TAG_MARKUNMARK,
|
||||
TAG_MARKRANGE,
|
||||
TAG_MARKTOGGLE,
|
||||
TAG_MARKQUIT
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Structure for GOLDNODE.IXL
|
||||
|
||||
struct NodeIxl {
|
||||
|
||||
// Nodelists
|
||||
int nodelists;
|
||||
Stamp* nodelist;
|
||||
|
||||
// Index files
|
||||
Path addrindex;
|
||||
Path nodeindex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// GEUSER
|
||||
|
||||
struct infoLookup {
|
||||
char* attr;
|
||||
char* node;
|
||||
char* system;
|
||||
char* location;
|
||||
char* name;
|
||||
char* phone;
|
||||
char* baud;
|
||||
char* flags;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Structures and constants for external utilities
|
||||
|
||||
const int EXTUTIL_CLS = 0x0001;
|
||||
const int EXTUTIL_CURSOR = 0x0004;
|
||||
const int EXTUTIL_RELOAD = 0x0008;
|
||||
const int EXTUTIL_PAUSE = 0x0010;
|
||||
const int EXTUTIL_PAUSEONERROR = 0x0020;
|
||||
const int EXTUTIL_WIPE = 0x0040;
|
||||
const int EXTUTIL_KEEPCTRL = 0x0080;
|
||||
|
||||
struct ExtUtil {
|
||||
int utilno;
|
||||
int options;
|
||||
char cmdline[256];
|
||||
};
|
||||
|
||||
struct SaveUtil {
|
||||
int utilno;
|
||||
char menutext[41];
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Window areas
|
||||
|
||||
#define GC_BACK_ CFG->color[0]
|
||||
#define GC_STAT_ CFG->color[1]
|
||||
#define GC_BRAG_ CFG->color[2]
|
||||
#define GC_AREA_ CFG->color[3]
|
||||
#define GC_READ_ CFG->color[4]
|
||||
#define GC_HEAD_ CFG->color[5]
|
||||
#define GC_ASK__ CFG->color[6]
|
||||
#define GC_MENU_ CFG->color[7]
|
||||
#define GC_HELP_ CFG->color[8]
|
||||
#define GC_CFG_ CFG->color[9]
|
||||
#define GC_INFO_ CFG->color[10]
|
||||
#define GC_CFGB_ CFG->color[11]
|
||||
#define GC_STYLE_ CFG->color[12]
|
||||
#define GC_SHAD_ CFG->color[13]
|
||||
#if defined(GCFG_SPELL_INCLUDED)
|
||||
#define GC_SPELL_ CFG->color[14]
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Window parts
|
||||
|
||||
#define _Window c[0]
|
||||
#define _Border c[1]
|
||||
#define _Title c[2]
|
||||
#define _Cursor c[2]
|
||||
#define _Selector c[3]
|
||||
#define _Quote c[3]
|
||||
#define _Subject c[3]
|
||||
#define _Highlight c[4]
|
||||
#define _Noselect c[5]
|
||||
#define _Kludge c[5]
|
||||
#define _Location c[5]
|
||||
#define _Tearline c[6]
|
||||
#define _Edit c[6]
|
||||
#define _Block c[7]
|
||||
#define _Input c[7]
|
||||
#define _Shadow c[7]
|
||||
#define _Origin c[8]
|
||||
#define _To c[8]
|
||||
#define _From c[9]
|
||||
#define _Tagline c[9]
|
||||
#define _Hidden c[10]
|
||||
#define _Pagebar c[11]
|
||||
#define _Signature c[12]
|
||||
#define _Quote2 c[13]
|
||||
#define _URL c[14]
|
||||
|
||||
#define _WindowUnsent c[6]
|
||||
#define _WindowUnread c[7]
|
||||
#define _HighlightUnsent c[8]
|
||||
#define _HighlightUnread c[9]
|
||||
|
||||
#define _Bold c[1]
|
||||
#define _Italic c[2]
|
||||
#define _BoldItalic c[3]
|
||||
#define _Underscore c[4]
|
||||
#define _BoldUnderscore c[5]
|
||||
#define _ItalicUnderscore c[6]
|
||||
#define _BoldItalicUnderscore c[7]
|
||||
#define _Reverse c[8]
|
||||
#define _ReverseBold c[9]
|
||||
#define _ReverseItalic c[10]
|
||||
#define _ReverseBoldItalic c[11]
|
||||
#define _ReverseUnderscore c[12]
|
||||
#define _ReverseBoldUnderscore c[13]
|
||||
#define _ReverseItalicUnderscore c[14]
|
||||
#define _ReverseBoldItalicUnderscore c[15]
|
||||
|
||||
#if defined(GCFG_SPELL_INCLUDED)
|
||||
#define _SpellError c[0]
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Window part colors
|
||||
|
||||
#define C_BACKW GC_BACK_._Window
|
||||
#define C_BACKB GC_BACK_._Border
|
||||
|
||||
#define C_STATW GC_STAT_._Window
|
||||
#define C_STATB GC_STAT_._Border
|
||||
|
||||
#define C_BRAGW GC_BRAG_._Window
|
||||
#define C_BRAGB GC_BRAG_._Border
|
||||
#define C_BRAGT GC_BRAG_._Title
|
||||
#define C_BRAGH GC_BRAG_._Highlight
|
||||
#define C_BRAGA GC_BRAG_._Block
|
||||
|
||||
#define C_AREAW GC_AREA_._Window
|
||||
#define C_AREAB GC_AREA_._Border
|
||||
#define C_AREAT GC_AREA_._Title
|
||||
#define C_AREAS GC_AREA_._Selector
|
||||
#define C_AREAQ GC_AREA_._Highlight
|
||||
#define C_AREAPB GC_AREA_._Pagebar
|
||||
|
||||
#define C_READW GC_READ_._Window
|
||||
#define C_READB GC_READ_._Border
|
||||
#define C_READQ GC_READ_._Quote
|
||||
#define C_READK GC_READ_._Kludge
|
||||
#define C_READKH GC_READ_._Hidden
|
||||
#define C_READC GC_READ_._Cursor
|
||||
#define C_READA GC_READ_._Block
|
||||
#define C_READH GC_READ_._Highlight
|
||||
#define C_READG GC_READ_._Tagline
|
||||
#define C_READT GC_READ_._Tearline
|
||||
#define C_READO GC_READ_._Origin
|
||||
#define C_READPB GC_READ_._Pagebar
|
||||
#define C_READS GC_READ_._Signature
|
||||
#define C_READQ2 GC_READ_._Quote2
|
||||
#define C_READU GC_READ_._URL
|
||||
#define C_HEADW GC_HEAD_._Window
|
||||
#define C_HEADB GC_HEAD_._Border
|
||||
#define C_HEADT GC_HEAD_._Title
|
||||
#define C_HEADE GC_HEAD_._Edit
|
||||
#define C_HEADI GC_HEAD_._Input
|
||||
#define C_HEADQ GC_HEAD_._Highlight
|
||||
#define C_HEADBY GC_HEAD_._From
|
||||
#define C_HEADTO GC_HEAD_._To
|
||||
#define C_HEADRE GC_HEAD_._Subject
|
||||
#define C_HEADLOC GC_HEAD_._Location
|
||||
|
||||
#define C_ASKW GC_ASK__._Window
|
||||
#define C_ASKB GC_ASK__._Border
|
||||
#define C_ASKT GC_ASK__._Title
|
||||
#define C_ASKS GC_ASK__._Selector
|
||||
#define C_ASKQ GC_ASK__._Highlight
|
||||
#define C_ASKN GC_ASK__._Noselect
|
||||
#define C_ASKPB GC_ASK_._Pagebar
|
||||
|
||||
#define C_MENUW GC_MENU_._Window
|
||||
#define C_MENUB GC_MENU_._Border
|
||||
#define C_MENUT GC_MENU_._Title
|
||||
#define C_MENUS GC_MENU_._Selector
|
||||
#define C_MENUQ GC_MENU_._Highlight
|
||||
#define C_MENUN GC_MENU_._Noselect
|
||||
#define C_MENUPB GC_MENU_._Pagebar
|
||||
#define C_MENUW_UNREAD GC_MENU_._WindowUnread
|
||||
#define C_MENUQ_UNREADHIGH GC_MENU_._HighlightUnread
|
||||
#define C_MENUW_UNSENT GC_MENU_._WindowUnsent
|
||||
#define C_MENUQ_UNSENTHIGH GC_MENU_._HighlightUnsent
|
||||
|
||||
#define C_HELPW GC_HELP_._Window
|
||||
#define C_HELPB GC_HELP_._Border
|
||||
#define C_HELPT GC_HELP_._Title
|
||||
#define C_HELPS GC_HELP_._Selector
|
||||
#define C_HELPQ GC_HELP_._Highlight
|
||||
#define C_HELPPB GC_HELP_._Pagebar
|
||||
|
||||
#define C_INFOW GC_INFO_._Window
|
||||
#define C_INFOB GC_INFO_._Border
|
||||
#define C_INFOT GC_INFO_._Title
|
||||
#define C_INFOPB GC_INFO_._Pagebar
|
||||
|
||||
#define C_CFGW GC_CFG_._Window
|
||||
#define C_CFGB GC_CFG_._Border
|
||||
#define C_CFGT GC_CFG_._Title
|
||||
#define C_CFGS GC_CFG_._Selector
|
||||
#define C_CFGQ GC_CFG_._Highlight
|
||||
#define C_CFGN GC_CFG_._Noselect
|
||||
#define C_CFGPB GC_CFG_._Pagebar
|
||||
|
||||
#define C_CFGBW GC_CFGB_._Window
|
||||
#define C_CFGBB GC_CFGB_._Border
|
||||
#define C_CFGBT GC_CFGB_._Title
|
||||
#define C_CFGBS GC_CFGB_._Selector
|
||||
#define C_CFGBQ GC_CFGB_._Highlight
|
||||
#define C_CFGBN GC_CFGB_._Noselect
|
||||
#define C_CFGBPB GC_CFGB_._Pagebar
|
||||
|
||||
#define C_SHADOW GC_SHAD_._Shadow
|
||||
|
||||
#define C_STYLE GC_STYLE_.c
|
||||
#define C_STYLE___B GC_STYLE_._Bold
|
||||
#define C_STYLE__I_ GC_STYLE_._Italic
|
||||
#define C_STYLE__IB GC_STYLE_._BoldItalic
|
||||
#define C_STYLE_U__ GC_STYLE_._Underscore
|
||||
#define C_STYLE_U_B GC_STYLE_._BoldUnderscore
|
||||
#define C_STYLE_UI_ GC_STYLE_._ItalicUnderscore
|
||||
#define C_STYLE_UIB GC_STYLE_._BoldItalicUnderscore
|
||||
#define C_STYLER___ GC_STYLE_._Reverse
|
||||
#define C_STYLER__B GC_STYLE_._ReverseBold
|
||||
#define C_STYLER_I_ GC_STYLE_._ReverseItalic
|
||||
#define C_STYLER_IB GC_STYLE_._ReverseBoldItalic
|
||||
#define C_STYLERU__ GC_STYLE_._ReverseUnderscore
|
||||
#define C_STYLERU_B GC_STYLE_._ReverseBoldUnderscore
|
||||
#define C_STYLERUI_ GC_STYLE_._ReverseItalicUnderscore
|
||||
#define C_STYLERUIB GC_STYLE_._ReverseBoldItalicUnderscore
|
||||
|
||||
#if defined(GCFG_SPELL_INCLUDED)
|
||||
#define C_SCERROR GC_SPELL_._SpellError
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Window handles
|
||||
|
||||
#define W_BACK GC_BACK_.w
|
||||
#define W_STAT GC_STAT_.w
|
||||
#define W_BRAG GC_BRAG_.w
|
||||
#define W_AREA GC_AREA_.w
|
||||
#define W_READ GC_READ_.w
|
||||
#define W_HEAD GC_READ_.w
|
||||
#define W_ASK GC_ASK__.w
|
||||
#define W_MENU GC_MENU_.w
|
||||
#define W_INFO GC_INFO_.w
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Window offsets
|
||||
|
||||
#define W_XBACK GC_BACK_.x
|
||||
#define W_XSTAT GC_STAT_.x
|
||||
#define W_XBRAG GC_BRAG_.x
|
||||
#define W_XAREA GC_AREA_.x
|
||||
#define W_XREAD GC_READ_.x
|
||||
#define W_XHEAD GC_READ_.x
|
||||
#define W_XASK GC_ASK__.x
|
||||
#define W_XMENU GC_MENU_.x
|
||||
#define W_XINFO GC_INFO_.x
|
||||
|
||||
#define W_YBACK GC_BACK_.y
|
||||
#define W_YSTAT GC_STAT_.y
|
||||
#define W_YBRAG GC_BRAG_.y
|
||||
#define W_YAREA GC_AREA_.y
|
||||
#define W_YREAD GC_READ_.y
|
||||
#define W_YHEAD GC_READ_.y
|
||||
#define W_YASK GC_ASK__.y
|
||||
#define W_YMENU GC_MENU_.y
|
||||
#define W_YINFO GC_INFO_.y
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Window border types
|
||||
|
||||
#define W_BBACK GC_BACK_.btype
|
||||
#define W_BSTAT GC_STAT_.btype
|
||||
#define W_BBRAG GC_BRAG_.btype
|
||||
#define W_BAREA GC_AREA_.btype
|
||||
#define W_BREAD GC_READ_.btype
|
||||
#define W_BHEAD GC_READ_.btype
|
||||
#define W_BASK GC_ASK__.btype
|
||||
#define W_BMENU GC_MENU_.btype
|
||||
#define W_BHELP GC_HELP_.btype
|
||||
#define W_BINFO GC_INFO_.btype
|
||||
#define W_BCFG GC_CFG_.btype
|
||||
#define W_BCFGB GC_CFGB_.btype
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Charset translation table structure
|
||||
|
||||
typedef byte ChsTab[4];
|
||||
|
||||
struct Chs {
|
||||
long id;
|
||||
int version;
|
||||
int level;
|
||||
XlatName imp; // From Charset
|
||||
XlatName exp; // To Charset
|
||||
ChsTab t[256]; // The Translation Table
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Escaped characters table structure
|
||||
|
||||
typedef byte EscTab[5];
|
||||
|
||||
struct Esc {
|
||||
XlatName exp; // To Charset
|
||||
byte esc; // Escape character
|
||||
int pos1; // Relative position of first character
|
||||
int pos2; // Relative position of last character
|
||||
uint size; // Number of escaped chars in table
|
||||
EscTab t[256]; // The Escaped Characters Table
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Charset mapping files
|
||||
|
||||
struct Map {
|
||||
XlatName imp; // From Charset
|
||||
XlatName exp; // To Charset
|
||||
char* mapfile; // Mapping file and timestamp
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
struct PosLen {
|
||||
int pos;
|
||||
int len;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
struct Ezycom {
|
||||
Path msgbasepath;
|
||||
Path userbasepath;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
struct Invalidate {
|
||||
std::pair<std::string, std::string> origin, seenby, tearline, cc, xc, xp;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
struct Semaphore {
|
||||
Path netscan;
|
||||
Path echoscan;
|
||||
Path exportlist;
|
||||
Path importlist;
|
||||
Path scanall;
|
||||
Path scanthis;
|
||||
Path scannetmail;
|
||||
Path pmscanall;
|
||||
Path pmscanthis;
|
||||
Path pmscannetmail;
|
||||
Path qwkimport;
|
||||
Path qwkexport;
|
||||
Path soupimport;
|
||||
Path soupexport;
|
||||
Path exitnow;
|
||||
|
||||
uint idletime;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
typedef char BarList[45];
|
||||
|
||||
struct FFblk {
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
int hour;
|
||||
int minute;
|
||||
int second;
|
||||
long size;
|
||||
Path name;
|
||||
bool selected; // Extra - YES/NO
|
||||
};
|
||||
|
||||
struct FileSpec {
|
||||
Path path; // Path to file(s)
|
||||
char password[20]; // File Password
|
||||
int files; // Number of files
|
||||
bool delsent; // Kill files after sent
|
||||
FFblk* fblk; // Filenames
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
const int RFCAddress = 1;
|
||||
const int RFCName = 2;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Message written by/to me/you ?
|
||||
|
||||
const uint TO_ME = 1;
|
||||
const uint BY_ME = 2;
|
||||
const uint TO_YOU = 4;
|
||||
const uint BY_YOU = 8;
|
||||
const uint TO_ALL = 16;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#if defined(GOLD_CANPACK)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#endif
|
@@ -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(); }
|
||||
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
@@ -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
|
||||
|
@@ -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) {
|
||||
|
@@ -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++) {
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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) );
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <gmemdbg.h>
|
||||
#include <gfile.h>
|
||||
#if defined(__GOLD_GUI__)
|
||||
#include <gvidall.h>
|
||||
#include <gvidgui.h>
|
||||
|
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <gmemdbg.h>
|
||||
#include <gfile.h>
|
||||
#include <gstrall.h>
|
||||
#if defined(__GOLD_GUI__)
|
||||
#include <gvidall.h>
|
||||
|
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <gmemdbg.h>
|
||||
#include <gfile.h>
|
||||
#include <gstrall.h>
|
||||
#if defined(__GOLD_GUI__)
|
||||
#include <gvidall.h>
|
||||
|
@@ -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
@@ -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;
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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++) {
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
@@ -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();
|
||||
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -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 -----
|
@@ -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
|
@@ -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;
|
||||
}
|
@@ -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
|
||||
}
|
@@ -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
|
@@ -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);
|
||||
}
|
@@ -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_ */
|
@@ -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_ */
|
@@ -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
|
@@ -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
|
@@ -1,9 +0,0 @@
|
||||
/* Completely rewritten */
|
||||
|
||||
#ifndef __TYPEDEFS_H__
|
||||
#define __TYPEDEFS_H__
|
||||
|
||||
#include <gdefs.h>
|
||||
#include <gctype.h>
|
||||
|
||||
#endif /*#ifndef __TYPEDEFS_H__*/
|
@@ -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
|
@@ -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
|
@@ -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
@@ -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 */
|
@@ -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
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user