forked from nemequ/vala-extra-vapis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pwquality.vapi
116 lines (106 loc) · 3.72 KB
/
pwquality.vapi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* libpwquality Vala Bindings
* Copyright 2013 Evan Nemerson <[email protected]>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
[CCode (lower_case_cprefix = "pwquality_", cheader_filename = "pwquality.h")]
namespace PasswordQuality {
[CCode (cname = "int", cprefix = "PWQ_SETTING_", has_type_id = false)]
public enum Setting {
DIFF_OK,
MIN_LENGTH,
DIG_CREDIT,
UP_CREDIT,
LOW_CREDIT,
OTH_CREDIT,
MIN_CLASS,
MAX_REPEAT,
DICT_PATH,
MAX_CLASS_REPEAT,
GECOS_CHECK,
BAD_WORDS,
MAX_SEQUENCE
}
[CCode (cname = "int", cprefix = "PWQ_ERROR_", has_type_id = false)]
public enum Error {
SUCCESS,
FATAL_FAILURE,
INTEGER,
CFGFILE_OPEN,
CFGFILE_MALFORMED,
UNKNOWN_SETTING,
NON_INT_SETTING,
NON_STR_SETTING,
MEM_ALLOC,
TOO_SIMILAR,
MIN_DIGITS,
MIN_UPPERS,
MIN_LOWERS,
MIN_OTHERS,
MIN_LENGTH,
PALINDROME,
CASE_CHANGES_ONLY,
ROTATED,
MIN_CLASSES,
MAX_CONSECUTIVE,
EMPTY_PASSWORD,
SAME_PASSWORD,
CRACKLIB_CHECK,
RNG,
GENERATION_FAILED,
USER_CHECK,
GECOS_CHECK,
MAX_CLASS_REPEAT,
BAD_WORDS,
MAX_SEQUENCE;
[CCode (cname = "pwquality_strerror", instance_pos = 2.5)]
private void* strerror (void* buf, size_t len, void* auxerror);
public string to_string (void* auxerror = null) {
string ret = null;
string** retp = &ret;
*retp = GLib.malloc (PasswordQuality.MAX_ERROR_MESSAGE_LEN);
void* res = this.strerror (*retp, PasswordQuality.MAX_ERROR_MESSAGE_LEN, auxerror);
if ( res != *retp ) {
GLib.Memory.copy (*retp, res, ((string) res).length + 1);
}
return ret;
}
}
[CCode (cname = "PWQ_MAX_ENTROPY_BITS")]
public const int MAX_ENTROPY_BITS;
[CCode (cname = "PWQ_MIN_ENTROPY_BITS")]
public const int MIN_ENTROPY_BITS;
[CCode (cname = "PWQ_MAX_ERROR_MESSAGE_LEN")]
public const int MAX_ERROR_MESSAGE_LEN;
[Compact, CCode (cname = "pwquality_settings_t", lower_case_cprefix = "pwquality_", free_function = "pwquality_free_settings")]
public class Settings {
[CCode (cname = "pwquality_default_settings")]
public Settings ();
public PasswordQuality.Error read_config (string cfgfile, out void* auxerror);
public PasswordQuality.Error set_option (string option);
public PasswordQuality.Error set_int_value (PasswordQuality.Setting setting, int value);
public PasswordQuality.Error set_str_value (PasswordQuality.Setting setting, string value);
public PasswordQuality.Error get_int_value (PasswordQuality.Setting setting, out int value);
public PasswordQuality.Error get_str_value (PasswordQuality.Setting setting, out unowned string value);
public PasswordQuality.Error generate (int entropy_bits, out string password);
public int check (string password, string? oldpassword = null, string? user = null, out void* auxerror = null);
}
}