Artifact c65f25b92fea98f2445297b9e4cfe772f5d3c97658215346c81cf8aa0779a3a9:
- File pwman.h — part of check-in [c14cf350df] at 2014-05-15 21:36:21 on branch manualheaven — Move src and doc files to top directory (user: base@atomicules.co.uk size: 2884) [more...]
- File
src/pwman.h
— part of check-in
[f05023e8f3]
at
2011-02-15 22:24:16
on branch origin/tweaks
— Tweak search internals to always track the parent of items, and use this to allow locating of search entries
git-svn-id: https://pwman.svn.sourceforge.net/svnroot/pwman/trunk@121 db5f1c25-4851-472e-ac1e-5437d07aece1 (user: gagravarr@users.sourceforge.net size: 2884)
0000: 2f 2a 0a 20 2a 20 20 50 57 4d 61 6e 20 2d 20 70 /*. * PWMan - p
0010: 61 73 73 77 6f 72 64 20 6d 61 6e 61 67 65 6d 65 assword manageme
0020: 6e 74 20 61 70 70 6c 69 63 61 74 69 6f 6e 0a 20 nt application.
0030: 2a 0a 20 2a 20 20 43 6f 70 79 72 69 67 68 74 20 *. * Copyright
0040: 28 43 29 20 32 30 30 32 20 20 49 76 61 6e 20 4b (C) 2002 Ivan K
0050: 65 6c 6c 79 20 3c 69 76 61 6e 40 69 76 61 6e 6b elly <ivan@ivank
0060: 65 6c 6c 79 2e 6e 65 74 3e 0a 20 2a 0a 20 2a 20 elly.net>. *. *
0070: 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 This program is
0080: 20 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 free software;
0090: 79 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 you can redistri
00a0: 62 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 20 6d bute it and/or m
00b0: 6f 64 69 66 79 0a 20 2a 20 20 69 74 20 75 6e 64 odify. * it und
00c0: 65 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 20 er the terms of
00d0: 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 the GNU General
00e0: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 61 Public License a
00f0: 73 20 70 75 62 6c 69 73 68 65 64 20 62 79 0a 20 s published by.
0100: 2a 20 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 * the Free Soft
0110: 77 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 3b ware Foundation;
0120: 20 65 69 74 68 65 72 20 76 65 72 73 69 6f 6e 20 either version
0130: 32 20 6f 66 20 74 68 65 20 4c 69 63 65 6e 73 65 2 of the License
0140: 2c 20 6f 72 0a 20 2a 20 20 28 61 74 20 79 6f 75 , or. * (at you
0150: 72 20 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 r option) any la
0160: 74 65 72 20 76 65 72 73 69 6f 6e 2e 0a 20 2a 0a ter version.. *.
0170: 20 2a 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d * This program
0180: 20 69 73 20 64 69 73 74 72 69 62 75 74 65 64 20 is distributed
0190: 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68 61 74 in the hope that
01a0: 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73 65 66 it will be usef
01b0: 75 6c 2c 0a 20 2a 20 20 62 75 74 20 57 49 54 48 ul,. * but WITH
01c0: 4f 55 54 20 41 4e 59 20 57 41 52 52 41 4e 54 59 OUT ANY WARRANTY
01d0: 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74 ; without even t
01e0: 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61 he implied warra
01f0: 6e 74 79 20 6f 66 0a 20 2a 20 20 4d 45 52 43 48 nty of. * MERCH
0200: 41 4e 54 41 42 49 4c 49 54 59 20 6f 72 20 46 49 ANTABILITY or FI
0210: 54 4e 45 53 53 20 46 4f 52 20 41 20 50 41 52 54 TNESS FOR A PART
0220: 49 43 55 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 ICULAR PURPOSE.
0230: 20 53 65 65 20 74 68 65 0a 20 2a 20 20 47 4e 55 See the. * GNU
0240: 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 General Public
0250: 4c 69 63 65 6e 73 65 20 66 6f 72 20 6d 6f 72 65 License for more
0260: 20 64 65 74 61 69 6c 73 2e 0a 20 2a 0a 20 2a 20 details.. *. *
0270: 20 59 6f 75 20 73 68 6f 75 6c 64 20 68 61 76 65 You should have
0280: 20 72 65 63 65 69 76 65 64 20 61 20 63 6f 70 79 received a copy
0290: 20 6f 66 20 74 68 65 20 47 4e 55 20 47 65 6e 65 of the GNU Gene
02a0: 72 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e ral Public Licen
02b0: 73 65 0a 20 2a 20 20 61 6c 6f 6e 67 20 77 69 74 se. * along wit
02c0: 68 20 74 68 69 73 20 70 72 6f 67 72 61 6d 3b 20 h this program;
02d0: 69 66 20 6e 6f 74 2c 20 77 72 69 74 65 20 74 6f if not, write to
02e0: 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 the Free Softwa
02f0: 72 65 0a 20 2a 20 20 46 6f 75 6e 64 61 74 69 6f re. * Foundatio
0300: 6e 2c 20 49 6e 63 2e 2c 20 35 39 20 54 65 6d 70 n, Inc., 59 Temp
0310: 6c 65 20 50 6c 61 63 65 2c 20 53 75 69 74 65 20 le Place, Suite
0320: 33 33 30 2c 20 42 6f 73 74 6f 6e 2c 20 4d 41 20 330, Boston, MA
0330: 20 30 32 31 31 31 2d 31 33 30 37 20 20 55 53 41 02111-1307 USA
0340: 0a 20 2a 2f 0a 0a 23 69 66 6e 64 65 66 20 50 57 . */..#ifndef PW
0350: 5f 4d 49 4e 44 45 52 5f 48 0a 23 64 65 66 69 6e _MINDER_H.#defin
0360: 65 20 50 57 5f 4d 49 4e 44 45 52 5f 48 0a 0a 23 e PW_MINDER_H..#
0370: 69 6e 63 6c 75 64 65 20 3c 63 75 72 73 65 73 2e include <curses.
0380: 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 h>.#include <std
0390: 69 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c io.h>.#include <
03a0: 73 74 72 69 6e 67 2e 68 3e 0a 23 69 6e 63 6c 75 string.h>.#inclu
03b0: 64 65 20 3c 63 6f 6e 66 69 67 2e 68 3e 0a 23 69 de <config.h>.#i
03c0: 6e 63 6c 75 64 65 20 3c 74 69 6d 65 2e 68 3e 0a nclude <time.h>.
03d0: 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 61 72 67 #include <stdarg
03e0: 2e 68 3e 0a 0a 23 64 65 66 69 6e 65 20 43 4f 4e .h>..#define CON
03f0: 46 5f 46 49 4c 45 20 09 22 2e 70 77 6d 61 6e 72 F_FILE .".pwmanr
0400: 63 22 20 0a 2f 2a 0a 23 64 65 66 69 6e 65 20 4e c" ./*.#define N
0410: 41 4d 45 5f 4c 45 4e 09 34 30 0a 23 64 65 66 69 AME_LEN.40.#defi
0420: 6e 65 20 48 4f 53 54 5f 4c 45 4e 09 34 30 0a 23 ne HOST_LEN.40.#
0430: 64 65 66 69 6e 65 20 55 53 45 52 5f 4c 45 4e 09 define USER_LEN.
0440: 34 30 0a 23 64 65 66 69 6e 65 20 50 41 53 53 5f 40.#define PASS_
0450: 4c 45 4e 09 34 30 0a 23 64 65 66 69 6e 65 20 4c LEN.40.#define L
0460: 41 55 4e 43 48 5f 4c 45 4e 09 34 30 0a 0a 23 64 AUNCH_LEN.40..#d
0470: 65 66 69 6e 65 20 53 48 4f 52 54 5f 53 54 52 09 efine SHORT_STR.
0480: 32 30 0a 23 64 65 66 69 6e 65 09 4d 45 44 5f 53 20.#define.MED_S
0490: 54 52 09 09 33 30 0a 23 64 65 66 69 6e 65 20 4c TR..30.#define L
04a0: 4f 4e 47 5f 53 54 52 09 34 30 0a 23 64 65 66 69 ONG_STR.40.#defi
04b0: 6e 65 20 56 5f 4c 4f 4e 47 5f 53 54 52 09 32 35 ne V_LONG_STR.25
04c0: 36 0a 2a 2f 0a 0a 2f 2a 20 73 74 72 69 6e 67 20 6.*/../* string
04d0: 6c 65 6e 67 74 68 73 20 2a 2f 0a 23 64 65 66 69 lengths */.#defi
04e0: 6e 65 20 53 54 52 49 4e 47 5f 53 48 4f 52 54 09 ne STRING_SHORT.
04f0: 36 34 0a 23 64 65 66 69 6e 65 20 53 54 52 49 4e 64.#define STRIN
0500: 47 5f 4d 45 44 49 55 4d 09 31 32 38 0a 23 64 65 G_MEDIUM.128.#de
0510: 66 69 6e 65 20 53 54 52 49 4e 47 5f 4c 4f 4e 47 fine STRING_LONG
0520: 09 32 35 36 0a 0a 23 64 65 66 69 6e 65 20 4d 41 .256..#define MA
0530: 49 4e 5f 48 45 4c 50 4c 49 4e 45 20 09 22 71 3a IN_HELPLINE ."q:
0540: 71 75 69 74 20 20 3f 3a 68 65 6c 70 20 20 61 3a quit ?:help a:
0550: 61 64 64 20 20 65 3a 65 64 69 74 20 20 64 3a 64 add e:edit d:d
0560: 65 6c 65 74 65 22 0a 23 64 65 66 69 6e 65 20 52 elete".#define R
0570: 45 41 44 4f 4e 4c 59 5f 4d 53 47 09 22 52 4f 22 EADONLY_MSG."RO"
0580: 0a 0a 23 64 65 66 69 6e 65 20 4d 41 58 5f 53 45 ..#define MAX_SE
0590: 41 52 43 48 5f 44 45 50 54 48 20 32 35 0a 0a 23 ARCH_DEPTH 25..#
05a0: 64 65 66 69 6e 65 20 44 45 46 41 55 4c 54 5f 55 define DEFAULT_U
05b0: 4d 41 53 4b 20 30 36 36 0a 0a 0a 23 64 65 66 69 MASK 066...#defi
05c0: 6e 65 20 46 46 5f 56 45 52 53 49 4f 4e 20 33 20 ne FF_VERSION 3
05d0: 0a 0a 73 74 72 75 63 74 20 5f 50 57 20 7b 0a 09 ..struct _PW {..
05e0: 69 6e 74 20 69 64 3b 0a 09 63 68 61 72 20 2a 6e int id;..char *n
05f0: 61 6d 65 3b 0a 09 63 68 61 72 20 2a 68 6f 73 74 ame;..char *host
0600: 3b 0a 09 63 68 61 72 20 2a 75 73 65 72 3b 0a 09 ;..char *user;..
0610: 63 68 61 72 20 2a 70 61 73 73 77 64 3b 0a 09 63 char *passwd;..c
0620: 68 61 72 20 2a 6c 61 75 6e 63 68 3b 0a 09 73 74 har *launch;..st
0630: 72 75 63 74 20 5f 50 57 20 2a 6e 65 78 74 3b 0a ruct _PW *next;.
0640: 7d 3b 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 };.typedef struc
0650: 74 20 5f 50 57 20 50 77 3b 0a 0a 73 74 72 75 63 t _PW Pw;..struc
0660: 74 20 5f 50 57 4c 69 73 74 20 7b 0a 09 63 68 61 t _PWList {..cha
0670: 72 20 2a 6e 61 6d 65 3b 0a 09 50 77 20 2a 6c 69 r *name;..Pw *li
0680: 73 74 3b 0a 09 73 74 72 75 63 74 20 5f 50 57 4c st;..struct _PWL
0690: 69 73 74 20 2a 70 61 72 65 6e 74 3b 0a 09 73 74 ist *parent;..st
06a0: 72 75 63 74 20 5f 50 57 4c 69 73 74 20 2a 73 75 ruct _PWList *su
06b0: 62 6c 69 73 74 73 3b 0a 09 73 74 72 75 63 74 20 blists;..struct
06c0: 5f 50 57 4c 69 73 74 20 2a 6e 65 78 74 3b 0a 0a _PWList *next;..
06d0: 09 2f 2a 20 75 69 20 73 74 75 66 66 2c 20 73 68 ./* ui stuff, sh
06e0: 6f 75 6c 64 6e 27 74 20 62 65 20 68 65 72 65 20 ouldn't be here
06f0: 62 75 74 20 74 68 69 73 20 69 73 20 61 20 71 75 but this is a qu
0700: 69 63 6b 20 68 61 63 6b 20 2a 2f 0a 09 69 6e 74 ick hack */..int
0710: 20 63 75 72 72 65 6e 74 5f 69 74 65 6d 3b 0a 7d current_item;.}
0720: 3b 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 ;.typedef struct
0730: 20 5f 50 57 4c 69 73 74 20 50 57 4c 69 73 74 3b _PWList PWList;
0740: 0a 0a 73 74 72 75 63 74 20 5f 50 57 53 65 61 72 ..struct _PWSear
0750: 63 68 52 65 73 75 6c 74 20 7b 0a 09 2f 2a 20 41 chResult {../* A
0760: 6c 77 61 79 73 20 68 61 73 20 61 20 73 75 62 6c lways has a subl
0770: 69 73 74 2c 20 77 68 65 74 68 65 72 20 74 68 65 ist, whether the
0780: 20 6c 69 73 74 20 6f 72 20 63 68 69 6c 64 20 6d list or child m
0790: 61 74 63 68 65 73 20 2a 2f 0a 09 50 57 4c 69 73 atches */..PWLis
07a0: 74 20 2a 73 75 62 6c 69 73 74 3b 0a 09 2f 2a 20 t *sublist;../*
07b0: 49 66 20 74 68 65 20 65 6e 74 72 79 20 69 74 73 If the entry its
07c0: 65 6c 66 20 6d 61 74 63 68 65 73 2c 20 77 69 6c elf matches, wil
07d0: 6c 20 62 65 20 70 72 65 73 65 6e 74 20 2a 2f 0a l be present */.
07e0: 09 50 77 20 2a 65 6e 74 72 79 3b 0a 0a 09 2f 2a .Pw *entry;.../*
07f0: 20 54 68 65 20 6e 65 78 74 20 6f 6e 65 20 61 6c The next one al
0800: 6f 6e 67 2c 20 61 73 20 77 69 74 68 20 6f 74 68 ong, as with oth
0810: 65 72 20 73 74 72 75 63 74 73 20 2a 2f 0a 09 73 er structs */..s
0820: 74 72 75 63 74 20 5f 50 57 53 65 61 72 63 68 52 truct _PWSearchR
0830: 65 73 75 6c 74 2a 20 6e 65 78 74 3b 0a 7d 3b 0a esult* next;.};.
0840: 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 5f typedef struct _
0850: 50 57 53 65 61 72 63 68 52 65 73 75 6c 74 20 50 PWSearchResult P
0860: 57 53 65 61 72 63 68 52 65 73 75 6c 74 3b 0a 0a WSearchResult;..
0870: 0a 74 79 70 65 64 65 66 20 73 74 72 75 63 74 20 .typedef struct
0880: 7b 0a 09 69 6e 74 20 66 69 65 6c 64 3b 0a 09 63 {..int field;..c
0890: 68 61 72 20 2a 66 69 6c 74 65 72 3b 0a 7d 20 50 har *filter;.} P
08a0: 77 46 69 6c 74 65 72 3b 0a 0a 74 79 70 65 64 65 wFilter;..typede
08b0: 66 20 73 74 72 75 63 74 20 7b 0a 09 63 68 61 72 f struct {..char
08c0: 20 2a 73 65 61 72 63 68 5f 74 65 72 6d 3b 0a 7d *search_term;.}
08d0: 20 50 77 53 65 61 72 63 68 3b 0a 0a 74 79 70 65 PwSearch;..type
08e0: 64 65 66 20 73 74 72 75 63 74 20 7b 0a 09 63 68 def struct {..ch
08f0: 61 72 20 2a 67 70 67 5f 69 64 3b 0a 09 63 68 61 ar *gpg_id;..cha
0900: 72 20 2a 67 70 67 5f 70 61 74 68 3b 0a 09 63 68 r *gpg_path;..ch
0910: 61 72 20 2a 70 61 73 73 77 6f 72 64 5f 66 69 6c ar *password_fil
0920: 65 3b 0a 09 69 6e 74 20 70 61 73 73 70 68 72 61 e;..int passphra
0930: 73 65 5f 74 69 6d 65 6f 75 74 3b 0a 09 50 77 46 se_timeout;..PwF
0940: 69 6c 74 65 72 20 2a 66 69 6c 74 65 72 3b 0a 09 ilter *filter;..
0950: 50 77 53 65 61 72 63 68 20 2a 73 65 61 72 63 68 PwSearch *search
0960: 3b 0a 09 69 6e 74 20 72 65 61 64 6f 6e 6c 79 3b ;..int readonly;
0970: 0a 7d 20 4f 70 74 69 6f 6e 73 3b 0a 0a 4f 70 74 .} Options;..Opt
0980: 69 6f 6e 73 20 2a 6f 70 74 69 6f 6e 73 3b 0a 69 ions *options;.i
0990: 6e 74 20 77 72 69 74 65 5f 6f 70 74 69 6f 6e 73 nt write_options
09a0: 3b 0a 50 57 4c 69 73 74 20 2a 70 77 6c 69 73 74 ;.PWList *pwlist
09b0: 3b 0a 50 57 4c 69 73 74 20 2a 63 75 72 72 65 6e ;.PWList *curren
09c0: 74 5f 70 77 5f 73 75 62 6c 69 73 74 3b 0a 50 57 t_pw_sublist;.PW
09d0: 53 65 61 72 63 68 52 65 73 75 6c 74 20 2a 73 65 SearchResult *se
09e0: 61 72 63 68 5f 72 65 73 75 6c 74 73 3b 0a 74 69 arch_results;.ti
09f0: 6d 65 5f 74 20 74 69 6d 65 5f 62 61 73 65 3b 0a me_t time_base;.
0a00: 0a 63 68 61 72 20 2a 74 72 69 6d 5f 77 73 28 63 .char *trim_ws(c
0a10: 68 61 72 2a 29 3b 0a 76 6f 69 64 20 64 65 62 75 har*);.void debu
0a20: 67 28 63 68 61 72 2a 2c 20 2e 2e 2e 29 3b 0a 76 g(char*, ...);.v
0a30: 6f 69 64 20 70 77 5f 61 62 6f 72 74 28 63 68 61 oid pw_abort(cha
0a40: 72 2a 2c 20 2e 2e 2e 29 3b 0a 69 6e 74 20 75 69 r*, ...);.int ui
0a50: 5f 69 6e 69 74 28 29 3b 0a 69 6e 74 20 75 69 5f _init();.int ui_
0a60: 72 75 6e 28 29 3b 0a 69 6e 74 20 75 69 5f 65 6e run();.int ui_en
0a70: 64 28 29 3b 0a 0a 50 77 46 69 6c 74 65 72 20 2a d();..PwFilter *
0a80: 20 66 69 6c 74 65 72 5f 6e 65 77 28 29 3b 0a 50 filter_new();.P
0a90: 77 53 65 61 72 63 68 20 2a 20 73 65 61 72 63 68 wSearch * search
0aa0: 5f 6e 65 77 28 29 3b 0a 4f 70 74 69 6f 6e 73 20 _new();.Options
0ab0: 2a 20 6f 70 74 69 6f 6e 73 5f 6e 65 77 28 29 3b * options_new();
0ac0: 0a 0a 76 6f 69 64 20 73 65 61 72 63 68 5f 67 65 ..void search_ge
0ad0: 74 28 29 3b 0a 69 6e 74 20 73 65 61 72 63 68 5f t();.int search_
0ae0: 72 65 6d 6f 76 65 28 29 3b 0a 0a 69 6e 74 20 70 remove();..int p
0af0: 77 6c 69 73 74 5f 61 64 64 5f 70 74 72 28 50 57 wlist_add_ptr(PW
0b00: 4c 69 73 74 2a 2c 20 50 77 2a 29 3b 0a 50 77 2a List*, Pw*);.Pw*
0b10: 20 70 77 6c 69 73 74 5f 6e 65 77 5f 70 77 28 29 pwlist_new_pw()
0b20: 3b 0a 50 57 4c 69 73 74 20 2a 70 77 6c 69 73 74 ;.PWList *pwlist
0b30: 5f 6e 65 77 28 63 68 61 72 2a 29 3b 0a 23 65 6e _new(char*);.#en
0b40: 64 69 66 0a dif.