summaryrefslogtreecommitdiff
path: root/main.c
blob: 5dff237ebf09e3144e9f7cf370267c4d46489217 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include "eo_tokenizer.h"

int _eo_tokenizer_log_dom = -1;

int main(int argc, char **argv)
{
   int i;
   char *fpath;
   Eo_Tokenizer *toknz;

   if (argc < 2)
     {
        fprintf(stderr, "usage: %s FILE...\n", argv[0]);
        exit(EXIT_FAILURE);
     }

   eina_init();
   eina_log_color_disable_set(EINA_FALSE);
   _eo_tokenizer_log_dom = eina_log_domain_register("eo_toknz", EINA_COLOR_CYAN);

   for (i = 1; i < argc; i++)
     {
        toknz = eo_tokenizer_get();
        if (!toknz)
          {
             ERR("can't create eo_tokenizer");
             eina_shutdown();
             exit(EXIT_FAILURE);
          }

        fpath = argv[i];
        if (access(fpath, F_OK) != 0)
          {
             ERR("error accessing file %s : %s", fpath, strerror(errno));
             continue;
          }
        eo_tokenizer_walk(toknz, fpath);

        eo_tokenizer_dump(toknz);

        eo_tokenizer_free(toknz);
     }

   eina_shutdown();

   return EXIT_SUCCESS;
}