/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to pcilib/value.c

  • Committer: Suren A. Chilingaryan
  • Date: 2016-02-23 06:20:33 UTC
  • mfrom: (346.1.18 pcitool)
  • Revision ID: csa@suren.me-20160223062033-mz8qkpm1a2oioveb
Merge Python scripting support from Vasiliy Chernov

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define _POSIX_C_SOURCE 200809L
1
2
#include <stdio.h>
2
3
#include <stdlib.h>
3
4
#include <string.h>
71
72
    return 0;
72
73
}
73
74
 
 
75
int pcilib_set_value_from_string(pcilib_t *ctx, pcilib_value_t *value, const char *str) {
 
76
    size_t len;
 
77
 
 
78
    pcilib_clean_value(ctx, value);
 
79
 
 
80
    len = strlen(str) + 1;
 
81
    if (len < sizeof(value->str)) {
 
82
        memcpy(value->str, str, len);
 
83
        value->sval = value->str;
 
84
    } else {
 
85
        value->data = (void*)strdup(str);
 
86
        if (!value->data) return PCILIB_ERROR_MEMORY;
 
87
 
 
88
        value->size = strlen(str) + 1;
 
89
        value->sval = value->data;
 
90
    }
 
91
    value->type = PCILIB_TYPE_STRING;
 
92
 
 
93
    return 0;
 
94
}
 
95
 
74
96
double pcilib_get_value_as_float(pcilib_t *ctx, const pcilib_value_t *val, int *ret) {
75
97
    int err;
76
98
    double res;