5 # Form-urlencoding functions
7 # (c) 2006 Straylight/Edgeware
10 #----- Licensing notice -----------------------------------------------------
12 # This file is part of the Python interface to mLib.
14 # mLib/Python is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # mLib/Python is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with mLib/Python; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 def __cinit__(me, *hunoz, **hukairz):
35 def __init__(me, strictp = False, laxp = False, semip = False):
45 def encode(me, char *name, char *value):
46 url_enc(&me.ctx, &me.d, name, value)
50 return PyString_FromStringAndSize(me.d.buf, me.d.len)
53 return _tobool(me.ctx.f & URLF_STRICT)
56 me.ctx.f = me.ctx.f | URLF_STRICT
58 me.ctx.f = me.ctx.f & ~URLF_STRICT
61 return _tobool(me.ctx.f & URLF_LAX)
64 me.ctx.f = me.ctx.f | URLF_LAX
66 me.ctx.f = me.ctx.f & ~URLF_LAX
69 return _tobool(me.ctx.f & URLF_SEMI)
72 me.ctx.f = me.ctx.f | URLF_SEMI
74 me.ctx.f = me.ctx.f & ~URLF_SEMI
82 def __cinit__(me, *hunoz, **hukairz):
84 url_initdec(&me.ctx, me.p)
85 def __init__(me, char *string, semip = False):
91 me.p = xstrdup(string)
104 anyp = url_dec(&me.ctx, &n, &v)
106 nn = PyString_FromStringAndSize(n.buf, n.len)
107 vv = PyString_FromStringAndSize(v.buf, v.len)
115 return _tobool(me.ctx.f & URLF_SEMI)
116 def __set__(me, val):
118 me.ctx.f = me.ctx.f | URLF_SEMI
120 me.ctx.f = me.ctx.f & ~URLF_SEMI
124 #----- That's all, folks ----------------------------------------------------