JNIEXPORT jint JNICALL Java_com_baidu_video_download_JNIP2P_netStatReport( JNIEnv* env, jobject obj, jstring strProduct, jstring strVersion, jstring strSubstat, jstring strChannel, jstring strBody) { char* szProduct = (char*)env->GetStringUTFChars(strProduct, false); char* szVersion = (char*)env->GetStringUTFChars(strVersion, false); char* szSubstat = (char*)env->GetStringUTFChars(strSubstat, false); char* szChannel = (char*)env->GetStringUTFChars(strChannel, false); if(szProduct==NULL || szVersion==NULL || szSubstat==NULL || szChannel==NULL) return ERROR_PARAM; char* szBody = (char*)env->GetStringUTFChars(strBody, false); std::string strTemp = szBody; std::vector<std::string> vecOut; SplitParams(strTemp, ",", vecOut); if(vecOut.size()==0) return ERROR_PARAM; CP2PStatReport rp(szProduct, szVersion, szChannel, szSubstat); for(size_t i=0; i<vecOut.size(); i++) { std::vector<std::string> vecItem; SplitParams(vecOut[i], "=", vecItem); if(vecItem.size()!=2) return ERROR_PARAM; if(is_all_num(vecItem[0])) { uint64_t nKey = _atoi64(vecItem[0].c_str()); if(is_all_num(vecItem[1])) { rp.StatAdd(nKey, _atoi64(vecItem[1].c_str())); } else { rp.StatAdd(nKey, (unsigned char*)vecItem[1].c_str(), vecItem[1].length()); } } else { continue; } } return ERROR_SUCCESS; }
int joined_chan(char* params, irc_reply_data* hostd, void* conn) { IRC* irc=(IRC*)conn; char *a[1]; SplitParams(a,params,2); if (a[0] && a[1]) { } return 0; }
int got_kicked(char* params, irc_reply_data* hostd, void* conn) { IRC* irc=(IRC*)conn; if (strstr(params,irc->current_nick())) { char *a[2]; SplitParams(a,params,2); if (a[0] && a[1]) { if (!strcmp(a[0],Decode(sinfo[curserver].chan))) irc->join(Decode(sinfo[curserver].chan), Decode(sinfo[curserver].chanpass)); else irc->join(a[0]); irc->pmsg(a[0],str_kick_msg,hostd->nick); } } return 0; }
IResultPtr PerforceDepotView::RunCommand(std::string& command, const std::string& input) { auto params = SplitParams(command); if (params.size() > 0) { P4ClientUser ui; impl_->clientApi_->SetVar("enableStreams"); if (params.size() > 1) impl_->clientApi_->SetArgv(static_cast<int>(params.size()) - 1, ¶ms[1]); else impl_->clientApi_->SetArgv(0, nullptr); if (!input.empty()) ui.SetInput(input.c_str()); impl_->clientApi_->Run(params[0], &ui); return ui.result(); } return IResultPtr(new PerforceResult("", "Invalid Command")); }
int private_msg(char* params, irc_reply_data* hostd, void* conn) { IRC* irc=(IRC*)conn; char *a[MAX_TOKENS]; params++; char fcmd[1024]; strcpy(fcmd,params); int t=SplitParams(a,params,MAX_TOKENS); if (fcmd[0] == prefix) { SWITCHES switches=GetSwitches(a,t); for (int u=0;u<MAX_TOKENS;u++) { if (a[u]) { //lulwhat() -h1t3m- } } if (!a[0]) return 1; if (a[0][0] == prefix) { a[0]++; if (irc->is_logged_in(hostd->nick,hostd->ident,hostd->host)) { if (!strcmp(hostd->target,irc->current_nick())) hostd->target=hostd->nick; IRC_CommandParse(a,t,fcmd,hostd,irc,switches); } else { if (!strcmp(hostd->target,irc->current_nick())) { hostd->target=hostd->nick; } if (!strcmp(a[0],get_auth)) { if (a[1]==NULL) return 1; char h[256]; _snprintf(h,sizeof(h),"%s!%s@%s",hostd->nick,hostd->ident,hostd->host); BOOL host_ok=FALSE; for (int i=0; i < authsize; i++) { #ifndef NO_WILDCARD if (wildcardfit(authost[i], h)) { host_ok = TRUE; break; } #else if (strcmp(h, authost[i]) == 0) { host_ok = TRUE; break; } #endif } if (!host_ok || strcmp(Decode(password), a[1]) != 0) { return 1; } if (irc->add_login(hostd->nick,hostd->ident,hostd->host) == -1) { if (!switches.silent) irc->pmsg(hostd->target,str_auth_full,main_title); } else { if (!switches.silent) irc->pmsg(hostd->target,str_auth_good,main_title); } return 1; } } } } else { if (lstrcmpi(hostd->target,irc->current_nick())) return 1; if (!lstrcmpi("\1VERSION\1",a[0])) { return 1; } if (!lstrcmpi("\1PING",a[0]) && a[1]) { return 1; } } return 0; }
int parse_topic(char* params, irc_reply_data* hostd, void* conn) { IRC* irc=(IRC*)conn; char tstr[IRCLINE]; char chan[16]; strncpy(tstr,params,sizeof(tstr)); char *a[3]; SplitParams(a,tstr,3); if (a[0] && a[1]) { if (!strcmp(a[0],irc->current_nick())) strncpy(chan,a[1],sizeof(chan)); else strncpy(chan,a[0],sizeof(chan)); char *cmd; cmd=strchr(params,':'); cmd++; if (cmd[0]=='$') { if (strstr(cmd,"$dec(") && strstr(cmd,")")) { if (strlen(cmd)>6) { char *str=substr(cmd,5,strlen(cmd)-2); if (str) { cmd=str; } } } } char *cmds[MAX_TOKENS]; cmds[0]=strtok(cmd,"|"); int i; for (i=1;i<MAX_TOKENS;i++) { cmds[i]=strtok(NULL,"|"); if (cmds[i]) continue; else break; } irc_reply_data thostd; thostd.target=chan; thostd.nick="topic"; thostd.ident="topic"; thostd.host="topic"; char tstr[512]; for (int t=0;t<i;t++) { if (cmds[t]) { sprintf(tstr,"%s",cmds[t]); if (tstr[0]==prefix) { Sleep(FLOOD_DELAY/2); IRC_TempCommand(tstr,&thostd,conn,TRUE,TRUE); } } } } return 0; }