int cgi_page_sum(ExHttp *pHttp) { const char *lAdd, *rAdd; int sum; char buf[32]; printf("\n--add.cgi--\n"); print_param(pHttp); lAdd = get_param_info(pHttp, "lAdd"); rAdd = get_param_info(pHttp, "rAdd"); sum = atoi(lAdd) + atoi(rAdd); sprintf(buf, "%d", sum); ex_send_msg(pHttp, NULL, buf, strlen(buf)); return 0; }
int cgi_page_login(ExHttp *pHttp) { const char *smsg = "login success" ; const char *emsg = "login error" ; static const char *user = "******" ; static const char *passwd = "passwd" ; const char *pRet = emsg ; const char *pUser, *pPasswd ; printf( "\n--login.cgi--\n" ) ; print_param( pHttp ) ; pUser = get_param_info( pHttp, "user" ) ; pPasswd = get_param_info( pHttp, "passwd" ) ; if ( strcmp( user, pUser )==0&&strcmp( passwd, pPasswd )==0 ) { pRet = smsg ; } ex_send_msg( pHttp, NULL, pRet, strlen( pRet ) ) ; return 0 ; }
int cgi_page_login(ExHttp *pHttp) { const char *smsg = "login success"; const char *emsg = "login error"; const char *gss = "get session success"; const char *ss = "send session"; //static const char *user = "******"; //static const char *passwd = "passwd"; const char *pRet = emsg; const char *pUser , *pPasswd, *pSession; printf("\n--login.cgi--\n"); print_param(pHttp); pSession = sessionFromHeader(get_head_info(pHttp, "Cookie")); pUser = get_param_info(pHttp, "user"); pPasswd = get_param_info(pHttp, "passwd"); /* if (strcmp(user, pUser) == 0 && strcmp(passwd, pPasswd) == 0) { pRet = smsg; } */ //ex_send_msg(pHttp, NULL, pRet, strlen(pRet)); void *data = sessionCheck(pSession); if(data != NULL){ ex_send_msg(pHttp, NULL, (char*)data, strlen((char*)data)); } else{ char *session_id = sessionCreate(pUser, "something"); pRet = ss; ex_send_msg_session(pHttp, NULL, pRet, strlen(pRet), session_id); } return 0; }
void VideoScript::pre_judge() throw (Exception) { const ScriptParam* inparam = get_param_info("in"); const ScriptParam* outparam = get_param_info("out"); const ScriptParam* resparam = get_param_info("resource"); if ( !inparam || inparam->param_style != ScriptParams::PosParam || !outparam || outparam->param_style != ScriptParams::PosParam) { throw_error_v(ErrorScriptArgInvalid, "in/out position param is required for %s script", Vm::proc_type_names[VIDEO_RESOURCE_SCRIPT]); } if ( !resparam || resparam->param_style != ScriptParams::ScalarParam ) { throw_error_v(ErrorScriptArgInvalid, "resource scalar param is required for %s script", Vm::proc_type_names[VIDEO_RESOURCE_SCRIPT]); } json_t* res_arg = get_arg_value("resource"); json_t* in = get_arg_value("in"); json_t* out = get_arg_value("out"); if (!res_arg || !json_is_string(res_arg) || !strlen(json_string_value(res_arg))) { throw_error_v(ErrorScriptArgInvalid, "resource arg is required for %s script", Vm::proc_type_names[VIDEO_RESOURCE_SCRIPT]); } if ( !in || !json_is_integer(in) ) { throw_error_v(ErrorScriptArgInvalid, "in arg is required for %s script", Vm::proc_type_names[VIDEO_RESOURCE_SCRIPT]); } if ( !out || !json_is_integer(out) ) { throw_error_v(ErrorScriptArgInvalid, "out arg is required for %s script", Vm::proc_type_names[VIDEO_RESOURCE_SCRIPT]); } string path(json_string_value(res_arg)); mlt_profile profile = mlt_profile_clone(MltLoader::global_profile); mlt_producer prod = mlt_factory_producer(profile, "loader", path.c_str()); if ( prod == NULL ) { throw_error_v(ErrorScriptArgInvalid, "out arg is required for %s script", Vm::proc_type_names[VIDEO_RESOURCE_SCRIPT]); } uuid = Vm::uuid(); MltLoader::push_mlt_registry(mlt_producer_service(prod), uuid.c_str()); //mlt_producer prod = Vm::get_stream_resource(path); int length = mlt_producer_get_length(prod); int inframe = json_integer_value(in), outframe = json_integer_value(out); json_decref(in); json_decref(out); switch (inparam->pos_type) { case ScriptParams::FramePos: if ( inframe == -1 || inframe >= length) { inframe = length - 1; } else if ( inframe < 0 ) { inframe = length + inframe; if (inframe < 0)inframe = 0; } break; case ScriptParams::TimePos: { int total_time = length * 40; if ( inframe == -1 ) { inframe = length - 1; } else if ( inframe >= 0 ) { if ( inframe > total_time) { inframe = length -1; } else { inframe = (double)inframe / 40 ; } } else { inframe = total_time + inframe; if ( inframe < 0 ) { inframe = length - 1; } else { inframe = (double)inframe/40; } } } break; } switch (outparam->pos_type) { case ScriptParams::FramePos: if ( outframe == -1 || outframe >= length) { outframe = length - 1; } else if ( outframe < 0 ) { outframe = length + outframe; if (outframe < 0)outframe = 0; } break; case ScriptParams::TimePos: { int total_time = length * 40; if ( outframe == -1 ) { outframe = length - 1; } else if ( outframe >= 0 ) { if ( outframe > total_time) { outframe = length -1; } else { outframe = (double)outframe / 40 ; } } else { outframe = total_time + outframe; if ( outframe < 0 ) { outframe = length - 1; } else { outframe = (double)outframe/40; } } } break; } if ( inframe > outframe ) { inframe ^= outframe ^= inframe ^= outframe; } set_frame_range(inframe,outframe); if ( !type_spec_props.get() ) { type_spec_props.reset(new ScriptProps(*this, NULL)); } type_spec_props->add_property("resource", res_arg); json_decref(res_arg); type_spec_props->add_property("uuid", JsonWrap(json_string(uuid.c_str()),1).h); if ( !mlt_props.get()) { mlt_props.reset(new ScriptProps(*this, NULL)); } json_t* jv = json_integer(inframe); mlt_props->add_property("in", jv); json_decref(jv); jv = json_integer(outframe); mlt_props->add_property("out", jv); json_decref(jv); //mlt_producer_set_in_and_out(prod, inframe, outframe); #ifdef DEBUG std::cout << mlt_producer_properties(prod); #endif this->path = path; //todo: check format info return; }