/** * Analyze argument with exit. * This function is called before ngexStubInitialize(). * When the argument which requires immediate exit comes, * This function exits in the function. And not return to caller. */ int ngexStubAnalyzeArgumentWithExit( int argc, char *argv[], ngRemoteClassInformation_t *rcInfo, int *error) { int local_error, result, requireImmediateExit; requireImmediateExit = 0; /* Clear the error */ NGI_SET_ERROR(&local_error, NG_ERROR_NO_ERROR); result = ngexlStubAnalyzeArgumentWithExit( argc, argv, rcInfo, &requireImmediateExit, &local_error); ngexiContext.ngc_error = local_error; NGI_SET_ERROR(error, local_error); if (result == 0) { exit(1); } /* Success */ return requireImmediateExit; }
/** * GetCopy */ int ngclLocalMachineInformationGetCopy( ngclContext_t *context, ngclLocalMachineInformation_t *lmInfo, int *error) { int local_error, result; static const char fName[] = "ngclLocalMachineInformationGetCopy"; /* Clear the error */ NGI_SET_ERROR(&local_error, NG_ERROR_NO_ERROR); /* Is Ninf-G Context valid? */ result = ngcliContextIsValid(context, &local_error); if (result == 0) { ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "Ninf-G Context is not valid.\n"); NGI_SET_ERROR(error, local_error); return 0; } result = ngcllLocalMachineInformationGetCopy( context, lmInfo, &local_error); NGI_SET_ERROR_CONTEXT(context, local_error, NULL); NGI_SET_ERROR(error, local_error); return result; }
/** * Calculation end. */ int ngexStubCalculationEnd(int *error) { int local_error, result; /* Clear the error */ NGI_SET_ERROR(&local_error, NG_ERROR_NO_ERROR); result = ngexlStubCalculationEnd(&local_error); ngexiContext.ngc_error = local_error; NGI_SET_ERROR(error, local_error); return result; }
int ngexIsCanceled(int *error) { int local_error, result; /* Clear the error */ NGI_SET_ERROR(&local_error, NG_ERROR_NO_ERROR); result = ngexlIsCanceled(&local_error); ngexiContext.ngc_error = local_error; NGI_SET_ERROR(error, local_error); return result; }
/** * Get the argument. */ int ngexStubGetArgument(int argumentNo, void *data, int *error) { int local_error, result; /* Clear the error */ NGI_SET_ERROR(&local_error, NG_ERROR_NO_ERROR); result = ngexlStubGetArgument(argumentNo, data, &local_error); ngexiContext.ngc_error = local_error; NGI_SET_ERROR(error, local_error); return result; }
/** * Get request * * This function returned when receive request, which ARGUMENT or EXIT. * Otherwise, process the requests and not returned. * * @return * This function returns method ID. The value of method ID is greater equal 0. * Otherwise, returns NGEXI_EXIT when received exit request and returns * NGEXI_FAIL when error occurred. */ int ngexStubGetRequest(int *methodID, int *error) { int local_error, result; /* Clear the error */ NGI_SET_ERROR(&local_error, NG_ERROR_NO_ERROR); result = ngexlStubGetRequest(methodID, &local_error); ngexiContext.ngc_error = local_error; NGI_SET_ERROR(error, local_error); return result; }
/** * Get the information. * * Note: * Lock the list before using this function, and unlock the list after use. */ ngcliLocalMachineInformationManager_t * ngcliLocalMachineInformationCacheGet( ngclContext_t *context, int *error) { int result; static const char fName[] = "ngcliLocalMachineInformationCacheGet"; /* Is context valid? */ result = ngcliContextIsValid(context, error); if (result == 0) { ngLogFatal(NULL, NG_LOGCAT_NINFG_PURE, fName, "Ninf-G Context is not valid.\n"); return NULL; } if (context->ngc_lmInfo == NULL) { /* Not found */ NGI_SET_ERROR(error, NG_ERROR_NOT_EXIST); ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't get LocalMachineInformation list.\n"); return NULL; } return context->ngc_lmInfo; }
/** * ObserveItem: Unregister */ static int ngcllObserveItemUnregister( ngclContext_t *context, ngcliObserveThread_t *observe, ngcliObserveItem_t *observeItem, int *error) { ngcliObserveItem_t **tail; static const char fName[] = "ngcllObserveItemUnregister"; /* Check the arguments */ assert(context != NULL); assert(observe != NULL); assert(observeItem != NULL); /* Find the observeItem */ tail = &observe->ngot_item_head; while ((*tail != NULL) && (*tail != observeItem)) { tail = &(*tail)->ngoi_next; } if (*tail == NULL) { NGI_SET_ERROR(error, NG_ERROR_NOT_EXIST); ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't find the ObserveItem in context.\n", fName); return 0; } /* Unregister the observeItem */ *tail = (*tail)->ngoi_next; /* Success */ return 1; }
static int ngexlStubCalculationEnd(int *error) { int result; ngLog_t *log; ngexiContext_t *context; ngiProtocol_t *protocol; ngexiExecutableStatus_t status; static const char fName[] = "ngexlStubCalculationEnd"; /* Initialize the local variables */ context = &ngexiContext; protocol = context->ngc_protocol; log = context->ngc_log; /* Set end time */ result = ngexiContextSetMethodEndTime(context, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't set the End Time.\n"); return 0; } /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "Calculation finished.\n"); /* Get status */ status = ngexiContextExecutableStatusGet(context, error); /* Check Status */ switch(status) { case NGEXI_EXECUTABLE_STATUS_CANCEL_REQUESTED: case NGEXI_EXECUTABLE_STATUS_RESET_REQUESTED: case NGEXI_EXECUTABLE_STATUS_EXIT_REQUESTED: case NGEXI_EXECUTABLE_STATUS_PULL_WAIT: case NGEXI_EXECUTABLE_STATUS_END: return 1; case NGEXI_EXECUTABLE_STATUS_CALCULATING: /* Do nothing, go next */ break; default: NGI_SET_ERROR(error, NG_ERROR_INVALID_STATE); ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Unexpected state: %d.\n", status); return 0; } /* Send notify */ result = ngexiProtocolNotifyCalculationEnd( context, protocol, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't send the notify Calculation End.\n"); return 0; } /* Success */ return 1; }
static int ngcllLocalMachineInformationRelease( ngclContext_t *context, ngclLocalMachineInformation_t *lmInfo, int *error) { int result; ngLog_t *log; int ret = 1; static const char fName[] = "ngcllLocalMachineInformationRelease"; /* Check the arguments */ assert(context != NULL); if (lmInfo == NULL) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Invalid argument.\n"); return 0; } log = context->ngc_log; /* Deallocate the members */ if (lmInfo->nglmi_hostName != NULL) ngiFree(lmInfo->nglmi_hostName, log, error); if (lmInfo->nglmi_tmpDir != NULL) ngiFree(lmInfo->nglmi_tmpDir, log, error); if (lmInfo->nglmi_invokeServerLog != NULL) ngiFree(lmInfo->nglmi_invokeServerLog, log, error); if (lmInfo->nglmi_commProxyLog != NULL) ngiFree(lmInfo->nglmi_commProxyLog, log, error); if (lmInfo->nglmi_infoServiceLog != NULL) ngiFree(lmInfo->nglmi_infoServiceLog, log, error); if (lmInfo->nglmi_signals != NULL) ngiFree(lmInfo->nglmi_signals, log, error); /* Release Log Information */ result = ngiLogInformationFinalize(&lmInfo->nglmi_logInfo, log, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't release Log Information.\n"); error = NULL; ret = 0; } result = ngiLogLevelInformationFinalize(&lmInfo->nglmi_logLevels, log, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't release Log Levels Information.\n"); error = NULL; ret = 0; } /* Initialize the members */ ngcllLocalMachineInformationInitializeMember(lmInfo); /* Success */ return ret; }
/** * Free the information storage. (not Manager) */ int ngcliLocalMachineInformationFree( ngclContext_t *context, ngclLocalMachineInformation_t *lmInfo, int *error) { int result; ngLog_t *log; static const char fName[] = "ngcliLocalMachineInformationFree"; /* Is context valid? */ result = ngcliContextIsValid(context, error); if (result == 0) { ngLogFatal(NULL, NG_LOGCAT_NINFG_PURE, fName, "Ninf-G Context is not valid.\n"); return 0; } log = context->ngc_log; /* Check the arguments */ if (lmInfo == NULL) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Invalid argument.\n"); return 0; } ngiFree(lmInfo, log, error); return 1; }
/** * Allocate the information storage. (not Manager) */ ngclLocalMachineInformation_t * ngcliLocalMachineInformationAllocate( ngclContext_t *context, int *error) { int result; ngLog_t *log; ngclLocalMachineInformation_t *lmInfo; static const char fName[] = "ngcliLocalMachineInformationAllocate"; /* Is context valid? */ result = ngcliContextIsValid(context, error); if (result == 0) { ngLogFatal(NULL, NG_LOGCAT_NINFG_PURE, fName, "Ninf-G Context is not valid.\n"); return 0; } log = context->ngc_log; /* Allocate new storage */ lmInfo = ngiCalloc( 1, sizeof (ngclLocalMachineInformation_t), log, error); if (lmInfo == NULL) { NGI_SET_ERROR(error, NG_ERROR_MEMORY); ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't allocate the storage " "for LocalMachineInformationManager.\n"); return NULL; } return lmInfo; }
char * ngclGetVersion(int *error) { char *versionFull, *versionStart, *versionReturn, *versionEnd; NGI_SET_ERROR(error, NG_ERROR_NO_ERROR); versionFull = "$AIST_Release: 4.2.4 $"; /** * If version string replaced to the keyword by the release script, * a character : (colon) will appear. * If not, then the source was CVS checked out one. * That's not released Ninf-G. */ versionStart = strchr(versionFull, ':'); if (versionStart != NULL) { /* skip first ' ' */ while (*versionStart == ' ') { versionStart++; } versionReturn = strdup(versionStart); /* cut last '$' */ versionEnd = strrchr(versionReturn, '$'); if (versionEnd != NULL) { *versionEnd = '\0'; } } else { versionReturn = strdup("CVS"); } return versionReturn; }
/** * Initialize */ int ngexStubInitialize( int argc, char *argv[], ngRemoteClassInformation_t *rcInfo, int *error) { int local_error, result; /* Clear the error */ NGI_SET_ERROR(&local_error, NG_ERROR_NO_ERROR); result = ngexlStubInitialize(argc, argv, rcInfo, 0, &local_error); ngexiContext.ngc_error = local_error; NGI_SET_ERROR(error, local_error); return result; }
/** * Information delete. */ int ngcliLocalMachineInformationCacheUnregister( ngclContext_t *context, int *error) { int result; static const char fName[] = "ngcliLocalMachineInformationCacheUnregister"; /* Is context valid? */ result = ngcliContextIsValid(context, error); if (result == 0) { ngLogFatal(NULL, NG_LOGCAT_NINFG_PURE, fName, "Ninf-G Context is not valid.\n"); return 0; } /* Lock the list */ result = ngcliLocalMachineInformationListWriteLock(context, context->ngc_log, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't lock LocalMachineInformation list.\n"); return 0; } /* Is information registered? */ if (context->ngc_lmInfo == NULL) { /* Not registered */ NGI_SET_ERROR(error, NG_ERROR_NOT_EXIST); ngcliLocalMachineInformationListWriteUnlock(context, context->ngc_log, NULL); ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't unregister DefaultRemoteMachineInformation list.\n"); return 0; } /* Delete */ result = ngcllLocalMachineInformationDestruct( context, context->ngc_lmInfo, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't destruct LocalMachineInformation.\n"); return 0; } /* Unlock the list */ result = ngcliLocalMachineInformationListWriteUnlock(context, context->ngc_log, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't unlock LocalMachineInformation list.\n"); return 0; } return 1; }
/** * JobStartTimeout: Time change event arrived. */ static int ngcllJobStartTimeoutEventTimeSet( void *arg, ngiIOhandle_t *handle, ngiIOhandleState_t state, ngLog_t *argLog, int *argError) { static const char fName[] = "ngcllJobStartTimeoutEventTimeSet"; int *error, errorEntity; ngclContext_t *context; time_t timeoutTime; ngLog_t *log; int result; /* Check the arguments */ assert(arg != NULL); context = (ngclContext_t *)arg; log = context->ngc_log; error = &errorEntity; NGI_SET_ERROR(error, NG_ERROR_NO_ERROR); if (state == NGI_IOHANDLE_STATE_CANCELED) { ngclLogDebugContext(context, NG_LOGCAT_NINFG_PURE, fName, "job start timeout event time change callback canceled.\n"); return 1; } assert(state == NGI_IOHANDLE_STATE_NORMAL); /* Get earliest timeout time */ result = ngcllJobStartTimeoutGetEarliestTimeoutTime( context, &timeoutTime, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Getting earliest timeout time failed.\n"); return 0; } /* Set new timeout time */ result = ngiIOhandleTimeEventTimeSet( context->ngc_jobStartTimeoutHandle, timeoutTime, log, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Set the event time failed.\n"); return 0; } /* Success */ return 1; }
/** * Allocate */ ngSessionInformation_t * ngiSessionInformationAllocate(ngLog_t *log, int *error) { ngSessionInformation_t *info; static const char fName[] = "ngiSessionInformationAllocate"; info = globus_libc_calloc(1, sizeof (ngSessionInformation_t)); if (info == NULL) { NGI_SET_ERROR(error, NG_ERROR_MEMORY); ngLogPrintf(log, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't allocate the storage for Session Information.\n", fName); return NULL; } /* Success */ return info; }
/** * Allocate */ NET_Communicator * ngiNetCommunicatorAllocate(ngLog_t *log, int *error) { NET_Communicator *netComm; static const char fName[] = "ngiNetCommunicatorAllocate"; netComm = globus_libc_calloc(1, sizeof (NET_Communicator)); if (netComm == NULL) { NGI_SET_ERROR(error, NG_ERROR_MEMORY); ngLogPrintf(log, NG_LOG_CATEGORY_NINFG_PROTOCOL, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't allocate the storage for Communicator.", fName); return NULL; } /* Success */ return netComm; }
/** * Initialize the members. */ int ngcliLocalMachineInformationInitialize( ngclContext_t *context, ngclLocalMachineInformation_t *lmInfo, int *error) { int result; ngLog_t *log; static const char fName[] = "ngcliLocalMachineInformationInitialize"; /* Is context valid? */ result = ngcliContextIsValid(context, error); if (result == 0) { ngLogFatal(NULL, NG_LOGCAT_NINFG_PURE, fName, "Ninf-G Context is not valid.\n"); return 0; } log = context->ngc_log; /* Check the arguments */ if (lmInfo == NULL) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Invalid argument.\n"); return 0; } ngcllLocalMachineInformationInitializeMember(lmInfo); result = ngiLogInformationInitialize(&lmInfo->nglmi_logInfo, log, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the log information.\n"); return 0; } result = ngiLogLevelInformationInitialize(&lmInfo->nglmi_logLevels, log, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the log levels.\n"); return 0; } /* Success */ return 1; }
/** * Initialize XDR */ static int nglNetCommunicatorInitializeXDR( NET_Communicator *netComm, int dataType, int nElements, ngLog_t *log, int *error) { size_t xdrNbytes; int result; static const char fName[] = "nglNetCommunicatorInitializeXDR"; /* Check tha arguments */ assert(netComm != NULL); assert(netComm->nc_xdrBuffer == NULL); assert(nElements > 0); /* Get the number of bytes of data */ result = ngiNetCommunicatorGetDataSize( netComm, dataType, &xdrNbytes, log, error); if ((result == 0) || (nBytes < 0)) { ngLogPrintf(log, NG_LOG_CATEGORY_NINFG_PROTOCOL, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't get the number of bytes of data.\n", fName); return 0; } netComm->nc_xdrNbytes = xdrNbytes * nElements; /* Allocate the data buffer */ netComm->nc_xdrBuffer = globus_libc_calloc(1, netComm->nc_xdrNbytes); if (netComm->nc_xdrBuffer == NULL) { NGI_SET_ERROR(error, NG_ERROR_MEMORY); ngLogPrintf(log, NG_LOG_CATEGORY_NINFG_PROTOCOL, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't allocate the storage for Data Buffer.\n", fName); return 0; } /* Initialize the XDR stream */ xdrmem_create( &netComm->nc_xdrStream, netComm->nc_xdrBuffer, nBytes, XDR_FREE); xdrmem_create( &netComm->nc_xdrStream, netComm->nc_xdrBuffer, nBytes, XDR_ENCODE); /* Success */ return 1; }
/** * JobStartTimeout: Time event arrived. */ static int ngcllJobStartTimeoutEvent( void *arg, ngiIOhandle_t *handle, ngiIOhandleState_t state, ngLog_t *argLog, int *argError) { static const char fName[] = "ngcllJobStartTimeoutEvent"; int *error, errorEntity; ngclContext_t *context; int result; /* Check the arguments */ assert(arg != NULL); context = (ngclContext_t *)arg; error = &errorEntity; NGI_SET_ERROR(error, NG_ERROR_NO_ERROR); if (state == NGI_IOHANDLE_STATE_CANCELED) { ngclLogDebugContext(context, NG_LOGCAT_NINFG_PURE, fName, "job start timeout event callback canceled.\n"); return 1; } assert(state == NGI_IOHANDLE_STATE_NORMAL); ngclLogInfoContext(context, NG_LOGCAT_NINFG_PURE, fName, "Checking job start timeout." " May be, one executable handle was timeout.\n"); /* Check the job start timeout */ result = ngcllJobStartTimeoutCheck(context, error); if (result == 0) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "checking job start timeout failed.\n"); return 0; } /* Success */ return 1; }
/** * Start the measurement. */ int ngiSessionInformationStartMeasurement( ngSessionInformation_t *info, int nArguments, ngLog_t *log, int *error) { int result; static const char fName[] = "ngiSessionInformationStartMeasurement"; /* Check tha arguments */ assert(info != NULL); assert(nArguments >= 0); assert(info->ngsi_compressionInformation == NULL); /* Initialize */ result = ngiSessionInformationInitialize(info, log, error); if (result == 0) { ngLogPrintf(log, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't initialize the Session Information.\n", fName); return 0; } /* Allocate the storage for Compression Information */ info->ngsi_nCompressionInformations = nArguments; if (nArguments > 0) { info->ngsi_compressionInformation = globus_libc_calloc( nArguments, sizeof (*info->ngsi_compressionInformation)); if (info->ngsi_compressionInformation == NULL) { NGI_SET_ERROR(error, NG_ERROR_MEMORY); ngLogPrintf(log, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't allocate the storage for Session Information.\n", fName); return 0; } } /* Success */ return 1; }
/** * ObserveItem: Allocate */ static ngcliObserveItem_t * ngcllObserveItemAllocate( ngclContext_t *context, int *error) { ngcliObserveItem_t *observeItem; static const char fName[] = "ngcllObserveItemAllocate"; /* Allocate */ observeItem = globus_libc_calloc(1, sizeof(ngcliObserveItem_t)); if (observeItem == NULL) { NGI_SET_ERROR(error, NG_ERROR_MEMORY); ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't allocate the storage for ObserveItem.\n", fName); return NULL; } /* Success */ return observeItem; }
/** * ObserveThread: Finalize */ static int ngcllObserveThreadFinalize( ngclContext_t *context, ngcliObserveThread_t *observe, int *error) { static const char fName[] = "ngcllObserveThreadFinalize"; int result; /* Check the arguments */ assert(context != NULL); assert(observe != NULL); /* log */ ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_DEBUG, NULL, "%s: Finalize the Observe Thread module.\n", fName); if (observe->ngot_continue != 0) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_ERROR, NULL, "%s: Observe Thread is not stopped.\n", fName); return 0; } result = ngcllObserveThreadFinalizeMutexAndCond( context, &context->ngc_observe, error); if (result == 0) { ngclLogPrintfContext(context, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_ERROR, NULL, "%s: Can't finalize the Mutex and Condition Variable.\n", fName); return 0; } ngcllObserveThreadInitializeMember(observe); /* Success */ return 1; }
/** * Information append. */ int ngcliLocalMachineInformationCacheRegister( ngclContext_t *context, ngclLocalMachineInformation_t *lmInfo, int *error) { int result; ngcliLocalMachineInformationManager_t *lmInfoMng; static const char fName[] = "ngcliLocalMachineInformationCacheRegister"; /* Is context valid? */ result = ngcliContextIsValid(context, error); if (result == 0) { ngLogFatal(NULL, NG_LOGCAT_NINFG_PURE, fName, "Ninf-G Context is not valid.\n"); return 0; } /* Check the arguments */ if (lmInfo == NULL) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Invalid argument.\n"); return 0; } /* Note : No Replace for Local Machine Information. */ /* Construct */ lmInfoMng = ngcllLocalMachineInformationConstruct(context, lmInfo, error); if (lmInfoMng == NULL) { ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName, "Can't construct Local Machine Information.\n"); return 0; } /* Success */ return 1; }
static int ngexlStubGetArgument(int argumentNo, void *data, int *error) { int result; int methodID; ngLog_t *log; ngiArgument_t *arg; ngiArgumentPointer_t src, dest; ngRemoteMethodInformation_t *rmInfo; ngexiContext_t *context; static const char fName[] = "ngexlStubGetArgument"; static const ngexiExecutableStatus_t reqStatus[] = { NGEXI_EXECUTABLE_STATUS_CALCULATING, }; /* Initialize the local variables */ context = &ngexiContext; log = context->ngc_log; /* Get methodID */ methodID = ngexiContextGetMethodID(context); /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "Getting argument %3d for method %d from Context.\n", argumentNo, methodID); /* Check the status */ result = ngexiContextExecutableStatusCheck( context, &reqStatus[0], NGI_NELEMENTS(reqStatus), log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Invalid state.\n"); return 0; } /* Get the Method Information */ rmInfo = ngexiRemoteMethodInformationGet( context, methodID, log, error); if (rmInfo == NULL) { ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName, "Remote Method Information is not found.\n"); return 0; } /* Get the Argument Data */ ngexiContextGetMethodArgument(context, &arg); if (arg == NULL) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName, "Argument Data is NULL.\n"); return 0; } if (arg->nga_nArguments < 0) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName, "The number of Argument Data is smaller than zero.\n"); return 0; } if (arg->nga_nArguments > rmInfo->ngrmi_nArguments) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName, "The number of Argument Data %d is greater than maximum %d.\n", arg->nga_nArguments, rmInfo->ngrmi_nArguments); return 0; } if (argumentNo < 0) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName, "The requested Argument No. %d is smaller equal zero.\n", argumentNo); return 0; } if (argumentNo >= rmInfo->ngrmi_nArguments) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName, "The number of Argument Data %d is greater than maximum %d.\n", argumentNo, rmInfo->ngrmi_nArguments); return 0; } /* Is argument scalar variable? */ src = arg->nga_argument[argumentNo].ngae_pointer; if (arg->nga_argument[argumentNo].ngae_dataType == NG_ARGUMENT_DATA_TYPE_FILENAME) { if (arg->nga_argument[argumentNo].ngae_tmpFileNameTable == NULL) { *(char **)data = NULL; } else if (arg->nga_argument[argumentNo].ngae_nDimensions <= 0) { *(char **)data = arg->nga_argument[argumentNo].ngae_tmpFileNameTable[0]; } else { *(char ***)data = arg->nga_argument[argumentNo].ngae_tmpFileNameTable; } } else if (arg->nga_argument[argumentNo].ngae_dataType == NG_ARGUMENT_DATA_TYPE_STRING) { if (src.ngap_string == NULL) { *(char **)data = NULL; } else if (arg->nga_argument[argumentNo].ngae_nDimensions <= 0) { *(char **)data = src.ngap_stringArray[0]; } else { *(char ***)data = src.ngap_stringArray; } } else if (arg->nga_argument[argumentNo].ngae_nDimensions != 0) { *(void **)data = src.ngap_void; } else { dest.ngap_void = data; result = ngiGetArgumentData( arg->nga_argument[argumentNo].ngae_dataType, src, dest, log, error); if (result == 0) { ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName, "Can't get the Argument Data.\n"); return 0; } } /* log */ ngLogDebug(log, NG_LOGCAT_NINFG_PURE, fName, "Getting argument %3d for method %d finished.\n", argumentNo, methodID); /* Success */ return 1; }
static int ngexlStubInitialize( int argc, char *argv[], ngRemoteClassInformation_t *rcInfo, int rank, int *error) { int result; ngCommLogPairInfo_t pairInfo; char host[NGI_HOST_NAME_MAX]; ngLogConstructArgument_t logCarg; int logCargInitialized = 0; ngLogInformation_t *logInfo = NULL; ngLog_t *log = NULL; static const char fName[] = "ngexlStubInitialize"; /* Is argc valid? */ if (argc <= 1) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "The argc %d is smaller equal 1.\n", argc); return 0; } /* Is argv valid? */ if (argv == NULL) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "The argv is NULL.\n"); return 0; } /* Is argv[1] valid? */ if (argv[1] == NULL) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "The argv[1] is NULL.\n"); return 0; } if (rank < 0) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "rank %d is a negative number.\n", rank); return 0; } if (rank == 0) { /* Initialize the Signal Manager */ result = ngexiSignalManagerInitialize(NULL, error); if (result == 0) { ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the Signal Manager.\n"); return 0; } /* Initialize the Context */ result = ngexiContextInitialize( &ngexiContext, argc, argv, rcInfo, rank, error); if (result == 0) { ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the Context.\n"); return 0; } ngexiContextInitialized = 1; log = ngexiContext.ngc_log; /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "Ninf-G Executable Context was created.\n"); /* Negotiation */ result = ngexiProcessNegotiation(&ngexiContext, log, error); if (result == 0) { ngLogError(ngexiContext.ngc_log, NG_LOGCAT_NINFG_PURE, fName, "Negotiation failed.\n"); return 0; } /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "Executable ID = %d.\n", ngexiContext.ngc_commInfo.ngci_executableID); /* Change log file name to executableID numbered file */ result = ngiLogExecutableIDchanged(log, ngexiContext.ngc_commInfo.ngci_executableID, error); if (result == 0) { ngLogError(ngexiContext.ngc_log, NG_LOGCAT_NINFG_PURE, fName, "Can't change the log file name.\n"); return 0; } /* Construct the Communication Log */ if (ngexiContext.ngc_lmInfo.nglmi_commLogEnable != 0) { /* Create the message */ logInfo = &ngexiContext.ngc_lmInfo.nglmi_commLogInfo; result = ngLogConstructArgumentInitialize(&logCarg, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize log construct argument.\n"); goto error; } logCargInitialized = 1; if (logInfo->ngli_filePath == NULL) { logCarg.nglca_output = NG_LOG_STDERR; } else { logCarg.nglca_output = NG_LOG_FILE; logCarg.nglca_nFiles = logInfo->ngli_nFiles; logCarg.nglca_maxFileSize = logInfo->ngli_maxFileSize; logCarg.nglca_overWriteDir = logInfo->ngli_overWriteDir; logCarg.nglca_appending = 0;/* false */ logCarg.nglca_filePath = ngiStrdup( logInfo->ngli_filePath, log, error); if (logCarg.nglca_filePath == NULL) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't copy string.\n"); goto error; } if (logInfo->ngli_suffix != NULL) { logCarg.nglca_suffix = ngiStrdup( logInfo->ngli_suffix, log, error); if (logCarg.nglca_suffix == NULL) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't copy string.\n"); goto error; } } } result = ngiHostnameGet(&host[0], sizeof (host), NULL, error); if (result == 0) { ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "Can't get the host name.\n"); goto error; } pairInfo.ngcp_localAppName = "Executable"; pairInfo.ngcp_localHostname = host; pairInfo.ngcp_remoteAppName = "Client"; pairInfo.ngcp_remoteHostname = ngexiContext.ngc_commInfo.ngci_hostname; ngexiContext.ngc_commLog = ngCommLogConstructForExecutable( &pairInfo, ngexiContext.ngc_commInfo.ngci_executableID, &logCarg, log, error); if (ngexiContext.ngc_commLog == NULL) { ngLogError(ngexiContext.ngc_log, NG_LOGCAT_NINFG_PURE, fName, "Can't create the Communication Log.\n"); goto error; } /* Register the Communication Log */ result = ngiCommunicationLogRegister( ngexiContext.ngc_communication, ngexiContext.ngc_commLog, ngexiContext.ngc_log, error); if (result == 0) { ngLogError(ngexiContext.ngc_log, NG_LOGCAT_NINFG_PURE, fName, "Can't register the Communication Log.\n"); goto error; } result = ngLogConstructArgumentFinalize(&logCarg, log, error); logCargInitialized = 0; if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't get the host name.\n"); goto error; } } /* Switch stdout/stderr output if necessary */ result = ngexiContextSwitchStdoutStderr( &ngexiContext, ngexiContext.ngc_commInfo.ngci_executableID, error); if (result == 0) { ngLogError(ngexiContext.ngc_log, NG_LOGCAT_NINFG_PURE, fName, "Can't switch stdout/stderr output.\n"); return 0; } /* log */ ngLogInfo(ngexiContext.ngc_log, NG_LOGCAT_NINFG_PURE, fName, "Initialize was successful.\n"); /* Register the I/O Callback */ result = ngexiProtocolRegisterCallback(&ngexiContext, error); if (result == 0) { ngLogError(ngexiContext.ngc_log, NG_LOGCAT_NINFG_PURE, fName, "Can't register I/O callback.\n"); return 0; } } else { /* rank != 0 */ /* Initialize the Context */ result = ngexiContextInitialize( &ngexiContext, argc, argv, rcInfo, rank, error); if (result == 0) { ngLogError(NULL, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the Context.\n"); return 0; } ngexiContextInitialized = 1; } /* Success */ return 1; error: if (logCargInitialized != 0) { result = ngLogConstructArgumentFinalize(&logCarg, log, NULL); logCargInitialized = 0; if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't get the host name.\n"); goto error; } } return 0; }
static int ngexlStubGetRequest(int *methodID, int *error) { int result; int finished; char *string; ngLog_t *log; int returnCode; ngexiContext_t *context; ngiProtocol_t *protocol; ngexiExecutableStatus_t status; static const char fName[] = "ngexlStubGetRequest"; static ngexiExecutableStatus_t waitStatus[] = { NGEXI_EXECUTABLE_STATUS_CALCULATING, NGEXI_EXECUTABLE_STATUS_CANCEL_REQUESTED, NGEXI_EXECUTABLE_STATUS_RESET_REQUESTED, NGEXI_EXECUTABLE_STATUS_EXIT_REQUESTED, NGEXI_EXECUTABLE_STATUS_END, }; /* Initialize the local variables */ context = &ngexiContext; protocol = context->ngc_protocol; log = context->ngc_log; returnCode = NGEXI_FAIL; /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "GetRequest started.\n"); /* Check the arguments */ if (methodID == NULL) { NGI_SET_ERROR(error, NG_ERROR_INVALID_ARGUMENT); ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "methodID is NULL.\n"); return NGEXI_FAIL; } /* Get status */ status = ngexiContextExecutableStatusGet(context, error); /* Check Status */ if ((status < NGEXI_EXECUTABLE_STATUS_IDLE) || (status > NGEXI_EXECUTABLE_STATUS_END)) { NGI_SET_ERROR(error, NG_ERROR_INVALID_STATE); ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Unexpected state: %d.\n", status); return NGEXI_FAIL; } finished = 0; while (finished == 0) { /* Wait the status */ result = ngexiContextExecutableStatusWait( context, &waitStatus[0], NGI_NELEMENTS(waitStatus), &status, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't wait the status.\n"); goto error; } switch (status) { case NGEXI_EXECUTABLE_STATUS_CANCEL_REQUESTED: case NGEXI_EXECUTABLE_STATUS_RESET_REQUESTED: case NGEXI_EXECUTABLE_STATUS_EXIT_REQUESTED: /* Process request */ result = ngexiProtocolReplyByStatus( context, protocol, status, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't send the reply.\n"); goto error; } if (status == NGEXI_EXECUTABLE_STATUS_EXIT_REQUESTED) { returnCode = NGEXI_EXIT; finished = 1; /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "GetRequest is returned by EXIT.\n"); } break; case NGEXI_EXECUTABLE_STATUS_CALCULATING: *methodID = ngexiContextGetMethodID(context); returnCode = NGEXI_INVOKE_METHOD; finished = 1; /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "GetRequest is returned by Invoke method. MethodID = %d.\n", *methodID); break; case NGEXI_EXECUTABLE_STATUS_END: default: /* log */ string = ngexiContextExecutableStatusStringGet(status, log, NULL); if (string == NULL) { string = "Not valid status"; } ngLogWarn(log, NG_LOGCAT_NINFG_PURE, fName, "Unexpected status \"%s\":%d was found.\n", string, status); goto error; } } /* Success */ return returnCode; /* Error occurred */ error: ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "return by abnormal error.\n"); /* Failed */ return NGEXI_FAIL; }
/** * Decode by the string encoded by ngiCommunicationProxyEncode(). */ char * ngiCommunicationProxyDecode( const char *src, ngLog_t *log, int *error) { const char *p; char *q; int len; int req = 0; char hex[3];/* XX\0 */ int i; int found; char *ret = NULL; static const char fName[] = "ngiCommunicationProxyDecode"; assert(src != NULL); len = 0; req = 0; for (p = src;*p != '\0';++p) { if (req == 0) { if (*p == '%') { req = 2; /* %XX */ /* ^^ */ } len++; } else { found = 0; for (i = 0;nglCharSetXdigit[i] != '\0';++i) { if (nglCharSetXdigit[i] == *p) { found = 1; break; } } if (found == 0) { /* Error */ ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "%s: Invalid String.\n", src); NGI_SET_ERROR(error, NG_ERROR_SYNTAX); return NULL; } req--; } } if (req > 0) { NGI_SET_ERROR(error, NG_ERROR_SYNTAX); ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "%s: Invalid String.\n", src); return NULL; } len++; /* for '\0' */ ret = ngiMalloc(len, log, error); if (ret == NULL) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't allocate storage for string.\n"); return NULL; } q = ret; for (p = src;*p != '\0';++p) { if (*p == '%') { hex[0] = *++p; hex[1] = *++p; hex[2] = '\0'; assert(hex[0] != '\0'); assert(hex[1] != '\0'); *q = (unsigned char)strtol(hex, NULL, 16); } else if (*p == '+') { *q = ' '; } else { *q = *p; } q++; } *q = '\0'; return ret; }
/** * Callback function is performed. */ int ngexStubCallback(int callbackID, int *error, ...) { int result; va_list ap; int finished; int methodID; char *string; ngLog_t *log; int i, count = 0; ngiProtocol_t *protocol; ngexiContext_t *context; ngexiExecutableStatus_t status; ngiArgument_t *arg, *callbackArg; ngRemoteMethodInformation_t *rmInfo, *rmInfoCallback; static const char fName[] = "ngexStubCallback"; static ngexiExecutableStatus_t waitStatus[] = { NGEXI_EXECUTABLE_STATUS_CALCULATING, NGEXI_EXECUTABLE_STATUS_CANCEL_REQUESTED, NGEXI_EXECUTABLE_STATUS_RESET_REQUESTED, NGEXI_EXECUTABLE_STATUS_EXIT_REQUESTED, NGEXI_EXECUTABLE_STATUS_END, }; /* Initialize the local variables */ context = &ngexiContext; protocol = context->ngc_protocol; log = context->ngc_log; /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "Performing callback (id=%d).\n", callbackID); /* Get status */ status = ngexiContextExecutableStatusGet(context, error); /* Check Status */ switch(status) { case NGEXI_EXECUTABLE_STATUS_CALCULATING: /* Do nothing, go next */ break; case NGEXI_EXECUTABLE_STATUS_CANCEL_REQUESTED: case NGEXI_EXECUTABLE_STATUS_RESET_REQUESTED: case NGEXI_EXECUTABLE_STATUS_EXIT_REQUESTED: case NGEXI_EXECUTABLE_STATUS_PULL_WAIT: case NGEXI_EXECUTABLE_STATUS_END: NGI_SET_ERROR(error, NG_ERROR_INVALID_STATE); ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "The session is already canceled. (status=%d)\n", status); return 0; default: NGI_SET_ERROR(error, NG_ERROR_INVALID_STATE); ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Unexpected state: %d.\n", status); return 0; } /* Set the callback ID to Protocol */ result = ngiProtocolSetCallbackID(protocol, callbackID, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Can't set the callback ID.\n"); return 0; } /* Get the argument pointer */ va_start(ap, error); /* Get the Method Information */ methodID = ngexiContextGetMethodID(context); rmInfo = ngexiRemoteMethodInformationGet( context, methodID, log, error); if (rmInfo == NULL) { ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName, "Remote Method Information is not found.\n"); return 0; } for (i = 0; i < rmInfo->ngrmi_nArguments; i++) { if (rmInfo->ngrmi_arguments[i].ngai_dataType == NG_ARGUMENT_DATA_TYPE_CALLBACK) { if (count == callbackID) { break; } count += 1; } } if ((i == rmInfo->ngrmi_nArguments) && (count != callbackID)) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Callback ID %d is not valid.\n", callbackID); return 0; } rmInfoCallback = rmInfo->ngrmi_arguments[i].ngai_callback; /* Get the argument */ ngexiContextGetMethodArgument(&ngexiContext, &arg); if (arg == NULL) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Can't get the argument.\n"); return 0; } /* Construct the Argument */ callbackArg = ngiArgumentConstruct( rmInfoCallback->ngrmi_arguments, rmInfoCallback->ngrmi_nArguments, log, error); if (callbackArg == NULL) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't construct the argument.\n"); return 0; } result = ngiArgumentElementInitializeVarg( callbackArg, rmInfoCallback->ngrmi_nArguments, ap, NGI_ARGUMENT_DELIVERY_C, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the Argument Element.\n"); return 0; } /* Initialize the Subscript Value of Argument */ result = ngiArgumentInitializeSubscriptValue( callbackArg, arg, rmInfoCallback->ngrmi_arguments, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't initialize the Argument Element.\n"); return 0; } /* Check the Subscript Value of Argument */ result = ngiArgumentCheckSubscriptValue(callbackArg, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Subscript Value of Argument is not valid.\n"); goto error; } /* Set the Argument for Callback*/ ngexiContextSetCallbackArgument(context, callbackArg); /* Set the argument to protocol */ result = ngiProtocolSetCallbackArgument(protocol, callbackArg, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Can't set the argument to protocol.\n"); return 0; } /* Send Notify Invoke Callback */ result = ngexiProtocolNotifyInvokeCallback( context, protocol, callbackID, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Can't set executable ID to protocol.\n"); return 0; } /* Increment the number of times to which the callback was called */ context->ngc_sessionInfo.ngsi_callbackNtimesCalled++; finished = 0; while (finished == 0) { /* Wait the status */ result = ngexiContextExecutableStatusWait( context, &waitStatus[0], NGI_NELEMENTS(waitStatus), &status, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PURE, fName, "Can't wait the status.\n"); goto error; } switch (status) { case NGEXI_EXECUTABLE_STATUS_CANCEL_REQUESTED: case NGEXI_EXECUTABLE_STATUS_RESET_REQUESTED: case NGEXI_EXECUTABLE_STATUS_EXIT_REQUESTED: /* Do not reply. reply is treated by ngexStubGetRequest */ finished = 1; break; case NGEXI_EXECUTABLE_STATUS_CALCULATING: finished = 1; break; case NGEXI_EXECUTABLE_STATUS_END: default: /* log */ string = ngexiContextExecutableStatusStringGet(status, log, NULL); if (string == NULL) { string = "Not valid status"; } ngLogWarn(log, NG_LOGCAT_NINFG_PURE, fName, "Unexpected status \"%s\":%d was found.\n", string, status); goto error; } } /* Release the argument pointer */ va_end(ap); /* Release the argument to protocol */ result = ngiProtocolReleaseCallbackArgument(protocol, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Can't release the argument to protocol.\n"); return 0; } /* Release the callback ID to protocol */ result = ngiProtocolReleaseCallbackID(protocol, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Can't release the callback ID to protocol.\n"); return 0; } /* Check canceled */ switch (status) { case NGEXI_EXECUTABLE_STATUS_CANCEL_REQUESTED: case NGEXI_EXECUTABLE_STATUS_RESET_REQUESTED: case NGEXI_EXECUTABLE_STATUS_EXIT_REQUESTED: return 0; default: break; } /* log */ ngLogInfo(log, NG_LOGCAT_NINFG_PURE, fName, "The callback was successfully done (id=%d).\n", callbackID); /* Success */ return 1; /* Error occurred */ error: /* Release the argument pointer */ va_end(ap); /* Release the argument to protocol */ result = ngiProtocolReleaseCallbackArgument(protocol, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Can't release the argument to protocol.\n"); } /* Release the callback ID to protocol */ result = ngiProtocolReleaseCallbackID(protocol, log, error); if (result == 0) { ngLogError(log, NG_LOGCAT_NINFG_PROTOCOL, fName, "Can't release the callback ID to protocol.\n"); } /* Initialize the IDs */ ngiProtocolInitializeID(protocol); return 0; }