Example #1
0
/**
 * Destruct
 */
int
ngiSessionInformationDestruct(
    ngSessionInformation_t *info,
    ngLog_t *log,
    int *error)
{
    int result;
    static const char fName[] = "ngiSessionInformationDestruct";

    /* Check the arguments */
    assert(info != NULL);

    /* Finalize */
    result = ngiSessionInformationFinalize(info, log, error);
    if (result == 0) {
        ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't finalize the Session Information.\n"); 
	return 0;
    }

    result = NGI_DEALLOCATE(ngSessionInformation_t, info, log, error);
    if (result == 0) {
        ngLogFatal(log, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't deallocate the storage for Session Information.\n"); 
	return 0;
    }

    /* Success */
    return 1;
}
Example #2
0
/**
 * Socket: Destroy
 */
ngemResult_t
ngrcSocketDestroy(
    ngrcSocket_t *sock)
{
    ngemResult_t ret = NGEM_SUCCESS;
    int result;
    ngLog_t *log = NULL;
    NGEM_FNAME(ngrcSocketDestroy);

    log = ngemLogGetDefault();

    if (sock == NULL) {
        return NGEM_SUCCESS;
    }
 
    if (sock->ngs_fd >= 0) {
        result = close(sock->ngs_fd);
        if (result < 0) {
            ngLogError(log, NGRC_LOGCAT_GT, fName,
                "close: %s.\n", strerror(errno));
            ret = NGEM_FAILED;
        }
        sock->ngs_fd = -1;
    }

    if (sock->ngs_pipe[0] >= 0) {
        result = close(sock->ngs_pipe[0]);
        if (result < 0) {
            ngLogError(log, NGRC_LOGCAT_GT, fName,
                "close: %s.\n", strerror(errno));
            ret = NGEM_FAILED;
        }
        sock->ngs_pipe[0] = -1;
    }

    if (sock->ngs_pipe[1] >= 0) {
        result = close(sock->ngs_pipe[1]);
        if (result < 0) {
            ngLogError(log, NGRC_LOGCAT_GT, fName,
                "close: %s.\n", strerror(errno));
            ret = NGEM_FAILED;
        }
        sock->ngs_pipe[1] = -1;
    }

    NGI_DEALLOCATE(ngrcSocket_t, sock, log, NULL);

    return ret;
}
Example #3
0
/**
 * Destruct.
 */
static int
ngcllLocalMachineInformationDestruct(
    ngclContext_t *context,
    ngcliLocalMachineInformationManager_t *lmInfoMng,
    int *error)
{
    int result;
    static const char fName[] = "ngcllLocalMachineInformationDestruct";

    /* Check the arguments */
    assert(context != NULL);
    assert(lmInfoMng != NULL);

    /* Unregister */
    result = ngcliContextUnregisterLocalMachineInformation(context, lmInfoMng, error);
    if (result == 0) {
	ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,  
	    "Can't unregister the Local Machine Information.\n"); 
	return 0;
    }

    /* Finalize */
    result = ngcllLocalMachineInformationManagerFinalize(context, lmInfoMng, error);
    if (result == 0) {
	ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,  
	    "Can't finalize the Local Machine Information.\n"); 
	return 0;
    }

    /* Deallocate */
    result = NGI_DEALLOCATE(ngcliLocalMachineInformationManager_t,
            lmInfoMng, context->ngc_log, error);
    if (result == 0) {
	ngclLogErrorContext(context, NG_LOGCAT_NINFG_PURE, fName,  
	    "Can't deallocate the Local Machine Information.\n"); 
	return 0;
    }

    /* Success */
    return 1;
}
Example #4
0
/**
 * Construct
 */
ngSessionInformation_t *
ngiSessionInformationConstruct(
    ngLog_t *log,
    int *error)
{
    int result;
    ngSessionInformation_t *info;
    static const char fName[] = "ngiSessionInformationConstruct";

    /* Allocate */
    info = NGI_ALLOCATE(ngSessionInformation_t, log, error);
    if (info == NULL) {
        ngLogError(log, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't allocate the storage for Session Information.\n"); 
	return NULL;
    }

    /* Initialize */
    result = ngiSessionInformationInitialize(info, log, error);
    if (result == 0) {
        ngLogError(log, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't initialize the Session Information.\n"); 
	goto error;
    }

    /* Success */
    return info;

    /* Error occurred */
error:
    result = NGI_DEALLOCATE(ngSessionInformation_t, info, log, NULL);
    if (result == 0) {
        ngLogError(log, NG_LOGCAT_NINFG_PURE, fName,  
            "Can't deallocate the storage for Session Information.\n"); 
	return NULL;
    }

    /* Failed */
    return NULL;
}