1 .\" This program is free software; you can redistribute it and/or modify
2 .\" it under the terms of the GNU General Public License as published by
3 .\" the Free Software Foundation; either version 2 of the License, or
4 .\" (at your option) any later version.
6 .\" This program is distributed in the hope that it will be useful,
7 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
8 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 .\" GNU General Public License for more details.
11 .\" You should have received a copy of the GNU General Public License
12 .\" along with this program; if not, write to the Free Software
13 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 \\$2 \(laURL: \\$1 \(ra\\$3
17 .if \n[.g] .mso www.tmac
18 .TH LIBPWMD 3 "10 Jul 2007" "Password Manager Daemon Library" "Password Manager Daemon Library"
21 libpwmd \- pwmd client interface library
24 .B #include <libpwmd.h>
26 .BI "pwmd_error_t pwmd_init(void);"
27 .BI "pwm_t *pwmd_connect(const char *" socket ", gpg_error_t *" error ");"
28 .BI "pwmd_error_t pwmd_setopt(pwm_t *" pwm ", gpg_error_t *" error ", pwmd_option_t " opt ", ...);"
29 .BI "pwmd_error_t pwmd_open(pwm_t *" pwm ", gpg_error_t *" error ", const char *" filename ");"
30 .BI "int pwmd_open_nb(pwm_t *" pwm ", gpg_error_t *" error ", const char *" filename ");"
31 .BI "pwmd_error_t pwmd_open_nb_finalize(pwm_t *" pwm ", gpg_error_t *" error ", pwmd_nb_status_t *" status ");"
32 .BI "pwmd_error_t pwmd_command(pwm_t *" pwm ", char **" result ", gpg_error_t *" error ", const char *" cmd ", " ... ");"
33 .BI "void pwmd_free_result(void *" result ");"
34 .BI "pwmd_error_t pwmd_save(pwm_t *" pwm ", gpg_error_t *" error ");"
35 .BI "int pwmd_save_nb(pwm_t *" pwm ", gpg_error_t *" error ");"
36 .BI "pwmd_error_t pwmd_save_nb_finalize(pwm_t *" pwm ", gpg_error_t *" error ", pwmd_nb_status_t *" status ");"
37 .BI "void pwmd_close(pwm_t *" pwm ");"
38 .BI "const char *pwmd_strerror(gpg_error_t " error ");"
40 .BI "typedef int (*" pwmd_status_fn ")(void *" data ", const char *" line ");"
41 .BI "typedef char *(*" pwmd_password_fn ")(pwm_t *" pwm ", void *" data ");"
45 is an library making it easy for applications to use
49 .BI "pwmd_error_t pwmd_init(void);"
50 Initializes libassuan and libgpg-error stuff. Be sure to call this before
51 using the other functions.
54 .BI "pwm_t *pwmd_connect(const char *" socket ", gpg_error_t *" error ");"
55 Connects to the specified \fIsocket\fP. If \fIsocket\fP is NULL then a default
56 of \fI~/.pwmd/socket\fP will be used. If there is an error while connecting
57 \fIerror\fP is set to the error code of the failed function and NULL is
58 returned. When successful a handle is returned for use with the other library
62 .BI "pwmd_error_t pwmd_setopt(pwm_t *" pwm ", gpg_error_t *" error ", pwmd_option_t " opt ", ...);"
63 Set the library option \fIopt\fP to the value of the next argument where
64 \fIopt\fP is one of the following:
67 .B PWMD_OPTION_PASSWORD_FUNC
68 Specifies a function to use to get a password. The next argument should be of
69 type \fIpwmd_password_fn\fP. The function should return a \fIchar
70 *\fP string which is the password or NULL if there is an
73 .B PWMD_OPTION_PASSWORD_DATA
74 A user data pointer passed to the password function.
76 .B PWMD_OPTION_PINENTRY
79 to obtain the password when opening and saving a file on the server. The
80 following argument is an \fIint\fP and is \fI1\fP to enable
82 use, and \fI0\fP to use the password which is set with
83 \fBPWMD_OPTION_PASSWORD\fP or \fBPWMD_OPTION_PASSWORD_FUNC\fP.
85 .B PWMD_OPTION_PINENTRY_TTY
87 .B PWMD_OPTION_PINENTRY_TERM
89 .B PWMD_OPTION_PINENTRY_DISPLAY
92 command line options. The next argument should be of type \fIchar *\fP. If not
93 set, then the current DISPLAY, if set, or tty will be used.
95 .B PWMD_OPTION_PINENTRY_TITLE
97 .B PWMD_OPTION_PINENTRY_DESC
99 .B PWMD_OPTION_PINENTRY_PROMPT
100 Sets the strings used in the
103 The next argument is of type \fIchar *\fP. If not defined then a default will
106 .B PWMD_OPTION_PASSWORD
107 Sets the password to use for opening and saving a file when
108 \fBPWMD_OPTION_PINENTRY\fP is \fI0\fP. The following argument is the password
109 and is of type \fIchar *\fP.
111 .B PWMD_OPTION_STATUS_FUNC
113 .B PWMD_OPTION_STATUS_DATA
114 Function to be called when
116 sends a status message. This function should return \fB0\fP on success or a
117 \fBgpg_error_t\fP on failure. The data passed to the function can be set with
118 \fBPWMD_OPTION_STATUS_DATA\fP. At the moment,
120 only send's status messages when opening or saving a file and configured to do
126 .BI "pwmd_error_t pwmd_open(pwm_t *" pwm ", gpg_error_t *" error ", const char *" filename ");"
127 Opens the specified \fIfilename\fP on the server. The password for the file is
128 gotten from one of the methods specified with \fBpwmd_setopt\fP().
129 \fBPWMD_ERROR\fP is returned on error with \fIerror\fP set to the error code
130 of the failed function. Otherwise \fBPWMD_OK\fP is returned.
133 .BI "int pwmd_open_nb(pwm_t *" pwm ", gpg_error_t *" error ", const char *" filename ");"
134 This is a nonblocking way of obtaining the password from
136 when opening a file on the server. When successful, it returns a file
141 should read a \fIpwmd_nb_status_t\fP and then call
142 \fBpwmd_open_nb_finalize\fP() to update the handle. If there is an error,
143 \fB-1\fP is returned and \fIerror\fP is set. If \fIfilename\fP is already
144 cached on the server or doesn't exist on the filesystem and the open
145 succeeded, \fB-2\fP is returned. Note that \fBPWMD_OPTION_PINENTRY\fP must be
149 .BI "pwmd_error_t pwmd_open_nb_finalize(pwm_t *" pwm ", gpg_error_t *" error ", pwmd_nb_status_t *" status ");"
150 For use with \fBpwmd_open_nb\fP(); it updates the handle \fIpwm\fP. This
151 should be called right after the successful
153 of \fIstatus\fP from the file descriptor returned by \fBpwmd_open_nb\fP(). If
154 there was a protocol or
156 error, \fIerror\fP is set and \fBPWMD_ERROR\fP is returned. Otherwise
157 \fBPWMD_OK\fP is returned.
160 .BI "pwmd_error_t pwmd_command(pwm_t *" pwm ", char **" result ", gpg_error_t *" error ", const char *" cmd ", " ... ");"
161 Sends a protocol command to the server. The function returns \fBPWMD_OK\fP
162 when successful and stores the result of the command format string \fIcmd\fP
163 to \fIresult\fP. The result should be free'd with \fBpwmd_free_result\fP().
164 Protocol commands that don't have a result will set \fIresult\fP to NULL. If
165 an error occurs then \fBPWMD_ERROR\fP is returned and \fIerror\fP is set to
166 the error code. Note: the BYE protocol command should not be sent here. Use
167 \fBpwmd_close\fP() instead.
170 .BI "void pwmd_free_result(void *" result ");"
171 Deallocates the memory of \fBpwmd_command\fP() result. It is important to use
172 this function because
174 not only keeps track of all allocated memory used by other
176 functions, but also clears the memory contents for better security. Don't use
177 this to free your own allocated memory though.
180 .BI "pwmd_error_t pwmd_save(pwm_t *" pwm ", gpg_error_t *" error ");"
181 Saves the changes to the file associated with the handle \fIpwm\fP. If not
182 called before \fBpwmd_close\fP() then any changes will be lost. If an error
183 occurs then \fBPWMD_ERROR\fP is returned and \fIerror\fP is set. Otherwise
184 \fBPWMD_OK\fP is returned.
187 .BI "int pwmd_save_nb(pwm_t *" pwm ", gpg_error_t *" error ");"
188 This is a nonblocking way of obtaining the password from
190 when saving an opened file. When successful, a file descriptor is returned
195 should read a \fIpwmd_nb_status_t\fP and then call
196 \fBpwmd_save_nb_finalize\fP() to update the handle. If there was an error,
197 \fB-1\fP is returned and \fIerror\fP is set. If the file is cached on the
198 server and the save succeeded, \fB-2\fP is returned. Note that
199 \fBPWMD_OPTION_PINENTRY\fP must be set.
202 .BI "pwmd_error_t pwmd_save_nb_finalize(pwm_t *" pwm ", gpg_error_t *" error ", pwmd_nb_status_t *" status ");"
203 For use with \fBpwmd_save_nb\fP(); it updates the handle \fIpwm\fP. This
204 should be called right after the successful
206 of \fIstatus\fP from the file descriptor returned by \fBpwmd_save_nb\fP(). If
207 there was a protocol or
209 error, \fIerror\fP is set and \fBPWMD_ERROR\fP is returned. Otherwise
210 \fBPWMD_OK\fP is returned.
213 .BI "void pwmd_close(pwm_t *" pwm ");"
214 Closes the server connection and free's resources used by the handle
218 .BI "const char *pwmd_strerror(gpg_error_t " error ");"
219 Returns a string describing the error code \fIerror\fP which was set from one
220 of the above functions.
225 Default connecting socket.
227 .B @prefix@/lib/pkgconfig/libpwmd.pc
232 .B @prefix@/include/libpwmd.h
233 Installed location of header file.
236 Ben Kibbey <bjk@luxsci.net>
238 .URL "http://bjk.sourceforge.net/pwmd/" "PWMD Homepage" .