summaryrefslogtreecommitdiff
path: root/src/print_kmpdetails.c
blob: 6494f350d57beeda4e66a720c840921c63cb3215 (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
// APIs to get info that ibus-keyman will want from
// the kmp.json from each kmp
//
// get list of keyboards from this
// associated languages

#include <locale.h>
#include <sys/stat.h>
#include "kmpdetails.h"


int
main (gint argc, gchar **argv)
{
    struct stat filestat;
    kmp_details details;

    if (argc < 2)
    {
      g_print ("Usage: kmpdetails <kmp.json>\n");
      g_print ("ERROR: no file specified\n");
      return EXIT_FAILURE;
    }

    stat(argv[1], &filestat);
    if (!S_ISREG(filestat.st_mode))
    {
      g_print ("Usage: kmpdetails <kmp.json>\n");
      g_print ("ERROR: file %s not found\n", argv[1]);
      return EXIT_FAILURE;
    }

    setlocale (LC_ALL, "C.UTF-8");

    get_kmp_details(argv[1], &details);
    print_kmp_details(&details);
    free_kmp_details(&details);

    return EXIT_SUCCESS;
}