Exemple #1
0
int  add_filter( size_t vhost_id, const char *lib_name, const char *fact_function )
{
  FILTER_FACTORY filter_factory;
  HTTP_FILTER *filter;

  filter_factory = (FILTER_FACTORY) load_factory( lib_name, fact_function, "load_filter" );

  filter = filter_factory();
  if (!filter) {
    fprintf(stderr,"ERROR: shared library %s, factory method %s did not create a filter\n", lib_name, fact_function );
    exit(1);
  }

  WEBBY_add_filter(  webby, vhost_id, filter );
  return 0;
}
Exemple #2
0
int add_servlet( const char *lib_name, const char *fact_function)
{
  HTTP_SERVLET *servlet;
  SERVLET_FACTORY servlet_factory;
  
  servlet_factory = (SERVLET_FACTORY) load_factory( lib_name, fact_function, "load_servlet" );

  servlet = servlet_factory();
  if (!servlet) {
    fprintf(stderr,"ERROR: shared library %s, factory method %s did not create a servlet\n", lib_name, fact_function );
    exit(1);
  }

  WEBBY_add_servlet( webby, servlet );
  return 0;
}   
Exemple #3
0
static ExpatStatus
builder_StartDocument(void *userState)
{
  ParserState *state = (ParserState *)userState;
  PyObject *uri;
  EntityObject *document;

#ifdef DEBUG_PARSER
  fprintf(stderr, "--- builder_StartDocument(%p)\n", state);
#endif
  uri = ExpatReader_GetBase(state->reader);
  if (state->entity_factory) {
    PyObject *obj = PyObject_CallFunction(state->entity_factory, "N", uri);
    if (obj) {
      if (Entity_Check(obj)) {
        /* populate the remaining factory callables */
        if (!load_factory(obj, "xml_element_factory", &DomletteElement_Type,
                          &state->element_factory))
          goto factory_error;
        if (!load_factory(obj, "xml_text_factory", &DomletteText_Type,
                          &state->text_factory))
          goto factory_error;
        if (!load_factory(obj, "xml_processing_instruction_factory",
                          &DomletteProcessingInstruction_Type,
                          &state->processing_instruction_factory))
          goto factory_error;
        if (!load_factory(obj, "xml_comment_factory", &DomletteComment_Type,
                          &state->comment_factory))
          goto factory_error;
      } else {
        PyErr_Format(PyExc_TypeError,
                     "entity_factory should return entity, not %s",
                     obj->ob_type->tp_name);
       factory_error:
        Py_DECREF(obj);
        return EXPAT_STATUS_ERROR;
      }
    }
    document = Entity(obj);
  } else {
    document = Entity_New(uri);
    Py_DECREF(uri);
  }
  if (document == NULL)
    return EXPAT_STATUS_ERROR;


  /* Callout to matcher */
  if (state->rule_matcher) {
    if (RuleMatch_StartDocument(state->rule_matcher, (PyObject *) document) < 0) {
      Py_DECREF(document);
      return EXPAT_STATUS_ERROR;
    }
  }

  if (ParserState_AddContext(state, (NodeObject *)document) == NULL) {
    Py_DECREF(document);
    return EXPAT_STATUS_ERROR;
  }
  Py_INCREF(document);
  state->owner_document = document;

  return EXPAT_STATUS_OK;
}