­ì©lµ{¦¡

W_OBJ.H
­ì©lÀɡа_©l
/*---------( W_OBJ.H     )--------------*/
#include   "alloc.h"
#include   "stdio.h"
#include   "stdlib.h"
#include   "mem.h"
#include   "string.h"
#include   "math.h"
#include   "io.h"
extern  int     _Cdecl _argc;
extern  char  **_Cdecl _argv;
typedef unsigned char  unchar;
typedef unsigned short unshort;
typedef unsigned int   unint;
/*---------------------------------------------------------------------------*/
typedef struct
{  int     X1,Y1,X2,Y2,TitleX;      /*TitleX¦bM.EXE·|¥Î¨ì*/
   char    *pBuff;                  /*µe­±Àx¦s°Ï«ü¼Ð*/
}  WINDOW  ;

WINDOW  *Uwo_Open(int X1, int Y1, int X2, int Y2);
void     Uwo_Save(WINDOW *Wo);
void     Uwo_Restore(WINDOW *Wo);
void     Uwo_Close(WINDOW *Wo);
void     Uwo_DrawBar(WINDOW *Wo,int attr,int clear,int shadow,int type); /*µe¤@¯x§Î¨Ã±N¯x§Î¤º²M¬°ªÅ¥Õ*/
#define  WDO(fn) {WINDOW *w;w=Uwo_Open(1,1,80,25);fn();Uwo_Close(w);}
/*---------------------------------------------------------------------------*/
typedef struct
{   WINDOW  *wo;          /* window ¤@«ß¥Ñ²Ä¤@¦æ¶}°_                 */
    int     x1,x2;        /* x1¬°¥ª®Ø,x2¬°¥k®Ø                       */
    char    **ptr1;       /* ¦s©ñ©Ò¦³Insªº¦r¦ê,search®É¤@«ß¦b¦¹°}¦C  */
    char    **ptr2;       /* ¦s©ñ²Å¦X±ø¥ó¦r¦ê©ÎMtPickªº«ü¼Ð          */
    unchar  sel[31];      /* ¿ï¾Ü±ø¥óªº¦r¦ê                          */
    int     sel_sw;       /* ¬O§_­n¿ï¾Ü±ø¥ó                          */
    int     FIND;         /* InsPtr§ä¨ì®É¬°ON,§_«h¬°OFF, ­ì ins      */
    int     max_row;      /* open­n¨D³Ì¤j¥i°t¸m¦r¦êªº¼Æ¶q            */
    int     mem_row;      /* ¤wadd,ins ¨ìptr1ªº¦r¦ê¼Æ¶q              */
    int     kcl;          /* KEY ªºªø«×(¤£§tNULL)                    */
    int     match_num;    /* ²Å¦XPick±ø¥óªº¼Æ¶q,,­ì no               */
    int     pno;          /* MtPick¿ï¨ìªº¼Æ¶q                        */
    int     top;          /* Åã¥Ü®Éªº³»ºÝ                            */
    int     bar;          /* ±N¥Ø«eªº¤Ï¥Õ´Î¦s°_¨Ó¨Ñ¤U¦¸¶i¤J¨Ï¥Î      */
    int     lock;         /* lock head number ¼Æ                     */
    unchar *pfmt;         /* «ü¦V¥¿½TªºUSprint()¦r¦ê®æ¦¡             */
    unchar *gfmt;         /* «ü¦V­ì©l¦r¦ê                            */
    int     handle;       /* Àˬd¬O§_¥i¥H¨Ï¥Î§_                      */
}   TEXT;

TEXT    *Utx_Open(int X1,int Y1,int X2,int Y2,int max_row,int kcl,int sel_sw);
void     Utx_Del(TEXT *tx,char *s);
int      Utx_Ins(TEXT *tx,char *fmt,...); /*¥¢±Ñ¶Ç¦^OFF,¦¨¥\¶Ç¦^ON*/
int      Utx_Add(TEXT *tx,char *fmt,...); /*¥¢±Ñ¶Ç¦^OFF,¦¨¥\¶Ç¦^²Ä´Xµ§*/
int      Utx_AddHead(TEXT *tx,char *fmt,...);
         /*«öENTER:RetKey=ENTER,Modify=ON,¶Ç¦^ON. «öESC:RetKey=NULL,¶Ç¦^OFF */
char    *Utx_Pick(TEXT *tx,char *buf,int x,int y,int len,char *title,int attr);
char   **Utx_MtPick(TEXT *tx,int no,char *title); /*¶Ç¦^«ü¼Ð°}¦C,·í°}¦C«ü¼Ð¬°NULLªí¥Üµ²§ô,Ãþ¦ü¦r¦ê*/
int      Utx_Chain(TEXT *tx,char *key,int x,int y,int len,int attr);
int      Utx_GetS(TEXT *tx,char *buf,char *key,int offset); /*keyªºªø«×»PUtx_Openªºkeyªø«×­n¤@¼Ë*/
void     Utx_View(TEXT *tx,char *title);
void     Utx_Close(TEXT *tx);
void     Utx_Sort(TEXT *Tx,char *fmt,int sw);  /*sw=ON¥Ñ¤p¨ì¤j,OFF¥Ñ¤j¨ì¤p*/
TEXT    *Utx_SetMemo(int X1,int Y1,int X2,int Y2,int kln,char *fn);
        /*¥þ³¡­n¶Ç¤J¦ì§}(&),fmtùØÀ³«ü©úint(I),long(L),float(F),double(D)... µ¥*/
int      Utx_GetFmt(TEXT *tx,unchar *str,unchar *fmt,...);    /*¤é´Á,¼Æ­È¥Î&*/
int      Utx_Strstr(TEXT *tx,char *buf,char *key,int offset); /*±qÀY¨ì§À·j´M¦³§tkeyªº¦r¦ê,keyªø«×¤£­­¨î*/
/*---------------------------------------------------------------------------*/
typedef struct
{   int      ffd;         /* Viewªºfile handle                   */
    int      col;         /* ¨C¦C³Ì¤j¦æ¼Æ                        */
    int      lcol;        /* ¥ªÃä lock colom byte¼Æ              */
    int      ncol;        /* ¥Ø«eªºoffset­È                      */
    int      scol;        /* display ¥X¨Óªºbyte¼Æ(lcol+mcol+spc) */
    int      mcol;        /* ³]©w«á¥b³¡move  byte¼Æ              */
    long     row;         /* ³Ì¤j¦C¼Æ(§t¥xÀY)                    */
    int      lrow;        /* ¥­¤ôlock¦C¼Æ                        */
    int      srow;        /* ¿Ã¥Ø³Ì¤j¦C¼Æ(¤£§t¥xÀY)              */
    long     nrow;        /* ¥Ø«eªºrow¦b²Ä´X¦C(§t¥xÀY)           */
    int      lhed;        /* ¬O§_Âê¼ÐÀY                          */
    int      itm;         /*0¥Î¥H§PÂ_¬O§_¤wSetRptItem(¦bUPrint()¤¤) ¬G0¤£¥Î,¥Ñ1ºâ°_,¾î¦V³Ì¦h¥i¦³40²Õitem */
    int      litm;        /* lock item ¶µ¼Æ,¥Ñ1ºâ°_              */
    int      sitm;        /* ¥Ø«e«á¥b³¡°_©litem¶µ,¥Ñ0ºâ°_        */
    int      eitm;        /* ¥Ø«e«á¥b³¡µ²§ôitem¶µ,¥Ñ0ºâ°_        */
    int      x[41],n[41]; /* 0¤£¥Î,¥Ñ1ºâ°_,¦@¦³40²Õ              */
    char    *pHead;
    char    *pVirt;
}  VIEW    ;              /* ±M¨Ñreport¥Î                        */

void     LockItemHead(int litm,char *s1,char *n,char *s2);
void     LineReturn(int nextpage);
/*---------------------------------------------------------------------------*/
typedef struct
{   char    *ffn;         /* ¥DÀÉÀɦW                     */
    int      ffd;         /* ¥DÀɪºfile handle            */
    int      frl;         /* ¥DÀɪº°O¿ýªø«×               */

    char    *kfn;         /* ¯Á¤ÞÀɦW                     */
    int      kfd;         /* ¯Á¤ÞÀɪºfile handle          */
    int      krl;         /* ¯Á¤ÞÀɪº¸ê®Æªø«×             */
    int      kcl;         /* ¯Á¤ÞÀɪº¤ñ¸ûªø«×(§tNULL)     */
    int      desh;        /* desh ¦³´XBYTE                */
    int      kmk;         /* kcl-desh-1(main key ªø)      */
    int      kpl;         /* ¯Á¤ÞÀɪº«ü¼Ðªø«×(2,3)        */

    char    *krb;         /* ¯Á¤ÞÀɪºKEY½w½Ä°Ï            */
    long     kip;         /* ¯Á¤ÞÀɤ¤«ü¦V¥DÀɪº²Äkip µ§   */
    long     ksr;         /* ¦Û¯Á¤ÞÀɤ¤§ä¨ìªº²Ä ksr µ§    */
    int      wrk;         /* ¬O§_¬° work file ¼È®ÉÀÉ      */
    int      handle;      /* Àˬd¬O§_¤w¸g¥i¥H¨Ï¥Î¤F(7632) */

    char     hasbuf;      /* 0µLBuffer,1:¦³¥Bflush­n¼g¤J,2:¦³¦ýflush¤£¼g¤J */
    void   **ptr;         /* ¦³¥ÎBuffer®ÉªºRecord«ü¼Ð     */
    int      max_row;     /* ¦³¥ÎBuffer®É³Ì¦h¥i°t¸m¼Æ¥Ø   */
    int      mem_row;     /* ¦³¥ÎBuffer®Émemùز{¦³¼Æ¥Ø    */

    int      net_sw;      /* ºô¸ôÀÉ®×±±¨î§_               */
    int      net_fd;      /* ºô¸ô¤½¥ÎÀÉ®×                 */
    char     net_fn[24];  /* ºô¸ôLOGÀɦW                  */
    unchar   net_lk[16];  /* read®É³Ì«áµn¿ý               */
}  FKIP;

#define  FKMAXBUF  16384  /* FKIP Ins & Del ®É¨C¦¸·h°ÊªºBuffer*/
#define  NETBUF    256
void     Ufk_NetOnlyRW(FKIP *Fk,int sw);/*±MÄݦs¨úÀÉ,¼È®É¦û¾Ú¸ÓÀÉ,¥H¶i¦æUpdate,°Ñ¦ÒFSOCP011.c¡]¢°¡^*/
void     Ufk_NetLogKey(FKIP *Fk,unchar *key);/*¤£³z¹LUfk_Readª½±µºM¾P¨Ãµn¿ý·sKEY,°Ñ¦ÒFSBMP041.c¡]¢±¡^*/
void     Ufk_ViewNetLog(FKIP *Fk);         /*¬d¬Ýºô¸ôªºLOGÀÉ*/

void     Ufk_Close(FKIP *Fk);
long     Ufk_Del(FKIP *Fk,void *Buf);  /*¶Ç¦^del²Ä´Xµ§*/
void     Ufk_Flush(FKIP *Fk);
void     Ufk_NotFlush(FKIP *Fk); /*1:­nflush,2:¤£flush,¥»¨ç¦¡³]©w¤£flush*/
void     Ufk_InsKey(FKIP *Fk,void *Buf);
void     Ufk_LockFile(FKIP *fk,char *doc);    /*±NÀɮץѦ@¥ÎÂର±M¥Î*/
FKIP    *Ufk_Open(char *ffn,int frl,int kcl,int desh,int kpl);
int      Ufk_PgUD(FKIP *Fk,char *bufS); /*­YPGDN¶W¹LÀɧÀ«h*bufS==NULL*/
int      Condition();
void     Ufk_Pack(FKIP *Fk,void *Buf,int (*Condition)());
int      Ufk_Read(FKIP *Fk,void *Buf,char *Key); /*¥¢±Ñ¶Ç¦^OFF,¥¿½T¶Ç¦^ON*/
#define  Ufk_Chain(b,s) if(Ufk_Read(b##K,&b,s)==0) memset(&b,NULL,sizeof(b))
int      Ufk_Search(FKIP *Fk,char *Str);
int      Ufk_SeqRead(FKIP *Fk,void *Buf,char *k1,char *k2); /*EOF:ÀÉ®×µ²§ô,ON:Ū¤J¦¨¥\,OFF:¤£¦bk1,k2½d³ò¤§¤º*/
int      Ufk_SetBuf(FKIP *Fk);  /*¶Ç¦^°t¸mªº¼Æ¶q,¨Ï¥Î«á­n©I¥sUfk_Flush()¤~¥¿½T*/
long     Ufk_Write(FKIP *Fk,void *Buf);    /*¶Ç¦^write²Ä´Xµ§*/
int      Ufk_ReadLast(FKIP *Fk,char *Key); /*±N¤W¦¸ªºKEY­È¦ÛLAST_IPÀÉŪ¤J¨ìKey*/
void     Ufk_WriteLast(FKIP *Fk);          /*±N³Ì«á¼g¤JªºKEY­È¦s¤JLAST_IPÀɸÌ*/
#define  Ufk_RecNo(f) (filelength(f->kfd)/f->krl) /*¶Ç¦^¥Ø«e¸ê®Æµ§¼Æ*/
#define  READ2  }}free(pp);}
#define  WRITE1 }lseek(fd,frl*ll,SEEK_SET);write(fd,pp,frl*rr);}free(pp);}
#define  READ1(f) READ1_T(f##K,FS##f##_T)
#define  READ1_T(fk,type) {long tt,nn,rr,jj,ll;int fd=fk->ffd,frl=fk->frl;type *p,*pp;tt=filelength(fd)/frl;nn=65520U/frl;\
         if((pp=malloc(nn*frl))==NULL){nn=32;if((pp=malloc(nn*frl))==NULL) UFatal("READ1 mem");}lseek(fd,0L,SEEK_SET);\
         for(ll=L=0;tt>0;tt-=rr,ll+=rr){if(tt>=nn) rr=nn;else rr=tt;read(fd,pp,frl*rr);for(p=pp,jj=0;jj<rr;jj++,p++,L++){if(p->KEY[0]<=SPACE) continue;
/*---------------------------------------------------------------------------*/
typedef struct
{   char    **key;        /* ¦s ¤J ªº ¦r ¦ê                            */
    long     *ip;         /* ¦s ¤J ªº «ü ¼Ð                            */
    int       fd1;        /* open tmp file for file split buffer       */
    FILE     *fp1;
    int       fd2;        /* open tmp file for file split buffer       */
    FILE     *fp2;
    int       kcl;        /* ´¡¤Jkeyªºªø(§tNULL)                       */
    int       mem_row;    /* ±Æ §Ç «á ªº ip & ¦r¦ê«ü¼Ð¼Æ               */
    long      all_row;    /* Á`¦@±Æ¦Cªºµ§¼Æ                            */
    long      now;        /* ªì­È¬°0L,¥H«á¨C¦¸Usp_GetIp()«h¥[1         */
    int       free_key;   /* ­Y ¦³ Usp_GetIp «h ON                     */
    int       dec_sw;     /* ¨Ì»¼´î±Æ§Ç                                */
    int       disk;       /* ­YµLSORT¨ìDISK«hOFF,¦bGetIp,Close®É¦³¥Î¨ì */
    int       handle;     /* ÀË ¬d ¬O §_ ¤w ¸g ¥i ¥H ¨Ï ¥Î ¤F(7632)    */
} SORTIP;

SORTIP  *Usp_Open();
void     Usp_Dec(SORTIP *Sp);                 /*¤º©w­È¬°»¼¼W,¥»¨ç¼Æ³]©w¬°»¼´î*/
int      Usp_InsIp(SORTIP *Sp,char *key,long ip);/*¶Ç¤JKey(»Ý©T©wªø«×),¤Îip­È*/
int      Usp_GetIp(SORTIP *Sp,long *ip);  /*¨ÌKey¦¸§Ç¨ú¥X¨äip­È,¥¢±Ñ®É¶Ç¦^OFF*/
                                          /*¨Ã±N¤U¤@µ§ªºKEY­È¹w¥ý¦s¤JNkey©Ò«ü*/
/*---------------------------------------------------------------------------*/
typedef struct
{  unint  Y:7 ;  /* 82.08.31 = FC52 = 11111 1000 1010010, RAM¦s®É,¥i¯à²Ä1byte=0*/
   unint  M:4 ;  /* 82.09.02 = 14D2 = 00010 1001 1010010,         (·í¦~=0,¤ë>1)*/
   unint  D:5 ;  /* M©ÎD¬°0ªí¥Ü¿ù»~*/
} DATE;

DATE     UAsc2Date(char *pStr);          /*±NYY.MM.DD®æ¦¡ªº¤é´ÁÂରDATE«¬ºA*/
long     UDiffDate(DATE Start, DATE End);/*­pºâStart¨ìEnd¬Û®t´X¤Ñ          */
DATE     UGetM(void);                    /*¨ú±o¹q¸£¥Ø«e¤é´Á                */
DATE     UGetLastM(void);                /*¨ú±o¹q¸£¤W­Ó¤ëªº¤é´Á            */
long     UHowDate(DATE day);             /*¶Ç¦^¦Û¦è¤¸0¦~¨ìdayªº¤Ñ¼Æ        */
void     UShowM(int X,int Y,int len,DATE Date,int attr);
int      UReadM(int X,int Y,int len,DATE *day,int locate,int attr_off,int attr);
 /* len : 5   ¦A¥ÑChrist§PÂ_¬°"¦~.¤ë",¤é«h¬°1,   ©Î"¤ë/¤é",¦~«h¬°127
    flag: 0-7 ªí¥Ü­nÀˬd¤é´Á¬O§_¥¿½T,¥B¦b UReadM()¦Û°ÊŪ¨ú¨t²Î¤é´Á,¥B©w´å¼Ð
    flag: 8   ªí¥Ü­nÀˬd¤é´Á¬O§_¥¿½T,¥B¦b UReadM()¦Û°ÊŪ¨ú¤W¦¸¿é¤J¤§Â¤é´Á,
    flag: 9   ªí¥Ü¦b UReadM() ®É¤£¦Û°ÊÅã¥Ü¨t²Î¤é´Á,¥i¤£¿é¤J,­Y¤é´Á¿ù»~«h¤£Åã¥Ü¤é´Á
    flag: 10  ªí¥Ü¦b­nÀˬd¤é´Á¬O§_¥¿½T,¥B¦b UReadM() ®É¦Û°ÊŪ¨ú(¦è¤¸)¨t²Î¤é´Á
    flag: < 0 ªí¥Ü­nÀˬd¤é´Á,¤@©w­n¿é¤J,¦ý¦b UReadM() ®É¤£¦Û°ÊÅã¥Ü¨t²Î¤é´Á
 */
int      UMidDate(DATE S,DATE M,DATE E); /*M¤¶©óS,E¤§¶¡,¥¢±Ñ¶Ç¦^OFF        */
DATE     UAddDate(DATE Date, long n, int today);    /*¥[¤J¤Ñ¼Æ*/
         /*today=0·í¤Ñ¤£ºâ 10¤ë5¤é + 1¤Ñ = 10¤ë6¤é  */
         /*today=1·í¤Ñºâ   10¤ë5¤é + 1¤Ñ = 10¤ë5¤é  */
DATE     USubDate(DATE Date, long n, int today);    /*´î±¼¤Ñ¼Æ*/
         /*TODAY=0·í¤Ñ¤£ºâ 10¤ë5¤é - 1¤Ñ = 10¤ë4¤é  */
         /*TODAY=1·í¤Ñºâ   10¤ë5¤é - 1¤Ñ = 10¤ë5¤é  */
/*---------------------------------------------------------------------------*/
typedef struct
{  unint  H:5 ;
   unint  M:6 ;
   unint  F:1 ;    /* ON¬°¥¿½T,OFF¬°¿ù»~*/
} TIME;

int  UReadT(int X,int Y,int len,TIME *t,int flag,int attr_off,int attr);
void UShowT(int X,int Y,int len,TIME Time,int attr);      /* modify 93/04/17 */
TIME UDiffTim2(TIME Start, TIME End);     /*­pºâStart¨ìEnd¬Û®t´X®É,´X¤À*/
TIME UDiffTim3(TIME Start, TIME End, TIME Rest);     /*­pºâStart¨ìEnd,¦AÕç¥ð®§,¬Û®t´X®É,´X¤À*/
TIME UAddTime(TIME t1,TIME t2);  /*®É¶¡¬Û¥[*/
TIME USubTime(TIME t1,TIME t2);  /*®É¶¡¬Û´î*/
/*-----------------------------------------------------------------*/
#define OFF         0                 /* set cursor disappear                */
#define BIG         -1                /* set cursor style big, insert mode   */
#define SMALL       1                 /* set cursor style small, replace mode*/

void USetCursor(int Status);  /*³]©w´å¼Ð¥¿±`,©ñ¤j,®ø¥¢*/
/*---------------------------------------------------------------------------*/
void     Ugr_Open(char typ,int x,int up,double base);
void     Ugr_Qty(char *s,double  *f);
void     Ugr_Head(char *s);
void     Ugr_MtHead(char *s,...);
void     Ugr_View(int sw);            /*¬O§_³]¥­§¡½u*/
/*---------------------------------------------------------------------------*/
void     UFatal(char *fmt,...);    /*Åã¥Ü¿ù»~°T®§¨Ãµ²§ôµ{¦¡      */
void     Ugd_Open(char *fmt,...);  /*¥H°ïÅ|¤è¦¡¦b²Ä25¦CÅã¥Ü°T®§  */
unchar   UGetC(int X,int Y);
FILE    *USetTmpFp(char *mode,char *fn);  /*¶Ç¦^Àɮתº«ü¼Ð,¤Î¨äÀɦW*/
unshort  UGetKb(void);
char    *UGetName(char *a);
void     UGetS(int X,int Y,int len,char *p);
void     UPrint(char *fmt,...); /*¨ÌPsfÅܼƱN¦r¦ê¿é¥X¨ì¬Û¹ï¸ê®Æ¬y¥h*/
void     USprint(char *buf,char *fmt,...);
void     UWait(int bell,char *fmt,...); /*Åã¥Ü°T®§,¨Ã¦ÛÁä½L¨ú±o¤@¦r¦s¤JRetKey*/
/*---------------------------------------------------------------------------*/
#define  DEC       7
#define  COMA      8         /* for long int has Comma        */
#define  ZERO      16        /* if number is 0 then show 0    */
#define  MONEY     32        /* if has MONEY flag show '$'    */
#define  OFF       0
#define  ON        1
#define  SPACE     32
#define  F3        0x3D00
#define  F4        0x3E00
#define  F5        0x3F00
#define  F6        0x4000
#define  F7        0x4100
#define  F8        0x4200
#define  F9        0x4300
#define  F10       0x4400
#define  HOME      0x4700
#define  END       0x4F00
#define  INS       0x5200
#define  DEL       0x5300
#define  PGUP      0x4900
#define  PGDN      0x5100
#define  UP        0x4800
#define  DOWN      0x5000
#define  LEFT      0x4B00
#define  RIGHT     0x4D00
#define  ENTER     0x1C0D
#define  BACK      0x0E08
#define  ESC       0x011B
#define  TAB       0x0F09
#define  C_F1      0x5E00
#define  C_F2      0x5F00
#define  C_F3      0x6000
#define  C_F4      0x6100
#define  C_F5      0x6200
#define  C_F6      0x6300
#define  C_F8      0x6500
#define  C_F9      0x6600
#define  C_F10     0x6700
#define  C_LEFT    0x7300
#define  C_RIGHT   0x7400
#define  C_PGUP    0x7200    /* ­ì¬° 0x8400 */
#define  C_PGDN    0x7600
#define  C_HOME    0x7700
#define  C_END     0x7500
#define  C_ENTER   0x1C0A
#define  C_BACK    0x0E7F
#define  S_TAB     0x0F00
#define  A_A       0x1E00
#define  A_B       0x3000
#define  A_C       0x2E00
#define  A_D       0x2000
#define  A_E       0x1200
#define  A_F       0x2100
#define  A_G       0x2200
#define  A_H       0x2300
#define  A_I       0x1700
#define  A_J       0x2400
#define  A_K       0x2500
#define  A_L       0x2600
#define  A_M       0x3200
#define  A_N       0x3100
#define  A_O       0x1800
#define  A_P       0x1900
#define  A_Q       0x1000
#define  A_R       0x1300
#define  A_S       0x1F00
#define  A_T       0x1400
#define  A_U       0x1600
#define  A_V       0x2F00
#define  A_W       0x1100
#define  A_X       0x2D00
#define  A_Y       0x1500
#define  A_Z       0x2C00
#define  A_F1      0x6800
#define  A_F2      0x6900
#define  A_F3      0x6A00
#define  A_F4      0x6B00
#define  A_F5      0x6C00
#define  A_F6      0x6D00
#define  A_F7      0x6E00
#define  A_F8      0x6F00
#define  A_F9      0x7000
#define  A_F10     0x7100
#define  beep()    putch(7)
#define  XN(r)     X[r],y,N[r]
#define  XY(r)     X[r],y
#define  XL(s,e)   X[s],y,X[e]+N[e]-X[s]
#define  BXN(r)    BX[r],BY[r],BN[r]  /* for USetBXYN() */
#define  MAX_FIELD     100           /* for BX[],BY[],BN[] */
#define  UClsTable(x1,y1,x2,y2,attr)   UScroll(0,x1,y1,x2,y2,attr)
#define  UClsField(x,y,len,attr)  UScroll(0,x,y,x+len-1,y,attr)
#define  UCls()                   UScroll(0,1,3,80,24,V_SHOW)
#define  s_open(fn) sopen(fn,4|0x0100|0x8000,0x0040,0x0100|0x0080);  /*¥ÎfopenªÌ,ºô¸ôª©§¡¥H¦¹¨ú¥N¡]¢²¡^*/
#define  ShowNullLine(y)  UShowSL(3,y,76,&Table[(SNO-4)*76],V_SHOW)  /*²M¤@¦C*/
/*---------------------------------------------------------------------------*/
#ifdef MAIN
    unshort  RetKey;
    int      Modify;       /*Ū¥X¸ê®Æ®É­n³]¬°OFF,¸ê®Æ­Y¦³³Q§ó°Ê«h¬°ON.»Ý¼g¤J*/
    int      Field=1,OffSet=0,Cter,I;
    int      X[20],N[20]; /*¥HSetXN()¨ç¼Æ³]©w¿é¤JÄæ¦ìªºX.len,¨Ã±`»PXN()¥¨¶°¨Ö¥Î*/
    int      NetWare,NetWritAble;             /*¬O§_ºô¸ôª©,¬O§_¦³Åv¼g¤J¸ê®Æ*/
    int      P0,P1,K0,K1; /*¦C¦L³øªí±±¨îÅܼÆ,P0­¶¼Æ,P1°¸¼Æ¸õ­¶,K0¦C¼Æ,K1³Ì¤j¦C¼Æ*/
    int      DiskRec,Update=OFF;                       /*¨ÑWrite1Page¨Ï¥Î  */
    long     L;                                        /*±`¥Îªºªø¾ã¼ÆÅÜ¼Æ  */
    unchar   BufS[320],TmpS[320],TmpFn[32];            /*±`¥Îªº¦r¦êÅÜ¼Æ    */
    unchar   *Str,*Lkey,*Nkey,*RptHd,*NamS;            /*¨Ï¥Î¨t²Îªº¤½¥q¦WºÙ*/
    unchar   Psf2,Psf;  /*UPrint¨ÌPsfÅܼƱN¦r¦ê¿é¥X¨ì S¿Ã¹õ,P¦Lªí¾÷,f.VÀÉ®×*/
    unchar   LastKey[32],SelKey[32],Skey[24],Ekey[24]; /*³øªí±`¥Îªº¦r¦êÅܼÆ*/
    DATE     Sday,Eday,Day;                            /*±`¥Îªº¤é´ÁÅÜ¼Æ    */
    VIEW     Vw;
    SORTIP  *Sp;
    TEXT    *Tx;
    FILE    *Stream;
    WINDOW  *Wo;
    FKIP    *WORKK;
    #define  OPEN_WORK WORKK=Ufk_Open("WORKFILE",sizeof(WORK),sizeof(WORK.KEY),0,2);Ufk_SetBuf(WORKK)
    int      HasRead=OFF;
    int      BX[MAX_FIELD],BY[MAX_FIELD],BN[MAX_FIELD];   /* 0¤£¥Î,¥Ñ1ºâ°_,¦@¦³MAX_FIELD-1²Õ,°t¦XBXN(r)¨Ï¥Î */
    int      SR;                                          /* ¦Û°Ê­pºâ */
    int      Christ=OFF;      /*ON=¦è¤¸,OFF=¥Á°ê*/
    int      CURSOR=SMALL;    /* set cursor style small, replace mode*/
    unint    KbMode;          /*Áä½L­ì©l­È*/
    int      OldSec;          /*CLOCK(),°O¿ý¬í¥Î*/
    unint    Click;           /*CLOCK(),°O¿ý¶i¤J¦¸¼Æ¥Î*/
    unchar   Pe2=OFF;         /*«öAlt-P,«h¥Ñ PE2 ¦L¥X*/
#endif
/*===========================================================================*/
/*===========================================================================*/
/*===========================================================================*/
/*---------( W_PROTO.UTL )--------------*/
/* "­ì«¬«Å§i" ¤Î ¨ä¥i¯à¨Ï¥Î¤§ "¤½¥ÎÅܼƭÈ" ¤Î "#define" ­È

/*-----------------------------------------------------------------*/
#define COMPANY_ROW 1
#define TITLE_ROW   2                 /* screen from 1 .. 25 row */
#define ITEM_ROW    3
#define STATUS_ROW  25                /* screen from 1 .. 25 row */
/*---------*/
#define NO          0
#define YES         1

/*-----------------------------------------------------------------*/
#define  ET_CURSOR_TRAN    'T'  /* cousor move transparant, Chiness skip 2 byte */
#define  ET_CHINESS        'C'  /* force use previous Chiness input method */
#define  ET_ENGLISH        'N'  /* force use English input method */
#define  ET_CHANGJEI       '1'  /* use Changjei method input Chiness */
#define  ET_SAMPLY         '2'  /* use samply method input Chiness */
#define  ET_PHONETIC       '3'  /* use samply method input Chiness */

void UETKbSet(char set_key);
/*-----------------------------------------------------------------*/
#define  KB_GET      1           /*°O¿ý­ì©l­È*/
#define  KB_SET      2           /*Num Lock=ON,Caps Lock=¤j¼g*/
#define  KB_RET      3           /*¦^´_­ì©l­È*/

void USetKbFlag(int sw);
/*-----------------------------------------------------------------*/
#define  MONO_MODE   0                  /*if is MONO display */
#define  VGA_MODE    1                  /*if is VGA display  */
typedef  char far    *V_PTR;

#ifdef   MAIN
   int      VIDEO = VGA_MODE;
   V_PTR    video_base = (V_PTR) 0xb8000000;          /* ¤º©w VGA displey */
   int      RIBBON = ON;                      /*Clock()¥Î,ON=¶]¦â,OFF=¤£¶]*/
   char     ET_PICK[4]="CL0";           /*¤¤¤å="CL0",­^¤å="NL0",±±¨î¿é¤Jªk*/
#else
   extern   int   VIDEO;
   extern   V_PTR video_base;
#endif

void ChkVideo();                       /*´ú¦¡³æ¦â©Î±m¦â¿Ã¹õ */
/*-----------------------------------------------------------------*/
#define B_W               7
#define HB_W              15           /*High light*/
#define XB_W              120          /*Invert*/
#define FB_W              240          /*Flash*/

#define V_BLUE            (VIDEO) ? 11 : B_W   /*  UDrawBox() frame color */
#define V_BOARD           (VIDEO) ? 46 : B_W   /* 19                  */
#define V_CALC_BOX        (VIDEO) ? 91 : XB_W  /*  for calcurate      */
#define V_CALC_IN         (VIDEO) ? 63 : XB_W  /*  for calcurate      */
#define V_CALC            (VIDEO) ? 79 :  B_W  /* for calcurate       */
#define V_COMPANY         (VIDEO) ? 46 : HB_W  /* company title line  */
#define V_COPY            (VIDEO) ? 206: FB_W  /*  for A_C copy string  */
#define V_CREATE          (VIDEO) ? 63 : HB_W  /*  the reacord is new  */
#define V_DATE            (VIDEO) ? 43 : HB_W  /* title line date     */
#define V_DOS             (VIDEO) ? B_W: B_W   /* return DOS          */
#define V_EDIT            (VIDEO) ? 78 : XB_W  /*  the record is old   */
#define V_EXE_ITEM        (VIDEO) ? 94 : XB_W  /* execute ITEM string */
#define V_EXPRESS         (VIDEO) ? 91 : XB_W  /*  for Express */
#define V_GREEN           (VIDEO) ? 10 : HB_W  /*  for Express */
#define V_ITEM_ON         (VIDEO) ? 110: XB_W  /* item name active    */
#define V_ITEM_OFF        (VIDEO) ? 63 : B_W   /* item name inactive  */
#define V_IDX_IN          (VIDEO) ? 30 : B_W   /* index pick_box inside */
#define V_MENU            (VIDEO) ? 94 : B_W   /* window frame        */
#define V_MONTH           (VIDEO) ? 62 : XB_W  /* for calandar        */
#define V_MODIFY          (VIDEO) ? 206: FB_W  /* for calandar        */
#define V_READ            (VIDEO) ? 30 : XB_W  /* 46  for READ function  */
#define V_READ_F          (VIDEO) ? 174: 240   /*  for READ function  */
#define V_RED_F           (VIDEO) ? 207: 240   /*  for < 0 flash color  */
#define V_SHOW            (VIDEO) ? 15 : B_W   /*  for SHOW function  */
#define V_STATUS          (VIDEO) ? 107: XB_W  /* bottom status line  */
#define V_SYMBLE          (VIDEO) ? 238: 240   /*  for Symble  */
#define V_TABLE           (VIDEO) ? 11 : B_W   /*  table */
#define V_TIME            (VIDEO) ? 47 : HB_W  /* title line time     */
#define V_TITLE_ON        (VIDEO) ? 94 : B_W   /* title name active   */
#define V_TITLE_OFF       (VIDEO) ? 127: XB_W  /* title name inactive */
#define V_TOG             (VIDEO) ? 78 : XB_W  /*  UReadTog()  */
#define V_TX_READ         (VIDEO) ? 78 : XB_W  /*  active bar */
#define V_TX_SHOW         (VIDEO) ? 95 :  B_W  /*  inactive bar */
#define V_TX_SEL          (VIDEO) ? 94 : HB_W  /*  inactive bar */
#define V_TX_VIEW         (VIDEO) ? 30 : XB_W  /*  inactive bar */
#define V_W_IN            (VIDEO) ? 91 :  B_W  /* window in_side attr */
#define V_WARNING         (VIDEO) ? 203: 240   /* warning message     */
#define V_WBOX            (VIDEO) ? 123: XB_W  /* frame color */
#define V_WUSR            (VIDEO) ? 95 : HB_W  /* window in_side string attr */
#define V_YELLOW          (VIDEO) ? 14 : B_W   /*  UDrawBox() frame color */

void  UScroll(int sw,int x1,int y1,int x2,int y2,char attr);  /* sw=UP,DOWN or 0(cls screen) */
void  USetColor(int X, int Y, int len, int color);             /*§ïÅÜÃC¦âÄÝ©Ê*/
void  UShowSL(int X,int Y,int len,char *s,int attr);
void  UShowFD(int X,int Y,int len,double DoubleNum,char *FlagS,int attr);
void  UShowS(int X,int Y,char *s,int attr);
void  UShowC(int X,int Y,int len,char c,int attr);
void  UShowI(int X,int Y,int len,int IntNum, char *FlagS,int attr);
void  UShowD(int X,int Y,int len,double D  , char *flag ,int attr);
void  UShowF(int X,int Y,int len,float F,char *flag,int attr);
void  UShowL(int X,int Y,int len,long L,char *flag,int attr);
double  UReadFD(int X, int Y, int len,char *FlagS,int attr_off, int attr);
int   UReadS(int X,int Y,int len,char *Pstr,char *flagS,int attr_off,int attr);
int   UReadD(int X,int Y,int len,double *pD,char *flagS,int attr_off,int attr);
int   UReadF(int X,int Y,int len,float *pF ,char *flagS,int attr_off,int attr);
int   UReadI(int X,int Y,int len,int *pI   ,char *flagS,int attr_off,int attr);
int   UReadL(int X,int Y,int len,long  *pL ,char *flagS,int attr_off,int attr);
int   UReadV(int X,int Y,int len,unchar *s,int truelen,char *flagS,int attr_off,int attr);
int   UReadC(int X,int Y,int len,char *c, char *flagS,int attr_off,int attr);
#define  UShowV(x,y,l,s,a,b)  UShowSL(x,y,l,s,V_SHOW)
void  UShowTable(int X1,int Y1,int X2,int Y2,char *s,int attr);
/*================================================================*/
void UClKbBuf();                /*²M°£Áä½L½w½Ä°Ï¸Ìªº¸ê®Æ*/
int  UClock();                  /*¶Ç¦^­ÈYES=¦P¬í,NO=¤£¦P¬í*/
void UInitSys();                /* Initial system,(ChkVideo,SetKb,...)  */
void UVsprint(char *buf,char *fmt,va_list ap);
void UShiftString(unchar str[],int len,char *flagS);
void SetRptItem(char *p);
void UExtract(char bufS[]);               /* ¥h±¼«D¼Æ¦r¦r¤¸ */
void Read1Page();
void Write1Page();
void Show1Page();
void ShowHead();
int  UReadTog(int X, int Y,int leng,char *Pc, int attr, char *flags, ...);
void UTime(int i,int sw);                 /*(0,OFF)=¶}©l,(1,ON)=µ²§ô¹Í*/
void UF1Help(char *FileName);
int  USetBXYN(char *Table, int SX, int SY, int SC);
void USetMtXN(int lock,int lino,char *fmt,int sno,int cno);  /*(­nÂê´XÄæ,Fmt¦@¦³´X¦C,Fmt«ü¼Ð(­n¿é¤J'---',¤£¿é¤J'==='),SNO,CNO)*/
int  IndexHelp(int fd,int DispLeng,int GetLeng,char *mode,char *buf,char *wbuf,char *title);
double  Out4In5(double f,int p);    /*p=precision,ºë½T«×,0=¥þ¾ã¼Æ,1=¤p¼Æ1¦ì*/
void UPrnCtrl(char *s,...);       /*°e¥X±±¨î½X,¨Ãºâ¥XL¦C¶Z,¤Î¦r°ª,¦bNextPage()¤¤*/
void NextPage(void);              /*·sª©,¤£¥Î¤Þ¼Æ,95/1/25*/
void NextLabel(int tot);          /*¼ÐÅÒ¥Î,tot=¼ÐÅÒ°ª«×,96/6/26*/
­ì©lÀɡе²§ô

Byron Wey¡@¡@Oct.21.1998


¦^­º­¶¡D¢Ñ¤§«°