updates
[silc.git] / lib / silccore / silcprivate.h
1 /****h* silccore/silcprivate.h
2  *
3  * NAME
4  *
5  * silcprivate.h
6  *
7  * COPYRIGHT
8  *
9  * Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
10  *
11  * Copyright (C) 1997 - 2001 Pekka Riikonen
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * DESCRIPTION
24  *
25  * Implementation of the SILC Private Message Payload that is used to
26  * deliver private messages.
27  *
28  ***/
29
30 #ifndef SILCPRIVATE_H
31 #define SILCPRIVATE_H
32
33 /****s* silccore/SilcPrivateAPI/SilcPrivateMessagePayload
34  *
35  * NAME
36  * 
37  *    typedef struct SilcPrivateMessagePayloadStruct 
38  *                     *SilcPrivateMessagePayload;
39  *
40  *
41  * DESCRIPTION
42  *
43  *    This context is the actual Private Message Payload and is allocated
44  *    by silc_private_message_payload_parse and given as argument usually
45  *    to all silc_private_message_* functions.  It is freed by the
46  *    silc_private_message_payload_free function.
47  *
48  ***/
49 typedef struct SilcPrivateMessagePayloadStruct *SilcPrivateMessagePayload;
50
51 /* Prototypes */
52
53 /****f* silccore/SilcPrivateAPI/silc_private_message_payload_parse
54  *
55  * SYNOPSIS
56  *
57  *    SilcPrivateMessagePayload 
58  *    silc_private_message_payload_parse(SilcBuffer buffer, SilcCipher cipher);
59  *
60  * DESCRIPTION
61  *
62  *    Parses private message payload returning new private mesage payload 
63  *    structure. This also decrypts the message if the `cipher' is provided.
64  *
65  ***/
66 SilcPrivateMessagePayload 
67 silc_private_message_payload_parse(SilcBuffer buffer, SilcCipher cipher);
68
69 /****f* silccore/SilcPrivateAPI/silc_private_message_payload_encode
70  *
71  * SYNOPSIS
72  *
73  *    SilcBuffer silc_private_message_payload_encode(uint16 flags,
74  *                                                   uint16 data_len,
75  *                                                   unsigned char *data,
76  *                                                   SilcCipher cipher);
77  *
78  * DESCRIPTION
79  *
80  *    Encodes private message payload into a buffer and returns it.  If
81  *    the cipher is provided the packet is also encrypted here.  It is provided
82  *    if the private message private keys are used.
83  *
84  ***/
85 SilcBuffer silc_private_message_payload_encode(uint16 flags,
86                                                uint16 data_len,
87                                                unsigned char *data,
88                                                SilcCipher cipher);
89
90 /****f* silccore/SilcPrivateAPI/silc_private_message_payload_free
91  *
92  * SYNOPSIS
93  *
94  *    void 
95  *    silc_private_message_payload_free(SilcPrivateMessagePayload payload);
96  *
97  * DESCRIPTION
98  *
99  *    Frees Private Message Payload
100  *
101  ***/
102 void silc_private_message_payload_free(SilcPrivateMessagePayload payload);
103
104 /****f* silccore/SilcPrivateAPI/silc_private_message_get_flags
105  *
106  * SYNOPSIS
107  *
108  *    uint16 
109  *    silc_private_message_get_flags(SilcPrivateMessagePayload payload);
110  *
111  * DESCRIPTION
112  *
113  *    Returns flags from the payload. Message flags may indicate some
114  *    status of the message. Private message flags are equivalent to the
115  *    channel message flags.
116  *
117  ***/
118 uint16 
119 silc_private_message_get_flags(SilcPrivateMessagePayload payload);
120
121 /****f* silccore/SilcPrivateAPI/silc_private_message_get_message
122  *
123  * SYNOPSIS
124  *
125  *    unsigned char *
126  *    silc_private_message_get_nickname(SilcPrivateMessagePayload payload,
127  *                                      uint32 *nickname_len);
128  *
129  * DESCRIPTION
130  *
131  *    Returns the actual private message. The caller must not free it.
132  *
133  ***/
134 unsigned char *
135 silc_private_message_get_message(SilcPrivateMessagePayload payload,
136                                  uint32 *message_len);
137
138 #endif