summaryrefslogtreecommitdiff
path: root/src/include/pamela/pamela.h
blob: ca451247c9cc15400b82c9ce49d53d5e5a57e0c6 (plain)
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
/* ISC license. */

#ifndef PAMELA_H
#define PAMELA_H

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/types.h>
#include <stdint.h>
#include <sys/uio.h>
#include <skalibs/stralloc.h>
#include <skalibs/textmessage.h>
#include <pamela/common.h>


 /* pam_fail_delay */

typedef void pamela_pam_delay_func_t (int, unsigned int, void *) ;
typedef pamela_pam_delay_func_t *pamela_pam_delay_func_t_ref ;


 /* Conversations */

typedef struct pamela_pam_message_s pamela_pam_message_t, *pamela_pam_message_t_ref ;
struct pamela_pam_message_s
{
  int msg_style ;
  char const *msg ;
} ;

typedef struct pamela_pam_response_s pamela_pam_response_t, *pamela_pam_response_t_ref ;
struct pamela_pam_response_s
{
  char *resp ;
  int *resp_retcode ;
} ;

extern void pamela_pam_response_free (pamela_pam_response_t *, uint32_t) ;

typedef int pamela_pam_conv_func_t (int, pamela_pam_message_t const **, pamela_pam_response_t **, void *) ;
typedef pamela_pam_conv_func_t *pamela_pam_conv_func_t_ref ;


 /* Client handle */

typedef struct pamela_s pamela_t, *pamela_t_ref ;
struct pamela_s
{
  textmessage_receiver_t in ;
  textmessage_sender_t out ;
  pid_t pid ;
  pamela_pam_delay_func_t_ref delayfn ;
  pamela_pam_conv_func_t_ref convfn ;
  void *aux ;
  char inbuf[PAMELA_BUFSIZE] ;
} ;
#define PAMELA_ZERO { TEXTMESSAGE_RECEIVER_ZERO, TEXTMESSAGE_SENDER_ZERO, 0, 0, 0, 0, "" }

extern pamela_t const pamela_zero ;


 /* User-facing functions */

extern int pamela_startf (pamela_t *, char const *, char const *, pamela_pam_conv_func_t_ref, void *) ;
extern void pamela_end (pamela_t *) ;
extern int pamela_strerror (pamela_t *, unsigned char, stralloc *) ;
extern int pamela_getenvlist (pamela_t *, stralloc *) ;
extern int pamela_get_item (pamela_t *, unsigned char, stralloc *) ;
extern int pamela_set_item (pamela_t *, unsigned char, char const *) ;
extern int pamela_set_itemv (pamela_t *, unsigned char, struct iovec const *, unsigned int) ;
extern int pamela_op (pamela_t *, unsigned char, int) ;


#ifdef __cplusplus
}
#endif

#endif