~ubuntu-branches/ubuntu/lucid/stfl/lucid

« back to all changes in this revision

Viewing changes to example.c

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde
  • Date: 2007-08-07 13:06:54 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070807130654-fmvsraotulj0nbri
Tags: 0.15-3
Again added fPIC to CFLAGS. Hopefully all build issues
are fixed now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  STFL - The Structured Terminal Forms Language/Library
3
 
 *  Copyright (C) 2006  Clifford Wolf <clifford@clifford.at>
4
 
 *
5
 
 *  This program is free software; you can redistribute it and/or modify
6
 
 *  it under the terms of the GNU General Public License as published by
7
 
 *  the Free Software Foundation; either version 2 of the License, or
8
 
 *  (at your option) any later version.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
 
3
 *  Copyright (C) 2006, 2007  Clifford Wolf <clifford@clifford.at>
 
4
 *
 
5
 *  This library is free software; you can redistribute it and/or
 
6
 *  modify it under the terms of the GNU Lesser General Public
 
7
 *  License as published by the Free Software Foundation; either
 
8
 *  version 3 of the License, or (at your option) any later version.
 
9
 *  
 
10
 *  This library is distributed in the hope that it will be useful,
11
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 *  Lesser General Public License for more details.
 
14
 *  
 
15
 *  You should have received a copy of the GNU Lesser General Public
 
16
 *  License along with this library; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
18
 *  MA 02110-1301 USA
18
19
 *
19
20
 *  example.c: A little STFL example
20
21
 */
25
26
#include <stdlib.h>
26
27
#include <stdio.h>
27
28
 
 
29
#include <langinfo.h>
 
30
#include <locale.h>
 
31
 
28
32
int main()
29
33
{
30
 
        struct stfl_form *f = stfl_create("<example.stfl>");
31
 
 
32
 
        stfl_set(f, "value_a", "This is a little");
33
 
        stfl_set(f, "value_b", "test for STFL!");
34
 
 
35
 
        const char *event = 0;
36
 
        while (!event || strcmp(event, "ESC"))
 
34
        if (!setlocale(LC_ALL,""))
 
35
                fprintf(stderr, "WARING: Can't set locale!\n");
 
36
 
 
37
        struct stfl_ipool *ipool = stfl_ipool_create(nl_langinfo(CODESET));
 
38
        struct stfl_form *f = stfl_create(L"<example.stfl>");
 
39
 
 
40
        stfl_set(f, L"value_a", L"This is a little");
 
41
        stfl_set(f, L"value_b", stfl_ipool_towc(ipool, "test for STFL!"));
 
42
        stfl_ipool_flush(ipool);
 
43
 
 
44
        const wchar_t *event = 0;
 
45
        while (!event || wcscmp(event, L"ESC"))
37
46
                event = stfl_run(f, 0);
38
47
 
39
48
        stfl_reset();
40
49
 
41
 
        printf("A: %s\n", stfl_get(f, "value_a"));
42
 
        printf("B: %s\n", stfl_get(f, "value_b"));
43
 
        printf("C: %s\n", stfl_get(f, "value_c"));
 
50
        printf("A: %ls\n", stfl_get(f, L"value_a"));
 
51
        printf("B: %ls\n", stfl_get(f, L"value_b"));
 
52
        printf("C: %s\n", stfl_ipool_fromwc(ipool, stfl_get(f, L"value_c")));
 
53
        stfl_ipool_flush(ipool);
44
54
 
45
55
        stfl_free(f);
 
56
        stfl_ipool_destroy(ipool);
46
57
 
47
58
        return 0;
48
59
}