/**
 * Close a dest file
 * @param df the dest file to close
 * @param tlen the length of the underling text 
 * @return 1 if successful else 0
 */
int dest_file_close( dest_file *df, int tlen )
{
    int res = 1;
    if ( df->kind == markup_kind )  
    {
        if ( df->l != NULL )
            res = compute_range_lengths( df, tlen );
#ifdef JNI        
        tmplog("compute_range_lengths returned %d\n",res);
#endif
        if ( res )
            res = dest_file_dequeue(df);
#ifdef JNI        
        tmplog("dest_file_dequeue returned %d\n",res);
#endif
        // write tail
        if ( res )
            res = df->f->tfunc(NULL, dest_file_dst(df) );
#ifdef JNI        
        tmplog("df->f->tfunc returned %d\n",res);
#endif
    }
#ifndef JNI
    if ( df->dst != NULL )
        fclose( df->dst );
#endif
    return res;
}
static int add_layer( JNIEnv *env, jobject obj, char *value )
{
    int res = 0;
    jstring jstr;
    jstr = (*env)->NewStringUTF( env, value );
    if (jstr != NULL) 
    {
        jclass cls = (*env)->GetObjectClass( env, obj );
        jmethodID mid = (*env)->GetMethodID( env, cls,"addLayer",
            "(Ljava/lang/String;)V");
        if ( mid == 0 )
        {
            tmplog("stripper: failed to find method addLayer\n");
            res = 0;
        }
        else
        {
            (*env)->ExceptionClear( env );
            (*env)->CallVoidMethod( env, obj, mid, jstr);
            if((*env)->ExceptionOccurred(env)) 
            {
                fprintf(stderr,"stripper: couldn't add layer\n");
                (*env)->ExceptionDescribe( env );
                (*env)->ExceptionClear( env );
            }
            else
                res = 1;
        }
    }
    return res;
}
void construct::done_trunk_plank(game *g, point p)
{
    int num_logs = rng(5, 15);
    for( int i = 0; i < num_logs; ++i ) {
        item tmplog(g->itypes["log"], int(g->turn), g->nextinv);
        iuse::cut_log_into_planks( g, &(g->u), &tmplog);
    }
}
Exemple #4
0
void construct::done_trunk_plank(point p)
{
    (void)p; //unused
    int num_logs = rng(5, 15);
    for( int i = 0; i < num_logs; ++i ) {
        item tmplog(itypes["log"], int(g->turn), g->nextinv);
        iuse::cut_log_into_planks( &(g->u), &tmplog);
    }
}
Exemple #5
0
void add_notify(const char *dirname, uint32_t mask)
{
	if (notify_fd < 0)
	{
		notify_fd = inotify_init1(IN_NONBLOCK);
		pfd[1].fd = notify_fd;
		pfd[1].events = POLLIN;
	}

	inotify_add_watch(notify_fd, dirname, mask);
	tmplog("Watching '%s'\n", dirname);
}
Exemple #6
0
void handle_notify(void)
{
	char ibuf[256]; /* XXX */
	int i = 0;
	int len = read(notify_fd, ibuf, sizeof(ibuf));

	while (i < len)
	{
		struct inotify_event *ie = (struct inotify_event *)&ibuf[i];
		i += sizeof(struct inotify_event) + ie->len;

		if (!ie->len)
			continue;

		tmplog("'%s': %s", ie->name, ie->mask & IN_ISDIR ? "dir" : "file");

		if (ie->mask & IN_Q_OVERFLOW)
			tmplog(", Q_OVERFLOW");
		if (ie->mask & IN_UNMOUNT)
			tmplog(", UNMOUNT");
		if (ie->mask & IN_IGNORED)
			tmplog(", IGNORED");
		if (ie->mask & IN_ACCESS)
			tmplog(", ACCESS");
		if (ie->mask & IN_ATTRIB)
			tmplog(", ATTRIB");
		if (ie->mask & IN_CLOSE_WRITE)
			tmplog(", CLOSE_WRITE");
		if (ie->mask & IN_CLOSE_NOWRITE)
			tmplog(", CLOSE_NOWRITE");
		if (ie->mask & IN_CREATE)
			tmplog(", CREATE");
		if (ie->mask & IN_DELETE)
			tmplog(", DELETE");
		if (ie->mask & IN_DELETE_SELF)
			tmplog(", DELETE_SELF");
		if (ie->mask & IN_MODIFY)
			tmplog(", MODIFY");
		if (ie->mask & IN_MOVE_SELF)
			tmplog(", MOVE_SELF");
		if (ie->mask & IN_MOVED_FROM)
			tmplog(", MOVED_FROM (cookie=%d)", ie->cookie);
		if (ie->mask & IN_MOVED_TO)
			tmplog(", MOVED_TO (cookie=%d)", ie->cookie);
		if (ie->mask & IN_OPEN)
			tmplog(", OPEN");
		tmplog("\n");
	}
}
Exemple #7
0
/*
 * Class:     calliope_AeseStripper
 * Method:    strip
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLcalliope/json/JSONResponse;Lcalliope/json/JSONResponse;)I
 */
JNIEXPORT jint JNICALL Java_calliope_AeseStripper_strip
  (JNIEnv *env, jobject obj, jstring xml, jstring rules, jstring format, jstring style, jstring language, jstring hexcepts, jboolean html, jobject text, jobject markup)
{
	int res = 1;
    jboolean x_copied,r_copied=JNI_FALSE,f_copied,s_copied,h_copied,l_copied=JNI_FALSE;
    const char *x_str = load_string( env, xml, &x_copied );
    //fprintf(stderr,"x_str=%s r_str\n",x_str);
    const char *r_str = (rules!=NULL)?load_string(env,rules,&r_copied):NULL;
    //fprintf(stderr,"r_str=%s\n",r_str);
    const char *f_str = load_string( env, format, &f_copied );
    //fprintf(stderr,"f_str=%s\n",f_str);
    const char *s_str = load_string( env, style, &s_copied );
    //fprintf(stderr,"s_str=%s\n",s_str);
    const char *l_str = (language==NULL)?"en_GB"
        :load_string( env, language, &l_copied );
    //fprintf(stderr,"l_str=%s\n",l_str);
    const char *h_str = (hexcepts==NULL)?NULL
        :load_string( env, hexcepts, &h_copied );
    //fprintf(stderr,"h_str=%s\n",h_str);
    stripper *s = stripper_create();
    if ( s != NULL )
    {
        recipe *ruleset;
        s->hh_except_string = (h_str==NULL)?NULL:strdup(h_str);
        s->selected_format = lookup_format( f_str );
        // load or initialise rule set
        if ( rules == NULL )
            ruleset = recipe_new();
        else
            ruleset = recipe_load(r_str,strlen(r_str));
        hh_exceptions *hhe = hh_exceptions_create( s->hh_except_string );
        if ( hhe != NULL )
        {
            s->user_data = userdata_create( s->language, s->barefile, 
                ruleset, &formats[s->selected_format], hhe );
            if ( s->user_data != NULL )
            {
                // write header
                int i=0;
                while ( res && userdata_markup_dest(s->user_data,i)!= NULL )
                {
                    res = formats[s->selected_format].hfunc( NULL, 
                        dest_file_dst(
                            userdata_markup_dest(s->user_data,i)), s_str );
                    i++;
                }
                // parse XML
                if ( res )
                {
                    int xlen = strlen( x_str );
                    res = scan_source( x_str, xlen, s );
                    if ( res )
                        userdata_write_files( env, s->user_data, text, markup );
                }
                else
                    tmplog("write header failed\n");
            }
        }
        stripper_dispose( s );
        unload_string( env, xml, x_str, x_copied );
        unload_string( env, rules, r_str, r_copied );
        unload_string( env, format, f_str, f_copied );
        unload_string( env, style, s_str, s_copied );
        unload_string( env, language, l_str, l_copied );
        if ( h_str != NULL )
            unload_string( env, hexcepts, h_str, h_copied );
    }
    return res;
}
	void COpenGLExtensionHandler::dumpFramebufferFormats() const
	{
#if  (SAPPHIRE_PLATFORM == SAPPHIRE_PLATFORM_WIN32)
		HDC hdc = wglGetCurrentDC();
		String wglExtensions;
#ifdef WGL_ARB_extensions_string
		PFNWGLGETEXTENSIONSSTRINGARBPROC sapphireGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
		if (sapphireGetExtensionsString)
			wglExtensions = sapphireGetExtensionsString(hdc);
#elif defined(WGL_EXT_extensions_string)
		PFNWGLGETEXTENSIONSSTRINGEXTPROC sapphireGetExtensionsString = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT");
		if (sapphireGetExtensionsString)
			wglExtensions = sapphireGetExtensionsString(hdc);
#endif
		const bool pixel_format_supported = (wglExtensions.find("WGL_ARB_pixel_format") != -1);
		const bool multi_sample_supported = ((wglExtensions.find("WGL_ARB_multisample") != -1) ||
			(wglExtensions.find("WGL_EXT_multisample") != -1) || (wglExtensions.find("WGL_3DFX_multisample") != -1));
#ifdef _DEBUG
		Printer::log("WGL_extensions", wglExtensions);
#endif

#ifdef WGL_ARB_pixel_format
		PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat_ARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
		if (pixel_format_supported && wglChoosePixelFormat_ARB)
		{
			// This value determines the number of samples used for antialiasing
			// My experience is that 8 does not show a big
			// improvement over 4, but 4 shows a big improvement
			// over 2.

			PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribiv_ARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB");
			if (wglGetPixelFormatAttribiv_ARB)
			{
				int vals[128];
				int atts[] = {
					WGL_NUMBER_PIXEL_FORMATS_ARB,
					WGL_DRAW_TO_BITMAP_ARB,
					WGL_ACCELERATION_ARB,
					WGL_NEED_PALETTE_ARB,
					WGL_NEED_SYSTEM_PALETTE_ARB,
					WGL_SWAP_LAYER_BUFFERS_ARB,
					WGL_SWAP_METHOD_ARB,
					WGL_NUMBER_OVERLAYS_ARB,
					WGL_NUMBER_UNDERLAYS_ARB,
					WGL_TRANSPARENT_ARB,
					WGL_TRANSPARENT_RED_VALUE_ARB,
					WGL_TRANSPARENT_GREEN_VALUE_ARB,
					WGL_TRANSPARENT_BLUE_VALUE_ARB,
					WGL_TRANSPARENT_ALPHA_VALUE_ARB,
					WGL_TRANSPARENT_INDEX_VALUE_ARB,
					WGL_SHARE_DEPTH_ARB,
					WGL_SHARE_STENCIL_ARB,
					WGL_SHARE_ACCUM_ARB,
					WGL_SUPPORT_GDI_ARB,
					WGL_SUPPORT_OPENGL_ARB,
					WGL_DOUBLE_BUFFER_ARB,
					WGL_STEREO_ARB,
					WGL_PIXEL_TYPE_ARB,
					WGL_COLOR_BITS_ARB,
					WGL_RED_BITS_ARB,
					WGL_RED_SHIFT_ARB,
					WGL_GREEN_BITS_ARB,
					WGL_GREEN_SHIFT_ARB,
					WGL_BLUE_BITS_ARB,
					WGL_BLUE_SHIFT_ARB,
					WGL_ALPHA_BITS_ARB,
					WGL_ALPHA_SHIFT_ARB,
					WGL_ACCUM_BITS_ARB,
					WGL_ACCUM_RED_BITS_ARB,
					WGL_ACCUM_GREEN_BITS_ARB,
					WGL_ACCUM_BLUE_BITS_ARB,
					WGL_ACCUM_ALPHA_BITS_ARB,
					WGL_DEPTH_BITS_ARB,
					WGL_STENCIL_BITS_ARB,
					WGL_AUX_BUFFERS_ARB
#ifdef WGL_ARB_render_texture
					, WGL_BIND_TO_TEXTURE_RGB_ARB //40
					, WGL_BIND_TO_TEXTURE_RGBA_ARB
#endif
#ifdef WGL_ARB_pbuffer
					, WGL_DRAW_TO_PBUFFER_ARB //42
					, WGL_MAX_PBUFFER_PIXELS_ARB
					, WGL_MAX_PBUFFER_WIDTH_ARB
					, WGL_MAX_PBUFFER_HEIGHT_ARB
#endif
#ifdef WGL_ARB_framebuffer_sRGB
					, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB //46
#endif
#ifdef WGL_ARB_multisample
					, WGL_SAMPLES_ARB //47
					, WGL_SAMPLE_BUFFERS_ARB
#endif
#ifdef WGL_EXT_depth_float
					, WGL_DEPTH_FLOAT_EXT //49
#endif
					, 0, 0, 0, 0
				};
				size_t nums = sizeof(atts) / sizeof(int);
				const bool depth_float_supported = (wglExtensions.find("WGL_EXT_depth_float") != -1);
				if (!depth_float_supported)
				{
					memmove(&atts[49], &atts[50], (nums - 50)*sizeof(int));
					nums -= 1;
				}
				if (!multi_sample_supported)
				{
					memmove(&atts[47], &atts[49], (nums - 49)*sizeof(int));
					nums -= 2;
				}
				const bool framebuffer_sRGB_supported = (wglExtensions.find("WGL_ARB_framebuffer_sRGB") != -1);
				if (!framebuffer_sRGB_supported)
				{
					memmove(&atts[46], &atts[47], (nums - 47)*sizeof(int));
					nums -= 1;
				}
				const bool pbuffer_supported = (wglExtensions.find("WGL_ARB_pbuffer") != -1);
				if (!pbuffer_supported)
				{
					memmove(&atts[42], &atts[46], (nums - 46)*sizeof(int));
					nums -= 4;
				}
				const bool render_texture_supported = (wglExtensions.find("WGL_ARB_render_texture") != -1);
				if (!render_texture_supported)
				{
					memmove(&atts[40], &atts[42], (nums - 42)*sizeof(int));
					nums -= 2;
				}
				wglGetPixelFormatAttribiv_ARB(hdc, 0, 0, 1, atts, vals);
				const int count = vals[0];
				atts[0] = WGL_DRAW_TO_WINDOW_ARB;
				for (int i = 1; i<count; ++i)
				{
					memset(vals, 0, sizeof(vals));
#define tmplog(x,y) Printer::log(x, StringUtil::toString(y).c_str())
					const BOOL res = wglGetPixelFormatAttribiv_ARB(hdc, i, 0, nums, atts, vals);
					if (FALSE == res)
						continue;
					tmplog("Pixel format ", i);
					UINT32 j = 0;
					tmplog("Draw to window ", vals[j]);
					tmplog("Draw to bitmap ", vals[++j]);
					++j;
					tmplog("Acceleration ", (vals[j] == WGL_NO_ACCELERATION_ARB ? "No" :
						vals[j] == WGL_GENERIC_ACCELERATION_ARB ? "Generic" : vals[j] == WGL_FULL_ACCELERATION_ARB ? "Full" : "ERROR"));
					tmplog("Need palette ", vals[++j]);
					tmplog("Need system palette ", vals[++j]);
					tmplog("Swap layer buffers ", vals[++j]);
					++j;
					tmplog("Swap method ", (vals[j] == WGL_SWAP_EXCHANGE_ARB ? "Exchange" :
						vals[j] == WGL_SWAP_COPY_ARB ? "Copy" : vals[j] == WGL_SWAP_UNDEFINED_ARB ? "Undefined" : "ERROR"));
					tmplog("Number of overlays ", vals[++j]);
					tmplog("Number of underlays ", vals[++j]);
					tmplog("Transparent ", vals[++j]);
					tmplog("Transparent red value ", vals[++j]);
					tmplog("Transparent green value ", vals[++j]);
					tmplog("Transparent blue value ", vals[++j]);
					tmplog("Transparent alpha value ", vals[++j]);
					tmplog("Transparent index value ", vals[++j]);
					tmplog("Share depth ", vals[++j]);
					tmplog("Share stencil ", vals[++j]);
					tmplog("Share accum ", vals[++j]);
					tmplog("Support GDI ", vals[++j]);
					tmplog("Support OpenGL ", vals[++j]);
					tmplog("Double Buffer ", vals[++j]);
					tmplog("Stereo Buffer ", vals[++j]);
					tmplog("Pixel type ", vals[++j]);
					tmplog("Color bits", vals[++j]);
					tmplog("Red bits ", vals[++j]);
					tmplog("Red shift ", vals[++j]);
					tmplog("Green bits ", vals[++j]);
					tmplog("Green shift ", vals[++j]);
					tmplog("Blue bits ", vals[++j]);
					tmplog("Blue shift ", vals[++j]);
					tmplog("Alpha bits ", vals[++j]);
					tmplog("Alpha Shift ", vals[++j]);
					tmplog("Accum bits ", vals[++j]);
					tmplog("Accum red bits ", vals[++j]);
					tmplog("Accum green bits ", vals[++j]);
					tmplog("Accum blue bits ", vals[++j]);
					tmplog("Accum alpha bits ", vals[++j]);
					tmplog("Depth bits ", vals[++j]);
					tmplog("Stencil bits ", vals[++j]);
					tmplog("Aux buffers ", vals[++j]);
					if (render_texture_supported)
					{
						tmplog("Bind to texture RGB", vals[++j]);
						tmplog("Bind to texture RGBA", vals[++j]);
					}
					if (pbuffer_supported)
					{
						tmplog("Draw to pbuffer", vals[++j]);
						tmplog("Max pbuffer pixels ", vals[++j]);
						tmplog("Max pbuffer width", vals[++j]);
						tmplog("Max pbuffer height", vals[++j]);
					}
					if (framebuffer_sRGB_supported)
						tmplog("Framebuffer sRBG capable", vals[++j]);
					if (multi_sample_supported)
					{
						tmplog("Samples ", vals[++j]);
						tmplog("Sample buffers ", vals[++j]);
					}
					if (depth_float_supported)
						tmplog("Depth float", vals[++j]);
#undef tmplog
				}
			}
		}
#endif
#elif defined(SAPPHIRE_LINUX_DEVICE)
#endif
	}