~ubuntu-branches/ubuntu/oneiric/likewise-open/oneiric

« back to all changes in this revision

Viewing changes to librpc/testrpc/params.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Salley
  • Date: 2010-11-22 12:06:00 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122120600-8lba1fpceot71wlb
Tags: 6.0.0.53010-1
Likewise Open 6.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Editor Settings: expandtabs and use 4 spaces for indentation
2
 
 * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: *
3
 
 * -*- mode: c, c-basic-offset: 4 -*- */
4
 
 
5
 
/*
6
 
 * Copyright Likewise Software    2004-2008
7
 
 * All rights reserved.
8
 
 *
9
 
 * This library is free software; you can redistribute it and/or modify it
10
 
 * under the terms of the GNU Lesser General Public License as published by
11
 
 * the Free Software Foundation; either version 2.1 of the license, or (at
12
 
 * your option) any later version.
13
 
 *
14
 
 * This library is distributed in the hope that it will be useful,
15
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
17
 
 * General Public License for more details.  You should have received a copy
18
 
 * of the GNU Lesser General Public License along with this program.  If
19
 
 * not, see <http://www.gnu.org/licenses/>.
20
 
 *
21
 
 * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING
22
 
 * TERMS AS WELL.  IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT
23
 
 * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE
24
 
 * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU
25
 
 * LESSER GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE.  IF YOU
26
 
 * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING
27
 
 * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT
28
 
 * license@likewisesoftware.com
29
 
 */
30
 
 
31
 
#ifndef _PARAMS_H_
32
 
#define _PARAMS_H_
33
 
 
34
 
struct parameter {
35
 
    char *key;
36
 
    char *val;
37
 
};
38
 
 
39
 
 
40
 
enum param_type {
41
 
    pt_string = 1,
42
 
    pt_w16string,
43
 
    pt_w16string_list,
44
 
    pt_char,
45
 
    pt_int32,
46
 
    pt_uint32,
47
 
    pt_sid,
48
 
    pt_sid_list
49
 
};
50
 
 
51
 
 
52
 
enum param_err {
53
 
    perr_not_found = 1,
54
 
    perr_invalid_out_param = 2,
55
 
    perr_unknown_type = 3,
56
 
    perr_nullptr_passed = 4,
57
 
 
58
 
    perr_success = 0,
59
 
    perr_unknown = -1
60
 
};
61
 
 
62
 
 
63
 
struct param_errstr_map {
64
 
    enum param_err perr;
65
 
    const char* desc;
66
 
};
67
 
 
68
 
static const
69
 
struct param_errstr_map param_errstr_maps[] = {
70
 
    { perr_not_found, "parameter not found" },
71
 
    { perr_invalid_out_param, "invalid output parameter" },
72
 
    { perr_unknown_type, "unknown parameter type" },
73
 
    { perr_nullptr_passed, "null pointer passed" },
74
 
    { perr_success, "success" },
75
 
    { perr_unknown, "unknown error" }
76
 
};
77
 
 
78
 
const char *param_errstr(enum param_err perr);
79
 
 
80
 
 
81
 
#define perr_is_ok(perr_code)  ((perr_code) == perr_success)
82
 
#define perr_fail(perr_code) { \
83
 
        printf("Parameter error: %s\n", param_errstr(perr_code)); \
84
 
        return false; \
85
 
    }
86
 
 
87
 
 
88
 
struct parameter* get_optional_params(char *opt, int *count);
89
 
const char* find_value(struct parameter *params, int count, const char *key);
90
 
enum param_err fetch_value(struct parameter *params, int count,
91
 
                           const char *key, enum param_type type, void *val,
92
 
                           const void *def);
93
 
 
94
 
void ParamInfo(const char* name, enum param_type type, void *value);
95
 
 
96
 
 
97
 
 
98
 
#endif /* _PARAMS_H_ */
99
 
 
100
 
 
101
 
/*
102
 
local variables:
103
 
mode: c
104
 
c-basic-offset: 4
105
 
indent-tabs-mode: nil
106
 
tab-width: 4
107
 
end:
108
 
*/