예제 #1
0
/* Python 2 module initialization */
PyMODINIT_FUNC
initblosc_extension(void)
{
  PyObject *m;
  m = Py_InitModule("blosc_extension", blosc_methods);
  if (m == NULL)
    return;

  BloscError = PyErr_NewException("blosc_extension.error", NULL, NULL);
  if (BloscError != NULL) {
    Py_INCREF(BloscError);
    PyModule_AddObject(m, "error", BloscError);
  }

  /* Integer macros */
  PyModule_AddIntMacro(m, BLOSC_MAX_BUFFERSIZE);
  PyModule_AddIntMacro(m, BLOSC_MAX_THREADS);
  PyModule_AddIntMacro(m, BLOSC_MAX_TYPESIZE);
  PyModule_AddIntMacro(m, BLOSC_NOSHUFFLE);
  PyModule_AddIntMacro(m, BLOSC_SHUFFLE);
  PyModule_AddIntMacro(m, BLOSC_BITSHUFFLE);

  /* String macros */
  PyModule_AddStringMacro(m, BLOSC_VERSION_STRING);
  PyModule_AddStringMacro(m, BLOSC_VERSION_DATE);

}
예제 #2
0
PyMODINIT_FUNC
PyInit_blosc_extension(void) {
  PyObject *m = PyModule_Create(&blosc_def);

  /* Integer macros */
  PyModule_AddIntMacro(m, BLOSC_MAX_BUFFERSIZE);
  PyModule_AddIntMacro(m, BLOSC_MAX_THREADS);
  PyModule_AddIntMacro(m, BLOSC_MAX_TYPESIZE);

  /* String macros */
  PyModule_AddStringMacro(m, BLOSC_VERSION_STRING);
  PyModule_AddStringMacro(m, BLOSC_VERSION_DATE);

  return m;
}
예제 #3
0
파일: htpy.c 프로젝트: 0rbytal/htpy
PyMODINIT_FUNC inithtpy(void) {
	PyObject *m;

	if (PyType_Ready(&htpy_config_type) < 0 || PyType_Ready(&htpy_connp_type) < 0)
		return;

	m = Py_InitModule3("htpy", htpy_methods, "Python interface to libhtp.");
	if (!m)
		return;

	htpy_error = PyErr_NewException("htpy.error", NULL, NULL);
	Py_INCREF(htpy_error);
	PyModule_AddObject(m, "error", htpy_error);

	htpy_stop = PyErr_NewException("htpy.stop", NULL, NULL);
	Py_INCREF(htpy_stop);
	PyModule_AddObject(m, "stop", htpy_stop);

	Py_INCREF(&htpy_config_type);
	PyModule_AddObject(m, "config", (PyObject *) &htpy_config_type);
	Py_INCREF(&htpy_connp_type);
	PyModule_AddObject(m, "connp", (PyObject *) &htpy_connp_type);

	PyModule_AddStringMacro(m, HTPY_VERSION);

	PyModule_AddIntMacro(m, HTP_ERROR);
	PyModule_AddIntMacro(m, HTP_OK);
	PyModule_AddIntMacro(m, HTP_STOP);
	PyModule_AddIntMacro(m, HTP_DATA);
	PyModule_AddIntMacro(m, HTP_DATA_OTHER);
	PyModule_AddIntMacro(m, HTP_DECLINED);

	PyModule_AddIntMacro(m, HTP_PROTOCOL_UNKNOWN);
	PyModule_AddIntMacro(m, HTP_PROTOCOL_0_9);
	PyModule_AddIntMacro(m, HTP_PROTOCOL_1_0);
	PyModule_AddIntMacro(m, HTP_PROTOCOL_1_1);

	PyModule_AddIntMacro(m, HTP_COMPRESSION_NONE);
	PyModule_AddIntMacro(m, HTP_COMPRESSION_GZIP);
	PyModule_AddIntMacro(m, HTP_COMPRESSION_DEFLATE);

	PyModule_AddIntMacro(m, HTP_LOG_ERROR);
	PyModule_AddIntMacro(m, HTP_LOG_WARNING);
	PyModule_AddIntMacro(m, HTP_LOG_NOTICE);
	PyModule_AddIntMacro(m, HTP_LOG_INFO);
	PyModule_AddIntMacro(m, HTP_LOG_DEBUG);
	PyModule_AddIntMacro(m, HTP_LOG_DEBUG2);

	PyModule_AddIntMacro(m, HTP_STREAM_NEW);
	PyModule_AddIntMacro(m, HTP_STREAM_OPEN);
	PyModule_AddIntMacro(m, HTP_STREAM_CLOSED);
	PyModule_AddIntMacro(m, HTP_STREAM_ERROR);
	PyModule_AddIntMacro(m, HTP_STREAM_TUNNEL);
	PyModule_AddIntMacro(m, HTP_STREAM_DATA_OTHER);
	PyModule_AddIntMacro(m, HTP_STREAM_DATA);
	PyModule_AddIntMacro(m, HTP_STREAM_STOP);
}
예제 #4
0
파일: libmtp.c 프로젝트: AEliu/calibre
PyMODINIT_FUNC
initlibmtp(void) {
    PyObject *m;

    DeviceType.tp_new = PyType_GenericNew;
    if (PyType_Ready(&DeviceType) < 0)
        return;
    
    m = Py_InitModule3("libmtp", libmtp_methods, "Interface to libmtp.");
    if (m == NULL) return;

    MTPError = PyErr_NewException("libmtp.MTPError", NULL, NULL);
    if (MTPError == NULL) return;
    PyModule_AddObject(m, "MTPError", MTPError);

    // Redirect stdout to get rid of the annoying message about mtpz. Really,
    // who designs a library without anyway to control/redirect the debugging
    // output, and hardcoded paths that cannot be changed? Compiling libmtp without the crypt use flag disables mtpz support in libmtp
    /* int bak, new; */
    /* fprintf(stdout, "\n"); // This is needed, without it, for some odd reason the code below causes stdout to buffer all output after it is restored, rather than using line buffering, and setlinebuf does not work. */
    /* fflush(stdout); */
    /* bak = dup(STDOUT_FILENO); */
    /* new = open("/dev/null", O_WRONLY); */
    /* dup2(new, STDOUT_FILENO); */
    /* close(new); */
    LIBMTP_Init();
    /* fflush(stdout); */
    /* dup2(bak, STDOUT_FILENO); */
    /* close(bak); */

    LIBMTP_Set_Debug(LIBMTP_DEBUG_NONE);

    Py_INCREF(&DeviceType);
    PyModule_AddObject(m, "Device", (PyObject *)&DeviceType);

    PyModule_AddStringMacro(m, LIBMTP_VERSION_STRING);
    PyModule_AddIntMacro(m, LIBMTP_DEBUG_NONE);
    PyModule_AddIntMacro(m, LIBMTP_DEBUG_PTP);
    PyModule_AddIntMacro(m, LIBMTP_DEBUG_PLST);
    PyModule_AddIntMacro(m, LIBMTP_DEBUG_USB);
    PyModule_AddIntMacro(m, LIBMTP_DEBUG_DATA);
    PyModule_AddIntMacro(m, LIBMTP_DEBUG_ALL);
}
예제 #5
0
파일: pepy.cpp 프로젝트: Arbiv/pe-parse
PyMODINIT_FUNC initpepy(void) {
	PyObject *m;

	if (PyType_Ready(&pepy_parsed_type) < 0 ||
	    PyType_Ready(&pepy_section_type) < 0 ||
	    PyType_Ready(&pepy_import_type) < 0 ||
	    PyType_Ready(&pepy_export_type) < 0 ||
	    PyType_Ready(&pepy_relocation_type) < 0 ||
	    PyType_Ready(&pepy_resource_type) < 0)
		return;

	m = Py_InitModule3("pepy", pepy_methods, "Python interface to pe-parse.");
	if (!m)
		return;

	pepy_error = PyErr_NewException((char *) "pepy.error", NULL, NULL);
	Py_INCREF(pepy_error);
	PyModule_AddObject(m, "error", pepy_error);

	Py_INCREF(&pepy_parsed_type);
	PyModule_AddObject(m, "pepy_parsed", (PyObject *) &pepy_parsed_type);

	Py_INCREF(&pepy_section_type);
	PyModule_AddObject(m, "pepy_section", (PyObject *) &pepy_section_type);

	Py_INCREF(&pepy_import_type);
	PyModule_AddObject(m, "pepy_import", (PyObject *) &pepy_import_type);

	Py_INCREF(&pepy_export_type);
	PyModule_AddObject(m, "pepy_export", (PyObject *) &pepy_export_type);

	Py_INCREF(&pepy_relocation_type);
	PyModule_AddObject(m, "pepy_relocation", (PyObject *) &pepy_relocation_type);

	Py_INCREF(&pepy_resource_type);
	PyModule_AddObject(m, "pepy_resource", (PyObject *) &pepy_resource_type);

	PyModule_AddStringMacro(m, PEPY_VERSION);

	PyModule_AddIntMacro(m, MZ_MAGIC);
	PyModule_AddIntMacro(m, NT_MAGIC);
	PyModule_AddIntMacro(m, NUM_DIR_ENTRIES);
	PyModule_AddIntMacro(m, NT_OPTIONAL_32_MAGIC);
	PyModule_AddIntMacro(m, NT_SHORT_NAME_LEN);
	PyModule_AddIntMacro(m, DIR_EXPORT);
	PyModule_AddIntMacro(m, DIR_IMPORT);
	PyModule_AddIntMacro(m, DIR_RESOURCE);
	PyModule_AddIntMacro(m, DIR_EXCEPTION);
	PyModule_AddIntMacro(m, DIR_SECURITY);
	PyModule_AddIntMacro(m, DIR_BASERELOC);
	PyModule_AddIntMacro(m, DIR_DEBUG);
	PyModule_AddIntMacro(m, DIR_ARCHITECTURE);
	PyModule_AddIntMacro(m, DIR_GLOBALPTR);
	PyModule_AddIntMacro(m, DIR_TLS);
	PyModule_AddIntMacro(m, DIR_LOAD_CONFIG);
	PyModule_AddIntMacro(m, DIR_BOUND_IMPORT);
	PyModule_AddIntMacro(m, DIR_IAT);
	PyModule_AddIntMacro(m, DIR_DELAY_IMPORT);
	PyModule_AddIntMacro(m, DIR_COM_DESCRIPTOR);

	PyModule_AddIntMacro(m, IMAGE_SCN_TYPE_NO_PAD);
	PyModule_AddIntMacro(m, IMAGE_SCN_CNT_CODE);
	PyModule_AddIntMacro(m, IMAGE_SCN_CNT_INITIALIZED_DATA);
	PyModule_AddIntMacro(m, IMAGE_SCN_CNT_UNINITIALIZED_DATA);
	PyModule_AddIntMacro(m, IMAGE_SCN_LNK_OTHER);
	PyModule_AddIntMacro(m, IMAGE_SCN_LNK_INFO);
	PyModule_AddIntMacro(m, IMAGE_SCN_LNK_REMOVE);
	PyModule_AddIntMacro(m, IMAGE_SCN_LNK_COMDAT);
	PyModule_AddIntMacro(m, IMAGE_SCN_NO_DEFER_SPEC_EXC);
	PyModule_AddIntMacro(m, IMAGE_SCN_GPREL);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_FARDATA);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_PURGEABLE);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_16BIT);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_LOCKED);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_PRELOAD);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_1BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_2BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_4BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_8BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_16BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_32BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_64BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_128BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_256BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_512BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_1024BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_2048BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_4096BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_8192BYTES);
	PyModule_AddIntMacro(m, IMAGE_SCN_ALIGN_MASK);
	PyModule_AddIntMacro(m, IMAGE_SCN_LNK_NRELOC_OVFL);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_DISCARDABLE);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_NOT_CACHED);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_NOT_PAGED);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_SHARED);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_EXECUTE);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_READ);
	PyModule_AddIntMacro(m, IMAGE_SCN_MEM_WRITE);
}