1/*
2 * This file is part of ltrace.
3 * Copyright (C) 2011,2012 Petr Machata, Red Hat Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * 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., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 */
20
21#ifndef ARGS_H
22#define ARGS_H
23
24#include "forward.h"
25#include "vect.h"
26
27/* Value dictionary is used to store actual function arguments.  It
28 * supports both numbered and named arguments.  */
29struct value_dict
30{
31	struct vect numbered;
32	struct vect named;
33};
34
35/* Initialize DICT.  */
36void val_dict_init(struct value_dict *dict);
37
38/* Clone SOURCE into TARGET.  Return 0 on success or a negative value
39 * on failure.  */
40int val_dict_clone(struct value_dict *target, struct value_dict *source);
41
42/* Push next numbered value, VAL.  The value is copied over and the
43 * dictionary becomes its owner, and is responsible for destroying it
44 * later.  Returns 0 on success and a negative value on failure.  */
45int val_dict_push_next(struct value_dict *dict, struct value *val);
46
47/* Return count of numbered arguments.  */
48size_t val_dict_count(struct value_dict *dict);
49
50/* Push value VAL named NAME.  See notes at val_dict_push_next about
51 * value ownership.  The name is owned and freed if OWN_NAME is
52 * non-zero.  */
53int val_dict_push_named(struct value_dict *dict, struct value *val,
54			const char *name, int own_name);
55
56/* Get NUM-th numbered argument, or NULL if there's not that much
57 * arguments.  */
58struct value *val_dict_get_num(struct value_dict *dict, size_t num);
59
60/* Get argument named NAME, or NULL if there's no such argument.  */
61struct value *val_dict_get_name(struct value_dict *dict, const char *name);
62
63/* Destroy the dictionary and all the values in it.  Note that DICT
64 * itself (the pointer) is not freed.  */
65void val_dict_destroy(struct value_dict *dict);
66
67#endif /* ARGS_H */
68