2
* readflo.c -- Filename translation in ?lo-files
4
* readflo.c is a part of binkd project
6
* Copyright (C) 1997 Dima Maloff, 5047/13
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version. See COPYING.
15
* $Id: readflo.c,v 2.0 2001/01/10 12:12:39 gul Exp $
18
* Revision 2.0 2001/01/10 12:12:39 gul
19
* Binkd is under CVS again
21
* Revision 1.1 1997/03/28 06:20:30 mff
35
RF_RULE *rf_rules = 0;
38
* Reads a line from a flo to dst[MAXPATHLEN], sets action
42
int read_flo_line (char *dst, int *action, FILE *flo)
44
char buf[MAXPATHLEN + 1];
49
if (!fgets (buf, MAXPATHLEN, flo))
52
for (i = strlen (buf) - 1; i > 0 && isspace (buf[i]); --i)
62
strcpy (dst, buf + 1);
66
strcpy (dst, buf + 1);
79
* Translates a flo line using rf_rules.
80
* Returns 0 if no rf_rules defined, otherwise returned value
83
char *trans_flo_line (char *s)
86
char buf[MAXPATHLEN + 1];
92
strnzcpy (buf, s, MAXPATHLEN);
93
for (curr = rf_rules; curr; curr = curr->next)
95
w = ed (buf, curr->from, curr->to, NULL);
96
strnzcpy (buf, w, MAXPATHLEN);
106
* Add a translation rule for trans_flo_line ()
107
* (From and to are saved as pointers!)
109
void rf_rule_add (char *from, char *to)
111
static RF_RULE *last_rule = 0;
112
RF_RULE *new_rule = xalloc (sizeof (RF_RULE));
114
memset (new_rule, 0, sizeof (RF_RULE));
115
new_rule->from = from;
118
last_rule->next = new_rule;
121
last_rule = new_rule;