TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Phil Crown
from: Edwin Groothuis
date: 1994-10-17 10:44:00
subject: OS/2 COMM ROUTINES

Hallo Phil,

10-12-94 03:24, Phil Crown wrote to Edwin Groothuis:

 PC> However, I hit another dead-end when I tried to incorporate
 PC> P204.ZIP, a freeware X, Y, Zmodem driver with complete source. 
 PC> I had to end up trying the same thing you mentioned,
 PC> DosLoadModule(), and emximp. I am stuck at the emximp part right
 PC> now.  Here's what I'm trying to do;

 PC> If you can help me with this part and/or show me how you
 PC> emximp'ed gio, I'd really appreciate it.

I didn't emxinp'd it (I have no idea what to do with that...)

Here is a little source which shows you the import of GIO2.DLL. It's
called GIO2DLL.C

/*///////////////////////////////////////////////////////////////////////*/
/* GIO2DLL, or: How to import functions of the GIO2.DLL                  */
/*///////////////////////////////////////////////////////////////////////*/

#define INCL_BASE
#include 

#include 

/* GIO */
#include    "gio2.h"

static HMODULE dll_handle;
HCOMINFO hComInfo;
ULONG   ComHandle;

APIRET (* EXPENTRY ComOpen            )(PSZ, HFILE, ULONG, BYTE, SHORT,
SHORT, ULONG, PHCOMINFO)=NULL;
APIRET (* EXPENTRY ComClose           )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComSetLineControl  )(HCOMINFO, BYTE, SHORT, SHORT)=NULL;
APIRET (* EXPENTRY ComSetFlowControl  )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComGetBPS          )(HCOMINFO, PEXTBITRATES)=NULL;
APIRET (* EXPENTRY ComSetBPS          )(HCOMINFO, ULONG)=NULL;
APIRET (* EXPENTRY ComGetDCB          )(HCOMINFO, PDCBINFO)=NULL;
APIRET (* EXPENTRY ComSetDCB          )(HCOMINFO, PDCBINFO)=NULL;
APIRET (* EXPENTRY ComSetDTR          )(HCOMINFO, SHORT)=NULL;
BOOL   (* EXPENTRY ComGetDCD          )(HCOMINFO)=NULL;
BOOL   (* EXPENTRY ComGetCTS          )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComXONEnable       )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComXONDisable      )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComTXStart         )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComTXStop          )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComTXPurge         )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComTXCharImm       )(HCOMINFO, BYTE)=NULL;
ULONG  (* EXPENTRY ComTXChar          )(HCOMINFO, BYTE, BOOL)=NULL;
APIRET (* EXPENTRY ComTXString        )(HCOMINFO, PSZ, BOOL)=NULL;
APIRET (* EXPENTRY ComTXBlock         )(HCOMINFO, PBYTE, ULONG, BOOL)=NULL;
BOOL   (* EXPENTRY ComTXEmpty         )(HCOMINFO)=NULL;
VOID   (* EXPENTRY ComTXFlush         )(HCOMINFO, ULONG)=NULL;
APIRET (* EXPENTRY ComTXCount         )(HCOMINFO, PUSHORT)=NULL;
APIRET (* EXPENTRY ComRXPurge         )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComRX              )(HCOMINFO, PSHORT, ULONG, BOOL, BOOL)=NULL;
APIRET (* EXPENTRY ComRXBlock         )(HCOMINFO, PBYTE, ULONG, ULONG,
BOOL, PULONG)=NULL;
APIRET (* EXPENTRY ComRXString        )(HCOMINFO, PBYTE, ULONG, SHORT,
ULONG, BOOL)=NULL;
BOOL   (* EXPENTRY ComRXEmpty         )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComRXCount         )(HCOMINFO, PUSHORT)=NULL;
VOID   (* EXPENTRY ComPause           )(HCOMINFO)=NULL;
VOID   (* EXPENTRY ComResume          )(HCOMINFO)=NULL;
VOID   (* EXPENTRY ComBreak           )(HCOMINFO, BOOL)=NULL;
APIRET (* EXPENTRY ComConnect         )(HCOMINFO)=NULL;
APIRET (* EXPENTRY ComDisConnect      )(HCOMINFO)=NULL;
VOID   (* EXPENTRY ComGetHandle       )(HCOMINFO, PULONG)=NULL;


unsigned long  get_dir_len(char *path);

int     LoadGio2Dll(char *Arg0)
{
    char    ObjNameBuf[256];
    char    path[256];
    int     error=0;

    if (DosLoadModule(ObjNameBuf, 256, "GIO2.DLL", &dll_handle))
    {   
        sprintf(path, "%.*sGIO2.DLL", (int)get_dir_len(Arg0), Arg0);
        if (DosLoadModule(ObjNameBuf, 256, path, &dll_handle))
        {
            perror("Error DosLoadModule");
            return (0);
        }

        if (DosQueryProcAddr(dll_handle,0,"ComOpen",(PFN
*)&ComOpen)) { perror("ComOpen");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComOpen",(PFN
*)&ComOpen)) { perror("ComOpen");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComClose",(PFN
*)&ComClose)) { perror("ComClose");error=1;}
        if
(DosQueryProcAddr(dll_handle,0,"ComSetLineControl",(PFN
*)&ComSetLineControl)) {
perror("ComSetLineControl");error=1;}
        if
(DosQueryProcAddr(dll_handle,0,"ComSetFlowControl",(PFN
*)&ComSetFlowControl)) {
perror("ComSetFlowControl");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComGetBPS",(PFN
*)&ComGetBPS)) { perror("ComGetBPS");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComSetBPS",(PFN
*)&ComSetBPS)) { perror("ComSetBPS");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComGetDCB",(PFN
*)&ComGetDCB)) { perror("ComGetDCB");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComSetDCB",(PFN
*)&ComSetDCB)) { perror("ComSetDCB");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComSetDTR",(PFN
*)&ComSetDTR)) { perror("ComSetDTR");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComGetDCD",(PFN
*)&ComGetDCD)) { perror("ComGetDCD");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComGetCTS",(PFN
*)&ComGetCTS)) { perror("ComGetCTS");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComXONEnable",(PFN
*)&ComXONEnable)) { perror("ComXONEnable");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComXONDisable",(PFN
*)&ComXONDisable)) { perror("ComXONDisable");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXStart",(PFN
*)&ComTXStart)) { perror("ComTXStart");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXStop",(PFN
*)&ComTXStop)) { perror("ComTXStop");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXPurge",(PFN
*)&ComTXPurge)) { perror("ComTXPurge");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXCharImm",(PFN
*)&ComTXCharImm)) { perror("ComTXCharImm");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXChar",(PFN
*)&ComTXChar)) { perror("ComTXChar");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXString",(PFN
*)&ComTXString)) { perror("ComTXString");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXBlock",(PFN
*)&ComTXBlock)) { perror("ComTXBlock");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXEmpty",(PFN
*)&ComTXEmpty)) { perror("ComTXEmpty");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXFlush",(PFN
*)&ComTXFlush)) { perror("ComTXFlush");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComTXCount",(PFN
*)&ComTXCount)) { perror("ComTXCount");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComRXPurge",(PFN
*)&ComRXPurge)) { perror("ComRXPurge");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComRX",(PFN
*)&ComRX)) { perror("ComRX");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComRXBlock",(PFN
*)&ComRXBlock)) { perror("ComRXBlock");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComRXString",(PFN
*)&ComRXString)) { perror("ComRXString");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComRXEmpty",(PFN
*)&ComRXEmpty)) { perror("ComRXEmpty");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComRXCount",(PFN
*)&ComRXCount)) { perror("ComRXCount");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComPause",(PFN
*)&ComPause)) { perror("ComPause");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComResume",(PFN
*)&ComResume)) { perror("ComResume");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComBreak",(PFN
*)&ComBreak)) { perror("ComBreak");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComConnect",(PFN
*)&ComConnect)) { perror("ComConnect");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComDisConnect",(PFN
*)&ComDisConnect)) { perror("ComDisConnect");error=1;}
        if (DosQueryProcAddr(dll_handle,0,"ComGetHandle",(PFN
*)&ComGetHandle)) { perror("ComGetHandle");error=1;}
    }
    if (error)
        return (0);
    else
        return (1);
}


void    UnloadGio2Dll(void)
{
    if (DosFreeModule(dll_handle))
        perror("GIO2.DLL");
}


Easy, isn't it? And the GIO2DLL.H:

/*///////////////////////////////////////////////////////////////////////*/
/* GIO2DLL, or: How to import functions of the GIO2.DLL                  */
/*///////////////////////////////////////////////////////////////////////*/

extern  HCOMINFO hComInfo;
extern  ULONG ComHandle;
void    UnloadGio2Dll(void);
int     LoadGio2Dll(char *Arg0);

You have to init it in your main-function like

    if (!LoadGio2Dll(argv[0]))
    {
        printf("main: Error initializing GIO2.DLL\n");
        exit(1);
    }
    if (!LoadP203Dll(argv[0]))
    {
        printf("main: Error initializing P.DLL\n");
        exit(1);
    }

and destroy it with

    UnloadGio2DLL();
    UnloadP203Dll();


If it isn't clear, give me a reply!

Edwin           (edwin{at}mavetju.iaehv.nl)
/\/\ /\ \/!

...A half moon is better than no moon at all.
--- FNNR 17a+


* Origin: MavEtJu rules! (2:284/205.1)
SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413
SEEN-BY: 711/430 807 808 809 934 942 949 712/353 623 713/888 800/1
@PATH: 284/205 2 1 280/0 801 24/24 396/1 3615/50 229/2 12/2442
@PATH: 711/409 54/54 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™.