]> granicus.if.org Git - strace/blob - tests/printxval.c
strace: terminate itself if interrupted by a signal
[strace] / tests / printxval.c
1 /*
2  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6  * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
7  * All rights reserved.
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11
12 #include "tests.h"
13 #include "xlat.h"
14 #include <stdio.h>
15
16 int
17 printxval(const struct xlat *xlat, unsigned long long val,
18           const char *const dflt)
19 {
20         for (; xlat->str; xlat++) {
21                 if (xlat->val == val) {
22                         fputs(xlat->str, stdout);
23                         return 1;
24                 }
25         }
26
27         printf("%#llx", val);
28         if (dflt)
29                 printf(" /* %s */", dflt);
30         return 0;
31 }