Exemplo n.º 1
0
Arquivo: clip.c Projeto: kai4785/LM
PDL_bool hello_world(PDL_JSParameters *params)
{
    const char *buf;
    if (PDL_GetNumJSParams(params) < 1)
    {
        buf = PDL_GetJSParamString(params, 1);
        if(buf == NULL)
        {
            PDL_JSException(params, "You must send a hellostr param");
            return PDL_TRUE;
        }
    }
    else
    {
        PDL_JSException(params, "No params sent");
        return PDL_TRUE;
    }
    
    char reply[32] = "Hello World!";
    PDL_JSReply(params, reply);

    return PDL_TRUE;
}
Exemplo n.º 2
0
PDL_bool flip_page(PDL_JSParameters *params)
{
    char *key;
    if(PDL_GetNumJSParams(params) < 1) {
             PDL_JSException(params, "Params not ok");
        return PDL_TRUE;
    }
    key = PDL_GetJSParamString(params,0); 

    pdfapp_onkey(&app,*key);
    draw_pdf();

    return PDL_TRUE;
}
Exemplo n.º 3
0
PDL_bool dateToUTCTimestamp(PDL_JSParameters *params)
{
	int numParams = PDL_GetNumJSParams(params);
	if(numParams < 4)
	{
		//problem: not enough params!
		PDL_JSException(params,"Not enough params, need TZName, Year, Month, Day, at least.");
		return PDL_TRUE;
	}

	const char* oldTZ = getenv("TZ");

	struct std::tm t;
	setenv("TZ",PDL_GetJSParamString(params,0),true);
	tzset();
	t.tm_year = PDL_GetJSParamInt(params,1)-1900;
	t.tm_mon  = PDL_GetJSParamInt(params,2); //-1 already in JS.
	t.tm_mday = PDL_GetJSParamInt(params,3);
	if(numParams >= 5)
		t.tm_hour = PDL_GetJSParamInt(params,4);
	else
		t.tm_hour = 0;
	if(numParams >= 6)
		t.tm_min = PDL_GetJSParamInt(params,5);
	else
		t.tm_min = 0;
	if(numParams >= 7)
		t.tm_sec = PDL_GetJSParamInt(params,6);
	else
		t.tm_sec = 0;

	time_t time = std::mktime(&t); //this should produce a timestamp in UTC from the set timezone!
	Funambol::LOG.debug("Converted %02d.%02d.%04d - %02d:%02d:%02d to %d in timezone %s.",t.tm_mday,t.tm_mon+1,t.tm_year+1900,t.tm_hour,t.tm_min,t.tm_sec,time,getenv("TZ"));

	std::stringstream res;
	res << time;
	PDL_JSReply(params,res.str().c_str());

	setenv("TZ",oldTZ,1);

	return PDL_TRUE;
}