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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508
#![allow(raw_pointer_derive)] extern crate libc; extern crate libgpg_error_sys; use libc::{c_void, c_char, c_uchar, c_short, c_ushort, c_int, c_uint, c_long, c_ulong, ssize_t, size_t}; use consts::*; pub use libgpg_error_sys::gpg_error_t as gpgme_error_t; #[cfg(all(target_os = "windows", target_arch = "x86"))] pub type gpgme_off_t = i32; #[cfg(all(target_os = "windows", target_arch = "x86_64"))] pub type gpgme_off_t = i64; #[cfg(not(target_os = "windows"))] pub type gpgme_off_t = libc::off_t; pub type gpgme_ssize_t = libc::ssize_t; pub enum gpgme_context {} pub type gpgme_ctx_t = *mut gpgme_context; pub enum gpgme_data {} pub type gpgme_data_t = *mut gpgme_data; #[repr(C)] #[derive(Clone)] pub struct _gpgme_sig_notation { pub next: gpgme_sig_notation_t, pub name: *mut c_char, pub value: *mut c_char, pub name_len: c_int, pub value_len: c_int, pub flags: gpgme_sig_notation_flags_t, pub bitfield: u32 } pub type gpgme_sig_notation_t = *mut _gpgme_sig_notation; impl _gpgme_sig_notation { pub fn human_readable(&self) -> bool { (self.bitfield & 0x1) == 0x1 } pub fn critical(&self) -> bool { (self.bitfield & 0x2) == 0x2 } } #[repr(C)] #[derive(Clone)] pub struct _gpgme_engine_info { pub next: gpgme_engine_info_t, pub protocol: gpgme_protocol_t, pub file_name: *mut c_char, pub version: *mut c_char, pub req_version: *mut c_char, pub home_dir: *mut c_char } pub type gpgme_engine_info_t = *mut _gpgme_engine_info; #[repr(C)] #[derive(Clone)] pub struct _gpgme_subkey { pub next: gpgme_subkey_t, pub bitfield: u32, pub pubkey_algo: gpgme_pubkey_algo_t, pub length: c_uint, pub keyid: *mut c_char, _keyid: [c_char; 17], pub fpr: *mut c_char, pub timestamp: c_long, pub expires: c_long, pub card_number: *mut c_char, pub curve: *mut c_char, } pub type gpgme_subkey_t = *mut _gpgme_subkey; impl _gpgme_subkey { pub fn revoked(&self) -> bool { (self.bitfield & 0x1) == 0x1 } pub fn expired(&self) -> bool { (self.bitfield & 0x2) == 0x2 } pub fn disabled(&self) -> bool { (self.bitfield & 0x4) == 0x4 } pub fn invalid(&self) -> bool { (self.bitfield & 0x8) == 0x8 } pub fn can_encrypt(&self) -> bool { (self.bitfield & 0x10) == 0x10 } pub fn can_sign(&self) -> bool { (self.bitfield & 0x20) == 0x20 } pub fn can_certify(&self) -> bool { (self.bitfield & 0x40) == 0x40 } pub fn secret(&self) -> bool { (self.bitfield & 0x80) == 0x80 } pub fn can_authenticate(&self) -> bool { (self.bitfield & 0x100) == 0x100 } pub fn is_qualified(&self) -> bool { (self.bitfield & 0x200) == 0x200 } pub fn is_cardkey(&self) -> bool { (self.bitfield & 0x400) == 0x400 } } #[repr(C)] #[derive(Clone)] pub struct _gpgme_key_sig { pub next: gpgme_key_sig_t, pub bitfield: u32, pub pubkey_algo: gpgme_pubkey_algo_t, pub keyid: *mut c_char, _keyid: [c_char; 17], pub timestamp: c_long, pub expires: c_long, pub status: gpgme_error_t, _class: c_uint, pub uid: *mut c_char, pub name: *mut c_char, pub email: *mut c_char, pub comment: *mut c_char, pub sig_class: c_uint, pub notations: gpgme_sig_notation_t, _last_notation: gpgme_sig_notation_t } pub type gpgme_key_sig_t = *mut _gpgme_key_sig; impl _gpgme_key_sig { pub fn revoked(&self) -> bool { (self.bitfield & 0x1) == 0x1 } pub fn expired(&self) -> bool { (self.bitfield & 0x2) == 0x2 } pub fn invalid(&self) -> bool { (self.bitfield & 0x4) == 0x4 } pub fn exportable(&self) -> bool { (self.bitfield & 0x8) == 0x8 } } #[repr(C)] #[derive(Clone)] pub struct _gpgme_user_id { pub next: gpgme_user_id_t, pub bitfield: u32, pub validity: gpgme_validity_t, pub uid: *mut c_char, pub name: *mut c_char, pub email: *mut c_char, pub comment: *mut c_char, pub signatures: gpgme_key_sig_t, _last_keysig: gpgme_key_sig_t } pub type gpgme_user_id_t = *mut _gpgme_user_id; impl _gpgme_user_id { pub fn revoked(&self) -> bool { (self.bitfield & 0x1) == 0x1 } pub fn invalid(&self) -> bool { (self.bitfield & 0x2) == 0x2 } } #[repr(C)] #[derive(Clone)] pub struct _gpgme_key { _refs: c_uint, pub bitfield: u32, pub protocol: gpgme_protocol_t, pub issuer_serial: *mut c_char, pub issuer_name: *mut c_char, pub chain_id: *mut c_char, pub owner_trust: gpgme_validity_t, pub subkeys: gpgme_subkey_t, pub uids: gpgme_user_id_t, _last_subkey: gpgme_subkey_t, _last_uid: gpgme_user_id_t, pub keylist_mode: gpgme_keylist_mode_t } pub type gpgme_key_t = *mut _gpgme_key; impl _gpgme_key { pub fn revoked(&self) -> bool { (self.bitfield & 0x1) == 0x1 } pub fn expired(&self) -> bool { (self.bitfield & 0x2) == 0x2 } pub fn disabled(&self) -> bool { (self.bitfield & 0x4) == 0x4 } pub fn invalid(&self) -> bool { (self.bitfield & 0x8) == 0x8 } pub fn can_encrypt(&self) -> bool { (self.bitfield & 0x10) == 0x10 } pub fn can_sign(&self) -> bool { (self.bitfield & 0x20) == 0x20 } pub fn can_certify(&self) -> bool { (self.bitfield & 0x40) == 0x40 } pub fn secret(&self) -> bool { (self.bitfield & 0x80) == 0x80 } pub fn can_authenticate(&self) -> bool { (self.bitfield & 0x100) == 0x100 } pub fn is_qualified(&self) -> bool { (self.bitfield & 0x200) == 0x200 } } pub type gpgme_passphrase_cb_t = Option<extern fn(*mut c_void, *const c_char, *const c_char, c_int, c_int) -> gpgme_error_t>; pub type gpgme_progress_cb_t = Option<extern fn(*mut c_void, *const c_char, c_int, c_int, c_int)>; pub type gpgme_status_cb_t = Option<extern fn(*mut c_void, *const c_char, *const c_char) -> gpgme_error_t>; pub type gpgme_edit_cb_t = Option<extern fn(*mut c_void, gpgme_status_code_t, *const c_char, c_int) -> gpgme_error_t>; pub type gpgme_io_cb_t = Option<extern fn(*mut c_void, c_int) -> gpgme_error_t>; pub type gpgme_register_io_cb_t = Option<extern fn(*mut c_void, c_int, c_int, gpgme_io_cb_t, *mut c_void, *mut *mut c_void) -> gpgme_error_t>; pub type gpgme_remove_io_cb_t = Option<extern fn(*mut c_void)>; #[repr(C)] #[derive(Clone)] pub struct gpgme_io_event_done_data { pub err: gpgme_error_t, pub op_err: gpgme_error_t } pub type gpgme_io_event_done_data_t = *mut gpgme_io_event_done_data; pub type gpgme_event_io_cb_t = Option<extern fn(*mut c_void, gpgme_event_io_t, *mut c_void)>; #[repr(C)] #[derive(Clone)] pub struct gpgme_io_cbs { pub add: gpgme_register_io_cb_t, pub add_priv: *mut c_void, pub remove: gpgme_remove_io_cb_t, pub event: gpgme_event_io_cb_t, pub event_priv: *mut c_void } pub type gpgme_io_cbs_t = *mut gpgme_io_cbs; pub type gpgme_data_read_cb_t = Option<extern fn(*mut c_void, *mut c_void, size_t) -> ssize_t>; pub type gpgme_data_write_cb_t = Option<extern fn(*mut c_void, *const c_void, size_t) -> ssize_t>; pub type gpgme_data_seek_cb_t = Option<extern fn(*mut c_void, libc::off_t, c_int) -> libc::off_t>; pub type gpgme_data_release_cb_t = Option<extern fn(*mut c_void)>; #[repr(C)] #[derive(Clone)] pub struct gpgme_data_cbs { pub read: gpgme_data_read_cb_t, pub write: gpgme_data_write_cb_t, pub seek: gpgme_data_seek_cb_t, pub release: gpgme_data_release_cb_t } pub type gpgme_data_cbs_t = *mut gpgme_data_cbs; #[repr(C)] #[derive(Clone)] pub struct _gpgme_invalid_key { pub next: gpgme_invalid_key_t, pub fpr: *mut c_char, pub reason: gpgme_error_t } pub type gpgme_invalid_key_t = *mut _gpgme_invalid_key; #[repr(C)] #[derive(Clone)] pub struct _gpgme_op_encrypt_result { pub invalid_recipients: gpgme_invalid_key_t } pub type gpgme_encrypt_result_t = *mut _gpgme_op_encrypt_result; #[repr(C)] #[derive(Clone)] pub struct _gpgme_recipient { pub next: gpgme_recipient_t, pub keyid: *mut c_char, _keyid: [c_char; 17], pub pubkey_algo: gpgme_pubkey_algo_t, pub status: gpgme_error_t } pub type gpgme_recipient_t = *mut _gpgme_recipient; #[repr(C)] #[derive(Clone)] pub struct _gpgme_op_decrypt_result { pub unsupported_algorithm: *mut c_char, pub bitfield: u32, pub recipients: gpgme_recipient_t, pub file_name: *mut c_char } pub type gpgme_decrypt_result_t = *mut _gpgme_op_decrypt_result; impl _gpgme_op_decrypt_result { pub fn wrong_key_usage(&self) -> bool { (self.bitfield & 0x1) == 0x1 } } #[repr(C)] #[derive(Clone)] pub struct _gpgme_new_signature { pub next: gpgme_new_signature_t, pub sig_type: gpgme_sig_mode_t, pub pubkey_algo: gpgme_pubkey_algo_t, pub hash_algo: gpgme_hash_algo_t, _class1: c_ulong, pub timestamp: c_long, pub fpr: *mut c_char, _class2: c_uint, pub sig_class: c_uint } pub type gpgme_new_signature_t = *mut _gpgme_new_signature; #[repr(C)] #[derive(Clone)] pub struct _gpgme_op_sign_result { pub invalid_signers: gpgme_invalid_key_t, pub signatures: gpgme_new_signature_t } pub type gpgme_sign_result_t = *mut _gpgme_op_sign_result; #[repr(C)] #[derive(Clone)] pub struct _gpgme_signature { pub next: gpgme_signature_t, pub summary: gpgme_sigsum_t, pub fpr: *mut c_char, pub status: gpgme_error_t, pub notations: gpgme_sig_notation_t, pub timestamp: c_ulong, pub exp_timestamp: c_ulong, pub bitfield: u32, pub validity: gpgme_validity_t, pub validity_reason: gpgme_error_t, pub pubkey_algo: gpgme_pubkey_algo_t, pub hash_algo: gpgme_hash_algo_t, pub pka_address: *mut c_char } pub type gpgme_signature_t = *mut _gpgme_signature; impl _gpgme_signature { pub fn wrong_key_usage(&self) -> bool { (self.bitfield & 0x1) == 0x1 } pub fn pka_trust(&self) -> c_uint { (self.bitfield & 0x6) >> 1 } pub fn chain_model(&self) -> bool { (self.bitfield & 0x8) == 0x8 } } #[repr(C)] #[derive(Clone)] pub struct _gpgme_op_verify_result { pub signatures: gpgme_signature_t, pub file_name: *mut c_char } pub type gpgme_verify_result_t = *mut _gpgme_op_verify_result; #[repr(C)] #[derive(Clone)] pub struct _gpgme_import_status { pub next: gpgme_import_status_t, pub fpr: *mut c_char, pub result: gpgme_error_t, pub status: c_uint } pub type gpgme_import_status_t = *mut _gpgme_import_status; #[repr(C)] #[derive(Clone)] pub struct _gpgme_op_import_result { pub considered: c_int, pub no_user_id: c_int, pub imported: c_int, pub imported_rsa: c_int, pub unchanged: c_int, pub new_user_ids: c_int, pub new_sub_keys: c_int, pub new_signatures: c_int, pub new_revocations: c_int, pub secret_read: c_int, pub secret_imported: c_int, pub secret_unchanged: c_int, pub skipped_new_keys: c_int, pub not_imported: c_int, pub imports: gpgme_import_status_t } pub type gpgme_import_result_t = *mut _gpgme_op_import_result; #[repr(C)] #[derive(Clone)] pub struct _gpgme_op_genkey_result { pub bitfield: u32, pub fpr: *mut c_char } pub type gpgme_genkey_result_t = *mut _gpgme_op_genkey_result; impl _gpgme_op_genkey_result { pub fn primary(&self) -> bool { (self.bitfield & 0x1) == 0x1 } pub fn sub(&self) -> bool { (self.bitfield & 0x2) == 0x2 } } #[repr(C)] #[derive(Clone)] pub struct _gpgme_op_keylist_result { pub bitfield: u32 } pub type gpgme_keylist_result_t = *mut _gpgme_op_keylist_result; impl _gpgme_op_keylist_result { pub fn truncated(&self) -> bool { (self.bitfield & 0x1) == 0x1 } } #[repr(C)] #[derive(Clone)] pub struct _gpgme_trust_item { _refs: c_uint, pub keyid: *mut c_char, _keyid: [c_char; 17], pub trust_type: c_int, pub level: c_int, pub owner_trust: *mut c_char, _owner_trust: [c_char; 2], pub validity: *mut c_char, _validity: [c_char; 2], pub name: *mut c_char } pub type gpgme_trust_item_t = *mut _gpgme_trust_item; pub type gpgme_assuan_data_cb_t = Option<extern fn(*mut c_void, *const c_void, size_t) -> gpgme_error_t>; pub type gpgme_assuan_inquire_cb_t = Option<extern fn(*mut c_void, *const c_char, *const c_char, *mut gpgme_data_t) -> gpgme_error_t>; pub type gpgme_assuan_status_cb_t = Option<extern fn(*mut c_void, *const c_char, *const c_char) -> gpgme_error_t>; #[repr(C)] #[derive(Clone)] pub struct _gpgme_op_vfs_mount_result { pub mount_dir: *mut c_char } pub type gpgme_vfs_mount_result_t = *mut _gpgme_op_vfs_mount_result; #[repr(C)] #[derive(Clone)] pub struct gpgme_conf_arg { pub next: gpgme_conf_arg_t, pub no_arg: c_uint, pub union: libc::uintptr_t } pub type gpgme_conf_arg_t = *mut gpgme_conf_arg; #[repr(C)] #[derive(Clone)] pub struct gpgme_conf_opt { pub next: gpgme_conf_opt_t, pub name: *mut c_char, pub flags: c_uint, pub level: gpgme_conf_level_t, pub description: *mut c_char, pub opt_type: gpgme_conf_type_t, pub alt_type: gpgme_conf_type_t, pub argname: *mut c_char, pub default_value: gpgme_conf_arg_t, pub default_description: *mut c_char, pub no_arg_value: gpgme_conf_arg_t, pub no_arg_description: *mut c_char, pub value: gpgme_conf_arg_t, pub change_value: c_int, pub new_value: gpgme_conf_arg_t, pub user_data: *mut c_void } pub type gpgme_conf_opt_t = *mut gpgme_conf_opt; #[repr(C)] #[derive(Clone)] pub struct gpgme_conf_comp { pub next: gpgme_conf_comp_t, _last_opt_p: *mut gpgme_conf_opt_t, pub name: *mut c_char, pub description: *mut c_char, pub program_name: *mut c_char, pub options: gpgme_conf_opt_t } pub type gpgme_conf_comp_t = *mut gpgme_conf_comp;