NeoMutt  2023-05-17-16-g61469c
Teaching an old dog new tricks
DOXYGEN
remailer.h File Reference

Mixmaster Remailer. More...

#include <stdint.h>
#include "mutt/lib.h"
+ Include dependency graph for remailer.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Remailer
 A Mixmaster remailer. More...
 

Macros

#define MIX_CAP_NO_FLAGS   0
 No flags are set. More...
 
#define MIX_CAP_COMPRESS   (1 << 0)
 Accepts compressed messages. More...
 
#define MIX_CAP_MIDDLEMAN   (1 << 1)
 Must be a middle-man (not at the end of a chain) More...
 
#define MIX_CAP_NEWSPOST   (1 << 2)
 Supports direct posting to Usenet. More...
 
#define MIX_CAP_NEWSMAIL   (1 << 3)
 Supports posting to Usenet through a mail-to-news gateway. More...
 

Typedefs

typedef uint8_t MixCapFlags
 Flags, e.g. MIX_CAP_NO_FLAGS. More...
 

Functions

 ARRAY_HEAD (RemailerArray, struct Remailer *)
 
void remailer_free (struct Remailer **ptr)
 Free a Remailer. More...
 
struct Remailerremailer_new (void)
 Create a new Remailer. More...
 
void remailer_clear_hosts (struct RemailerArray *ra)
 Clear a Remailer List. More...
 
struct RemailerArray remailer_get_hosts (void)
 Parse the type2.list as given by mixmaster -T. More...
 

Detailed Description

Mixmaster Remailer.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file remailer.h.

Macro Definition Documentation

◆ MIX_CAP_NO_FLAGS

#define MIX_CAP_NO_FLAGS   0

No flags are set.

Definition at line 30 of file remailer.h.

◆ MIX_CAP_COMPRESS

#define MIX_CAP_COMPRESS   (1 << 0)

Accepts compressed messages.

Definition at line 31 of file remailer.h.

◆ MIX_CAP_MIDDLEMAN

#define MIX_CAP_MIDDLEMAN   (1 << 1)

Must be a middle-man (not at the end of a chain)

Definition at line 32 of file remailer.h.

◆ MIX_CAP_NEWSPOST

#define MIX_CAP_NEWSPOST   (1 << 2)

Supports direct posting to Usenet.

Definition at line 33 of file remailer.h.

◆ MIX_CAP_NEWSMAIL

#define MIX_CAP_NEWSMAIL   (1 << 3)

Supports posting to Usenet through a mail-to-news gateway.

Definition at line 34 of file remailer.h.

Typedef Documentation

◆ MixCapFlags

typedef uint8_t MixCapFlags

Flags, e.g. MIX_CAP_NO_FLAGS.

Definition at line 29 of file remailer.h.

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( RemailerArray  ,
struct Remailer  
)

◆ remailer_free()

void remailer_free ( struct Remailer **  ptr)

Free a Remailer.

Parameters
ptrRemailer to free

Definition at line 44 of file remailer.c.

45{
46 if (!ptr || !*ptr)
47 return;
48
49 struct Remailer *r = *ptr;
50
51 FREE(&r->shortname);
52 FREE(&r->addr);
53 FREE(&r->ver);
54 FREE(ptr);
55}
#define FREE(x)
Definition: memory.h:43
A Mixmaster remailer.
Definition: remailer.h:40
char * addr
Address of host.
Definition: remailer.h:43
char * shortname
Short name of remailer host.
Definition: remailer.h:42
char * ver
Version of host.
Definition: remailer.h:44
+ Here is the caller graph for this function:

◆ remailer_new()

struct Remailer * remailer_new ( void  )

Create a new Remailer.

Return values
ptrNewly allocated Remailer

Definition at line 61 of file remailer.c.

62{
63 return mutt_mem_calloc(1, sizeof(struct Remailer));
64}
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remailer_clear_hosts()

void remailer_clear_hosts ( struct RemailerArray *  ra)

Clear a Remailer List.

Parameters
raArray of Remailer hosts to clear
Note
The empty array is not freed

Definition at line 203 of file remailer.c.

204{
205 struct Remailer **r = NULL;
206 ARRAY_FOREACH(r, ra)
207 {
208 remailer_free(r);
209 }
210
211 ARRAY_FREE(ra);
212}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:211
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:203
void remailer_free(struct Remailer **ptr)
Free a Remailer.
Definition: remailer.c:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remailer_get_hosts()

struct RemailerArray remailer_get_hosts ( void  )

Parse the type2.list as given by mixmaster -T.

Return values
objArray of Remailer Hosts

Definition at line 113 of file remailer.c.

114{
115 struct RemailerArray ra = ARRAY_HEAD_INITIALIZER;
116 FILE *fp = NULL;
117 char line[8192] = { 0 };
118 char *t = NULL;
119 struct Remailer *p = NULL;
120
121 const char *const c_mixmaster = cs_subset_string(NeoMutt->sub, "mixmaster");
122 if (!c_mixmaster)
123 return ra;
124
125 int fd_null = open("/dev/null", O_RDWR);
126 if (fd_null == -1)
127 return ra;
128
129 struct Buffer *cmd = buf_pool_get();
130 buf_printf(cmd, "%s -T", c_mixmaster);
131
132 pid_t mm_pid = filter_create_fd(buf_string(cmd), NULL, &fp, NULL, fd_null, -1, fd_null);
134 if (mm_pid == -1)
135 {
136 buf_pool_release(&cmd);
137 close(fd_null);
138 return ra;
139 }
140
141 buf_pool_release(&cmd);
142
143 /* first, generate the "random" remailer */
144
145 p = remailer_new();
146 p->shortname = mutt_str_dup(_("<random>"));
147 p->num = 0;
148 ARRAY_ADD(&ra, p);
149
150 while (fgets(line, sizeof(line), fp))
151 {
152 p = remailer_new();
153
154 t = strtok(line, " \t\n");
155 if (!t)
156 goto problem;
157
158 p->shortname = mutt_str_dup(t);
159
160 t = strtok(NULL, " \t\n");
161 if (!t)
162 goto problem;
163
164 p->addr = mutt_str_dup(t);
165
166 t = strtok(NULL, " \t\n");
167 if (!t)
168 goto problem;
169
170 t = strtok(NULL, " \t\n");
171 if (!t)
172 goto problem;
173
174 p->ver = mutt_str_dup(t);
175
176 t = strtok(NULL, " \t\n");
177 if (!t)
178 goto problem;
179
180 p->caps = mix_get_caps(t);
181
182 p->num = ARRAY_SIZE(&ra);
183 ARRAY_ADD(&ra, p);
184 continue;
185
186 problem:
187 remailer_free(&p);
188 }
189
190 filter_wait(mm_pid);
191
192 close(fd_null);
193
194 return ra;
195}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition: array.h:155
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:86
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition: array.h:57
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:171
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:78
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
pid_t filter_create_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr)
Run a command on a pipe (optionally connect stdin/stdout)
Definition: filter.c:61
#define _(a)
Definition: message.h:28
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:251
void window_invalidate_all(void)
Mark all windows as in need of repaint.
Definition: mutt_window.c:743
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:106
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:119
static MixCapFlags mix_get_caps(const char *capstr)
Get Mixmaster Capabilities.
Definition: remailer.c:71
struct Remailer * remailer_new(void)
Create a new Remailer.
Definition: remailer.c:61
String manipulation buffer.
Definition: buffer.h:34
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
int num
Index number.
Definition: remailer.h:41
MixCapFlags caps
Capabilities of host.
Definition: remailer.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function: