Remove win32 mapi mail from distribution (trunk only)

This commit is contained in:
nethack.allison
2006-10-19 13:26:54 +00:00
parent aed3d37e17
commit 4169a3a308
19 changed files with 22 additions and 785 deletions
+10 -10
View File
@@ -38,13 +38,13 @@ display.h dlb.h dungeon.h engrave.h extern.h
flag.h func_tab.h global.h hack.h lev.h
mail.h mextra.h mfndpos.h micro.h mkroom.h
monattk.h mondata.h monflag.h monst.h monsym.h
nhlan.h ntconf.h obj.h objclass.h os2conf.h
patchlevel.h pcconf.h permonst.h prop.h qtext.h
quest.h rect.h region.h rm.h skills.h
sp_lev.h spell.h system.h tcap.h timeout.h
tosconf.h tradstdc.h trampoli.h trap.h unixconf.h
vision.h vmsconf.h wceconf.h winami.h winprocs.h
wintype.h you.h youprop.h
ntconf.h obj.h objclass.h os2conf.h patchlevel.h
pcconf.h permonst.h prop.h qtext.h quest.h
rect.h region.h rm.h skills.h sp_lev.h
spell.h system.h tcap.h timeout.h tosconf.h
tradstdc.h trampoli.h trap.h unixconf.h vision.h
vmsconf.h wceconf.h winami.h winprocs.h wintype.h
you.h youprop.h
(file for tty versions)
wintty.h
(files for X versions)
@@ -198,9 +198,9 @@ stat.h
sys/winnt:
(files for Windows 9x, NT and Windows2000 version)
Install.nt Makefile.bcc Makefile.gcc Makefile.msc console.rc
defaults.nh mapimail.c nethack.def nh340key.c nhdefkey.c
nhico.uu nhraykey.c nhsetup.bat ntsound.c nttty.c
porthelp win32api.h winnt.c
defaults.nh nethack.def nh340key.c nhdefkey.c nhico.uu
nhraykey.c nhsetup.bat ntsound.c nttty.c porthelp
win32api.h winnt.c
util:
(files for all versions)
-7
View File
@@ -1453,13 +1453,6 @@ E int FDECL(do_play_instrument, (struct obj *));
#ifdef LAN_FEATURES
E void NDECL(init_lan_features);
E char *NDECL(lan_username);
# ifdef LAN_MAIL
E boolean NDECL(lan_mail_check);
E void FDECL(lan_mail_read, (struct obj *));
E void NDECL(lan_mail_init);
E void NDECL(lan_mail_finish);
E void NDECL(lan_mail_terminate);
# endif
#endif
/* ### nttty.c ### */
-48
View File
@@ -1,48 +0,0 @@
/* SCCS Id: @(#)nhlan.h 3.5 1997/04/12 */
/* Copyright (c) Michael Allison, 1997 */
/* NetHack may be freely redistributed. See license for details. */
#ifndef NHLAN_H
#define NHLAN_H
/*
* Here are the LAN features currently implemented:
* LAN_MAIL Mail facility allowing receipt and
* reading of mail.
* LAN_SHARED_BONES Allows bones files to be stored on a
* network share. (Does NOT imply compatibiliy
* between unlike platforms)
*/
# ifdef LAN_FEATURES
# ifdef LAN_MAIL
#define MAIL
#ifndef WIN32
#define MAILCKFREQ 50
#else
/*
* WIN32 port does the real mail lookups in a separate thread
* and the NetHack core code really just checks a flag,
* so that part of it can be done more often. The throttle
* for how often the mail thread should contact the mail
* system is controlled by MAILTHREADFREQ and is expressed
* in milliseconds.
*/
#define MAILCKFREQ 5
#define MAILTHREADFREQ 50000
#endif
#ifndef MAX_BODY_SIZE
#define MAX_BODY_SIZE 1024
#endif
struct lan_mail_struct {
char sender[120];
char subject[120];
boolean body_in_ram; /* TRUE means body in memory not file */
char filename[_MAX_PATH];
char body[MAX_BODY_SIZE];
};
# endif
# endif /*LAN_FEATURES*/
#endif /*NHLAN_H*/
-3
View File
@@ -217,9 +217,6 @@ int _RTLENTRY _EXPFUNC read (int __handle, void _FAR *__buf, unsigned __len);
#ifdef LAN_FEATURES
#define MAX_LAN_USERNAME 20
#define LAN_RO_PLAYGROUND /* not implemented in 3.3.0 */
#define LAN_SHARED_BONES /* not implemented in 3.3.0 */
#include "nhlan.h"
#endif
#ifndef alloca
+3 -43
View File
@@ -38,7 +38,7 @@ STATIC_DCL void FDECL(newmail, (struct mail_info *));
extern char *viz_rmin, *viz_rmax; /* line-of-sight limits (vision.c) */
# if !defined(UNIX) && !defined(VMS) && !defined(LAN_MAIL)
# if !defined(UNIX) && !defined(VMS)
int mustgetmail = -1;
# endif
@@ -402,7 +402,7 @@ give_up:
pline("Hark! \"%s.\"", info->display_txt);
}
# if !defined(UNIX) && !defined(VMS) && !defined(LAN_MAIL)
# if !defined(UNIX) && !defined(VMS)
void
ckmailstatus()
@@ -445,7 +445,7 @@ struct obj *otmp;
}
# endif /* !UNIX && !VMS && !LAN_MAIL */
# endif /* !UNIX && !VMS */
# ifdef UNIX
@@ -568,46 +568,6 @@ struct obj *otmp;
}
# endif /* VMS */
# ifdef LAN_MAIL
void
ckmailstatus()
{
static int laststattime = 0;
if(u.uswallow || !flags.biff
# ifdef MAILCKFREQ
|| moves < laststattime + MAILCKFREQ
# endif
)
return;
laststattime = moves;
if (lan_mail_check()) {
static struct mail_info deliver = {
# ifndef NO_MAILREADER
MSG_MAIL, "I have some mail for you",
# else
/* suppress creation and delivery of scroll of mail */
MSG_OTHER, "You have some mail in the outside world",
# endif
0, 0
};
newmail(&deliver);
}
}
/*ARGSUSED*/
void
readmail(otmp)
struct obj *otmp;
{
lan_mail_read(otmp);
}
# endif /* LAN_MAIL */
#endif /* MAIL */
/*mail.c*/
-6
View File
@@ -2452,12 +2452,6 @@ goodfruit:
else if ((boolopt[i].addr) == &flags.invlet_constant) {
if (flags.invlet_constant) reassign();
}
#ifdef LAN_MAIL
else if ((boolopt[i].addr) == &flags.biff) {
if (flags.biff) lan_mail_init();
else lan_mail_finish();
}
#endif
else if ((boolopt[i].addr) == &flags.lit_corridor) {
/*
* All corridor squares seen via night vision or
-149
View File
@@ -10,13 +10,6 @@
* that might be available in a Local Area Network environment.
*
* Network Username of player
* Mail
* Futures
* Shared bones
* To implement this: code, data files, and configuration
* files need to be separated from writeable files such
* as level files, bones files, and save files.
*
*/
#include "hack.h"
@@ -24,26 +17,9 @@
#ifdef LAN_FEATURES
#ifdef LAN_MAIL
/* Port specific code needs to implement these routines for LAN_MAIL */
extern char *FDECL(get_username, (int *));
extern boolean NDECL(mail_check);
extern boolean FDECL(mail_fetch, (struct lan_mail_struct *));
extern void FDECL(mail_init, (char *));
extern void NDECL(mail_finish);
struct lan_mail_struct mailmessage;
#endif /* LAN_MAIL */
void init_lan_features()
{
lan_username();
#ifdef LAN_MAIL
lan_mail_init();
#endif
#ifdef LAN_SHARED_BONES
#endif
}
/*
* The get_lan_username() call is a required call, since some of
@@ -62,130 +38,5 @@ char *lan_username()
return lusername;
} else return (char *)0;
}
# ifdef LAN_MAIL
#if 0
static void
mail_by_pline(msg)
struct lan_mail_struct *msg;
{
long size;
for (size = 0; size < qt_msg->size; size += (long)strlen(in_line)) {
(void) dlb_fgets(in_line, 80, msg_file);
convert_line();
pline(out_line);
}
}
#endif /* 0 */
static void
mail_by_window(msg)
struct lan_mail_struct *msg;
{
char buf[BUFSZ];
winid datawin = create_nhwindow(NHW_TEXT);
char *get, *put;
int ccount = 0;
get = msg->body;
put = buf;
while (*get) {
if (ccount > 79) {
*put = '\0';
putstr(datawin, 0, buf);
put = buf;
ccount = 0;
}
if (*get == '\r') {
get++;
} else if (*get == '\n') {
*put = '\0';
putstr(datawin, 0, buf);
put = buf;
get++;
ccount = 0;
} else if (!isprint(*get)) {
get++;
} else {
*put++ = *get++;
ccount++;
}
}
*put = '\0';
putstr(datawin, 0, buf);
putstr(datawin, 0, "");
display_nhwindow(datawin, TRUE);
destroy_nhwindow(datawin);
}
/* this returns TRUE if there is mail ready to be read */
boolean lan_mail_check()
{
if (flags.biff) {
if (mail_check()) return TRUE;
}
return FALSE;
}
void lan_mail_read(otmp)
struct obj *otmp;
{
if (flags.biff) {
(void) mail_fetch(&mailmessage);
/* after a successful fetch iflags.lan_mail_fetched
* should be TRUE. If it isn't then we don't
* trust the contents of mailmessage. This
* ensures that things work correctly across
* save/restores where mailmessage isn't
* saved (nor should it be since it may be
* way out of context by then).
*/
if (iflags.lan_mail_fetched) {
if (mailmessage.body_in_ram) {
mail_by_window(&mailmessage);
return;
}
}
}
pline_The("text has faded and is no longer readable.");
}
void lan_mail_init()
{
if (!flags.biff) return;
(void) mail_init(lusername);
}
void lan_mail_finish()
{
if (iflags.lan_mail)
(void) mail_finish();
}
/* If ever called, the underlying mail system ran into trouble
* and wants us to cease bothering it immediately.
* Don't call mail_finish() because the underlying mail system
* may already be unavailable. Just clean up the NetHack side
* of things to prevent a crash.
*/
void lan_mail_terminate()
{
/* Step 1. Clear iflags.lan_mail to indicate "not inited" */
iflags.lan_mail = FALSE;
/* Step 2. Clear iflags.lan_mail_fetched */
iflags.lan_mail_fetched = FALSE;
/* Once having gotten to this point, the only
way to resume NetHack mail features again is
to Save/Quit game, or for the user to clear
iflags.biff and then set it once again,
which triggers mail initialization */
}
# endif /*LAN_MAIL*/
#endif /*LAN_FEATURES*/
/*nhlan.c*/
+1 -1
View File
@@ -556,7 +556,7 @@ $(CONFIG_H): ../include/config.h ../include/config1.h ../include/tradstdc.h \
../include/system.h ../include/unixconf.h ../include/os2conf.h \
../include/micro.h ../include/pcconf.h ../include/tosconf.h \
../include/amiconf.h ../include/macconf.h ../include/beconf.h \
../include/wceconf.h ../include/ntconf.h ../include/nhlan.h
../include/wceconf.h ../include/ntconf.h
touch $(CONFIG_H)
# hack.h timestamp
$(HACK_H): ../include/hack.h $(CONFIG_H) ../include/align.h \
+1 -1
View File
@@ -294,7 +294,7 @@ $(CONFIG_H) : $(INC)config.h $(INC)config1.h $(INC)tradstdc.h $(INC)global.h \
$(INC)unixconf.h $(INC)os2conf.h $(INC)micro.h \
$(INC)pcconf.h $(INC)tosconf.h $(INC)amiconf.h \
$(INC)macconf.h $(INC)beconf.h $(INC)wceconf.h \
$(INC)ntconf.h $(INC)nhlan.h
$(INC)ntconf.h
$(TOUCH) $(CONFIG_H)
# hack.h timestamp
$(HACK_H) : $(INC)hack.h $(CONFIG_H) $(INC)align.h \
+1 -3
View File
@@ -186,7 +186,7 @@ CONFIG_H = $(INCL)\config.h $(INCL)\config1.h $(INCL)\tradstdc.h \
$(INCL)\system.h $(INCL)\unixconf.h $(INCL)\os2conf.h \
$(INCL)\micro.h $(INCL)\pcconf.h $(INCL)\tosconf.h \
$(INCL)\amiconf.h $(INCL)\macconf.h $(INCL)\beconf.h \
$(INCL)\ntconf.h $(INCL)\nhlan.h $(INCL)\wceconf.h
$(INCL)\ntconf.h $(INCL)\wceconf.h
HACK_H = $(INCL)\hack.h $(CONFIG_H) $(INCL)\align.h \
$(INCL)\dungeon.h $(INCL)\monsym.h $(INCL)\mkroom.h \
@@ -632,8 +632,6 @@ $(DAT)\dungeon: $(UTIL)\makedefs.exe $(DAT)\dungeon.def
# $(CC) $(CFLAGSU) -Fo$@ $(NTSYS)\winnt.c
#$(O)ntsound.o: $(HACK_H) $(NTSYS)\ntsound.c
# $(CC) $(CFLAGSU) -Fo$@ $(NTSYS)\ntsound.c
#$(O)mapimail.o: $(HACK_H) $(INCL)\nhlan.h $(NTSYS)\mapimail.c
# $(CC) $(CFLAGSU) -DMAPI_VERBOSE -Fo$@ $(NTSYS)\mapimail.c
#
# util dependencies
+2 -4
View File
@@ -440,7 +440,7 @@ DLBOBJ = $(O)dlb.o
TTYOBJ = $(O)topl.o $(O)getline.o $(O)wintty.o
SOBJ = $(O)winnt.o $(O)pcsys.o $(O)pcunix.o \
$(SOUND) $(O)pcmain.o $(O)mapimail.o $(O)nhlan.o
$(SOUND) $(O)pcmain.o $(O)nhlan.o
OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
$(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \
@@ -470,7 +470,7 @@ CONFIG_H = $(INCL)\config.h $(INCL)\config1.h $(INCL)\tradstdc.h \
$(INCL)\system.h $(INCL)\unixconf.h $(INCL)\os2conf.h \
$(INCL)\micro.h $(INCL)\pcconf.h $(INCL)\tosconf.h \
$(INCL)\amiconf.h $(INCL)\macconf.h $(INCL)\beconf.h \
$(INCL)\ntconf.h $(INCL)\nhlan.h
$(INCL)\ntconf.h
HACK_H = $(INCL)\hack.h $(CONFIG_H) $(INCL)\context.h $(INCL)\align.h \
$(INCL)\dungeon.h $(INCL)\monsym.h $(INCL)\mkroom.h \
@@ -1126,8 +1126,6 @@ $(O)winnt.o: $(HACK_H) $(INCL)\win32api.h $(NTSYS)\winnt.c
@$(cc) $(CFLAGS) -o$@ $(NTSYS)\winnt.c
$(O)ntsound.o: $(HACK_H) $(NTSYS)\ntsound.c
@$(cc) $(CFLAGS) -o$@ $(NTSYS)\ntsound.c
$(O)mapimail.o: $(HACK_H) $(INCL)\nhlan.h $(NTSYS)\mapimail.c
@$(cc) $(CFLAGS) -DMAPI_VERBOSE -o$@ $(NTSYS)\mapimail.c
#
# util dependencies
+2 -4
View File
@@ -396,7 +396,7 @@ DLBOBJ = $(O)dlb.o
TTYOBJ = $(O)topl.o $(O)getline.o $(O)wintty.o
SOBJ = $(O)winnt.o $(O)pcsys.o $(O)pcunix.o \
$(SOUND) $(O)pcmain.o $(O)mapimail.o $(O)nhlan.o
$(SOUND) $(O)pcmain.o $(O)nhlan.o
OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
$(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \
@@ -426,7 +426,7 @@ CONFIG_H = $(INCL)/config.h $(INCL)/config1.h $(INCL)/tradstdc.h \
$(INCL)/system.h $(INCL)/unixconf.h $(INCL)/os2conf.h \
$(INCL)/micro.h $(INCL)/pcconf.h $(INCL)/tosconf.h \
$(INCL)/amiconf.h $(INCL)/macconf.h $(INCL)/beconf.h \
$(INCL)/ntconf.h $(INCL)/nhlan.h
$(INCL)/ntconf.h
HACK_H = $(INCL)/hack.h $(CONFIG_H) $(INCL)/align.h $(INCL)/context.h \
$(INCL)/dungeon.h $(INCL)/monsym.h $(INCL)/mkroom.h \
@@ -1090,8 +1090,6 @@ $(O)winnt.o: $(HACK_H) $(INCL)/win32api.h $(NTSYS)/winnt.c
$(cc) $(CFLAGS) -o$@ $(NTSYS)/winnt.c
$(O)ntsound.o: $(HACK_H) $(NTSYS)/ntsound.c
$(cc) $(CFLAGS) -o$@ $(NTSYS)/ntsound.c
$(O)mapimail.o: $(HACK_H) $(INCL)/nhlan.h $(NTSYS)/mapimail.c
$(cc) $(CFLAGS) -DMAPI_VERBOSE -o$@ $(NTSYS)/mapimail.c
#
# util dependencies
+2 -4
View File
@@ -410,7 +410,7 @@ DLBOBJ = $(O)dlb.o
TTYOBJ = $(O)topl.o $(O)getline.o $(O)wintty.o
SOBJ = $(O)winnt.o $(O)pcsys.o $(O)pcunix.o \
$(SOUND) $(O)mapimail.o $(O)nhlan.o
$(SOUND) $(O)nhlan.o
OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
$(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \
@@ -439,7 +439,7 @@ CONFIG_H = $(INCL)\config.h $(INCL)\config1.h $(INCL)\tradstdc.h \
$(INCL)\system.h $(INCL)\unixconf.h $(INCL)\os2conf.h \
$(INCL)\micro.h $(INCL)\pcconf.h $(INCL)\tosconf.h \
$(INCL)\amiconf.h $(INCL)\macconf.h $(INCL)\beconf.h \
$(INCL)\ntconf.h $(INCL)\nhlan.h
$(INCL)\ntconf.h
HACK_H = $(INCL)\hack.h $(CONFIG_H) $(INCL)\align.h $(INCL)\context.h \
$(INCL)\dungeon.h $(INCL)\monsym.h $(INCL)\mkroom.h \
@@ -1193,8 +1193,6 @@ $(O)winnt.o: $(HACK_H) $(INCL)\win32api.h $(NTSYS)\winnt.c
@$(CC) $(cflagsUtil) -Fo$@ $(NTSYS)\winnt.c
$(O)ntsound.o: $(HACK_H) $(NTSYS)\ntsound.c
@$(CC) $(cflagsUtil) -Fo$@ $(NTSYS)\ntsound.c
$(O)mapimail.o: $(HACK_H) $(INCL)\nhlan.h $(NTSYS)\mapimail.c
@$(CC) $(cflagsUtil) -DMAPI_VERBOSE -Fo$@ $(NTSYS)\mapimail.c
#
# util dependencies
-482
View File
@@ -1,482 +0,0 @@
/* SCCS Id: @(#)mapimail.c 3.5 $Date$ */
/* Copyright (c) Michael Allison, 1997 */
/* NetHack may be freely redistributed. See license for details. */
#ifdef MAX_BODY_SIZE
#undef MAX_BODY_SIZE
#define MAX_BODY_SIZE 2048 /* largest body held in ram in bytes */
#endif
#include "hack.h"
# ifdef LAN_MAIL
#include "win32api.h"
#include <mapi.h>
#define MAPI_MSGID_SIZE 512 /* as recommended */
#define MAPI_LIB_FAIL 1
#define MAPI_FUNC_FAIL 2
HANDLE hLibrary; /* Handle for MAPI32.DLL */
LHANDLE MAPISession; /* Handle for MAPI session */
char MAPIMessageID[MAPI_MSGID_SIZE]; /* Msg ID from provider */
lpMapiMessage MAPIMessage; /* Ptr to message from prov */
struct lan_mail_struct received_msg; /* store received msg here */
#ifdef MAPI_VERBOSE
FILE *dbgfile;
#define MAPIDEBUGFILENAME "mapidebug.log"
#endif
/*
* Prototypes for functions in this file
* (Not in normal NetHack style, but its doubtful that any
* of the code in here is at all portable between platforms)
*/
static long __stdcall start_mailthread(LPVOID ThreadParam);
static boolean MAPI_mail_check(char *);
static boolean MAPI_mail_fetch(char *);
static void MAPI_mail_finish(void);
static int MAPI_mail_context(int *);
static boolean MAPI_mail_init(char *);
static int InitMAPI(void);
static int DeInitMAPI(void);
static void MAPI_mail_abort(unsigned long);
/*
* Declare the function pointers used to access MAPI routines
* from the MAPI32.DLL
*/
LPMAPILOGON fpMAPILogon;
LPMAPILOGOFF fpMAPILogoff;
LPMAPIFINDNEXT fpMAPIFindNext;
LPMAPIREADMAIL fpMAPIReadMail;
LPMAPIFREEBUFFER fpMAPIFreeBuffer;
/*
* Data requiring synchronized access between the
* two thread contexts contained in this file
* (nethack thread and the MAPI-mail thread)
*/
HANDLE mailthread = 0; /* handle for the mail-thread */
unsigned nhmailthread_ID; /* thread ID for mail-thread */
unsigned long nhmail_param; /* value passed to mail-thread */
long mailthread_continue = 0; /* nh -> mapi thread: shut down! */
long mailthread_stopping = 0; /* mapi -> nh thread: MAPI is ill! */
/*
* Data updated by the NetHack thread only
* but read by the MAPI-mail thread.
*
*/
char MAPI_username[120];
boolean debugmapi;
/*
* Data updated by the MAPI-mail thread only
* but read by the NetHack thread.
*/
long mail_fetched = 0;
/*
* Data used only by the MAPI-mail thread.
*/
long mailpasses; /* counts the FindNext calls issued to MAPI */
char msgID[80]; /* message ID of msg under manipulation */
/*===============================================================
* NetHack thread routines
*
* These routines run in the context of the main NetHack thread.
* They are used to provide an interface between the NetHack
* LAN_MAIL code and the MAPI-thread code.
*
* These routines are referenced by shared code in
* sys/share/nhlan.c and they are prototyped in include/extern.h
*===============================================================
*/
boolean mail_check()
{
if (!mailthread_stopping) {
if (mail_fetched > 0)
return TRUE;
} else lan_mail_terminate();
return FALSE;
}
boolean mail_fetch(msg)
struct lan_mail_struct *msg;
{
/* shouldn't need to check mailthread_stopping here
as the data should be valid anyway */
*msg = received_msg;
iflags.lan_mail_fetched = TRUE;
/* clear the marker now so new messages can arrive */
InterlockedDecrement(&mail_fetched);
/* check to see if the MAPI-mail thread is saying "stop" */
if (mailthread_stopping) lan_mail_terminate();
return TRUE;
}
void mail_finish()
{
InterlockedDecrement(&mailthread_continue);
}
void mail_init(uname)
char *uname;
{
/* This routine invokes the _beginthreadex()
* run-time library call to start the execution
* of the MAPI-mail thread. It also performs
* few other preparatory tasks.
*/
if (mailthread_continue) {
/* Impossible - something is really messed up */
/* We better do some sanity checking */
/* Is there a valid thread handle and ID? */
if (mailthread && nhmailthread_ID) {
/* TODO: check 'em via WIN32 call */
/* if valid, do something about them */
/* if not, clear them */
}
}
mailthread = 0;
nhmailthread_ID = 0;
mailthread_continue = 0; /* no interlock needed yet */
mailthread_stopping = 0; /* no interlock needed yet */
#ifdef MAPI_VERBOSE
if (getenv("DEBUG_MAPI")) debugmapi = TRUE;
#endif
if (uname)
strcpy(MAPI_username, uname);
else {
#ifdef MAPI_VERBOSE
if (debugmapi) dbgfile = fopen(MAPIDEBUGFILENAME,"w");
if (dbgfile) {
fprintf(dbgfile,
"mapi initialization bypassed because uname not available\n");
fclose(dbgfile);
}
#endif
return;
}
mailthread = (HANDLE)_beginthreadex(
(void *)0,
(unsigned)0,
start_mailthread,
(void *)&nhmail_param,
(unsigned)0, (unsigned *)&nhmailthread_ID);
#if 0
/* TODO: check for failure of the thread. For now nethack
* doesn't care
*/
if (!mailthread) {
}
#endif
}
/*===============================================================
* MAPI-mail thread routines
*
* These routines run in the context of their own
* MAPI-mail thread. They were placed into their own
* thread, because MAPI calls can sometimes (often?) take
* a horribly long time to return (minutes even).
*
* Each of the routines below are referenced only by other
* routines below, with the exception of start_mailthread(),
* of course, which is started by a run-time library call
* issued from the main NetHack thread.
*===============================================================
*/
/*
* start_mailthread() is the entry point of the MAPI-mail thread.
*
*/
static long __stdcall start_mailthread(LPVOID ThreadParam)
{
char *lu = MAPI_username;
if(MAPI_mail_init(lu)) {
InterlockedIncrement(&mailthread_continue);
while (mailthread_continue) {
mailpasses++;
if (MAPI_mail_check(msgID)) {
if (MAPI_mail_fetch(msgID)) {
/* getting here means success */
}
}
Sleep(MAILTHREADFREQ);
}
#ifdef MAPI_VERBOSE
if (debugmapi && !mailthread_continue) {
fprintf(dbgfile,
"MAPI-thread detected mailthread_continue change.\n");
fprintf(dbgfile,
"NetHack has requested that the MAPI-thread cease.\n");
}
#endif
}
return 0;
}
static int
MAPI_mail_context(mcount)
int *mcount;
{
unsigned long status;
char tmpID[80];
int count = 0;
tmpID[0] = '\0';
MAPIMessageID[0] = '\0';
/* Get the ID of the first unread message */
status = fpMAPIFindNext(MAPISession, 0, 0, 0,
MAPI_UNREAD_ONLY | MAPI_GUARANTEE_FIFO,
0, tmpID);
/* Now loop through them all until we have no more */
while (status == SUCCESS_SUCCESS) {
strcpy(MAPIMessageID, tmpID);
count++;
status = fpMAPIFindNext(MAPISession, 0,
0, MAPIMessageID,
MAPI_UNREAD_ONLY | MAPI_GUARANTEE_FIFO,
0, tmpID);
}
if (status == MAPI_E_NO_MESSAGES) {
/* context is now at last message */
if (mcount) *mcount = count;
return SUCCESS_SUCCESS;
}
return status;
}
static boolean
MAPI_mail_check(mID)
char *mID;
{
unsigned long status;
char tmpID[80];
tmpID[0] = '\0';
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile, "MAPI_mail_check() ");
#endif
if (mail_fetched) {
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile, "returning FALSE (buffer occupied)\n");
#endif
return FALSE; /* buffer occupied, don't bother */
}
/* Get the ID of the next unread message if there is one */
status = fpMAPIFindNext(MAPISession, 0, 0, MAPIMessageID,
MAPI_UNREAD_ONLY | MAPI_GUARANTEE_FIFO,
0, tmpID);
if (status == SUCCESS_SUCCESS) {
strcpy(mID, tmpID);
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile, "returning TRUE\n");
#endif
return TRUE;
}
if (status == MAPI_E_NO_MESSAGES) {
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile, "returning FALSE\n");
#endif
return FALSE;
}
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile,"Error, check_newmail() status: %d\n", status);
MAPI_mail_abort(status);
#endif
return FALSE;
}
static boolean
MAPI_mail_fetch(mID)
char *mID;
{
unsigned long status;
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile, "MAPI_mail_fetch() ");
#endif
/*
* Update context right away so we don't loop if there
* was a problem getting the message
*/
strcpy(MAPIMessageID, mID);
if (mail_fetched) {
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile, "returning FALSE (buffer occupied)\n");
#endif
return FALSE; /* buffer occupied */
}
status = fpMAPIReadMail(MAPISession, 0, mID,
MAPI_SUPPRESS_ATTACH | MAPI_PEEK,
0, &MAPIMessage);
if (status == SUCCESS_SUCCESS) {
strncpy(received_msg.subject,
MAPIMessage->lpszSubject,
sizeof(received_msg.subject) - 1);
if((MAPIMessage->lpOriginator->lpszName != (char *)0)
&& MAPIMessage->lpOriginator->lpszName[0] != '\0')
strncpy(received_msg.sender,
MAPIMessage->lpOriginator->lpszName,
sizeof(received_msg.sender) - 1);
else
strncpy(received_msg.sender,
MAPIMessage->lpOriginator->lpszAddress,
sizeof(received_msg.sender) - 1);
strncpy(received_msg.body,
MAPIMessage->lpszNoteText,MAX_BODY_SIZE - 1);
received_msg.body[MAX_BODY_SIZE - 1] = '\0';
received_msg.body_in_ram = TRUE;
status = fpMAPIFreeBuffer(MAPIMessage);
InterlockedIncrement(&mail_fetched);
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile, "returning TRUE\n");
#endif
return TRUE;
}
#ifdef MAPI_VERBOSE
else
if (debugmapi) fprintf(dbgfile,"MAPIRead failed, status = %d\n", status);
if (debugmapi) fprintf(dbgfile, "returning FALSE (failed)\n");
#endif
return FALSE;
}
static void
MAPI_mail_finish()
{
InterlockedIncrement(&mailthread_stopping);
(void) fpMAPILogoff(MAPISession,0,0,0);
(void) DeInitMAPI();
#ifdef MAPI_VERBOSE
if (debugmapi) fclose(dbgfile);
#endif
(void) _endthreadex(0);
}
static void
MAPI_mail_abort(reason)
unsigned long reason;
{
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile,
"Terminating MAPI-thread due to error %d.\n", reason);
#endif
MAPI_mail_finish();
}
static boolean
MAPI_mail_init(uname)
char *uname;
{
unsigned long status;
int count = 0;
#ifdef MAPI_VERBOSE
if (debugmapi) dbgfile = fopen(MAPIDEBUGFILENAME,"w");
if (debugmapi) fprintf(dbgfile,"Hello %s, NetHack is initializing MAPI.\n",
uname);
#endif
status = InitMAPI();
if (status) {
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile,"Error initializing MAPI %d\n", status);
#endif
return FALSE;
}
status = fpMAPILogon(0,uname,0L,0L,0L,(LPLHANDLE)&MAPISession);
if (status != SUCCESS_SUCCESS) {
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile,"Status of MAPI logon is %d\n", status);
#endif
return FALSE;
}
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile,
"Stage 1 of MAPI initialization successful.\n");
if (debugmapi) fprintf(dbgfile,"MAPI Session handle: %d\n", MAPISession);
#endif
status = MAPI_mail_context(&count);
if (status == SUCCESS_SUCCESS) {
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile,
"Stage 2 of MAPI initialization successful.\n");
if (debugmapi) fprintf(dbgfile,"Detected %d old unread messages.\n",
count);
#endif
return TRUE;
}
#ifdef MAPI_VERBOSE
if (debugmapi) fprintf(dbgfile,
"Error, status of MAPI_mail_context() is %d.\n",
status);
if (debugmapi) fprintf(dbgfile,
"Dismantling MAPI interface and cleaning up.\n");
#endif
MAPI_mail_finish();
return FALSE;
}
int InitMAPI()
{
if (!(hLibrary = LoadLibrary("MAPI32.DLL")))
return MAPI_LIB_FAIL;
if ((fpMAPILogon = (LPMAPILOGON)GetProcAddress(hLibrary,"MAPILogon")) == NULL)
return MAPI_FUNC_FAIL;
if ((fpMAPILogoff = (LPMAPILOGOFF)GetProcAddress(hLibrary,"MAPILogoff")) == NULL)
return MAPI_FUNC_FAIL;
if ((fpMAPIFindNext= (LPMAPIFINDNEXT)GetProcAddress(hLibrary,"MAPIFindNext")) == NULL)
return MAPI_FUNC_FAIL;
if ((fpMAPIReadMail= (LPMAPIREADMAIL)GetProcAddress(hLibrary,"MAPIReadMail")) == NULL)
return MAPI_FUNC_FAIL;
if ((fpMAPIFindNext= (LPMAPIFINDNEXT)GetProcAddress(hLibrary,"MAPIFindNext")) == NULL)
return MAPI_FUNC_FAIL;
if ((fpMAPIFreeBuffer= (LPMAPIFREEBUFFER)GetProcAddress(hLibrary,"MAPIFreeBuffer")) == NULL)
return MAPI_FUNC_FAIL;
#ifdef MAPI_VERBOSE
if (debugmapi) {
fprintf(dbgfile,"Entry Points:\n");
fprintf(dbgfile,"MAPILogon = %p\n",fpMAPILogon);
fprintf(dbgfile,"MAPILogoff = %p\n",fpMAPILogoff);
fprintf(dbgfile,"MAPIFindNext = %p\n",fpMAPIFindNext);
fprintf(dbgfile,"MAPIFreeBuffer = %p\n",fpMAPIReadMail);
fprintf(dbgfile,"MAPIReadMail = %p\n",fpMAPIFreeBuffer);
}
#endif
return 0;
}
int DeInitMAPI()
{
fpMAPILogon = NULL;
fpMAPILogoff= NULL;
fpMAPIFindNext= NULL;
fpMAPIReadMail= NULL;
fpMAPIFreeBuffer = NULL;
FreeLibrary(hLibrary);
return 0;
}
#endif /*LAN_MAIL*/
-4
View File
@@ -198,10 +198,6 @@ SOURCE=..\include\monsym.h
# End Source File
# Begin Source File
SOURCE=..\include\nhlan.h
# End Source File
# Begin Source File
SOURCE=..\include\ntconf.h
# End Source File
# Begin Source File
-4
View File
@@ -171,10 +171,6 @@ SOURCE=..\include\monsym.h
# End Source File
# Begin Source File
SOURCE=..\include\nhlan.h
# End Source File
# Begin Source File
SOURCE=..\include\ntconf.h
# End Source File
# Begin Source File
-4
View File
@@ -756,10 +756,6 @@ SOURCE=..\include\mttypriv.h
# End Source File
# Begin Source File
SOURCE=..\include\nhlan.h
# End Source File
# Begin Source File
SOURCE=..\include\ntconf.h
# End Source File
# Begin Source File
-4
View File
@@ -125,10 +125,6 @@ SOURCE=..\include\global.h
# End Source File
# Begin Source File
SOURCE=..\include\nhlan.h
# End Source File
# Begin Source File
SOURCE=..\include\ntconf.h
# End Source File
# Begin Source File
-4
View File
@@ -182,10 +182,6 @@ SOURCE=..\include\monsym.h
# End Source File
# Begin Source File
SOURCE=..\include\nhlan.h
# End Source File
# Begin Source File
SOURCE=..\include\ntconf.h
# End Source File
# Begin Source File