| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | EMX and DLL`s |
Hallo, Greg!
*** Am Freitag 06. Oktober 1995 um 17:52 schrieb Greg Collins an Thomas Seeling:
GC>>> Well, I've got a bit of a problem here running EMX. I have
a DLL that
GC>>> Actually, is the MSGAPI32.DLL written by Scott Dudley, and
it barfs at
GC>>> MsgOpenMsg.
GC> main, but more than likely it's jumping to some garbage pointer which
GC> happens to be in my code segment.
This is not a fault of the msgapi32. As I wrote, I am using it for a long
time now, and it never left me (except for some minor glitches). It is even
possible to recompile the source and build a DLL with emx 0.9a that works
with all other programs (wasn't that easy with 0.8*).
GC> I've got the import library. That's not the problem.
Then it's a problem in your code. This example works for me together with
the import library I posted last time (I rebuilt it to check that it really
does):
=== Cut ===
#include
#include
#include
#include
#include
#include "msgapi.h"
#define BUFSIZE 8192
#define msgtypename(x) (x==MSGTYPE_SQUISH ? "Squish" : "*.Msg")
#define msgtype(x) (*(x)=='$' ? MSGTYPE_SQUISH : MSGTYPE_SDM)
#define msgname(x) (*(x)=='$' ? (x)+1 : (x))
void segviol() {
abort();
}
int dosftime(char *buf, int size, char *format, struct _stamp time) {
struct tm mytime;
mytime.tm_mday=time.date.da;
mytime.tm_mon =time.date.mo;
mytime.tm_year=time.date.yr+80;
mytime.tm_hour=time.time.hh;
mytime.tm_min =time.time.mm;
mytime.tm_sec =time.time.ss;
return strftime(buf,size,format,&mytime);
}
char *fido(NETADDR *n) {
static char buf[25];
sprintf(buf,"%d:%d/%d.%d",n->zone,n->net,n->node,n->point);
return buf;
}
int main(int argc,char *argv[]) {
XMSG xmsg;
HAREA area;
HMSG msg;
struct _minf mi;
char *ctrl,*buffer,*name,*p,*q;
dword offset, msgn;
long got;
int ctrllen,type;
char quiet;
if (argc<2) {
fprintf(stderr,"Areaname expected\n");
exit(1);
}
type=msgtype(argv[1]);
name=strdup(msgname(argv[1]));
printf("Reading %s Area %s\n",
msgtypename(type),name);
if (argc>2)
quiet=stricmp(argv[2],"-q")==0;
else
quiet=0;
signal(SIGSEGV,segviol);
memset(&mi, '\0', sizeof mi);
mi.req_version=1;
mi.def_zone=2;
mi.palloc = mi.farpalloc = malloc;
mi.repalloc = mi.farrepalloc = realloc;
mi.pfree = mi.farpfree = free;
MsgOpenApi(&mi);
msgapierr=0;
if ((area=MsgOpenArea(name, MSGAREA_NORMAL, type))==NULL) {
fprintf(stderr,"MsgOpenArea error %d area '%s' (%s) for read!\n",
msgapierr,name,msgtypename(type));
MsgCloseApi();
exit(1);
}
/*
MsgLock(area);
*/
if ((buffer=malloc(BUFSIZE))==NULL) {
fprintf(stderr,"Error! No memory\n");
MsgCloseArea(area);
MsgCloseApi();
exit(1);
}
for (msgn=1L; msgn <= MsgHighMsg(area); msgn++) {
msgapierr=0;
msg=MsgOpenMsg(area,MOPEN_READ,msgn);
if (msg==NULL) {
fprintf(stderr,"MsgOpenMsg error %d area '%s' (%s) for read!\n",
msgapierr,name,msgtypename(type));
continue;
}
ctrllen=(int)MsgGetCtrlLen(msg);
if ((ctrl=malloc(ctrllen))==NULL)
ctrllen=0;
msgapierr=0;
MsgReadMsg(msg, &xmsg, 0L, 0L, NULL, ctrllen, ctrl);
if (msgapierr) {
fprintf(stderr,"MsgReadMsg error %d area '%s' (%s) for read ctrl\n",
msgapierr,name,msgtypename(type));
continue;
}
ConvertControlInfo(ctrl,&xmsg.orig,&xmsg.dest);
dosftime(buffer,20,"%d.%m.%y, %T",xmsg.date_written);
printf("From: %s, %s (%s)\n",xmsg.from,fido(&xmsg.orig),buffer);
dosftime(buffer,20,"%d.%m.%y, %T",xmsg.date_arrived);
printf("To: %s, %s (%s)\n",xmsg.to,fido(&xmsg.dest),buffer);
printf("Subj: %s\n",xmsg.subj);
printf("Ctrlsize %d, Textsize %d, Umsgid %08lx\n",
ctrllen,MsgGetTextLen(msg),
MsgMsgnToUid(area,msgn));
if (quiet)
printf("----------\n");
else {
printf("--- Message start\n");
if (((p=ctrl)!=NULL) && *ctrl)
while (*p) {
putchar(*p=='\001' ? '{at}' : *p);
++p;
if (*p=='\001' || *p=='\0')
putchar('\n');
}
for (offset=0L; offset < MsgGetTextLen(msg); ) {
msgapierr=0;
got=MsgReadMsg(msg, NULL, offset, BUFSIZE, buffer, 0L, NULL);
if (msgapierr) {
fprintf(stderr,"MsgReadMsg error %d area '%s' (%s) for read text\n",
msgapierr,name,msgtypename(type));
continue;
}
if (got <= 0)
break;
buffer[got]='\0';
for (p=buffer; *p, (q=strpbrk(p,"\r\n"))!=NULL; p=q+1) {
if (q)
*q='\0';
puts(p);
}
offset += got;
}
printf("--- Message end\n");
}
if (ctrl)
free(ctrl);
MsgCloseMsg(msg);
}
free(buffer);
MsgCloseArea(area);
/*
MsgUnlock(area);
*/
MsgCloseApi();
free(name);
return 0;
}
=== Cut ===
Tschau...Thomas
--- E3-32/1.11-32/2.50+
* Origin: Die TeX-Box +49-6034-1455 V.34 -930022 ISDN 24h (2:244/1130.42)SEEN-BY: 270/101 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 244/1130 24/999 2/777 396/1 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.