* to users on the Citadel system.
*/
+#ifdef DLL_EXPORT
+#define IN_LIBCIT
+#endif
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include "citadel.h"
#include "server.h"
+#include "dynloader.h"
#include "sysdep_decls.h"
#include "citserver.h"
#include "support.h"
/* extract full name - first, it's From minus <userid> */
strcpy(name, rfc822);
- for (a = 0; a < strlen(name); ++a) {
- if (name[a] == '<') {
- do {
- strcpy(&name[a], &name[a + 1]);
- } while ((strlen(name) > 0) && (name[a] != '>'));
- strcpy(&name[a], &name[a + 1]);
- }
- }
+ stripout(name, '<', '>');
+
/* strip anything to the left of a bang */
while ((strlen(name) > 0) && (haschar(name, '!') > 0))
strcpy(name, &name[1]);
/* but if there are parentheses, that changes the rules... */
if ((haschar(rfc822, '(') == 1) && (haschar(rfc822, ')') == 1)) {
strcpy(name, rfc822);
- while ((strlen(name) > 0) && (name[0] != '(')) {
- strcpy(&name[0], &name[1]);
- }
- strcpy(&name[0], &name[1]);
- for (a = 0; a < strlen(name); ++a) {
- if (name[a] == ')') {
- name[a] = 0;
- }
- }
+ stripallbut(name, '(', ')');
}
+
/* but if there are a set of quotes, that supersedes everything */
if (haschar(rfc822, 34) == 2) {
strcpy(name, rfc822);
strcpy(user, rfc822);
/* first get rid of anything in parens */
- for (a = 0; a < strlen(user); ++a)
- if (user[a] == '(') {
- do {
- strcpy(&user[a], &user[a + 1]);
- } while ((strlen(user) > 0) && (user[a] != ')'));
- strcpy(&user[a], &user[a + 1]);
- }
+ stripout(user, '(', ')');
+
/* if there's a set of angle brackets, strip it down to that */
if ((haschar(user, '<') == 1) && (haschar(user, '>') == 1)) {
- while ((strlen(user) > 0) && (user[0] != '<')) {
- strcpy(&user[0], &user[1]);
- }
- strcpy(&user[0], &user[1]);
- for (a = 0; a < strlen(user); ++a)
- if (user[a] == '>')
- user[a] = 0;
+ stripallbut(user, '<', '>');
}
+
/* strip anything to the left of a bang */
while ((strlen(user) > 0) && (haschar(user, '!') > 0))
strcpy(user, &user[1]);
strcpy(node, rfc822);
/* first get rid of anything in parens */
- for (a = 0; a < strlen(node); ++a)
- if (node[a] == '(') {
- do {
- strcpy(&node[a], &node[a + 1]);
- } while ((strlen(node) > 0) && (node[a] != ')'));
- strcpy(&node[a], &node[a + 1]);
- }
+ stripout(node, '(', ')');
+
/* if there's a set of angle brackets, strip it down to that */
if ((haschar(node, '<') == 1) && (haschar(node, '>') == 1)) {
- while ((strlen(node) > 0) && (node[0] != '<')) {
- strcpy(&node[0], &node[1]);
- }
- strcpy(&node[0], &node[1]);
- for (a = 0; a < strlen(node); ++a)
- if (node[a] == '>')
- node[a] = 0;
+ stripallbut(node, '<', '>');
}
/* If no node specified, tack ours on instead */
* (Compares an internet name [buffer1] and stores in [buffer2] if found)
*/
void try_name(struct usersupp *us, void *data) {
+ struct passwd *pw;
struct trynamebuf *tnb;
tnb = (struct trynamebuf *)data;
if (!collapsed_strcmp(tnb->buffer1, us->fullname))
strcpy(tnb->buffer2, us->fullname);
- if (us->uid != BBSUID)
- if (!strcasecmp(tnb->buffer1, getpwuid(us->uid)->pw_name))
- strcpy(tnb->buffer2, us->fullname);
+ if (us->uid != BBSUID) {
+ pw = getpwuid(us->uid);
+ if (pw != NULL) {
+ if (!strcasecmp(tnb->buffer1, pw->pw_name)) {
+ strcpy(tnb->buffer2, us->fullname);
+ }
+ }
+ }
}