Example #1
0
gint
accept_add_inet (ACCEPT_POOL ap, const gchar *h, const gchar *p, GError **err)
{
	struct sockaddr_storage sa;
	gint srv = -1;

	if (!ap || !p)
	{
		GSETERROR (err, "Invalid parameter");
		goto errorLabel;
	}

	if (!h || !(*h))
		h = "0.0.0.0";

	if (!resolve (&sa, h, p, err))
	{
		GSETERROR(err,"Cannot resolve [%s]:%s", h, p);
		goto errorLabel;
	}

	/*create the server socket*/
	if (-1 == (srv = socket (FAMILY(&sa), SOCK_STREAM, 0)))
	{
		GSETERROR(err,"Cannot open a %s socket (%s)", _get_family_name(FAMILY(&sa)), strerror(errno));
		goto errorLabel;
	}

	if (!sock_set_reuseaddr(srv, TRUE)) {
		GSETERROR(err,"Cannot set SO_REUSEADDR on %d [%s]:%s (%s)", srv, h, p, strerror(errno));
		goto errorLabel;
	}

	fcntl(srv, F_SETFL, O_NONBLOCK|fcntl(srv, F_GETFL));

	if (-1 == bind (srv, (struct sockaddr*)(&sa), sizeof(struct sockaddr_in)))
	{
		GSETERROR(err,"Cannot bind %d on [%s]:%s (%s)", srv, h, p, strerror(errno));
		goto errorLabel;
	}

	if (-1 == listen (srv,AP_BACKLOG))
	{
		GSETERROR(err,"Cannot listen on %d [%s]:%s (%s)", srv, h, p, strerror(errno));
		goto errorLabel;
	}

	if (!accept_add_any(ap,srv,err))
	{
		GSETERROR(err,"Cannot monitor %s srv=%d", _get_family_name(FAMILY(&sa)), srv);
		goto errorLabel;
	}

	return 1;
errorLabel:
	if (srv>=0)
		metautils_pclose(&srv);
	return 0;
}
Example #2
0
/*
	Search the builtin fonts for a match.
	Whether a given font is present or not will depend on the
	configuration in which MuPDF is built.

	name: The name of the font desired.

	bold: 1 if bold desired, 0 otherwise.

	italic: 1 if italic desired, 0 otherwise.

	len: Pointer to a place to receive the length of the discovered
	font buffer.

	Returns a pointer to the font file data, or NULL if not present.
*/
const unsigned char *
fz_lookup_builtin_font(fz_context *ctx, const char *name, int is_bold, int is_italic, int *size)
{
#ifndef TOFU_BASE14
	if (!strcmp(name, "Courier")) {
		FAMILY(urw, NimbusMonoPS_Regular_cff,
				NimbusMonoPS_Italic_cff,
				NimbusMonoPS_Bold_cff,
				NimbusMonoPS_BoldItalic_cff)
	}
	if (!strcmp(name, "Helvetica") || !strcmp(name, "Arial")) {
		FAMILY(urw, NimbusSans_Regular_cff,
				NimbusSans_Italic_cff,
				NimbusSans_Bold_cff,
				NimbusSans_BoldItalic_cff)
	}
	if (!strcmp(name, "Times") || !strcmp(name, "Times Roman") || !strcmp(name, "Times New Roman")) {
		FAMILY(urw, NimbusRoman_Regular_cff,
				NimbusRoman_Italic_cff,
				NimbusRoman_Bold_cff,
				NimbusRoman_BoldItalic_cff)
	}
	if (!strcmp(name, "Dingbats") || !strcmp(name, "Zapf Dingbats")) {
		RETURN(urw, Dingbats_cff);
	}
	if (!strcmp(name, "Symbol")) {
		RETURN(urw, StandardSymbolsPS_cff);
	}
#endif
#ifndef TOFU_SIL
	if (!strcmp(name, "Charis SIL")) {
		FAMILY(sil, CharisSIL_R_cff,
				CharisSIL_I_cff,
				CharisSIL_B_cff,
				CharisSIL_BI_cff)
	}
#endif
#ifndef TOFU_NOTO
	if (!strcmp(name, "Noto Serif")) {
		RETURN(noto, NotoSerif_Regular_otf);
	}
#endif
	return *size = 0, NULL;
}
Example #3
0
/* static */
PicFamily PicType::GetFamilyFromString(const wxString& str)
{


#define FAMILY(x)           \
    if (str == #x)          \
        return x;

	FAMILY(P18F2XXX);
    FAMILY(P18FXX2);
    FAMILY(P16F87XA);
    FAMILY(P16F62XA);
    FAMILY(P16F62X);
    FAMILY(P12F629);
    FAMILY(P12F6XX);
    FAMILY(P16F84A);
    FAMILY(P16F81X);
    FAMILY(P16F7X);
    FAMILY(P16F7X7);
    FAMILY(P16F87X);
    FAMILY(P16F72);
    FAMILY(P16F87);
    FAMILY(P16F54);
    FAMILY(P16F57);
    FAMILY(P16F785);
    FAMILY(P16F59);
    FAMILY(P16F91X);
    FAMILY(P16F88X);
    FAMILY(P16C6XX);
    FAMILY(P16C55X);
    FAMILY(P16C7XX);
    FAMILY(P16C64X);
    FAMILY(P14000);
    FAMILY(P16C50X);
    FAMILY(P17CXX);
    FAMILY(P17C7XX);
    FAMILY(P18FXX39);
    FAMILY(P18F6X2X);
    FAMILY(P18FXX80);
    FAMILY(P18F8410);
    FAMILY(P18F6XJXX);    
    FAMILY(P18F45J10);    
    FAMILY(P18F97J60);    
    FAMILY(P18F1X30);    
    FAMILY(P18FXX23);    
    FAMILY(P18FXXK20);    
    FAMILY(P24FJXXXGA0XX);    
    FAMILY(P24FJXXXGA1);    
    FAMILY(dsP30F);    
    FAMILY(dsP33F);    
    FAMILY(P24H);    
    FAMILY(P10F200);    
    FAMILY(P10F202);    
	FAMILY(P12F61X);    
	FAMILY(P16F716);
	FAMILY(P18FXX31);
	FAMILY(P18FX220);
	FAMILY(I2C_EE_1);
	FAMILY(I2C_EE_2);
	FAMILY(P12F508);
	FAMILY(P24FXXKAXXX);
	FAMILY(P18F4XK22);
	FAMILY(P18LF4XK22);
	FAMILY(P18F872X);
	FAMILY(P16F18XX);
	FAMILY(P18F6XKXX);
	FAMILY(P18F67KXX);
	FAMILY(P18F13K22);
	FAMILY(P18F14K22);
	FAMILY(P18LF13K22);
	FAMILY(P18LF14K22);
	FAMILY(dsP30F_LV);
    return UPP_INVALID_PICFAMILY;
}
Example #4
0
gint
accept_add_local (ACCEPT_POOL ap, const gchar *l, GError **err)
{
	struct working_parameter_s wrkParam;
	struct sockaddr_un sun;
	int srv = -1;
	
	if (!l || !(*l))
	{
		GSETERROR(err,"invalid parameter");
		goto errorLabel;
	}

	/*parse the URL*/
	init_socket_options_defaults( l, &wrkParam );
	parse_socket_options( &wrkParam );

	/*try to stat the file*/
	if (-1 == check_socket_is_absent( &wrkParam, err )) {
		GSETERROR(err,"A socket seems already present at [%s]", wrkParam.path.ptr);
	}

	/*open and bind the socket*/

	if (-1==(srv=socket(PF_UNIX, SOCK_STREAM, 0)))
	{
		GSETERROR(err,"Cannot open a new socket PF_UNIX : %s", strerror(errno));
		goto errorLabel;
	}
	
	if (!sock_set_reuseaddr(srv, TRUE)) {
		GSETERROR(err,"Cannot set SO_REUSEADDR on %d [%s] (%s)", srv, l, strerror(errno));
		goto errorLabel;
	}

	fcntl(srv, F_SETFL, O_NONBLOCK|fcntl(srv, F_GETFL));

	sun.sun_family = PF_LOCAL;
	strncpy(sun.sun_path, wrkParam.path.ptr, sizeof(sun.sun_path));

	if (-1==bind (srv, (struct sockaddr*) &sun, sizeof(struct sockaddr_un)))
	{
		GSETERROR(err,"cannot bind srv=%d to %s (%s)", srv, l, strerror(errno));
		goto errorLabel;
	}
	
	if (-1==listen (srv,AP_BACKLOG))
	{
		GSETERROR(err,"cannot listen to inbound connections : %s",  strerror(errno));
		goto errorLabel;
	}
	
	if (!accept_add_any(ap,srv,err))
	{
		GSETERROR(err,"Cannot monitor the local server");
		goto errorLabel;
	}

	/*change socket rights*/
	if (0 != chmod(wrkParam.path.ptr,wrkParam.mode)) {
		int errsav = errno;
		ERROR("Failed to set mode [%o] on UNIX socket [%s] : %s", wrkParam.mode, wrkParam.path.ptr, strerror(errsav));
		SRV_SEND_WARNING("server","UNIX socket might be not accessible : failed to set mode [%o] on UNIX socket [%s] (%s)",
			wrkParam.mode, wrkParam.path.ptr, strerror(errsav));
	}
	
	INFO("socket srv=%d %s now monitored", srv, _get_family_name(FAMILY(&sun)));

	return 1;
errorLabel:
	if (srv>=0)
		metautils_pclose(&srv);
	return 0;
}