Example demonstrating the functions for checking GWY files beyond the physical consistency enforced by libgwyfile.
#include <stdlib.h>
#include <math.h>
#include <errno.h>
#include <string.h>
int
main(int argc, char *argv[])
{
GwyfileObject *gwyf;
bool using_stdin = false;
unsigned int i;
if (argc != 2) {
printf("checkgeneric FILE.gwy\n"
"Read a generic GWY file and check it for problems.\n"
"Pass \"-\" as the filename to read the standard input.\n");
exit(argc == 1 ? EXIT_SUCCESS : EXIT_FAILURE);
}
if (strcmp(argv[1], "-") == 0) {
using_stdin = true;
}
else
if (!gwyf) {
fprintf(stderr, "Cannot read %s: %s\n",
using_stdin ?
"the standard input" : argv[1], error->
message);
exit(EXIT_FAILURE);
}
printf("No validity problems found.\n");
}
else {
printf("Validity problems:\n");
for (i = 0; i < errlist.
n; i++) {
}
}
printf("No warnings found.\n");
}
else {
printf("Warnings:\n");
for (i = 0; i < errlist.
n; i++) {
}
}
return 0;
}
GwyfileObject * gwyfile_read_file(const char *filename, GwyfileError **error)
Reads a GWY file from a named file and returns its top-level object.
Definition: gwyfile.c:405
GwyfileObject * gwyfile_fread(FILE *stream, size_t max_size, GwyfileError **error)
Reads a GWY file from a stdio stream and returns the top-level object.
Definition: gwyfile.c:565
bool gwyfile_check_object(const GwyfileObject *object, unsigned int flags, GwyfileErrorList *errlist)
Checks an object for specifications violations.
Definition: gwyfile.c:9065
@ GWYFILE_CHECK_FLAG_WARNING
Enables checking for errors from the GWYFILE_ERROR_DOMAIN_WARNING category in gwyfile_check_object().
Definition: gwyfile.h:152
@ GWYFILE_CHECK_FLAG_VALIDITY
Enables checking for errors from the GWYFILE_ERROR_DOMAIN_VALIDITY category in gwyfile_check_object()...
Definition: gwyfile.h:151
void gwyfile_error_list_init(GwyfileErrorList *errlist)
Initializes a GwyfileErrorList.
Definition: gwyfile.c:9009
void gwyfile_error_clear(GwyfileError **error)
Clears a GwyfileError.
Definition: gwyfile.c:8990
void gwyfile_error_list_clear(GwyfileErrorList *errlist)
Frees all errors in a GwyfileErrorList.
Definition: gwyfile.c:9026
void gwyfile_object_free(GwyfileObject *object)
Frees a GWY file data object.
Definition: gwyfile.c:4577
List of errors.
Definition: gwyfile.h:137
GwyfileError ** errors
Array holding the errors.
Definition: gwyfile.h:138
size_t n
Number of errors in the list.
Definition: gwyfile.h:139
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
int code
Particular error code. For errors from the system domain it is equal to errno while for libgwyfile-sp...
Definition: gwyfile.h:133