Seeding from the 1.2 tree.
This commit is contained in:
98
dll/nap/Changes
Normal file
98
dll/nap/Changes
Normal file
@@ -0,0 +1,98 @@
|
||||
|
||||
02-01-00
|
||||
* added support for opennap server commands.
|
||||
* added support for opennap soundex searching. This means we can
|
||||
search for something which may be spelled incorrectly or where we
|
||||
don't know the exact spelling. /nsound is the command. It is used
|
||||
exactly like /nsearch
|
||||
* added support for opennap mime-type searching. When specifying a
|
||||
type, all other params are ignored, except max_results.
|
||||
/nsearch -type video matrix
|
||||
|
||||
01-17-00
|
||||
* gratitious change to napster windows client involving the md5
|
||||
checksum. Seems we need to send the filesize at the end of the
|
||||
md5. "md5-filesize"
|
||||
* Added /nload -load which will load a ~/.BitchX/shared.dat. This
|
||||
file is in the same format as the linux client.
|
||||
* Added /nload -save which will save/overwrite the shared.dat.
|
||||
* firewall get's are fixed.
|
||||
* removed SO_LINGER on a file send. why should we wait for the other
|
||||
end to catch up.
|
||||
|
||||
01-11-00 0.7
|
||||
* when a file get returns "FILE NOT SHARED" we need to use += on the
|
||||
read
|
||||
* Changed the queued get to actually queue the file instead of
|
||||
deleting the request.
|
||||
* Changed socket's to SO_LINGER. Maybe this'll fix firewall get's.
|
||||
|
||||
12-20-99 0.6c
|
||||
* md5 only calculated on 300k. do NOT include the id3v1 or id3v2 tag.
|
||||
Also it seems that MusicMatch uses id3v2 (lame piece of shit, why
|
||||
make something so complicated as id3v2), So we have to skip the
|
||||
id3v2 header while calculating it. Also noticed was that a file
|
||||
had BOTH id3v1 and id3v2 headers. Like, give us a break. Use one
|
||||
or the other, not both.
|
||||
|
||||
12-19-99
|
||||
* void noticed that /nscan was not working. Turns out my
|
||||
nap_current_channel and njoin routines were a little screwy. njoin
|
||||
should not "remove" the channel from our internal list.
|
||||
* fudd helped me find a problem with file sends.. needed to be a
|
||||
little less optimistic about when data is available for reading.
|
||||
* added /necho command. accepts a -x arg, which places text without
|
||||
the prompt.
|
||||
* found another possible coredump problem in filesends.
|
||||
* added auto-reconfigure dataport.
|
||||
* colorized speed of connection in the names and scan list. Also
|
||||
joins and parts. bright green is fastest, dark grey is unknown.
|
||||
|
||||
12-15-99
|
||||
* found/fixed firewall sends. IT should work as long as the other
|
||||
end is okay. It does seem however that on occasion the other end
|
||||
fails and odd errors will pop up.
|
||||
* found the send limit numerics.
|
||||
* found remove file numeric.
|
||||
* added support for data port misconfigurations.
|
||||
* modified tab_completion() so that tab key will work for nmsg.
|
||||
* fixed lost sockets.
|
||||
* fixed download coredump.
|
||||
* made certain /set's send the appropriate napster command.
|
||||
* merged all the admin commands into /nadmin
|
||||
* added several functions for scripting.
|
||||
$mp3time(seconds) pretty prints the time.
|
||||
$nonchan(chan) returns if we are on the specified channel
|
||||
$nonchannel(chan [nick]) returns ALL nicks or just nick
|
||||
$napconnected() returns the server/port
|
||||
$ntopic(chan) topic for the channel
|
||||
$ncurrent() returns the current "client" channel
|
||||
$nhotlist([nick]) returns the whole hotlist or whether
|
||||
nick is online
|
||||
$nraw(# string) will send "raw" commands to the server.
|
||||
$md5(# [size]) will md5 checksum a open file # using 300000
|
||||
as the default size or whatever you specify.
|
||||
@f = open(filename R)
|
||||
@md = md5(f)
|
||||
close(f)
|
||||
* started adding firewall download support. (does this even work ??)
|
||||
|
||||
12-13-99
|
||||
* Fixed more cores.
|
||||
* Found more numerics... Almost complete.
|
||||
* Found "resume" semantics..
|
||||
* Added "hooks" for scripting.
|
||||
* Whois info is updated with number of file sends/gets
|
||||
* Added channel save between connects. We now re-join any channels we
|
||||
were in when the server dumps us.
|
||||
* Fudd found a problem when the filesend does not complete, but a
|
||||
msg saying it did, appears
|
||||
* Should compile for cygwin now as well.
|
||||
* new commands added. /nemail, /ndataport, /nlinespeed etc.
|
||||
?? should these be removed in favour of the /set's
|
||||
|
||||
12-12-99
|
||||
* Server connection errors detected earlier.
|
||||
* Server read error caught.
|
||||
* Hotlist fixes.
|
||||
|
||||
196
dll/nap/Makefile.in
Normal file
196
dll/nap/Makefile.in
Normal file
@@ -0,0 +1,196 @@
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
topdir = @topdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = @oldincludedir@
|
||||
|
||||
local_dir = $(HOME)
|
||||
|
||||
# Where the BitchX binary will be installed.
|
||||
# "make install" will compile and install the program.
|
||||
INSTALL_IRC = @INSTALL_IRC@
|
||||
|
||||
# Where the BitchX library will be. Generally this is the place that
|
||||
# you put the scripts, help pages and translation tables. It is
|
||||
# very important that you set this correctly.
|
||||
IRCLIB = @IRCLIB@
|
||||
|
||||
CC = @CC@
|
||||
DEFS = @INCLUDES@
|
||||
LIBS = @LIBS@
|
||||
|
||||
# Tcl library.
|
||||
TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
# These are for Tcl support.
|
||||
TCL_OBJS = @TCL_OBJS@
|
||||
# You don't have the following, so you'll want to leave this blank.
|
||||
TCL_SRCS = @TCL_SRCS@
|
||||
|
||||
# Set this to -g if you want to be able to debug the client, otherwise
|
||||
# use -O to have the compiler do some optimization instead.
|
||||
CFLAGS = @CFLAGS@
|
||||
|
||||
# Set this to -s if you want the binary to be stripped.
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
# These are for the cd device player.
|
||||
CD_SRCS = @CD_SRCS@
|
||||
CD_OBJS = @CD_OBJS@
|
||||
|
||||
# This is the executable suffix for the target operating system.
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
# Extra files.
|
||||
DEFAULT_CTOOLZ_DIR = @DEFAULT_CTOOLZ_DIR@
|
||||
DEFAULT_MSGLOGFILE = @DEFAULT_MSGLOGFILE@
|
||||
DEFAULT_BITCHX_HELP_FILE = @DEFAULT_BITCHX_HELP_FILE@
|
||||
DEFAULT_SCRIPT_HELP_FILE = @DEFAULT_SCRIPT_HELP_FILE@
|
||||
DEFAULT_BITCHX_KICK_FILE = @DEFAULT_BITCHX_KICK_FILE@
|
||||
DEFAULT_BITCHX_QUIT_FILE = @DEFAULT_BITCHX_QUIT_FILE@
|
||||
DEFAULT_BITCHX_IRCNAME_FILE = @DEFAULT_BITCHX_IRCNAME_FILE@
|
||||
|
||||
# Full path of the directory for BitchX help files.
|
||||
HELPDIR = @HELPDIR@
|
||||
|
||||
# Full path of the directory for the BitchX scripts.
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
# Default setting for IRCPATH where BitchX will look for
|
||||
# its script files if the environment variable is undefined.
|
||||
# Usually, this should contain the same path as used for INSTALL_SCRIPT in
|
||||
# the Makefile, but it can contain multiple path elements
|
||||
# separated by colons. The path MUST lead to an existing directory,
|
||||
# because the 'global' script is expected to be found there.
|
||||
IRCPATH = @IRCPATH@
|
||||
|
||||
# Path for TRANSLATION variable.
|
||||
TRANSLATION_PATH = @TRANSLATION_PATH@
|
||||
|
||||
# This is where the optional plugins will be copied to.
|
||||
PLUGINDIR = @PLUGINDIR@
|
||||
|
||||
# Plugin flags.
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_SUFFIX = @SHLIB_SUFFIX@
|
||||
|
||||
# This command will be used to install the BitchX files on Win32/OS2EMX
|
||||
# systems.
|
||||
WINNT_INSTALL = @WINNT_INSTALL@
|
||||
|
||||
# This program allows you to use screen/xterm's to put new BitchX windows
|
||||
# on new screen/xterm windows.
|
||||
INSTALL_WSERV = @INSTALL_WSERV@
|
||||
|
||||
# This program allows you to screen BitchX and reattach to it later.
|
||||
INSTALL_SCRBX = @INSTALL_SCRBX@
|
||||
|
||||
# Set gzip and bzip2 options.
|
||||
GZIP_ENV = @GZIP_ENV@
|
||||
BZIP2 = @BZIP2@
|
||||
|
||||
# Standard programs.
|
||||
RM = @RM@
|
||||
LN = @LN_S@
|
||||
CP = @CP@
|
||||
MV = @MV@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
VERSION = @VERSION@
|
||||
_VERSION_ = @_VERSION_@
|
||||
|
||||
MAKE_BIN = @MAKE@
|
||||
MAKE = $(MAKE_BIN) $(MFLAGS)
|
||||
MFLAGS = \
|
||||
'local_dir=$(HOME)' \
|
||||
'INSTALL_IRC=$(INSTALL_IRC)' \
|
||||
'IRCLIB=$(IRCLIB)' \
|
||||
'CC=$(CC)' \
|
||||
'CFLAGS=$(CFLAGS)' \
|
||||
'HELPDIR=$(HELPDIR)' \
|
||||
'INSTALL_WSERV=$(INSTALL_WSERV)' \
|
||||
'IRCPATH=$(IRCPATH)' \
|
||||
'TRANSLATION_PATH=$(TRANSLATION_PATH)' \
|
||||
'LDFLAGS=$(LDFLAGS)' \
|
||||
'LIBS=$(LIBS)' \
|
||||
'LN=$(LN)' \
|
||||
'RM=$(RM)' \
|
||||
'TCL_SRCS=$(TCL_SRCS)' \
|
||||
'TCL_OBJS=$(TCL_OBJS)' \
|
||||
'CD_PLAY=$(CD_PLAY)' \
|
||||
'CD_SRCS=$(CD_SRCS)' \
|
||||
'CD_OBJS=$(CD_OBJS)' \
|
||||
'TCL_LIBS=$(TCL_LIBS)' \
|
||||
'PLUGINDIR=$(PLUGINDIR)' \
|
||||
'_VERSION_=$(_VERSION_)' \
|
||||
'VERSION=$(VERSION)' \
|
||||
'INSTALL_DATA=$(INSTALL_DATA)' \
|
||||
'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
|
||||
'EXEEXT=$(EXEEXT)' \
|
||||
'SHLIB_CFLAGS=$(SHLIB_CFLAGS)' \
|
||||
'SHLIB_SUFFIX=$(SHLIB_SUFFIX)'
|
||||
|
||||
## Makefile starts here.
|
||||
|
||||
PLUGIN_NAME = nap
|
||||
|
||||
OBJS = nap.o napsend.o nap_file.o napfunc.o napother.o md5.o compat.o
|
||||
|
||||
all: Makefile nap$(SHLIB_SUFFIX)
|
||||
|
||||
Makefile: Makefile.in
|
||||
cd $(topdir) \
|
||||
&& ./config.status
|
||||
|
||||
compat.o: $(top_srcdir)/source/compat.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) \
|
||||
-c $(top_srcdir)/source/compat.c
|
||||
|
||||
nap.o: $(srcdir)/nap.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/nap.c
|
||||
|
||||
napsend.o: $(srcdir)/napsend.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/napsend.c
|
||||
|
||||
nap_file.o: $(srcdir)/nap_file.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/nap_file.c
|
||||
|
||||
napfunc.o: $(srcdir)/napfunc.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/napfunc.c
|
||||
|
||||
napother.o: $(srcdir)/napother.c
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/napother.c
|
||||
|
||||
md5.o: $(srcdir)/md5.c $(srcdir)/md5.h
|
||||
$(CC) $(DEFS) $(SHLIB_CFLAGS) $(CFLAGS) -c $(srcdir)/md5.c
|
||||
|
||||
nap$(SHLIB_SUFFIX): $(OBJS)
|
||||
$(SHLIB_LD) $(OBJS) $(SHLIB_CFLAGS) -o nap$(SHLIB_SUFFIX)
|
||||
|
||||
clean:
|
||||
$(RM) *~ *.o *.so *.a *.dll *.def .#*
|
||||
|
||||
distclean: clean
|
||||
$(RM) Makefile
|
||||
|
||||
install:
|
||||
$(INSTALL) $(PLUGIN_NAME)$(SHLIB_SUFFIX) $(DESTDIR)$(PLUGINDIR)
|
||||
343
dll/nap/README.nap
Normal file
343
dll/nap/README.nap
Normal file
@@ -0,0 +1,343 @@
|
||||
|
||||
|
||||
Well here's my attempt at a "napster" client. Mine is a plugin for BitchX
|
||||
and should work with 1.0c11 or 1.0c12. This source should be untar'd in the
|
||||
BitchX/dll directory in order to find certain files that are required.
|
||||
There will be a compile error in include/modval.h of 1.0c11 and 1.0c12,
|
||||
requiring you to edit the file and add a ( to the #define for strmopencat.
|
||||
This is what the line should look like.
|
||||
|
||||
#define strmopencat ((char * (*)())global[STRMOPENCAT])
|
||||
|
||||
After you have compiled BitchX with plugin support (./configure
|
||||
--with-plugins) and have installed the client with either make install or
|
||||
make install_local, you can then /loaddll nap which loads the plugin into
|
||||
the client. At this point, you have a bunch of new /set's and a few new
|
||||
commands.
|
||||
|
||||
There is a /set napster_user and a /set napster_pass to set the username and
|
||||
password you use with the server. You will need to set these to a unique
|
||||
name and password. IF after you run set these 2 variables and /napster,
|
||||
recieve an error msg about Invalid Password, it means the username is taken.
|
||||
|
||||
There is also a /napster command which actually connects you to the server.
|
||||
The /napster command can also take a -create flag which tells the napster
|
||||
server to create the account. /n<tab> will display a list of commands
|
||||
(starting with the letter N) of which ALL the nap plugin commands are
|
||||
included. /set napster will display ALL the set's.
|
||||
|
||||
|
||||
We also have a list of functions specific to napster and a whole set of
|
||||
hook's for use in a scripted environment. /on module "NAP *" where the
|
||||
first arg is NAP, second is a function are available for scripts to be
|
||||
written.
|
||||
|
||||
[Functions]
|
||||
|
||||
$md5(open_file_des [size])
|
||||
size defaults to 300000
|
||||
|
||||
$napchannel()
|
||||
returns current channel
|
||||
|
||||
$nraw(num [args])
|
||||
sends a raw command to the server.
|
||||
returns -1 on error.
|
||||
returns 0 if no args for command.
|
||||
returns len of args.
|
||||
|
||||
$nhotlist([nick|nick(s)])
|
||||
returns current hotlist with no args.
|
||||
returns hotlist info if nick is specified.
|
||||
|
||||
$nap_connected()
|
||||
returns empty or the server we are connected to.
|
||||
|
||||
$nonchannel(channel [nick|nick(s)]);
|
||||
returns all nicks on the channel if no other arg specified.
|
||||
returns info on nicks specified.
|
||||
|
||||
$nonchan(channel)
|
||||
are we on this channel?. 0 or 1
|
||||
|
||||
$ntopic(channel)
|
||||
returns the topic for the specified channel.
|
||||
|
||||
$mp3time(seconds)
|
||||
pretty prints the seconds.
|
||||
|
||||
[Commands]
|
||||
n command args
|
||||
command can be one of raw, whois. raw is for sending raw server
|
||||
numerics and is meant for testing.
|
||||
|
||||
napster [-create] [user] [pass] [host] [port]
|
||||
This command will attempt to find the best server and connect you to
|
||||
it. with -create, it will attempt to create an account using the
|
||||
/set napster_user and /set napster_pass variables.
|
||||
|
||||
nbrowse nick
|
||||
Attempts to get the filelist that nick is offering.
|
||||
|
||||
nclose
|
||||
Close the current napster connection.
|
||||
|
||||
nconnect <server:port> | <server port>
|
||||
Attempt to connect to a known server.
|
||||
|
||||
ndel <*|#>
|
||||
Deletes the numbered download.
|
||||
|
||||
necho [-x] args
|
||||
Will display text using the internal window display routine. -x
|
||||
displays text without the "prompt"
|
||||
|
||||
ninfo [nick]
|
||||
Will display whois info about nick, or yourself if no nick
|
||||
specified.
|
||||
|
||||
nget [-request] [-browse] <#>
|
||||
Attempt to get the # file from the request or the browse list
|
||||
|
||||
nglist
|
||||
Display list of current uploads and downloads.
|
||||
|
||||
njoin [channelname]
|
||||
Join the channelname specified, or if none and we are on a
|
||||
channel(s), then switch current channels.
|
||||
|
||||
nlist
|
||||
Displays all the channel's available.
|
||||
|
||||
nload [-recurse][-share][-file [filename]][-save [filename]] dir | dir(s)
|
||||
-recurse is a toggle which turns on/off recursive directory
|
||||
searching. It can appear anywhere, and turns on/off recursion until
|
||||
the end of the directory paths or until the next occurance.
|
||||
-share will add the files as they are found to the napster server
|
||||
database
|
||||
-file will load a file called shared.dat(default) from your
|
||||
~/.BitchX or CTOOLZ_DIR. This file is in the same format as the
|
||||
linux napster save file. A filename can be specified in it's place
|
||||
-save will attempt to save a file using the same as the information
|
||||
in -file
|
||||
|
||||
nmsg nick msg
|
||||
sends a msg to nick.
|
||||
|
||||
|
||||
|
||||
npart [channelname]
|
||||
Attempts to part or leave the [channelname] or if no channelname is
|
||||
specified it leaves the current channel.
|
||||
|
||||
nprint
|
||||
Prints a list of the mp3's in a nice format.. /set napster_format
|
||||
can be used to change this format. More documentation needed here.
|
||||
|
||||
nreconnect
|
||||
Attempts to re-connect to the current server.
|
||||
|
||||
nreload [-recurse] dir | dir(s)
|
||||
Removes the old list of mp3's and then scans the directories
|
||||
specified. See [nload].
|
||||
|
||||
nrequest nick filename
|
||||
If you know the exact filename on "nick" then you can directly
|
||||
request it without going through the browse.
|
||||
|
||||
nsave
|
||||
This saves ~/.BitchX/Napster.sav which is all your current set's.
|
||||
|
||||
nsay msg
|
||||
Say msg on the current channel.
|
||||
|
||||
nscan
|
||||
Display the nicks on the current channel.
|
||||
|
||||
nsound
|
||||
same arg's are nsearch. The differance is that a soundex is
|
||||
performed and requested. This is an opennap feature.
|
||||
|
||||
nsearch [-maxresults #][-bitrate|-maxbitrate|-minbitrate #]
|
||||
(20,24,32,48,56,64,98,112,128,160,192,256,320)
|
||||
[-freq|-minfreq|-maxfreq #]
|
||||
(8000,11025,12000,16000,22050,24000,32000,44100,48000)
|
||||
[-linespeed|-minlinespeed|-maxlinespeed #] (0-11)
|
||||
[-type video/zip/audio]
|
||||
pattern
|
||||
|
||||
Search for "pattern" on your napster server.. You can then use /nget
|
||||
to receive files.
|
||||
** NOTE napster servers have an error where more than 100 results will never
|
||||
be returned.
|
||||
|
||||
nshare
|
||||
After a /nload you might want to actually share the files with your
|
||||
friends.
|
||||
|
||||
ntopic [topic]
|
||||
Displays or attempts to set the current channel topic.
|
||||
|
||||
npass <nick password>
|
||||
Command to change your password.
|
||||
|
||||
nping <nick>
|
||||
Will ping a nick giving an indication of server response time.
|
||||
|
||||
nstats
|
||||
Display statistics gathered during the operation of napster plugin.
|
||||
|
||||
nignore <nick|-nick>
|
||||
This will ignore everything this particular nick might do to you.
|
||||
-nick will remove the ignore.
|
||||
|
||||
necho [-x] <args>
|
||||
output args to the napster window. -x is raw output.
|
||||
|
||||
nadmin <command> [args]
|
||||
This command is used for admins and elite etc. <command> is one of
|
||||
the following:
|
||||
|
||||
annouce <args>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
kill <nick>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
muzzle <nick>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
muzzle <nick>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
nuke <nick>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
opsay <msg>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
setdataport <nick port>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
setlinespeed <nick #>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
setuserlevel <nick level>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
unban <nick>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
unnuke <nick>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
ban <nick>
|
||||
This is a command for moderators and admins.
|
||||
|
||||
banlist
|
||||
Display current list of server bans.
|
||||
|
||||
version
|
||||
grab the server version.
|
||||
|
||||
[following are opennap specific]
|
||||
connect <host> <port> [<remote server>]
|
||||
attempts to connect to the server on <port>
|
||||
|
||||
disconnect <host> <reason>
|
||||
delink server from net.
|
||||
|
||||
killserver <server> <reason>
|
||||
shutdown server
|
||||
|
||||
removeserver <servername> <reason>
|
||||
remove server from table of allowed servers
|
||||
|
||||
config <variable> [<value>]
|
||||
attempts to set a server variable
|
||||
|
||||
reload
|
||||
reloads the default variables from the config file
|
||||
|
||||
|
||||
The Following set's are available.
|
||||
|
||||
napster_dataport [6699]
|
||||
Set's your dataport for filesends.
|
||||
|
||||
napster_dir
|
||||
Set's your base directory for /nload
|
||||
|
||||
napster_download_dir ~
|
||||
Set's the location for your downloaded files.
|
||||
|
||||
napster_email blah@hrm.test
|
||||
Set's your email address for login
|
||||
|
||||
napster_send_limit 5
|
||||
Set the max send's allowed.
|
||||
|
||||
napster_max_send_nick
|
||||
Set the max sends to one nick allowed at one time. Should be smaller
|
||||
than "napster_send_limit"
|
||||
|
||||
napster_format
|
||||
Set's the output of the /nprint command.
|
||||
%% will print a % sign.
|
||||
%b bitrate
|
||||
%s filesize
|
||||
%t print mp3 time in minutes/seconds.
|
||||
%T print raw time in seconds.
|
||||
%f print base name of the file.
|
||||
%F print raw filename
|
||||
%M print md5 checksum
|
||||
%S print mode of mp3.
|
||||
%H print frequency
|
||||
%h print raw frequency
|
||||
\n start a newline
|
||||
\t put a tab in the output.
|
||||
|
||||
napster_host server.napster.com
|
||||
Set's the napster server for lookups.
|
||||
|
||||
napster_max_results 100
|
||||
Set's the MAX number of results for /nsearch.
|
||||
|
||||
napster_names_nickcolor %K[%w$[12]0%K]
|
||||
Set's the format for the nicks when you /njoin or /nscan a channel
|
||||
A double space in the format will be replaced with a "color" code
|
||||
based on the speed of the user.
|
||||
|
||||
napster_numeric
|
||||
Set's the numeric prompt
|
||||
|
||||
napster_pass
|
||||
Set's the password you will use on the server.
|
||||
|
||||
napster_port 8875
|
||||
Set's the port for /set napster_server
|
||||
|
||||
napster_prompt [Nap]
|
||||
Set's the prompt when outputting a napster line.
|
||||
|
||||
napster_show_numeric OFF
|
||||
Set's display of numerics on/off
|
||||
|
||||
napster_speed 3
|
||||
Set's your connection speed. values are 0-11.
|
||||
|
||||
napster_user
|
||||
Set's the username you will use on the server.
|
||||
|
||||
napster_window OFF
|
||||
Set's a private window for napster
|
||||
|
||||
napster_window_hidden OFF
|
||||
Set's the private window hidden.
|
||||
|
||||
napster_share ON
|
||||
Turn's on/off sharing of music. shared files will however stay in
|
||||
the database.
|
||||
|
||||
panasync
|
||||
Colten Edwards
|
||||
24
dll/nap/dragonap/README.FIRST
Normal file
24
dll/nap/dragonap/README.FIRST
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
This source was written in my spare time and was intended for immediate
|
||||
release....originally. There were some issues with the fact that napster may
|
||||
become rather ugly if little green trolls start writing hacks and bots for
|
||||
napster. But whatever, open source is your friend. This release is probably
|
||||
against the wishes of many, very sorry. I'm sure the napster product will
|
||||
survive just fine. With the release of gnap I figured what the hell, I'll send
|
||||
out what I had been working on as well. Lets see what happens.
|
||||
|
||||
Feel free to use any of this code as a base/example.
|
||||
If you use any of the code, simply give credit where its due.
|
||||
|
||||
*Please make note that *NONE* of this code is complete. If you dont code C
|
||||
then you're fucked. This is intended for developers only. I do not plan
|
||||
on completing a client at the current time. This is what I have, and
|
||||
where I left off.
|
||||
|
||||
Released 11-30-99.
|
||||
|
||||
All source by Drago (drago@0x00.org). Email if you have any questions/comments.
|
||||
|
||||
Another open source napster clone can be found at http://gnap.soundforge.net
|
||||
Information and the official napster software can be found at http://www.napster.com
|
||||
2
dll/nap/dragonap/napi/Makefile
Normal file
2
dll/nap/dragonap/napi/Makefile
Normal file
@@ -0,0 +1,2 @@
|
||||
all:
|
||||
gcc -o main main.c napi.c
|
||||
32
dll/nap/dragonap/napi/commands.h
Normal file
32
dll/nap/dragonap/napi/commands.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
napster code base by Drago (drago@0x00.org)
|
||||
released: 11-30-99
|
||||
*/
|
||||
|
||||
#ifndef COMMANDS_H
|
||||
#define COMMANDS_H
|
||||
enum recv_Commands {
|
||||
CMDR_STATS=214,
|
||||
CMDR_EMAILADDR=3,
|
||||
CMDR_MOTD=109,
|
||||
CMDR_SEARCHRESULTS=201,
|
||||
CMDR_SEARCHRESULTSEND=202,
|
||||
CMDR_ERROR=0,
|
||||
CMDR_ANOTHERUSER=148,
|
||||
CMDR_SENDFILE=95,
|
||||
CMDR_USERSPEED=209,
|
||||
CMDR_REQUESTUSERSPEED=89,
|
||||
CMDR_FILEREADY=204,
|
||||
CMDR_GETERROR=206,
|
||||
CMDR_GETQUEUE=108
|
||||
};
|
||||
|
||||
|
||||
enum send_Commands {
|
||||
CMDS_LOGIN=2,
|
||||
CMDS_SEARCH=200,
|
||||
CMDS_REQUESTFILE=203,
|
||||
CMDS_ADDFILE=100,
|
||||
CMDS_ADDHOTLIST=208
|
||||
};
|
||||
#endif
|
||||
BIN
dll/nap/dragonap/napi/main
Executable file
BIN
dll/nap/dragonap/napi/main
Executable file
Binary file not shown.
27
dll/nap/dragonap/napi/main.c
Normal file
27
dll/nap/dragonap/napi/main.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
napster code base by Drago (drago@0x00.org)
|
||||
released: 11-30-99
|
||||
*/
|
||||
|
||||
#include "napi.h"
|
||||
|
||||
void motdhook(char *s) {
|
||||
printf("MOTD: %s\n", s);
|
||||
}
|
||||
|
||||
void statshook(_N_STATS *s) {
|
||||
printf("Stats: Libraries==%d Songs==%d Gigs==%d\n", s->libraries, s->songs, s->gigs);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
_N_SERVER *s;
|
||||
_N_AUTH a={"dragotest", "nap"};
|
||||
n_SetMotdHook(motdhook);
|
||||
n_SetStatsHook(statshook);
|
||||
s=n_GetServer();
|
||||
if (!n_Connect(s, &a)) {
|
||||
printf("Error connecting\n");
|
||||
return 1;
|
||||
}
|
||||
while(1) n_Loop();
|
||||
}
|
||||
221
dll/nap/dragonap/napi/napi.c
Normal file
221
dll/nap/dragonap/napi/napi.c
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
napster code base by Drago (drago@0x00.org)
|
||||
released: 11-30-99
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "napi.h"
|
||||
|
||||
|
||||
_N_SERVER *n_GetServer(void) {
|
||||
char serverline[1024], *server;
|
||||
int fd, r, port;
|
||||
struct sockaddr_in socka;
|
||||
static _N_SERVER theserver;
|
||||
|
||||
fd=socket(AF_INET, SOCK_STREAM, 0);
|
||||
socka.sin_addr.s_addr=inet_addr(n_nslookup(N_DISTRO_SERVER));
|
||||
socka.sin_family=AF_INET;
|
||||
socka.sin_port=htons(N_DISTRO_SERVER_PORT);
|
||||
|
||||
if (connect(fd, (struct sockaddr *)&socka, sizeof(struct sockaddr))!=0) {
|
||||
n_Error("connect()");
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
r=read(fd, serverline, sizeof(serverline));
|
||||
if (r==-1) {
|
||||
n_Error("read()");
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
server=strstr(serverline, ":");
|
||||
if (!server) {
|
||||
n_Error("No port token?");
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*server='\0';
|
||||
server++;
|
||||
port=atoi(server);
|
||||
server=serverline;
|
||||
|
||||
strncpy(theserver.address, server, sizeof(theserver.address));
|
||||
theserver.port=port;
|
||||
|
||||
n_Debug("Server: %s Port: %d", theserver.address, theserver.port);
|
||||
close(fd);
|
||||
return &theserver;
|
||||
}
|
||||
|
||||
char *n_nslookup(char *addr) {
|
||||
struct hostent *h;
|
||||
if ((h=gethostbyname(addr)) == NULL) {
|
||||
return addr;
|
||||
}
|
||||
return (char *)inet_ntoa(*((struct in_addr *)h->h_addr));
|
||||
}
|
||||
|
||||
int n_Connect(_N_SERVER *s, _N_AUTH *a) {
|
||||
int r, port;
|
||||
struct sockaddr_in socka;
|
||||
|
||||
n_serverfd=socket(AF_INET, SOCK_STREAM, 0);
|
||||
socka.sin_addr.s_addr=inet_addr(n_nslookup(s->address));
|
||||
socka.sin_family=AF_INET;
|
||||
socka.sin_port=htons(s->port);
|
||||
|
||||
if (connect(n_serverfd, (struct sockaddr *)&socka, sizeof(struct sockaddr))!=0) {
|
||||
n_Error("connect()");
|
||||
close(n_serverfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
n_Debug("Connected");
|
||||
|
||||
n_SendCommand(CMDS_LOGIN, "%s %s %d \"v2.0 BETA 3\" %d", a->username, a->password, n_dataport, n_connectionspeed);
|
||||
{
|
||||
_N_COMMAND *cmd;
|
||||
cmd=n_GetCommand();
|
||||
if (cmd->cmd[2]==CMDR_ERROR) {
|
||||
n_Error("%s", cmd->data);
|
||||
return 0;
|
||||
} else {
|
||||
n_HandleCommand(cmd);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void n_HandleCommand(_N_COMMAND *cmd) {
|
||||
switch (cmd->cmd[2]) {
|
||||
case CMDR_MOTD:
|
||||
if (n_HookMotd) {
|
||||
n_HookMotd(cmd->data);
|
||||
} else {
|
||||
n_Debug("No motd hook installed");
|
||||
}
|
||||
break;
|
||||
case CMDR_STATS:
|
||||
/*
|
||||
D:napi.c:n_GetCommand():171:Data: 2104 197246 798
|
||||
2104==Libraries
|
||||
197246==songs
|
||||
798==gigs
|
||||
*/
|
||||
if (n_HookStats) {
|
||||
_N_STATS s;
|
||||
if (sscanf(cmd->data, "%d %d %d",
|
||||
&s.libraries, &s.songs, &s.gigs)!=3) {
|
||||
n_Error("Too few args");
|
||||
}
|
||||
else n_HookStats(&s);
|
||||
} else {
|
||||
n_Debug("No stats hook installed");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void n_SendCommand(_N_CMD ncmd, char *fmt, ...) {
|
||||
char buff[2048];
|
||||
_N_COMMAND command;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
command.cmd[0]=vsnprintf(buff, sizeof(buff), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
command.cmd[1]='\0';
|
||||
command.cmd[2]=ncmd;
|
||||
command.cmd[3]='\0';
|
||||
|
||||
n_Debug("Flags: %d %d %d %d", command.cmd[0], command.cmd[1], command.cmd[2], command.cmd[3]);
|
||||
n_Debug("Data: %s", buff);
|
||||
|
||||
n_Send(command.cmd, sizeof(command.cmd));
|
||||
n_Send(buff, command.cmd[0]);
|
||||
}
|
||||
|
||||
int n_Send(char *data, int s) {
|
||||
return write(n_serverfd, data, s);
|
||||
}
|
||||
|
||||
int n_Loop(void) {
|
||||
int sret;
|
||||
struct timeval tv;
|
||||
fd_set rfd;
|
||||
FD_ZERO(&rfd);
|
||||
FD_SET(n_serverfd, &rfd);
|
||||
tv.tv_sec=0;
|
||||
tv.tv_usec=0;
|
||||
|
||||
sret = select(n_serverfd+1, &rfd, NULL, NULL, &tv);
|
||||
if (sret>0) {
|
||||
if (FD_ISSET(n_serverfd, &rfd)) {
|
||||
n_DoCommand();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_N_COMMAND *n_GetCommand(void) {
|
||||
static char rbuff[1024];
|
||||
static _N_COMMAND command;
|
||||
read(n_serverfd, command.cmd, sizeof(command.cmd));
|
||||
if (command.cmd[1]==0) {
|
||||
int r;
|
||||
assert(sizeof(rbuff) > command.cmd[0]);
|
||||
r=n_ReadCount(rbuff, command.cmd[0]);
|
||||
} else {
|
||||
int r=0;
|
||||
int cc=command.cmd[3]+1;
|
||||
while(cc>0) {
|
||||
assert(sizeof(rbuff) > r);
|
||||
if (read(n_serverfd, &rbuff[r], sizeof(char))==1) r++;
|
||||
if (rbuff[r-1]=='.') cc--;
|
||||
}
|
||||
rbuff[r]=0;
|
||||
}
|
||||
command.data=rbuff;
|
||||
n_Debug("Flags: %d %d %d %d", command.cmd[0], command.cmd[1], command.cmd[2], command.cmd[3]);
|
||||
n_Debug("Data: %s", command.data);
|
||||
return &command;
|
||||
}
|
||||
|
||||
void n_DoCommand(void) {
|
||||
_N_COMMAND *cmd;
|
||||
cmd=n_GetCommand();
|
||||
n_HandleCommand(cmd);
|
||||
}
|
||||
|
||||
int n_ReadCount(char *buff, int c) {
|
||||
int rc=0;
|
||||
while (c>rc) {
|
||||
if (read(n_serverfd, &buff[rc], sizeof(char))==1) rc++;
|
||||
}
|
||||
buff[rc]=0;
|
||||
}
|
||||
|
||||
void n_SetMotdHook(void (*f)(char *)) {
|
||||
n_HookMotd=f;
|
||||
n_Debug("Installed motd hook");
|
||||
}
|
||||
|
||||
void n_SetStatsHook(void (*f)(_N_STATS *)) {
|
||||
n_HookStats=f;
|
||||
n_Debug("Installed stats hook");
|
||||
}
|
||||
|
||||
99
dll/nap/dragonap/napi/napi.h
Normal file
99
dll/nap/dragonap/napi/napi.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
napster code base by Drago (drago@0x00.org)
|
||||
released: 11-30-99
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "commands.h"
|
||||
|
||||
#ifndef NAPI_H
|
||||
#define NAPI_H
|
||||
|
||||
int n_serverfd;
|
||||
int n_connectionspeed;
|
||||
int n_dataport;
|
||||
|
||||
#define N_DEBUG
|
||||
#define N_DISTRO_SERVER "server.napster.com"
|
||||
#define N_DISTRO_SERVER_PORT 8875
|
||||
|
||||
/* Error faculty */
|
||||
#define n_Error(fmt, args...) \
|
||||
do { \
|
||||
fprintf(stderr, "E:%s:%s():%d:%s:", __FILE__, __FUNCTION__, __LINE__, strerror(errno)); \
|
||||
fprintf(stderr, fmt, ## args); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while (0)
|
||||
|
||||
/* Debug faculty.....duh? */
|
||||
#ifdef N_DEBUG
|
||||
# define n_Debug(fmt, args...) \
|
||||
do { \
|
||||
fprintf(stderr, "D:%s:%s():%d:", __FILE__, __FUNCTION__, __LINE__); \
|
||||
fprintf(stderr, fmt, ## args); \
|
||||
fprintf(stderr, "\n"); \
|
||||
} while (0)
|
||||
#else
|
||||
# define n_Debug(fmt, args...) (void)0
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char address[100];
|
||||
int port;
|
||||
} _N_SERVER;
|
||||
|
||||
typedef struct {
|
||||
char username[100];
|
||||
char password[100];
|
||||
} _N_AUTH;
|
||||
|
||||
typedef unsigned char _N_CMD;
|
||||
|
||||
typedef struct {
|
||||
_N_CMD cmd[4];
|
||||
char *data;
|
||||
} _N_COMMAND;
|
||||
|
||||
typedef struct {
|
||||
int libraries;
|
||||
int gigs;
|
||||
int songs;
|
||||
} _N_STATS;
|
||||
|
||||
/* Get a napster server */
|
||||
_N_SERVER *n_GetServer(void);
|
||||
|
||||
/* Connect to a napster server */
|
||||
int n_Connect(_N_SERVER *, _N_AUTH *);
|
||||
|
||||
/* nslookup helper function */
|
||||
char *n_nslookup(char *addr);
|
||||
|
||||
/* Send a napster command */
|
||||
void n_SendCommand(_N_CMD, char *, ...);
|
||||
|
||||
/* Send raw napster data */
|
||||
int n_Send(char *, int);
|
||||
|
||||
/* This is the main napster loop */
|
||||
int n_Loop(void);
|
||||
|
||||
/* Command handler */
|
||||
_N_COMMAND *n_GetCommand(void);
|
||||
|
||||
/* Force a read of X bytes */
|
||||
int n_ReadCount(char *, int);
|
||||
|
||||
/* MOTD hook handling */
|
||||
void (*n_HookMotd)(char *);
|
||||
void n_SetMotdHook(void (*)(char *));
|
||||
|
||||
/* Stats hook handling */
|
||||
void (*n_HookStats)(_N_STATS *);
|
||||
void n_SetStatsHook(void (*)(_N_STATS *));
|
||||
|
||||
void n_DoCommand(void);
|
||||
void n_HandleCommand(_N_COMMAND *);
|
||||
|
||||
#endif
|
||||
67
dll/nap/dragonap/napster/args.c
Normal file
67
dll/nap/dragonap/napster/args.c
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
napster code base by Drago (drago@0x00.org)
|
||||
released: 11-30-99
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main(void) {
|
||||
char **argv;
|
||||
|
||||
printf("%d\n", getargs(strdup("buddhempseed 1916592664 6699 \"E:\\New
|
||||
Folder\\mp3\\Korn - Twist Chi.mp3\" 7cf872d13eed1822b840144d77dc5329 7"),
|
||||
&argv));
|
||||
|
||||
}
|
||||
|
||||
int getargs(char *s, char ***sargs) {
|
||||
char *orig;
|
||||
int escape=0;
|
||||
char *beginword;
|
||||
char *endword;
|
||||
char **args=NULL;
|
||||
int argc=0;
|
||||
int myidx=0;
|
||||
|
||||
beginword=s;
|
||||
endword=NULL;
|
||||
|
||||
while (1) {
|
||||
switch(*s) {
|
||||
case '"':
|
||||
escape^=1;
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
if (!escape)
|
||||
endword=s;
|
||||
break;
|
||||
}
|
||||
s++;
|
||||
if (*s=='\0') endword=s;
|
||||
if (endword) {
|
||||
int len=endword-beginword;
|
||||
char tmp[len+1];
|
||||
strncpy(tmp, beginword, len);
|
||||
tmp[len]=0;
|
||||
endword=NULL;
|
||||
beginword=s;
|
||||
myidx=argc;
|
||||
argc++;
|
||||
args=(char **) realloc(args, sizeof(char *) * argc);
|
||||
assert(args!=NULL);
|
||||
args[myidx]=strdup(tmp);
|
||||
}
|
||||
if (!*s) break;
|
||||
}
|
||||
myidx=argc;
|
||||
argc++;
|
||||
args=(char **) realloc(args, sizeof(char *) * argc);
|
||||
assert(args!=NULL);
|
||||
args[myidx]=NULL;
|
||||
*sargs=args;
|
||||
return argc-1;
|
||||
}
|
||||
|
||||
2
dll/nap/dragonap/napster/blah
Normal file
2
dll/nap/dragonap/napster/blah
Normal file
@@ -0,0 +1,2 @@
|
||||
GETdragotest "C:\napster2\Music\test.mp3" 0
|
||||
|
||||
505
dll/nap/dragonap/napster/nappy.c
Normal file
505
dll/nap/dragonap/napster/nappy.c
Normal file
@@ -0,0 +1,505 @@
|
||||
/*
|
||||
napster code base by Drago (drago@0x00.org)
|
||||
released: 11-30-99
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/shm.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
//#define PACKET_FILE "10.0.0.115.1165-208.178.163.58.8888"
|
||||
|
||||
//#define PACKET_FILE "10.0.0.115.1146-208.178.163.58.7777"
|
||||
//#define PACKET_FILE "208.178.163.58.6666-10.0.0.115.1117"
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#define D(fmt, args...) fprintf(stderr, fmt, ## args)
|
||||
#else
|
||||
#define D(fmt, args...) (void)0
|
||||
#endif
|
||||
|
||||
#define I(fmt, args...) fprintf(stdout, fmt, ## args)
|
||||
|
||||
#define E(fmt, args...) fprintf(stderr, fmt, ## args)
|
||||
|
||||
|
||||
typedef unsigned char COMMAND;
|
||||
|
||||
char *nslookup(char *addr);
|
||||
int connect_to(char *to, int port);
|
||||
|
||||
void NAP_login(void);
|
||||
int NAP_send(char *, int);
|
||||
void NAP_disconnect(void);
|
||||
void NAP_connect(void);
|
||||
void NAP_loop(void);
|
||||
void NAP_getcommand(void);
|
||||
void NAP_addfile(char *, char *, int, int, int, int);
|
||||
int NAP_readcount(char *, int);
|
||||
void KB_getcommand(void);
|
||||
void NAP_search(char *);
|
||||
int getargs(char *, char ***);
|
||||
void freeargs(char **);
|
||||
char *argstring(char **);
|
||||
void NAP_requestfile(char *, char *);
|
||||
void NAP_getfile(char *);
|
||||
char *basefile(char *);
|
||||
|
||||
char *username;
|
||||
char *password;
|
||||
int dataport=0;
|
||||
int connectionspeed=6;
|
||||
|
||||
enum recv_Commands {
|
||||
CMDR_STATS=214,
|
||||
CMDR_EMAILADDR=3,
|
||||
CMDR_MOTD=109,
|
||||
CMDR_SEARCHRESULTS=201,
|
||||
CMDR_SEARCHRESULTSEND=202,
|
||||
CMDR_ERROR=0,
|
||||
CMDR_ANOTHERUSER=148,
|
||||
CMDR_SENDFILE=95,
|
||||
CMDR_USERSPEED=209,
|
||||
CMDR_REQUESTUSERSPEED=89,
|
||||
CMDR_FILEREADY=204,
|
||||
CMDR_GETERROR=206,
|
||||
CMDR_GETQUEUE=108
|
||||
};
|
||||
|
||||
|
||||
enum send_Commands {
|
||||
CMDS_LOGIN=2,
|
||||
CMDS_SEARCH=200,
|
||||
CMDS_REQUESTFILE=203,
|
||||
CMDS_ADDFILE=100,
|
||||
CMDS_ADDHOTLIST=208
|
||||
};
|
||||
|
||||
int NAP_fd;
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc<3) {
|
||||
I("nappy v0.1Beta1 By Drago (drago@0x00.org)\n");
|
||||
I("Usage: %s <username> <password> [line speed]\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
username=argv[1];
|
||||
password=argv[2];
|
||||
if (argc>3) connectionspeed=atoi(argv[3]);
|
||||
NAP_connect();
|
||||
NAP_login();
|
||||
NAP_loop();
|
||||
NAP_disconnect();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void NAP_loop() {
|
||||
int sret;
|
||||
struct timeval tv, tmptv;
|
||||
fd_set rfd, tmprfd;
|
||||
FD_ZERO(&rfd);
|
||||
FD_SET(NAP_fd, &rfd);
|
||||
FD_SET(STDIN_FILENO, &rfd);
|
||||
tv.tv_sec=1;
|
||||
tv.tv_usec=0;
|
||||
while (1) {
|
||||
tmprfd=rfd;
|
||||
tmptv=tv;
|
||||
sret = select(NAP_fd+1, &tmprfd, NULL, NULL, &tmptv);
|
||||
if (sret>0) {
|
||||
if (FD_ISSET(NAP_fd, &tmprfd)) {
|
||||
NAP_getcommand();
|
||||
}
|
||||
if (FD_ISSET(STDIN_FILENO, &tmprfd)) {
|
||||
KB_getcommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NAP_sendcommand(COMMAND ncmd, char *fmt, ...) {
|
||||
char buff[2048];
|
||||
COMMAND cmd[4];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
cmd[0]=vsnprintf(buff, sizeof(buff), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
cmd[1]='\0';
|
||||
cmd[2]=ncmd;
|
||||
cmd[3]='\0';
|
||||
|
||||
D("Send Flags: %d %d %d %d\n", cmd[0], cmd[1], cmd[2], cmd[3]);
|
||||
D("Send Data: %s\n", buff);
|
||||
|
||||
NAP_send(cmd, 4);
|
||||
NAP_send(buff, cmd[0]);
|
||||
}
|
||||
|
||||
void NAP_getcommand(void) {
|
||||
char rbuff[1024];
|
||||
static COMMAND cmd[4];
|
||||
read(NAP_fd, cmd, sizeof(cmd));
|
||||
if (cmd[1]==0) {
|
||||
int r;
|
||||
assert(sizeof(rbuff) > cmd[0]);
|
||||
r=NAP_readcount(rbuff, cmd[0]);
|
||||
} else {
|
||||
int r=0;
|
||||
int cc=cmd[3]+1;
|
||||
while(cc>0) {
|
||||
assert(sizeof(rbuff) > r);
|
||||
if (read(NAP_fd, &rbuff[r], sizeof(char))==1) r++;
|
||||
if (rbuff[r-1]=='.') cc--;
|
||||
}
|
||||
rbuff[r]=0;
|
||||
}
|
||||
|
||||
D("Recv Flags: %d %d %d %d\n", cmd[0], cmd[1], cmd[2], cmd[3]);
|
||||
D("Recv Data: %s\n", rbuff);
|
||||
|
||||
switch(cmd[2]) {
|
||||
case CMDR_GETQUEUE:
|
||||
I("Added to get queue: %s\n", rbuff);
|
||||
break;
|
||||
case CMDR_REQUESTUSERSPEED:
|
||||
I("Requested user speed: %s\n", rbuff);
|
||||
break;
|
||||
case CMDR_GETERROR:
|
||||
I("Get error: %s\n", rbuff);
|
||||
break;
|
||||
case CMDR_FILEREADY:
|
||||
I("File is ready: %s\n", rbuff);
|
||||
NAP_getfile(rbuff);
|
||||
break;
|
||||
case CMDR_USERSPEED:
|
||||
I("User speed: %s\n", rbuff);
|
||||
break;
|
||||
case CMDR_SENDFILE:
|
||||
I("Someone trying to get file: %s\n", rbuff);
|
||||
break;
|
||||
|
||||
case CMDR_ANOTHERUSER:
|
||||
I("Another user has logged in as you!\n");
|
||||
exit(1);
|
||||
break;
|
||||
|
||||
case CMDR_ERROR:
|
||||
E("Error: %s\n", rbuff);
|
||||
break;
|
||||
|
||||
case CMDR_SEARCHRESULTS:
|
||||
I("Search results: %s\n", rbuff);
|
||||
break;
|
||||
|
||||
case CMDR_SEARCHRESULTSEND:
|
||||
I("End of search results\n");
|
||||
break;
|
||||
|
||||
case CMDR_STATS:
|
||||
I("Got stats: %s\n", rbuff);
|
||||
break;
|
||||
|
||||
case CMDR_EMAILADDR:
|
||||
I("Email address: %s\n", rbuff);
|
||||
break;
|
||||
|
||||
case CMDR_MOTD:
|
||||
I("Message: %s\n", rbuff);
|
||||
break;
|
||||
|
||||
default:
|
||||
E("Unknown command: %d\n", cmd[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int NAP_readcount(char *buff, int c) {
|
||||
int rc=0;
|
||||
while (c>rc) {
|
||||
if (read(NAP_fd, &buff[rc], sizeof(char))==1) rc++;
|
||||
}
|
||||
buff[rc]=0;
|
||||
}
|
||||
|
||||
void NAP_disconnect(void) {
|
||||
close(NAP_fd);
|
||||
}
|
||||
|
||||
void NAP_connect(void) {
|
||||
#ifdef PACKET_FILE
|
||||
NAP_fd=open(PACKET_FILE, O_RDONLY);
|
||||
#else
|
||||
NAP_fd=connect_to("208.178.163.59", 8888);
|
||||
#endif
|
||||
if (!NAP_fd>0) {
|
||||
E("Error making connection.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void NAP_login(void) {
|
||||
int c;
|
||||
char loginstr[1024];
|
||||
c=snprintf(loginstr, sizeof(loginstr), "%s %s %d \"v2.0 BETA 3\" %d", username, password, dataport, connectionspeed);
|
||||
NAP_sendcommand(CMDS_LOGIN, loginstr);
|
||||
}
|
||||
|
||||
int NAP_send(char *data, int s) {
|
||||
return write(NAP_fd, data, s);
|
||||
}
|
||||
|
||||
int connect_to(char *to, int port) {
|
||||
struct sockaddr_in socka;
|
||||
int fd;
|
||||
fd=socket(AF_INET, SOCK_STREAM, 0);
|
||||
socka.sin_addr.s_addr=inet_addr(nslookup(to));
|
||||
socka.sin_family=AF_INET;
|
||||
socka.sin_port=htons(port);
|
||||
if (connect(fd, (struct sockaddr *)&socka, sizeof(struct sockaddr))!=0) {
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
char *nslookup(char *addr) {
|
||||
struct hostent *h;
|
||||
if ((h=gethostbyname(addr)) == NULL) {
|
||||
return addr;
|
||||
}
|
||||
return (char *)inet_ntoa(*((struct in_addr *)h->h_addr)) ;
|
||||
}
|
||||
|
||||
void KB_getcommand(void) {
|
||||
char **argv=NULL;
|
||||
int argc;
|
||||
char buff[1024];
|
||||
fgets(buff, sizeof(buff), stdin);
|
||||
buff[strlen(buff)-1]=0;
|
||||
argc=getargs(buff, &argv);
|
||||
|
||||
if (argc>0) {
|
||||
if (!strcasecmp(argv[0], "raw")) {
|
||||
if (argc==1) {
|
||||
I("raw <command id> <data>\n");
|
||||
} else {
|
||||
char *data;
|
||||
if (argc==2) NAP_sendcommand(atoi(argv[1]), "");
|
||||
else {
|
||||
data=argstring(&argv[2]);
|
||||
NAP_sendcommand(atoi(argv[1]), data);
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(argv[0], "get")) {
|
||||
if (argc<3) {
|
||||
I("get <name> <file>\n");
|
||||
} else {
|
||||
char *f;
|
||||
f=argstring(&argv[2]);
|
||||
NAP_requestfile(argv[1], f);
|
||||
free(f);
|
||||
}
|
||||
} else if (!strcasecmp(argv[0], "search")) {
|
||||
if (argc==1) {
|
||||
I("search <file>");
|
||||
} else {
|
||||
char *s;
|
||||
s=argstring(&argv[1]);
|
||||
NAP_search(s);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
freeargs(argv);
|
||||
|
||||
// NAP_sendcommand(CMDS_GETFILE, "Avenger713 \"The A-Team Theme.mp3\"");
|
||||
|
||||
}
|
||||
|
||||
void NAP_search(char *string) {
|
||||
/*
|
||||
FILENAME CONTAINS \"filename\" MAX_RESULTS 100000
|
||||
*/
|
||||
|
||||
NAP_sendcommand(CMDS_SEARCH, "FILENAME CONTAINS \"%s\" MAX_RESULTS 10", string);
|
||||
}
|
||||
|
||||
void NAP_addfile(char *filen, char *checksum, int size, int bitrate, int freq, int length) {
|
||||
/*
|
||||
Recv Flags: 121 0 100 0
|
||||
Recv Data: "C:\napster2\Music\Korn - Follow The Leader - 15 - Got The Life.mp3"
|
||||
fd40cd10955270701dd169d4e6739858 749568 160 44100 37
|
||||
*/
|
||||
NAP_sendcommand(CMDS_ADDFILE, "\"%s\" %s %d %d %d %d", filen, checksum, size, bitrate, freq, length);
|
||||
}
|
||||
|
||||
void NAP_requestfile(char *from, char *file) {
|
||||
NAP_sendcommand(CMDS_REQUESTFILE, "%s \"%s\"", from, file);
|
||||
}
|
||||
|
||||
int getargs(char *s, char ***sargs) {
|
||||
char *orig;
|
||||
int escape=0;
|
||||
char *beginword;
|
||||
char *endword;
|
||||
char **args=NULL;
|
||||
int argc=0;
|
||||
int myidx=0;
|
||||
|
||||
beginword=s;
|
||||
endword=NULL;
|
||||
|
||||
while (1) {
|
||||
switch(*s) {
|
||||
case '"':
|
||||
escape^=1;
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
if (!escape)
|
||||
endword=s;
|
||||
break;
|
||||
}
|
||||
s++;
|
||||
if (*s=='\0') endword=s;
|
||||
if (endword) {
|
||||
int len=endword-beginword;
|
||||
char tmp[len+1];
|
||||
strncpy(tmp, beginword, len);
|
||||
tmp[len]=0;
|
||||
endword=NULL;
|
||||
beginword=s;
|
||||
myidx=argc;
|
||||
argc++;
|
||||
args=(char **) realloc(args, sizeof(char *) * argc);
|
||||
assert(args!=NULL);
|
||||
args[myidx]=strdup(tmp);
|
||||
}
|
||||
if (!*s) break;
|
||||
}
|
||||
myidx=argc;
|
||||
argc++;
|
||||
args=(char **) realloc(args, sizeof(char *) * argc);
|
||||
assert(args!=NULL);
|
||||
args[myidx]=NULL;
|
||||
*sargs=args;
|
||||
return argc-1;
|
||||
}
|
||||
|
||||
void freeargs(char **args) {
|
||||
char **save=args;
|
||||
while (*args) {
|
||||
free(*args);
|
||||
args++;
|
||||
}
|
||||
free(save);
|
||||
}
|
||||
|
||||
char *argstring(char **start) {
|
||||
char *buildit=NULL;
|
||||
int len=0;
|
||||
int addl=0;
|
||||
|
||||
while (*start) {
|
||||
addl=strlen(*start);
|
||||
buildit=(char *) realloc(buildit, addl+len+2);
|
||||
assert(buildit!=NULL);
|
||||
strncpy(&buildit[len], *start, addl);
|
||||
len+=addl;
|
||||
buildit[len]=' ';
|
||||
buildit[len+1]='\0';
|
||||
len++;
|
||||
start++;
|
||||
}
|
||||
if (buildit!=NULL) {
|
||||
buildit[len-1]=0;
|
||||
}
|
||||
return buildit;
|
||||
}
|
||||
|
||||
void NAP_getfile(char *data) {
|
||||
/*
|
||||
gato242 3068149784 6699 "d:\mp3\Hackers_-_07_-_Orbital_-_Halcyon_&_On_&_On.mp3"
|
||||
8b451240c17fec98ea4f63e26bd42c60 7
|
||||
*/
|
||||
|
||||
int getfd, argc, port, linespeed, outfd, rc;
|
||||
unsigned long int longip;
|
||||
char getcmd[1024], cip[20], **argv, *nick, *ip, *file, *checksum;
|
||||
char indata[1024];
|
||||
char *fixedfile, c;
|
||||
char *savefile;
|
||||
struct sockaddr_in socka;
|
||||
argc=getargs(data, &argv);
|
||||
nick=argv[0];
|
||||
ip=argv[1];
|
||||
port=atoi(argv[2]);
|
||||
file=argv[3];
|
||||
checksum=argv[4];
|
||||
linespeed=atoi(argv[5]);
|
||||
getfd=socket(AF_INET, SOCK_STREAM, 0);
|
||||
socka.sin_addr.s_addr=atol(ip);
|
||||
socka.sin_family=AF_INET;
|
||||
socka.sin_port=htons(port);
|
||||
if (connect(getfd, (struct sockaddr *)&socka, sizeof(struct sockaddr))!=0) {
|
||||
E("error connecting to file host (%s)\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
read(getfd, &c, sizeof(c));
|
||||
snprintf(getcmd, sizeof(getcmd), "GET");
|
||||
write(getfd, getcmd, strlen(getcmd));
|
||||
sleep(1);
|
||||
snprintf(getcmd, sizeof(getcmd), "%s %s 0", username, file);
|
||||
write(getfd, getcmd, strlen(getcmd));
|
||||
|
||||
fixedfile=file;
|
||||
fixedfile++;
|
||||
fixedfile[strlen(fixedfile)-1]=0;
|
||||
|
||||
savefile=basefile(fixedfile);
|
||||
|
||||
outfd=open(savefile, O_CREAT|O_EXCL|O_WRONLY);
|
||||
if (!outfd) {
|
||||
E("Error opening output file %s: %s\n", savefile, strerror(errno));
|
||||
return;
|
||||
}
|
||||
if (fork()) return;
|
||||
I("New child has been spawned with pid %d for download of %s from %s\n", getpid(), savefile, nick);
|
||||
while ((rc=read(getfd, indata, sizeof(indata)))>0) {
|
||||
if (rc==0) continue;
|
||||
write(outfd, indata, rc);
|
||||
}
|
||||
I("File %s from %s done!\n", savefile, nick);
|
||||
close(getfd);
|
||||
close(outfd);
|
||||
}
|
||||
|
||||
char *basefile(char *s) {
|
||||
char *lastslash;
|
||||
lastslash=strrchr(s, '\\');
|
||||
if (!lastslash) return basename(s);
|
||||
lastslash++;
|
||||
return basename(lastslash);
|
||||
}
|
||||
|
||||
288
dll/nap/md5.c
Normal file
288
dll/nap/md5.c
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
/* for memcpy() */
|
||||
#include "md5.h"
|
||||
|
||||
#ifndef HIGHFIRST
|
||||
#define byteReverse(buf, len)
|
||||
/* Nothing */
|
||||
#else
|
||||
void byteReverse(unsigned char *buf, unsigned longs);
|
||||
|
||||
#ifndef ASM_MD5
|
||||
/*
|
||||
* Note: this code is harmless on little-endian machines.
|
||||
*/
|
||||
void byteReverse(unsigned char *buf, unsigned longs)
|
||||
{
|
||||
uint32 t;
|
||||
do {
|
||||
|
||||
t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
|
||||
|
||||
((unsigned) buf[1] << 8 | buf[0]);
|
||||
|
||||
*(uint32 *) buf = t;
|
||||
|
||||
buf += 4;
|
||||
} while (--longs);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||
* initialization constants.
|
||||
*/
|
||||
void MD5Init(struct MD5Context *ctx)
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bits[0] = 0;
|
||||
ctx->bits[1] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update context to reflect the concatenation of another buffer full
|
||||
* of bytes.
|
||||
*/
|
||||
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
|
||||
{
|
||||
uint32 t;
|
||||
|
||||
/* Update bitcount */
|
||||
|
||||
t = ctx->bits[0];
|
||||
if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
|
||||
|
||||
ctx->bits[1]++;
|
||||
|
||||
/* Carry from low to high */
|
||||
ctx->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f;
|
||||
/* Bytes already in shsInfo->data */
|
||||
|
||||
/* Handle any leading odd-sized chunks */
|
||||
|
||||
if (t) {
|
||||
|
||||
unsigned char *p = (unsigned char *) ctx->in + t;
|
||||
|
||||
|
||||
t = 64 - t;
|
||||
|
||||
if (len < t) {
|
||||
|
||||
memcpy(p, buf, len);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
memcpy(p, buf, t);
|
||||
|
||||
byteReverse(ctx->in, 16);
|
||||
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
|
||||
buf += t;
|
||||
|
||||
len -= t;
|
||||
}
|
||||
/* Process data in 64-byte chunks */
|
||||
|
||||
while (len >= 64) {
|
||||
|
||||
memcpy(ctx->in, buf, 64);
|
||||
|
||||
byteReverse(ctx->in, 16);
|
||||
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
|
||||
buf += 64;
|
||||
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
|
||||
{
|
||||
unsigned count;
|
||||
unsigned char *p;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
count = (ctx->bits[0] >> 3) & 0x3F;
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
p = ctx->in + count;
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 64 bytes */
|
||||
count = 64 - 1 - count;
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if (count < 8) {
|
||||
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
|
||||
memset(p, 0, count);
|
||||
|
||||
byteReverse(ctx->in, 16);
|
||||
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
|
||||
memset(ctx->in, 0, 56);
|
||||
} else {
|
||||
|
||||
/* Pad block to 56 bytes */
|
||||
|
||||
memset(p, 0, count - 8);
|
||||
}
|
||||
byteReverse(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
((uint32 *) ctx->in)[14] = ctx->bits[0];
|
||||
((uint32 *) ctx->in)[15] = ctx->bits[1];
|
||||
|
||||
MD5Transform(ctx->buf, (uint32 *) ctx->in);
|
||||
byteReverse((unsigned char *) ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(ctx));
|
||||
/* In case it's sensitive */
|
||||
}
|
||||
|
||||
#ifndef ASM_MD5
|
||||
|
||||
/* The four core functions - F1 is optimized somewhat */
|
||||
|
||||
/* #define F1(x, y, z) (x & y | ~x & z) */
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define F2(x, y, z) F1(z, x, y)
|
||||
#define F3(x, y, z) (x ^ y ^ z)
|
||||
#define F4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
/* This is the central step in the MD5 algorithm. */
|
||||
#define MD5STEP(f, w, x, y, z, data, s) ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
|
||||
|
||||
/*
|
||||
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
* reflect the addition of 16 longwords of new data. MD5Update blocks
|
||||
* the data and converts bytes into longwords for this routine.
|
||||
*/
|
||||
void MD5Transform(uint32 buf[4], uint32 const in[16])
|
||||
{
|
||||
register uint32 a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
35
dll/nap/md5.h
Normal file
35
dll/nap/md5.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef MD5_H
|
||||
#define MD5_H
|
||||
|
||||
#ifdef __alpha
|
||||
typedef unsigned int uint32;
|
||||
#else
|
||||
typedef unsigned long uint32;
|
||||
#endif
|
||||
|
||||
struct MD5Context {
|
||||
|
||||
uint32 buf[4];
|
||||
|
||||
uint32 bits[2];
|
||||
|
||||
unsigned char in[64];
|
||||
};
|
||||
|
||||
void MD5Init(struct MD5Context *context);
|
||||
void MD5Update(struct MD5Context *context, unsigned char const *buf,
|
||||
unsigned len);
|
||||
void MD5Final(unsigned char digest[16], struct MD5Context *context);
|
||||
void MD5Transform(uint32 buf[4], uint32 const in[16]);
|
||||
|
||||
/*
|
||||
* This is needed to make RSAREF happy on some MS-DOS compilers.
|
||||
*/
|
||||
typedef struct MD5Context MD5_CTX;
|
||||
#define md5_init MD5Init
|
||||
#define md5_state_t MD5_CTX
|
||||
#define md5_append MD5Update
|
||||
#define md5_finish MD5Final
|
||||
|
||||
#endif /* !MD5_H */
|
||||
|
||||
2371
dll/nap/nap.c
Normal file
2371
dll/nap/nap.c
Normal file
File diff suppressed because it is too large
Load Diff
38
dll/nap/nap.sh
Normal file
38
dll/nap/nap.sh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
# Make .def file:
|
||||
export LIBPATH=/usr/local/cygwin-new/i586-pc-cygwin/lib
|
||||
export LD=/usr/local/cygwin-new/bin/i586-pc-cygwin-ld
|
||||
export NM=/usr/local/cygwin-new/bin/i586-pc-cygwin-nm
|
||||
export DLLTOOL=/usr/local/cygwin-new/bin/i586-pc-cygwin-dlltool
|
||||
export AS=/usr/local/cygwin-new/bin/i586-pc-cygwin-as
|
||||
export GCC=/usr/local/cygwin-new/bin/i586-pc-cygwin-gcc
|
||||
CP=cp
|
||||
RM=rm
|
||||
|
||||
$GCC -I../../include -c nap.c
|
||||
$GCC -I../../include -c md5.c
|
||||
$GCC -I../../include -c nap_file.c
|
||||
$GCC -I../../include -c napfunc.c
|
||||
$GCC -I../../include -c napother.c
|
||||
$GCC -I../../include -c napsend.c
|
||||
|
||||
echo EXPORTS > nap.def
|
||||
$NM nap.o md5.o nap_file.o napfunc.o napother.o napsend.o ../init.o ../fixup.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> nap.def
|
||||
|
||||
# Link DLL.
|
||||
$LD --base-file nap.base --dll -o nap.dll nap.o md5.o nap_file.o napfunc.o napother.o napsend.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname nap.dll --def nap.def --base-file\
|
||||
nap.base --output-exp nap.exp
|
||||
$LD --base-file nap.base nap.exp --dll -o nap.dll nap.o md5.o nap_file.o napfunc.o napother.o napsend.o \
|
||||
../init.o ../fixup.o $LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
$DLLTOOL --as=$AS --dllname nap.dll --def nap.def --base-file\
|
||||
nap.base --output-exp nap.exp
|
||||
$LD nap.exp --dll -o nap.dll nap.o md5.o nap_file.o napfunc.o napother.o napsend.o ../init.o ../fixup.o\
|
||||
$LIBPATH/libcygwin.a $LIBPATH/libkernel32.a -e _dll_entry@12
|
||||
|
||||
# Build the napB.a lib to link to:
|
||||
$DLLTOOL --as=$AS --dllname nap.dll --def nap.def --output-lib nap.a
|
||||
|
||||
$RM *.base *.exp *.def
|
||||
$CP *.dll ..
|
||||
845
dll/nap/nap_file.c
Normal file
845
dll/nap/nap_file.c
Normal file
@@ -0,0 +1,845 @@
|
||||
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "dcc.h"
|
||||
#include "ircaux.h"
|
||||
#include "ctcp.h"
|
||||
#include "cdcc.h"
|
||||
#include "input.h"
|
||||
#include "status.h"
|
||||
#include "lastlog.h"
|
||||
#include "screen.h"
|
||||
#include "vars.h"
|
||||
#include "misc.h"
|
||||
#include "output.h"
|
||||
#include "module.h"
|
||||
#include "hook.h"
|
||||
#include "hash2.h"
|
||||
#include "napster.h"
|
||||
#include "bsdglob.h"
|
||||
#include "modval.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#ifdef HAVE_SYS_FILIO_H
|
||||
#include <sys/filio.h>
|
||||
#endif
|
||||
|
||||
GetFile *getfile_struct = NULL;
|
||||
ResumeFile *resume_struct = NULL;
|
||||
|
||||
|
||||
char *napster_status(void)
|
||||
{
|
||||
int upload = 0;
|
||||
int download = 0;
|
||||
GetFile *tmp;
|
||||
char buffer[NAP_BUFFER_SIZE+1];
|
||||
char tmpbuff[80];
|
||||
double perc = 0.0;
|
||||
if (!get_dllint_var("napster_window"))
|
||||
return m_strdup(empty_string);
|
||||
sprintf(buffer, statistics.shared_files ? "%s [Sh:%lu/%3.2f%s] ": "%s ",
|
||||
nap_current_channel ? nap_current_channel : empty_string,
|
||||
statistics.shared_files, _GMKv(statistics.shared_filesize),
|
||||
_GMKs(statistics.shared_filesize));
|
||||
for (tmp = getfile_struct; tmp; tmp = tmp->next, download++)
|
||||
{
|
||||
if (!tmp->filesize)
|
||||
continue;
|
||||
perc = (100.0 * (((double)(tmp->received + tmp->resume)) / (double)tmp->filesize));
|
||||
sprintf(tmpbuff, "%4.1f%%%%", perc);
|
||||
if (download)
|
||||
strcat(buffer, ",");
|
||||
else
|
||||
strcat(buffer, " [G:");
|
||||
strcat(buffer, tmpbuff);
|
||||
}
|
||||
if (download)
|
||||
strcat(buffer, "]");
|
||||
for (tmp = napster_sendqueue; tmp; tmp = tmp->next, upload++)
|
||||
{
|
||||
if (!tmp->filesize)
|
||||
continue;
|
||||
perc = (100.0 * (((double)(tmp->received + tmp->resume)) / (double)tmp->filesize));
|
||||
sprintf(tmpbuff, "%4.1f%%%%", perc);
|
||||
if (upload)
|
||||
strcat(buffer, ",");
|
||||
else
|
||||
strcat(buffer, " [S:");
|
||||
strcat(buffer, tmpbuff);
|
||||
}
|
||||
if (upload)
|
||||
strcat(buffer, "]");
|
||||
sprintf(tmpbuff, " [U:%d/D:%d]", upload, download);
|
||||
strcat(buffer, tmpbuff);
|
||||
return m_strdup(buffer);
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(nap_del)
|
||||
{
|
||||
int count = 0;
|
||||
GetFile *tmp, *last = NULL;
|
||||
int num;
|
||||
char *t;
|
||||
if (!args && !*args)
|
||||
return;
|
||||
if (*args == '*')
|
||||
{
|
||||
if ((do_hook(MODULE_LIST, "NAP DEL ALL")))
|
||||
nap_say("%s", cparse("Removing ALL file send/upload", NULL));
|
||||
while (getfile_struct)
|
||||
{
|
||||
count++;
|
||||
tmp = getfile_struct;
|
||||
last = tmp->next;
|
||||
if ((do_hook(MODULE_LIST, "NAP DEL GET %s %s", tmp->nick, tmp->filename)))
|
||||
nap_say("%s", cparse("Removing $0 [$1-]", "%s %s", tmp->nick, base_name(tmp->filename)));
|
||||
nap_finished_file(tmp->socket, tmp);
|
||||
getfile_struct = last;
|
||||
send_ncommand(CMDS_UPDATE_GET, NULL);
|
||||
}
|
||||
while (napster_sendqueue)
|
||||
{
|
||||
count++;
|
||||
tmp = napster_sendqueue;
|
||||
last = tmp->next;
|
||||
if ((do_hook(MODULE_LIST, "NAP DEL SEND %s %s", tmp->nick, tmp->filename)))
|
||||
nap_say("%s", cparse("Removing $0 [$1-]", "%s %s", tmp->nick, base_name(tmp->filename)));
|
||||
nap_finished_file(tmp->socket, tmp);
|
||||
napster_sendqueue = last;
|
||||
send_ncommand(CMDS_UPDATE_SEND, NULL);
|
||||
}
|
||||
build_napster_status(NULL);
|
||||
return;
|
||||
}
|
||||
while ((t = next_arg(args, &args)))
|
||||
{
|
||||
char *name = NULL;
|
||||
count = 1;
|
||||
if (!(num = my_atol(t)))
|
||||
name = t;
|
||||
for (tmp = getfile_struct; tmp; tmp = tmp->next, count++)
|
||||
{
|
||||
if ((count == num) || (name && !my_stricmp(name, tmp->nick)))
|
||||
{
|
||||
if (last)
|
||||
last->next = tmp->next;
|
||||
else
|
||||
getfile_struct = tmp->next;
|
||||
if ((do_hook(MODULE_LIST, "NAP DEL GET %s %s", tmp->nick, tmp->filename)))
|
||||
nap_say("%s", cparse("Removing $0 [$1-]", "%s %s", tmp->nick, base_name(tmp->filename)));
|
||||
nap_finished_file(tmp->socket, tmp);
|
||||
build_napster_status(NULL);
|
||||
send_ncommand(CMDS_UPDATE_GET, NULL);
|
||||
return;
|
||||
}
|
||||
last = tmp;
|
||||
}
|
||||
last = NULL;
|
||||
for (tmp = napster_sendqueue; tmp; tmp = tmp->next, count++)
|
||||
{
|
||||
if ((count == num) || (name && !my_stricmp(name, tmp->nick)))
|
||||
{
|
||||
if (last)
|
||||
last->next = tmp->next;
|
||||
else
|
||||
napster_sendqueue = tmp->next;
|
||||
if ((do_hook(MODULE_LIST, "NAP DEL SEND %s %s", tmp->nick, tmp->filename)))
|
||||
nap_say("%s", cparse("Removing $0 [$1-]", "%s %s", tmp->nick, base_name(tmp->filename)));
|
||||
nap_finished_file(tmp->socket, tmp);
|
||||
build_napster_status(NULL);
|
||||
send_ncommand(CMDS_UPDATE_SEND, NULL);
|
||||
return;
|
||||
}
|
||||
last = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(nap_glist)
|
||||
{
|
||||
int count = 1;
|
||||
GetFile *sg = getfile_struct;
|
||||
time_t snow = now;
|
||||
char *dformat = "%W#$[3]0%n %Y$4%n $[14]1 $[-6]2$3 $5/$6 $7-";
|
||||
|
||||
for(sg = getfile_struct; sg; sg = sg->next, count++)
|
||||
{
|
||||
char buff[80];
|
||||
char buff1[80];
|
||||
char buff2[80];
|
||||
char ack[4];
|
||||
double perc = 0.0;
|
||||
if (count == 1)
|
||||
{
|
||||
nap_put("%s", cparse("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%GD%gownloads", NULL));
|
||||
nap_put("%s", cparse("%K<><4B><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", NULL, NULL));
|
||||
}
|
||||
if (sg->starttime)
|
||||
sprintf(buff, "%2.3f", sg->received / 1024.0 / (snow - sg->starttime));
|
||||
else
|
||||
strcpy(buff, "N/A");
|
||||
if (sg->filesize)
|
||||
perc = (100.0 * (((double)(sg->received + sg->resume)) / (double)sg->filesize));
|
||||
sprintf(buff1, "%4.1f%%", perc);
|
||||
sprintf(buff2, "%4.2f", _GMKv(sg->filesize));
|
||||
*ack = 0;
|
||||
if (sg->up & NAP_QUEUED)
|
||||
strcpy(ack, "Q");
|
||||
strcat(ack, sg->starttime ? "D" : "W");
|
||||
nap_put("%s", cparse(dformat, "%d %s %s %s %s %s %s %s",
|
||||
count, sg->nick, buff2, _GMKs(sg->filesize),
|
||||
ack, buff, buff1, base_name(sg->filename)));
|
||||
}
|
||||
for (sg = napster_sendqueue; sg; sg = sg->next, count++)
|
||||
{
|
||||
char buff[80];
|
||||
char buff1[80];
|
||||
char buff2[80];
|
||||
char ack[10];
|
||||
double perc = 0.0;
|
||||
if (count == 1)
|
||||
{
|
||||
nap_put("%s", cparse("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%GU%gploads", NULL));
|
||||
nap_put("%s", cparse("%K<><4B><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD>%n<>%W<>%n<>%K<><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", NULL, NULL));
|
||||
}
|
||||
if (sg->starttime)
|
||||
sprintf(buff, "%2.3f", sg->received / 1024.0 / (snow - sg->starttime));
|
||||
else
|
||||
strcpy(buff, "N/A");
|
||||
if (sg->filesize)
|
||||
perc = (100.0 * (((double)(sg->received + sg->resume)) / (double)sg->filesize));
|
||||
sprintf(buff1, "%4.1f%%", perc);
|
||||
sprintf(buff2, "%4.2f", _GMKv(sg->filesize));
|
||||
*ack = 0;
|
||||
if (sg->up & NAP_QUEUED)
|
||||
strcpy(ack, "Q");
|
||||
strcat(ack, sg->starttime ? "U" : "W");
|
||||
nap_put("%s", cparse(dformat, "%d %s %s %s %s %s %s %s",
|
||||
count, sg->nick, buff2, _GMKs(sg->filesize),
|
||||
ack, buff, buff1, base_name(sg->filename)));
|
||||
}
|
||||
}
|
||||
|
||||
NAP_COMM(cmd_resumerequest)
|
||||
{
|
||||
char *nick, *file, *checksum;
|
||||
int port;
|
||||
unsigned long filesize;
|
||||
unsigned long ip;
|
||||
int speed;
|
||||
int count = 0;
|
||||
ResumeFile *sf;
|
||||
|
||||
nick = next_arg(args, &args);
|
||||
ip = my_atol(next_arg(args, &args));
|
||||
port = my_atol(next_arg(args, &args));
|
||||
file = new_next_arg(args, &args);
|
||||
checksum = next_arg(args, &args);
|
||||
filesize = my_atol(next_arg(args, &args));
|
||||
speed = my_atol(next_arg(args, &args));
|
||||
|
||||
for (sf = resume_struct; sf; sf = sf->next)
|
||||
{
|
||||
if (!strcmp(checksum, sf->checksum) && (filesize == sf->filesize))
|
||||
{
|
||||
FileStruct *new;
|
||||
new = new_malloc(sizeof(FileStruct));
|
||||
new->nick = m_strdup(nick);
|
||||
new->ip = ip;
|
||||
new->name = m_strdup(file);
|
||||
new->checksum = m_strdup(checksum);
|
||||
new->port = port;
|
||||
new->filesize = filesize;
|
||||
new->speed = speed;
|
||||
new->next = sf->results;
|
||||
sf->results = new;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (!count)
|
||||
nap_say("error in resume request. no match");
|
||||
return 0;
|
||||
}
|
||||
|
||||
NAP_COMM(cmd_resumerequestend)
|
||||
{
|
||||
char *checksum;
|
||||
unsigned long filesize;
|
||||
ResumeFile *sf;
|
||||
checksum = next_arg(args, &args);
|
||||
filesize = my_atol(next_arg(args, &args));
|
||||
for (sf = resume_struct; sf; sf = sf->next)
|
||||
{
|
||||
if (!strcmp(checksum, sf->checksum) && (filesize == sf->filesize))
|
||||
{
|
||||
FileStruct *new;
|
||||
int count = 1;
|
||||
for (new = sf->results; new; new = new->next)
|
||||
print_file(new, count++);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BUILT_IN_DLL(nap_request)
|
||||
{
|
||||
char *nick, *filen, *comm;
|
||||
|
||||
if (!my_stricmp(command, "nrequest"))
|
||||
{
|
||||
nick = next_arg(args, &args);
|
||||
filen = new_next_arg(args, &args);
|
||||
if (nick && filen && *filen)
|
||||
{
|
||||
GetFile *new;
|
||||
do_hook(MODULE_LIST, "NAP REQUESTFILE %s %s", nick, filen);
|
||||
send_ncommand(CMDS_REQUESTFILE, "%s \"%s\"", nick, filen);
|
||||
new = new_malloc(sizeof(GetFile));
|
||||
new->nick = m_strdup(nick);
|
||||
new->filename = m_strdup(filen);
|
||||
new->next = getfile_struct;
|
||||
getfile_struct = new;
|
||||
}
|
||||
}
|
||||
else if (!my_stricmp(command, "nget") || !my_stricmp(command, "nresume"))
|
||||
{
|
||||
int i = 0, count = 1, resume = 0;
|
||||
FileStruct *sf = NULL;
|
||||
ResumeFile *rf = NULL;
|
||||
|
||||
resume = !my_stricmp(command, "nresume") ? 1 : 0;
|
||||
while (args && *args)
|
||||
{
|
||||
int req, browse;
|
||||
|
||||
sf = NULL;
|
||||
req = browse = 0;
|
||||
count = 1;
|
||||
comm = next_arg(args, &args);
|
||||
if (!my_strnicmp(comm, "-request", 3))
|
||||
{
|
||||
req = 1;
|
||||
comm = next_arg(args, &args);
|
||||
}
|
||||
else if (!my_strnicmp(comm, "-browse", 3))
|
||||
{
|
||||
browse = 1;
|
||||
comm = next_arg(args, &args);
|
||||
}
|
||||
|
||||
if (comm && *comm)
|
||||
i = strtoul(comm, NULL, 10);
|
||||
if (!req && !browse)
|
||||
{
|
||||
if (file_search)
|
||||
sf = file_search;
|
||||
else
|
||||
sf = file_browse;
|
||||
}
|
||||
else if (req)
|
||||
sf = file_search;
|
||||
else
|
||||
sf = file_browse;
|
||||
|
||||
if (sf && i)
|
||||
{
|
||||
for (; sf; sf = sf->next, count++)
|
||||
{
|
||||
if (i == count)
|
||||
{
|
||||
GetFile *new;
|
||||
if (resume)
|
||||
{
|
||||
for (rf = resume_struct; rf; rf= rf->next)
|
||||
{
|
||||
if (!strcmp(rf->checksum, sf->checksum) && (sf->filesize == rf->filesize))
|
||||
{
|
||||
nap_say("Already a Resume request for %s", base_name(sf->name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
rf = new_malloc(sizeof(ResumeFile));
|
||||
rf->checksum = m_strdup(sf->checksum);
|
||||
rf->filename = m_strdup(sf->name);
|
||||
rf->filesize = sf->filesize;
|
||||
rf->next = resume_struct;
|
||||
resume_struct = rf;
|
||||
send_ncommand(CMDS_REQUESTRESUME, "%s %lu", rf->checksum, rf->filesize);
|
||||
do_hook(MODULE_LIST, "NAP RESUMEREQUEST %s %lu %s", sf->checksum, rf->filesize, rf->filename);
|
||||
return;
|
||||
}
|
||||
do_hook(MODULE_LIST, "NAP REQUESTFILE %s %s", sf->nick, sf->name);
|
||||
send_ncommand(CMDS_REQUESTFILE, "%s \"%s\"", sf->nick, sf->name);
|
||||
new = new_malloc(sizeof(GetFile));
|
||||
new->nick = m_strdup(sf->nick);
|
||||
new->filename = m_strdup(sf->name);
|
||||
new->filesize = sf->filesize;
|
||||
new->checksum = m_strdup(sf->checksum);
|
||||
new->next = getfile_struct;
|
||||
getfile_struct = new;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (sf)
|
||||
{
|
||||
for (; sf; sf = sf->next)
|
||||
print_file(sf, count++);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (file_search)
|
||||
{
|
||||
for (sf = file_search; sf; sf = sf->next)
|
||||
print_file(sf, count++);
|
||||
} else if (file_browse)
|
||||
for (sf = file_browse; sf; sf = sf->next)
|
||||
print_file(sf, count++);
|
||||
}
|
||||
}
|
||||
|
||||
GetFile *find_in_getfile(GetFile **fn, int remove, char *nick, char *check, char *file, int speed, int up)
|
||||
{
|
||||
GetFile *last, *tmp;
|
||||
last = NULL;
|
||||
if (!nick)
|
||||
return NULL;
|
||||
for (tmp = *fn; tmp; tmp = tmp->next)
|
||||
{
|
||||
if (!my_stricmp(tmp->nick, nick))
|
||||
{
|
||||
if (check && my_stricmp(tmp->checksum, check))
|
||||
{
|
||||
last = tmp;
|
||||
continue;
|
||||
}
|
||||
if (file && my_stricmp(tmp->filename, file))
|
||||
{
|
||||
last = tmp;
|
||||
continue;
|
||||
}
|
||||
if ((speed != -1) && (tmp->speed != speed))
|
||||
{
|
||||
last = tmp;
|
||||
continue;
|
||||
}
|
||||
if ((up != -1) && ((tmp->up & ~NAP_QUEUED) != up))
|
||||
{
|
||||
last = tmp;
|
||||
continue;
|
||||
}
|
||||
if (remove)
|
||||
{
|
||||
if (last)
|
||||
last->next = tmp->next;
|
||||
else
|
||||
*fn = tmp->next;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
last = tmp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void getfile_cleanup(int snum)
|
||||
{
|
||||
SocketList *s;
|
||||
if ((s = get_socket(snum)) && s->info)
|
||||
{
|
||||
GetFile *f = (GetFile *)s->info;
|
||||
if ((f = find_in_getfile(&getfile_struct, 1, f->nick, f->checksum, f->filename, -1, NAP_DOWNLOAD)))
|
||||
{
|
||||
new_free(&f->nick);
|
||||
new_free(&f->filename);
|
||||
new_free(&f->realfile);
|
||||
new_free(&f->ip);
|
||||
new_free(&f->checksum);
|
||||
if (f->write > 0)
|
||||
close(f->write);
|
||||
new_free(&f);
|
||||
}
|
||||
s->info = NULL;
|
||||
}
|
||||
close_socketread(snum);
|
||||
build_napster_status(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
void nap_getfile(int snum)
|
||||
{
|
||||
char indata[2*NAP_BUFFER_SIZE+1];
|
||||
SocketList *s;
|
||||
int rc;
|
||||
int count = sizeof(indata) - 1;
|
||||
GetFile *gf;
|
||||
unsigned long nbytes = 0;
|
||||
|
||||
s = get_socket(snum);
|
||||
gf = (GetFile *)get_socketinfo(snum);
|
||||
if (gf && gf->count)
|
||||
{
|
||||
int flags = O_WRONLY;
|
||||
memset(&indata, 0, 200);
|
||||
if ((rc = read(snum, &indata, gf->count)) != gf->count)
|
||||
return;
|
||||
if (!isdigit(*indata) || !*(indata+1) || !isdigit(*(indata+1)))
|
||||
{
|
||||
rc += read(snum, &indata[gf->count], sizeof(indata)-1);
|
||||
indata[rc] = 0;
|
||||
nap_say("Request from %s is %s", gf->nick, indata);
|
||||
gf = find_in_getfile(&getfile_struct, 1, gf->nick, gf->checksum, gf->filename, -1, NAP_DOWNLOAD);
|
||||
nap_finished_file(snum, gf);
|
||||
return;
|
||||
}
|
||||
gf->count = 0;
|
||||
set_non_blocking(snum);
|
||||
gf->starttime = time(NULL);
|
||||
if (!gf->resume)
|
||||
flags |= O_CREAT;
|
||||
if (!gf->realfile || ((gf->write = open(gf->realfile, flags, 0666)) == -1))
|
||||
{
|
||||
nap_say("Error opening output file %s: %s\n", base_name(gf->realfile), strerror(errno));
|
||||
gf = find_in_getfile(&getfile_struct, 1, gf->nick, gf->checksum, gf->filename, -1, NAP_DOWNLOAD);
|
||||
nap_finished_file(snum, gf);
|
||||
return;
|
||||
}
|
||||
if (gf->resume)
|
||||
lseek(gf->write, gf->resume, SEEK_SET);
|
||||
if (do_hook(MODULE_LIST, "NAP GETFILE %sING %s %lu %s",gf->resume ? "RESUM": "GETT", gf->nick, gf->filesize, gf->filename))
|
||||
{
|
||||
sprintf(indata, "%4.2g%s %4.2g%s", _GMKv(gf->resume), _GMKs(gf->resume), _GMKv(gf->filesize), _GMKs(gf->filesize));
|
||||
nap_say("%s", cparse(gf->resume ?"$0ing from $1 $2/$3 [$4-]":"$0ing from $1 $3 [$4-]", "%s %s %s %s", gf->resume?"Resum":"Gett", gf->nick, indata, base_name(gf->filename)));
|
||||
}
|
||||
add_sockettimeout(snum, 0, NULL);
|
||||
send_ncommand(CMDS_UPDATE_GET1, NULL);
|
||||
build_napster_status(NULL);
|
||||
return;
|
||||
}
|
||||
else if (!gf)
|
||||
{
|
||||
s->is_write = 0;
|
||||
close_socketread(snum);
|
||||
send_ncommand(CMDS_UPDATE_GET, NULL);
|
||||
return;
|
||||
}
|
||||
if ((rc = ioctl(snum, FIONREAD, &nbytes) != -1))
|
||||
{
|
||||
if (nbytes)
|
||||
{
|
||||
count = (nbytes > count) ? count : nbytes;
|
||||
rc = read(snum, indata, count);
|
||||
} else
|
||||
rc = 0;
|
||||
}
|
||||
switch (rc)
|
||||
{
|
||||
case -1:
|
||||
nap_say("ERROR reading file [%s]", strerror(errno));
|
||||
case 0:
|
||||
{
|
||||
if (gf && (gf = find_in_getfile(&getfile_struct, 1, gf->nick, gf->checksum, gf->filename, -1, NAP_DOWNLOAD)))
|
||||
{
|
||||
char speed1[80];
|
||||
double speed;
|
||||
speed = gf->received / 1024.0 / (now - gf->starttime);
|
||||
sprintf(speed1, "%4.2fK/s", speed);
|
||||
if ((gf->received + gf->resume) >= gf->filesize)
|
||||
{
|
||||
char rs[60];
|
||||
sprintf(rs, "%4.2g%s", _GMKv(gf->filesize), _GMKs(gf->filesize));
|
||||
if (rc != -1 && do_hook(MODULE_LIST, "NAP GETFILE FINISH %sING %s %s %lu %s", gf->resume ? "RESUM":"GETT", gf->nick, speed1, gf->received + gf->resume, gf->filename))
|
||||
nap_say("%s", cparse("Finished $2ing [$3-] from $0 $1", "%s %s %s %s %s", gf->nick, speed1, gf->resume ? "Resum":"Gett", rs, base_name(gf->filename)));
|
||||
if (speed > statistics.max_downloadspeed)
|
||||
statistics.max_downloadspeed = speed;
|
||||
statistics.files_received++;
|
||||
statistics.filesize_received += gf->received;
|
||||
}
|
||||
else if (do_hook(MODULE_LIST, "NAP GETFILE ERROR %sING %s %s %lu %lu %s", gf->resume? "RESUM":"GETT", gf->nick, speed1, gf->filesize, gf->received + gf->resume, gf->filename))
|
||||
{
|
||||
char fs[60];
|
||||
char rs[60];
|
||||
sprintf(fs, "%4.2g%s", _GMKv(gf->filesize), _GMKs(gf->filesize));
|
||||
sprintf(rs, "%4.2g%s", _GMKv(gf->received), _GMKs(gf->received));
|
||||
nap_say("%s", cparse("Error $2ing [$3-] from $0 $1", "%s %s %s %s %s %s", gf->nick, speed1, gf->resume ? "Resum":"Gett", fs, rs, base_name(gf->filename)));
|
||||
}
|
||||
}
|
||||
send_ncommand(CMDS_UPDATE_GET, NULL);
|
||||
nap_finished_file(snum, gf);
|
||||
build_napster_status(NULL);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
write(gf->write, indata, rc);
|
||||
gf->received += rc;
|
||||
if ((gf->received+gf->resume) >= gf->filesize)
|
||||
{
|
||||
if ((gf = find_in_getfile(&getfile_struct, 1,
|
||||
gf->nick, gf->checksum, gf->filename, -1, NAP_DOWNLOAD)))
|
||||
{
|
||||
char speed1[80];
|
||||
double speed;
|
||||
speed = gf->received / 1024.0 / (now - gf->starttime);
|
||||
sprintf(speed1, "%4.2fK/s", speed);
|
||||
if (speed > statistics.max_downloadspeed)
|
||||
statistics.max_downloadspeed = speed;
|
||||
if (do_hook(MODULE_LIST, "NAP GETFILE FINISH %sING %s %s %lu %s", gf->resume ? "RESUM":"GETT", gf->nick, speed1, gf->filesize, gf->filename))
|
||||
{
|
||||
char rs[60];
|
||||
sprintf(rs, "%4.2g%s", _GMKv(gf->filesize), _GMKs(gf->filesize));
|
||||
nap_say("%s", cparse("Finished $2ing [$3-] from $0 at $1", "%s %s %s %s %s", gf->nick, speed1, gf->resume?"Resum":"Gett", rs, base_name(gf->filename)));
|
||||
}
|
||||
statistics.files_received++;
|
||||
statistics.filesize_received += gf->received;
|
||||
}
|
||||
send_ncommand(CMDS_UPDATE_GET, NULL);
|
||||
nap_finished_file(snum, gf);
|
||||
build_napster_status(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void nap_getfilestart(int snum)
|
||||
{
|
||||
SocketList *s;
|
||||
int rc;
|
||||
char c;
|
||||
GetFile *gf;
|
||||
s = get_socket(snum);
|
||||
gf = (GetFile *)get_socketinfo(snum);
|
||||
if (gf)
|
||||
{
|
||||
set_blocking(snum);
|
||||
if ((rc = read(snum, &c, 1)) != 1)
|
||||
return;
|
||||
s->func_read = nap_getfile;
|
||||
return;
|
||||
}
|
||||
close_socketread(snum);
|
||||
}
|
||||
|
||||
|
||||
void nap_firewall_get(int snum)
|
||||
{
|
||||
char indata[2*NAP_BUFFER_SIZE+1];
|
||||
int rc;
|
||||
memset(indata, 0, sizeof(indata));
|
||||
alarm(15);
|
||||
rc = recv(snum, indata, sizeof(indata)-1, 0);
|
||||
alarm(0);
|
||||
switch(rc)
|
||||
{
|
||||
case -1:
|
||||
close_socketread(snum);
|
||||
nap_say("ERROR in nap_firewall_get %s", strerror(errno));
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
char *args, *nick, *filename;
|
||||
unsigned long filesize;
|
||||
GetFile *gf;
|
||||
SocketList *s;
|
||||
|
||||
s = get_socket(snum);
|
||||
if (!strncmp(indata, "FILE NOT", 8) || !strncmp(indata, "INVALID DATA", 10))
|
||||
{
|
||||
close_socketread(snum);
|
||||
return;
|
||||
}
|
||||
args = &indata[0];
|
||||
if (!(nick = next_arg(args, &args)))
|
||||
{
|
||||
close_socketread(snum);
|
||||
return;
|
||||
}
|
||||
filename = new_next_arg(args, &args);
|
||||
filesize = my_atol(next_arg(args, &args));
|
||||
if (!filename || !*filename || !filesize)
|
||||
{
|
||||
close_socketread(snum);
|
||||
return;
|
||||
}
|
||||
if ((gf = find_in_getfile(&getfile_struct, 0, nick, NULL, filename, -1, NAP_DOWNLOAD)))
|
||||
{
|
||||
int flags = O_WRONLY;
|
||||
#ifndef NO_STRUCT_LINGER
|
||||
int len;
|
||||
struct linger lin;
|
||||
len = sizeof(lin);
|
||||
lin.l_onoff = lin.l_linger = 1;
|
||||
#endif
|
||||
|
||||
gf->count = 0;
|
||||
set_non_blocking(snum);
|
||||
gf->starttime = time(NULL);
|
||||
gf->socket = snum;
|
||||
gf->filesize = filesize;
|
||||
if (!gf->resume)
|
||||
flags |= O_CREAT;
|
||||
if (!gf->realfile || ((gf->write = open(gf->realfile, flags, 0666)) == -1))
|
||||
{
|
||||
nap_say("Error opening output file %s: %s\n", base_name(gf->realfile), strerror(errno));
|
||||
gf = find_in_getfile(&getfile_struct, 1, gf->nick, gf->checksum, gf->filename, -1, NAP_DOWNLOAD);
|
||||
nap_finished_file(snum, gf);
|
||||
return;
|
||||
}
|
||||
if (gf->resume)
|
||||
lseek(gf->write, gf->resume, SEEK_SET);
|
||||
sprintf(indata, "%lu", gf->resume);
|
||||
write(snum, indata, strlen(indata));
|
||||
if (do_hook(MODULE_LIST, "NAP GETFILE %sING %s %lu %s",gf->resume ? "RESUM": "GETT", gf->nick, gf->filesize, gf->filename))
|
||||
{
|
||||
sprintf(indata, "%4.2g%s %4.2g%s", _GMKv(gf->resume), _GMKs(gf->resume), _GMKv(gf->filesize), _GMKs(gf->filesize));
|
||||
nap_say("%s", cparse("$0ing from $1 $3 [$4-]", "%s %s %s %s", gf->resume?"Resum":"Gett", gf->nick, indata, base_name(gf->filename)));
|
||||
}
|
||||
add_sockettimeout(snum, 0, NULL);
|
||||
send_ncommand(CMDS_UPDATE_GET1, NULL);
|
||||
build_napster_status(NULL);
|
||||
s->func_read = nap_getfile;
|
||||
set_socketinfo(snum, gf);
|
||||
#ifndef NO_STRUCT_LINGER
|
||||
setsockopt(snum, SOL_SOCKET, SO_LINGER, (char *)&lin, len);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NAP_COMM(cmd_getfileinfo)
|
||||
{
|
||||
char *nick;
|
||||
GetFile *gf;
|
||||
char indata[2*NAP_BUFFER_SIZE+1];
|
||||
int count;
|
||||
nick = next_arg(args, &args);
|
||||
count = my_atol(args);
|
||||
if ((gf = find_in_getfile(&getfile_struct, 0, nick, NULL, NULL, count, NAP_DOWNLOAD)))
|
||||
{
|
||||
sprintf(indata, "%lu", gf->filesize);
|
||||
gf->count = strlen(indata);
|
||||
write(gf->socket, "GET", 3);
|
||||
snprintf(indata, sizeof(indata), "%s \"%s\" %lu", get_dllstring_var("napster_user"), gf->filename, gf->resume);
|
||||
write(gf->socket, indata, strlen(indata));
|
||||
add_socketread(gf->socket, gf->port, gf->write, gf->nick, nap_getfilestart, NULL);
|
||||
set_socketinfo(gf->socket, gf);
|
||||
add_sockettimeout(gf->socket, 180, getfile_cleanup);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
NAP_COMM(cmd_getfile)
|
||||
{
|
||||
/*
|
||||
gato242 3068149784 6699 "d:\mp3\Hackers_-_07_-_Orbital_-_Halcyon_&_On_&_On.mp3"
|
||||
8b451240c17fec98ea4f63e26bd42c60 7
|
||||
*/
|
||||
unsigned short port;
|
||||
int getfd = -1;
|
||||
int speed;
|
||||
char *nick, *file, *checksum, *ip, *dir = NULL;
|
||||
char *realfile = NULL;
|
||||
char indata[2*NAP_BUFFER_SIZE+1];
|
||||
struct sockaddr_in socka;
|
||||
GetFile *gf = NULL;
|
||||
struct stat st;
|
||||
|
||||
nick = next_arg(args, &args);
|
||||
ip = next_arg(args, &args);
|
||||
port = my_atol(next_arg(args, &args));
|
||||
file = new_next_arg(args, &args);
|
||||
checksum = next_arg(args, &args);
|
||||
speed = my_atol(args);
|
||||
|
||||
if (!(gf = find_in_getfile(&getfile_struct, 1, nick, checksum, file, -1, NAP_DOWNLOAD)))
|
||||
{
|
||||
nap_say("%s", "request not in getfile");
|
||||
return 0;
|
||||
}
|
||||
gf->ip = m_strdup(ip);
|
||||
gf->checksum = m_strdup(checksum);
|
||||
gf->speed = atol(args);
|
||||
gf->port = port;
|
||||
|
||||
if (!(dir = get_dllstring_var("napster_download_dir")))
|
||||
if (!(dir = get_string_var(DCC_DLDIR_VAR)))
|
||||
dir = "~";
|
||||
snprintf(indata, sizeof(indata), "%s/%s", dir, base_name(file));
|
||||
|
||||
realfile = expand_twiddle(indata);
|
||||
|
||||
gf->realfile = realfile;
|
||||
if (!(stat(realfile, &st)) && get_dllint_var("napster_resume_download"))
|
||||
gf->resume = st.st_size;
|
||||
|
||||
gf->write = -1;
|
||||
|
||||
if (!port)
|
||||
{
|
||||
/* this is a firewalled host. make a listen socket instead */
|
||||
send_ncommand(CMDS_REQUESTFILEFIRE, "%s \"%s\"", nick, file);
|
||||
nap_say("Attempting to get from a firewalled host");
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef NO_STRUCT_LINGER
|
||||
int len;
|
||||
struct linger lin;
|
||||
len = sizeof(lin);
|
||||
lin.l_onoff = lin.l_linger = 1;
|
||||
#endif
|
||||
|
||||
getfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
socka.sin_addr.s_addr = strtoul(ip, NULL, 10);
|
||||
socka.sin_family = AF_INET;
|
||||
socka.sin_port = htons(port);
|
||||
alarm(get_int_var(CONNECT_TIMEOUT_VAR));
|
||||
if (connect(getfd, (struct sockaddr *)&socka, sizeof(struct sockaddr)) != 0)
|
||||
{
|
||||
nap_say("ERROR connecting [%s]", strerror(errno));
|
||||
send_ncommand(CMDR_DATAPORTERROR, gf->nick);
|
||||
new_free(&gf->nick);
|
||||
new_free(&gf->filename);
|
||||
new_free(&gf->ip);
|
||||
new_free(&gf->checksum);
|
||||
new_free(&gf->realfile);
|
||||
new_free(&gf);
|
||||
return 0;
|
||||
}
|
||||
alarm(0);
|
||||
#ifndef NO_STRUCT_LINGER
|
||||
setsockopt(getfd, SOL_SOCKET, SO_LINGER, (char *)&lin, len);
|
||||
#endif
|
||||
send_ncommand(CMDS_REQUESTINFO, nick);
|
||||
}
|
||||
|
||||
gf->socket = getfd;
|
||||
gf->next = getfile_struct;
|
||||
gf->up = NAP_DOWNLOAD;
|
||||
getfile_struct = gf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
NAP_COMM(cmd_send_limit_msg)
|
||||
{
|
||||
char *nick, *filename, *limit, *filesize;
|
||||
GetFile *gf;
|
||||
nick = next_arg(args, &args);
|
||||
filename = new_next_arg(args, &args);
|
||||
filesize = next_arg(args, &args);
|
||||
limit = args;
|
||||
if (!(gf = find_in_getfile(&getfile_struct, 1, nick, NULL, filename, -1, NAP_DOWNLOAD)))
|
||||
{
|
||||
nap_say("%s %s[%s]", "request not in getfile", nick, filename);
|
||||
return 0;
|
||||
}
|
||||
/* nap_finished_file(gf->socket, gf);*/
|
||||
gf->up &= NAP_QUEUED;
|
||||
if (do_hook(MODULE_LIST, "NAP QUEUE FULL %s %s %s %s", nick, filesize, limit, filename))
|
||||
nap_say("%s", cparse("$0 send queue[$1] is full.", "%s %s %s", nick, limit, filename));
|
||||
return 0;
|
||||
|
||||
}
|
||||
180
dll/nap/napfunc.c
Normal file
180
dll/nap/napfunc.c
Normal file
@@ -0,0 +1,180 @@
|
||||
#define IN_MODULE
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "dcc.h"
|
||||
#include "ircaux.h"
|
||||
#include "misc.h"
|
||||
#include "output.h"
|
||||
#include "lastlog.h"
|
||||
#include "screen.h"
|
||||
#include "status.h"
|
||||
#include "window.h"
|
||||
#include "vars.h"
|
||||
#include "input.h"
|
||||
#include "module.h"
|
||||
#include "hook.h"
|
||||
#include "list.h"
|
||||
#include "modval.h"
|
||||
#include "./napster.h"
|
||||
#include "md5.h"
|
||||
|
||||
#define NEMPTY ""
|
||||
#define EMPTY_STRING m_strdup(NEMPTY)
|
||||
#define RETURN_EMPTY return EMPTY_STRING
|
||||
#define RETURN_IF_EMPTY(x) if (empty( x )) RETURN_EMPTY
|
||||
#define GET_INT_ARG(x, y) {RETURN_IF_EMPTY(y); x = atol(new_next_arg(y, &y));}
|
||||
#define GET_STR_ARG(x, y) {RETURN_IF_EMPTY(y); x = new_next_arg(y, &y);RETURN_IF_EMPTY(x);}
|
||||
#define RETURN_STR(x) return m_strdup(x ? x : EMPTY)
|
||||
#define RETURN_INT(x) return m_strdup(ltoa(x))
|
||||
|
||||
|
||||
/*
|
||||
* given a "time in seconds" we convert this to a pretty time format
|
||||
*/
|
||||
|
||||
BUILT_IN_FUNCTION(func_mp3_time)
|
||||
{
|
||||
unsigned long t;
|
||||
t = my_atol(input);
|
||||
return m_strdup(mp3_time(t));
|
||||
}
|
||||
|
||||
/*
|
||||
* return topic for the channel or empty
|
||||
*/
|
||||
|
||||
BUILT_IN_FUNCTION(func_topic)
|
||||
{
|
||||
char *chan;
|
||||
ChannelStruct *ch;
|
||||
GET_STR_ARG(chan, input);
|
||||
ch = (ChannelStruct *)find_in_list((List **)&nchannels, chan, 0);
|
||||
return ch ? m_strdup(ch->topic) : m_strdup("");
|
||||
}
|
||||
|
||||
/*
|
||||
* are we on "channel"
|
||||
*/
|
||||
|
||||
BUILT_IN_FUNCTION(func_onchan)
|
||||
{
|
||||
char *chan;
|
||||
ChannelStruct *ch;
|
||||
GET_STR_ARG(chan, input);
|
||||
ch = (ChannelStruct *)find_in_list((List **)&nchannels, chan, 0);
|
||||
return ch ? m_strdup("1") : m_strdup("0");
|
||||
}
|
||||
|
||||
/*
|
||||
* given a channel, returns the nicks on that channel.
|
||||
* given a channel and a "nick speed files" returns the nick else empty.
|
||||
*/
|
||||
BUILT_IN_FUNCTION(func_onchannel)
|
||||
{
|
||||
char *chan;
|
||||
ChannelStruct *ch;
|
||||
NickStruct *n;
|
||||
char *nick = NULL;
|
||||
GET_STR_ARG(chan, input);
|
||||
if ((ch = (ChannelStruct *)find_in_list((List **)&nchannels, chan, 0)))
|
||||
{
|
||||
char *ret = NULL;
|
||||
char buffer[200];
|
||||
if (input && *input)
|
||||
{
|
||||
while ((nick = next_arg(input, &input)))
|
||||
{
|
||||
for (n = ch->nicks; n; n = n->next)
|
||||
{
|
||||
if (!my_stricmp(nick, n->nick))
|
||||
{
|
||||
sprintf(buffer, "%s %d %lu", n->nick, n->speed, n->shared);
|
||||
m_s3cat(&ret, " ", buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (n = ch->nicks; n; n = n->next)
|
||||
m_s3cat(&ret, " ", n->nick);
|
||||
}
|
||||
return ret ? ret : m_strdup("");
|
||||
}
|
||||
RETURN_EMPTY;
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(func_connected)
|
||||
{
|
||||
if (nap_socket > -1)
|
||||
{
|
||||
int len;
|
||||
struct sockaddr_in name;
|
||||
len = sizeof (name);
|
||||
if (getpeername(nap_socket, (struct sockaddr *)&name, &len))
|
||||
return m_strdup("-1");
|
||||
return m_sprintf("%s %d", inet_ntoa(name.sin_addr), ntohs(name.sin_port));
|
||||
}
|
||||
return m_strdup("");
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(func_hotlist)
|
||||
{
|
||||
char *nick = NULL;
|
||||
char *ret = NULL;
|
||||
NickStruct *n;
|
||||
if (input && *input)
|
||||
{
|
||||
char buffer[200];
|
||||
while ((nick = next_arg(input, &input)))
|
||||
{
|
||||
for (n = nap_hotlist; n; n = n->next)
|
||||
{
|
||||
if (!my_stricmp(nick, n->nick))
|
||||
{
|
||||
sprintf(buffer, "%s %d %lu", n->nick, n->speed, n->shared);
|
||||
m_s3cat(&ret, " ", buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (n = nap_hotlist; n; n = n->next)
|
||||
m_s3cat(&ret, " ", n->nick);
|
||||
|
||||
}
|
||||
return ret ? ret : m_strdup("");
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(func_raw)
|
||||
{
|
||||
int l;
|
||||
_N_DATA n_data = {0, 0};
|
||||
GET_INT_ARG(l, input);
|
||||
n_data.command = l;
|
||||
if (input && *input)
|
||||
n_data.len = strlen(input);
|
||||
if (nap_socket < 0)
|
||||
return m_strdup("-1");
|
||||
write(nap_socket, &n_data, 4);
|
||||
if (n_data.len)
|
||||
return m_strdup(ltoa(write(nap_socket, input, n_data.len)));
|
||||
else
|
||||
return m_strdup("0");
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(func_napchannel)
|
||||
{
|
||||
return nap_current_channel ? m_strdup(nap_current_channel) : m_strdup(empty_string);
|
||||
}
|
||||
|
||||
BUILT_IN_FUNCTION(func_md5)
|
||||
{
|
||||
int l;
|
||||
unsigned long size = 0;
|
||||
GET_INT_ARG(l, input);
|
||||
if (input && *input)
|
||||
size = my_atol(input);
|
||||
return calc_md5(l, size);
|
||||
}
|
||||
261
dll/nap/napother.c
Normal file
261
dll/nap/napother.c
Normal file
@@ -0,0 +1,261 @@
|
||||
#include "irc.h"
|
||||
#include "struct.h"
|
||||
#include "ircaux.h"
|
||||
#include "misc.h"
|
||||
#include "output.h"
|
||||
#include "module.h"
|
||||
#include "list.h"
|
||||
#include "vars.h"
|
||||
#include "modval.h"
|
||||
#include "napster.h"
|
||||
|
||||
static IgnoreStruct *ignores = NULL;
|
||||
|
||||
int check_nignore(char *nick)
|
||||
{
|
||||
if (ignores && find_in_list((List **)&ignores, nick, 0))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ignore_user(IrcCommandDll *intp, char *command, char *args, char *subargs, char *help)
|
||||
{
|
||||
IgnoreStruct *new;
|
||||
char *nick;
|
||||
if (command && !my_stricmp(command, "nignore"))
|
||||
{
|
||||
if (!args || !*args)
|
||||
{
|
||||
char buffer[NAP_BUFFER_SIZE+1];
|
||||
int cols = get_dllint_var("napster_names_columns") ?
|
||||
get_dllint_var("napster_names_columns") :
|
||||
get_int_var(NAMES_COLUMNS_VAR);
|
||||
int count = 0;
|
||||
if (!cols)
|
||||
cols = 1;
|
||||
*buffer = 0;
|
||||
nap_say("%s", cparse("Ignore List:", NULL));
|
||||
for (new = ignores; new; new = new->next)
|
||||
{
|
||||
strcat(buffer, cparse(get_dllstring_var("napster_names_nickcolor"), "%s %d %d", new->nick, 0, 0));
|
||||
strcat(buffer, space);
|
||||
if (count++ >= (cols - 1))
|
||||
{
|
||||
nap_put("%s", buffer);
|
||||
*buffer = 0;
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
if (*buffer)
|
||||
nap_put("%s", buffer);
|
||||
return;
|
||||
}
|
||||
while ((nick = next_arg(args, &args)))
|
||||
{
|
||||
if (*nick == '-')
|
||||
{
|
||||
nick++;
|
||||
if (!*nick)
|
||||
continue;
|
||||
if ((new = (IgnoreStruct *)remove_from_list((List **)&ignores, nick)))
|
||||
{
|
||||
new_free(&new->nick);
|
||||
new_free(&new);
|
||||
nap_say("Removed %s from ignore list", nick);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new = new_malloc(sizeof(IgnoreStruct));
|
||||
new->nick = m_strdup(nick);
|
||||
new->start = time(NULL);
|
||||
new->next = ignores;
|
||||
ignores = new;
|
||||
nap_say("Added %s to ignore list", new->nick);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nap_echo(IrcCommandDll *intp, char *command, char *args, char *subargs, char *help)
|
||||
{
|
||||
int (*func)(char *, ...);
|
||||
if (!args || !*args)
|
||||
return;
|
||||
|
||||
func = nap_say;
|
||||
while (args && (*args == '-'))
|
||||
{
|
||||
args++;
|
||||
if (!*args)
|
||||
break;
|
||||
if (tolower(*args) == 'x')
|
||||
{
|
||||
func = nap_put;
|
||||
next_arg(args, &args);
|
||||
}
|
||||
else
|
||||
{
|
||||
args--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (args)
|
||||
(func)("%s", args);
|
||||
}
|
||||
|
||||
extern GetFile *napster_sendqueue;
|
||||
|
||||
int count_download(char *nick)
|
||||
{
|
||||
int count = 0;
|
||||
GetFile *gf;
|
||||
for (gf = napster_sendqueue; gf; gf = gf->next)
|
||||
if (!my_stricmp(gf->nick, nick))
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
void compute_soundex (char *d, int dsize, const char *s)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
/* if it's not big enough to hold one soundex word, quit without
|
||||
doing anything */
|
||||
if (dsize < 4)
|
||||
{
|
||||
if (dsize > 0)
|
||||
*d = 0;
|
||||
return;
|
||||
}
|
||||
dsize--; /* save room for the terminatin nul (\0) */
|
||||
|
||||
while (*s && !isalpha(*s))
|
||||
s++;
|
||||
if (!*s)
|
||||
{
|
||||
*d = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
*d++ = toupper (*s);
|
||||
dsize--;
|
||||
s++;
|
||||
|
||||
while (*s && dsize > 0)
|
||||
{
|
||||
switch (tolower (*s))
|
||||
{
|
||||
case 'b':
|
||||
case 'p':
|
||||
case 'f':
|
||||
case 'v':
|
||||
if (n < 3)
|
||||
{
|
||||
*d++ = '1';
|
||||
dsize--;
|
||||
n++;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
case 's':
|
||||
case 'k':
|
||||
case 'g':
|
||||
case 'j':
|
||||
case 'q':
|
||||
case 'x':
|
||||
case 'z':
|
||||
if (n < 3)
|
||||
{
|
||||
*d++ = '2';
|
||||
dsize--;
|
||||
n++;
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
case 't':
|
||||
if (n < 3)
|
||||
{
|
||||
*d++ = '3';
|
||||
dsize--;
|
||||
n++;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
if (n < 3)
|
||||
{
|
||||
*d++ = '4';
|
||||
dsize--;
|
||||
n++;
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
case 'n':
|
||||
if (n < 3)
|
||||
{
|
||||
*d++ = '5';
|
||||
dsize--;
|
||||
n++;
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if (n < 3)
|
||||
{
|
||||
*d++ = '6';
|
||||
dsize--;
|
||||
n++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!isalpha (*s))
|
||||
{
|
||||
/* pad short words with 0's */
|
||||
while (n < 3 && dsize > 0)
|
||||
{
|
||||
*d++ = '0';
|
||||
dsize--;
|
||||
n++;
|
||||
}
|
||||
n = 0; /* reset */
|
||||
/* skip forward until we find the next word */
|
||||
s++;
|
||||
while (*s && !isalpha (*s))
|
||||
s++;
|
||||
if (!*s)
|
||||
{
|
||||
*d = 0;
|
||||
return;
|
||||
}
|
||||
if (dsize > 0)
|
||||
{
|
||||
*d++ = ',';
|
||||
dsize--;
|
||||
if (dsize > 0)
|
||||
{
|
||||
*d++ = toupper (*s);
|
||||
dsize--;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* else it's a vowel and we ignore it */
|
||||
break;
|
||||
}
|
||||
/* skip over duplicate letters */
|
||||
while (*(s+1) == *s)
|
||||
s++;
|
||||
|
||||
/* next letter */
|
||||
s++;
|
||||
}
|
||||
/* pad short words with 0's */
|
||||
while (n < 3 && dsize > 0)
|
||||
{
|
||||
*d++ = '0';
|
||||
dsize--;
|
||||
n++;
|
||||
}
|
||||
*d = 0;
|
||||
}
|
||||
|
||||
1682
dll/nap/napsend.c
Normal file
1682
dll/nap/napsend.c
Normal file
File diff suppressed because it is too large
Load Diff
424
dll/nap/napster.h
Normal file
424
dll/nap/napster.h
Normal file
@@ -0,0 +1,424 @@
|
||||
|
||||
#ifndef _napster_h
|
||||
#define _napster_h
|
||||
|
||||
#include "modval.h"
|
||||
|
||||
typedef struct _Stats {
|
||||
int libraries;
|
||||
int gigs;
|
||||
int songs;
|
||||
unsigned long total_files;
|
||||
double total_filesize;
|
||||
unsigned long files_served;
|
||||
double filesize_served;
|
||||
unsigned long files_received;
|
||||
double filesize_received;
|
||||
double max_downloadspeed;
|
||||
double max_uploadspeed;
|
||||
time_t starttime;
|
||||
unsigned long shared_files;
|
||||
double shared_filesize;
|
||||
} Stats;
|
||||
|
||||
extern Stats statistics;
|
||||
|
||||
typedef struct {
|
||||
char *username;
|
||||
char *password;
|
||||
int connection_speed;
|
||||
} _N_AUTH;
|
||||
|
||||
typedef unsigned char _N_CMD;
|
||||
|
||||
typedef struct {
|
||||
int libraries;
|
||||
int gigs;
|
||||
int songs;
|
||||
} _N_STATS;
|
||||
|
||||
#define cparse convert_output_format
|
||||
|
||||
typedef struct _nick_struct {
|
||||
struct _nick_struct *next;
|
||||
char *nick;
|
||||
int speed;
|
||||
unsigned long shared;
|
||||
} NickStruct;
|
||||
|
||||
typedef struct _AUDIO_HEADER {
|
||||
unsigned long filesize;
|
||||
int mpeg25;
|
||||
int ID;
|
||||
int layer;
|
||||
int error_protection;
|
||||
int bitrate_index;
|
||||
int sampling_frequency;
|
||||
int padding;
|
||||
int extension;
|
||||
int mode; /* 0 = STEREO 1 = Joint 2 = DUAL 3 = Mono */
|
||||
int mode_ext;
|
||||
int copyright;
|
||||
int original;
|
||||
int emphasis;
|
||||
int stereo;
|
||||
int jsbound;
|
||||
int sblimit;
|
||||
int true_layer;
|
||||
int framesize;
|
||||
int freq;
|
||||
unsigned long totalframes;
|
||||
unsigned long bitrate;
|
||||
} AUDIO_HEADER;
|
||||
|
||||
typedef struct _files {
|
||||
struct _files *next;
|
||||
char *filename;
|
||||
char *checksum;
|
||||
unsigned long filesize;
|
||||
time_t time;
|
||||
int bitrate;
|
||||
int freq;
|
||||
int stereo;
|
||||
int type;
|
||||
} Files;
|
||||
|
||||
typedef struct _ignore_nick_struct {
|
||||
struct _ignore_nick_struct *next;
|
||||
char *nick;
|
||||
unsigned long start;
|
||||
unsigned long end;
|
||||
} IgnoreStruct;
|
||||
|
||||
typedef struct _channel_struct {
|
||||
struct _channel_struct *next;
|
||||
char *channel;
|
||||
char *topic;
|
||||
int injoin;
|
||||
NickStruct *nicks;
|
||||
} ChannelStruct;
|
||||
|
||||
typedef struct _file_struct {
|
||||
struct _file_struct *next;
|
||||
char *name;
|
||||
char *checksum;
|
||||
unsigned long filesize;
|
||||
unsigned int bitrate;
|
||||
unsigned int freq;
|
||||
unsigned int seconds;
|
||||
char *nick;
|
||||
unsigned long ip;
|
||||
int port;
|
||||
unsigned short speed;
|
||||
} FileStruct;
|
||||
|
||||
typedef struct _getfile_ {
|
||||
struct _getfile_ *next;
|
||||
|
||||
char *nick;
|
||||
char *ip;
|
||||
char *checksum;
|
||||
char *filename;
|
||||
char *realfile;
|
||||
|
||||
int socket;
|
||||
int port;
|
||||
int write;
|
||||
int count;
|
||||
unsigned long filesize;
|
||||
unsigned long received;
|
||||
unsigned long resume;
|
||||
time_t starttime;
|
||||
time_t addtime;
|
||||
int speed;
|
||||
int up;
|
||||
} GetFile;
|
||||
|
||||
typedef struct _resume_file_ {
|
||||
struct _resume_file_ *next;
|
||||
char *checksum;
|
||||
unsigned long filesize;
|
||||
char *filename;
|
||||
FileStruct *results;
|
||||
} ResumeFile;
|
||||
|
||||
enum nap_Commands {
|
||||
CMDR_ERROR = 0,
|
||||
CMDS_UNKNOWN = 1,
|
||||
CMDS_LOGIN = 2, /* user pass dataport "version" speed */
|
||||
CMDR_EMAILADDR = 3, /* email address */
|
||||
CMDR_BASTARD = 4, /* unknown */
|
||||
CMDS_REGISTERINFO = 6, /* userinfo */
|
||||
CMDS_CREATEUSER = 7, /* create user account */
|
||||
CMDR_CREATED = 8, /* account created */
|
||||
CMDR_CREATEERROR = 9, /* username taken */
|
||||
CMDR_ILLEGALNICK = 10, /* illegal nickname specified */
|
||||
|
||||
CMDR_LOGINERROR = 13,
|
||||
|
||||
CMDS_OPTIONS = 14, /* NAME:%s ADDRESS:%s CITY:%s STATE:%s PHONE:%s AGE:%s INCOME:%s EDUCATION:%s *login options */
|
||||
|
||||
CMDR_MSTAT = 15,
|
||||
CMDR_REQUESTUSERSPEED = 89,
|
||||
CMDR_SENDFILE = 95,
|
||||
CMDS_ADDFILE = 100,
|
||||
|
||||
CMDS_REMOVEFILE = 102, /* "\path\to\filename\" for removal */
|
||||
|
||||
CMDR_GETQUEUE = 108,
|
||||
CMDR_MOTD = 109,
|
||||
CMDR_ANOTHERUSER = 148,
|
||||
CMDS_SEARCH = 200,
|
||||
CMDR_SEARCHRESULTS = 201,
|
||||
CMDR_SEARCHRESULTSEND = 202,
|
||||
|
||||
/* if dataport is 0 we use 500 to request a transfer. 0 is a firewalled host */
|
||||
CMDS_REQUESTFILE = 203,
|
||||
CMDR_FILEREADY = 204,
|
||||
|
||||
CMDS_SENDMSG = 205,
|
||||
CMDR_GETERROR = 206,
|
||||
|
||||
CMDS_ADDHOTLIST = 207,
|
||||
|
||||
CMDS_ADDHOTLISTSEQ = 208,
|
||||
CMDR_HOTLISTONLINE = 209,
|
||||
CMDR_USEROFFLINE = 210,
|
||||
|
||||
CMDS_BROWSE = 211,
|
||||
CMDR_BROWSERESULT = 212,
|
||||
CMDR_BROWSEENDRESULT = 213,
|
||||
CMDR_STATS = 214,
|
||||
|
||||
CMDS_REQUESTRESUME = 215, /* checksum filesize */
|
||||
CMDR_RESUMESUCCESS = 216, /* nick ip port filename checksum size connection */
|
||||
CMDR_RESUMEEND = 217, /* end resume for checksum filesize */
|
||||
|
||||
CMDS_UPDATE_GET1 = 218, /* add 1 to download */
|
||||
CMDS_UPDATE_GET = 219, /* sub 1 from download */
|
||||
CMDS_UPDATE_SEND1 = 220, /* add 1 for send */
|
||||
CMDS_UPDATE_SEND = 221, /* sub 1 from send */
|
||||
|
||||
CMDR_HOTLISTSUCCESS = 301,
|
||||
CMDR_HOTLISTERROR = 302, /* not on hotlist */
|
||||
CMDS_HOTLISTREMOVE = 303, /* nick */
|
||||
|
||||
CMDS_JOIN = 400,
|
||||
CMDS_PART = 401,
|
||||
CMDS_SEND = 402,
|
||||
CMDR_PUBLIC = 403,
|
||||
CMDR_ERRORMSG = 404,
|
||||
CMDR_JOIN = 405,
|
||||
CMDR_JOINNEW = 406,
|
||||
CMDR_PARTED = 407,
|
||||
CMDR_NAMES = 408,
|
||||
CMDR_ENDNAMES = 409,
|
||||
CMDS_TOPIC = 410, /* got/change topic */
|
||||
|
||||
CMDS_REQUESTFILEFIRE = 500,
|
||||
CMDR_FILEINFOFIRE = 501, /* if firewalled then expect a 501 request send */
|
||||
|
||||
CMDS_REQUESTINFO = 600,
|
||||
CMDS_FILESIZE = 601,
|
||||
CMDS_REQUESTSIZE = 602,
|
||||
CMDS_WHOIS = 603,
|
||||
CMDR_WHOIS = 604,
|
||||
CMDR_WHOWAS = 605,
|
||||
CMDS_SETUSERLEVEL = 606, /* moderators/administrators/elite */
|
||||
CMDR_FILEREQUEST = 607, /* nick \"filename\" */
|
||||
CMDS_FILEINFO = 608, /* nick \"filename\" */
|
||||
CMDR_ACCEPTERROR = 609, /* accept failed on request */
|
||||
|
||||
CMDS_KILLUSER = 610, /* return 404 permission denied */
|
||||
CMDS_NUKEUSER = 611, /* return 404 */
|
||||
CMDS_BANUSER = 612,
|
||||
CMDS_SETDATAPORT = 613,
|
||||
CMDS_UNBANUSER = 614,
|
||||
CMDS_BANLIST = 615,
|
||||
CMDR_BANLIST_IP = 616,
|
||||
CMDS_LISTCHANNELS = 617,
|
||||
CMDR_LISTCHANNELS = 618,
|
||||
|
||||
CMDS_SENDLIMIT = 619, /* nick "filename" queuelimit */
|
||||
CMDR_SENDLIMIT = 620, /* nick "filename" filesize queuelimit */
|
||||
|
||||
CMDR_MOTDS = 621,
|
||||
CMDS_MUZZLE = 622,
|
||||
CMDS_UNMUZZLE = 623,
|
||||
CMDS_UNNUKEUSER = 624, /* return 404 */
|
||||
CMDS_SETLINESPEED = 625,
|
||||
CMDR_DATAPORTERROR = 626,
|
||||
CMDS_OPSAY = 627,
|
||||
CMDS_ANNOUNCE = 628,
|
||||
CMDR_BANLIST_NICK = 629,
|
||||
|
||||
CMDS_CHANGESPEED = 700,
|
||||
CMDS_CHANGEPASS = 701,
|
||||
CMDS_CHANGEEMAIL = 702,
|
||||
CMDS_CHANGEDATA = 703,
|
||||
|
||||
CMDS_PING = 751, /* user */
|
||||
CMDS_PONG = 752, /* <user> recieved from a ping*/
|
||||
/* <user> can also be used to send a pong */
|
||||
/* 753 */
|
||||
|
||||
CMDS_RELOADCONFIG = 800, /* <config variable> */
|
||||
CMDS_SERVERVERSION = 801, /* none */
|
||||
/* 802 missing */
|
||||
CMDS_SETCONFIG = 810, /* <config string */
|
||||
/* 811 */
|
||||
CMDS_CLEARCHANNEL = 820, /* channelname */
|
||||
/* 821 822 823 826 827 */
|
||||
CMDS_SENDME = 824,
|
||||
CMDR_NICK = 825,
|
||||
CMDS_NAME = 830, /* <channel> returns 825 with nick info, 830 is recieved on end of list */
|
||||
/* 831 */
|
||||
|
||||
|
||||
/* the following are open-nap specific */
|
||||
CMDS_SERVERLINK = 10100, /* link server <server> <port> [<remote server>] */
|
||||
CMDS_SERVERUNLINK = 10101, /* unlink server <server> <reason> */
|
||||
CMDS_SERVERKILL = 10110, /* kill server <server> <reason> */
|
||||
CMDS_SERVERREMOVE = 10111, /* remove it <server> <reason> */
|
||||
CMDS_ADDMIMEFILE = 10300 /* add a mime file type */
|
||||
#if 0
|
||||
%s %s "%s"
|
||||
Proper Syntax: /setpassword <user> <password> [reason]
|
||||
SETPASSWORD
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
500 nick filename -> "501 nick ip port filename md5 speed"
|
||||
*/
|
||||
|
||||
|
||||
typedef struct {
|
||||
unsigned short len;
|
||||
unsigned short command;
|
||||
} _N_DATA;
|
||||
|
||||
typedef struct {
|
||||
int cmd;
|
||||
int (*func)(int, char *);
|
||||
} _NAP_COMMANDS;
|
||||
|
||||
#define NAP_COMM(name) \
|
||||
int name (int cmd, char *args)
|
||||
|
||||
NAP_COMM(cmd_error);
|
||||
NAP_COMM(cmd_unknown);
|
||||
NAP_COMM(cmd_login);
|
||||
NAP_COMM(cmd_email);
|
||||
NAP_COMM(cmd_stats);
|
||||
NAP_COMM(cmd_whois);
|
||||
NAP_COMM(cmd_whowas);
|
||||
NAP_COMM(cmd_joined);
|
||||
NAP_COMM(cmd_topic);
|
||||
NAP_COMM(cmd_names);
|
||||
NAP_COMM(cmd_endnames);
|
||||
NAP_COMM(cmd_parted);
|
||||
NAP_COMM(cmd_public);
|
||||
NAP_COMM(cmd_msg);
|
||||
NAP_COMM(cmd_search);
|
||||
NAP_COMM(cmd_endsearch);
|
||||
NAP_COMM(cmd_browse);
|
||||
NAP_COMM(cmd_endbrowse);
|
||||
NAP_COMM(cmd_request);
|
||||
NAP_COMM(cmd_getfile);
|
||||
NAP_COMM(cmd_getfileinfo);
|
||||
NAP_COMM(cmd_alreadyregistered);
|
||||
NAP_COMM(cmd_registerinfo);
|
||||
NAP_COMM(cmd_banlist);
|
||||
NAP_COMM(cmd_offline);
|
||||
NAP_COMM(cmd_filerequest);
|
||||
NAP_COMM(cmd_dataport);
|
||||
NAP_COMM(cmd_hotlist);
|
||||
NAP_COMM(cmd_fileinfo);
|
||||
NAP_COMM(cmd_hotlistsuccess);
|
||||
NAP_COMM(cmd_hotlisterror);
|
||||
NAP_COMM(cmd_channellist);
|
||||
NAP_COMM(cmd_resumerequest);
|
||||
NAP_COMM(cmd_resumerequestend);
|
||||
NAP_COMM(cmd_send_limit_msg);
|
||||
NAP_COMM(cmd_accepterror);
|
||||
|
||||
NAP_COMM(cmd_recname);
|
||||
NAP_COMM(cmd_endname);
|
||||
NAP_COMM(cmd_firewall_request);
|
||||
NAP_COMM(cmd_ping);
|
||||
NAP_COMM(cmd_bastard);
|
||||
NAP_COMM(cmd_sendme);
|
||||
|
||||
BUILT_IN_DLL(load_napserv);
|
||||
BUILT_IN_DLL(print_napster);
|
||||
BUILT_IN_DLL(share_napster);
|
||||
BUILT_IN_DLL(nclose);
|
||||
BUILT_IN_DLL(nap_del);
|
||||
BUILT_IN_DLL(nap_glist);
|
||||
BUILT_IN_DLL(nap_request);
|
||||
BUILT_IN_DLL(ignore_user);
|
||||
BUILT_IN_DLL(nap_echo);
|
||||
|
||||
#define NAP_send(s, i) write(nap_socket, s, i);
|
||||
SocketList *naplink_connect(char *, unsigned short);
|
||||
void naplink_getserver(char *, unsigned short, int);
|
||||
|
||||
int nap_say(char *, ...);
|
||||
int nap_put(char *, ...);
|
||||
int send_ncommand(unsigned int, char *, ...);
|
||||
|
||||
|
||||
void print_file(FileStruct *, int);
|
||||
void naplink_handlelink(int);
|
||||
int make_listen(int);
|
||||
void set_napster_socket(int);
|
||||
char *napster_status(void);
|
||||
int build_napster_status(Window *);
|
||||
int nap_finished_file(int, GetFile *);
|
||||
int clean_queue(GetFile **, int);
|
||||
void clear_filelist(FileStruct **);
|
||||
void clear_files(Files **);
|
||||
void nap_firewall_get(int);
|
||||
char *mp3_time(unsigned long);
|
||||
char *calc_md5(int, unsigned long);
|
||||
int check_nignore(char *);
|
||||
|
||||
#if 0
|
||||
#undef BUILT_IN_FUNCTION
|
||||
#define BUILT_IN_FUNCTION(x, y) static char * x (char *fn, char * y)
|
||||
#endif
|
||||
|
||||
BUILT_IN_FUNCTION(func_mp3_time);
|
||||
BUILT_IN_FUNCTION(func_topic);
|
||||
BUILT_IN_FUNCTION(func_onchan);
|
||||
BUILT_IN_FUNCTION(func_onchannel);
|
||||
BUILT_IN_FUNCTION(func_connected);
|
||||
BUILT_IN_FUNCTION(func_hotlist);
|
||||
BUILT_IN_FUNCTION(func_napchannel);
|
||||
BUILT_IN_FUNCTION(func_raw);
|
||||
BUILT_IN_FUNCTION(func_md5);
|
||||
|
||||
GetFile *find_in_getfile(GetFile **, int, char *, char *, char *, int, int);
|
||||
int connectbynumber(char *, unsigned short *, int, int, int);
|
||||
|
||||
int count_download(char *);
|
||||
void compute_soundex (char *, int, const char *);
|
||||
|
||||
char *base_name(char *);
|
||||
|
||||
extern FileStruct *file_search;
|
||||
extern FileStruct *file_browse;
|
||||
extern GetFile *napster_sendqueue;
|
||||
extern char *nap_current_channel;
|
||||
extern int nap_socket;
|
||||
extern ChannelStruct *nchannels;
|
||||
extern NickStruct *nap_hotlist;
|
||||
|
||||
|
||||
#define NAP_DOWNLOAD 0x00
|
||||
#define NAP_UPLOAD 0x01
|
||||
#define NAP_QUEUED 0xf0
|
||||
#define NAP_BUFFER_SIZE 2048
|
||||
|
||||
#endif
|
||||
392
dll/nap/old/md5.c
Normal file
392
dll/nap/old/md5.c
Normal file
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
L. Peter Deutsch
|
||||
ghost@aladdin.com
|
||||
|
||||
*/
|
||||
/*$Id: md5.c 3 2008-02-25 09:49:14Z keaston $ */
|
||||
/*
|
||||
Independent implementation of MD5 (RFC 1321).
|
||||
|
||||
This code implements the MD5 Algorithm defined in RFC 1321.
|
||||
It is derived directly from the text of the RFC and not from the
|
||||
reference implementation.
|
||||
|
||||
The original and principal author of md5.c is L. Peter Deutsch
|
||||
<ghost@aladdin.com>. Other authors are noted in the change history
|
||||
that follows (in reverse chronological order):
|
||||
|
||||
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
|
||||
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
|
||||
1999-05-03 lpd Original version.
|
||||
*/
|
||||
|
||||
#include "md5.h"
|
||||
|
||||
#ifdef TEST
|
||||
/*
|
||||
* Compile with -DTEST to create a self-contained executable test program.
|
||||
* The test program should print out the same values as given in section
|
||||
* A.5 of RFC 1321, reproduced below.
|
||||
*/
|
||||
#include <string.h>
|
||||
main()
|
||||
{
|
||||
static const char *const test[7] = {
|
||||
"", /*d41d8cd98f00b204e9800998ecf8427e*/
|
||||
"a", /*0cc175b9c0f1b6a831c399e269772661*/
|
||||
"abc", /*900150983cd24fb0d6963f7d28e17f72*/
|
||||
"message digest", /*f96b697d7cb7938d525a2f31aaf161d0*/
|
||||
"abcdefghijklmnopqrstuvwxyz", /*c3fcd3d76192e4007dfb496cca67e13b*/
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
|
||||
/*d174ab98d277d9f5a5611c2c9f419d9f*/
|
||||
"12345678901234567890123456789012345678901234567890123456789012345678901234567890" /*57edf4a22be3c955ac49da2e2107b67a*/
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 7; ++i) {
|
||||
md5_state_t state;
|
||||
md5_byte_t digest[16];
|
||||
int di;
|
||||
|
||||
md5_init(&state);
|
||||
md5_append(&state, (const md5_byte_t *)test[i], strlen(test[i]));
|
||||
md5_finish(&state, digest);
|
||||
printf("MD5 (\"%s\") = ", test[i]);
|
||||
for (di = 0; di < 16; ++di)
|
||||
printf("%02x", digest[di]);
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* TEST */
|
||||
|
||||
|
||||
/*
|
||||
* For reference, here is the program that computed the T values.
|
||||
*/
|
||||
#if 0
|
||||
#include <math.h>
|
||||
main()
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i <= 64; ++i) {
|
||||
unsigned long v = (unsigned long)(4294967296.0 * fabs(sin((double)i)));
|
||||
printf("#define T%d 0x%08lx\n", i, v);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* End of T computation program.
|
||||
*/
|
||||
#define T1 0xd76aa478
|
||||
#define T2 0xe8c7b756
|
||||
#define T3 0x242070db
|
||||
#define T4 0xc1bdceee
|
||||
#define T5 0xf57c0faf
|
||||
#define T6 0x4787c62a
|
||||
#define T7 0xa8304613
|
||||
#define T8 0xfd469501
|
||||
#define T9 0x698098d8
|
||||
#define T10 0x8b44f7af
|
||||
#define T11 0xffff5bb1
|
||||
#define T12 0x895cd7be
|
||||
#define T13 0x6b901122
|
||||
#define T14 0xfd987193
|
||||
#define T15 0xa679438e
|
||||
#define T16 0x49b40821
|
||||
#define T17 0xf61e2562
|
||||
#define T18 0xc040b340
|
||||
#define T19 0x265e5a51
|
||||
#define T20 0xe9b6c7aa
|
||||
#define T21 0xd62f105d
|
||||
#define T22 0x02441453
|
||||
#define T23 0xd8a1e681
|
||||
#define T24 0xe7d3fbc8
|
||||
#define T25 0x21e1cde6
|
||||
#define T26 0xc33707d6
|
||||
#define T27 0xf4d50d87
|
||||
#define T28 0x455a14ed
|
||||
#define T29 0xa9e3e905
|
||||
#define T30 0xfcefa3f8
|
||||
#define T31 0x676f02d9
|
||||
#define T32 0x8d2a4c8a
|
||||
#define T33 0xfffa3942
|
||||
#define T34 0x8771f681
|
||||
#define T35 0x6d9d6122
|
||||
#define T36 0xfde5380c
|
||||
#define T37 0xa4beea44
|
||||
#define T38 0x4bdecfa9
|
||||
#define T39 0xf6bb4b60
|
||||
#define T40 0xbebfbc70
|
||||
#define T41 0x289b7ec6
|
||||
#define T42 0xeaa127fa
|
||||
#define T43 0xd4ef3085
|
||||
#define T44 0x04881d05
|
||||
#define T45 0xd9d4d039
|
||||
#define T46 0xe6db99e5
|
||||
#define T47 0x1fa27cf8
|
||||
#define T48 0xc4ac5665
|
||||
#define T49 0xf4292244
|
||||
#define T50 0x432aff97
|
||||
#define T51 0xab9423a7
|
||||
#define T52 0xfc93a039
|
||||
#define T53 0x655b59c3
|
||||
#define T54 0x8f0ccc92
|
||||
#define T55 0xffeff47d
|
||||
#define T56 0x85845dd1
|
||||
#define T57 0x6fa87e4f
|
||||
#define T58 0xfe2ce6e0
|
||||
#define T59 0xa3014314
|
||||
#define T60 0x4e0811a1
|
||||
#define T61 0xf7537e82
|
||||
#define T62 0xbd3af235
|
||||
#define T63 0x2ad7d2bb
|
||||
#define T64 0xeb86d391
|
||||
|
||||
static void
|
||||
md5_process(register md5_state_t *pms, const md5_byte_t *data /*[64]*/)
|
||||
{
|
||||
register md5_word_t
|
||||
a = pms->abcd[0], b = pms->abcd[1],
|
||||
c = pms->abcd[2], d = pms->abcd[3];
|
||||
md5_word_t t;
|
||||
|
||||
#ifndef ARCH_IS_BIG_ENDIAN
|
||||
# define ARCH_IS_BIG_ENDIAN 1 /* slower, default implementation */
|
||||
#endif
|
||||
#if ARCH_IS_BIG_ENDIAN
|
||||
|
||||
/*
|
||||
* On big-endian machines, we must arrange the bytes in the right
|
||||
* order. (This also works on machines of unknown byte order.)
|
||||
*/
|
||||
md5_word_t X[16];
|
||||
const md5_byte_t *xp = data;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; ++i, xp += 4)
|
||||
X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
|
||||
|
||||
#else /* !ARCH_IS_BIG_ENDIAN */
|
||||
|
||||
/*
|
||||
* On little-endian machines, we can process properly aligned data
|
||||
* without copying it.
|
||||
*/
|
||||
md5_word_t xbuf[16];
|
||||
const md5_word_t *X;
|
||||
|
||||
if (!((data - (const md5_byte_t *)0) & 3)) {
|
||||
/* data are properly aligned */
|
||||
X = (const md5_word_t *)data;
|
||||
} else {
|
||||
/* not aligned */
|
||||
memcpy(xbuf, data, 64);
|
||||
X = xbuf;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
|
||||
/* Round 1. */
|
||||
/* Let [abcd k s i] denote the operation
|
||||
a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
|
||||
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
|
||||
#define SET(a, b, c, d, k, s, Ti)\
|
||||
t = a + F(b,c,d) + X[k] + Ti;\
|
||||
a = ROTATE_LEFT(t, s) + b
|
||||
/* Do the following 16 operations. */
|
||||
SET(a, b, c, d, 0, 7, T1);
|
||||
SET(d, a, b, c, 1, 12, T2);
|
||||
SET(c, d, a, b, 2, 17, T3);
|
||||
SET(b, c, d, a, 3, 22, T4);
|
||||
SET(a, b, c, d, 4, 7, T5);
|
||||
SET(d, a, b, c, 5, 12, T6);
|
||||
SET(c, d, a, b, 6, 17, T7);
|
||||
SET(b, c, d, a, 7, 22, T8);
|
||||
SET(a, b, c, d, 8, 7, T9);
|
||||
SET(d, a, b, c, 9, 12, T10);
|
||||
SET(c, d, a, b, 10, 17, T11);
|
||||
SET(b, c, d, a, 11, 22, T12);
|
||||
SET(a, b, c, d, 12, 7, T13);
|
||||
SET(d, a, b, c, 13, 12, T14);
|
||||
SET(c, d, a, b, 14, 17, T15);
|
||||
SET(b, c, d, a, 15, 22, T16);
|
||||
#undef SET
|
||||
|
||||
/* Round 2. */
|
||||
/* Let [abcd k s i] denote the operation
|
||||
a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
|
||||
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
|
||||
#define SET(a, b, c, d, k, s, Ti)\
|
||||
t = a + G(b,c,d) + X[k] + Ti;\
|
||||
a = ROTATE_LEFT(t, s) + b
|
||||
/* Do the following 16 operations. */
|
||||
SET(a, b, c, d, 1, 5, T17);
|
||||
SET(d, a, b, c, 6, 9, T18);
|
||||
SET(c, d, a, b, 11, 14, T19);
|
||||
SET(b, c, d, a, 0, 20, T20);
|
||||
SET(a, b, c, d, 5, 5, T21);
|
||||
SET(d, a, b, c, 10, 9, T22);
|
||||
SET(c, d, a, b, 15, 14, T23);
|
||||
SET(b, c, d, a, 4, 20, T24);
|
||||
SET(a, b, c, d, 9, 5, T25);
|
||||
SET(d, a, b, c, 14, 9, T26);
|
||||
SET(c, d, a, b, 3, 14, T27);
|
||||
SET(b, c, d, a, 8, 20, T28);
|
||||
SET(a, b, c, d, 13, 5, T29);
|
||||
SET(d, a, b, c, 2, 9, T30);
|
||||
SET(c, d, a, b, 7, 14, T31);
|
||||
SET(b, c, d, a, 12, 20, T32);
|
||||
#undef SET
|
||||
|
||||
/* Round 3. */
|
||||
/* Let [abcd k s t] denote the operation
|
||||
a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
|
||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define SET(a, b, c, d, k, s, Ti)\
|
||||
t = a + H(b,c,d) + X[k] + Ti;\
|
||||
a = ROTATE_LEFT(t, s) + b
|
||||
/* Do the following 16 operations. */
|
||||
SET(a, b, c, d, 5, 4, T33);
|
||||
SET(d, a, b, c, 8, 11, T34);
|
||||
SET(c, d, a, b, 11, 16, T35);
|
||||
SET(b, c, d, a, 14, 23, T36);
|
||||
SET(a, b, c, d, 1, 4, T37);
|
||||
SET(d, a, b, c, 4, 11, T38);
|
||||
SET(c, d, a, b, 7, 16, T39);
|
||||
SET(b, c, d, a, 10, 23, T40);
|
||||
SET(a, b, c, d, 13, 4, T41);
|
||||
SET(d, a, b, c, 0, 11, T42);
|
||||
SET(c, d, a, b, 3, 16, T43);
|
||||
SET(b, c, d, a, 6, 23, T44);
|
||||
SET(a, b, c, d, 9, 4, T45);
|
||||
SET(d, a, b, c, 12, 11, T46);
|
||||
SET(c, d, a, b, 15, 16, T47);
|
||||
SET(b, c, d, a, 2, 23, T48);
|
||||
#undef SET
|
||||
|
||||
/* Round 4. */
|
||||
/* Let [abcd k s t] denote the operation
|
||||
a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
|
||||
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
|
||||
#define SET(a, b, c, d, k, s, Ti)\
|
||||
t = a + I(b,c,d) + X[k] + Ti;\
|
||||
a = ROTATE_LEFT(t, s) + b
|
||||
/* Do the following 16 operations. */
|
||||
SET(a, b, c, d, 0, 6, T49);
|
||||
SET(d, a, b, c, 7, 10, T50);
|
||||
SET(c, d, a, b, 14, 15, T51);
|
||||
SET(b, c, d, a, 5, 21, T52);
|
||||
SET(a, b, c, d, 12, 6, T53);
|
||||
SET(d, a, b, c, 3, 10, T54);
|
||||
SET(c, d, a, b, 10, 15, T55);
|
||||
SET(b, c, d, a, 1, 21, T56);
|
||||
SET(a, b, c, d, 8, 6, T57);
|
||||
SET(d, a, b, c, 15, 10, T58);
|
||||
SET(c, d, a, b, 6, 15, T59);
|
||||
SET(b, c, d, a, 13, 21, T60);
|
||||
SET(a, b, c, d, 4, 6, T61);
|
||||
SET(d, a, b, c, 11, 10, T62);
|
||||
SET(c, d, a, b, 2, 15, T63);
|
||||
SET(b, c, d, a, 9, 21, T64);
|
||||
#undef SET
|
||||
|
||||
/* Then perform the following additions. (That is increment each
|
||||
of the four registers by the value it had before this block
|
||||
was started.) */
|
||||
pms->abcd[0] += a;
|
||||
pms->abcd[1] += b;
|
||||
pms->abcd[2] += c;
|
||||
pms->abcd[3] += d;
|
||||
}
|
||||
|
||||
void
|
||||
md5_init(md5_state_t *pms)
|
||||
{
|
||||
pms->count[0] = pms->count[1] = 0;
|
||||
pms->abcd[0] = 0x67452301;
|
||||
pms->abcd[1] = 0xefcdab89;
|
||||
pms->abcd[2] = 0x98badcfe;
|
||||
pms->abcd[3] = 0x10325476;
|
||||
}
|
||||
|
||||
void
|
||||
md5_append(register md5_state_t *pms, const md5_byte_t *data, int nbytes)
|
||||
{
|
||||
const register md5_byte_t *p = data;
|
||||
int register left = nbytes;
|
||||
int offset = (pms->count[0] >> 3) & 63;
|
||||
md5_word_t nbits = (md5_word_t)(nbytes << 3);
|
||||
|
||||
if (nbytes <= 0)
|
||||
return;
|
||||
|
||||
/* Update the message length. */
|
||||
pms->count[1] += nbytes >> 29;
|
||||
pms->count[0] += nbits;
|
||||
if (pms->count[0] < nbits)
|
||||
pms->count[1]++;
|
||||
|
||||
/* Process an initial partial block. */
|
||||
if (offset) {
|
||||
int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
|
||||
|
||||
memcpy(pms->buf + offset, p, copy);
|
||||
if (offset + copy < 64)
|
||||
return;
|
||||
p += copy;
|
||||
left -= copy;
|
||||
md5_process(pms, pms->buf);
|
||||
}
|
||||
|
||||
/* Process full blocks. */
|
||||
for (; left >= 64; p += 64, left -= 64)
|
||||
md5_process(pms, p);
|
||||
|
||||
/* Process a final partial block. */
|
||||
if (left)
|
||||
memcpy(pms->buf, p, left);
|
||||
}
|
||||
|
||||
void
|
||||
md5_finish(register md5_state_t *pms, md5_byte_t digest[16])
|
||||
{
|
||||
static const md5_byte_t pad[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
md5_byte_t data[8];
|
||||
register int i;
|
||||
|
||||
/* Save the length before padding. */
|
||||
for (i = 0; i < 8; ++i)
|
||||
data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
|
||||
/* Pad to 56 bytes mod 64. */
|
||||
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
|
||||
/* Append the length. */
|
||||
md5_append(pms, data, 8);
|
||||
for (i = 0; i < 16; ++i)
|
||||
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
|
||||
}
|
||||
94
dll/nap/old/md5.h
Normal file
94
dll/nap/old/md5.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
L. Peter Deutsch
|
||||
ghost@aladdin.com
|
||||
|
||||
*/
|
||||
/*$Id: md5.h 3 2008-02-25 09:49:14Z keaston $ */
|
||||
/*
|
||||
Independent implementation of MD5 (RFC 1321).
|
||||
|
||||
This code implements the MD5 Algorithm defined in RFC 1321.
|
||||
It is derived directly from the text of the RFC and not from the
|
||||
reference implementation.
|
||||
|
||||
The original and principal author of md5.h is L. Peter Deutsch
|
||||
<ghost@aladdin.com>. Other authors are noted in the change history
|
||||
that follows (in reverse chronological order):
|
||||
|
||||
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
|
||||
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
|
||||
added conditionalization for C++ compilation from Martin
|
||||
Purschke <purschke@bnl.gov>.
|
||||
1999-05-03 lpd Original version.
|
||||
*/
|
||||
|
||||
#ifndef md5_INCLUDED
|
||||
# define md5_INCLUDED
|
||||
|
||||
/*
|
||||
* This code has some adaptations for the Ghostscript environment, but it
|
||||
* will compile and run correctly in any environment with 8-bit chars and
|
||||
* 32-bit ints. Specifically, it assumes that if the following are
|
||||
* defined, they have the same meaning as in Ghostscript: P1, P2, P3,
|
||||
* ARCH_IS_BIG_ENDIAN.
|
||||
*/
|
||||
|
||||
typedef unsigned char md5_byte_t; /* 8-bit byte */
|
||||
typedef unsigned int md5_word_t; /* 32-bit word */
|
||||
|
||||
/* Define the state of the MD5 Algorithm. */
|
||||
typedef struct md5_state_s {
|
||||
md5_word_t count[2]; /* message length in bits, lsw first */
|
||||
md5_word_t abcd[4]; /* digest buffer */
|
||||
md5_byte_t buf[64]; /* accumulate block */
|
||||
} md5_state_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Initialize the algorithm. */
|
||||
#ifdef P1
|
||||
void md5_init(P1(md5_state_t *pms));
|
||||
#else
|
||||
void md5_init(md5_state_t *pms);
|
||||
#endif
|
||||
|
||||
/* Append a string to the message. */
|
||||
#ifdef P3
|
||||
void md5_append(P3(md5_state_t *pms, const md5_byte_t *data, int nbytes));
|
||||
#else
|
||||
void md5_append(register md5_state_t *pms, const md5_byte_t *data, int nbytes);
|
||||
#endif
|
||||
|
||||
/* Finish the message and return the digest. */
|
||||
#ifdef P2
|
||||
void md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16]));
|
||||
#else
|
||||
void md5_finish(register md5_state_t *pms, md5_byte_t digest[16]);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* md5_INCLUDED */
|
||||
BIN
dll/nap/test
Executable file
BIN
dll/nap/test
Executable file
Binary file not shown.
23
dll/nap/test.c
Normal file
23
dll/nap/test.c
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
#include <stdio.h>
|
||||
unsigned short len = 0;
|
||||
unsigned char blah[3];
|
||||
|
||||
main()
|
||||
{
|
||||
int burp = 1;
|
||||
blah[2] = '\224';
|
||||
blah[3] = '\1';
|
||||
blah[0] = '\027';
|
||||
blah[1] = 0x0;
|
||||
memcpy(&len, blah, sizeof(len));
|
||||
printf("%d\n", len);
|
||||
memcpy(&len, blah+2, sizeof(len));
|
||||
printf("%d\n", len);
|
||||
printf("%d ", burp);
|
||||
burp += 0xf0;
|
||||
printf("%d ", burp);
|
||||
printf("and %d ", burp & ~0xf0);
|
||||
printf("or %d \n", burp | 0xf0);
|
||||
|
||||
}
|
||||
13
dll/nap/to-do
Normal file
13
dll/nap/to-do
Normal file
@@ -0,0 +1,13 @@
|
||||
[Nap] Recieved error for [609] booz_hound
|
||||
|
||||
"\home\mp3\incoming\VA-Promo_Only_Canadian_Modern_Rock_November_1999-
|
||||
KSI\10-silverchair-miss_you_love-ksi.mp3".
|
||||
[Nap] Recieved error for [609] jaime_romain
|
||||
"\home\mp3\Albums5\Rosie_ODonnell-A_Rosie_Christmas-1999-EGO\09-rosie
|
||||
_odonnell-last_christmas_ft._darren_hayes-ego.mp3".
|
||||
[Nap] Recieved error for [609] booz_hound
|
||||
|
||||
"\home\mp3\incoming\Various_Artists-WBCN_Naked_Disc_2000-ALLiED\08-si
|
||||
lverchair-anthem_for_the_year_2000-allied.mp3".
|
||||
|
||||
remove person from send queue on receipt of 609
|
||||
Reference in New Issue
Block a user