Beispiel #1
0
void pike_module_init( void )
{
  STRS(data)     = make_shared_string("data");
  STRS(file)     = make_shared_string("file");
  STRS(method)   = make_shared_string("method");
  STRS(protocol) = make_shared_string("protocol");
  STRS(query)    = make_shared_string("query");
  STRS(raw_url)  = make_shared_string("raw_url");

  SVAL(data)->type     = T_STRING;
  SVAL(file)->type     = T_STRING;
  SVAL(method)->type   = T_STRING;
  SVAL(protocol)->type = T_STRING;
  SVAL(query)->type    = T_STRING;
  SVAL(raw_url)->type  = T_STRING;
  
  add_function_constant( "parse_headers", f_parse_headers,
			 "function(string:mapping)", 0);
  add_function_constant( "parse_query_string", f_parse_query_string,
			 "function(string,mapping:void)",
			 OPT_SIDE_EFFECT);
  add_function_constant( "get_address", f_get_address,
                         "function(string:string)", 0);

  start_new_program();
  ADD_STORAGE( buffer  );
  add_function( "append", f_buf_append,
		"function(string:int)", OPT_SIDE_EFFECT );
  add_function( "create", f_buf_create, "function(mapping,mapping:void)", 0 );
  set_exit_callback(free_buf_struct);
  set_init_callback(alloc_buf_struct);
  parsehttp_program = end_program();
  add_program_constant("ParseHTTP", parsehttp_program, 0);
}
Beispiel #2
0
/* Restore and exit module */
void pike_module_exit( void )
{
  free_string(STRS(data));
  free_string(STRS(file));
  free_string(STRS(method));
  free_string(STRS(protocol));
  free_string(STRS(query));
  free_string(STRS(raw_url));
  exit_nbio();
}
Beispiel #3
0
/* Restore and exit module */
void pike_module_exit( void )
{
  free_program(parsehttp_program);
  free_string(STRS(data));
  free_string(STRS(file));
  free_string(STRS(method));
  free_string(STRS(protocol));
  free_string(STRS(query));
  free_string(STRS(raw_url));
}
Beispiel #4
0
/* Initialize and start module */
void pike_module_init( void )
{
  STRS(data)     = make_shared_string("data");
  STRS(file)     = make_shared_string("file");
  STRS(method)   = make_shared_string("method");
  STRS(protocol) = make_shared_string("protocol");
  STRS(query)    = make_shared_string("query");
  STRS(raw_url)  = make_shared_string("raw_url");

  SVAL(data)->type     = T_STRING;
  SVAL(file)->type     = T_STRING;
  SVAL(method)->type   = T_STRING;
  SVAL(protocol)->type = T_STRING;
  SVAL(query)->type    = T_STRING;
  SVAL(raw_url)->type  = T_STRING;
  
  add_function_constant( "parse_headers", f_parse_headers,
                         "function(string:mapping)", 0);
  add_function_constant( "parse_query_string", f_parse_query_string,
                         "function(string,mapping:void)",
                         OPT_SIDE_EFFECT);
  add_function_constant( "parse_prestates", f_parse_prestates,
                         "function(string,multiset,multiset:string)",
                         OPT_SIDE_EFFECT);
  add_function_constant( "get_address", f_get_address,
                         "function(string:string)", 0);
  add_function_constant( "extension", f_extension,
                         "function(string:string)", 0);
  add_function_constant( "create_process", f_create_process,
                         "function(array(string),void|mapping(string:mixed):int)", 0);

  start_new_program();
  ADD_STORAGE( buffer );
  add_function( "append", f_buf_append,
                "function(string:int)", OPT_SIDE_EFFECT );
  add_function( "create", f_buf_create, "function(mapping,mapping,int|void:void)", 0 );
  set_init_callback(alloc_buf_struct);
  set_exit_callback(free_buf_struct);
  end_class("ParseHTTP", 0);
  init_nbio();
}
Beispiel #5
0
static void initW(Display *dpy, XvPortID port)
{
    char nameBuffer[BUFLEN];
    void *handle;
    int tmp;
    char *clientName = NULL;
    char *err;
    FILE *configFile;
    int nameLen = 0;
    int major,minor,patchLevel,isLocal;
    char *busID = NULL;

    wrapperInit = 1;
    xW.initialised = 0;

    if (!wrapperPreInit)
	if (preInitW( dpy )) return;

    /*
     * Will the DDX tell us the client driver name?
     */

    xW.XvMCGetDRInfo = (XvMCGetDRInfoP)
	dlsym(handle2,"XvMCGetDRInfo");

    if ((err = dlerror()) == NULL) {
	if (0 == xW.XvMCGetDRInfo( dpy, port, &clientName, &busID, &major,
				    &minor,&patchLevel, &isLocal)) {
	    nameLen = strlen(clientName);
	    XFree(busID);
	    if (!isLocal) {
		fprintf(stderr,"XvMCWrapper: X server is not local. Cannot run XvMC.\n");
		XFree(clientName);
		return;
	    }
	} else {
	    clientName = NULL;
	}
    }

    if (clientName && (nameLen < BUFLEN-7) && (nameLen > 0)) {
	nameLen += 3;
	strncpy(nameBuffer,"lib",BUFLEN-1);
	strncpy(nameBuffer+3, clientName, BUFLEN-4);
	strncpy(nameBuffer + nameLen, ".so", BUFLEN-nameLen-1);
	nameBuffer[BUFLEN-1] = 0;
	XFree(clientName);
	handle = dlopenversion(nameBuffer, XVMC_SOVERSION,RTLD_LAZY);
    } else {
	/*
	 * No. Try to obtain it from the config file.
	 */

	if (clientName) XFree(clientName);

	configFile = fopen(STRS(XVMC_CONFIGDIR) "/XvMCConfig","r");

	xW.initialised = 0;
	xW.vldextension = 0;

	if (NULL == configFile) {
	    fprintf(stderr,"XvMCWrapper: Could not open config file \"%s\".\n",
		    STRS(XVMC_CONFIGDIR) "/XvMCConfig");
	    perror("XvMCWrapper");
	    return;
	}

	if (NULL == fgets(nameBuffer, BUFLEN, configFile)) {
	    fclose(configFile);
	    fprintf(stderr,"XvMCWrapper: Could not read XvMC library name.\n");
	    perror("XvMCWrapper");
	    return;
	}

	fclose(configFile);
	if ((tmp = strlen(nameBuffer)) == 0) {
	    fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n");
	    fprintf(stderr,"%s\n",dlerror());
	    return;
	}

	/*
	 * Skip trailing newlines and garbage.
	 */

	while (iscntrl(nameBuffer[tmp-1])) {
	    nameBuffer[tmp-1] = 0;
	    if (--tmp == 0) {
		fprintf(stderr,"XvMCWrapper: Zero length XvMC library name.\n");
		return;
	    }
	}
	handle = dlopen(nameBuffer,RTLD_LAZY);
    }
    if (!handle) {
	fprintf(stderr,"XvMCWrapper: Could not load hardware specific XvMC "
		"library \"%s\".\n",nameBuffer);
	fprintf(stderr,"%s\n",dlerror());
	return;
    }

    XW_RSYM(xW, handle, handle2, XvMCListSurfaceTypes,);
    XW_RSYM(xW, handle, handle2, XvMCCreateContext,);
    XW_RSYM(xW, handle, handle2, XvMCDestroyContext,);
    XW_RSYM(xW, handle, handle2, XvMCCreateSurface,);
    XW_RSYM(xW, handle, handle2, XvMCDestroySurface,);
    XW_RSYM(xW, handle, handle2, XvMCListSubpictureTypes,);
    XW_RSYM(xW, handle, handle2, XvMCHideSurface,);
    XW_RSYM(xW, handle, handle2, XvMCCreateSubpicture,);
    XW_RSYM(xW, handle, handle2, XvMCClearSubpicture,);
    XW_RSYM(xW, handle, handle2, XvMCCompositeSubpicture,);
    XW_RSYM(xW, handle, handle2, XvMCDestroySubpicture,);
    XW_RSYM(xW, handle, handle2, XvMCSetSubpicturePalette,);
    XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture,);
    XW_RSYM(xW, handle, handle2, XvMCBlendSubpicture2,);
    XW_RSYM(xW, handle, handle2, XvMCPutSurface,);
    XW_RSYM(xW, handle, handle2, XvMCSyncSurface,);
    XW_RSYM(xW, handle, handle2, XvMCFlushSurface,);
    XW_RSYM(xW, handle, handle2, XvMCGetSurfaceStatus,);
    XW_RSYM(xW, handle, handle2, XvMCRenderSurface,);
    XW_RSYM(xW, handle, handle2, XvMCSyncSubpicture,);
    XW_RSYM(xW, handle, handle2, XvMCFlushSubpicture,);
    XW_RSYM(xW, handle, handle2, XvMCGetSubpictureStatus,);
    XW_RSYM(xW, handle, handle2, XvMCCreateBlocks,);
    XW_RSYM(xW, handle, handle2, XvMCDestroyBlocks,);
    XW_RSYM(xW, handle, handle2, XvMCCreateMacroBlocks,);
    XW_RSYM(xW, handle, handle2, XvMCDestroyMacroBlocks,);
    XW_RSYM(xW, handle, handle2, XvMCQueryAttributes,);
    XW_RSYM(xW, handle, handle2, XvMCSetAttribute,);
    XW_RSYM(xW, handle, handle2, XvMCGetAttribute,);
    xW.initialised = 1;
    XW_RSYM2(xW, handle, handle2, XvMCBeginSurface);
    XW_RSYM(xW, handle, handle2, XvMCLoadQMatrix,);
    XW_RSYM(xW, handle, handle2, XvMCPutSlice,);
    XW_RSYM(xW, handle, handle2, XvMCPutSlice2,);
    xW.vldextension = 1;
}