Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/invoke/testfns.c
blob: 77e54c1a5d9c6f20956b1743947f11be44bad463 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <string.h>

#include <glib.h>
#include <glib/gprintf.h>

typedef struct {
    int foo;
} TestStruct;

gint test1 (gint in);
void test2 (gint in, gint *out);
void test3 (gint *inout);
void test4 (const gchar *blurb);
void test5 (gchar **blurb, gint *len);
gint test6 (GList *list);
char *test7 (GList *list);
TestStruct * test8 (int foo);
void test9 (TestStruct *test_struct, int *out);

gint test1 (gint in)
{
  return in + 4;
}

void test2 (gint in, gint *out)
{
  *out = in + 4;
}

void test3 (gint *inout)
{
  *inout = *inout + 4;
}

void test4 (const gchar *blurb)
{
  g_printf ("%s", blurb);
}

void test5 (gchar **blurb, gint *len)
{
  *blurb = g_strdup ("hey there");
  *len = strlen (*blurb);
}

gint test6 (GList *list)
{
  return g_list_length(list);
}

char *test7 (GList *list)
{
  GList *lp;
  GString *string = g_string_new("");

  for (lp=list; lp ; lp=lp->next)
    {
      g_string_append(string, (const char *)lp->data);
    }
  return g_string_free (string, FALSE);
}

/* constructor */
TestStruct * test8 (int foo)
{
  TestStruct *ret;

  ret = g_new(TestStruct, 1);
  ret->foo = foo;
  return ret;
}

void test9 (TestStruct *test_struct, int *out)
{
  *out = test_struct->foo;
}