/* ***** WTPPN.H -- Header for WTPPN.C ***** */ /* ===== CONSTANTS ===== */ #if defined(WIZTERM) #define PPN_FG BLACK /* foreground for PPN display */ #define PPN_BG LIGHTGRAY /* background for PPN display */ #endif #define PPNFILENAME "wtnotes.dat" #define TMPFILENAME "wtnotes.tmp" #define BAKFILENAME "wtnotes.bak" #define FIXFILENAME "wtnotes.fix" #define NAME_LEN 9 /* # of chars in user name */ #define UID_LEN1 6 /* # of chars before comma in uid */ #define UID_LEN2 4 /* # of chars after comma in uid */ #define UID_LEN (UID_LEN1 + 1 + UID_LEN2) #define CDATE_LEN 6 /* length of "YYMMDD" */ /*********************/ /* ***** TYPES ***** */ /*********************/ typedef struct user { char uid[UID_LEN]; char name[NAME_LEN]; char mxlv; } t_user; typedef char cdate[CDATE_LEN+1]; typedef int cmpfunc(const void *ptr1, const void *ptr2); typedef struct ppnrec { t_user user; char date1[CDATE_LEN]; char date2[CDATE_LEN]; char crlf[2]; } t_ppnrec; #define l_ppnrec (sizeof(t_ppnrec)) /**************************/ /* ***** PROTOTYPES ***** */ /**************************/ #if defined(WIZTERM) void ppn_exi(void); void ppn_init(void); void ppn_lookup(char *id); void ppn_position(int where); #endif int cmp_by_name(const void far *uitem1, const void far *uitem2); int cmp_by_uids(const void far *uitem1, const void far *uitem2); /********************************/ /* ***** COMMON FUNCTIONS ***** */ /********************************/ /* ** It may seem strange to define coding in a header file, where ** it could be in an OBJ to be shared by multiple programs. ** But WizTerm and WizWho are routinely built in different ** memory models, meaning that the OBJ could not be re-used ** without re-compiling. Having the common code in a .H file ** means the identical code will be included in all programs that ** need it, with no memory model hassles. */ #if defined(PPNFUNC) /**********************************************************/ /* cmp_by_name(): compare two t_user items by name first. */ /* The result is -1, 0 or 1 and can be used in a switch */ /**********************************************************/ int cmp_by_name(const void far *uitem1, const void far *uitem2) { int dif; dif = strncmp(((t_user *) uitem1)->name, ((t_user *) uitem2)->name, NAME_LEN); if (!dif) { dif = strncmp(((t_user *) uitem1)->uid, ((t_user *) uitem2)->uid, UID_LEN); } if (dif < 0) return -1; if (dif > 0) return 1; return 0; } /* end cmp_by_name() */ /*********************************************************/ /* cmp_by_uids(): compare two t_user items by UID first. */ /* The result is -1, 0 or 1 and can be used in a switch */ /*********************************************************/ int cmp_by_uids(const void far *uitem1, const void far *uitem2) { int dif; dif = strncmp(((t_user *) uitem1)->uid, ((t_user *) uitem2)->uid, UID_LEN); if (!dif) { dif = strncmp(((t_user *) uitem1)->name, ((t_user *) uitem2)->name, NAME_LEN); } if (dif < 0) return -1; if (dif > 0) return 1; return 0; } /* end cmp_by_uids() */ #endif /* defined(PPNFUNC) */ /* ***** EOF(WtPPN.H) ***** */