aboutsummaryrefslogtreecommitdiff
path: root/src/bi_other.m4
blob: 1e4a98c2d26045c420a07c2bca0755c7d5985dd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* This file is part of mailfromd.             -*- c -*-
   Copyright (C) 2006, 2007 Sergey Poznyakoff

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   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, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
   MA 02110-1301 USA */

static int
valid_user_p(eval_environ_t env, const char *name)
{
	int rc;
	struct mu_auth_data *auth_data = NULL;

#if HAVE_MU_GET_AUTH
	rc = mu_get_auth(&auth_data, mu_auth_key_name, name);
	mu_auth_data_free(auth_data);
	switch (rc) {
	case 0:
		rc = 1;
		break;
		
	case MU_ERR_AUTH_FAILURE:
		rc = 0;
		break;

	case EAGAIN:
                MF_THROW(mf_temp_failure,
		         _("Temporary failure querying for username %s"),
			 name);
		break;

	default:
                MF_THROW(mf_failure,
		         _("Failure querying for username %s"),
			 name);
		break;
	}
#else
	auth_data = mu_get_auth_by_name(name);
	rc = auth_data != NULL;
	mu_auth_data_free(auth_data);
#endif
	debug2(10, "Checking user %s: %s", name,
	       rc ? "true" : "false");
	return rc;
}

MF_DEFUN(validuser, NUMBER, STRING name)
{
	MF_RETURN(valid_user_p(env, name));
}
END

MF_DEFUN(interval, NUMBER, STRING str)
{
       time_t t;
       const char *endp;

       MF_ASSERT(parse_time_interval(str, &t, &endp) == 0,
	         mf_invtime,
		 _("Unrecognized time format (near `%s')"), endp);
       MF_RETURN(t);
}
END

MF_DEFUN(rate, NUMBER, STRING key, NUMBER interval)
{
	double rate;
	long lrate;
		
	MF_ASSERT(get_rate(key, &rate) == mf_success,
		 mf_dbfailure,
		 _("Cannot get rate for %s"), key);
	lrate = rate * interval;
	
	MF_RETURN(lrate);
}
END

MF_DEFUN(debug_level, NUMBER, OPTIONAL, STRING modname)
{
	int level;
	MF_ASSERT(debug_module_level(MF_OPTVAL(modname, NULL), &level) == 0,
		  mf_range,
		  _("Invalid module name: %s"), modname);
	MF_RETURN(level);
}
END

MF_DEFUN(debug_spec, STRING, OPTIONAL, STRING modnames)
{
	char *buf;
	char *s;
	size_t off;

 	int rc = debug_spec_string(MF_OPTVAL(modnames, NULL), &buf);
	MF_ASSERT(rc == 0,
		  mf_failure,
		  "%s", mu_strerror(rc));
	s = MF_ALLOC_HEAP(off, strlen(buf) + 1);
	strcpy(s, buf);
	free(buf);
	MF_RETURN(off);
}
END

MF_DEFUN(debug, VOID, STRING spec)
{
	debug_parse_spec(spec);
}
END

MF_DEFUN(program_trace, VOID, STRING name)
{
	enable_prog_trace(name);
}
END

MF_DEFUN(cancel_program_trace, VOID, STRING name)
{
	disable_prog_trace(name);
}
END	

MF_DEFUN(stack_trace, VOID)
{
	runtime_stack_trace(env);
}
END

MF_INIT

Return to:

Send suggestions and report system problems to the System administrator.