📄 scmds.c
字号:
t = ud_basename(tok[1]); cur->ping = -2; cur->song = strdup(quote(t)); cur->rfn = strdup(tok[1]); cur->sz = atoi(tok[3]); cur->brate = atoi(tok[4]); cur->freq = atoi(tok[5]); cur->time = atoi(tok[6]); cur->nick = strdup(tok[0]); cur->conn = -1; cur->next = NULL; return(1);}/* received an "end of browse list" packet from server: * <nick> [ip] */I_NAP_FUNC(sdbrowse){ int i; list_length(ssearch_t, search, i); wp(win, "* Received %d browse %s\n", i, i==1 ? "result" : "results"); drw(win); showresults(win, 0); return(1);}/* 642 (0x282) direct browse error: <nick> "message" */I_NAP_FUNC(sbrowse2err){ if (num < 2) return(1); srch = 0; directbrowse.state = FAILED; wp(win, "* Unable to directly browse %s: %s\n", tok[0], tok[1]); drw(win); return(1);}/* 641 (0x281) direct browse accept: <nick> <ip> <port> * <nick> accepted our direct browse request and the server is giving us * the IP address and port to connect to. * Note: If <nick> is firewalled, we will not receive this packet. * The remote client will connect to us and issue a SENDLIST command * (assuming we are not also firewalled). */I_NAP_FUNC(sbrowse2acc){ struct sockaddr_in dst; int k, r; sock_t *sk=NULL; unsigned short int dstport; if (num < 3) /* error, ignore the message */ return(1); if (directbrowse.state != REQUESTED || \ strcasecmp(directbrowse.nick, tok[0]) != 0) { /* didn't ask to browse this nick (or maybe we did, but that request * has timed out). Just ignore the message. */ return(1); } dstport = htons(atoi(tok[2])); if (dstport == 0) { return(1); } /* connect to the remote client */ dst.sin_addr.s_addr = htonl(swapl(strtoul(tok[1], (char **)NULL, 10))); dst.sin_port = dstport; dst.sin_family = AF_INET; k = socket(AF_INET, SOCK_STREAM, 0); fcntl(k, F_SETFL, O_NONBLOCK); r = connect(k, (struct sockaddr *)&dst, sizeof(dst)); if (r == -1 && errno != EINPROGRESS) { wp(win, ""RED"* Error browsing %s: %s"WHITE"\n", tok[0], strerror(errno)); drw(win); directbrowse.state = FAILED; srch = 0; close(k); return(1); } setkeepalive(k); sk = addsock(k, "dirbrowse", S_R, initgetlist); /* initgetlist in event.c */ directbrowse.state = CONNECTING; directbrowse.sk = sk; if (nvar("debug") == 2) { wp(win, ""DARK GREEN"* Connecting to %s to get list of shared files"\ WHITE"\n", tok[0]); drw(win); } return(1);}/* 640 (0x280) direct browse request: <nick> [ip port] * <nick> is requesting to directly browse our shared files. * If we are firewalled, the server also provides <nick>'s IP address and port * so that we can initiate the connection. */I_NAP_FUNC(sbrowse2req){ struct sockaddr_in dst; int k, r; sock_t *sk=NULL; unsigned short int dstport; if (num < 1) return(1); /* XXX if we limit the number of outgoing browse connections, * check that we are within the limit here. */ if (num < 3) { /* accept the direct browse request: <nick> */ sendpack(s, NAP_BROWSE2ACC, "%s", tok[0]); /* remote client will initiate the connection */ return(1); } /* Note the Napster v2.0 BETA 8 & BETA 9 clients don't send a * 641 direct browse accept message if they are firewalled. They * simply connect to the remote client and issue a SENDLIST command. * (They also don't understand SENDLIST commands that are issued * to them, but that is a separate matter...) */ dstport = htons(atoi(tok[2])); if (dstport == 0) return(1); /* this is an error but we ignore it */ /* initiate connection because we are firewalled */ dst.sin_addr.s_addr = htonl(swapl(strtoul(tok[1], (char **)NULL, 10))); dst.sin_port = dstport; dst.sin_family = AF_INET; k = socket(AF_INET, SOCK_STREAM, 0); fcntl(k, F_SETFL, O_NONBLOCK); r = connect(k, (struct sockaddr *)&dst, sizeof(dst)); if (r == -1 && errno != EINPROGRESS) { if (nvar("debug") == 2) { wp(win, ""RED"* Error sending list to %s: %s"WHITE"\n", tok[0], strerror(errno)); drw(win); } close(k); return(1); } setkeepalive(k); sk = addsock(k, gnum(2), S_R, initsendlist); /* initsendlist in event.c */ if (nvar("debug") == 2) { wp(win, ""DARK GREEN"* Connecting to %s to send list of shared files"\ WHITE"\n", tok[0]); drw(win); } return(1);}I_NAP_FUNC(sop){ wp(win, "%s!%s%s%s!%s %s\n", GREEN, WHITE, tok[0], GREEN, WHITE, str+strlen(tok[0])+1); drw(win); return(1);}I_NAP_FUNC(spchange){ wp(win, "%s* Your data port was changed to %s%s\n", RED, tok[0], WHITE); closefserv(); info.port = initfserv(tok[0]); if (info.port == -1) { wp(win, ""RED"Warning: could not open port %s: %s"WHITE"\n", tok[0], strerror(errno)); info.port = 0; } drw(win); return(1);}I_NAP_FUNC(sbport){ wp(win, "%s* Your dataport is misconfigured%s\n", RED, WHITE); drw(win); return(1);}I_NAP_FUNC(sannounce){ wp(win, "%s[%s%s%s]%s %s\n", RED, WHITE, tok[0], RED, WHITE, str+strlen(tok[0])+1); drw(win); return(1);}I_NAP_FUNC(sbanlist){ wp(win, "%s* Banned: %s%s\n", BRIGHT(BLUE), str, WHITE); drw(win); return(1);}I_NAP_FUNC(ssping){ sendpack(s, SERVER_PING, NULL); return(1);}I_NAP_FUNC(scping){ wp(win, "%s* Received PING from %s%s\n", RED, tok[0], WHITE); drw(win); sendpack(s, CLIENT_PONG, "%s", str); return(1);}I_NAP_FUNC(scpong){ if (nvar_default("announcepongs", 0)) { wp(win, "%s* Received PONG from %s%s\n", RED, tok[0], WHITE); drw(win); } return(1);}I_NAP_FUNC(sredir){ int t; sock_t *sk; chans_t *cur; char *t1=NULL; int c; char *libraryfile; wp(win, "%s* You've been redirected%s\n", RED, WHITE); drw(win); msprintf(&t1, "%s:%s", tok[0], tok[1]); wp(win, "Connecting to %s...\n", t1); drw(win); t = conn(t1); if (t == -1) { drw(win); free(t1); return(1); } free(t1); wp(win, "Logging in...\n"); drw(win); c = connection(); if (login(t, info.user, info.pass, info.port, c, info.email) == -1) { drw(win); close(t); return(1); } sk = findsock("server"); if (sk) delsock(sk->fd); sk = addsock(t, "server", S_R, inserv); /* schedule shared file list for sending */ if (info.shared_filename) { libraryfile = strdup(info.shared_filename); } else { libraryfile = home_file(LIBRARYFILE); } lfiles(sk->fd, libraryfile); free(libraryfile); curchan=NULL; if (chanl) { for (cur=chanl;;cur=cur->next) if (!cur->q) sendpack(sk->fd, NAP_JOIN, "%s", cur->nm); delnapchans(); } indraw(); return(1);}I_NAP_FUNC(scycle){ int t; sock_t *sk; chans_t *cur; int c; char *libraryfile; wp(win, "%s* You've been cycled%s\n", RED, WHITE); drw(win); wp(win, "Connecting to %s...\n", tok[0]); drw(win); t = conn(tok[0]); if (t == -1) { drw(win); return(1); } wp(win, "Logging in...\n"); drw(win); c = connection(); if (login(t, info.user, info.pass, info.port, c, info.email) == -1) { drw(win); close(t); return(1); } sk = findsock("server"); if (sk) delsock(sk->fd); sk = addsock(t, "server", S_R, inserv); /* schedule shared file list for sending */ if (info.shared_filename) { libraryfile = strdup(info.shared_filename); } else { libraryfile = home_file(LIBRARYFILE); } lfiles(sk->fd, libraryfile); free(libraryfile); curchan=NULL; if (chanl) { for (cur=chanl;;cur=cur->next) if (!cur->q) sendpack(sk->fd, NAP_JOIN, "%s", cur->nm); delnapchans(); } indraw(); return(1);}I_NAP_FUNC(sclist){ wp(win, "%s%s%s - %s - %s\n", BOLD, tok[0], WHITE, tok[1], str+strlen(tok[0])+strlen(tok[1])+2); drw(win); return(1);}I_NAP_FUNC(sclist2){ wp(win, "%s%s%s - %s - %s\n", BOLD, tok[0], WHITE, tok[1], tok[5] /* str+strlen(tok[0])+strlen(tok[1])+strlen(tok[2])+strlen(tok[3])+strlen(tok[4])+5 */ ); drw(win); return(1);}I_NAP_FUNC(sblocklist){ wp(win, "%s* Blocked: %s%s\n", BRIGHT(BLUE), str, WHITE); drw(win); return(1);}I_NAP_FUNC(signorelist){ wp(win, "%s* Ignored: %s%s\n", BRIGHT(BLUE), str, WHITE); drw(win); return(1);}I_NAP_FUNC(signoreend){ wp(win, "%s* Total users ignored: %s%s\n", BRIGHT(BLUE), str, WHITE); drw(win); return(1);}I_NAP_FUNC(signoreadd){ wp(win, "%s* Added %s to the ignore list%s\n", BRIGHT(BLUE), str, WHITE); drw(win); return(1);}I_NAP_FUNC(signoreremove){ wp(win, "%s* Removed %s from the ignore list%s\n", BRIGHT(BLUE), str, WHITE); drw(win); return(1);}I_NAP_FUNC(signoreunknown){ wp(win, "%s* %s is not ignored or does not exist%s\n", RED, str, WHITE); drw(win); return(1);}I_NAP_FUNC(signoreexists){ wp(win, "%s* %s is already on your ignore list%s\n", RED, str, WHITE); drw(win); return(1);}I_NAP_FUNC(signoreclear){ wp(win, "%s* Cleared %s users from your ignore list%s\n", BRIGHT(BLUE), str, WHITE); drw(win); return(1);}I_NAP_FUNC(signorefail){ wp(win, "%s* Ignoring %s failed!%s\n", RED, str, WHITE); drw(win); return(1);}I_NAP_FUNC(scbanlist){ wp(win, "%s* Channel ban: %s%s\n", BRIGHT(BLUE), str, WHITE); drw(win); return(1);}I_NAP_FUNC(snerr){ wp(win, "%s* Server: Could not add %s to your hotlist%s\n", RED, tok[0], WHITE); drw(win); return(1);}I_NAP_FUNC(snadd){ /* the server is telling us that it successfully added somebody to our hotlist. Since we keep our own copy of our hotlist, do we really care? */ return(1);}I_NAP_FUNC(sme){ if (!(recent = findchan(chanl, tok[0]))) return(1); if (!strcasecmp(curchan->nm, tok[0]) || wmode) { wp(win, "%s* %s%s %s\n", CYAN, tok[1], WHITE, tok[2]); drw(win); } else { wp(win, "%s* %s%s/%s%s%s %s\n", CYAN, tok[1], WHITE, CYAN, tok[0], WHITE, tok[2]); drw(win); } recent = NULL; return(1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -