funkalicious 0.1

round-trip-grid-file.c File Reference

#include <stdio.h>
#include <libdotcode/read_binary_data.h>
#include <libdotcode/write_binary_data.h>
Include dependency graph for round-trip-grid-file.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file round-trip-grid-file.c.

References DOTCODE_GRID, dotcode_string_from_type2(), dotcode_write_typed_file(), e, and read_dotcode_generic_file().

                                {
  if(argc < 3) {
    fprintf(stderr, "ERROR: you must give two arguments: the input file and the output file.\n");
    return 1;
  }
  g_type_init();
  //fprintf(stderr, "=%s\n", argv[0]);
  //fprintf(stderr, "=%s\n", argv[1]);
  GFile* inf = g_file_new_for_commandline_arg(argv[1]);
  GFile* ouf = g_file_new_for_commandline_arg(argv[2]);
  printf("Roundtripping from \"%s\" to \"%s\"\n", argv[1], argv[2]);
  GError *e = NULL;
  enum dotcode_type t;
  void* g = read_dotcode_generic_file(&t, inf, &e);
  if(e != NULL) {
    fprintf(stderr, "ERROR reading input file: %s\n", e->message);
    return 10;
  }
  if(g == NULL) {
    fprintf(stderr, "ERROR read_dotcode_generic_file returned NULL!\n");
    return 11;
  }
  if(t != DOTCODE_GRID) {
    fprintf(stderr, "ERROR got incorrect dotcode type (should be grid!): was %d (%s)\n", t, dotcode_string_from_type2(t));
    return 12;
  }
  e = dotcode_write_typed_file(t, g, ouf);
  if(e != NULL) {
    fprintf(stderr, "ERROR writing input file back out again: %s\n", e->message);
    return 20;
  }
  return 0;
}

Here is the call graph for this function:

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines