updated for fc8, dynamic linking
[sfa.git] / keyconvert / keyconvertext.c
1 #include <python2.3/Python.h>
2
3 #include "keyconvert.h"
4
5 static PyObject *keyconvert_opensshtoopenssl(PyObject *self, PyObject *args)
6 {
7     const char *fn;
8     const char *s;
9     int len;
10     FILE *fout;
11
12     PyArg_ParseTuple(args, "ss#", &fn, &s, &len);
13
14     fout = fopen(fn, "wt");
15     if (fout == NULL) {
16         return Py_BuildValue("i", 0);
17     } else {
18         fprintf(stdout, "len = %d\n", len);
19         openssh_binary_to_openssl(s, len, fout);
20         fclose(fout);
21     }
22
23     return Py_BuildValue("i", 1);
24 }
25
26 static PyMethodDef KeyConvertMethods[] = {
27     {"opensshtoopenssl", keyconvert_opensshtoopenssl, METH_VARARGS, "convert an openssh key to an openssl key"},
28     {NULL, NULL, 0, NULL}};
29
30 PyMODINIT_FUNC initkeyconvert(void)
31 {
32     (void) Py_InitModule("keyconvert", KeyConvertMethods);
33 }
34