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

    /* Allocate */
    info = ngiSessionInformationAllocate(log, error);
    if (info == NULL) {
        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;
    }

    /* 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);
	goto error;
    }

    /* Success */
    return info;

    /* Error occurred */
error:
    result = ngiSessionInformationFree(info, log, error);
    if (result == 0) {
        ngLogPrintf(log, NG_LOG_CATEGORY_NINFG_PURE, NG_LOG_LEVEL_ERROR, NULL,
	    "%s: Can't deallocate the storage for Session Information.\n",
	    fName);
	return NULL;
    }

    /* Failed */
    return NULL;
}
Exemple #2
0
/**
 * 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;
}
Exemple #3
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;
}