Пример #1
0
int cap_http::init_request_interaction(interaction* pinter,char request[],char src[],char des[],unsigned short 
	sport,unsigned short dport)
{
	if (!pinter||!request||!des)
	{
		return -1;
	}
	struct serverInfo* serinfo=pinter->get_server_info();  
	if (!serinfo)
	{
		return -1;
	}
	//char method[512]={0};
	//char resource[4096]={0};
	//char httptype[512]={0};
	string srequest(request);
	stringstream sstream(srequest);
	string smethod("");
	string sresource("");
	string shttptype("");
	sstream>>smethod>>sresource>>shttptype;
	unsigned int http_head_len=0;
	unsigned int desAddr_len=0;
	strncpy(serinfo->src,src,strlen(src));
	strncpy(serinfo->des,des,strlen(des));
	serinfo->srcPort=sport;
	serinfo->desPort=dport;
//	sscanf(request, "%s %s %s", method, resource, httptype);//分割为 GET  resource http/1.1 形式  容易溢出 改用stringstream
	strncpy(serinfo->method,smethod.c_str(),my_min(smethod.length(),METHOD_BUF_SIZE-1));
	http_head_len=strlen("http://");
	strncpy(serinfo->url,"http://",http_head_len);
	desAddr_len=strlen(serinfo->des);
	strncat(serinfo->url,serinfo->des,desAddr_len);
	strncat(serinfo->url,sresource.c_str(),my_min(sresource.length(),URL_BUF_SIZE-http_head_len-desAddr_len-1));
	strncpy(serinfo->httpType,shttptype.c_str(),my_min(shttptype.length(),HTTPTYPE_BUFF_SIZE-1));
	my_uuid_generate(serinfo->requestID,64);
	return 0;
}
Пример #2
0
    method( LTime, getHoursInAmPmFormat ),
    method( LTime, setSystemTimeToThisTime ),
    method( LTime, toString ),
    method( LTime, formatted ),
    method( LTime, getWeekdayName ),
    method( LTime, getDayOfWeek ),
    method( LTime, getMonthName ),
    method( LTime, getYear ),
    method( LTime, getMinutes ),
    method( LTime, isDaylightSavingTime ),
    method( LTime, isAfternoon ),
    {0,0}
};

const Luna<LTime>::StaticType LTime::statics[] = {
    smethod( LTime, getMillisecondCounterHiRes ),
    smethod( LTime, currentTimeMillis ),
    smethod( LTime, getWeekdayName ),
    smethod( LTime, waitForMillisecondCounter ),
    smethod( LTime, getMillisecondCounter ),
    smethod( LTime, getMonthName ),
    smethod( LTime, secondsToHighResolutionTicks ),
    smethod( LTime, highResolutionTicksToSeconds ),
    smethod( LTime, getCurrentTime ),
    smethod( LTime, getHighResolutionTicksPerSecond ),
    smethod( LTime, getHighResolutionTicks ),
    smethod( LTime, getApproximateMillisecondCounter ),
    {0,0}
};

LTime::LTime(lua_State *L)
Пример #3
0
    {0,0}
};
const Luna<LConnectionPool>::FunctionType LConnectionPool::methods[] = {
    method( LConnectionPool, isRunning ),
    method( LConnectionPool, start ),
    method( LConnectionPool, stop ),
    method( LConnectionPool, kill ),
    method( LConnectionPool, destroy ),
    method( LConnectionPool, reset ),

    method( LConnectionPool, receive ),
    {0,0}
};

const Luna<LConnectionPool>::StaticType LConnectionPool::statics[] = {
    smethod( LConnectionPool, createPool ),
    {0,0}
};

LConnectionPool::LConnectionPool(lua_State * L_)
    : LBase(L_, "LConnectionPool", true),
      Thread("LConnectionPool")
{
    L=L_;
}

LConnectionPool::~LConnectionPool() {
}

struct LURLThread : public Thread {
    LURLThread(Results *_results, const URL *_url, int ms = 60000, String name = String("LURLThread")):
Пример #4
0
		FUNCTION PRIVATE DEFINITION static int answer_to_connection
			(
				void *cls, 
				struct MHD_Connection * connection, 
				const char *url, 
				const char *method,
				const char *version, 
				const char *upload_data, 
				size_t *upload_data_size, 
				void **con_cls
			)
		{
			#ifdef DEBUG
				std::printf("%s %s %s\n", version, method, url);
			#endif        
			Str_t smethod(method);    
			if (*con_cls == NULL)
			{
				Connection_info_struct_t* con_info = new (VAR2STR(Connection_info_struct_t)) Connection_info_struct_t;        
				if (con_info == NULL) return MHD_NO;
				con_info->answerstring.clear();

				if (smethod.compare(txPOST) == 0)
				{
					con_info->postprocessor = MHD_create_post_processor(connection, POST_BUFFER_SIZE, iterate_post, (void *) con_info);
					if (con_info->postprocessor == NULL)
					{
						#ifdef DEBUG                    
							std::printf("[ERROR-LOG][deploy::answer_to_connection] POST Request not datas to process.\n");
						#endif                    
						delete con_info;
						return MHD_NO;
					}
					con_info->connectiontype = POST;
				}
				else if (smethod.compare(txGET) == 0)	
				{
					con_info->connectiontype = GET;			
				}

				*con_cls = (void *) con_info;

				return MHD_YES;
			}

			if (smethod.compare(txGET) == 0)
			{
				Str_t page, mimetype;
				page_dispatcher(Str_t(url), page, mimetype);
				return send_page (connection, page, mimetype);
			}

			if (smethod.compare(txPOST) == 0)
			{
				Connection_info_struct_t* con_info = reinterpret_cast<Connection_info_struct_t*>(*con_cls);

				if (*upload_data_size != 0)
				{
					MHD_post_process (con_info->postprocessor, upload_data, *upload_data_size);
					*upload_data_size = 0;
		            
					return MHD_YES;
				}
				else if (!con_info->post_key_value.empty())
				{     				
					
				}
			}
			Str_t page, mimetype;
			deployapp::page_dispatcher("", page, mimetype);
			return send_page (connection, page, mimetype); 	
		}    
Пример #5
0
    method( LLookAndFeel, drawMenuBarBackground ),
    method( LLookAndFeel, drawConcertinaPanelHeader ),
    method( LLookAndFeel, drawPopupMenuBackground ),
    method( LLookAndFeel, drawTextEditorOutline ),
    method( LLookAndFeel, drawComboBox ),
    method( LLookAndFeel, drawLinearSliderBackground ),
    method( LLookAndFeel, drawKeymapChangeButton ),
    method( LLookAndFeel, drawScrollbar ),
    method( LLookAndFeel, drawTabAreaBehindFrontButton ),
    method( LLookAndFeel, drawButtonBackground ),
    method( LLookAndFeel, drawTableHeaderBackground ),
    {0,0}
};

const Luna<LLookAndFeel>::StaticType LLookAndFeel::statics[] = {
    smethod( LLookAndFeel, createTabTextLayout ),
    {0,0}
};

LLookAndFeel::LLookAndFeel(lua_State *L)
    : LBase(L, "LLookAndFeel", true),
      LookAndFeel_V3()
{
}

LLookAndFeel::~LLookAndFeel() {}

static void createTabTextLayout (const TabBarButton& button, float length, 
                                                        float depth, Colour colour, TextLayout& tl)
{
    // ???
Пример #6
0
    {0,0}
};
const Luna<LOpenGLShaderProgram>::FunctionType LOpenGLShaderProgram::methods[] = {
    method( LOpenGLShaderProgram, link ),
    method( LOpenGLShaderProgram, addFragmentShader ),
    method( LOpenGLShaderProgram, getLastError ),
    method( LOpenGLShaderProgram, getProgramID ),
    method( LOpenGLShaderProgram, addVertexShader ),
    method( LOpenGLShaderProgram, addShader ),
    method( LOpenGLShaderProgram, release ),
    method( LOpenGLShaderProgram, use ),
    {0,0}
};

const Luna<LOpenGLShaderProgram>::StaticType LOpenGLShaderProgram::statics[] = {
    smethod( LOpenGLShaderProgram, getLanguageVersion ),
    {0,0}
};

LOpenGLShaderProgram::LOpenGLShaderProgram(lua_State *L)
    : LBase(L, "LOpenGLShaderProgram", true),
      OpenGLShaderProgram( OpenGLContext() )
{
    // INVALID
}

LOpenGLShaderProgram::LOpenGLShaderProgram(lua_State *L, const OpenGLContext& context)
    : LBase(L, "LOpenGLShaderProgram", true),
      OpenGLShaderProgram( context )
{
}