source: murachi/esteidfirefoxplugin/common/l10n-linux.c @ c4dd8d1

Last change on this file since c4dd8d1 was 7d3ae3e, checked in by antonioaraujob <aaraujo@…>, 9 years ago

Agregados archivos fuentes del complemento esteidfirefoxplugin de Estonia para firmar electrónicamente un hash.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 * Estonian ID card plugin for web browsers
3 *
4 * Copyright (C) 2010-2011 Codeborne <info@codeborne.com>
5 *
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <ctype.h>
25#include <string.h>
26
27#include "esteid_log.h"
28#include "l10n.h"
29
30char *EstEID_findLine(FILE *file, const char *prefix) {
31        char *result = NULL;
32        for (char *line = NULL; !result; free(line)) {
33                size_t size = 0;
34                int len = getline(&line, &size, file);
35                if (len == -1) break;
36                char *l = line;
37                while (isspace(*l)) l++;
38                if (*l == '#' || *l == ';') continue;
39                if (!strncmp(prefix, l, strlen(prefix))) {
40                        l += strlen(prefix);
41                        while (isspace(*l) || *l == '=') l++;
42                        while   (isspace(l[strlen(l) - 1])) l[strlen(l) - 1] = 0;
43                        result = strdup(l);
44                }
45        }
46        return result;
47}
48
49#define CONFIG_FILE "/.config/Estonian ID Card.conf"
50
51char *EstEID_getUserLocale() {
52        char *home = getenv("HOME");
53        char *filename = malloc(strlen(home) + strlen(CONFIG_FILE) + 1);
54        sprintf(filename, "%s%s", home, CONFIG_FILE);
55        FILE *f = fopen(filename, "r");
56        free(filename);
57        char *locale = NULL;
58        if (f) {
59                locale = EstEID_findLine(f, "Language");
60                EstEID_log("EstEID_getUserLocale\t locale from conf file: %s", locale);
61                fclose(f);
62        }
63        return locale;
64}
65
Note: See TracBrowser for help on using the repository browser.