funkalicious 0.1

material_slice.c File Reference

#include <stdio.h>
#include <glib-2.0/glib.h>
#include <gio/gio.h>
#include <libdotcode/grid1.h>
#include <libdotcode/displ.h>
#include "material_slice_args.h"
Include dependency graph for material_slice.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 33 of file material_slice.c.

References DOTCODE_COORD_X, DOTCODE_COORD_Y, DOTCODE_COORD_Z, dotcode_displ_get_grid1(), dotcode_grid1_free(), dotcode_grid1_write_assignments_slice_text(), process_args(), args::struct_list, args::xslices, args::yslices, and args::zslices.

                                {
  g_type_init();
  GError *err = NULL;
  struct args *args = process_args(argc, argv, &err);
  if(args == NULL) {
    /*If err is NULL; this means that the user just wanted the version.*/
    if(err == NULL) {
      return 0;
    }else{
      fprintf(stderr, "ERROR processing args: %s\n", err->message);
      return 1;
    }
  }
  GList *l;
  char* s;
  GFile *cwd = g_file_new_for_path(".");
  for(l=args->struct_list; l!=NULL; l=l->next) {
    err = NULL;
    struct dotcode_grid1* g = dotcode_displ_get_grid1((GFile*)(l->data), &err);
    if((g == NULL) || (err != NULL)) {
      s = g_file_get_uri((GFile*)(l->data));
      if(err == NULL) {
  fprintf(stderr, "WARNING: unable to read in grid1 from specified file (%s); no GError was returned, so I have no further information.\n", s);
      }else{
  fprintf(stderr, "WARNING: unable to read in grid1 from specified file (%s): %s\n", s, err->message);
      }
      g_free(s);
      continue;
    }
    GList *ll;
    for(ll = args->xslices; ll != NULL; ll=ll->next) {
      err = NULL;
      dotcode_grid1_write_assignments_slice_text(g, cwd, DOTCODE_COORD_X, *(int*)(ll->data), &err);
      if(err != NULL) {
  fprintf(stderr, "ERROR writing X slice at %d: %s\n", *(int*)(ll->data), err->message);
  g_error_free(err);
      }
    }
    for(ll = args->yslices; ll != NULL; ll=ll->next) {
      err = NULL;
      dotcode_grid1_write_assignments_slice_text(g, cwd, DOTCODE_COORD_Y, *(int*)(ll->data), &err);
      if(err != NULL) {
  fprintf(stderr, "ERROR writing Y slice at %d: %s\n", *(int*)(ll->data), err->message);
  g_error_free(err);
      }
    }
    for(ll = args->zslices; ll != NULL; ll=ll->next) {
      err = NULL;
      dotcode_grid1_write_assignments_slice_text(g, cwd, DOTCODE_COORD_Z, *(int*)(ll->data), &err);
      if(err != NULL) {
  fprintf(stderr, "ERROR writing Z slice at %d: %s\n", *(int*)(ll->data), err->message);
  g_error_free(err);
      }
    }
    dotcode_grid1_free(g);
  }
  return 0;
}

Here is the call graph for this function:

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines