Example showing how to write a generic GWY file with various kinds of data types.
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <string.h>
 
#define AL(x) (sizeof(x)/sizeof((x)[0]))
 
enum {
    OBJECTS_DATA_LEN = 2,
    STRINGS_DATA_LEN = 3,
};
 
static char char_data[21];
static int32_t int32_data[6];
static int64_t int64_data[15];
static double double_data[13];
 
int
main(void)
{
    GwyfileObject *gwyf, **objects_data;
    char **strings_data;
    unsigned int i;
 
    
                              NULL);
 
    
    strings_data = (char**)malloc(sizeof(char*)*STRINGS_DATA_LEN);
    for (i = 0; i < STRINGS_DATA_LEN; i++) {
        strings_data[i] = (char*)malloc(8);
        snprintf(strings_data[i], 8, "string%u", i);
    }
 
    
    objects_data = (GwyfileObject**)malloc(sizeof(GwyfileObject*)*OBJECTS_DATA_LEN);
    for (i = 0; i < OBJECTS_DATA_LEN; i++)
 
    
        fprintf(stderr, 
"Cannot write test.gwy: %s\n", error->
message);
 
        exit(EXIT_FAILURE);
    }
 
    
 
    return 0;
}
 
bool gwyfile_write_file(GwyfileObject *object, const char *filename, GwyfileError **error)
Writes a GWY file to a named file.
Definition: gwyfile.c:331
 
void gwyfile_error_clear(GwyfileError **error)
Clears a GwyfileError.
Definition: gwyfile.c:8990
 
GwyfileItem * gwyfile_item_new_bool(const char *name, bool value)
Creates a new boolean GWY file item.
Definition: gwyfile.c:5406
 
GwyfileItem * gwyfile_item_new_char_array_copy(const char *name, const char *value, uint32_t array_length)
Creates a new character array GWY file item.
Definition: gwyfile.c:6008
 
GwyfileItem * gwyfile_item_new_char(const char *name, char value)
Creates a new character GWY file item.
Definition: gwyfile.c:5456
 
GwyfileItem * gwyfile_item_new_double_array_copy(const char *name, const double *value, uint32_t array_length)
Creates a new double array GWY file item.
Definition: gwyfile.c:6697
 
GwyfileItem * gwyfile_item_new_double(const char *name, double value)
Creates a new double GWY file item.
Definition: gwyfile.c:5606
 
GwyfileItem * gwyfile_item_new_int32_array_copy(const char *name, const int32_t *value, uint32_t array_length)
Creates a new 32bit integer array GWY file item.
Definition: gwyfile.c:6238
 
GwyfileItem * gwyfile_item_new_int32(const char *name, int32_t value)
Creates a new 32bit integer GWY file item.
Definition: gwyfile.c:5506
 
GwyfileItem * gwyfile_item_new_int64_array_copy(const char *name, const int64_t *value, uint32_t array_length)
Creates a new 64bit integer array GWY file item.
Definition: gwyfile.c:6466
 
GwyfileItem * gwyfile_item_new_int64(const char *name, int64_t value)
Creates a new 64bit integer GWY file item.
Definition: gwyfile.c:5556
 
GwyfileItem * gwyfile_item_new_object_array(const char *name, GwyfileObject **value, uint32_t array_length)
Creates a new object array GWY file item.
Definition: gwyfile.c:7155
 
GwyfileItem * gwyfile_item_new_string_array(const char *name, char **value, uint32_t array_length)
Creates a new string array GWY file item.
Definition: gwyfile.c:6867
 
GwyfileItem * gwyfile_item_new_string_copy(const char *name, const char *value)
Creates a new string GWY file item.
Definition: gwyfile.c:5712
 
GwyfileObject * gwyfile_object_new(const char *name,...)
Creates a new GWY file object.
Definition: gwyfile.c:607
 
bool gwyfile_object_add(GwyfileObject *object, GwyfileItem *item)
Adds an data item to a GWY file data object.
Definition: gwyfile.c:4652
 
void gwyfile_object_free(GwyfileObject *object)
Frees a GWY file data object.
Definition: gwyfile.c:4577
 
Detailed information about an error.
Definition: gwyfile.h:131
 
char * message
Text message describing the error. It is allocated when the error struct is created and freed with gw...
Definition: gwyfile.h:134