示例#1
0
文件: send.c 项目: hxmhuang/CFIO2
int cfio_send_def_var_old(
    int ncid, char *name, cfio_type xtype,
    int ndims, int *dimids,
    size_t *start, size_t *count, int varid)
{
    uint32_t code = FUNC_NC_DEF_VAR;
    size_t size;

    size = cfio_buf_data_size(sizeof(size_t));
    size += cfio_buf_data_size(sizeof(uint32_t));
    size += cfio_buf_data_size(sizeof(int));
    size += cfio_buf_str_size(name);
    size += cfio_buf_data_size(sizeof(cfio_type));
    size += cfio_buf_data_array_size(ndims, sizeof(int));
    size += cfio_buf_data_array_size(ndims, sizeof(size_t));
    size += cfio_buf_data_array_size(ndims, sizeof(size_t));
    size += cfio_buf_data_size(sizeof(int));

    ensure_free_space(buffer, size, cfio_send_client_buf_free);

    cfio_buf_pack_data(&size, sizeof(size_t) , buffer);
    cfio_buf_pack_data(&code , sizeof(uint32_t), buffer);
    cfio_buf_pack_data(&ncid, sizeof(int), buffer);
    cfio_buf_pack_str(name, buffer);
    cfio_buf_pack_data(&xtype, sizeof(cfio_type), buffer);
    cfio_buf_pack_data_array(dimids, ndims, sizeof(int), buffer);
    cfio_buf_pack_data_array(start, ndims, sizeof(size_t), buffer);
    cfio_buf_pack_data_array(count, ndims, sizeof(size_t), buffer);
    cfio_buf_pack_data(&varid, sizeof(int), buffer);

    debug(DEBUG_SEND, "ncid = %d, name = %s, ndims = %u", ncid, name, ndims);

    return CFIO_ERROR_NONE;
}
示例#2
0
文件: send.c 项目: hxmhuang/CFIO2
int cfio_send_put_att(
    int ncid, int varid, char *name,
    cfio_type xtype, size_t len, void *op)
{
    uint32_t code = FUNC_PUT_ATT;
    size_t size;
    size_t att_size;

    cfio_types_size(att_size, xtype);

    size = cfio_buf_data_size(sizeof(size_t));
    size += cfio_buf_data_size(sizeof(uint32_t));
    size += cfio_buf_data_size(sizeof(int));
    size += cfio_buf_data_size(sizeof(int));
    size += cfio_buf_str_size(name);
    size += cfio_buf_data_size(sizeof(cfio_type));
    size += cfio_buf_data_array_size(len, att_size);

    ensure_free_space(buffer, size, cfio_send_client_buf_free);

    cfio_buf_pack_data(&size, sizeof(size_t) , buffer);
    cfio_buf_pack_data(&code , sizeof(uint32_t), buffer);
    cfio_buf_pack_data(&ncid, sizeof(int), buffer);
    cfio_buf_pack_data(&varid, sizeof(int), buffer);
    cfio_buf_pack_str(name, buffer);
    cfio_buf_pack_data(&xtype, sizeof(cfio_type), buffer);
    cfio_buf_pack_data_array(op, len, att_size, buffer);

    debug(DEBUG_SEND, "ncid = %d, varid = %d, name = %s, len = %lu",
          ncid, varid, name, len);

    return CFIO_ERROR_NONE;
}
示例#3
0
文件: send.c 项目: hxmhuang/CFIO2
/**
 *pack msg function
 **/
int cfio_send_def_dim(
    int ncid, char *name, size_t len, int dimid)
{
    uint32_t code = FUNC_NC_DEF_DIM;
    size_t size;

    size = cfio_buf_data_size(sizeof(size_t));
    size += cfio_buf_data_size(sizeof(uint32_t));
    size += cfio_buf_data_size(sizeof(int));
    size += cfio_buf_str_size(name);
    size += cfio_buf_data_size(sizeof(size_t));
    size += cfio_buf_data_size(sizeof(int));

    ensure_free_space(buffer, size, cfio_send_client_buf_free);

    cfio_buf_pack_data(&size, sizeof(size_t) , buffer);
    cfio_buf_pack_data(&code, sizeof(uint32_t), buffer);
    cfio_buf_pack_data(&ncid, sizeof(int), buffer);
    cfio_buf_pack_str(name, buffer);
    cfio_buf_pack_data(&len, sizeof(size_t), buffer);
    cfio_buf_pack_data(&dimid, sizeof(int), buffer);

    debug(DEBUG_SEND, "ncid = %d, name = %s, len = %lu", ncid, name, len);

    return CFIO_ERROR_NONE;
}
示例#4
0
文件: dynabuf.c 项目: Jedzia/acm3
// add string version of float to buffer (without terminator)
void DynaBuf_add_double(dynabuf_t* db, double value) {
	char	*write	= ensure_free_space(db, 40);	// reserve 40 chars

	// write up to 30 significant characters. remaining 10 should suffice
	// for sign, decimal point, exponent, terminator etc.
	db->size += sprintf(write, "%.30g", value);
}
示例#5
0
文件: strutil.c 项目: yath/spdroxy
void str_cat_cpl(str *s, const char *cp, size_t len) {
    //debug("cat '%s' (%d)", cp, len);
    ensure_free_space(s, len);
//    debug("s->buf = %p, s->pos = %p, *s->pos = '%c'", s->buf, s->pos, ' ');
//    debug("pos-buf = %d, size = %d", s->pos - s->buf, s->size);
    memcpy(s->pos, cp, len);
    s->pos += len;
    s->size += len;
}
示例#6
0
文件: send.c 项目: hxmhuang/CFIO2
int cfio_send_close(
    int ncid)
{
    uint32_t code = FUNC_NC_CLOSE;
    size_t size;

    size = cfio_buf_data_size(sizeof(size_t));
    size += cfio_buf_data_size(sizeof(uint32_t));
    size += cfio_buf_data_size(sizeof(int));

    ensure_free_space(buffer, size, cfio_send_client_buf_free);

    cfio_buf_pack_data(&size, sizeof(size_t) , buffer);
    cfio_buf_pack_data(&code, sizeof(uint32_t), buffer);
    cfio_buf_pack_data(&ncid, sizeof(int), buffer);

    return CFIO_ERROR_NONE;
}
示例#7
0
文件: send.c 项目: hxmhuang/CFIO2
int cfio_send_enddef(
    int ncid)
{
    uint32_t code = FUNC_NC_ENDDEF;
    size_t size;

    size = cfio_buf_data_size(sizeof(size_t));
    size += cfio_buf_data_size(sizeof(uint32_t));
    size += cfio_buf_data_size(sizeof(int));

    ensure_free_space(buffer, size, cfio_send_client_buf_free);

    cfio_buf_pack_data(&size, sizeof(size_t) , buffer);
    cfio_buf_pack_data(&code, sizeof(uint32_t), buffer);
    cfio_buf_pack_data(&ncid, sizeof(int), buffer);

    debug(DEBUG_SEND, "ncid = %d", ncid);

    return CFIO_ERROR_NONE;
}
示例#8
0
文件: send.c 项目: hxmhuang/CFIO2
int cfio_send_create(
    char *path, int cmode, int ncid)
{
    uint32_t code = FUNC_NC_CREATE;
    size_t size;

    size = cfio_buf_data_size(sizeof(size_t));
    size += cfio_buf_data_size(sizeof(uint32_t));
    size += cfio_buf_str_size(path);
    size += cfio_buf_data_size(sizeof(int));
    size += cfio_buf_data_size(sizeof(int));

    ensure_free_space(buffer, size, cfio_send_client_buf_free);

    cfio_buf_pack_data(&size, sizeof(size_t) , buffer);
    cfio_buf_pack_data(&code, sizeof(uint32_t) , buffer);
    cfio_buf_pack_str(path, buffer);
    cfio_buf_pack_data(&cmode, sizeof(int), buffer);
    cfio_buf_pack_data(&ncid, sizeof(int), buffer);

    debug(DEBUG_SEND, "path = %s; cmode = %d, ncid = %d", path, cmode, ncid);

    return CFIO_ERROR_NONE;
}
示例#9
0
文件: send.c 项目: hxmhuang/CFIO2
int cfio_send_put_vara(
    int ncid, int varid, int ndims,
    size_t *start, size_t *count,
    int fp_type, void *fp)
{
    int i;
    size_t data_len;
    uint32_t code = FUNC_NC_PUT_VARA;
    size_t size;

    debug(DEBUG_SEND, "pack_msg_put_vara_float");
    for(i = 0; i < ndims; i ++) {
        debug(DEBUG_SEND, "start[%d] = %lu", i, start[i]);
    }
    for(i = 0; i < ndims; i ++) {
        debug(DEBUG_SEND, "count[%d] = %lu", i, count[i]);
    }

    data_len = 1;
    for(i = 0; i < ndims; i ++) {
        data_len *= count[i];
    }

    size = cfio_buf_data_size(sizeof(size_t));
    size += cfio_buf_data_size(sizeof(uint32_t));
    size += cfio_buf_data_size(sizeof(int));
    size += cfio_buf_data_size(sizeof(int));
    size += cfio_buf_data_array_size(ndims, sizeof(size_t));
    size += cfio_buf_data_array_size(ndims, sizeof(size_t));
    size += cfio_buf_data_size(sizeof(int));
    switch(fp_type) {
    case CFIO_BYTE :
        size += cfio_buf_data_array_size(data_len, 1);
        break;
    case CFIO_CHAR :
        size += cfio_buf_data_array_size(data_len, sizeof(char));
        break;
    case CFIO_SHORT :
        size += cfio_buf_data_array_size(data_len, sizeof(short));
        break;
    case CFIO_INT :
        size += cfio_buf_data_array_size(data_len, sizeof(int));
        break;
    case CFIO_FLOAT :
        size += cfio_buf_data_array_size(data_len, sizeof(float));
        break;
    case CFIO_DOUBLE :
        size += cfio_buf_data_array_size(data_len, sizeof(double));
        break;
    }

    ensure_free_space(buffer, size, cfio_send_client_buf_free);

    cfio_buf_pack_data(&size, sizeof(size_t) , buffer);
    cfio_buf_pack_data(&code, sizeof(uint32_t), buffer);
    cfio_buf_pack_data(&ncid, sizeof(int), buffer);
    cfio_buf_pack_data(&varid, sizeof(int), buffer);
    cfio_buf_pack_data_array(start, ndims, sizeof(size_t), buffer);
    cfio_buf_pack_data_array(count, ndims, sizeof(size_t), buffer);
    cfio_buf_pack_data(&fp_type, sizeof(int), buffer);
    switch(fp_type) {
    case CFIO_BYTE :
        cfio_buf_pack_data_array(fp, data_len, 1, buffer);
        break;
    case CFIO_CHAR :
        cfio_buf_pack_data_array(fp, data_len, sizeof(char), buffer);
        break;
    case CFIO_SHORT :
        cfio_buf_pack_data_array(fp, data_len, sizeof(short), buffer);
        break;
    case CFIO_INT :
        cfio_buf_pack_data_array(fp, data_len, sizeof(int), buffer);
        break;
    case CFIO_FLOAT :
        cfio_buf_pack_data_array(fp, data_len, sizeof(float), buffer);
        break;
    case CFIO_DOUBLE :
        cfio_buf_pack_data_array(fp, data_len, sizeof(double), buffer);
        break;
    }

    debug(DEBUG_SEND, "ncid = %d, varid = %d, ndims = %d, data_len = %lu",
          ncid, varid, ndims, data_len);

    return CFIO_ERROR_NONE;
}
示例#10
0
文件: dynabuf.c 项目: Jedzia/acm3
// add string version of int to buffer (without terminator)
void DynaBuf_add_signed_long(dynabuf_t* db, signed long value) {
	char	*write	= ensure_free_space(db, INTVAL_MAXCHARACTERS + 1);

	db->size += sprintf(write, "%ld", value);
}