本文整理汇总了C++中OpenLibrary函数的典型用法代码示例。如果您正苦于以下问题:C++ OpenLibrary函数的具体用法?C++ OpenLibrary怎么用?C++ OpenLibrary使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OpenLibrary函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: amiga_sockinit
void amiga_sockinit() {
if ((SocketBase = OpenLibrary("bsdsocket.library", 1L)) == NULL) {
printf("Error opening bsdsocket.library\n");
exit(10);
}
SetErrnoPtr(&errno, sizeof(errno));
}
示例2: startup_run_update
// Run the update module
void startup_run_update()
{
struct Library *ModuleBase;
#ifdef __amigaos4__
struct ModuleIFace *IModule;
#endif
// Try and get update.module
#ifdef __amigaos4__
if (OpenLibIFace("dopus5:modules/update.module", (APTR)&ModuleBase, (APTR)&IModule, LIB_VERSION))
#else
if ((ModuleBase=OpenLibrary("dopus5:modules/update.module",0)))
#endif
{
// Launch update function
Module_Entry(0,0,0,0,0,0);
// Expunge library
Module_Expunge();
// Close library
#ifdef __amigaos4__
DropInterface((struct Interface *)IModule);
#endif
CloseLibrary(ModuleBase);
}
}
示例3: main
void main(int argc, char *argv[]) {
int nodnr, state = 0, i;
if(argc < 2) {
puts("Usage: SetNodeState <nodenr> [SERCLOSED] [NOANSWER] [LOGOUT]");
return;
}
nodnr = atoi(argv[1]);
for(i = 2; i < argc; i++) {
if(!stricmp(argv[i],"SERCLOSED")) {
state |= NIKSTATE_CLOSESER;
}
if(!stricmp(argv[i],"NOANSWER")) {
state |= NIKSTATE_NOANSWER;
}
if(!stricmp(argv[i],"LOGOUT")) {
state |= NIKSTATE_LOGOUT;
}
}
if(NiKomBase = OpenLibrary("nikom.library",0)) {
if(SetNodeState(nodnr,state)) {
puts("Suceeded");
} else {
puts("Failed");
}
CloseLibrary(NiKomBase);
} else {
puts("Kunde inte öppna nikom.library");
}
}
示例4: main
int main(int argc, char **argv)
{
struct PartitionHandle *root;
char *device = "fdsk.device";
ULONG unit = 1;
if (argc > 2)
{
device = argv[1];
unit = atoi(argv[2]);
}
PartitionBase = (struct PartitionBase *)OpenLibrary("partition.library", 1);
if (PartitionBase)
{
root = OpenRootPartition(device, unit);
if (root)
{
printf("got root handle of %s unit %d\n", device, (int)unit);
if (PrintPartitionTable(root, 0))
printf("Couldn't read partition table\n");
CloseRootPartition(root);
}
else
printf("No root handle for %s unit %d\n", device, (int)unit);
CloseLibrary((struct Library *)PartitionBase);
}
else
printf("No partition.library\n");
return 0;
}
示例5: strcpy
// Open a module
struct Library *OpenModule(char *name)
{
struct Library *lib = NULL;
char buf[256];
short a,ver=0;
// See if this is one of our modules
for (a=0;dopus_modules[a];a++)
if (stricmp(name,dopus_modules[a])==0)
{
// Need newest version
ver=LIB_VERSION;
break;
}
/* We can't check for valid modules in a LIBS: multiassign etc.
// See if it's in RAM
if ((lib=OpenLibrary(name,ver)))
return lib;
*/
// Build name in modules directory
strcpy(buf,"dopus5:modules/");
strcat(buf,name);
// Open library
if (!(lib=OpenLibrary(buf,ver)))
{
// Show error
error_request(GUI->window,1,GetString(&locale,MSG_OPENING),-1,name,0);
}
return lib;
}
示例6: pgsql_load_dll
static int pgsql_load_dll(void)
{
if ((handle = OpenLibrary(PGSQL_LIB)) == NULL) return -1;
if ( ((p_PQclear = (f_PQclear) GetFunction(handle, "PQclear")) == NULL) ||
((p_PQcmdTuples = (f_PQcmdTuples) GetFunction(handle, "PQcmdTuples")) == NULL) ||
((p_PQerrorMessage = (f_PQerrorMessage) GetFunction(handle, "PQerrorMessage")) == NULL) ||
((p_PQescapeString = (f_PQescapeString) GetFunction(handle, "PQescapeString")) == NULL) ||
((p_PQexec = (f_PQexec) GetFunction(handle, "PQexec")) == NULL) ||
((p_PQfinish = (f_PQfinish) GetFunction(handle, "PQfinish")) == NULL) ||
((p_PQfname = (f_PQfname) GetFunction(handle, "PQfname")) == NULL) ||
((p_PQgetvalue = (f_PQgetvalue) GetFunction(handle, "PQgetvalue")) == NULL) ||
((p_PQnfields = (f_PQnfields) GetFunction(handle, "PQnfields")) == NULL) ||
((p_PQntuples = (f_PQntuples) GetFunction(handle, "PQntuples")) == NULL) ||
((p_PQresultStatus = (f_PQresultStatus) GetFunction(handle, "PQresultStatus")) == NULL) ||
((p_PQsetdbLogin = (f_PQsetdbLogin) GetFunction(handle, "PQsetdbLogin")) == NULL) ||
((p_PQstatus = (f_PQstatus) GetFunction(handle, "PQstatus")) == NULL) )
{
CloseLibrary(handle);
handle = NULL;
return -1;
}
return 0;
}
示例7: amiga_init
BOOL amiga_init()
{
if(!SocketBase)
SocketBase = OpenLibrary("bsdsocket.library", 4);
if(!SocketBase) {
__request("No TCP/IP Stack running!");
return FALSE;
}
if(SocketBaseTags(
SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG) &errno,
// SBTM_SETVAL(SBTC_HERRNOLONGPTR), (ULONG) &h_errno,
SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG) "cURL",
TAG_DONE)) {
__request("SocketBaseTags ERROR");
return FALSE;
}
#ifndef __libnix__
atexit(amiga_cleanup);
#endif
return TRUE;
}
示例8: NetworkCoreInitialize
/**
* Initializes the network core (as that is needed for some platforms
* @return true if the core has been initialized, false otherwise
*/
bool NetworkCoreInitialize()
{
#if defined(__MORPHOS__) || defined(__AMIGA__)
/*
* IMPORTANT NOTE: SocketBase needs to be initialized before we use _any_
* network related function, else: crash.
*/
DEBUG(net, 3, "[core] loading bsd socket library");
SocketBase = OpenLibrary("bsdsocket.library", 4);
if (SocketBase == NULL) {
DEBUG(net, 0, "[core] can't open bsdsocket.library version 4, network unavailable");
return false;
}
#if defined(__AMIGA__)
/* for usleep() implementation (only required for legacy AmigaOS builds) */
TimerPort = CreateMsgPort();
if (TimerPort != NULL) {
TimerRequest = (struct timerequest*)CreateIORequest(TimerPort, sizeof(struct timerequest);
if (TimerRequest != NULL) {
if (OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest*)TimerRequest, 0) == 0) {
TimerBase = TimerRequest->tr_node.io_Device;
if (TimerBase == NULL) {
/* free resources... */
DEBUG(net, 0, "[core] can't initialize timer, network unavailable");
return false;
}
}
}
}
示例9: OpenLibs
static void OpenLibs(void)
{
if (!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",39)))
{
Cleanup("Can't open intuition.library V39!");
}
if (!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",39)))
{
Cleanup("Can't open graphics.library V39!");
}
if (!(LayersBase = OpenLibrary("layers.library",39)))
{
Cleanup("Can't open layers.library V39!");
}
}
示例10: Init
/* Open and initialize AmiSSL */
static BOOL Init(void)
{
BOOL is_ok = FALSE;
if (!(SocketBase = OpenLibrary("bsdsocket.library", 4)))
FPrintf(GetStdErr(), "Couldn't open bsdsocket.library v4!\n");
#if defined(__amigaos4__)
else if (!(ISocket = (struct SocketIFace *)GetInterface(SocketBase, "main", 1, NULL)))
FPrintf(GetStdErr(), "Couldn't get Socket interface!\n");
#endif
else if (!(AmiSSLMasterBase = OpenLibrary("amisslmaster.library",
AMISSLMASTER_MIN_VERSION)))
FPrintf(GetStdErr(), "Couldn't open amisslmaster.library v"
MKSTR(AMISSLMASTER_MIN_VERSION) "!\n");
#if defined(__amigaos4__)
else if (!(IAmiSSLMaster = (struct AmiSSLMasterIFace *)GetInterface(AmiSSLMasterBase,
"main", 1, NULL)))
FPrintf(GetStdErr(), "Couldn't get AmiSSLMaster interface!\n");
#endif
else if (!InitAmiSSLMaster(AMISSL_CURRENT_VERSION, TRUE))
FPrintf(GetStdErr(), "AmiSSL version is too old!\n");
else if (!(AmiSSLBase = OpenAmiSSL()))
FPrintf(GetStdErr(), "Couldn't open AmiSSL!\n");
#if defined(__amigaos4__)
else if (!(IAmiSSL = (struct AmiSSLIFace *)GetInterface(AmiSSLBase,
"main", 1, NULL)))
FPrintf(GetStdErr(), "Couldn't get AmiSSL interface!\n");
#endif
#if defined(__amigaos4__)
else if (InitAmiSSL(AmiSSL_ErrNoPtr, &errno,
AmiSSL_ISocket, ISocket,
TAG_DONE) != 0)
#else
else if (InitAmiSSL(AmiSSL_ErrNoPtr, &errno,
AmiSSL_SocketBase, SocketBase,
TAG_DONE) != 0)
#endif
FPrintf(GetStdErr(), "Couldn't initialize AmiSSL!\n");
else
is_ok = TRUE;
if (!is_ok)
Cleanup(); /* This is safe to call even if something failed above */
return(is_ok);
}
示例11: setup
void setup()
{
ExpatBase = OpenLibrary("expat.library", 4);
IExpat = (struct ExpatIFace*)GetInterface(ExpatBase, "main", 1, NULL);
if ( IExpat == 0 ) {
DebugPrintF("Can't open expat.library\n");
}
}
示例12: texture_init
TEXTURE_INFO *stub_texture_init(char *name, struct Library **Base)
{
*Base = OpenLibrary(name, 0);
if(!Base)
return NULL;
TextureBase = *Base;
return texture_init();
}
示例13: ASM
/* Initialize library */
static ASM(struct Library *) LibInit(REG(a0, SEGLISTPTR seglist),
REG(d0, struct MCP9808BaseP * MCP9808Base), REG(a6, struct ExecBase *SysBase))
{
#ifdef _M68060
if(!(SysBase->AttnFlags & AFF_68060))
return 0;
#elif defined (_M68040)
if(!(SysBase->AttnFlags & AFF_68040))
return 0;
#elif defined (_M68030)
if(!(SysBase->AttnFlags & AFF_68030))
return 0;
#elif defined (_M68020)
if(!(SysBase->AttnFlags & AFF_68020))
return 0;
#endif
/* Remember stuff */
MCP9808Base->i2cClass_SegList = seglist;
MCP9808Base->i2cClass_SysBase = SysBase;
#ifdef BASE_GLOBAL
MakeGlobalSys(MCP9808Base);
#endif
if((MCP9808Base->i2cClass_IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 37)))
{
if((MCP9808Base->i2cClass_UtilityBase = (struct UtilityBase *) OpenLibrary("utility.library", 37)))
{
#ifdef BASE_GLOBAL
MakeGlobalLibs(MCP9808Base);
#endif
return &MCP9808Base->i2cClass_LibNode;
}
CloseLibraries(MCP9808Base);
}
/* Free the vector table and the library data */
FreeMem((STRPTR) MCP9808Base - MCP9808Base->i2cClass_LibNode.lib_NegSize,
MCP9808Base->i2cClass_LibNode.lib_NegSize +
MCP9808Base->i2cClass_LibNode.lib_PosSize);
return 0;
}
示例14: main
int
main( void )
{
struct Library* EMU10kxBase;
struct EMU10kxAC97* EMU10kxAC97;
ULONG value;
EMU10kxBase = OpenLibrary( "DEVS:AHI/emu10kx.audio", VERSION );
if( EMU10kxBase == NULL )
{
Printf( "Unable to open DEVS:AHI/emu10kx.audio version %ld.\n", VERSION );
return RETURN_FAIL;
}
Forbid();
EMU10kxAC97 = (struct EMU10kxAC97*) FindSemaphore( EMU10KX_AC97_SEMAPHORE );
if( EMU10kxAC97 != NULL )
{
ObtainSemaphore( &EMU10kxAC97->Semaphore );
}
Permit();
if( EMU10kxAC97 == NULL )
{
CloseLibrary( EMU10kxBase );
Printf( "Unable to find semaphore '%s'.\n", (ULONG) EMU10KX_AC97_SEMAPHORE );
return RETURN_FAIL;
}
Printf( "%ld EMU10kx cards found.\n", EMU10kxAC97->Cards );
value = CallHook( &EMU10kxAC97->GetFunc, (Object*) EMU10kxBase,
0, AC97_CD_VOL );
Printf( "CD volume on card 0 is 0x%04lx\n", value );
Printf( "Setting it to 0x0000.\n" );
CallHook( &EMU10kxAC97->SetFunc, (Object*) EMU10kxBase, 0, AC97_CD_VOL, 0 );
Delay( 3 * 50 );
Printf( "Restoring it.\n" );
CallHook( &EMU10kxAC97->SetFunc, (Object*) EMU10kxBase, 0, AC97_CD_VOL, value );
Printf( "Exiting.\n" );
if( EMU10kxAC97 != NULL )
{
ReleaseSemaphore( &EMU10kxAC97->Semaphore );
}
CloseLibrary( EMU10kxBase );
return RETURN_OK;
}
示例15: server_connect
static SOCKET server_connect(const char *host, unsigned short nport)
{
struct hostent *he;
char **ap;
#ifdef WIN32
static int need_init = 1;
if (need_init) {
WSADATA wsa;
if (WSAStartup(MAKEWORD(2, 0), &wsa))
return INVALID_SOCKET;
need_init = 0;
}
#elif defined(USE_AMITCP)
if (!socket_base) {
socket_base = OpenLibrary("bsdsocket.library", 4);
if (!socket_base)
return INVALID_SOCKET;
}
#endif
he = gethostbyname(host);
if (!he)
return INVALID_SOCKET;
for (ap = he->h_addr_list; *ap; ++ap) {
SOCKET sock;
struct sockaddr_in sa;
sa.sin_family = he->h_addrtype;
sa.sin_port = htons(nport);
memcpy(&sa.sin_addr, *ap, he->h_length);
memset(&sa.sin_zero, 0, sizeof(sa.sin_zero));
sock = socket(he->h_addrtype, SOCK_STREAM, 0);
if (sock == INVALID_SOCKET)
continue;
if (connect(sock, (struct sockaddr *)&sa, sizeof(sa)) >= 0) {
char greet[128];
if (xsend(sock, CLIENT_GREET, strlen(CLIENT_GREET), 0) ||
xrecv(sock, greet, strlen(SERVER_GREET), 0)) {
closesocket(sock);
continue;
}
if (!strncmp(SERVER_GREET, greet, strlen(SERVER_GREET)))
return sock;
}
closesocket(sock);
}
return INVALID_SOCKET;
}