Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / cmd / dtrace / test / tst / common / uctf / tst.chasestrings.c
blob595a7cb6c5755e134398f40a19eb7fe719ca90f4
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2013 (c) Joyent, Inc. All rights reserved.
17 * This test takes data from the current binary which is basically running in a
18 * loop between two functions and our goal is to have two unique types that they
19 * contain which we can print.
22 #include <unistd.h>
24 typedef struct zelda_info {
25 char *zi_gamename;
26 int zi_ndungeons;
27 char *zi_villain;
28 int zi_haszelda;
29 } zelda_info_t;
31 static int
32 has_princess(zelda_info_t *z)
34 return (z->zi_haszelda);
37 static int
38 has_dungeons(zelda_info_t *z)
40 return (z->zi_ndungeons != 0);
43 static const char *
44 has_villain(zelda_info_t *z)
46 return (z->zi_villain);
49 int
50 main(void)
52 zelda_info_t oot;
53 zelda_info_t la;
54 zelda_info_t lttp;
56 oot.zi_gamename = "Ocarina of Time";
57 oot.zi_ndungeons = 10;
58 oot.zi_villain = "Ganondorf";
59 oot.zi_haszelda = 1;
61 la.zi_gamename = "Link's Awakening";
62 la.zi_ndungeons = 9;
63 la.zi_villain = "Nightmare";
64 la.zi_haszelda = 0;
66 lttp.zi_gamename = "A Link to the Past";
67 lttp.zi_ndungeons = 12;
68 lttp.zi_villain = "Ganon";
69 lttp.zi_haszelda = 1;
71 for (;;) {
72 (void) has_princess(&oot);
73 (void) has_dungeons(&la);
74 (void) has_villain(&lttp);
75 sleep(1);
78 return (0);