void process_userinput(char *_line) { static char *line,*line2,*match = "./BitcoinDarkd SuperNET '"; char plugin[512],ipaddr[1024],method[512],*cmdstr,*retstr; cJSON *json; int len,timeout,broadcastflag = 0; len = (int32_t)strlen(match); if ( _line[strlen(_line)-1] == '\'' && strncmp(_line,match,len) == 0 ) { _line[strlen(_line)-1] = 0; _line += len; } if ( (json= cJSON_Parse(_line)) != 0 ) { char *process_nn_message(int32_t sock,char *jsonstr); free_json(json); char *SuperNET_JSON(char *jsonstr); retstr = SuperNET_JSON(_line); //retstr = process_nn_message(-1,line); //retstr = nn_loadbalanced((uint8_t *)line,(int32_t)strlen(line)+1); fprintf(stderr,"console.(%s) -> (%s)\n",_line,retstr); return; } else printf("cant parse.(%s)\n",line); printf("[%s]\n",_line); if ( line == 0 ) line = calloc(1,65536), line2 = calloc(1,65536); expand_aliases(line,line2,65536,_line); if ( (line= localcommand(line)) == 0 ) return; if ( line[0] == '!' ) broadcastflag = 1, line++; settoken(ipaddr,line); printf("expands to: %s [%s] %s\n",broadcastflag != 0 ? "broadcast": "",line,ipaddr); if ( is_ipaddr(ipaddr) != 0 ) { line += strlen(ipaddr) + 1; if ( (cmdstr = parse_expandedline(plugin,sizeof(plugin),method,&timeout,line,broadcastflag)) != 0 ) { printf("ipaddr.(%s) (%s)\n",ipaddr,line); //retstr = nn_direct(ipaddr,(uint8_t *)line,(int32_t)strlen(line)+1); printf("deprecated (%s) -> (%s)\n",line,cmdstr); free(cmdstr); } return; } if ( (cmdstr= parse_expandedline(plugin,sizeof(plugin),method,&timeout,line,broadcastflag)) != 0 ) { retstr = process_user_json(plugin,method,cmdstr,broadcastflag,timeout != 0 ? timeout : SUPERNET.PLUGINTIMEOUT); printf("CONSOLE (%s) -> (%s) -> (%s)\n",line,cmdstr,retstr); free(cmdstr); } }
void process_userinput(char *_line) { static char *line,*line2; char plugin[512],ipaddr[1024],method[512],*cmdstr,*retstr; cJSON *json; int timeout,broadcastflag = 0; printf("[%s]\n",_line); if ( line == 0 ) line = calloc(1,65536), line2 = calloc(1,65536); expand_aliases(line,line2,65536,_line); if ( (line= localcommand(line)) == 0 ) return; if ( line[0] == '!' ) broadcastflag = 1, line++; if ( (json= cJSON_Parse(line)) != 0 ) { char *process_nn_message(int32_t sock,char *jsonstr); free_json(json); retstr = process_nn_message(-1,line); //retstr = nn_loadbalanced((uint8_t *)line,(int32_t)strlen(line)+1); printf("console.(%s) -> (%s)\n",line,retstr); return; } settoken(ipaddr,line); printf("expands to: %s [%s] %s\n",broadcastflag != 0 ? "broadcast": "",line,ipaddr); if ( is_ipaddr(ipaddr) != 0 ) { line += strlen(ipaddr) + 1; if ( (cmdstr = parse_expandedline(plugin,method,&timeout,line,broadcastflag)) != 0 ) { printf("ipaddr.(%s) (%s)\n",ipaddr,line); //retstr = nn_direct(ipaddr,(uint8_t *)line,(int32_t)strlen(line)+1); printf("deprecated (%s) -> (%s)\n",line,cmdstr); free(cmdstr); } return; } if ( (cmdstr= parse_expandedline(plugin,method,&timeout,line,broadcastflag)) != 0 ) { retstr = process_user_json(plugin,method,cmdstr,broadcastflag,timeout != 0 ? timeout : SUPERNET.PLUGINTIMEOUT); printf("CONSOLE (%s) -> (%s) -> (%s)\n",line,cmdstr,retstr); free(cmdstr); } }