コード例 #1
0
/* Returns the psi.mount module */
PyMODINIT_FUNC
MODFUNC(void)
{
    PyObject *mod = NULL;

    if (prepare_types() < 0)
        RETURN(NULL);
    if (init_exceptions() < 0)
        goto error;
#ifdef PY3K
    mod = PyModule_Create(&moduledef);
#else
    mod = Py_InitModule3(MODULE_NAME, mount_methods, MODULE_DOC);
#endif
    if (mod == NULL)
        goto error;
    if (add_module_objects(mod) < 0)
        goto error;
    PyErr_WarnEx(PyExc_FutureWarning, "Experimental API", 1);
    RETURN(mod);

error:
    Py_XDECREF(mod);
    Py_XDECREF(PsiExc_AttrNotAvailableError);
    Py_XDECREF(PsiExc_AttrInsufficientPrivsError);
    Py_XDECREF(PsiExc_AttrNotImplementedError);
    Py_XDECREF(&MountBase_Type);
    Py_XDECREF(&LocalMount_Type);
    Py_XDECREF(&RemoteMount_Type);
    RETURN(NULL);
}
コード例 #2
0
int main (int argc, char **argv)
{
	if (argc > 1)
	{
		melt_path = argv [1];
	}
	else
	{
		melt_path = "melted.eif";
	}

	ifp = bfp = mfp = (FILE *) 0;

	if ((ifp = fopen (melt_path, "rb")) == (FILE *) 0)
	{
		fprintf (stderr,"Cannot open file <%s>\n", melt_path);
		panic ();
	}

	if ((mfp = fopen ("melted.txt", "wb")) == (FILE *) 0)
	{
		fprintf (stderr,"Cannot open file <%s>\n", "melted.txt");
		panic ();
	}

	prepare_types ();

	fclose (ifp);

	if ((ifp = fopen (melt_path, "rb")) == NULL) {
		fprintf (stderr, "Cannot open file <%s>\n", melt_path);
		panic ();
	}

	analyze_file ();

	fclose (ifp);
	fclose (bfp);
	fclose (mfp);

	printf ("Files \"melted.txt\" and \"bytecode.eif\" generated\n");

	return 0;
}