/**************** txm.h *******************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <jctype.h>
#include <jstring.h>
#include <dos.h>
#include <io.h>
#include <fcntl.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <conio.h>
#include <time.h>
#ifdef LSI_C
#include <farstr.h>
#else
#include <malloc.h>
#endif

#define NUL '\0'
#define TAB 0x09
#define RET 0x0A
#define CR  0x0D
#define LF  0x0A
#define TRUE   1
#define FALSE  0

#define NORMAL 0
#define ERROR  2

#define VBUFSIZE  (16384)

union _LONG {
	struct SHORT {unsigned short l, h;} s;
	unsigned long x;
};

/* バージョン:01 */
typedef struct _MES_ATTRIBtag {
	short version; /* = 0x01 */
	short ext;
	unsigned short art;
	union _LONG ltime;
	short reserve1;
	short reserve2;
	short reserve3;
} MES_ATTRIB;

typedef struct _TXMtag {
	MES_ATTRIB mes[20];
} TXM;

/**** Global ****/
#if MAIN
char *txmdir;			/* 情報ファイル用ディレクトリ */
char *logfile;			/* マージ前ログファイル */
char *mfile;			/* 現在のマージファイル */
char *workfile;			/* 作業ファイル */
char *line1;			/* 読み込みラインバッファ1 */
char *line2;			/* 読み込みラインバッファ2 */
char *infofile;			/* 使用する情報ファイル名 */
TXM   info;				/* 情報ファイル構造体 */
char *mesname;			/* 現在の会議室名 */
char *work;				/* 作業場所 */
char *head1;			/* ログヘッダ1 */
char *head2;			/* ログヘッダ2 */
MES_ATTRIB *nowinfo;	/* 使用する構造体 */

int  nextmerge;			/* マージファイル更新条件(0:size/1:article/2:monthly)*/
long nextvalue;			/* nextmergeに対応した量 nextmerge==2の時無効 */
int  minrun;			/* 切り詰めサイズ */
int  maxrun;			/* 実行開始サイズ */
#ifdef HEAVY_CHECK
char log_mes1[41]   ="%%%/%%%   ***%%%%%  $$$$$$$$$$$$$$$$  ";
char log_mes2[42]   ="%%%%%/%%%%% ***%%%%%  $$$$$$$$$$$$$$$$ ";
#else
char log_mes1[35]   ="%%%/";
char log_mes2[42]   ="%%%%%/";
#endif
char log_hp[40]     ="%%%  [%%/%%/%% %%:%%]  ***%%%%%      ";

int  mesno;				/* 会議室番号 (特殊な場合･･･ PATIO:1 HP:2) */
int  hpflg;				/* ログファイルはHPだった=1 */

#else
#endif

extern char *txmdir;
extern char *logfile;
extern char *mfile;
extern char *workfile;
extern char *line1;
extern char *line2;
extern char *infofile;
extern TXM   info;
extern char *mesname;
extern char *work;
extern char *head1;
extern char *head2;
extern MES_ATTRIB *nowinfo;

extern int  nextmerge;
extern long nextvalue;
extern int  minrun;
extern int  maxrun;
#ifdef HEAVY_CHECK
extern char log_mes1[41];
extern char log_mes2[42];
#else
extern char log_mes1[35];
extern char log_mes2[42];
#endif

extern char log_hp[40];
extern int  mesno;
extern int  hpflg;

/** End of Extern **********************************************************/

void swchk(int count, char **val);
int  smerge(void);
int  matchstr(char *form, char *txtptr);
int  chkinfo(void);
int  saveinfo(void);
int  hpmerge();
int  forummerge();
char *makenewextname(char *org, char *new, char *ext);
int  accessdir(char *path);
int  fchknewmerge(char *buf1, char *buf2, FILE **fp);

