Sending a Command to IBM Connect:Direct Using ndmapi_sendcmd() or ndmapi_sendcmd_c()

Use ndmapi_sendcmd() or ndmapi_sendcmd_c() to allow a command to be sent to a IBM® Connect:Direct® application. Following is the format of ndmapi_sendcmd() or ndmapi_sendcmd_c():

int32  rc, resp_moreflag;
struct sendcmd_data ret_data;
rc=ndmapi_sendcmd (error,
                   "select process pnumber=2,",

Following are the parameters for ndmapi_sendcmd() or ndmapi_sendcmd_c():

Parameter Description Value
error A pointer to a IBM Connect:Direct-defined structure that contains error information or status information. Pointer
cmd_text A pointer to the null-terminated text string that specifies the command to send to IBM Connect:Direct. The command text must be followed by a semicolon and terminated with a null.

When you use the submit=filename command from the API, ensure that you allocate enough storage for the Process text. The text of the Process submitted is returned in the text string associated with this parameter when the function completes. If you do not allocate enough storage for the Process text, a core dump can result.

Pointer to a text string
resp_moreflag A pointer to the flag that indicates that more responses are pending for the command just executed. Invoke ndmapi_recvresp() or ndmapi_recvresp_c() to retrieve the extra responses. Pointer to a flag
ret_data A pointer to a structure containing internal response information for a command. The structure is:
struct sendcmd_data  {
		char  * cmd_name;
		ulong cmd_id;
		long data1;
		long data2;
		long data3;
Pointer to a structure
sendcmd_data Provides the caller with some information about the user request. Because parsing of command text occurs at the CMGR, the End User Application (EUA) has no way to identify the command that was submitted, unless it generated the text. Information about the user request
cmd_name A pointer to a string with the name of the command submitted. The CLI uses this pointer to display completion messages. This field enables you to display unique completion messages without any knowledge of a specific command in the EUA. Pointer to name of command
cmd_id A four-byte identifier of the command that was found in the command text. Following are the four-byte identifiers:
/**************Command IDs*******************/
#define CHANGE_PROCESS 0x43484750  /* "CHGP" */
#define DELETE_PROCESS	 0x44454c50  /* "DELP"*/
#define FLUSH_PROCESS 0x464c5350  /* "FLSP" */
#define SELECT_PROCESS	 0x53454c50  /* "SELP"*/
#define SELECT_STATISTICS 0x53454c53  /* "SELS" */
#define SUBMIT 0x5355424d  /* "SUBM" */
#define TRACE_API 0x41504920  /* "API " */
#define TRACE_CMGR 0x434d4752  /* "CMGR" */
#define TRACE_SMGR 0x534d4752  /* "SMGR" */
#define TRACE_PMGR 0x504d4752  /* "PMGR" */
#define TRACE_COM 0x434f4d4d  /* "COMM"*/
#define TRACE	 0x54524143  /* "TRAC" */
#define STOPNDM 0x53544F50   /* "STOP" */

The CLI uses these identifiers to ensure that rules are being followed. For instance, if an ndmapi_sendcmd returns with the resp_moreflag set and the cmd_id is not SELECT_STATISTICS or SELECT_PROCESS, the CLI generates an error.

Four-byte identifier
data1, data2, and data3 For future expansion. data1 is used with the submit command to return the Process number. data2 is used with the submit command to return the result of the Process (0, 4, 8, or 16)  

The ndmapi_sendcmd_c() function call has the following return codes:

Return Code Description
NDM_NO_ERROR or Process Number

The function completed successfully.


An error occurred. Consult the error structure for detailed error status.

Following is a sample ndmapi_sendcmd() function:

int32  rc, resp_moreflag;
struct sendcmd_data ret_data;
rc=ndmapi_sendcmd (error,
                   "select process pnumber=2 ;",