Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymilter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
misc
pymilter
Commits
4e0d3da0
Commit
4e0d3da0
authored
14 years ago
by
Stuart Gathman
Browse files
Options
Downloads
Patches
Plain Diff
Print callback name for non-int return error.
parent
53c75199
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
miltermodule.c
+40
-6
40 additions, 6 deletions
miltermodule.c
with
40 additions
and
6 deletions
miltermodule.c
+
40
−
6
View file @
4e0d3da0
...
@@ -35,6 +35,9 @@ $ python setup.py help
...
@@ -35,6 +35,9 @@ $ python setup.py help
libraries=["milter","smutil","resolv"]
libraries=["milter","smutil","resolv"]
* $Log$
* $Log$
* Revision 1.28 2011/06/08 23:13:48 customdesigned
* Generate special exception when callback return not int.
*
* Revision 1.27 2009/07/28 21:45:54 customdesigned
* Revision 1.27 2009/07/28 21:45:54 customdesigned
* Add getversion() to return runtime version.
* Add getversion() to return runtime version.
*
*
...
@@ -271,7 +274,6 @@ $ python setup.py help
...
@@ -271,7 +274,6 @@ $ python setup.py help
#endif
#endif
#endif
#endif
/* Yes, these are static. If you need multiple different callbacks, */
/* Yes, these are static. If you need multiple different callbacks, */
/* it's cleaner to use multiple filters, or convert to OO method calls. */
/* it's cleaner to use multiple filters, or convert to OO method calls. */
static
PyObject
*
connect_callback
=
NULL
;
static
PyObject
*
connect_callback
=
NULL
;
...
@@ -284,6 +286,32 @@ static PyObject *body_callback = NULL;
...
@@ -284,6 +286,32 @@ static PyObject *body_callback = NULL;
static
PyObject
*
eom_callback
=
NULL
;
static
PyObject
*
eom_callback
=
NULL
;
static
PyObject
*
abort_callback
=
NULL
;
static
PyObject
*
abort_callback
=
NULL
;
static
PyObject
*
close_callback
=
NULL
;
static
PyObject
*
close_callback
=
NULL
;
#ifdef SMFIS_ALL_OPTS
static
PyObject
*
unknown_callback
=
NULL
;
static
PyObject
*
data_callback
=
NULL
;
static
PyObject
*
negotiate_callback
=
NULL
;
#endif
static
struct
MilterCallback
{
PyObject
**
cbp
;
const
char
*
name
;
}
callback_names
[]
=
{
{
&
connect_callback
,
"connect"
},
{
&
helo_callback
,
"helo"
},
{
&
envfrom_callback
,
"envfrom"
},
{
&
envrcpt_callback
,
"envrcpt"
},
{
&
header_callback
,
"header"
},
{
&
eoh_callback
,
"eoh"
},
{
&
body_callback
,
"body"
},
{
&
eom_callback
,
"eom"
},
{
&
abort_callback
,
"abort"
},
{
&
close_callback
,
"close"
},
#ifdef SMFIS_ALL_OPTS
{
&
unknown_callback
,
"unknown"
},
{
&
data_callback
,
"data"
},
{
&
negotiate_callback
,
"negotiate"
},
#endif
{
NULL
,
NULL
}
};
staticforward
struct
smfiDesc
description
;
/* forward declaration */
staticforward
struct
smfiDesc
description
;
/* forward declaration */
...
@@ -635,8 +663,18 @@ _generic_wrapper(milter_ContextObject *self, PyObject *cb, PyObject *arglist) {
...
@@ -635,8 +663,18 @@ _generic_wrapper(milter_ContextObject *self, PyObject *cb, PyObject *arglist) {
Py_DECREF
(
arglist
);
Py_DECREF
(
arglist
);
if
(
result
==
NULL
)
return
_report_exception
(
self
);
if
(
result
==
NULL
)
return
_report_exception
(
self
);
if
(
!
PyInt_Check
(
result
))
{
if
(
!
PyInt_Check
(
result
))
{
const
struct
MilterCallback
*
p
;
const
char
*
cbname
=
"milter"
;
char
buf
[
40
];
Py_DECREF
(
result
);
Py_DECREF
(
result
);
PyErr_SetString
(
MilterError
,
"callback methods must return int"
);
for
(
p
=
callback_names
;
p
->
cbp
;
++
p
)
{
if
(
cb
==
*
p
->
cbp
)
{
cbname
=
p
->
name
;
break
;
}
}
sprintf
(
buf
,
"The %s callback must return int"
,
cbname
);
PyErr_SetString
(
MilterError
,
buf
);
return
_report_exception
(
self
);
return
_report_exception
(
self
);
}
}
retval
=
PyInt_AS_LONG
(
result
);
retval
=
PyInt_AS_LONG
(
result
);
...
@@ -829,10 +867,6 @@ milter_wrap_abort(SMFICTX *ctx) {
...
@@ -829,10 +867,6 @@ milter_wrap_abort(SMFICTX *ctx) {
}
}
#ifdef SMFIS_ALL_OPTS
#ifdef SMFIS_ALL_OPTS
static
PyObject
*
unknown_callback
=
NULL
;
static
PyObject
*
data_callback
=
NULL
;
static
PyObject
*
negotiate_callback
=
NULL
;
static
int
static
int
milter_wrap_unknown
(
SMFICTX
*
ctx
,
const
char
*
cmd
)
{
milter_wrap_unknown
(
SMFICTX
*
ctx
,
const
char
*
cmd
)
{
PyObject
*
arglist
;
PyObject
*
arglist
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment