示例#1
0
/**
 * idmef_time_new_from_string:
 * @time: Address where to store the created #idmef_time_t object.
 * @buf: Pointer to a string describing a time in an IDMEF conforming format.
 *
 * Creates an #idmef_time_t object filled with information retrieved
 * from the user provided @buf, containing a string describing a time in a format
 * conforming to the IDMEF definition  (v. 0.10, section 3.2.6).
 *
 * Additionally, the provided time might be separated with white spaces, instead
 * of the IDMEF define 'T' character. The format might not specify a timezone
 * (will assume UTC in this case).
 *
 * The resulting #idmef_time_t object is stored in @time.
 *
 * Returns: 0 on success, a negative value if an error occured.
 */
int idmef_time_new_from_string(idmef_time_t **time, const char *buf)
{
        int ret;

        libidmef_return_val_if_fail(buf, libidmef_error(LIBIDMEF_ERROR_ASSERTION));

        ret = idmef_time_new(time);
        if ( ret < 0 )
                return ret;

        ret = idmef_time_set_from_string(*time, buf);
        if ( ret < 0 ) {
                free(*time);
                return ret;
        }

        return 0;
}
示例#2
0
/**
 * idmef_time_new_from_string:
 * @time: Address where to store the created #idmef_time_t object.
 * @buf: Pointer to a string describing a time in an IDMEF conforming format.
 *
 * Creates an #idmef_time_t object filled with information retrieved
 * from the user provided @buf, containing a string describing a time in a format
 * conforming to the IDMEF definition  (v. 0.10, section 3.2.6).
 *
 * Additionally, the provided time might be separated with white spaces, instead
 * of the IDMEF define 'T' character. The format might not specify a timezone
 * (will assume UTC in this case).
 *
 * The resulting #idmef_time_t object is stored in @time.
 *
 * Returns: 0 on success, a negative value if an error occured.
 */
int idmef_time_new_from_string(idmef_time_t **time, const char *buf)
{
        int ret;

        prelude_return_val_if_fail(buf, prelude_error(PRELUDE_ERROR_ASSERTION));

        ret = idmef_time_new(time);
        if ( ret < 0 )
                return ret;

        ret = idmef_time_set_from_string(*time, buf);
        if ( ret < 0 ) {
                free(*time);
                return ret;
        }

        return 0;
}
示例#3
0
/**
 * idmef_time_new_from_string:
 * @time: Address where to store the created #idmef_time_t object.
 * @buf: Pointer to a string describing a time in an IDMEF conforming format.
 *
 * Creates an #idmef_time_t object filled with information retrieved
 * from the user provided @buf, containing a string describing a time in a format
 * conforming to the IDMEF definition  (v. 0.10, section 3.2.6).
 *
 * Additionally, the provided time might be separated with white spaces, instead
 * of the IDMEF define 'T' character. The format might not specify a timezone
 * (will assume UTC in this case).
 *
 * The resulting #idmef_time_t object is stored in @time.
 *
 * Returns: 0 on success, a negative value if an error occured.
 */
int idmef_time_new_from_string(idmef_time_t **time, const char *buf)
{
        int ret;

        requiem_return_val_if_fail(buf, requiem_error(REQUIEM_ERROR_ASSERTION));

        ret = idmef_time_new(time);
        if ( ret < 0 )
                return ret;

        ret = idmef_time_set_from_string(*time, buf);
        if ( ret < 0 ) {
                free(*time);
                return ret;
        }

        return 0;
}