~exarkun/pyopenssl/mem-bio

« back to all changes in this revision

Viewing changes to src/crypto/x509ext.c

  • Committer: Jean-Paul Calderone
  • Date: 2008-12-31 20:53:48 UTC
  • Revision ID: exarkun@divmod.com-20081231205348-g6kxdommyilfd8ua
Add X509ExtensionType.get_short_name

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    return PyInt_FromLong(X509_EXTENSION_get_critical(self->x509_extension));
31
31
}
32
32
 
 
33
static char crypto_X509Extension_get_short_name_doc[] = "\n\
 
34
Returns the short version of the type name of the X509Extension\n\
 
35
\n\
 
36
Arguments: self - The X509Extension object\n\
 
37
           args - The argument tuple, should be empty\n\
 
38
Returns: The short type name.\n\
 
39
";
 
40
 
 
41
static PyObject *
 
42
crypto_X509Extension_get_short_name(crypto_X509ExtensionObj *self, PyObject *args) {
 
43
        ASN1_OBJECT *obj;
 
44
        const char *extname;
 
45
 
 
46
        if (!PyArg_ParseTuple(args, ":get_short_name")) {
 
47
                return NULL;
 
48
        }
 
49
 
 
50
        /* Returns an internal pointer to x509_extension, not a copy */
 
51
        obj = X509_EXTENSION_get_object(self->x509_extension);
 
52
 
 
53
        extname = OBJ_nid2sn(OBJ_obj2nid(obj));
 
54
        return PyString_FromString(extname);
 
55
}
 
56
 
 
57
 
33
58
/*
34
59
 * ADD_METHOD(name) expands to a correct PyMethodDef declaration
35
60
 *   {  'name', (PyCFunction)crypto_X509Extension_name, METH_VARARGS }
40
65
static PyMethodDef crypto_X509Extension_methods[] =
41
66
{
42
67
    ADD_METHOD(get_critical),
 
68
    ADD_METHOD(get_short_name),
43
69
    { NULL, NULL }
44
70
};
45
71
#undef ADD_METHOD