parameters.c revision 1150bc4b812f0150e832607b8724b023d6d7d575
1/* Ltrace Test : parameters.c.
2   Objectives  : Verify that Ltrace can handle all the different
3   parameter types
4
5   This file was written by Steve Fink <sphink@gmail.com>. */
6
7#include <stdio.h>
8#include <unistd.h>
9#include <sys/syscall.h>
10#include <sys/stat.h>
11#include <errno.h>
12#include <string.h>
13#include <stdlib.h>
14
15void func_ignore(int a, int b, int c);
16void func_intptr(int *i);
17void func_intptr_ret(int *i);
18int func_strlen(char*);
19void func_strfixed(char*);
20void func_ppp(int***);
21void func_stringp(char**);
22void func_short(short, short);
23void func_ushort(unsigned short, unsigned short);
24void func_float(float, float);
25void func_arrayi(int*, int);
26void func_arrayf(float*, int);
27
28typedef enum {
29  RED,
30  GREEN,
31  BLUE,
32  CHARTREUSE,
33  PETUNIA
34} color_t;
35void func_enum(color_t);
36void func_typedef(color_t);
37
38int
39main ()
40{
41  int x = 17;
42  int *xP, **xPP;
43  char buf[200];
44  char *s;
45  int *ai;
46  float *af;
47
48  func_ignore(1, 2, 3);
49
50  func_intptr(&x);
51
52  func_intptr_ret(&x);
53
54  func_strlen(buf);
55  printf("%s\n", buf);
56
57  func_strfixed(buf);
58  printf("%s\n", buf);
59
60  x = 80;
61  xP = &x;
62  xPP = &xP;
63  func_ppp(&xPP);
64
65  s = (char*) malloc(100);
66  strcpy(s, "Dude");
67  func_stringp(&s);
68
69  func_enum(BLUE);
70
71  func_short(-8, -9);
72  func_ushort(33, 34);
73  func_float(3.4, -3.4);
74
75  func_typedef(BLUE);
76
77  ai = (int*) calloc(sizeof(int), 8);
78  for (x = 0; x < 8; x++)
79    ai[x] = 10 + x;
80  func_arrayi(ai, 8);
81  func_arrayi(ai, 2);
82
83  af = (float*) calloc(sizeof(float), 8);
84  for (x = 0; x < 8; x++)
85    af[x] = 10.1 + x;
86  func_arrayf(af, 8);
87  func_arrayf(af, 2);
88
89  return 0;
90}
91