Establishes a list of services available to a Natural Access application.
DWORD ctaInitialize ( CTA_SERVICE_NAME *svcname[], unsigned nsvcs, CTA_INIT_PARMS *initparms)
Argument |
Description |
svcname |
Pointer to an array of service names to make available to the application. The CTA_SERVICE_NAME structure is: typedef struct |
nsvcs |
Number of services in svcname. |
initparms |
Pointer to a structure containing initialization parameters. The CTA_INIT_PARMS structure is: typedef struct See Details for a description of these fields. |
Return value |
Description |
SUCCESS |
|
CTAERR_ALREADY_DEFINED |
Duplicate service or service manager exists in svcname. |
CTAERR_ALREADY_INITIALIZED |
A Natural Access service was already initialized. |
CTAERR_BAD_SIZE |
initparms size field is not valid. |
CTAERR_FILE_NOT_FOUND |
The file name specified in CTA_INIT_PARMS is not found or cta.cfg is not found. |
CTAERR_FUNCTION_ACTIVE |
Two separate threads called ctaInitialize at the same time. The first thread executed the function correctly. The second thread received this error. |
CTAERR_INCOMPATIBLE_PARMS |
The same services provided by two or more service managers have different standard parameters. |
CTAERR_INCOMPATIBLE_REVISION |
One of the specified services or svcnames is incompatible with the Natural Access dispatcher. |
CTAERR_INVALID_LIB |
The specified action (usually setting the ctaflags bits) could not be performed because the application is not linked to the appropriate Natural Access library. |
CTAERR_LOAD_LIB |
An error occurred while loading the Natural Access core library. |
CTAERR_NOT_FOUND |
One or more services are not found or listed services are not found in the configuration file. |
CTAERR_SHAREMEM_ACCESS |
One of the following conditions occurred:
Update cta.cfg to contain all required services and restart ctdaemon. |
CTAERR_WRONG_COMPAT_LEVEL |
Installed Natural Access compatibility level is different from the application-specified compatibility level. |
ctaInitialize finds all service managers and services that the application needs. Call this function only once at application initialization.
You can register services in one of the following ways:
Invoke ctaInitialize and specify the service and service manager names of all the services you plan to use. The application can use only the services specified in the call to ctaInitialize.
Invoke ctaInitialize, pass NULL for svcname, and pass a user-defined Natural Access configuration file name. cta.cfg is the default configuration file name if a file name is not specified. ctaInitialize looks in the [ctasys] header section of the configuration file for the list of service and service manager names.
Note: If you want to use a remote server but pass NULL for svcname and pass the configuration file name cta.cfg, cta.cfg on the local server may not specify the same available services as the remote server.
After calling ctaInitialize, you can modify and retrieve global default parameters, and create and destroy event queues and contexts.
The CTA_INIT_PARMS structure contains the following fields:
Field |
Description |
---|---|
size |
Indicates the size of the passed structure. |
parmflags |
Specifies where the global default parameters are stored. Valid values are:
If you are using a local or remote server, the system ignores these flags. Parameter management applies to the entire system and cannot be overridden. Refer to Global default parameters for more information on parameter storage. |
traceflags |
Provides a backlog of trace information on a context when an error condition occurs. To observe trace information for all contexts, do not enable this feature.
To write all recently logged trace messages on a particular context to ctdaemon, call ctaLogTrace, specifying the context you want to analyze, and set the traceseverity argument to CTA_TRACE_SEVERITY_ERROR. If you are using a local or remote server, the system ignores these flags. |
daemonflags |
Set to zero (0). |
ctaflags |
Specifies the context and queue settings. Valid values are:
Note: When this bit is set under UNIX, a process cannot fork. Each process must create its own session to the server.
|
filename |
Determines the file to use to obtain the service names.
|
ctacompatlevel |
Verifies Natural Access compatibility. Valid values are:
The compatibility level is changed if the release includes changes requiring applications to be recompiled. Refer to Verifying compatibility for more information. |
reserved |
Reserved for future use. Set this value to zero (0). |
Refer to Initializing Natural Access applications for more information.
Refer to Natural Access configuration file for information on cta.cfg. Refer to Natural Access Server: ctdaemon for more information on ctdaemon.
ctaQueryWaitObjects, ctaSetTraceLevel
static CTA_SERVICE_NAME InitServices[] = { { "ADI", "ADIMGR" },
{ "SWI", "SWIMGR" },
{ "VCE", "VCEMGR" } };
void DemoInitialize()
{
DWORD ret;
CTA_INIT_PARMS initparms = { 0 };
/* Initialize size of init parms structure */
initparms.size = sizeof(CTA_INIT_PARMS);
/* Use process global default parameters */
initparms.parmflags |= CTA_PARM_MGMT_LOCAL;
/* If daemon running then initialize tracing */
initparms.traceflags = CTA_TRACE_ENABLE;
/* Notify when Natural Access changes its internal list of wait objects*/
initparms.ctaflags = CTA_NOTIFY_UPDATE_WAITOBJS;
/* Verify Natural Access compatibility */
initparms.ctacompatlevel = CTA_COMPATLEVEL;
/* Initialize Natural Access */
ctaInitialize(InitServices,
sizeof(InitServices)/sizeof(InitServices[0]),
&initparms);
}
Note: For QX boards, replace ADIMGR with QDIMGR.