home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
bin
/
p205.zip
/
exesrc
/
p_dll.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-18
|
2KB
|
71 lines
/*****************************************************************************/
/* Copyright (c) 1994 by Jyrki Salmi <jytasa@jyu.fi> */
/* You may modify, recompile and distribute this file freely. */
/*****************************************************************************/
/*
Routines that load P.DLL and get the address of p_tranfer() entry
function.
*/
#include <stdio.h>
#define INCL_DOSMODULEMGR
#define INCL_DOSPROCESS
#include <os2.h>
#include "typedefs.h"
#include "common.h"
#include "p.h"
#include "p_dll.h"
#include "error.h"
#include "modules.h"
static HMODULE dll_handle;
U32 (* _System p_transfer)(P_CFG *) = NULL;
char *get_exe_path(void) {
PTIB tib;
PPIB pib;
DosGetInfoBlocks(&tib, &pib); /* rc is always 0, no need to check */
return(pib->pib_pchcmd);
}
void load_p_dll(void) {
APIRET rc;
U8 *exe_path;
U8 path[256];
rc = DosLoadModule(NULL, 0L, "P", &dll_handle);
if (rc) {
/* P.DLL was not found in directory specified with LIBPATH, let's look */
/* up for it from the directory where P.EXE was ran from. */
exe_path = get_exe_path();
sprintf(path, "%.*sP.DLL", (int)get_dir_len(exe_path), exe_path);
rc = DosLoadModule(NULL, 0L, path, &dll_handle);
if (rc)
os2_error(P_ERROR_DOSLOADMODULE, rc, MODULE_P_DLL, __LINE__, path);
}
/* Query the address of p_transfer() entry function */
rc = DosQueryProcAddr(dll_handle,
0,
"p_transfer",
(PFN *)&p_transfer);
if (rc)
os2_error(P_ERROR_DOSQUERYPROCADDR, rc,
MODULE_P_DLL, __LINE__,
"p_transfer");
}
void unload_p_dll(void) {
APIRET rc;
rc = DosFreeModule(dll_handle);
if (rc)
os2_error(P_ERROR_DOSFREEMODULE, rc,
MODULE_P_DLL, __LINE__,
"P");
}