NeoMutt  2024-04-25-76-g20fe7b
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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.
 
#define MIX_CAP_COMPRESS   (1 << 0)
 Accepts compressed messages.
 
#define MIX_CAP_MIDDLEMAN   (1 << 1)
 Must be a middle-man (not at the end of a chain)
 
#define MIX_CAP_NEWSPOST   (1 << 2)
 Supports direct posting to Usenet.
 
#define MIX_CAP_NEWSMAIL   (1 << 3)
 Supports posting to Usenet through a mail-to-news gateway.
 

Typedefs

typedef uint8_t MixCapFlags
 Flags, e.g. MIX_CAP_NO_FLAGS.
 

Enumerations

enum  ExpandoDataMixmaster { ED_MIX_ADDRESS = 1 , ED_MIX_CAPABILITIES , ED_MIX_NUMBER , ED_MIX_SHORT_NAME }
 Expando UIDs for Mixmaster. More...
 

Functions

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

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.

Enumeration Type Documentation

◆ ExpandoDataMixmaster

Expando UIDs for Mixmaster.

See also
ED_MIXMASTER, ExpandoDomain
Enumerator
ED_MIX_ADDRESS 

Remailer.addr.

ED_MIX_CAPABILITIES 

Remailer, mix_format_caps()

ED_MIX_NUMBER 

Remailer.num.

ED_MIX_SHORT_NAME 

Remailer.shortname.

Definition at line 54 of file remailer.h.

55{
56 ED_MIX_ADDRESS = 1,
60};
@ ED_MIX_ADDRESS
Remailer.addr.
Definition: remailer.h:56
@ ED_MIX_CAPABILITIES
Remailer, mix_format_caps()
Definition: remailer.h:57
@ ED_MIX_SHORT_NAME
Remailer.shortname.
Definition: remailer.h:59
@ ED_MIX_NUMBER
Remailer.num.
Definition: remailer.h:58

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 46 of file remailer.c.

47{
48 if (!ptr || !*ptr)
49 return;
50
51 struct Remailer *r = *ptr;
52 FREE(&r->shortname);
53 FREE(&r->addr);
54 FREE(&r->ver);
55
56 FREE(ptr);
57}
#define FREE(x)
Definition: memory.h:45
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 63 of file remailer.c.

64{
65 return mutt_mem_calloc(1, sizeof(struct Remailer));
66}
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
+ 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 206 of file remailer.c.

207{
208 struct Remailer **r = NULL;
209 ARRAY_FOREACH(r, ra)
210 {
211 remailer_free(r);
212 }
213
214 ARRAY_FREE(ra);
215}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
void remailer_free(struct Remailer **ptr)
Free a Remailer.
Definition: remailer.c:46
+ 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 115 of file remailer.c.

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