New mailsend

This commit is contained in:
2020-09-01 01:15:02 -04:00
parent ccafb2b838
commit 8a89238897
126 changed files with 26685 additions and 664 deletions
+10 -6
View File
@@ -112,21 +112,25 @@ int SMTP2( const char * _server, const char * _from, char * _to, char * _body, c
if (subject == NULL)
{
subject = new char[15];
strcpy(subject,"PayLid Support");
strcpy(subject,"Wrenchboard Support");
logfmt( FLOG_MAX, "Subject is not found - defaulting to: %s", subject );
}
// Google
snprintf( name, BUF_SIZE, EMAIL_PREFIX"/../src/modules/mailsend -smtp %s -f %s -t %s -d %s -name '%s' +cc +bcc -v -starttls -auth-plain -user %s -pass %s -sub '%s' -M '%s'",
snprintf( name, BUF_SIZE, EMAIL_PREFIX"/../src/modules/mailsend -smtp %s -f %s -t %s -domain %s -name '%s' +cc +bcc -v -starttls -port 587 -auth-plain -user %s -pass %s -sub '%s' -content-type 'text/html' -mime-type 'text/html' -M '%s'",
_server, _from, _to, _domain, _name, _user, _pass, subject, body != NULL ? body : _body );
/*
// Virtualmail
snprintf( name, BUF_SIZE, EMAIL_PREFIX"/../src/modules/mailsend -smtp %s -f %s -t %s -d %s -name '%s' +cc +bcc -v -port 25 -auth-plain -user %s -pass %s -sub '%s' -M '%s'",
snprintf( name, BUF_SIZE, EMAIL_PREFIX"/../src/modules/mailsend -smtp %s -f %s -t %s -domain %s -name '%s' +cc +bcc -v -port 25 -auth-plain -user %s -pass %s -sub '%s' -content-type 'text/html' -mime-type 'text/html' -M '%s'",
_server, _from, _to, _domain, _name, _user, _pass, subject, body != NULL ? body : _body );
*//*
// GoDaddy
snprintf( name, BUF_SIZE, EMAIL_PREFIX"/../src/modules/mailsend -smtp %s -f %s -t %s -domain %s -name '%s' +cc +bcc -v -port 80 -auth-plain -user %s -pass %s -sub '%s' -content-type 'text/html' -mime-type 'text/html' -M '%s'",
_server, _from, _to, _domain, _name, _user, _pass, subject, body != NULL ? body : _body );
*/
logfmt( FLOG_MAX, "Calling MAILSEND: %s", name);
FILE * p = popen( name, "r" );
FILE * p = popen( name, "r" );
int c = 0;
do
+25
View File
@@ -0,0 +1,25 @@
Copyright (C) 2001-2017 Muhammad Muquit (http://www.muquit.com/)
o Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
o Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
o Neither the name of the author MUHAMMAD MUQUIT (http://www.muquit.com/)
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+259
View File
@@ -0,0 +1,259 @@
__TOC__
===1.20b2===
* Change Content-type to Content-Type. According to RFC, mail headers are not case sensitive. However, some servers wrongly think they are. MailHog thinks Content-type is not valid and fails to detect MIME parts.
'''Jan-10-2019'''
===1.20b1===
* File path was covnerted to lower case when calculating MIME-TYPE from
file extension. Fixes #140
'''(Aug-29-2018)'''
* Merge develop branch. Fixes #108 #111
'''(May-08-2017)'''
===1.19===
* New option <code>-rp</code> to specify the return path of the sent email which can be used where the bounced mails will be sent. Thanks to kullmanp for adding this feature.
'''(Mar-17-2016)'''
* In quiet mode (-q), list of one line attachments were still printed on stdout.
* Windows binary linked with OpenSSl 1.0.2h
'''(May-17-2016)'''
===1.18===
* Added -read-timeout flag. Default timeout is 5 seconds. When -starttls flag was used with ssl port 465 at gmail, recv() was blocked for a long time. Fixes #61.
'''(Jun-20-2015)'''
===1.17b15===
* Released for testing.
'''(May-25-2014)'''
* When the mail is sent in interactive mode, add a CRLF after the last header. Fixes #58
'''(May-24-2014)'''
* Read multi line SMTP response messages. Before if the status code was not what was expected, read was stopped after reading the first line. Sometimes it is useful to see all the lines as the messages could tell what is wrong. Fixes #57
'''(May-24-2014)'''
* If no encoding type was specified for a one line message, it was NULL and a debug message tried to print it causing a seg fault. Fixes Issue #45.
'''(Feb-01-2014)'''
* The flag <code>-emdbed-image img1 -embed-image imd2</code> etc to embed image in HTML.
'''(Dec-27-2013)'''
* The flag <code>-d</code> is changed to <code>-domain</code>. Added new option <code>-disposition</code> to specify the type of content disposition.
'''(Dec-22-2013)'''
* <code>-enc</code> flag is changed to <code>-enc-type</code> which is used for encoding type of one line messages. This option can be used with <code>-M</code> or <code>-attach</code>.
'''(Dec-08-2013)'''
* Major changes on how things work. Now each of one line message can have its own character set, mime type and encoding type. Before there was not way to distinguish the messages. The optiopn -attach option also behaves the same way.
* Fixes Issue 29. A file can be included as body of the mail with the flag <code>-msg-body file</code>. The character set and mime type can be specified with -cs and -mime-type flags but files can not be encoded.
* Fixes Issue 37. A new flags <code>-mime-type "type"</code> can be used to specify the MIME type. Default is text/plain. It can be used with -M or -attach.
'''(Dec-08-2013)'''
* Fixes Issue 36. Only specify filename with <code>-attach</code>. Specify other MIME * parameters with appropriate flags.
'''(Dec-07-2013)'''
* Fixes Issue 35. The default encoding type is base64. If no encoding should be used, specify encoding type with <code>-enc-type "none"</code>.
'''(Dec-07-2013)'''
* Fixess Issue 34. Try the current addrinfo in </code>connect()</code>, mistakenly the first one was used. If </code>getaddrinfo()</code> returned multiple results and if connect() to first address failed, the rest of the addresses were not tried. Patch sent by Peter Liu.
'''(Nov-27-2013)'''
* Fixes Issue 30. Support custom Content-type header and to support Conent-ID. The custom Conent-type can be specified with the option <code>-conent-type</code> and the Conent-ID of the attachment can be specified as fifth value of the -attach option. Thanks to skalogryz for supplying the patch.
'''(Nov-06-2013)'''.
* Fixes Issue 26. Added options <code>-4</code> and <code>-6</code> to force using IPv4 or IPv6 address of the SMTP server.
'''(Oct-20-2013)'''
=== 1.17b14===
* Multiline input with <code>-M</code> was completely broken.
'''(Oct-20-2013)'''
===1.17b13===
* Changed Copyright to more flexible BSD from GNU GPL. Added <code>-copyright</code> flag.
'''(Oct-12-2013)'''
* SMTP authentication was broken if the username and passwords are long enough to create longer than 60 characters base64 encoded string. A newline was added after 60 characters causing authentication to fail.
Fixes Issue 20. Fixes Issue 22.
'''(Oct-12-2013)'''
* Support DESTDIR during installation. Fixes Issue 5.
* Don't show SSL info in quiet mode. Fixes Issue 21.
'''(Oct-12-2013)'''
* New ommand line option -enc for Content-Transfer-Encoding. If your one line text message with -M is non-ascii, you should use -enc base64. Note: non-ascii input from windows cmd does not work at this time,
however it works fine in linux and mac.
'''(Jul-01-2013)'''
===1.17b12===
* Add \r\n to multiple one line messages specified by <code>-M</code>. Possible Fix for Issue 12.
* Do not show attachments in verbose mode. The option -show_attach will enable it. Fixes Issue 13.
'''(Jun-16-2013)'''
===1.17b11===
* mailsend writes "Mail sent successfully" message on stdout in interactive mode even if -quiet flag is used. Fixes Issue 6.
'''(May-05-2013)'''
===1.17b10===
* If there are some kind of socket error, print the error message. If a log file is specified with -log, the error will be written there.
'''(Mar-23-2013)'''
* modified Makefile.in to support make -j. Fixes Issue 4.
* fixed several warnings
'''(Apr-27-2013)'''
===1.17b9===
* There was a bug if multiple attachments were specified. The temp file was
created only once and was removed. The bug shows up in Windows.
* The flag -l is changed to -list.
* A new flag -log is added for logging status messages to a file. It is very alpha at the moment. User -v to see anything useful. The log messages are time stamped.
'''(Mar-16-2013)'''
===1.17b8===
* Print more error messages.
'''(Mar-06-2013)'''
===1.17b7===
* Print some error message with errno.
'''(Mar-06-2013)'''
===1.17b6===
* MIME temp file was created on current working directory. Now go through some huristics to determine the path.
'''(Mar-05-2013)'''
===1.17b5===
* </code>getaddrinfo()</code> was not found in ws2_32 dll in Windows 2000. included Wspiapi.h header in msock library as per Microsoft <http://support.microsoft.com/kb/955045>. Thanks to Bob R for reporting the issue. It's a Windows only change.
'''(Feb-21-2013)'''
===1.17b4===
* Added flag -H "header" to add custom headers. For example: -H "X-Priority: 1" -H "Importance: high". Requested by David Young.
'''(Feb-12-2013)'''
===1.17b3===
* Individual auth flags were not working.
'''(Jan-21-2013)'''
===1.17b2===
* IPv6 address was printed wrong.
'''(Aug-26-2012)'''
===1.17b1===
* IPv6 support for all platforms.
'''(Aug-25-2012)'''
* Multiple one line message can be added with -M, for example: <code>-M "message line 1" -M message line 2"</code>
'''(Aug-26-2012)'''
* First cut of debian package.
* After sending SMTP EOM, the status code was not checked. It is possible that the server has rejected the mail due to message too large etc. Thanks to Peter Soppe for reporting it.
'''(Aug-24-2012)'''
* Do not enforce authentication just because server supports it. Do it only if the user wants it.
'''(Jun-29-2012)'''
* Added flag <code>-ct <seconds></code> for connect timeout with SMTP server. The default default timeout is 5 seconds.
* Exit with 0 if everything went well otherwise exit with 1 in case of error.
* created man page. Added install target to Makefile.
'''(July-05-2012)'''
===1.16===
* Added support for SMTP over SSL with -ssl. It is different than STARTTLS in the sense that it is not part of SMTP protocol, the entire connection is encrypted from start to end. Note: No checking is performed on certificate. At this time, smtp.gmail.com does SMTP over SSL on port 465.
'''(Feb-27-2012)'''
* Cleaned up examples. Examples can be seen with -ex, before at least -exa was needed.
'''(Feb-27-2012)'''
* Created Makefile.nmake for MS Visual Studio 10.
'''(Feb-28-2012)'''
===1.15b5===
* New flag '-name "Your Name"' can be used to add your name in the From header, e.g. -f jdoe@example.com -name "John Doe" will create the From header as: From: John Doe <jdoe@example.com>
'''(Apr-24-2007)'''
* Changed >> to [C] and << to [S] in debug output to represent Client and Server respectively.
'''(Apr-25-2007)'''
* The flags '-d domain' is not mandatory anymore. If not specified "localhost" will be used as domain in HELO or EHLO.
'''(Apr-25-2007)'''
===1.15b4===
* When using -info and -smtp, message was wrong.
* Greetings can be multi line. Thanks to Keith B Smith.
* Some server don't say ESMTP in the greetings, but still supports it. In that case force EHLO with -esmtp. Again Thanks to Keith B Smith.
* The flag <code>-ex</code> is now <code>-example</code>.
'''(Mar-18-2007)'''
===1.15b3===
* Compiled on Windows with openssl 0.9.7l.
* If addresses are specified in a file with -l, do not ask for To. Addresses int he file not not validated howerver.
===1.15b2===
* New flag -ex show examples.
* New flag -info to show SMTP server info.
* Few bug fixes
'''(Feb-18-2007)'''
===1.15a===
* Added support for AUTH CRAM-MD5, AUTH PLAIN and AUTH LOGIN autentication.
'''(Feb-17-2007)'''
* Added support for AUTH PLAIN
'''(Feb-11-2007)'''
* The flag "-a" is changed to "-attach"
'''(Feb-11-2007)'''
* The flags "-m" is gone. There is no need for it anymore, as attachment type can be changed with i or a with the flag -a. If you want a "body" text, specify it with -a "file.txt,text/plain,i" as the first attachment.
'''(Feb-11-2007)'''
* STARTTLS support. If the SMTP server supports it, enable it in mailsend with flag "-starttls".
'''(Feb-11-2007)'''
===1.14===
* Content-disposition can be changed to attachment or inline. Example: -a * "file.gif,image/gif,i". The default is attachment. -a * "file.gif,image.gif,a" is same as a "file.gif,image/gif"
'''(Feb-06-2007)'''
* Bcc was broken
'''(Nov-03-2006)'''
===1.13===
* If no subject is specified with -sub, it'll be empty. Before the default subject was "hello!"
'''(Jun-25-2006)'''
* The flag -M was broken. Thanks to Amnon S for reporting it.
'''(Jun-25-2006)'''
* For text attachments, Content-Disposition was always inline. Now it'll be attachment. Thanks to Danny Casier.
'''(May-21-2006)'''
===1.12===
* mailsend was not adding Date header. Some SMTP servers does not add it either. Now by default it'll add the Date header (make sure your clock is set properly). If you don't want mailsend to add Date header, use the flag +D. Thanks to Mr S J Hannan for the bug report.
'''(May-20-2006)'''
===1.11===
* Attachment seperator character is changed to a , from :. Because in Windows drive is specified with :. Thanks to Jeppe Teglgaard Mohr for pointing it out. Example: -a "c:\file.gif,image/gif"
'''(Apr-23-2006)'''
* The flag -m is back. This option can be used to attach a text or html file as a blody (inline). Example: -m "file.html,text/html". It is the caller's responsibily to make sure file type is correct. mailsend will not verify if the file is binary or text.
'''(Apr-23-2006)'''
* New flag -rrr to request read receipts. Suggested by marc hubaut.
'''(May-14-2006)'''
* New flag -rt to add Reply-To header.
'''(May-14-2006)'''
===1.10===
* If the attachment type was text/plain, <CR><LF> was not added after Content-Disposition line which caused attachment to be ignored by some mail readers.
+71 -16
View File
@@ -2,9 +2,30 @@
# Makefile automatically generated by genmake 1.0, May-03-00
# genmake 1.0 by muquit@muquit.com, http://www.muquit.com/
##
srcdir = .
top_srcdir = .
CC= gcc
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_MALLOC_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CTYPE_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_FLOCK=1 -DHAVE_SOCKET=1 -DHAVE_HTONL=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETHOSTBYADDR=1 -DHAVE_YP_GET_DEFAULT_DOMAIN=1 -DHAVE_LIBNSL=1 -DHAVE_RES_SEARCH=1 -DHAVE_LIBRESOLV=1 -DHAVE_INET_ATON=1 -DHAVE_DN_SKIPNAME=1 -DHAVE_MKSTEMP=1 -DHAVE_OPENSSL=1 -DUNIX
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_MALLOC_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CTYPE_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_LIMITS_H=1 -DHAVE_FLOCK=1 -DHAVE_SOCKET=1 -DHAVE_HTONL=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETHOSTBYADDR=1 -DHAVE_RES_SEARCH=1 -DHAVE_LIBRESOLV=1 -DHAVE_INET_ATON=1 -DHAVE_DN_SKIPNAME=1 -DHAVE_MKSTEMP=1 -DHAVE_GETADDRINFO=1 -DUNIX
PROGNAME= mailsend
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
DESTDIR =
prefix = /usr/local
exec_prefix = ${prefix}
datarootdir = ${prefix}/share
datadir = ${datarootdir}
bindir = ${exec_prefix}/bin
mandir = ${datarootdir}/man
man1dir = $(mandir)/man1
BINDIR = $(DESTDIR)$(bindir)
MAN1DIR = $(DESTDIR)$(man1dir)
#BINDIR= /usr/bin
MANPAGE= doc/mailsend.1.gz
#MANDIR= /usr/share/man/man1
MUTILS_INCLUDE= -I./libs/libmutils
MSOCK_INCLUDE= -I./libs/libmsock
@@ -14,38 +35,72 @@ MUTILS_LIB= ./libs/libmutils/libmutils.a
MSOCK_LIB=./libs/libmsock/libmsock.a
SLL_LIB= ./libs/libsll/libsll.a
OPENSSL_DIR=/usr/
OPENSSL_INC=-I/usr/include
#OPENSSL_LIBS=-L/usr/lib -lssl -lcrypto -ldl
OPENSSL_DIR=
OPENSSL_INC=
OPENSSL_LIBS=
INCLUDES= -I. -I/usr/include/malloc $(MUTILS_INCLUDE) $(MSOCK_INCLUDE) $(SLL_INCLUDE) $(OPENSSL_INC)
STRIP=/usr/bin/strip
INCLUDES= -I. $(MUTILS_INCLUDE) $(MSOCK_INCLUDE) $(SLL_INCLUDE) $(OPENSSL_INC)
DEFINES= $(INCLUDES) $(DEFS) -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 \
-DHAVE_MATH_H=1
CFLAGS= -g -O2 -Wall $(DEFINES)
LIBS=$(MSOCK_LIB) $(SLL_LIB) $(MUTILS_LIB) -L/usr/lib -lssl -lcrypto -ldl
LIBS=$(MSOCK_LIB) $(SLL_LIB) $(MUTILS_LIB) $(OPENSSL_LIBS) -lresolv
SRCS = main.c smtp.c utils.c setget.c
OBJS = main.o smtp.o utils.o setget.o
SRCS = main.c smtp.c utils.c setget.c examples.c
OBJS = main.o smtp.o utils.o setget.o examples.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: mlibs $(PROGNAME)
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(PROGNAME) : mlibs $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(PROGNAME) $(LIBS)
cp -f $(PROGNAME) ../modules/
mlibs:
install: installdirs install-bin install-man
install-bin: $(BINDIR) $(PROGNAME)
$(INSTALL_PROGRAM) $(PROGNAME) $(BINDIR)/$(PROGNAME)
install-man:
$(INSTALL_DATA) $(MANPAGE) $(MAN1DIR)
installdirs:
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${bindir}
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man1
deb:
@ruby ./mk_debian_package.rb
help:
@echo "make - to compile"
@echo "make install - to install"
@echo "make docs - generate document"
@echo "make deb - create debian package"
docs:
@ruby scripts/mk_doc.rb
ex:
@ruby scripts/mk_examples.rb > examples.c
libmsock: libmutils
(cd libs/libmsock && make)
libmutils:
(cd libs/libmutils && make)
(cd libs/libsll && make)
libsll:
(cd libs/libsll && make)
mlibs: libmsock libsll
clean:
(cd libs/libmsock && make clean)
(cd libs/libmutils && make clean)
(cd libs/libsll && make clean)
+(cd libs/libmsock && make clean)
+(cd libs/libmutils && make clean)
+(cd libs/libsll && make clean)
rm -f *.o *~ core $(PROGNAME)
+106
View File
@@ -0,0 +1,106 @@
##
# Makefile automatically generated by genmake 1.0, May-03-00
# genmake 1.0 by muquit@muquit.com, http://www.muquit.com/
##
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
CC= @CC@
DEFS= @DEFS@ -DUNIX
PROGNAME= mailsend
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
DESTDIR =
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
bindir = @bindir@
mandir = @mandir@
man1dir = $(mandir)/man1
BINDIR = $(DESTDIR)$(bindir)
MAN1DIR = $(DESTDIR)$(man1dir)
#BINDIR= /usr/bin
MANPAGE= doc/mailsend.1.gz
#MANDIR= /usr/share/man/man1
MUTILS_INCLUDE= -I./libs/libmutils
MSOCK_INCLUDE= -I./libs/libmsock
SLL_INCLUDE= -I./libs/libsll
MUTILS_LIB= ./libs/libmutils/libmutils.a
MSOCK_LIB=./libs/libmsock/libmsock.a
SLL_LIB= ./libs/libsll/libsll.a
OPENSSL_DIR=@OPENSSL_DIR@
OPENSSL_INC=@OPENSSL_INC@
OPENSSL_LIBS=@OPENSSL_LIBS@ @DL_LIB@
STRIP=@STRIP@
INCLUDES= -I. $(MUTILS_INCLUDE) $(MSOCK_INCLUDE) $(SLL_INCLUDE) $(OPENSSL_INC)
DEFINES= $(INCLUDES) $(DEFS) -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 \
-DHAVE_MATH_H=1
CFLAGS= @CFLAGS@ $(DEFINES)
LIBS=$(MSOCK_LIB) $(SLL_LIB) $(MUTILS_LIB) $(OPENSSL_LIBS) @LIBS@
SRCS = main.c smtp.c utils.c setget.c examples.c
OBJS = main.o smtp.o utils.o setget.o examples.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: $(PROGNAME)
$(PROGNAME) : mlibs $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(PROGNAME) $(LIBS)
install: installdirs install-bin install-man
install-bin: $(BINDIR) $(PROGNAME)
$(INSTALL_PROGRAM) $(PROGNAME) $(BINDIR)/$(PROGNAME)
install-man:
$(INSTALL_DATA) $(MANPAGE) $(MAN1DIR)
installdirs:
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${bindir}
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man1
deb:
@ruby ./mk_debian_package.rb
help:
@echo "make - to compile"
@echo "make install - to install"
@echo "make docs - generate document"
@echo "make deb - create debian package"
docs:
@ruby scripts/mk_doc.rb
ex:
@ruby scripts/mk_examples.rb > examples.c
libmsock: libmutils
(cd libs/libmsock && make)
libmutils:
(cd libs/libmutils && make)
libsll:
(cd libs/libsll && make)
mlibs: libmsock libsll
clean:
+(cd libs/libmsock && make clean)
+(cd libs/libmutils && make clean)
+(cd libs/libsll && make clean)
rm -f *.o *~ core $(PROGNAME)
+58
View File
@@ -0,0 +1,58 @@
##
# Makefile automatically generated by genmake 1.0, May-03-00
# genmake 1.0 by muquit@muquit.com, http://www.muquit.com/
# updated for MS Visutal Studio 10 Feb-27-2012
##
PROGNAME= mailsend.exe
LINKER=link -nologo
OPENSSL_DIR=c:/openssl
OPENSSL_INC=-I$(OPENSSL_DIR)/include
OPENSSL_LIBS=$(OPENSSL_DIR)/lib/libeay32.lib $(OPENSSL_DIR)/lib/ssleay32.lib
MUTILS_INCLUDE= -I./libs/libmutils
MSOCK_INCLUDE= -I./libs/libmsock
SLL_INCLUDE= -I./libs/libsll
INCLUDES= -I. $(MUTILS_INCLUDE) $(MSOCK_INCLUDE) $(SLL_INCLUDE) $(OPENSSL_INC)
MUTILS_LIB= ./libs/libmutils/mutils.lib
MSOCK_LIB=./libs/libmsock/msock.lib
SLL_LIB= ./libs/libsll/sll.lib
# don't define -DSYS_WIN32.. win2k complains
DEFINES= $(INCLUDES) $(DEFS) -DWINNT=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MATH_H=1 -DHAVE_OPENSSL=1 -DHAVE_GETADDRINFO=1
CFLAGS= $(DEFINES) /Ox /W3 /wd4996 /nologo
WINDOWS_LIBS=ws2_32.lib shell32.lib advapi32.lib user32.lib gdi32.lib winmm.lib comdlg32.lib comctl32.lib
LIBS=$(MSOCK_LIB) $(SLL_LIB) $(MUTILS_LIB) $(OPENSSL_LIBS) $(WINDOWS_LIBS)
SRCS = main.c smtp.c utils.c setget.c examples.c
OBJS = main.obj smtp.obj utils.obj setget.obj examples.obj
all: $(PROGNAME)
$(PROGNAME) : LIBRARIES $(OBJS)
$(CC) $(CFLAGS) $(LIBS) $(OBJS) /Fe$(PROGNAME)
LIBRARIES:
cd libs\libsll
nmake -f Makefile.nmake
cd ..\..
cd libs\libmsock
nmake -f Makefile.nmake
cd ..\..
cd libs\libmutils
nmake -f Makefile.nmake
cd ..\..
clean:
del $(OBJS) $(PROGNAME)
cd libs\libsll
nmake -f Makefile.nmake clean
cd ..\..
cd libs\libmsock
nmake -f Makefile.nmake clean
cd ..\..
cd libs\libmutils
nmake -f Makefile.nmake clean
cd ..\..
+96
View File
@@ -0,0 +1,96 @@
My Personal notes
=================
How to release
--------------
* pixel
- compile windows binary
- test by running test_gmail.sh
* t105
- compile. run make docs
- ldd mailsend to make sure libs are ok.
- test by running test_gmail.sh
- cp mailsend.exe mailsendV.exe
- zip mailsendV.zip mailsendV.exe
- update issues if needed.
--
Apr-28-2013
Notes on mixing and embedding attachment
========================================
* Just embed images, say 2 images
Content-Type: multipart/related: boundary=relate
--relate
Content-Type: multipart/alternative; boundary=alt
--alt
Content-Type: text/html; charset=ISO-8859-1
<img src="cid:img1_deadbeef" alt="image 1">
<br>
<img src="cid:img2_deadbeef" alt="image 2">
--alt--
--relate
Content-Type: image/jpeg; name="test1.jpg"
Content-Transfer-Encoding: base64
Content-ID: <img1_deadbeef>
X-Attachment-Id: img1_deadbeef
base64........
base64........
--start
Content-Type: image/png; name="test.png"
Content-Transfer-Encoding: base64
Content-ID: <img2_deadbeef>
X-Attachment-Id: img2_deadbeef
base64........
base64........
--relate--
* embedded images and a pdf attachment
--------------------------------------------
Content-Type: multipart/mixed: boundary=mixed
--mixed
Content-Type: multipart/related: boundary=relate
--relate
Content-Type: multipart/alternative; boundary=alt
--alt
Content-Type: text/html; charset=ISO-8859-1
<img src="cid:img1_deadbeef" alt="image 1">
<br>
<img src="cid:img2_deadbeef" alt="image 2">
--alt--
--relate
Content-Type: image/jpeg; name="test1.jpg"
Content-Transfer-Encoding: base64
Content-ID: <img1_deadbeef>
X-Attachment-Id: img1_deadbeef
base64........
base64........
--start
Content-Type: image/png; name="test.png"
Content-Transfer-Encoding: base64
Content-ID: <img2_deadbeef>
X-Attachment-Id: img2_deadbeef
base64........
base64........
--relate--
--mixed
Content-Type: application/pdf; name="mailsend.pdf"
Content-Disposition: attachment; filename="mailsend.pdf"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_hppv4bio1
--mixed
+253
View File
@@ -0,0 +1,253 @@
= Announcement (Feb-11-2019)
If you use mailsend, please try https://github.com/muquit/mailsend-go[mailsend-go]. Your feedback will be appreciated.
mailsend will still be maintained (critical security fixes) but no new features will be added.
Thanks!
= mailsend v1.19
:experimental:
:toc:
:toc-placement: preamble
*mailsend* is a simple command line program to send mail via http://www.ietf.org/rfc/rfc0821.txt?number=821[SMTP] protocol. Long time ago, I needed to send a piece of alert mail from a program in a networked Windows machine, but could not find a simple program like this installed. So I wrote one. You might find it useful as well. The program does not use any config file and I plan to keep it that way. *From version 1.17b1+, IPv6 is supported in all platforms.* Suggestions, bug reports are always welcome. If you have any question, request or suggestion, please enter it in the https://github.com/muquit/mailsend/issues/[Issues] with appropriate label.
[[download-sourcebinary]]
== Download source/binary
To download source/binaries, please go to the https://github.com/muquit/mailsend/releases/[releases] page.
Bug fixes and stable features are merged from dev branch to master branch every now and then. Clone the repo if you want the latest code.
[[supported-platforms]]
== Supported Platforms
* Microsoft Windows
* Linux/Unix
* Mac OS X
It should compile on any POSIX compliant system. Works on 64 bit systems.
== Features
Few main features:
* ESMTP Authentication
* IPv6 transport
* Attachments
* Embed images in HTML
* Send mail to a list of users
[[versions]]
== Versions
=== Latest stable version is 1.19
Released on May-17-2016. Please look at: link:ChangeLog.mediawiki[ChangeLog].
== Synopsis
----
Version: @(#) mailsend v1.19
Copyright: BSD. It is illegal to use this software for Spamming
(Compiled with OpenSSL version: OpenSSL 1.0.2f 28 Jan 2016)
usage: mailsend [options]
Where the options are:
-copyright - show copyright information
-4 - Force to use IPv4 address of SMTP server
-6 - Force to use IPv6 address of SMTP server
-smtp hostname/IP* - Hostname/IP address of the SMTP server
-port SMTP port - SMTP port
-domain domain - domain name for SMTP HELO/EHLO
-t to,to..* - email address/es of the recipient/s
-cc cc,cc.. - carbon copy address/es
+cc - do not ask for Carbon Copy
-ct seconds - Connect timeout. Default is 5 seconds
-read-timeout seconds - Read timeout. Default is 5 seconds
-bc bcc,bcc.. - blind carbon copy address/es
+bc - do not ask for Blind carbon copy
+D - do not add Date header
-f address* - email address of the sender
-sub subject - subject
-list_address file - a file containing a list of email addresses
-log file - write log messages to this file
-cs character set - for text/plain attachments (default is us-ascii)
-separator character - separator used with -attach. Default is comma (,)
If used must be specified before -attach
-enc-type type - encoding type. base64, 8bit, 7bit etc.
Default is base64. Special type is "none"
-aname name - name of the attachment. Default is filename
-content-id id - content-id in the attachment
-mime-type type - MIME type
-dispostion val - "attachment" or "inline". Default is "attachment"
-attach file,mime_type,[i/a] (i=inline,a=attachment)
- attach this file as attachment or inline
-show-attach - show attachment in verbose mode, default is no
-show-mime-types - show the compiled in MIME types
-M "one line msg" - attach this one line text message
-content-type type - Content type. Default: multipart/mixed
-msg-body path - Path of the file to include as body of mail
-embed-image image - Path of image to embed in HTML
-H "header" - Add custom Header
-name "Full Name" - add name in the From header
-v - verbose mode
-V - show version info
-w - wait for a CR after sending the mail
-rt email_address - add Reply-To header
-rrr email_address - request read receipts to this address
-rp - return-path address
-ssl - SMTP over SSL
-starttls - use STARTTLS if the server supports it
-auth - try CRAM-MD5,LOGIN,PLAIN in that order
-auth-cram-md5 - use AUTH CRAM-MD5 authentication
-auth-plain - use AUTH PLAIN authentication
-auth-login - use AUTH LOGIN authentication
-user username - username for ESMTP authentication
-pass password - password for ESMTP authentication
-example - show examples
-ehlo - force EHLO
-info - show SMTP server information
-help - shows this help
-q - quiet
The options with * must be specified
Environment variables:
SMTP_USER_PASS for plain text password (-pass)
----
The options with asterisk must be specified. Environment variable *SMTP_USER_PASS* can be used to set the SMTP authentication password instead of the option +-pass+
[[how-to-compileinstall]]
== How to compile/install
[[linuxunixmac-os-x]]
=== Linux/Unix/Mac OS X
Specify the path of OpenSSL with +--with-openssl+. In most Linux systems, it is installed in +/usr+. If OpenSSL is installed in non-standard places, type +./configure --help+ for options.
----
$ /bin/sh ./configure --with-openssl=/usr
----
Default installation location is +/usr/local+. If you want to change that:
----
$ /bin/sh ./configure --with-openssl=/usr --prefix=/usr/local/mailsend
$ make clean
$ make
# make install
Or
$ sudo make install
Or
$ make install DESTDIR=/foo
----
The name of the binary will be mailsend. If compiled with OpenSSL, the
support for STARTTLS and SMTP over SSL will be available.
[[linux-debian-package]]
=== Linux Debian package
Starting from mailsend v1.18, Debian package is no longer supplied. If you want to build the Debian package yourself, after compiling mailsend, type:
----
$ ruby scripts/mk_debian_package.rb
----
To install the package, type:
[source,java]
----
$ sudo dpkg -i mailsend_1.19-ubuntu_i386.deb
----
To uninstall, type:
[source,java]
----
$ sudo dpkg -r mailsend
----
[[microsoft-windows]]
=== Microsoft Windows
A compiled binary with SMTP authentication support for MS Windows is already supplied. However, if you need to modify something or want to compile it yourself, you will need freely available Visual Studio from Microsoft. For Visual Studio 2015 community edition, start *Developer Command Prompt for VS2015*.
OpenSSL is required, if you need to compile with SMTP authentication support. Look at +INSTALL.32+ that comes with OpenSSL on how to compile and install OpenSSL. mailsend's +Makefile.nmake+ expects it to be installed at +c:\openssl+
To compile mailsend, open a command shell and type:
----
c:\> nmake -f Makefile.nmake clean
c:\> nmake -f Makefile.nmake
----
It compiles cleanly with cygwin as well. The name of the binary will be +mailsend.exe+
[[known-issues]]
== Known Issues
* For text or html attachments, \r\n is not added at the end of lines. Some SMTP servers (e.g. qmail) does not like that. It will be fixed in some future release.
* For non ascii characters, MIME headers are not converted as per RFC2047
* In Windows, non ascii characters can not be entered in subject or with +-M+ from
command line (Works fine in Linux and Mac). *mailsend* uses standard C
string functions and Windows versions do not know about multibyte input
from command line (https://github.com/muquit/mailsend/issues/14[Issue# 14]). If anyone is familiar with it, you are welcome to implement the support, unfortunately I do not have time at this time.
[[faq]]
== FAQ
Please look at link:doc/mailsend-FAQ.mediawiki[mailsend FAQ]
[[examples]]
== Examples
Please type: +mailsend -example+ or look at link:doc/examples.mediawiki[examples]
[[license]]
== License
BSD
To display license, please type: `mailsend -copyright`
----
Copyright (C) 2001-2019 Muhammad Muquit (http://www.muquit.com/)
o Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
o Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
o Neither the name of the author MUHAMMAD MUQUIT (http://www.muquit.com/)
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
----
'''
This document is created with https://github.com/asciidocfx/AsciidocFX[AsciidocFX]
+4
View File
@@ -0,0 +1,4 @@
- add \r\n at the end of each lines for text and html attachments.
- encode non-ascii headers as per RFC2047
- implement encoding type to one line message. command line -enc added
(Jun-30-2013)
+5370
View File
File diff suppressed because it is too large Load Diff
+5
View File
@@ -0,0 +1,5 @@
mailsend (1.17-ubuntu) unstable; urgency=low
* Built debian binary package for mailsend v1.17
-- Muhammad Muquit <muquit@muquit.com> Fri, 11 May 2012 13:54:10 -0400
+6982
View File
File diff suppressed because it is too large Load Diff
+121
View File
@@ -0,0 +1,121 @@
dnl --------------------------------------------------------------------
dnl Process this file with autoconf to produce a configure script.
dnl lots of m4 macros are borrowed from php configure
dnl muquit@muquit.com Jan-12-2003
dnl --------------------------------------------------------------------
AC_INIT(mailsend.h)
AC_PROG_RANLIB
AC_PROG_MAKE_SET
dnl Checks for programs.
AC_PROG_CC
test "$GCC" = yes && CFLAGS="$CFLAGS -Wall"
AC_PROG_INSTALL
AC_STDC_HEADERS
AC_CHECK_HEADERS(string.h strings.h memory.h malloc.h unistd.h ctype.h)
AC_CHECK_HEADERS(stdint.h sys/types.h stdlib.h fcntl.h sys/file.h)
AC_CHECK_HEADERS(limits.h sys/syslimits.h)
AC_PATH_TOOL([STRIP], [strip])
PHP_CHECK_FUNC(flock)
PHP_CHECK_FUNC(socket, socket)
PHP_CHECK_FUNC(htonl, socket)
PHP_CHECK_FUNC(gethostname, nsl)
PHP_CHECK_FUNC(gethostbyaddr, nsl)
PHP_CHECK_FUNC(yp_get_default_domain, nsl)
dnl Check for resolver routines.
dnl Need to check for both res_search and __res_search
dnl in -lc, -lbind, -lresolv and -lsocket
PHP_CHECK_FUNC(res_search, resolv, bind, socket)
dnl Check for inet_aton and dn_skipname
dnl in -lc, -lbind and -lresolv
PHP_CHECK_FUNC(inet_aton, resolv, bind)
PHP_CHECK_FUNC(dn_skipname, resolv, bind)
PHP_CHECK_FUNC(mkstemp)
PHP_CHECK_FUNC(getaddrinfo)
use_open_ssl="no"
OPENSSL_LIBS=""
AC_MSG_CHECKING(for OpenSSL)
OPENSSL_DO_IT_ALL
if test ."$OPENSSL_DIR" != . -a ."$OPENSSL_INC" != . -a ."$OPENSSL_LIBS" != . ; then
AC_DEFINE(HAVE_OPENSSL)
AC_MSG_RESULT(yes)
use_open_ssl="yes"
MKEY_HEX="a02abc222"
OPENSSL_LIBS="-L$OPENSSL_DIR/lib -lssl -lcrypto"
else
AC_MSG_RESULT(no)
fi
DL_LIB=""
if test ".$use_open_ssl" = ".yes"; then
dnl following borrowed from bind 9.3.2's configure.in
AC_MSG_CHECKING(whether linking with OpenSSL requires -ldl)
AC_TRY_LINK([
#include <openssl/err.h>],
[ DSO_METHOD_dlfcn(); ],
[AC_MSG_RESULT(no)],
[LIBS="$LIBS $OPENSSL_LIBS -ldl"
AC_TRY_LINK([
#include <openssl/err.h>
],[ DSO_METHOD_dlfcn(); ],
[AC_MSG_RESULT(yes)
OPENSSL_LIBS="-L$OPENSSL_DIR/lib -lssl -lcrypto -ldl"
],
[AC_MSG_RESULT(unknown)
AC_MSG_RESULT(OpenSSL has unsupported dynamic loading)],
[AC_MSG_RESULT(assuming it does work on target platform)])
],
[AC_MSG_RESULT(assuming it does work on target platform)]
)
fi
AC_SUBST(OPENSSL_LIBS)
AC_SUBST(DL_LIB)
MKEY_HEX=""
IV_HEX=""
MKEY_GENERATED=`date`
if test ".$use_open_ssl" = ".yes"; then
AC_MSG_CHECKING(if masterkey should be generated)
AC_ARG_WITH(genmkey, [ --with-genmkey=yes,no If master key should be generated],
[ openssl_cv_genmkey=`eval echo "$withval"` ])
if test ".$openssl_cv_genmkey" = ".yes"; then
bin=openssl
OPENSSL=''
for i in $OPENSSL_DIR/bin/$bin /usr/bin/ssl/bin/$bin /usr/local/bin/$bin /bin/$bin /usr/sbin/$bin /opt/bin/$bin
do
if test -f $i; then
OPENSSL=$i
MKEY_HEX=`$OPENSSL rand 24 -hex`
IV_HEX=`$OPENSSL rand 8 -hex`
AC_MSG_RESULT(yes $OPENSSL)
break
fi
done
if test ."$OPENSSL" = "."; then
AC_MSG_ERROR(no, openssl binary not found)
fi
else
AC_MSG_RESULT(no)
fi
fi
AC_SUBST(MKEY_GENERATED)
AC_SUBST(MKEY_HEX)
AC_SUBST(IV_HEX)
AC_CONFIG_FILES([
Makefile
libs/libmsock/Makefile
libs/libmutils/mkey.c
libs/libmutils/Makefile
libs/libsll/Makefile
])
AC_OUTPUT
+37
View File
@@ -0,0 +1,37 @@
#ifndef COPYRIGHT_H
#define COPYRIGHT_H
/*
** Automatically generated by copyright2arrayofp2chars.rb.
** 2015-06-20 14:58:33 -0400
*/
static char
*mailsend_copyright[] =
{
"Copyright (C) 2001-2017 Muhammad Muquit (http://www.muquit.com/)",
"",
" o Redistributions of source code must retain the above copyright notice, ",
"this list of conditions and the following disclaimer.",
"",
" o Redistributions in binary form must reproduce the above copyright notice, ",
"this list of conditions and the following disclaimer in the documentation ",
"and/or other materials provided with the distribution.",
"",
" o Neither the name of the author MUHAMMAD MUQUIT (http://www.muquit.com/)",
"nor the names of its contributors may be used to endorse or promote ",
"products derived from this software without specific prior written ",
"permission.",
"",
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" ",
"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ",
"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ",
"ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ",
"LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ",
"CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ",
"SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ",
"INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ",
"CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ",
"ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ",
"POSSIBILITY OF SUCH DAMAGE.",
(char *) NULL
};
#endif /* COPYRIGHT_H */
@@ -0,0 +1,94 @@
== Show server info ==
mailsend -v -info -port 587 -smtp smtp.gmail.com
mailsend -v -info -ssl -port 465 -smtp smtp.gmail.com
== STARTTLS + AUTHENTICATION ==
mailsend -to user@gmail.com -from user@gmail.com
-starttls -port 587 -auth
-smtp smtp.gmail.com
-sub test +cc +bc -v
-user you -pass "your_password"
Note: Password can be set by env var SMTP_USER_PASS instead of -pass
== SSL + AUTHENTICATION ==
mailsend -to user@gmail.com -from user@gmail.com
-ssl -port 465 -auth
-smtp smtp.gmail.com
-sub test +cc +bc -v
-user you -pass "your_password"
As -auth is specified, CRAM-MD5, LOGIN, PLAIN will be tried in that order. Use -auth-cram-md5, -auth-plan, -auth-login for specific auth mechanism.
Note: Password can be set by env var SMTP_USER_PASS instead of -pass
== One line messages ==
One line messages are specified with -M. Each message can have its own MIME type, character set and encoding type ('''requires mailsend v1.17b15+'''):
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub "testing oneline messages"
-cs "us-ascii"
-enc-type "7bit"
-M "This is a test"
-cs "iso-8859-1"
-enc-type "8bit"
-M "Das Wetter ist schön!"
-cs "Big5"
-enc-type "base64"
-M "中文測試"
== Attachments ==
Only requirement of -attach is the path of the file. All other attributes can be specified before -attach with appropriate flags. Note: The flags must be specified correctly for each attachment, otherwise the one specified in previous attachment will be used.
By default, MIME type is guessed from filename extension, default encoding type base64 is used:
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub "this is a test"
-attach "file.pdf" -attach "file.jpg"
But all aspects of attachments can be controlled ('''requires mailsend v1.17b15+''')
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub test
-mime-type "text/plain"
-enc-type "7bit"
-cs "us-ascii"
-attach "file.txt"
-enc-type "8bit"
-cs "iso-8859-1"
-attach "deutsch.txt"
-mime-type "image/gif"
-enc-type "base64"
-aname "flower.gif"
-attach "/usr/file.gif"
-mime-type "image/jpeg"
-enc-type "base64"
-attach "file.jpeg"
By default, content disposition of all attachments are attachment, use -disposition "inline" to give hint to the mail reader to display it as mail body. Look at FAQ# 1 for details.
== Including a body ==
Only one file can be included as a body of the mail. If the file is not us-ascii, the SMTP server has to support it. If you include a binary file, result is undefined. '''Requires mailsend v1.17b15+'''
mailsend -f user@gmail -t user@example.com -smtp smtp.gamil.com
-port 587 -starttls -auth -user user@gmail.com -pass secret
-cs "utf-8"
-mime-type "text/plain"
-msg-body "file.txt"
If you want to include attachments and a body, you must provide the body as inline attachment:
mailsend -f user@gmail -t user@example.com -smtp smtp.gamil.com
-port 587 -starttls -auth -user user@gmail.com -pass secret
-cs "utf-8"
-mime-type "image/gif"
-enc-type "base64"
-aname "flower.gif"
-attach "/usr/file.gif"
-mime-type "text/plain"
-disposition "inline"
-attach "file.txt"
@@ -0,0 +1,298 @@
= Frequently asked questions about mailsend =
This FAQ addresses mailsend v1.17b15+
== Can an attachment be part of the mail body? ==
Yes. mailsend supports attachments as inline with the option `-attach "file,MIME type,i"`. Any decent mail reader (gmail does, ThunderBird does) will display the attachment as a body of the mail but it is up to the mail reader to do so. mailsend can not do anything about it.
Microsoft Outlook does not support inline content-disposition MIME header by design. Please look at the Microsoft Knowledge base article http://support.microsoft.com/kb/814111 for detail.
My observation about Outlook 2010 is, if the very first attachment is attached as inline, it shows up as embedded in the body. The rest of the attachments show up as regular attachments, no matter what kind of content-disposition is used. I have no idea what kind of logic they are using!
'''However''' mailsend v1.17b15+ has a feature to include '''one''' text or HTML file has as message body with flag <code>-msg-body file</code>. It also has a feature to embed images inside HTML which is supported by most mail readers including Outlook. There are some scripts for testing embedding images in HTML in the [[../test|test/]] directory.
== How to find out the capabilities of a SMTP server? ==
Type any of:
'''c:\> mailsend.exe -info -smtp localhost'''
[S] 220 t105 ESMTP Exim 4.76 Sun, 04 Mar 2012 14:13:24 -0500
[C] EHLO localhost
[S] 250-t105 Hello localhost [127.0.0.1]
[S] 250-SIZE 52428800
[S] 250-PIPELINING
[S] 250 HELP
[C] QUIT
[S] 221 t105 closing connection
'''c:\> mailsend.exe -info -port 587 -smtp smtp.gmail.com'''
smtp.gmail.com
SMTP server: smtp.gmail.com, Port: 587
[S] 220 mx.google.com ESMTP xxxxxxxxxxxxxxxx.8
[C] EHLO localhost
[S] 250-mx.google.com at your service, [x.x.x.x]
[S] 250-SIZE 35882577
[S] 250-8BITMIME
[S] 250-STARTTLS
[S] 250 ENHANCEDSTATUSCODES
[C] STARTTLS
[S] 220 2.0.0 Ready to start TLS
Cipher: ECDHE-RSA-RC4-SHA
Certificate information:
Subject: /C==US/ST==California/L==Mountain View/O==Google Inc/CN==smtp.gmail.com
Issuer: /C==US/O==Google Inc/CN==Google Internet Authority
[C] EHLO localhost
[S] 250-mx.google.com at your service, [x.x.x.x]
[S] 250-SIZE 35882577
[S] 250-8BITMIME
[S] 250-AUTH LOGIN PLAIN XOAUTH
[S] 250 ENHANCEDSTATUSCODES
[C] QUIT
[S] 221 2.0.0 closing connection xxxxxxxxxxxxxxxx.8
'''c:\> mailsend.exe -info -port 465 -ssl -smtp smtp.gmail.com'''
smtp smtp.gmail.com
SMTP server: smtp.gmail.com, Port: 465
Cipher: ECDHE-RSA-RC4-SHA
Certificate information:
Subject: /C==US/ST==California/L==Mountain View/O==Google Inc/CN==smtp.gmail.com
Issuer: /C==US/O==Google Inc/CN==Google Internet Authority
[S] 220 mx.google.com ESMTP xxxxxxxxxxxxxxxx.19
[C] EHLO localhost
[S] 250-mx.google.com at your service, [xxx.xxx.xxx.xxx]
[S] 250-SIZE 35882577
[S] 250-8BITMIME
[S] 250-AUTH LOGIN PLAIN XOAUTH
[S] 250 ENHANCEDSTATUSCODES
[C] QUIT
[S] 221 2.0.0 closing connection xxxxxxxxxxxxxxxx.19
== How to embed images in HTML? ==
mailsend v1.17b15+ has has a feature to embed images inside HTML which is supported by most mail readers including Outlook. This feature can be used to embed one complicated messsage body of the mail. Note: <code>-msg-body file.txt</code> can embed only one text file as message body.
Two screenshots of embedded image in HTML file are shown below:
The HTML file [[../test/embed_image1.html]] is used to send this mail.
[[/images/embed1.png]]
The HTML file [[../test/embed_image2.html]] is used to send this mail.
[[/images/embed2.png]]
To embed images in HTML one below another (without HTML file), mailsend can be run as below:
$ mailsend -sub "Embed 2 images in HTML, one below the other" \
-from mailsend@gmail.com -to mailsend@gmail.com \
-smtp smtp.gmail.com -port 587 -starttls -auth \
-user mailsend.test@gmail.com -cs ISO-8859-1 \
-embed-image "test/blue.png" \
-embed-image "test/green.png"
Note: No content ids are specified, they will be generated. The mail will like:
[[/images/embed3.png]]
If you look at the mail at gmail (select Show original), it will look like:
Subject: Embed 2 images in HTML, one below the other
From: mailsend.test@gmail.com
Date: Sun, 05 Oct 2014 15:18:10 -0400
To: mailsend@gmail.com
X-Mailer: @(#) mailsend v1.17b15 (Unix)
X-Copyright: BSD. It is illegal to use this software for Spamming
Mime-version: 1.0
Content-type: multipart/related; boundary="NxSfacGEuTT0nqf7"
--NxSfacGEuTT0nqf7
Content-Type: multipart/alternative; boundary=Stw5amS+Ppc1NmFl
--Stw5amS+Ppc1NmFl
Content-Type: text/html; charset=ISO-8859-1
<img src="cid:ii1_FsOAfO89d/e04/32" alt="inline image 1"><br>
<img src="cid:ii2_Z5T3o06Y3iw8DIFf" alt="inline image 2"><br>
--Stw5amS+Ppc1NmFl--
--NxSfacGEuTT0nqf7
Content-Type: image/png
Content-ID: <ii1_FsOAfO89d/e04/32>
X-Attachment-Id: ii1_FsOAfO89d/e04/32
Content-Transfer-Encoding: base64
<base64 content here>
--NxSfacGEuTT0nqf7
Content-Type: image/png
Content-ID: <ii2_Z5T3o06Y3iw8DIFf>
X-Attachment-Id: ii2_Z5T3o06Y3iw8DIFf
Content-Transfer-Encoding: base64
<base64 content here>
--NxSfacGEuTT0nqf7--
--NxSfacGEuTT0nqf7--
== Does mailsend support IPv6? ==
From v1.17b1, IPv6 is supported in all platforms. If you have IPv6 (native or through tunnel), mailsend will use IPv6 automatically if the fqdn of the SMP server resolves to an IPv6 address. Or you can just specify the IPv6 address of the SMTP server.
Example:
'''c:\> mailsend.exe -v -info -smtp smtp.gmail.com'''
Connecting to SMTP server: smtp.gmail.com at Port: 25
Connection timeout: 5 secs
libmsock: using getaddrinfo
AF_INET6
IPv6 address: [2607:f8b0:400c:c03::6c]:25 <-------
EINPROGRESS==10036,EWOULDBLOCK==10035
conenct(): socket==312,rc==-1, errno==10035
Try socket 312
[S] 220 mx.google.com ESMTP q19sm8376288vdf.21
[C] EHLO localhost
[S] 250-mx.google.com at your service, [2001:xxx:xxxx:xxx::x]
[S] 250-SIZE 35882577
[S] 250-8BITMIME
[S] 250-STARTTLS
[S] 250 ENHANCEDSTATUSCODES
[C] STARTTLS
[S] 220 2.0.0 Ready to start TLS
Cipher: ECDHE-RSA-RC4-SHA
Certificate information:
Subject: /C==US/ST==California/L==Mountain View/O==Google Inc/CN==smtp.gmail.com
Issuer: /C==US/O==Google Inc/CN==Google Internet Authority
[C] EHLO localhost
[S] 250-mx.google.com at your service, [2001:xxx:xxxx:xxx::x]
[S] 250-SIZE 35882577
[S] 250-8BITMIME
[S] 250-AUTH LOGIN PLAIN XOAUTH
[S] 250 ENHANCEDSTATUSCODES
[C] QUIT
== How to send mail via gmail? ==
Please look at the [examples Examples] section. Look for -ssl and -starttls and -port.
== Does mailsend support multibyte non-ascii input? ==
At this time it only works in linux and mac. In windows it will be needed to change code to support reading multibyte characters input from command line. Here is an example of non-ascii input in mac, mailsend 1.17b14 is running in linux:
[http://mailsend.googlecode.com/svn/wiki/multibyte_input.png]
The verbose output looks something like:
Date: Sun, 20 Oct 2013 20:42:44 -0400
To: muquit@gmail.com
X-Mailer: @(#) mailsend v1.17b15 (Unix)
X-Copyright: BSD. It is illegal to use this software for Spamming
Content-type: multipart/mixed; boundary=="aWGL4q7mlq0dFml7"
Mime-version: 1.0
--aWGL4q7mlq0dFml7
Content-Type: text/plain; charset==utf-8
Content-Disposition: inline
[C] running on linux, input from mac keyboard
[C] Nicht möglich!
[C] Das macht Spaß!
[C] 中文測試
[C] গগনে গরজে মেঘ, ঘন বরষা
--aWGL4q7mlq0dFml7--
[C] .
[S] 250 2.0.0 OK 1382316162 b10sm27076637qeg.7 - gsmtp
[C] QUIT
[S] 221 2.0.0 closing connection b10sm27076637qeg.7 - gsmtp
Mail sent successfully
The mail in gmail looks like:
[http://mailsend.googlecode.com/svn/wiki/multibyte_gmail.png]
Notice smtp.gmail.com accepts raw multibyte characters. However some SMTP servers only accepts US-ASCII as data. So it is a good idea to use the option -enc base64. The verbose output will look like:
Date: Sun, 20 Oct 2013 20:48:05 -0400
To: muquit@gmail.com
X-Mailer: @(#) mailsend v1.17b15 (Unix)
X-Copyright: BSD. It is illegal to use this software for Spamming
Content-type: multipart/mixed; boundary=="NflDZxwWowVAFTP3"
Mime-version: 1.0
--NflDZxwWowVAFTP3
Content-Type: text/plain; charset==utf-8
Content-Disposition: inline
Content-Transfer-Encoding: base64
Oneline temp file1: * /tmp/mailsend05qsry
Oneline temp file2: * /tmp/mailsendtGT9GB
[C] cnVubmluZyBvbiBsaW51eCwgaW5wdXQgZnJvbSBtYWMga2V5Ym9hcmQKTmljaHQgbcO2Z2xp
[C] Y2ghCkRhcyBtYWNodCBTcGHDnyEK5Lit5paH5ris6KmmCuCml+Cml+CmqOCnhyDgppfgprDg
[C] ppzgp4cg4Kau4KeH4KaYLCDgppjgpqgg4Kas4Kaw4Ka34Ka+Cg
--NflDZxwWowVAFTP3--
[C] .
[S] 250 2.0.0 OK 1382316483 u3sm27124567qej.8 - gsmtp
[C] QUIT
[S] 221 2.0.0 closing connection u3sm27124567qej.8 - gsmtp
Mail sent successfully
The mail will look the same in gmail.
== Can this program be used as a mail sender from web browsers? ==
I'll use the Firefox as an example in Windows. By default in MS Windows, Firefox will start outlook express (or nothing) to send mail when you click on a mailto: link. This behavior can be changed as follows:
*Warning:* the following instructions might be different for different version of Windows.
Go to Control Panel
Click on Folder Options
Click on File Types tab
Click on [NONE] URL:MailTo Protocol
Click on Advanced button
Click on open then Click on Edit... button
Uncheck Use DDE
In the Application used to perform action field, add the line (without line breaks):
"C:\path\of\mailsend.exe" -smtp IP_address_of_your_smtp_server
-v -d your_domain.com
-f you@your_domain.com +cc +bc -v -w -t "%1"
Note: there's no need to clean mailto: tag from another program before calling mailsend.
On Unix, search on the web on how to setup external mail sender for Firefox. Again there's no need to remove mailto: tag from another script.
== Does the program support ESMTP authentication? ==
From v1.15a+, STARTTLS, CRAM-MD5, LOGIN and PLAIN authentication is supported. SMTP over SSL is also supported in v 1.16+. Type mailsend -ex for examples on how to use authentication.
== What's the difference between -ssl and -starttls? ==
With the option -ssl, an encrypted connection is made first and then SMTP protocol continues over the encrypted connection. For example, smtp.gmail.com supports it at port 465. With -starttls, a regular unencrypted connection is made first, then if the server supports STRTTLS, the command is issued to make the connection encrypted. For example smtp. gmail.com supports STARTTLS at port 587.
== How to send mail to multiple people? ==
Create a text file containing the addresses and then specify the file with -list-address. The syntax of the file is as follows:
#####################################################
# File can contain addresses to send mail to.
# A line can start with To: email_address,
# Cc: email_address, BCc: email_address or
# just a valid email address.
# Any line that starts with a # or ; is considered a comment
# and is ignored.
#user@example.com
To: blah@example.com
Cc: foo@example.com
jdoe@example.com
mjane@example.com
bar@example.com
#####################################################
Make sure there is a new line at the end of the last line or the last address will be ignored. Run mailsend with -v to verify that all the addresses are used.
== Does mailsend verify certificates while making SSL connections? ==
No.
== I send mail but the mail never reaches the destination. What's wrong? ==
* First of all make sure you can talk to the SMTP server ([mailsendFAQ#How_to_find_out_the_capabilities_of_a_SMTP_server?])
* Make sure the mail is accepted by the server (run mailsend with -v).
* Make sure that the SMTP server relays message to outside domain or only accepts mail from certain IP addresses (Talk to the admin).
* It is also possible the server requires authentication. Type mailsend -ex for examples on how to use authentication.
== What are the valid MIME types? ==
In mailsend v1.17b15+, type <code>mailsend -show-mime-types</code>. In older versions, look at the file [[../mime.types|mime.types]]
+359
View File
@@ -0,0 +1,359 @@
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "MAILSEND 1"
.TH MAILSEND 1 "2019-01-10" "mailsend 1.20b2" "User Commands"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
mailsend \- A command line program to send mail via SMTP protocol
.SH "SYNOPSYS"
.IX Header "SYNOPSYS"
.Vb 1
\& Version: @(#) mailsend v1.20b2
\&
\& Copyright: BSD. It is illegal to use this software for Spamming
\&
\& (Compiled with OpenSSL version: OpenSSL 1.0.2q 20 Nov 2018)
\& usage: mailsend [options]
\& Where the options are:
\& \-copyright \- show copyright information
\& \-4 \- Force to use IPv4 address of SMTP server
\& \-6 \- Force to use IPv6 address of SMTP server
\& \-smtp hostname/IP* \- Hostname/IP address of the SMTP server
\& \-port SMTP port \- SMTP port
\& \-domain domain \- domain name for SMTP HELO/EHLO
\& \-t to,to..* \- email address/es of the recipient/s
\& \-cc cc,cc.. \- carbon copy address/es
\& +cc \- do not ask for Carbon Copy
\& \-ct seconds \- Connect timeout. Default is 5 seconds
\& \-read\-timeout seconds \- Read timeout. Default is 5 seconds
\& \-bc bcc,bcc.. \- blind carbon copy address/es
\& +bc \- do not ask for Blind carbon copy
\& +D \- do not add Date header
\& \-f address* \- email address of the sender
\& \-sub subject \- subject
\& \-list_address file \- a file containing a list of email addresses
\& \-log file \- write log messages to this file
\& \-cs character set \- for text/plain attachments (default is us\-ascii)
\& \-separator character \- separator used with \-attach. Default is comma (,)
\& If used must be specified before \-attach
\& \-enc\-type type \- encoding type. base64, 8bit, 7bit etc.
\& Default is base64. Special type is "none"
\& \-aname name \- name of the attachment. Default is filename
\& \-content\-id id \- content\-id in the attachment
\& \-mime\-type type \- MIME type
\& \-dispostion val \- "attachment" or "inline". Default is "attachment"
\& \-attach file,mime_type,[i/a] (i=inline,a=attachment)
\& \- attach this file as attachment or inline
\& \-show\-attach \- show attachment in verbose mode, default is no
\& \-show\-mime\-types \- show the compiled in MIME types
\& \-M "one line msg" \- attach this one line text message
\& \-content\-type type \- Content type. Default: multipart/mixed
\& \-msg\-body path \- Path of the file to include as body of mail
\& \-embed\-image image \- Path of image to embed in HTML
\& \-H "header" \- Add custom Header
\& \-name "Full Name" \- add name in the From header
\& \-v \- verbose mode
\& \-V \- show version info
\& \-w \- wait for a CR after sending the mail
\& \-rt email_address \- add Reply\-To header
\& \-rrr email_address \- request read receipts to this address
\& \-rp \- return\-path address
\& \-ssl \- SMTP over SSL
\& \-starttls \- use STARTTLS if the server supports it
\& \-auth \- try CRAM\-MD5,LOGIN,PLAIN in that order
\& \-auth\-cram\-md5 \- use AUTH CRAM\-MD5 authentication
\& \-auth\-plain \- use AUTH PLAIN authentication
\& \-auth\-login \- use AUTH LOGIN authentication
\& \-user username \- username for ESMTP authentication
\& \-pass password \- password for ESMTP authentication
\& \-example \- show examples
\& \-ehlo \- force EHLO
\& \-info \- show SMTP server information
\& \-help \- shows this help
\& \-q \- quiet
\&
\& The options with * must be specified
\& Environment variables:
\& SMTP_USER_PASS for plain text password (\-pass)
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
mailsend is a simple command line program to send mail via \s-1SMTP\s0 protocol
for Windows, Linux/Unix.
.PP
For deatils, please look at the web page:
.PP
<http://muquit.com/muquit/software/mailsend/mailsend.html>
.SH "EXAMPLES"
.IX Header "EXAMPLES"
Examples of mailsend Version: @(#) mailsend v1.17b15
.PP
.Vb 4
\& Show server info
\& ================
\& mailsend \-v \-info \-port 587 \-smtp smtp.gmail.com
\& mailsend \-v \-info \-ssl \-port 465 \-smtp smtp.gmail.com
\&
\& STARTTLS + AUTHENTICATION
\& =========================
\& mailsend \-to user@gmail.com \-from user@gmail.com
\& \-starttls \-port 587 \-auth
\& \-smtp smtp.gmail.com
\& \-sub test +cc +bc \-v
\& \-user you \-pass "your_password"
\& Note: Password can be set by env var SMTP_USER_PASS instead of \-pass
\&
\& SSL + AUTHENTICATION
\& ====================
\& mailsend \-to user@gmail.com \-from user@gmail.com
\& \-ssl \-port 465 \-auth
\& \-smtp smtp.gmail.com
\& \-sub test +cc +bc \-v
\& \-user you \-pass "your_password"
\&
\& As \-auth is specified, CRAM\-MD5, LOGIN, PLAIN will be tried in that order.
\& Use \-auth\-cram\-md5, \-auth\-plan, \-auth\-login for specific auth mechanism.
\&
\& Note: Password can be set by env var SMTP_USER_PASS instead of \-pass
\&
\& One line messages
\& =================
\& One line messages are specified with \-M. Each message can have its own
\& MIME type, character set and encoding type:
\&
\& mailsend \-f user@example.com \-smtp 10.100.30.1
\& \-t user@example.com \-sub "testing oneline messages"
\& \-cs "us\-ascii"
\& \-enc\-type "7bit"
\& \-M "This is a test"
\&
\& \-cs "iso\-8859\-1"
\& \-enc\-type "8bit"
\& \-M "Das Vetter ist scho\*:n!"
\&
\& \-cs "Big5"
\& \-enc\-type "base64"
\& \-M "XXXX"
\&
\& Attachments
\& ===========
\& Only requirement of \-attach is the path of the file. All other
\& attributes can be specified before \-attach with appropriate
\& flags. Note: The flags must be specified correctly for each attachment,
\& otherwise the one specified in previous attachment will be used.
\&
\& By default MIME type is guessed from filename extension, default
\& encoding type base64 is used:
\& mailsend \-f user@example.com \-smtp 10.100.30.1
\& \-t user@example.com \-sub "this is a test"
\& \-attach "file.pdf" \-attach "file.jpg"
\&
\& But all espects of attachments can be controlled:
\& mailsend \-f user@example.com \-smtp 10.100.30.1
\& \-t user@example.com \-sub test
\& \-mime\-type "text/plain"
\& \-enc\-type "7bit"
\& \-charset "us\-ascii"
\& \-attach "file.txt"
\&
\& \-enc\-type "8bit"
\& \-charset "iso\-8859\-1"
\& \-attach "deutsch.txt"
\&
\& \-mime\-type "image/gif"
\& \-enc\-type "base64"
\& \-aname "flower.gif"
\& \-attach "/usr/file.gif"
\&
\& \-mime\-type "image/jpeg"
\& \-enc\-type "base64"
\& \-attach "file.jpeg"
\&
\& By default, content disposition of all atachments are attachment, use
\& \-disposition "inline" to give hint to the mail reader to display it as
\& mail body. Look at FAQ# 1 for details.
\&
\& Including a body
\& ================
\& Only one file can be included as a body of the mail. If the
\& file is not us\-ascii, the SMTP server has to support it. If you
\& include a binary file, result is undefined.
\&
\& mailsend \-f user@gmail \-t user@example.com \-smtp smtp.gamil.com
\& \-port 587 \-starttls \-auth \-user user@gmail.com \-pass secret
\& \-charset "utf\-8"
\& \-mime\-type "text/plain"
\& \-msg\-body "file.txt"
.Ve
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Please look at the web page for latest version and documentation:
<http://muquit.com/muquit/software/mailsend/mailsend.html>
.SH "LICENSE"
.IX Header "LICENSE"
Copyright (C) 2001\-2017 Muhammad Muquit (http://www.muquit.com/)
.PP
.Vb 2
\& o Redistributions of source code must retain the above copyright notice,
\&this list of conditions and the following disclaimer.
\&
\& o Redistributions in binary form must reproduce the above copyright notice,
\&this list of conditions and the following disclaimer in the documentation
\&and/or other materials provided with the distribution.
\&
\& o Neither the name of the author MUHAMMAD MUQUIT (http://www.muquit.com/)
\&nor the names of its contributors may be used to endorse or promote
\&products derived from this software without specific prior written
\&permission.
.Ve
.PP
\&\s-1THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \*(L"AS IS\*(R"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES \s0(\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES\s0; \s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR BUSINESS
INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT \s0(\s-1INCLUDING NEGLIGENCE OR OTHERWISE\s0)
\&\s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.\s0
.SH "AUTHOR"
.IX Header "AUTHOR"
mailsend is written by Muhammad Muquit <muquit@muquit.com>.
Homepage: <http://www.muquit.com/>.
+226
View File
@@ -0,0 +1,226 @@
=head1 NAME
mailsend - A command line program to send mail via SMTP protocol
=head1 SYNOPSYS
Version: @(#) mailsend v1.20b2
Copyright: BSD. It is illegal to use this software for Spamming
(Compiled with OpenSSL version: OpenSSL 1.0.2q 20 Nov 2018)
usage: mailsend [options]
Where the options are:
-copyright - show copyright information
-4 - Force to use IPv4 address of SMTP server
-6 - Force to use IPv6 address of SMTP server
-smtp hostname/IP* - Hostname/IP address of the SMTP server
-port SMTP port - SMTP port
-domain domain - domain name for SMTP HELO/EHLO
-t to,to..* - email address/es of the recipient/s
-cc cc,cc.. - carbon copy address/es
+cc - do not ask for Carbon Copy
-ct seconds - Connect timeout. Default is 5 seconds
-read-timeout seconds - Read timeout. Default is 5 seconds
-bc bcc,bcc.. - blind carbon copy address/es
+bc - do not ask for Blind carbon copy
+D - do not add Date header
-f address* - email address of the sender
-sub subject - subject
-list_address file - a file containing a list of email addresses
-log file - write log messages to this file
-cs character set - for text/plain attachments (default is us-ascii)
-separator character - separator used with -attach. Default is comma (,)
If used must be specified before -attach
-enc-type type - encoding type. base64, 8bit, 7bit etc.
Default is base64. Special type is "none"
-aname name - name of the attachment. Default is filename
-content-id id - content-id in the attachment
-mime-type type - MIME type
-dispostion val - "attachment" or "inline". Default is "attachment"
-attach file,mime_type,[i/a] (i=inline,a=attachment)
- attach this file as attachment or inline
-show-attach - show attachment in verbose mode, default is no
-show-mime-types - show the compiled in MIME types
-M "one line msg" - attach this one line text message
-content-type type - Content type. Default: multipart/mixed
-msg-body path - Path of the file to include as body of mail
-embed-image image - Path of image to embed in HTML
-H "header" - Add custom Header
-name "Full Name" - add name in the From header
-v - verbose mode
-V - show version info
-w - wait for a CR after sending the mail
-rt email_address - add Reply-To header
-rrr email_address - request read receipts to this address
-rp - return-path address
-ssl - SMTP over SSL
-starttls - use STARTTLS if the server supports it
-auth - try CRAM-MD5,LOGIN,PLAIN in that order
-auth-cram-md5 - use AUTH CRAM-MD5 authentication
-auth-plain - use AUTH PLAIN authentication
-auth-login - use AUTH LOGIN authentication
-user username - username for ESMTP authentication
-pass password - password for ESMTP authentication
-example - show examples
-ehlo - force EHLO
-info - show SMTP server information
-help - shows this help
-q - quiet
The options with * must be specified
Environment variables:
SMTP_USER_PASS for plain text password (-pass)
=head1 DESCRIPTION
mailsend is a simple command line program to send mail via SMTP protocol
for Windows, Linux/Unix.
For deatils, please look at the web page:
L<http://muquit.com/muquit/software/mailsend/mailsend.html>
=head1 EXAMPLES
Examples of mailsend Version: @(#) mailsend v1.17b15
Show server info
================
mailsend -v -info -port 587 -smtp smtp.gmail.com
mailsend -v -info -ssl -port 465 -smtp smtp.gmail.com
STARTTLS + AUTHENTICATION
=========================
mailsend -to user@gmail.com -from user@gmail.com
-starttls -port 587 -auth
-smtp smtp.gmail.com
-sub test +cc +bc -v
-user you -pass "your_password"
Note: Password can be set by env var SMTP_USER_PASS instead of -pass
SSL + AUTHENTICATION
====================
mailsend -to user@gmail.com -from user@gmail.com
-ssl -port 465 -auth
-smtp smtp.gmail.com
-sub test +cc +bc -v
-user you -pass "your_password"
As -auth is specified, CRAM-MD5, LOGIN, PLAIN will be tried in that order.
Use -auth-cram-md5, -auth-plan, -auth-login for specific auth mechanism.
Note: Password can be set by env var SMTP_USER_PASS instead of -pass
One line messages
=================
One line messages are specified with -M. Each message can have its own
MIME type, character set and encoding type:
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub "testing oneline messages"
-cs "us-ascii"
-enc-type "7bit"
-M "This is a test"
-cs "iso-8859-1"
-enc-type "8bit"
-M "Das Vetter ist schön!"
-cs "Big5"
-enc-type "base64"
-M "中文測試"
Attachments
===========
Only requirement of -attach is the path of the file. All other
attributes can be specified before -attach with appropriate
flags. Note: The flags must be specified correctly for each attachment,
otherwise the one specified in previous attachment will be used.
By default MIME type is guessed from filename extension, default
encoding type base64 is used:
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub "this is a test"
-attach "file.pdf" -attach "file.jpg"
But all espects of attachments can be controlled:
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub test
-mime-type "text/plain"
-enc-type "7bit"
-charset "us-ascii"
-attach "file.txt"
-enc-type "8bit"
-charset "iso-8859-1"
-attach "deutsch.txt"
-mime-type "image/gif"
-enc-type "base64"
-aname "flower.gif"
-attach "/usr/file.gif"
-mime-type "image/jpeg"
-enc-type "base64"
-attach "file.jpeg"
By default, content disposition of all atachments are attachment, use
-disposition "inline" to give hint to the mail reader to display it as
mail body. Look at FAQ# 1 for details.
Including a body
================
Only one file can be included as a body of the mail. If the
file is not us-ascii, the SMTP server has to support it. If you
include a binary file, result is undefined.
mailsend -f user@gmail -t user@example.com -smtp smtp.gamil.com
-port 587 -starttls -auth -user user@gmail.com -pass secret
-charset "utf-8"
-mime-type "text/plain"
-msg-body "file.txt"
=head1 SEE ALSO
Please look at the web page for latest version and documentation:
L<http://muquit.com/muquit/software/mailsend/mailsend.html>
=head1 LICENSE
Copyright (C) 2001-2017 Muhammad Muquit (http://www.muquit.com/)
o Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
o Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
o Neither the name of the author MUHAMMAD MUQUIT (http://www.muquit.com/)
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
=head1 AUTHOR
mailsend is written by Muhammad Muquit E<lt>muquit@muquit.comE<gt>.
Homepage: L<http://www.muquit.com/>.
+102
View File
@@ -0,0 +1,102 @@
#include "mailsend.h"
void show_examples(void)
{
(void) fprintf(stdout, "Examples of mailsend Version: @(#) mailsend v1.17b15\n\n");
(void) fprintf(stdout,
" Show server info\n"
" ================\n"
" mailsend -v -info -port 587 -smtp smtp.gmail.com\n"
" mailsend -v -info -ssl -port 465 -smtp smtp.gmail.com\n"
"\n"
" STARTTLS + AUTHENTICATION\n"
" =========================\n"
" mailsend -to user@gmail.com -from user@gmail.com\n"
" -starttls -port 587 -auth\n"
" -smtp smtp.gmail.com\n"
" -sub test +cc +bc -v\n"
" -user you -pass \"your_password\"\n"
" Note: Password can be set by env var SMTP_USER_PASS instead of -pass\n"
"\n"
" SSL + AUTHENTICATION\n"
" ====================\n"
" mailsend -to user@gmail.com -from user@gmail.com\n"
" -ssl -port 465 -auth\n"
" -smtp smtp.gmail.com\n"
" -sub test +cc +bc -v\n"
" -user you -pass \"your_password\"\n"
"\n"
" As -auth is specified, CRAM-MD5, LOGIN, PLAIN will be tried in that order.\n"
" Use -auth-cram-md5, -auth-plan, -auth-login for specific auth mechanism.\n"
"\n"
" Note: Password can be set by env var SMTP_USER_PASS instead of -pass\n"
"\n"
" One line messages\n"
" =================\n"
" One line messages are specified with -M. Each message can have its own\n"
" MIME type, character set and encoding type:\n"
"\n"
" mailsend -f user@example.com -smtp 10.100.30.1\n"
" -t user@example.com -sub \"testing oneline messages\"\n"
" -cs \"us-ascii\"\n"
" -enc-type \"7bit\"\n"
" -M \"This is a test\"\n"
"\n"
" -cs \"iso-8859-1\"\n"
" -enc-type \"8bit\"\n"
" -M \"Das Vetter ist schön!\"\n"
"\n"
" -cs \"Big5\"\n"
" -enc-type \"base64\"\n"
" -M \"中文測試\"\n"
"\n"
" Attachments\n"
" ===========\n"
" Only requirement of -attach is the path of the file. All other \n"
" attributes can be specified before -attach with appropriate\n"
" flags. Note: The flags must be specified correctly for each attachment,\n"
" otherwise the one specified in previous attachment will be used.\n"
"\n"
" By default MIME type is guessed from filename extension, default \n"
" encoding type base64 is used:\n"
" mailsend -f user@example.com -smtp 10.100.30.1\n"
" -t user@example.com -sub \"this is a test\"\n"
" -attach \"file.pdf\" -attach \"file.jpg\"\n"
"\n"
" But all espects of attachments can be controlled:\n"
" mailsend -f user@example.com -smtp 10.100.30.1\n"
" -t user@example.com -sub test\n"
" -mime-type \"text/plain\" \n"
" -enc-type \"7bit\"\n"
" -charset \"us-ascii\"\n"
" -attach \"file.txt\"\n"
"\n"
" -enc-type \"8bit\"\n"
" -charset \"iso-8859-1\"\n"
" -attach \"deutsch.txt\"\n"
"\n"
" -mime-type \"image/gif\"\n"
" -enc-type \"base64\"\n"
" -aname \"flower.gif\"\n"
" -attach \"/usr/file.gif\" \n"
"\n"
" -mime-type \"image/jpeg\"\n"
" -enc-type \"base64\" \n"
" -attach \"file.jpeg\"\n"
"\n"
" By default, content disposition of all atachments are attachment, use\n"
" -disposition \"inline\" to give hint to the mail reader to display it as\n"
" mail body. Look at FAQ# 1 for details.\n"
"\n"
" Including a body\n"
" ================\n"
" Only one file can be included as a body of the mail. If the\n"
" file is not us-ascii, the SMTP server has to support it. If you \n"
" include a binary file, result is undefined.\n"
"\n"
" mailsend -f user@gmail -t user@example.com -smtp smtp.gamil.com\n"
" -port 587 -starttls -auth -user user@gmail.com -pass secret \n"
" -charset \"utf-8\"\n"
" -mime-type \"text/plain\"\n"
" -msg-body \"file.txt\"\n"
);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

+5
View File
@@ -0,0 +1,5 @@
REM your env could be different
@echo %VS100COMMONTOOLS%
REM
REM "%VS100COMMONTOOLS%\vsvars32.bat
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\vsvars32.bat"
+250
View File
@@ -0,0 +1,250 @@
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
@@ -3,16 +3,16 @@
# genmake 1.0 by ma_muquit@fccc.edu, RCS
##
CC= gcc
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_MALLOC_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CTYPE_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_FLOCK=1 -DHAVE_SOCKET=1 -DHAVE_HTONL=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETHOSTBYADDR=1 -DHAVE_YP_GET_DEFAULT_DOMAIN=1 -DHAVE_LIBNSL=1 -DHAVE_RES_SEARCH=1 -DHAVE_LIBRESOLV=1 -DHAVE_INET_ATON=1 -DHAVE_DN_SKIPNAME=1 -DHAVE_MKSTEMP=1 -DHAVE_OPENSSL=1
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_MALLOC_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CTYPE_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_LIMITS_H=1 -DHAVE_FLOCK=1 -DHAVE_SOCKET=1 -DHAVE_HTONL=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETHOSTBYADDR=1 -DHAVE_RES_SEARCH=1 -DHAVE_LIBRESOLV=1 -DHAVE_INET_ATON=1 -DHAVE_DN_SKIPNAME=1 -DHAVE_MKSTEMP=1 -DHAVE_GETADDRINFO=1
AR= ar cq
RANLIB= ranlib
LIBNAME= libmsock.a
OPENSSL_DIR=/usr/
OPENSSL_INC=-I/usr//include
OPENSSL_LIBS=-L/usr//lib -lssl -lcrypto
OPENSSL_DIR=
OPENSSL_INC=
OPENSSL_LIBS=
INCLUDES= -I. -I/usr/include/malloc $(OPENSSL_INC)
INCLUDES= -I. $(OPENSSL_INC)
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
+43
View File
@@ -0,0 +1,43 @@
##
# Makefile Generated by genmake 1.0, Nov-16-96
# genmake 1.0 by ma_muquit@fccc.edu, RCS
##
CC= @CC@
DEFS= @DEFS@
AR= ar cq
RANLIB= @RANLIB@
LIBNAME= libmsock.a
OPENSSL_DIR=@OPENSSL_DIR@
OPENSSL_INC=@OPENSSL_INC@
OPENSSL_LIBS=@OPENSSL_LIBS@
INCLUDES= -I. $(OPENSSL_INC)
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
SRCS = msock.c
OBJS = msock.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: $(LIBNAME)
$(LIBNAME) : $(OBJS)
rm -f $@
$(AR) $@ $(OBJS)
$(RANLIB) $@
clean:
rm -f $(OBJS) $(LIBNAME) core
clean_all:
make clean
(cd examples/htget; make clean)
(cd examples/echod; make clean)
(cd examples/server_type; make clean)
+22
View File
@@ -0,0 +1,22 @@
#--------------------------------------------
# Makefile for MS Visual C++
# muquit@muquit.com
# Updated for MS Visual Studio 10.0 Feb-27-2012
#--------------------------------------------
CFLAGS= /DWINNT /DWIN32 /DHAVE_MALLOC_H /DHAVE_OPENSSL /DHAVE_GETADDRINFO=1 /Ic:\openssl\include /I.
#CFLAGS= /DWINNT /DWIN32 /DHAVE_MALLOC_H /DHAVE_OPENSSL /Ic:\openssl\include /I.
CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo
LIBFLAGS=/nologo
LIBRARY=msock.lib
SRCS = msock.c
OBJS = msock.obj
all: $(LIBRARY)
$(LIBRARY): $(OBJS)
lib $(LIBFLAGS) $(OBJS) /out:$(LIBRARY)
clean:
del $(OBJS) $(LIBRARY) *.bak
@@ -0,0 +1,35 @@
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define EALREADY WSAEALREADY
#define ENOTSOCK WSAENOTSOCK
#define EDESTADDRREQ WSAEDESTADDRREQ
#define EMSGSIZE WSAEMSGSIZE
#define EPROTOTYPE WSAEPROTOTYPE
#define ENOPROTOOPT WSAENOPROTOOPT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#define EOPNOTSUPP WSAEOPNOTSUPP
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#define EADDRINUSE WSAEADDRINUSE
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
#define ENETDOWN WSAENETDOWN
#define ENETUNREACH WSAENETUNREACH
#define ENETRESET WSAENETRESET
#define ECONNABORTED WSAECONNABORTED
#define ECONNRESET WSAECONNRESET
#define ENOBUFS WSAENOBUFS
#define EISCONN WSAEISCONN
#define ENOTCONN WSAENOTCONN
#define ESHUTDOWN WSAESHUTDOWN
#define ETOOMANYREFS WSAETOOMANYREFS
#define ETIMEDOUT WSAETIMEDOUT
#define ECONNREFUSED WSAECONNREFUSED
#define ELOOP WSAELOOP
#define EHOSTDOWN WSAEHOSTDOWN
#define EHOSTUNREACH WSAEHOSTUNREACH
#define EPROCLIM WSAEPROCLIM
#define EUSERS WSAEUSERS
#define EDQUOT WSAEDQUOT
#define ESTALE WSAESTALE
#define EREMOTE WSAEREMOTE
+32
View File
@@ -0,0 +1,32 @@
#--------------------------------------------
# Makefile for MS Visual C++
# muquit@muquit.com
#--------------------------------------------
CC= cl /MD
OPENSSL_DIR=c:\openssl
OPENSSL_INC=-I$(OPENSSL_DIR)/include
OPENSSL_LIBS=$(OPENSSL_DIR)/lib/libeay32.lib $(OPENSSL_DIR)/lib/ssleay32.lib
DEFS= -DWINNT=1 -DSTRICT_MODE=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1 -DHAVE_OPENSSL=1
INCLUDES= -I. $(OPENSSL_INC)
LIBRARY=msock.lib
DEFINES= $(INCLUDES) $(DEFS)
#CFLAGS= $(cvars) $(cdebug) -nologo -G4 $(DEFINES)
CFLAGS= $(DEFINES)
SRCS = msock.c
OBJS = msock.obj
.c.obj:
$(CC) $(CFLAGS) -c $< -Fo$@
all: $(LIBRARY)
$(LIBRARY): $(OBJS)
link /lib /OUT:$(LIBRARY) $(OBJS)
clean:
del $(OBJS) $(LIBRARY) *.bak
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env ruby
# muquit@muquit.com Aug-26-2012
begin
t = Time.new
puts <<EOD
\#ifndef WERRNO_H
\#define WERRNO_H
\#ifdef WINNT
/*
** This file is auto generated on #{t}
** Map wisock error code. Newer Visual Studio defines them
** but they do not map to Winsock error code.
*/
EOD
lines = File.read("./ecode.txt")
lines.each do |l|
l = l.strip
if l =~ /#define (.*)\s+(.*)$/
d = $1.strip
puts <<EOD
\#undef #{d}
#{l}
EOD
end
end
puts <<EOD
\#endif /* WINNT */
\#endif /* WERRNO_H */
EOD
end
+443 -22
View File
@@ -9,6 +9,29 @@ static SSL *s_ssl=NULL;
static SOCKET s_sock;
static int ssl_status=0;
static FILE *s_logfp = NULL;
#ifdef WINNT
#undef UNICODE
#endif /* WINNT */
static int debug = 0;
void msock_set_logfp(FILE *logfp)
{
if (logfp != NULL)
{
s_logfp = logfp;
}
else
{
s_logfp = stderr;
}
}
void msock_set_debug(int d)
{
debug = d;
}
void msock_set_socket(SOCKET sfd)
{
@@ -63,7 +86,37 @@ struct in_addr *atoAddr(char *address)
return ((struct in_addr *) NULL);
}
#ifdef WINNT
void msock_print_winsock_error(void)
{
int
error_code = WSAGetLastError();
LPSTR
error_string = NULL;
if (s_logfp == NULL)
{
s_logfp = stderr;
}
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
error_code,
0,
(LPSTR) &error_string,
0,
0);
(void) fprintf(s_logfp,"Winsock error[%d]: %s\n",
error_code,
error_string);
LocalFree(error_string);
return;
}
/* returns 0 on success -1 on failure */
int initWinSock(void)
{
@@ -76,23 +129,149 @@ int initWinSock(void)
int
err;
version_requested=MAKEWORD(2,0);
version_requested=MAKEWORD(2,2);
err=WSAStartup(version_requested,&wsa_data);
if (err != 0)
{
(void) fprintf(stderr," Unable to initialize winsock (%d)\n",err);
msock_print_error();
return(-1);
}
return(0);
}
/*
** Adapted from libevent2
*/
int msock_get_errno(SOCKET sock_fd)
{
int
optval,
optvallen = sizeof(optval);
int err = WSAGetLastError();
if (err == WSAEWOULDBLOCK && sock_fd >= 0)
{
if (getsockopt(sock_fd, SOL_SOCKET, SO_ERROR, (void*)&optval,
&optvallen))
return err;
if (optval)
return optval;
}
return err;
}
#endif /* WINNT */
/* returns SOCKET on success INVALID_SOCKET on failure */
SOCKET clientSocket(char *address,int port)
void msock_print_error(void)
{
if (s_logfp == NULL)
{
s_logfp = stderr;
}
#ifdef WINNT
msock_print_winsock_error();
#else
(void) fprintf(s_logfp,"Socket Error: [%d]: %s\n",
errno,
strerror(errno));
#endif /* WINNT */
}
#ifdef HAVE_GETADDRINFO
void msock_print_ipaddr(struct addrinfo *res)
{
#ifdef WINNT
INT
iRetval;
struct sockaddr_in
*sockaddr_ipv4;
LPSOCKADDR
sockaddr_ip;
char
ipstringbuffer[46];
DWORD
ipbufferlength = 46;
#else
struct sockaddr
*sa;
char
buf[1024];
#endif /* WINNT */
if (res == NULL) return;
if (debug == 0) return;
#ifdef WINNT
/*
** Ref: http://msdn.microsoft.com/en-us/library/windows/desktop/ms738520%28v=vs.85%29.aspx
*/
sockaddr_ip = (LPSOCKADDR) res->ai_addr;
ipbufferlength = 46;
iRetval = WSAAddressToString(sockaddr_ip, (DWORD) res->ai_addrlen, NULL,
ipstringbuffer, &ipbufferlength );
if (iRetval)
{
(void) fprintf(stderr," WSAAddressToString failed with %u\n",
WSAGetLastError() );
}
else
{
if (debug)
{
(void) fprintf(stderr," IP address: %s\n",ipstringbuffer);
}
}
#else
sa = (struct sockaddr *) res->ai_addr;
switch (sa->sa_family)
{
case AF_INET:
{
inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr),
buf,sizeof(buf) - 1);
if (debug)
{
(void) fprintf(stderr," IPv4 address: %s\n",buf);
}
break;
}
case AF_INET6:
{
inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)sa)->sin6_addr),
buf,sizeof(buf) - 1);
if (debug)
{
(void) fprintf(stderr," IPv6 address: %s\n",buf);
}
break;
}
default:
{
(void) fprintf(stderr,"Error: Uknown AF family\n");
}
}
#endif /* WINNT */
}
#else
void msock_print_ipaddr(void *res)
{
;
}
#endif /* HAVE_GETADDRINFO */
/*
** It is assumed that the socket is a blocking socket. In order to
** timeout the connect(), socket is made non-blocking and changed
** back to blocking after a successful connect, because lot of other calls
** are blocking. Someday I might change everything to non-blocking.
**
** returns a blocking SOCKET on success INVALID_SOCKET on failure
*/
SOCKET clientSocket(int use, char *address,int port, int connect_timeout)
{
SOCKET
s;
sock_fd;
struct sockaddr_in
sa;
@@ -100,46 +279,205 @@ SOCKET clientSocket(char *address,int port)
struct in_addr
*addr;
struct timeval
tv;
fd_set
fdset;
int
eno,
rc;
#ifdef HAVE_GETADDRINFO
char
service[64];
struct addrinfo
hints,
*cur,
*res,
*ressave;
#endif /* HAVE_GETADDRINFO */
#ifdef WINNT
rc=initWinSock();
if (rc != 0)
return(INVALID_SOCKET);
#endif /* WINNT */
addr=atoAddr(address);
if (addr == NULL)
#ifdef HAVE_GETADDRINFO
if (debug)
{
(void) fprintf(stderr," Invalid address: %s\n",address);
(void) fprintf(stderr,"> libmsock: using getaddrinfo\n");
}
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = PF_UNSPEC;
if (use == MSOCK_USE_IPV4)
{
hints.ai_family = PF_INET;
}
if (use == MSOCK_USE_IPV6)
{
hints.ai_family = PF_INET6;
}
(void) snprintf(service, sizeof(service) -1, "%d", port);
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
rc = getaddrinfo(address, service, &hints, &res);
if (rc != 0)
{
(void) fprintf(stderr,"Error: Could not find host \"%s\"\n",address);
return(INVALID_SOCKET);
}
ressave = res;
rc = (-1);
for (cur=res; cur != NULL; cur = cur->ai_next)
{
if (debug)
{
switch (cur->ai_family)
{
case AF_UNSPEC:
{
if (debug)
{
(void) fprintf(stderr,"> AF_UNSPEC\n");
}
break;
}
case AF_INET:
{
if (debug)
{
(void) fprintf(stderr,"> AF_INET IPv4\n");
}
break;
}
case AF_INET6:
{
if (debug)
{
(void) fprintf(stderr,"> AF_INET6\n");
}
break;
}
}
msock_print_ipaddr(cur);
}
sock_fd = socket(cur->ai_family,
cur->ai_socktype,
cur->ai_protocol);
if (sock_fd >= 0)
{
msock_make_socket_nonblocking(sock_fd);
/*
** Try the current addrinfo
** Patch by https://code.google.com/p/mailsend/issues/detail?id=34
*/
rc = connect(sock_fd, cur->ai_addr, cur->ai_addrlen);
eno = msock_get_errno(sock_fd);
if (debug)
{
(void) fprintf(stderr,"> EINPROGRESS=%d,EWOULDBLOCK=%d\n",
EINPROGRESS,EWOULDBLOCK);
(void) fprintf(stderr,"> connect(): socket=%d,rc=%d, errno=%d\n",
sock_fd,rc,eno);
}
if (rc != 0)
{
if (eno == EINPROGRESS ||
eno == EWOULDBLOCK)
{
/*
** our socket is non blocking.
** we need this to timout connection .
** we'll make the socket blocking again at the end
*/
rc = 0;
if (debug)
{
(void) fprintf(stderr,"> Try socket %d\n",sock_fd);
}
break;
}
}
else
{
msock_close_socket(sock_fd);
}
}
}
freeaddrinfo(ressave);
if (rc != 0)
{
(void) fprintf(stderr,"Could not connect to %s:%d\n",address,port);
return(INVALID_SOCKET);
}
#else
addr=atoAddr(address);
if (addr == NULL)
{
(void) fprintf(stderr,"Error: Invalid address: %s\n",address);
return(INVALID_SOCKET);
}
memset((char *) &sa,0,sizeof(sa));
sa.sin_family=AF_INET;
sa.sin_port=htons(port);
sa.sin_addr.s_addr=addr->s_addr;
/* open the socket */
s=socket(AF_INET,SOCK_STREAM,PF_UNSPEC);
if (s == INVALID_SOCKET)
sock_fd=socket(AF_INET,SOCK_STREAM,PF_UNSPEC);
if (sock_fd == INVALID_SOCKET)
{
(void) fprintf(stderr," Could not create socket\n");
return(INVALID_SOCKET);
}
/* make the socket non-blocking */
msock_make_socket_nonblocking(sock_fd);
rc=connect(sock_fd,(struct sockaddr *) &sa,sizeof(sa));
#endif /* HAVE_GETADDRINFO */
/* connect */
rc=connect(s,(struct sockaddr *) &sa,sizeof(sa));
if (rc < 0)
return(INVALID_SOCKET);
if (rc != 0 )
{
eno = msock_get_errno(sock_fd);
if (eno == ECONNREFUSED)
{
msock_print_error();
msock_close_socket(sock_fd);
return(INVALID_SOCKET);
}
}
FD_ZERO(&fdset);
FD_SET(sock_fd, &fdset);
return(s);
tv.tv_sec = connect_timeout;
tv.tv_usec = 0;
rc = select(sock_fd + 1, NULL, &fdset, NULL, &tv);
if (rc == -1)
{
(void) fprintf(stderr,"Fatal select() error\n");
msock_close_socket(sock_fd);
return (INVALID_SOCKET);
}
if (rc == 0)
{
(void) fprintf(stderr,"Error: Connection to %s:%d timed out after %d seconds\n",
address, port, connect_timeout);
msock_close_socket(sock_fd);
return (INVALID_SOCKET);
}
/* make the socket blocking again*/
msock_make_socket_blocking(sock_fd);
return(sock_fd);
}
/*
** this function writes a character string out to a socket.
** it returns -1 if the connection is closed while it is trying to
@@ -201,12 +539,12 @@ int sockPuts(SOCKET sock,char *str)
return (sockWrite(sock,str,strlen(str)));
}
int sockGets(SOCKET sockfd,char *str,size_t count)
int sockGets(SOCKET sockfd,char *str,size_t count, int read_timeout)
{
int
bytesRead;
int
size_t
totalCount=0;
char
@@ -216,6 +554,34 @@ int sockGets(SOCKET sockfd,char *str,size_t count)
char
lastRead=0;
#if defined(SO_RCVTIMEO)
struct timeval
tv;
#ifdef WINNT
DWORD
dwTime = read_timeout * 1000;
#endif /* WINNT */
#endif /* SO_RCVTIMEO*/
#if defined(SO_RCVTIMEO)
tv.tv_sec = read_timeout;
tv.tv_usec = 0;
if (debug)
{
(void) fprintf(stderr,"> Setting read timeout to: %d seconds\n", read_timeout);
}
#ifndef WINNT
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval));
#else
if (debug)
{
(void) fprintf(stderr,"> Windows Setting read timeout to: %d seconds\n", read_timeout);
}
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&dwTime, sizeof(dwTime));
#endif
#endif /* SO_RCVTIMEO*/
currentPosition=str;
while (lastRead != 10)
@@ -226,6 +592,8 @@ int sockGets(SOCKET sockfd,char *str,size_t count)
/*
** the other side may have closed unexpectedly
*/
msock_print_error();
(void) fprintf(stderr,"Error: Connection is closed unexpectedly\n");
return (-1);
}
lastRead=buf[0];
@@ -249,7 +617,7 @@ int sockGetsSSL(SSL *ssl,char *str,size_t count)
int
bytesRead;
int
size_t
totalCount=0;
char
@@ -268,6 +636,8 @@ int sockGetsSSL(SSL *ssl,char *str,size_t count)
/*
** the other side may have closed unexpectedly
*/
msock_print_error();
(void) fprintf(stderr,"Error: Connection is closed unexpectedly\n");
return (-1);
}
lastRead=buf[0];
@@ -289,11 +659,11 @@ int sockGetsSSL(SSL *ssl,char *str,size_t count)
/* must be called after msock_set_socket() */
/* must be called after msock_set_ssl() if SSL is on */
int msock_gets(char *str,size_t count)
int msock_gets(char *str,size_t count, int read_timeout)
{
if (! msock_is_ssl_on())
{
return(sockGets(msock_get_socket(),str,count));
return(sockGets(msock_get_socket(),str,count, read_timeout));
}
else
{
@@ -335,3 +705,54 @@ void msock_close(void)
msock_close_socket(msock_get_socket());
}
/*
** Make a socket non-blocking
*/
void msock_make_socket_nonblocking(SOCKET sock_fd)
{
#ifndef WINNT
int
flags;
#else
unsigned long
mode = 1L;
#endif /* WINNT */
if (sock_fd == INVALID_SOCKET)
{
return;
}
#ifdef WINNT
ioctlsocket(sock_fd, FIONBIO, &mode);
#else
/* Stevens: Page 411 */
flags = fcntl(sock_fd, F_GETFL);
fcntl(sock_fd, F_SETFL, (flags | O_NONBLOCK));
#endif /* WINNT */
}
/*
** Make a socket blocking
*/
void msock_make_socket_blocking(SOCKET sock_fd)
{
#ifndef WINNT
int
flags;
#else
unsigned long
mode = 0L;
#endif /* WINNT */
if (sock_fd == INVALID_SOCKET)
{
return;
}
#ifdef WINNT
ioctlsocket(sock_fd, FIONBIO, &mode);
#else
/* Stevens: Page 411 */
flags = fcntl(sock_fd, F_GETFL);
fcntl(sock_fd, F_SETFL, (flags & ~O_NONBLOCK));
#endif /* WINNT */
}
+31 -5
View File
@@ -8,8 +8,13 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <windows.h>
/*#include <windows.h>*/
#include <winsock2.h>
/* http://support.microsoft.com/kb/955045 */
/* for getaddrinfo in win2k */
#include <ws2tcpip.h>
#include <wspiapi.h>
#define snprintf _snprintf
#else
#include <stdio.h>
@@ -53,8 +58,17 @@
#endif /* HAVE_OPENSSL */
SOCKET clientSocket(char *,int);
int sockGets(SOCKET,char *,size_t);
#include "werrno.h"
#define MSOCK_USE_IPV4 0x01
#define MSOCK_USE_IPV6 0x02
#define MSOCK_USE_AUTO 0x03
/**
* familty can be USE_IPV4, USE_IPV6 or USE_AUTO
*/
SOCKET clientSocket(int use, char *server_addr,int port, int connect_timeout);
int sockGets(SOCKET,char *,size_t, int read_timoeut);
int sockPuts(SOCKET sock,char *str);
void msock_set_socket(SOCKET sock);
@@ -62,10 +76,22 @@ SOCKET msock_get_socket(void);
void msock_turn_ssl_on(void);
void msock_turn_ssl_off(void);
int msock_is_ssl_on(void);
int msock_gets(char *buf,size_t bufsiz);
int msock_gets(char *buf,size_t bufsiz, int connect_timeout);
int msock_puts(char *str);
void msock_close_socket(SOCKET fd);
void msock_close(void);
void msock_make_socket_nonblocking(SOCKET sock_fd);
void msock_make_socket_blocking(SOCKET sock_fd);
void msock_print_error(void);
void msock_set_logfp(FILE *logfp);
void msock_set_debug(int debug);
#ifdef WINNT
int msock_get_errno(SOCKET sock_fd);
#else
#define msock_get_errno(sock_fd) (errno)
#endif /* WINNT */
#ifdef HAVE_OPENSSL
@@ -0,0 +1,118 @@
#ifndef WERRNO_H
#define WERRNO_H
#ifdef WINNT
/*
** This file is auto generated on Sun Aug 26 10:12:25 -0400 2012
** Map wisock error code. Newer Visual Studio defines them
** but they do not map to Winsock error code.
*/
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#undef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#undef EALREADY
#define EALREADY WSAEALREADY
#undef ENOTSOCK
#define ENOTSOCK WSAENOTSOCK
#undef EDESTADDRREQ
#define EDESTADDRREQ WSAEDESTADDRREQ
#undef EMSGSIZE
#define EMSGSIZE WSAEMSGSIZE
#undef EPROTOTYPE
#define EPROTOTYPE WSAEPROTOTYPE
#undef ENOPROTOOPT
#define ENOPROTOOPT WSAENOPROTOOPT
#undef EPROTONOSUPPORT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#undef ESOCKTNOSUPPORT
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#undef EOPNOTSUPP
#define EOPNOTSUPP WSAEOPNOTSUPP
#undef EPFNOSUPPORT
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#undef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#undef EADDRINUSE
#define EADDRINUSE WSAEADDRINUSE
#undef EADDRNOTAVAIL
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
#undef ENETDOWN
#define ENETDOWN WSAENETDOWN
#undef ENETUNREACH
#define ENETUNREACH WSAENETUNREACH
#undef ENETRESET
#define ENETRESET WSAENETRESET
#undef ECONNABORTED
#define ECONNABORTED WSAECONNABORTED
#undef ECONNRESET
#define ECONNRESET WSAECONNRESET
#undef ENOBUFS
#define ENOBUFS WSAENOBUFS
#undef EISCONN
#define EISCONN WSAEISCONN
#undef ENOTCONN
#define ENOTCONN WSAENOTCONN
#undef ESHUTDOWN
#define ESHUTDOWN WSAESHUTDOWN
#undef ETOOMANYREFS
#define ETOOMANYREFS WSAETOOMANYREFS
#undef ETIMEDOUT
#define ETIMEDOUT WSAETIMEDOUT
#undef ECONNREFUSED
#define ECONNREFUSED WSAECONNREFUSED
#undef ELOOP
#define ELOOP WSAELOOP
#undef EHOSTDOWN
#define EHOSTDOWN WSAEHOSTDOWN
#undef EHOSTUNREACH
#define EHOSTUNREACH WSAEHOSTUNREACH
#undef EPROCLIM
#define EPROCLIM WSAEPROCLIM
#undef EUSERS
#define EUSERS WSAEUSERS
#undef EDQUOT
#define EDQUOT WSAEDQUOT
#undef ESTALE
#define ESTALE WSAESTALE
#undef EREMOTE
#define EREMOTE WSAEREMOTE
#endif /* WINNT */
#endif /* WERRNO_H */
+10 -9
View File
@@ -1,23 +1,24 @@
#
# ma_muquit@fccc.edu
# jul-29-199
#
# jul-29-1999
CC= gcc
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_MALLOC_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CTYPE_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_FLOCK=1 -DHAVE_SOCKET=1 -DHAVE_HTONL=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETHOSTBYADDR=1 -DHAVE_YP_GET_DEFAULT_DOMAIN=1 -DHAVE_LIBNSL=1 -DHAVE_RES_SEARCH=1 -DHAVE_LIBRESOLV=1 -DHAVE_INET_ATON=1 -DHAVE_DN_SKIPNAME=1 -DHAVE_MKSTEMP=1 -DHAVE_OPENSSL=1
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_MALLOC_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CTYPE_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_LIMITS_H=1 -DHAVE_FLOCK=1 -DHAVE_SOCKET=1 -DHAVE_HTONL=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETHOSTBYADDR=1 -DHAVE_RES_SEARCH=1 -DHAVE_LIBRESOLV=1 -DHAVE_INET_ATON=1 -DHAVE_DN_SKIPNAME=1 -DHAVE_MKSTEMP=1 -DHAVE_GETADDRINFO=1
AR= ar cq
RANLIB= ranlib
LIBNAME= libmutils.a
INCLUDES= -I. -I/usr/include/malloc
OPENSSL_DIR=
OPENSSL_INC=
OPENSSL_LIBS=
# replace -O with -g in order to debug
INCLUDES= -I. $(OPENSSL_INC)
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
SRCS = string.c mutils.c mime.c
OBJS = string.o mutils.o mime.o
SRCS = string.c mutils.c mutils_mime.c mutils_blob.c \
mutils_error.c mutils_temp.c mutils_time.c
OBJS = string.o mutils.o mutils_mime.o mutils_blob.o \
mutils_error.o mutils_temp.o mutils_time.o
.c.o:
rm -f $@
+35
View File
@@ -0,0 +1,35 @@
# jul-29-1999
CC= @CC@
DEFS= @DEFS@
AR= ar cq
RANLIB= @RANLIB@
LIBNAME= libmutils.a
OPENSSL_DIR=@OPENSSL_DIR@
OPENSSL_INC=@OPENSSL_INC@
OPENSSL_LIBS=@OPENSSL_LIBS@ @DL_LIB@
INCLUDES= -I. $(OPENSSL_INC)
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
SRCS = string.c mutils.c mutils_mime.c mutils_blob.c \
mutils_error.c mutils_temp.c mutils_time.c
OBJS = string.o mutils.o mutils_mime.o mutils_blob.o \
mutils_error.o mutils_temp.o mutils_time.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: $(LIBNAME)
$(LIBNAME): $(OBJS)
rm -f $@
$(AR) $@ $(OBJS)
$(RANLIB) $@
clean:
rm -f $(OBJS) $(LIBNAME) core
+32
View File
@@ -0,0 +1,32 @@
#--------------------------------------------
# Makefile for MS Visual C++
# muquit@muquit.com
# updated for MS Visual Studio 10.0 Feb-27-2012
#--------------------------------------------
OPENSSL_DIR=c:/openssl
OPENSSL_INC=/I$(OPENSSL_DIR)/include
CFLAGS= /DWINNT /DWIN32 /DHAVE_MALLOC_H /DHAVE_STRING_H /DHAVE_FCNTL_H /DHAVE_CTYPE_H /DHAVE_STDLIB_H /DHAVE_OPENSSL /I. $(OPENSSL_INC)
CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo
LIBFLAGS=/nologo
LIBRARY=mutils.lib
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS)
#CFLAGS= $(cvars) $(cdebug) -nologo -G4 $(DEFINES)
SRCS = string.c mutils.c muilts_mime.c mutils_error.c mutils_blob.c \
mutils_temp.c mutils_time.c
OBJS = string.obj mutils.obj mutils_mime.obj mutils_error.obj mutils_blob.obj \
mutils_temp.obj mutils_time.obj
all: $(LIBRARY)
$(LIBRARY): $(OBJS)
lib $(LIBFLAGS) $(OBJS) /out:$(LIBRARY)
clean:
del $(OBJS) $(LIBRARY) *.bak
View File
+32
View File
@@ -0,0 +1,32 @@
#--------------------------------------------
# Makefile for MS Visual C++
# ma_muquit@fccc.edu
# Jan-09-1999, Saturday, for Count 2.5
# Aug-08-1999
#--------------------------------------------
CC= cl /MD
DEFS= -DWINNT=1 -DSTRICT_MODE=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STDLIB_H=1
INCLUDES= -I. -I..
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS)
CFLAGS= $(cvars) $(cdebug) -nologo -G4 $(DEFINES)
SRCS = string.c mutils.c mime.c
OBJS = string.obj mutils.obj mime.obj
.c.obj:
$(CC) $(CFLAGS) -c $< -Fo$@
all: utils.lib
utils.lib: $(OBJS)
link /lib /OUT:mutils.lib $(OBJS)
utils.obj: mutils.h
clean:
del $(OBJS) mutils.lib *.bak
View File
@@ -0,0 +1,76 @@
/*
** mkey_hex and iv are generated at compile time
**
** muquit@muquit.com May-14-2012
*/
#include "mutils.h"
#define MKEY_HEX_LENGTH 48
#define IV_HEX_LENGTH 8
/* master key and iv are generated on: @MKEY_GENERATED@ */
/* -- GENERATED CODE: do not modify stats -- */
static char *mkey_hex="@MKEY_HEX@";
static char *iv_hex="@IV_HEX@";
/* -- GENERATED CODE: do not modify ends -- */
/*
** Return a 24 byte binary data.
*/
unsigned char *mutils_get_master_key24(void)
{
unsigned char
*bin = NULL;
int
olen;
char
*hex,
*default_mkey_hex;
default_mkey_hex="cfed17bd5ca36d94bfb77e029a2d0c876f6d0cc2bc8a53d6";
if (mkey_hex && strlen(mkey_hex) == MKEY_HEX_LENGTH)
{
hex = mkey_hex;
}
else
{
hex = default_mkey_hex;
}
bin = mutils_hex_to_bin(hex, MKEY_HEX_LENGTH, &olen);
if (olen > 0)
return(bin);
return(NULL);
}
/*
** Returns a 8 byte binary data
*/
unsigned char *mutils_get_iv8(void)
{
unsigned char
*bin = NULL;
int
olen;
char
*hex,
*default_iv_hex;
default_iv_hex="f76f9c327947ee19";
if (iv_hex && strlen(iv_hex) == IV_HEX_LENGTH)
{
hex = iv_hex;
}
else
{
hex = default_iv_hex;
}
bin = mutils_hex_to_bin(hex, IV_HEX_LENGTH, &olen);
if (olen > 0)
return(bin);
return(NULL);
}
+750 -12
View File
@@ -6,6 +6,263 @@
static int
lock_fd=(-1);
static const char basis_64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/* taken from Parrot code */
const char Parrot_utf8skip[256] =
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ascii */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* bogus */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* bogus */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* bogus */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* bogus */
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* scripts */
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* scripts */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* cjk etc. */
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6 /* cjk etc. */
};
#define UTF8_IS_START(c) ((c) >= 0xC2 && (c) <= 0xF4)
#define UTF8SKIP(c) Parrot_utf8skip[c]
#define UTF8_IS_CONTINUATION(c) (((c) & 0xC0) == 0x80)
void mutils_liberate_memory(void **memory)
{
if (memory == NULL)
return;
if (*memory)
free(*memory);
*memory=(void *) NULL;
}
void mutils_liberate(void **memory)
{
if (memory == NULL)
return;
if (*memory)
free(*memory);
*memory=(void *) NULL;
}
void mutils_free_zero(void *buf,int size)
{
if (buf)
{
memset(buf,0,size);
mutils_liberate_memory(&buf);
}
}
/**
* @brief same as mutils_acquire_memory
*/
void *mutils_acquire_memory(size_t size)
{
void
*ptr;
if (size == 0)
{
mutils_error("%s (%d) - allocation size is specified as 0\n",MUTILS_CFL);
return(NULL);
}
ptr=malloc(size);
if (ptr)
{
memset(ptr,0,size);
}
return(ptr);
}
/*
** changes the size of the memory and returns a pointer to the (possibly
** moved) block. The contents will be unchanged up to the lesser of the new
** and old sizes.
*/
void mutils_reacquire_memory(void **memory,const size_t size)
{
void
*allocation;
if (memory == NULL)
return;
if (*memory == (void *) NULL)
{
*memory=mutils_acquire_memory(size);
return;
}
allocation=realloc(*memory,size);
if (allocation == (void *) NULL)
mutils_liberate_memory((void **) memory);
*memory=allocation;
}
/* from my hod program, muquit, Nov-10-2000 */
static void mutils_hex_or_oct_dump(FILE *fp,int base,unsigned char *buf,int length)
{
int
ii,
i;
unsigned char
hexbuf[16];
int
count=0;
int
line = 0;
int
c;
unsigned char
*p=buf;
if (length <= 0)
return;
*hexbuf='\0';
(void) fprintf (fp,
(base == 16) ? "%11d" : "%11d",0);
(void) fflush (fp);
for (i=1; i<base;i++)
{
(void) fprintf (fp,
(base == 16) ? "%3x" : "%4o", i);
}
(void) fprintf (fp,
(base == 16) ? " " : " ");
for (i=0; i <base; i++)
{
(void) fprintf (fp, "%x", i);
}
(void) fprintf (fp,"\n");
for (ii=0; ii < length; ii++, p++)
{
c=*p;
hexbuf[count] = (unsigned char) c;
if (count++ == 0)
{
if (base == 16)
{
/*
(void) fprintf (fp, "%8x: ",line * 0x10);
*/
/* print offset in decimal */
(void) fprintf(fp,"%8d: ",line * base);
}
else
{
(void) fprintf (fp, "%8o: ",line * 0x08);
}
}
(void) fprintf (fp,
(base == 16) ? "%02x " : "%03o ", hexbuf[count-1]);
if (count == base)
{
(void) fprintf (fp," ");
for (i=0; i <base; i++)
{
/* 127 is non-printable - muquit@muquit.com Oct-03-2002 */
if (hexbuf[i] >= 32 && hexbuf[i] < 127)
(void) fprintf (fp,"%c", hexbuf[i]);
else
(void) fprintf (fp,".");
}
count=0;
line++;
(void) fprintf (fp,"\n");
}
} /* while c!= EOF*/
(void) fflush (fp);
/*
** pad if necessary
*/
if (count < base)
{
int
j;
for (j=count; j <base; j++)
{
(void) fprintf (fp,
(base == 16) ? " " : " ");
}
(void) fprintf (fp," ");
for (i=0; i < count; i++)
{
/* 127 is non-printable - muquit@muquit.com Oct-03-2002 */
if (hexbuf[i] >= 32 && hexbuf[i] < 127)
{
(void) fprintf (fp,"%c", hexbuf[i]);
}
else
(void) fprintf (fp,".");
}
(void) fprintf (fp,"\n");
(void) fflush (fp);
} /* count < base .. */
}
void mutils_hex_dump(FILE *fp,unsigned char *buf,int length)
{
mutils_hex_or_oct_dump(fp,16,buf,length);
}
void mutils_hex_print(FILE *fp,unsigned char *bytes,int len)
{
int
i;
for (i=0; i < len; i++)
{
(void) fprintf(fp,"%02x ",bytes[i]);
if ((i % 16) == 15)
fprintf(fp, "\n");
}
(void) fprintf(fp,"\n");
}
void mutils_oct_dump(FILE *fp,unsigned char *buf,int length)
{
mutils_hex_or_oct_dump(fp,8,buf,length);
}
/*
** mutilsHowmanyCommas()
@@ -224,9 +481,7 @@ int
/* initialize */
*port=80;
*hostname='\0';
*page='\0';
*tmpbuf='\0';
*hostname = *page = *tmpbuf = '\0';
tmpbuf_len=sizeof(tmpbuf);
@@ -324,8 +579,7 @@ char *mutilsSpacesToChar(char *str,int c)
{
char
*ibuf,
*obuf,
*nbuf;
*obuf;
register int
i,
@@ -708,6 +962,7 @@ void mutilsStripTrailingSpace (char *str)
** make a temporary filename
** filename - returns
*/
#if 0
int mutilsTmpFilename(char *filename)
{
#define TMP_DIR "/tmp"
@@ -726,6 +981,7 @@ int mutilsTmpFilename(char *filename)
return(mktemp(filename));
#endif /* ! HAVE_MKSTEMP */
}
#endif /* 0 */
/*
@@ -767,9 +1023,7 @@ int mutilsTmpFilename(char *filename)
* Development History:
* 3/26/92, jps, first cut
*/
char *mutilsBasename(path)
char
*path;
char *mutilsBasename(char *path)
{
char
*cptr;
@@ -788,6 +1042,80 @@ char
}
/*
** Return the extension of a file in a path
** Parameters:
** path - path of a file
** Return Values:
** pointer to the extension
** Side Effects:
** none
** Comments:
** If that is /usr/local/file.pdf, pointer to
** pdf will be returned
** Development History:
** muquit@muquit.com Dec-15-2013 - needed to detect mime type based on extension
*/
char *mutilsExtension(char *path)
{
char
*base,
*cptr;
base = mutilsBasename(path);
for (cptr = base + strlen(base); cptr >= base; --cptr)
{
switch (*cptr)
{
case '.':
{
return ++cptr;
}
}
}
return path;
}
char *mutilsExtensionLower(char *path)
{
char
*ext;
return (mutilsStrLower(mutilsExtension(path)));
}
/*
** Return the basename of a path
** Parameters:
** path - path in Unix or windows style
**
** Return Values:
** pointer to the basename on success
** pointer to the path on failure
** Side Effects:
** no memory is allocated, pointer is returned
** pointing to the basename
** Comments:
** If path is say /usr/local/foo, foo will be returned
** on success. if path is c:\foo\bar, pointer to bar
** will be returned. if path is blah, pointer ot
** blah will be returned
** Development History:
** muquit@muquit.com Dec-15-2013
** didn't know I already had it
*/
char *mutils_basename(const char *path)
{
char
*bn = path;
bn = strrchr(path,'/');
if (bn == NULL)
{
bn = strrchr(path,'\\');
}
return (bn == NULL) ? path : ++bn;
}
/*
** mutilsDotLock()
** open a file for locking purpose. If the system is Unix, use
@@ -985,9 +1313,6 @@ char
*f,
*p;
int
len;
if (file == NULL || *file == '\0')
return (NULL);
@@ -1142,15 +1467,41 @@ static void _fs_give (void **block)
*block = NULL;
}
/*
**
** Given the length of a plain text string, return the
** length
**
** Parameters:
** len - length of plain text string
**
** Side Effects:
** none
**
** Comments:
** taken from apache apr util library
**
** Return Values:
** length of base64 encoded string
**
** Development History:
** muquit@muquit.com Oct-12-2013 first cut
*/
int mutils_base64_encode_len(int len)
{
return ((len + 2) / 3 * 4) + 1;
}
/**
* @Deprecated
* @brief encode content to base64
* @param src pointer to source
* @param srcl Length of the source
* @param len length of base64 encoded string (returns)
*
* @return Ponter to encoded strin gon success, NULL on failure. The
* caller is responsile to free the memory
* caller is responsile to free the memory
*
* Adapted from from c-client source
*/
@@ -1215,6 +1566,82 @@ unsigned char *mutils_encode_base64(void *src,unsigned long srcl,unsigned long *
return (ret); /* return the resulting string */
}
/*
** Endode a string to base64
**
** Parameters:
** string - plain text/binary string
** len - length of the plain text string
**
** Return Values:
** Pointer to null terminated base 64 string. Memory is allocated for
** the string
** NULL in case of error.
** Comments:
** reason not to use mutils_encode_base64(), it adds crlf after 60
** characters, which broke smtp auth with longer base64 encoded string.
**
** The caller is responsible to free the memory of the returned string.
**
** Adapted from apache apr util library. Does not support EBCDIC.
**
** Side Effects:
** none
**
** Development History:
** muquit@muquit.com Oct-12-2013 first cut
*/
char *mutils_encode_base64_noformat(const char *string, int len)
{
int
encode_len,
i;
char
*p,
*encoded = NULL;
if (len == 0)
{
return NULL;
}
encode_len = mutils_base64_encode_len(len);
encoded = (char *) malloc(encode_len);
MUTILS_CHECK_MALLOC(encoded);
memset(encoded, 0, encode_len);
p = encoded;
for (i = 0; i < len - 2; i += 3)
{
*p++ = basis_64[(string[i] >> 2) & 0x3F];
*p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)];
*p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i + 2] & 0xC0) >> 6)];
*p++ = basis_64[string[i + 2] & 0x3F];
}
if (i < len)
{
*p++ = basis_64[(string[i] >> 2) & 0x3F];
if (i == (len - 1))
{
*p++ = basis_64[((string[i] & 0x3) << 4)];
*p++ = '=';
}
else
{
*p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0) >> 4)];
*p++ = basis_64[((string[i + 1] & 0xF) << 2)];
}
*p++ = '=';
}
*p++ = '\0';
return encoded;
ExitProcessing:
return NULL;
return strdup("fuck");
}
/**
* @brief converts base64 contents to binary
@@ -1330,6 +1757,317 @@ void *mutils_decode_base64(unsigned char *src,unsigned long srcl,unsigned long *
return ret; /* return the string */
}
unsigned char mutils_hex_char_to_bin(char x)
{
if (x >= '0' && x <= '9')
return(x - '0');
x=toupper(x);
return((x - 'A') + 10);
}
/**
* convert a hex string to it's binary format.
* @param hex_string - The hex string to convert
* @param len - length of the hex string
* @param *olen - The length of the binary string - returns
*
* @return pointer to a unsigned char holding the binary version of the
* hex string. returns NULL on failure. The caller should check
* olen (> 0) before using the binary
*
* @note Memory is allocated for the retured unsigned char pointer
* The caller is responsible to free it
*
* The format of the hex string can be any of:
* 0xde:ad:be:ef:ca:fe
* de:ad:be:ef:ca:fe
* de-ad-be-ef-ca-fe
* 0xde-ad-be-ef-ca-fe
* de:ad-be_ef:ca:fe
*
* The converted binary value will be: de ad be ef ca fe
*
* It will only convert valid hex strings to binary, for example, if
* the string is like: de:gh:ad:ff:bb:kk:cc
* The binary value will contain: de ad ff bb cc
* Note, gh and kk are ignored
*/
unsigned char *mutils_hex_to_bin(char *hex_string,int len,int *olen)
{
int
j=0;
int
bin_len=0,
n=0,
i;
unsigned char
value,
*out,
space[4];
char
*cp=hex_string;
if (! hex_string || ! len)
return(NULL);
if ((*cp == '0') && ((*(cp + 1) == 'x') || (*(cp + 1) == 'X')))
{
cp += 2;
n=2;
}
/*
** allocate half of hex_string as the length of binary.
** we may be allocated more than needed as : - etc may be
** part of the hex string
*/
bin_len=(len >> 1);
if (bin_len <= 0)
return(NULL);
out=(unsigned char *) malloc(bin_len*sizeof(unsigned char));
memset(out,0,bin_len);
for (i=n; i < len; i += 2)
{
if (hex_string[i] == '\n' || hex_string[i] == '\r' ||
hex_string[i] == ' ' || hex_string[i] == '\t' ||
hex_string[i] == ':' ||
hex_string[i] == '-' ||
hex_string[i] == '_')
{
i--;
continue;
}
if (isxdigit(hex_string[i]) && isxdigit(hex_string[i+1]))
{
value=(mutils_hex_char_to_bin (hex_string[i]) << 4) & 0xf0;
value |= (mutils_hex_char_to_bin(hex_string[i+1]) & 0x0f);
out[j++]=value;
}
}
*olen=j;
return(out);
}
/**
* @brief convert binary to hex
* @param input - binary data
* @param len - length of input data
* @param output - NULL terminated string equivalent in hex
* @return length of output string (not including NULL) on success, -1
* on failure
*
* Note: *output points to a malloc'd space, caller is responsible to
* to free it
* adapted from net-snmp 5.0.6 code (tools.c)
*/
int mutils_binary_to_hex(unsigned char *input,int len,char **output)
{
int
olen;
char
*s,
*op;
unsigned char
*ip;
olen=(len * 2) + 1;
s=(char *) calloc(1,olen);
if (s == NULL)
return (-1);
op=s;
ip=input;
while ((ip - input) < len)
{
*op++ = MUTILS_VAL2_HEX((*ip >> 4) & 0xf);
*op++ = MUTILS_VAL2_HEX(*ip & 0xf);
ip++;
}
*op='\0';
*output=s;
return(olen);
}
/**
* @brief convert binary to hex
* @param in binary data
* @param in_len length of input in bytes
* @param out output buffer to hold the converted hex data. in/out. The buffer is
* NULL terminated.
* @param out_len bytes of memroy pre allocated in out. out_len must be
* greater than in_len*2
* @return length of converted hex buffer on success, -1 on failure
*
* Note: this function is similar to mutils_binary_to_hex(), only differece is
* that in this function, the caller passes the pre-allocated buffer.
*/
int mutils_binary_to_hex_buf(unsigned char *in,int in_len,char *out,int *out_len)
{
char
*op;
unsigned char
*ip;
op=out;
ip=in;
if (*out_len < (in_len * 2) + 1)
{
*out_len=(-1);
(void) fprintf(stderr,"%s (%d) - outbuf must have atlease %d bytes of space pre-allocated\n",
MUTILS_CFL,((in_len * 2) + 1));
return(-1);
}
*out_len=(in_len * 2);
while ((ip - in) < in_len)
{
*op++ = MUTILS_VAL2_HEX((*ip >> 4) & 0xf);
*op++ = MUTILS_VAL2_HEX(*ip & 0xf);
ip++;
}
*op='\0';
return(*out_len);
}
/*
** return MUTILS_TRUE if the file is binary. MUTILS_FALSE otherwise.
** return -1 on error
** The algorithm is adapted from Perl pp_fttext()
** 512 bytes of file is used.
**
** here is the algorithm (perldoc -I -B|more)
The "-T" and "-B" switches work as follows. The first block or
so of the file is examined for odd characters such as strange
control codes or characters with the high bit set. If too many
strange characters (>30%) are found, it's a "-B" file;
otherwise it's a "-T" file. Also, any file containing a zero
byte in the first block is considered a binary file
*/
int mutils_file_is_binary(const char *file)
{
struct stat
sbuf;
FILE
*fp = NULL;
char
*s,
buf[513];
size_t
len;
int
i,
sz,
n;
int
odd = 0;
float
x;
sz = sizeof(buf) - 1;
if (stat(file, &sbuf) != 0)
{
(void) fprintf(stderr,"Could not stat file %s\n",file);
return(-1);
}
len = sbuf.st_size;
if (len > 512)
{
len = 512;
}
fp = fopen(file, "rb");
if (fp == NULL)
{
(void) fprintf(stderr,"Error reading file: %s\n",file);
return(-1);
}
memset(buf, 0, sizeof(buf));
n = fread(buf, 1, len, fp);
if (n != len)
{
(void) fprintf(stderr,"read error\n");
return(-1);
}
s = buf;
if (len && len < sizeof(buf) && buf[len - 1] == 0x1a)
{
--len;
}
for (i=0; i < len; i++, s++)
{
if (!*s)
{
odd += len;
break;
}
else if (*s & 128)
{
if (UTF8_IS_START(*s))
{
int ulen = UTF8SKIP(*s);
if (ulen < len - i)
{
int
j;
for (j = 1; j < ulen; j++)
{
if (!UTF8_IS_CONTINUATION(s[j]))
{
goto NotUtf8;
}
}
--ulen;
s += ulen;
i += ulen;
continue;
}
}
NotUtf8:
odd++;
}
else
{
if (*s < 32 && *s != '\n' && *s != '\r' && *s != '\b' &&
*s != '\t' && *s != '\f' && *s != 27)
{
odd++;
}
}
}
x = ((odd * 1.0) / (len * 1.0));
if (x < 0.30)
{
return MUTILS_FALSE;
}
else
{
return MUTILS_TRUE;
}
ExitProcessing:
if (fp)
{
(void) fclose(fp);
}
return(-1);
}
#ifdef TEST
+162 -3
View File
@@ -33,7 +33,20 @@
#include <sys/stat.h>
#include <io.h>
#include <share.h>
#include <direct.h>
#include <Winsock2.h> /* for timeval */
#define ftruncate chsize
#ifdef getcwd
#undef getcwd
#endif
#define getcwd _getcwd
#ifdef snprintf
#undef snprintf
#endif
#define snprintf _snprintf
#endif
#if HAVE_SYS_PARAM_H
@@ -48,6 +61,8 @@
#include <unistd.h>
#endif
#include <stdarg.h>
#if HAVE_FCNTL_H
#ifndef O_RDONLY /* prevent multiple inclusion on lame systems (from
vile)*/
@@ -75,8 +90,62 @@ vile)*/
#endif
#endif
#define MUTILS_CFL __FILE__,__LINE__
#if APR_HAVE_LIMITS_H
#include <limits.h>
#else
#if APR_HAVE_SYS_SYSLIMITS_H
#include <sys/syslimits.h>
#endif
#endif
#if defined(PATH_MAX)
#define MUTILS_PATH_MAX PATH_MAX
#elif defined(_POSIX_PATH_MAX)
#define MUTILS_PATH_MAX _POSIX_PATH_MAX
#else
#define MUTILS_PATH_MAX 4098
#endif
#if !defined(O_BINARY)
#define O_BINARY 0x00
#endif
#define MUTILS_TRUE 1
#define MUTILS_FALSE 0
typedef struct _MutilsBlob
{
size_t
length;
unsigned char
*data;
size_t
offset,
size;
}MutilsBlob;
#ifdef WINNT
typedef struct _MutilsTime
{
FILETIME
absolute;
}MutilsTime;
#else
typedef struct _MutilsTime
{
unsigned int
secs,
nsecs;
}MutilsTime;
#endif /* WINNT */
#define MUTILS_CFL __FILE__,__LINE__
#define MCFL __FILE__,__LINE__
#define MJL __LINE__
#if __STDC__ || defined(sgi) || defined(_AIX)
#undef _Declare
@@ -88,7 +157,6 @@ vile)*/
#define MUTILS_MAX_TOKEN_LEN 1024
#define MUTILS_CHECK_MALLOC(p) \
do \
{ \
@@ -99,9 +167,42 @@ do \
}\
}while(0)
/* from net-snmp 5.0.6 tools.h */
#define MUTILS_FREE(s) if (s) { free((void *)s); s=NULL;}
#define MUTILS_TOUPPER(c) (c >= 'a' && c <= 'z' ? c - ('a' - 'A') : c)
#define MUTILS_TOLOWER(c) (c >= 'A' && c <= 'Z' ? c + ('a' - 'A') : c)
#define MUTILS_VAL2_HEX(s) ( (s) + (((s) >= 10) ? ('a'-10) : '0') )
#define MUTILS_HEX2_VAL(s) \
((isalpha(s) ? (MUTILS_TOLOWER(s)-'a'+10) : (MUTILS_TOLOWER(s)-'0')) & 0xf)
#define MUTILS_MAX(a,b) ((a) > (b) ? (a) : (b))
#define MUTILS_MIN(a,b) ((a) > (b) ? (b) : (a))
/* from net-snmp 5.0.6 tools.h */
/* function prototypes */
typedef void (*mutils_error_func) (char *fmt,va_list args);
typedef void (*mutils_hexdump_func) (unsigned char *bytes,int bytes_len);
void mutils_error (char *fmt,...);
void mutils_info (char *fmt,...);
void mutils_warn (char *fmt,...);
void mutils_debug(char *fmt,...);
void mutils_set_debug(int debug);
void mutils_set_error_hook(mutils_error_func new_func);
void mutils_set_info_hook(mutils_error_func new_func);
void mutils_set_debug_hook(mutils_error_func new_func);
void mutils_set_warn_hook(mutils_error_func new_func);
void mutils_set_hexdump_hook(mutils_hexdump_func new_func);
void mutils_set_hexprint_hook(mutils_hexdump_func new_func);
void mutils_reset_error_hook(void);
void mutils_reset_info_hook(void);
void mutils_reset_warn_hook(void);
void mutils_reset_debug_hook(void);
void mutilsBase64Encode (FILE *ifp,FILE *ofp);
void mutilsGenerateMIMEBoundary(char *boundary,int len);
int mutilsParseURL (char *url,char *hostname,
@@ -127,8 +228,10 @@ char *mutilsStristr (char *s,char *t);
int mutilsIsinname (char *string,char *mask);
char *mutilsGetTime (void);
char mutilsChopNL (char *str);
int mutilsTmpFilename (char *filename);
/*int mutilsTmpFilename (char *filename);*/
char *mutilsBasename (char *path);
char *mutilsExtension (char *file_path);
char *mutilsExtensionLower (char *file_path);
int mutilsWhich (char *name);
void mutilsSetLock (int fd);
void mutilsDotLock (char *filepath,char *errbuf);
@@ -141,8 +244,64 @@ char *mutilsGetDirname (char *file);
char *mutilsSpacesToChar (char *str,int c);
char **mutilsTokenize(char *str,int delim,int *ntokens);
void mutilsFreeTokens(char **tokens,int ntokens);
int mutils_base64_encode_len(int len);
unsigned char *mutils_encode_base64(void *src,unsigned long srcl,unsigned long *len);
char *mutils_encode_base64_noformat(const char *src, int src_len);
void *mutils_decode_base64(unsigned char *src,unsigned long srcl,unsigned long *len);
int mutils_make_encrypted_key(const char *plain,unsigned char *cipher,int clen);
int mutils_decrypt_key(unsigned char *cipher,int clen,char *plain,int plain_buf_len);
char *mutils_decrypt_hex(char *hex,int hex_len,char *pbuf,int pbuf_len);
void mutils_hex_dump(FILE *fp,unsigned char *buf,int length);
void mutils_hex_print(FILE *fp,unsigned char *bytes,int len);
unsigned char *mutils_get_master_key24(void);
unsigned char *mutils_get_iv8(void);
unsigned char mutils_hex_char_to_bin(char x);
unsigned char *mutils_hex_to_bin(char *hex_string,int len,int *olen);
int mutils_binary_to_hex(unsigned char *input,int len,char **output);
int mutils_binary_to_hex_buf(unsigned char *in,int in_len,char *out,int *out_len);
void *mutils_acquire_memory(size_t size);
void mutils_liberate_memory(void **memory);
void mutils_reacquire_memory(void **memory,const size_t size);
void mutils_attach_blob(MutilsBlob *blob_info,void *blob,size_t length);
void mutils_rewind_blob(MutilsBlob *blob);
MutilsBlob *mutils_clone_blobinfo(MutilsBlob *blob_info);
MutilsBlob *mutils_allocate_blob(int data_len);
MutilsBlob *mutils_file_to_blob(char *filename);
MutilsBlob *mutils_data_to_blob(unsigned char *data,int data_len);
void mutils_detach_blob(MutilsBlob *blob_info);
void mutils_destroy_blob(MutilsBlob *blob);
void mutils_msb_order_long(char *p,const size_t length);
void mutils_msb_order_short(char *p,const size_t length);
int mutils_read_blob(MutilsBlob *blob_info,const size_t length,
void *data);
int mutils_read_blob_byte(MutilsBlob *blob);
unsigned long mutils_read_blob_lsb_long(MutilsBlob *blob_info);
unsigned short mutils_read_blob_lsb_short(MutilsBlob *blob);
unsigned long mutils_read_blob_msb_long(MutilsBlob *blob,int *err_no);
unsigned short mutils_read_blob_msb_short(MutilsBlob *blob,int *err_no);
char *mutils_read_blob_string(MutilsBlob *blob,char *string,int slen);
int mutils_size_blob(MutilsBlob *blob);
int mutils_tell_blob(MutilsBlob *blob);
int mutils_write_blob(MutilsBlob *blob,const size_t length,const void *data);
size_t mutils_write_blob_byte(MutilsBlob *blob_info,const long value);
int mutils_write_blob_lsb_long(MutilsBlob *blob,const unsigned long value);
int mutils_write_blob_lsb_short(MutilsBlob *blob,const unsigned long value);
int mutils_write_blob_msb_long(MutilsBlob *blob,const unsigned long value);
int mutils_write_blob_msb_short(MutilsBlob *blob,const unsigned long value);
size_t mutils_write_blob_string(MutilsBlob *blob_info,const char *string);
char *mutils_getcwd(char *buf,int buflen);
FILE *mutils_get_tempfileFP(char *tempfile_path,int buflen);
char *mutils_basename(const char *path);
int mutils_file_is_binary(const char *file);
/* time */
int mutils_time_now(MutilsTime *mt);
void mutils_time_fmt(MutilsTime *mt,char *buf,int bufsiz);
#endif /* MUTILS_H */
+692
View File
@@ -0,0 +1,692 @@
#include "mutils.h"
/* Note: all the blob realated routines are adapted from ImageMagick */
/*
** attaches a blob to the MutilsBlob structure
*/
void mutils_attach_blob(MutilsBlob *blob_info,void *blob,size_t length)
{
if (blob == (MutilsBlob *) NULL)
return;
blob_info->data=(unsigned char *) blob;
blob_info->length=length;
blob_info->offset=0;
}
/* duplicate the given MutilsBlob structure */
/* returns NULL on failure */
/**
* @brief Duplicates the given blob
* @param blob Blob to duplicate
* @return blob The duplicated blob on success, NULL on failure
*
*/
MutilsBlob *mutils_clone_blobinfo(MutilsBlob *blob)
{
MutilsBlob
*clone_info;
clone_info=(MutilsBlob *) mutils_acquire_memory(sizeof(MutilsBlob));
if (clone_info == (MutilsBlob *) NULL)
{
mutils_error("%s (%d) - unable to clone MutilsBlob, memory allocation failed\n",MUTILS_CFL);
return(NULL);
}
if (blob == (MutilsBlob *) NULL)
{
memset(clone_info,0,sizeof(MutilsBlob));
return(clone_info);
}
*clone_info=(*blob);
return(clone_info);
}
/**
* @brief rewind a blob
* @param blob
*
* Rewinds a blob after processing it
*/
void mutils_rewind_blob(MutilsBlob *blob)
{
if (!blob)
return;
blob->offset=0;
}
/**
* allocate memory for blob and and the data member
* @param data_len - the length of the data in bytes
* @return - pointer to blob on SUCCESS, NULL on failure
*/
MutilsBlob *mutils_allocate_blob(int data_len)
{
MutilsBlob
*blob=NULL;
if (data_len <= 0)
return(NULL);
/* allocate memory for blob */
blob=mutils_clone_blobinfo(NULL);
if (blob == NULL)
return(NULL);
/* allocate memory for data */
blob->length=data_len;
blob->data=(unsigned char *) mutils_acquire_memory(data_len+1);
if (blob->data == NULL)
{
mutils_destroy_blob(blob);
return(NULL);
}
return(blob);
}
/*
** detaches a blob from the BlobInfo structure.
*/
void mutils_detach_blob(MutilsBlob *blob)
{
if (blob == NULL)
return;
blob->length=0;
blob->offset=0;
blob->data=(unsigned char *) NULL;
}
/**
* creates a MutilsBlob object. allocates memory for data, copies the passed
* data, update the length and returns the blob
* @param data The data to copy to blob's data member
* @param data_len The number of bytes of data
* @return MutilsBlob on success NULL on failure
*/
MutilsBlob *mutils_data_to_blob(unsigned char *data,int data_len)
{
MutilsBlob
*blob;
if (data == (unsigned char *) NULL)
return(NULL);
blob=mutils_clone_blobinfo(NULL);
if (blob == (MutilsBlob *) NULL)
{
(void) fprintf(stderr,"%s (%d) unable to create blob, memory allocation problem\n",__FILE__,__LINE__);
return((MutilsBlob *) NULL);
}
blob->length=data_len;
blob->data=(unsigned char *) mutils_acquire_memory(blob->length+1);
if (blob->data == NULL)
{
(void) fprintf(stderr,"Unable to create blob data, memory allocation problem\n");
mutils_destroy_blob(blob);
return((void *) NULL);
}
memcpy(blob->data,data,blob->length);
return(blob);
}
/*
** returns the contents of a file as a blob.
** NULL on failure.
*/
MutilsBlob *mutils_file_to_blob(char *filename)
{
MutilsBlob
*blob;
long
count=0;
size_t
length;
int
fd;
struct stat
statbuf;
if (filename == NULL)
return(NULL);
fd=open(filename,O_RDONLY | O_BINARY);
if (fd == -1)
{
(void) fprintf(stderr,"Unable to open file %s\n",filename);
return((void *) NULL);
}
length=(size_t) (fstat(fd,&statbuf)) < 0 ? 0 : statbuf.st_size;
blob=mutils_clone_blobinfo(NULL);
if (blob == (MutilsBlob *) NULL)
{
(void )close(fd);
(void) fprintf(stderr,"unable to create blob, memory allocation problem\n");
return((MutilsBlob *) NULL);
}
blob->length=length;
blob->data=(unsigned char *) mutils_acquire_memory(blob->length+1);
if (blob->data == NULL)
{
(void) fprintf(stderr,"Unable to create blob data, memory allocation problem\n");
mutils_destroy_blob(blob);
return((void *) NULL);
}
count=read(fd,blob->data,length);
(void) close(fd);
if ((size_t) count != length)
{
mutils_destroy_blob(blob);
return((void *) NULL);
}
return(blob);
}
/*
** deallocates memory associated with an BlobInfo structure
*/
void mutils_destroy_blob(MutilsBlob *blob)
{
if (blob == NULL)
return;
if (blob->data)
(void) free(blob->data);
mutils_liberate_memory((void **) &blob);
}
/*
** converts a least-significant byte first buffer of integers to
** most-significant byte first.
*/
void mutils_msb_order_long(char *p,const size_t length)
{
register char
c,
*q,
*sp;
if (p == NULL)
return;
q=p+length;
while (p < q)
{
sp=p+3;
c=(*sp);
*sp=(*p);
*p++=c;
sp=p+1;
c=(*sp);
*sp=(*p);
*p++=c;
p+=2;
}
}
/*
** converts a least-significant byte first buffer of integers to
** most-significant byte first.
*/
void mutils_msb_order_short(char *p,const size_t length)
{
register char
c,
*q;
if (p == NULL)
return;
q=p+length;
while (p < q)
{
c=(*p);
*p=(*(p+1));
p++;
*p++=c;
}
}
/*
** reads data from the blob and returns it. It returns the number of bytes
** read.
** blob - MutilsBlob
** length - number of bytes to read from blob
** data - returns
**
** returns > 0 on sucess, -1 on failure
*/
int mutils_read_blob(MutilsBlob *blob,const size_t length,void *data)
{
int
count,
n=0;
if (blob == (MutilsBlob *) NULL)
return(-1);
if (blob->data != (unsigned char *) NULL)
{
count=MUTILS_MIN(length,blob->length - blob->offset);
if (count > 0)
{
(void) memcpy(data,blob->data + blob->offset,count);
blob->offset += count;
}
/*
if (count < length)
return(-1);
*/
return(count);
}
return(-1);
}
/*
** reads a single byte from blob and returns it.
** returns -1 on error
*/
int mutils_read_blob_byte(MutilsBlob *blob)
{
size_t
count;
unsigned char
buffer[1];
if (blob == NULL)
return(-1);
count=mutils_read_blob(blob,1,(unsigned char *) buffer);
if (count == 0)
return(-1);
return(*buffer);
}
/*
** reads a long value as a 32 bit quantity in least-significant byte first
**order.
*/
unsigned long mutils_read_blob_lsb_long(MutilsBlob *blob)
{
unsigned char
buffer[4];
unsigned long
value;
if (blob == NULL)
return ((unsigned long) ~0);
value=mutils_read_blob(blob,4,(unsigned char *) buffer);
if (value == 0)
return ((unsigned long) ~0);
value=buffer[3] << 24;
value|=buffer[2] << 16;
value|=buffer[1] << 8;
value|=buffer[0];
return(value);
}
/*
** reads a short value as a 16 bit quantity in least-significant byte first
* order.
*/
unsigned short mutils_read_blob_lsb_short(MutilsBlob *blob)
{
unsigned char
buffer[2];
unsigned short
value;
if (blob == (MutilsBlob *) NULL)
return((unsigned short) ~0);
value=mutils_read_blob(blob,2,(unsigned char *) buffer);
if (value == 0)
return((unsigned short) ~0);
value=buffer[1] << 8;
value|=buffer[0];
return(value);
}
/**
* @brief reads a long value as a 32 bit quantity in most-significant byte
* firstorder.
* @param blob The blob
* @param err_no If no error err_no is set to 0 other wise it is set to
* -1
* @param The read value as unsigned long
*
* The caller should always check the err_no instead of the return code,
* because there's no other way to return a number in case of error
*/
unsigned long mutils_read_blob_msb_long(MutilsBlob *blob,int *err_no)
{
unsigned char
buffer[4];
unsigned long
value;
*err_no=0;
if (blob == (MutilsBlob *) NULL)
{
mutils_error("%s (%d) - mutils_read_blob_msb_long() empty blob\n",
MUTILS_CFL);
*err_no=(-1);
return((unsigned long) ~0);
}
value=mutils_read_blob(blob,4,(unsigned char *) buffer);
if (value == 0)
{
mutils_error("%s (%d) - mutils_read_blob_msb_long() could not read 4 bytes from blob\n",MUTILS_CFL);
*err_no=(-1);
return((unsigned long) ~0);
}
/*
** We can not return ~0 on error because if the value ffffff is read,
** the return code will indicate it's an error
*/
/* return((unsigned long) ~0);*/
value=(unsigned long) buffer[0] << 24;
value|=buffer[1] << 16;
value|=buffer[2] << 8;
value|=buffer[3];
return(value);
}
/**
* @brief reads a short value as a 16 bit quantity in most-significant byte
* firstorder.
* @param blob The blob
* @param err_no If no error err_no is set to 0 other wise it is set to
* -1
* @return The read value as unsigned short
*
* The caller should always check the err_no instead of the return code,
* because there's no other way to return a number in case of error
*/
unsigned short mutils_read_blob_msb_short(MutilsBlob *blob,int *err_no)
{
unsigned char
buffer[2];
unsigned short
value;
*err_no=0;
if (blob == NULL)
{
mutils_error("%s (%d) - mutils_read_blob_msb_short() empty blob\n",
MUTILS_CFL);
*err_no=(-1);
return((unsigned short) ~0);
}
value=mutils_read_blob(blob,2,(unsigned char *) buffer);
if (value == 0)
{
mutils_error("%s (%d) - mutils_read_blob_msb_short() could not read 2 bytes from blob\n",MUTILS_CFL);
*err_no=(-1);
return((unsigned short) ~0);
}
/*
** We can not return ~0 on error because if the value ffff is read,
** the return code will indicate it's an error
*/
/* return((unsigned short) ~0);*/
value=(unsigned short) (buffer[0] << 8);
value |= buffer[1];
return(value);
}
/* reads characters from a blob until a new line or cr is read*/
/* the string is null terminated */
char *mutils_read_blob_string(MutilsBlob *blob,char *string,int slen)
{
int
c,
i;
if (blob == NULL)
return(NULL);
for (i=0; i < slen; i++)
{
c=mutils_read_blob_byte(blob);
if (c == -1)
return((char *) NULL);
string[i]=c;
if ((string[i] == '\n') || (string[i] == '\r'))
break;
}
string[i]='\0';
return(string);
}
/* returns current size of the blob */
/* -1 on error */
int mutils_size_blob(MutilsBlob *blob)
{
if (blob == NULL)
return(-1);
if (blob->data != (unsigned char *) NULL)
return(blob->length);
return(-1);
}
/* returns the current value of the blob position */
/* -1 on failure */
int mutils_tell_blob(MutilsBlob *blob)
{
if (blob == NULL)
return(-1);
if (blob->data != (unsigned char *) NULL)
return(blob->offset);
return(-1);
}
/**
* @brief Writes length bytes of data to blob
* @param blob The blob to fill with data
* @param length Length of data
* @param data Data to write to blob
*
* blob->data must have at least blob->length bytes of data pre-allocated.
* If we need more than that, memory will be allocated dynamically.
*
* blob->offset is incremented with the amount of data written to blob
*
* This code is adapted from ImageMagick. ImageMagick's version reallocate
* data bultiple of 8 bytes. This one allocates exact number of bytes as
* needed.
*
*/
int mutils_write_blob(MutilsBlob *blob,const size_t length,const void *data)
{
int
reallocate_bytes=0;
if (blob == (MutilsBlob *) NULL)
return(-1);
if (blob->data != (unsigned char *) NULL)
{
if (length > (blob->length - blob->offset))
{
reallocate_bytes=(length - (blob->length - blob->offset));
mutils_info("%s (%d) out of memory, re-allocating %d bytes\n",
MUTILS_CFL,reallocate_bytes);
/* find out how many bytes we need to re-allocate */
blob->length += reallocate_bytes;
mutils_reacquire_memory((void **) &blob->data,blob->length);
if (blob->data == (unsigned char *) NULL)
{
mutils_detach_blob(blob);
return(-1);
}
}
(void) memcpy(blob->data + blob->offset,data,length);
blob->offset += length;
if (blob->offset > (off_t) blob->length)
blob->length=blob->offset;
return(length);
}
return(-1);
}
/*
** write an integer to a blob. It returns the number of bytes written
** and -1 on failure
*/
size_t mutils_write_blob_byte(MutilsBlob *blob,const long value)
{
unsigned char
buffer[1];
if (blob == NULL)
return(-1);
buffer[0]=(unsigned char) value;
return(mutils_write_blob(blob,1,buffer));
}
/*
** writes a long value as a 32 bit quantity in least-significant byte first
** order. returns the number of unsigned longs written. -1 on error
*/
int mutils_write_blob_lsb_long(MutilsBlob *blob,const unsigned long value)
{
unsigned char
buffer[4];
if (blob == NULL)
return(-1);
buffer[0]=(unsigned char) value;
buffer[1]=(unsigned char) (value >> 8);
buffer[2]=(unsigned char) (value >> 16);
buffer[3]=(unsigned char) (value >> 24);
return(mutils_write_blob(blob,4,buffer));
}
/*
** writes a long value as a 16 bit quantity in least-significant byte first
** order. returns the number of unsigned longs written. -1 on failure
*/
int mutils_write_blob_lsb_short(MutilsBlob *blob,const unsigned long value)
{
unsigned char
buffer[2];
if (blob == NULL)
return(-1);
buffer[0]=(unsigned char) value;
buffer[1]=(unsigned char) (value >> 8);
return(mutils_write_blob(blob,2,buffer));
}
/*
** writes a long value as a 32 bit quantity in most-significant byte first
** order. returns the number of unsigned longs written. -1 on failure
*/
int mutils_write_blob_msb_long(MutilsBlob *blob,const unsigned long value)
{
unsigned char
buffer[4];
if (blob == NULL)
return(-1);
buffer[0]=(unsigned char) (value >> 24);
buffer[1]=(unsigned char) (value >> 16);
buffer[2]=(unsigned char) (value >> 8);
buffer[3]=(unsigned char) value;
return(mutils_write_blob(blob,4,buffer));
}
/*
** writes a long value as a 16 bit quantity in most-significant byte first
** order. returns the number of unsigned longs written. -1 on failure
*/
int mutils_write_blob_msb_short(MutilsBlob *blob,const unsigned long value)
{
unsigned char
buffer[2];
if (blob == NULL)
return(-1);
buffer[0]=(unsigned char) (value >> 8);
buffer[1]=(unsigned char) value;
return(mutils_write_blob(blob,2,buffer));
}
/*
** write a string to a blob. It returns the number of characters written
*/
size_t mutils_write_blob_string(MutilsBlob *blob,const char *string)
{
if (string == NULL)
return(0);
if (blob == NULL)
return(0);
return(mutils_write_blob(blob,strlen(string),string));
}
void mutils_hex_dump_blob(FILE *fp,MutilsBlob *blob)
{
if (blob && blob->data)
{
if (blob->length)
mutils_hex_dump(fp,blob->data,blob->length);
}
else
{
(void) fprintf(stderr,"Empty blob\n");
}
}
+232
View File
@@ -0,0 +1,232 @@
#include "mutils.h"
/*
** Allow the caller to register a error printing routine
*/
static int s_mutils_debug=0;
static void mutils_default_proc(char *fmt,va_list args)
{
if (fmt)
{
vfprintf(stderr,fmt,args);
(void) fflush(stderr);
}
}
static void mutils_default_hexdump_proc(unsigned char *bytes,int bytes_len)
{
if (bytes && bytes_len > 0)
{
mutils_hex_dump(stderr,bytes,bytes_len);
}
}
static void mutils_default_hexprint_proc(unsigned char *bytes,
int bytes_len)
{
if (bytes && bytes_len > 0)
{
mutils_hex_print(stderr,bytes,bytes_len);
}
}
/* default error, info and warning printing routine */
static mutils_error_func mutils_error_hook=mutils_default_proc;
static mutils_error_func mutils_info_hook=mutils_default_proc;
static mutils_error_func mutils_debug_hook=mutils_default_proc;
static mutils_error_func mutils_warn_hook=mutils_default_proc;
static mutils_hexdump_func mutils_hexdump_hook=mutils_default_hexdump_proc;
static mutils_hexdump_func mutils_hexprint_hook=mutils_default_hexprint_proc;
static void mutils_error_va(char *fmt,va_list args)
{
(*mutils_error_hook)(fmt,args);
}
static void mutils_info_va(char *fmt,va_list args)
{
(*mutils_info_hook)(fmt,args);
}
static void mutils_debug_va(char *fmt,va_list args)
{
(*mutils_debug_hook)(fmt,args);
}
static void mutils_warn_va(char *fmt,va_list args)
{
(*mutils_warn_hook)(fmt,args);
}
void mutils_hexdump(unsigned char *bytes,int bytes_len)
{
(*mutils_hexdump_hook)(bytes,bytes_len);
}
void mutils_hexprint(unsigned char *bytes,int bytes_len)
{
(*mutils_hexprint_hook)(bytes,bytes_len);
}
/**
* @brief Turn debug on or off
* @param d If 1, turn debug 1, if 0 turn debug off
*/
void mutils_set_debug(int d)
{
if (d == 1)
{
s_mutils_debug=1;
}
else if (d == 0)
{
s_mutils_debug=0;
}
}
/**
* @brief Set application defined function for printing error messages
*/
void mutils_set_error_hook(mutils_error_func new_func)
{
if (new_func)
{
mutils_error_hook=new_func;
}
else
{
mutils_error_hook=mutils_default_proc;
}
}
/**
* @brief Set application defined function for printing info messages
*/
void mutils_set_info_hook(mutils_error_func new_func)
{
if (new_func)
{
mutils_info_hook=new_func;
}
else
{
mutils_info_hook=mutils_default_proc;
}
}
void mutils_set_debug_hook(mutils_error_func new_func)
{
if (new_func)
{
mutils_debug_hook=new_func;
}
else
{
mutils_debug_hook=mutils_default_proc;
}
}
/**
* @brief Set application defined function for printing warning messages
*/
void mutils_set_warn_hook(mutils_error_func new_func)
{
if (new_func)
{
mutils_warn_hook=new_func;
}
else
{
mutils_warn_hook=mutils_default_proc;
}
}
void mutils_set_hexdump_hook(mutils_hexdump_func new_func)
{
if (new_func)
{
mutils_hexdump_hook=new_func;
}
else
{
mutils_hexdump_hook=mutils_default_hexdump_proc;
}
}
void mutils_set_hexprint_hook(mutils_hexdump_func new_func)
{
if (new_func)
{
mutils_hexprint_hook=new_func;
}
else
{
mutils_hexprint_hook=mutils_default_hexprint_proc;
}
}
void mutils_reset_error_hook(void)
{
mutils_set_error_hook(NULL);
}
void mutils_reset_info_hook(void)
{
mutils_set_info_hook(NULL);
}
void mutils_reset_warn_hook(void)
{
mutils_set_warn_hook(NULL);
}
/**
@brief print error message
@param fmt The formatted parameters
This function prints eror message to standard error if no application
error printing is not hooked by calling mutils_set_error_hook()
*/
void mutils_error(char *fmt,...)
{
va_list
ap;
va_start(ap,fmt);
mutils_error_va(fmt,ap);
va_end(ap);
}
void mutils_info(char *fmt,...)
{
va_list
ap;
va_start(ap,fmt);
mutils_info_va(fmt,ap);
va_end(ap);
}
void mutils_warn(char *fmt,...)
{
va_list
ap;
va_start(ap,fmt);
mutils_warn_va(fmt,ap);
va_end(ap);
}
void mutils_debug(char *fmt,...)
{
va_list
ap;
va_start(ap,fmt);
mutils_debug_va(fmt,ap);
va_end(ap);
}
+119
View File
@@ -0,0 +1,119 @@
#include "mutils.h"
static char base64_chars[64] =
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '+', '/'
};
/*
** generateBoundary()
** generate unuque string for boundary for MIME tag
**
** Parameters:
** char *boundary - NULL terminated boundary string - returns
** int len - size of boundary (malloc'd or static)
**
** Return Values:
** none
**
** Limitations and Comments:
** boundary must have len bytes in it to store the boundary. the
functio
n
** calls rand() for random number, so the caller should call srand()
** before calling this function.
**
** This function is adapted from mutt code.
**
** Development History:
** who when why
** muquit@muquit.com Mar-06-2002 needs MIME support
*/
#define BOUNDARY_LEN 16
void mutilsGenerateMIMEBoundary(char *boundary,int len)
{
char
*p;
int
i;
memset(boundary,0,len);
p=boundary;
for (i=0; i < BOUNDARY_LEN; i++)
{
if (i >= (len-1))
break;
*p++ = base64_chars[rand() % sizeof(base64_chars)];
}
*p='\0';
}
static void output64Chunk(int c1,int c2,int c3,int pads, FILE *outfile)
{
putc(base64_chars[c1>>2], outfile);
putc(base64_chars[((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)], outfile);
if (pads == 2)
{
putc('=', outfile);
putc('=', outfile);
}
else if (pads)
{
putc(base64_chars[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)], outfile);
putc('=', outfile);
}
else
{
putc(base64_chars[((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)], outfile);
putc(base64_chars[c3 & 0x3F], outfile);
}
}
void mutilsBase64Encode(FILE *ifp,FILE *ofp)
{
int
c1,
c2,
c3,
ct=0;
while ((c1=getc(ifp)) != EOF)
{
c2=getc(ifp);
if (c2 == EOF)
{
output64Chunk(c1,0,0,2,ofp);
}
else
{
c3=getc(ifp);
if (c3 == EOF)
{
output64Chunk(c1,c2,0,1,ofp);
}
else
{
output64Chunk(c1,c2,c3,0,ofp);
}
}
ct += 4;
if (ct > 71)
{
putc('\r',ofp); /* qmail fix 15.07.05 (movi) */
putc('\n',ofp);
ct=0;
}
}
if (ct)
{
putc('\r',ofp); /* qmail fix 15.07.05 (movi) */
putc('\n',ofp);
}
(void) fflush(ofp);
}
@@ -0,0 +1,205 @@
#include "mutils.h"
#include <errno.h>
/*
** return the path of current working directory
*/
char *mutils_getcwd(char *buf,int buflen)
{
if (getcwd(buf,buflen - 1) != NULL)
{
return(buf);
}
return(NULL);
}
/*
** tmpdir - path of temp directory
** tempfile_path - returns. path of temp filename
** buflen - length of tempfile_path buffer, preallocated
**
** returns: open FILE pointer to temp file
*/
static FILE *open_tempfile(const char *tempdir,char *tempfile_path,int buflen)
{
FILE
*fp = NULL;
int
rc,
tfwd,
len = strlen(tempdir);
if (len && len < MUTILS_PATH_MAX)
{
(void) snprintf(tempfile_path,buflen - 1,"%s/%s",tempdir,"mailsendXXXXXX");
#ifdef HAVE_MKSTEMP
tfwd = mkstemp(tempfile_path);
if (tfwd == -1)
{
mutils_error("%s (%d) - Could not open tmp file %s for writing: %s\n",
MUTILS_CFL,
tempfile_path,
strerror(errno));
return(0);
}
fp = fdopen(tfwd,"w");
if (fp == NULL)
{
mutils_error("%s (%d) - Could not open temp file %s\n",
MUTILS_CFL,
tempfile_path);
return(NULL);
}
return(fp);
#else
#ifdef WINNT
rc = _mktemp_s(tempfile_path, buflen);
if (rc != 0)
{
mutils_error("%s (%d) - Could not create file %s\n",
MUTILS_CFL,
tempfile_path);
return(NULL);
}
fp = fopen(tempfile_path,"w");
if (fp == NULL)
{
mutils_error("%s (%d) - Could not open temp file %s\n",
MUTILS_CFL,
tempfile_path);
return(NULL);
}
#else
mktemp(tempfile_path);
fp = fopen(tempfile_path,"w");
if (fp == NULL)
{
mutils_error("%s (%d) - Could not open temp file %s\n",
MUTILS_CFL,
tempfile_path);
return(NULL);
}
#endif /* WINNT */
#endif /* HAVE_MKSTEMP */
}
return(fp);
}
/*
** Return FILE pointer to a open temp file.
** Parameters:
** tempfile_path - returns. The buffer to hold the temp file path
** buflen - Length of tempfile_path
** Returns:
** FILE pointer to tempfile on success, NULL on failure
**
** The caller is responsible to close the FILE pointer and remove the file
**
** Note: adapted from apache apr lib
*/
FILE *mutils_get_tempfileFP(char *tempfile_path,int buflen)
{
char
tmpbuf[MUTILS_PATH_MAX];
int
tfwd;
FILE
*fp = NULL;
char
*dir = NULL;
const char *try_envs[] =
{
"TMP",
"TEMP",
"TMPDIR",
};
const char *try_dirs[] =
{
"/tmp",
"/usr/tmp",
"/var/tmp",
};
char
*tempdir;
int
i;
/* first look for the env vars */
for (i = 0; i < (sizeof(try_envs) / sizeof(const char *)); i++)
{
tempdir = getenv(try_envs[i]);
if (tempdir != NULL)
{
int
len = strlen(tempdir);
fp = open_tempfile(tempdir,tempfile_path,buflen);
if (fp != NULL)
goto ExitProcessing;
}
}
/* we could not find the env vars for temp dir */
/* try c:/TMP for windows */
#ifdef WINNT
fp = open_tempfile("c:/TEMP",tempfile_path, buflen);
if (fp != NULL)
goto ExitProcessing;
#endif /* WINNT */
/* Next try some hard coded path */
for (i = 0; i < (sizeof(try_dirs) / sizeof(const char *)); i++)
{
fp = open_tempfile(try_dirs[i], tempfile_path, buflen);
if (fp != NULL)
goto ExitProcessing;
}
/* Finally, try the current working directory */
tempdir = mutils_getcwd(tmpbuf,sizeof(tmpbuf)-1);
if (tempdir != NULL)
{
fp = open_tempfile(tempdir, tempfile_path, buflen);
if (fp != NULL)
goto ExitProcessing;
}
ExitProcessing:
return(fp);
}
#ifdef TESTING
int main(int argc,char *argv[])
{
char
*pwd,
tempfile[MUTILS_PATH_MAX];
FILE
*fp;
fp = mutils_get_tempfileFP(tempfile, MUTILS_PATH_MAX);
if (fp)
{
(void) fprintf(stderr,"%s\n",tempfile);
(void) fclose(fp);
unlink(tempfile);
}
pwd = mutils_getcwd(tempfile,sizeof(tempfile));
if (pwd)
(void) fprintf(stderr,"pwd=%s\n",pwd);
return(0);
}
#endif
+101
View File
@@ -0,0 +1,101 @@
/**
@file mutils_time.c
@author Muhamad A Muquit
@date $Date:$
@version $Revision:$
@brief Platform independ wrapper routines for time
*/
#include "mutils.h"
/* returns 0 on success, -1 on failure */
int mutils_time_now(MutilsTime *mt)
{
int
rc=(-1);
#ifdef WINNT
#else
struct timeval
tv;
#endif /* WINNT */
#ifdef WINNT
GetSystemTimeAsFileTime(&mt->absolute);
#else
rc=gettimeofday(&tv,NULL);
if (rc == -1)
{
mutils_error("gettimeofday() failed");
return(-1);
}
mt->secs=tv.tv_sec;
mt->nsecs=tv.tv_usec * 1000;
#endif /* WINNT */
return(0);
}
/* buf must be at least 64 bytes allocated and bufsiz must reflect that */
/* adapted from ISC time.c */
void mutils_time_fmt(MutilsTime *mt,char *buf,int bufsiz)
{
time_t
now;
int
rc;
#ifdef WINNT
FILETIME
localft;
SYSTEMTIME
st;
char
DateBuf[50],
TimeBuf[50];
static const char
badtime[] = "99-Bad-9999 99:99:99.999";
#endif /* WINNT */
if (bufsiz < 64)
return;
#ifdef WINNT
if (FileTimeToLocalFileTime(&mt->absolute, &localft) &&
FileTimeToSystemTime(&localft, &st))
{
GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, "dd-MMM-yyyy",
DateBuf, 50);
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOTIMEMARKER|
TIME_FORCE24HOURFORMAT, &st, NULL, TimeBuf, 50);
snprintf(buf, bufsiz, "%s %s.%03u", DateBuf, TimeBuf,
st.wMilliseconds);
}
else
snprintf(buf, bufsiz, badtime);
#else
now=(time_t) mt->secs;
rc=strftime(buf,bufsiz,"%d-%b-%Y %X",localtime(&now));
if (rc != 0)
(void) snprintf(buf+rc,bufsiz - rc,".%03u",mt->nsecs / 1000000);
else
(void) snprintf(buf+rc,bufsiz - 1,"99-Bad-9999 99:99:99.999"); /* from isc */
#endif /* WINNT */
}
#ifdef TEST_TIME
int main(int argc,char *argv[])
{
char
buf[65];
MutilsTime
mt;
mutils_time_now(&mt);
mutils_time_fmt(&mt,MUTILS_TRUE,buf,sizeof(buf));
(void) fprintf(stderr,"%s\n",buf);
}
#endif /* TEST_TIME */
+2 -2
View File
@@ -348,7 +348,7 @@ void mutilsSafeStrcat(char *dst,char *src,int length,int ssc_size,
exit(0);
}
if (strlen(src) >= ssc_size - ssc_length)
if ((int) strlen(src) >= ssc_size - ssc_length)
{
/*
StringImage("buffer overflow detected! aborting");
@@ -506,5 +506,5 @@ char *mutilsStrLower(char *str)
*s=tolower(*s);
}
return (s);
return (str);
}
View File
View File
+2 -2
View File
@@ -4,12 +4,12 @@
# Aug-07-1998
#
CC= gcc
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_MALLOC_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CTYPE_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_FLOCK=1 -DHAVE_SOCKET=1 -DHAVE_HTONL=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETHOSTBYADDR=1 -DHAVE_YP_GET_DEFAULT_DOMAIN=1 -DHAVE_LIBNSL=1 -DHAVE_RES_SEARCH=1 -DHAVE_LIBRESOLV=1 -DHAVE_INET_ATON=1 -DHAVE_DN_SKIPNAME=1 -DHAVE_MKSTEMP=1 -DHAVE_OPENSSL=1
DEFS= -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING_H=1 -DHAVE_STRINGS_H=1 -DHAVE_MEMORY_H=1 -DHAVE_MALLOC_H=1 -DHAVE_UNISTD_H=1 -DHAVE_CTYPE_H=1 -DHAVE_STDINT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_STDLIB_H=1 -DHAVE_FCNTL_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_LIMITS_H=1 -DHAVE_FLOCK=1 -DHAVE_SOCKET=1 -DHAVE_HTONL=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETHOSTBYADDR=1 -DHAVE_RES_SEARCH=1 -DHAVE_LIBRESOLV=1 -DHAVE_INET_ATON=1 -DHAVE_DN_SKIPNAME=1 -DHAVE_MKSTEMP=1 -DHAVE_GETADDRINFO=1
AR= ar cq
RANLIB= ranlib
LIBNAME= libsll.a
INCLUDES= -I. -I/usr/include/malloc
INCLUDES= -I.
# replace -O with -g in order to debug
+43
View File
@@ -0,0 +1,43 @@
#
# for Singly linked list package.
# muhammad a muquit
# Aug-07-1998
#
CC= @CC@
DEFS= @DEFS@
AR= ar cq
RANLIB= @RANLIB@
LIBNAME= libsll.a
INCLUDES= -I.
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
SRCS = sll.c
OBJS = sll.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: $(LIBNAME)
$(LIBNAME): $(OBJS)
rm -f $@
$(AR) $@ $(OBJS)
$(RANLIB) $@
sll.o: sll.h
clean:
rm -f $(OBJS) $(LIBNAME) core a.out
realclean:
rm -f $(OBJS) $(LIBNAME) core a.out config.cache config.log config.status
(cd examples/append;make clean)
(cd examples/append_sorted;make clean)
(cd examples/delete;make clean)
(cd examples/insert;make clean)
+27
View File
@@ -0,0 +1,27 @@
#--------------------------------------------
# Makefile for MS Visual C++
# muquit@muquit.com
#--------------------------------------------
DEFS= -DWINNT=1 -DSTRICT_MODE=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1
CFLAGS= /DWINNT /DWIN32 /DHAVE_MALLOC_H /I.
CFLAGS=$(CFLAGS) /Ox /W3 /wd4996 /nologo
LIBFLAGS=/nologo
LIBRARY=sll.lib
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS)
#CFLAGS= $(cvars) $(cdebug) -nologo -G4 $(DEFINES)
SRCS = sll.c
OBJS = sll.obj
all: $(LIBRARY)
$(LIBRARY): $(OBJS)
lib $(LIBFLAGS) $(OBJS) /out:$(LIBRARY)
clean:
del $(OBJS) $(LIBRARY) *.bak
+9
View File
@@ -0,0 +1,9 @@
A Singly Linked List library. You'll need a ANSI C compiler in order to
compile.
Please visit the URL: http://www.fccc.edu/users/muquit/libsll/libsll.html
for reference.
--
Muhammad A Muquit
Aug-09-1998.
+2
View File
@@ -0,0 +1,2 @@
#The current version of ssl lib is 1.1
SLL_VERSION=sll
+1722
View File
File diff suppressed because it is too large Load Diff
+40
View File
@@ -0,0 +1,40 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(sll.h)
dnl AC_CONFIG_HEADER(config.h)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_MAKE_SET
dnl Checks for libraries.
dnl Checks for header files.
dnl AC_HEADER_STDC
AC_STDC_HEADERS
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_CHECK_HEADERS(string.h fcntl.h memory.h malloc.h unistd.h ctype.h)
AC_CHECK_HEADERS(strings.h)
AC_CHECK_HEADERS(sys/stat.h sys/param.h sys/file.h stdlib.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_STRUCT_TM
AC_CHECK_FUNC(flock,AC_DEFINE(HAVE_FLOCK))
AC_CHECK_FUNC(strcasecmp,AC_DEFINE(HAVE_STRCASECMP))
AC_CHECK_FUNC(mktime,AC_DEFINE(HAVE_MKTIME))
AC_CHECK_FUNC(ftruncate,AC_DEFINE(HAVE_FTRUNCATE))
dnl from vile configure.in, I love vile, a great editor
AC_MSG_CHECKING([for SCO])
AC_PROGRAM_CHECK(COULD_BE_SCO, [scosh], maybe, maybenot)
if test "$COULD_BE_SCO" = "maybe"
then
AC_DEFINE(SYSTEM_LOOKS_LIKE_SCO)
fi
dnl Checks for library functions.
AC_OUTPUT(Makefile examples/insert/Makefile examples/append/Makefile\
examples/delete/Makefile examples/append_sorted/Makefile)
@@ -0,0 +1,31 @@
##
# Makefile automatically generated by genmake 1.0, Nov-12-98
# genmake 1.0 by ma_muquit@fccc.edu, RCS
##
CC= @CC@
DEFS= @DEFS@
PROGNAME= sll_append
INCLUDES= -I../..
LIBS= -L../../ -lsll
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
SRCS = append.c
OBJS = append.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
clean:
rm -f $(OBJS) $(PROGNAME) core
+187
View File
@@ -0,0 +1,187 @@
/*
** test appending a node at the end of the list. print the result
** and then free the memory. a user defined function is called to free
** the data.
**
** Development History:
** who when why
** ma_muquit@fccc.edu Aug-09-1998 first cut
*/
#include <sll.h>
typedef struct _addr
{
char
*name,
*city,
*state;
} Addr;
static void freeData(void **data);
int main (int argc,char **argv)
{
Sll
*l,
*head=NULL,
*new=NULL;
Addr
*addr;
int
n=0;
(void) fprintf(stderr,
"=========================================================================\n");
(void) fprintf(stderr," Testing Append a node at the beginning of a list\n");
(void) fprintf(stderr,
"=========================================================================\n");
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
(void) fprintf(stderr,"\n---------------[ appending ]----------\n");
/*
** it will be the last node
*/
addr->name=strdup("Muhammad A Muquit");
addr->city=strdup("Philadelphia");
addr->state=strdup("PA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNode(&head,&new);
(void) fprintf(stderr,"Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** append node after the last one
*/
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
addr->name=strdup("Janet Hunter");
addr->city=strdup("Santa Clara");
addr->state=strdup("CA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNode(&head,&new);
(void) fprintf(stderr,"Appending Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** append node after the last one
*/
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
addr->name=strdup("Babs Jensen");
addr->city=strdup("Cupertino");
addr->state=strdup("CA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNode(&head,&new);
(void) fprintf(stderr,"Appending Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** print
*/
(void) fprintf(stderr,"\n---------------[ printing ]----------\n");
n=0;
for (l=head; l; l=l->next)
{
addr=(Addr *) l->data;
(void) fprintf(stderr,"Node: %d\n",++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
}
/*
** free nodes
*/
(void) fprintf(stderr,"\n---------------[ freeing ]----------\n");
destroyNodes(&head,freeData);
exit(0);
}
/*
** routine to free the user data
*/
static void freeData(void **data)
{
Addr
**addr=(Addr **) data;
static int
n=0;
n++;
if (*addr)
{
if ((*addr)->name)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->name);
(void) free((char *) (*addr)->name);
}
if ((*addr)->city)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->city);
(void) free ((char *) (*addr)->city);
}
if ((*addr)->state)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->state);
(void) free ((char *) (*addr)->state);
}
(void) fprintf(stderr,"Freeing the node %d itself\n\n",n);
(void) free((char *) (*addr));
(*addr)=NULL;
}
}
@@ -0,0 +1,34 @@
##
# Makefile automatically generated by genmake 1.0, Mar-27-2001
# genmake 1.0 by muquit@muquit.com http://www.muquit.com/
##
CC= cl
DEFS= -nologo -G3
PROGNAME= append
LINKER=link -nologo
INCLUDES= -I. -I../../
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DWINNT=1 -DSYS_WIN32=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1
CFLAGS= -O $(DEFINES)
SLL_LIB=../../sll.lib
LIBS=$(SLL_LIB) user32.lib gdi32.lib winmm.lib comdlg32.lib comctl32.lib
RC=rc
RCVARS=-r -DWIN32
SRCS = append.c
OBJS = append.obj
.c.obj:
$(CC) $(CFLAGS) -c $< -Fo$@
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
clean:
del $(OBJS) $(PROGNAME)
@@ -0,0 +1,31 @@
##
# Makefile automatically generated by genmake 1.0, Nov-12-98
# genmake 1.0 by ma_muquit@fccc.edu, RCS
##
CC= @CC@
DEFS= @DEFS@
PROGNAME= sll_append_sorted
INCLUDES= -I../..
LIBS= -L../../ -lsll
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
SRCS = append_sorted.c
OBJS = append_sorted.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
clean:
rm -f $(OBJS) $(PROGNAME) core
@@ -0,0 +1,204 @@
/*
** Appends a node to the end of a list sorted. The data of two lists are
** passed to the user defined function compFunction for sorting.
**
** Development History:
** who when why
** ma_muquit@fccc.edu Aug-09-1998 first cut
*/
#include <sll.h>
typedef struct _addr
{
char
*name,
*city,
*state;
} Addr;
static void freeData(void **data);
static int compFunc(void *a1,void *a2);
int main (int argc,char **argv)
{
Sll
*l,
*head=NULL,
*new=NULL;
Addr
*addr;
int
n=0;
(void) fprintf(stderr,
"=========================================================================\n");
(void) fprintf(stderr," Testing Append a node at the beginning of a list\n");
(void) fprintf(stderr,
"=========================================================================\n");
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
(void) fprintf(stderr,"\n---------------[ appending ]----------\n");
/*
** it will be the last node
*/
addr->name=strdup("Cindy Muquit");
addr->city=strdup("Philadelphia");
addr->state=strdup("PA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNodeSorted(&head,&new,compFunc);
(void) fprintf(stderr,"Appending Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** append node before the last one
*/
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
addr->name=strdup("Janet Hunter");
addr->city=strdup("Santa Clara");
addr->state=strdup("CA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNodeSorted(&head,&new,compFunc);
(void) fprintf(stderr,"Appending Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** append node before the last one
*/
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
addr->name=strdup("Babs Jensen");
addr->city=strdup("Cupertino");
addr->state=strdup("CA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNodeSorted(&head,&new,compFunc);
(void) fprintf(stderr,"Appending Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** print
*/
(void) fprintf(stderr,"\n---------------[ printing ]----------\n");
n=0;
for (l=head; l; l=l->next)
{
addr=(Addr *) l->data;
(void) fprintf(stderr,"Node: %d\n",++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
}
/*
** free nodes
*/
(void) fprintf(stderr,"\n---------------[ freeing ]----------\n");
destroyNodes(&head,freeData);
exit(0);
}
/*
** routine to free the user data
*/
static void freeData(void **data)
{
Addr
**addr=(Addr **) data;
static int
n=0;
n++;
if (*addr)
{
if ((*addr)->name)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->name);
(void) free((char *) (*addr)->name);
}
if ((*addr)->city)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->city);
(void) free ((char *) (*addr)->city);
}
if ((*addr)->state)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->state);
(void) free ((char *) (*addr)->state);
}
(void) fprintf(stderr,"Freeing the node %d itself\n\n",n);
(void) free((char *) (*addr));
(*addr)=NULL;
}
}
static int compFunc(void *a1,void *a2)
{
Addr
*addr1=(Addr *) a1,
*addr2=(Addr *) a2;
/*
(void) fprintf(stderr,"name1=%s\n",addr1->name);
(void) fprintf(stderr,"name2=%s\n",addr2->name);
*/
#ifdef WINNT
return (stricmp(addr1->name,addr2->name));
#else
return (strcasecmp(addr1->name,addr2->name));
#endif /* ! WINNT */
}
@@ -0,0 +1,34 @@
##
# Makefile automatically generated by genmake 1.0, Mar-27-2001
# genmake 1.0 by muquit@muquit.com http://www.muquit.com/
##
CC= cl
DEFS= -nologo -G3
PROGNAME= apend_sorted
LINKER=link -nologo
INCLUDES= -I. -I../../
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DWINNT=1 -DSYS_WIN32=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1
CFLAGS= -O $(DEFINES)
SLL_LIB=../../sll.lib
LIBS=$(SLL_LIB) user32.lib gdi32.lib winmm.lib comdlg32.lib comctl32.lib
RC=rc
RCVARS=-r -DWIN32
SRCS = append_sorted.c
OBJS = append_sorted.obj
.c.obj:
$(CC) $(CFLAGS) -c $< -Fo$@
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
clean:
del $(OBJS) $(PROGNAME)
@@ -0,0 +1,31 @@
##
# Makefile automatically generated by genmake 1.0, Nov-12-98
# genmake 1.0 by ma_muquit@fccc.edu, RCS
##
CC= @CC@
DEFS= @DEFS@
PROGNAME= sll_delete
INCLUDES= -I../..
LIBS= -L../../ -lsll
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
SRCS = delete.c
OBJS = delete.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
clean:
rm -f $(OBJS) $(PROGNAME) core
+200
View File
@@ -0,0 +1,200 @@
/*
** first append a node at the end of a list. then dele a node and free the
** memory associated with data.
**
** Development History:
** who when why
** ma_muquit@fccc.edu Aug-09-1998 first cut
*/
#include <sll.h>
typedef struct _addr
{
char
*name,
*city,
*state;
} Addr;
static void freeData(void **data);
int main (int argc,char **argv)
{
Sll
*node,
*l,
*head=NULL,
*new=NULL;
Addr
*addr;
int
n=0;
(void) fprintf(stderr,
"=========================================================================\n");
(void) fprintf(stderr," Append a node at the beginning of a list\n");
(void) fprintf(stderr,
"=========================================================================\n");
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
(void) fprintf(stderr,"\n---------------[ appending ]----------\n");
/*
** it will be the last node
*/
addr->name=strdup("Muhammad A Muquit");
addr->city=strdup("Philadelphia");
addr->state=strdup("PA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNode(&head,&new);
(void) fprintf(stderr,"Appending Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** append node before the last one
*/
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
addr->name=strdup("Janet Hunter");
addr->city=strdup("Santa Clara");
addr->state=strdup("CA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNode(&head,&new);
(void) fprintf(stderr,"Appending Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** append node before the last one
*/
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
addr->name=strdup("Babs Jensen");
addr->city=strdup("Cupertino");
addr->state=strdup("CA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
appendNode(&head,&new);
(void) fprintf(stderr,"Appending Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** print
*/
(void) fprintf(stderr,"\n---------------[ printing ]----------\n");
n=0;
for (l=head; l; l=l->next)
{
addr=(Addr *) l->data;
(void) fprintf(stderr,"Node: %d\n",++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
}
(void) fprintf(stderr,"\n-----------[ delete Node 2 ]---------\n");
node=getNthNode(head,2);
if (node != NULL)
destroyNode(&head,node,freeData);
else
(void) fprintf(stderr,"No node found at position 2\n");
(void) fprintf(stderr,"\n-----------[ printing all the nodes again ]--------\n");
n=0;
for (l=head; l; l=l->next)
{
addr=(Addr *) l->data;
(void) fprintf(stderr,"Node: %d\n",++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
}
/*
** free nodes
*/
(void) fprintf(stderr,"\n---------------[ freeing ]----------\n");
destroyNodes(&head,freeData);
exit(0);
}
/*
** routine to free the user data
*/
static void freeData(void **data)
{
Addr
**addr=(Addr **) data;
if (*addr)
{
if ((*addr)->name)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->name);
(void) free((char *) (*addr)->name);
}
if ((*addr)->city)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->city);
(void) free ((char *) (*addr)->city);
}
if ((*addr)->state)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->state);
(void) free ((char *) (*addr)->state);
}
(void) fprintf(stderr,"Freeing the node itself\n\n");
(void) free((char *) (*addr));
(*addr)=NULL;
}
}
@@ -0,0 +1,34 @@
##
# Makefile automatically generated by genmake 1.0, Mar-27-2001
# genmake 1.0 by muquit@muquit.com http://www.muquit.com/
##
CC= cl
DEFS= -nologo -G3
PROGNAME= delete
LINKER=link -nologo
INCLUDES= -I. -I../../
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DWINNT=1 -DSYS_WIN32=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1
CFLAGS= -O $(DEFINES)
SLL_LIB=../../sll.lib
LIBS=$(SLL_LIB) user32.lib gdi32.lib winmm.lib comdlg32.lib comctl32.lib
RC=rc
RCVARS=-r -DWIN32
SRCS = delete.c
OBJS = delete.obj
.c.obj:
$(CC) $(CFLAGS) -c $< -Fo$@
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
clean:
del $(OBJS) $(PROGNAME)
@@ -0,0 +1,31 @@
##
# Makefile automatically generated by genmake 1.0, Nov-12-98
# genmake 1.0 by ma_muquit@fccc.edu, RCS
##
CC= @CC@
DEFS= @DEFS@
PROGNAME= sll_insert
INCLUDES= -I../..
LIBS= -L../../ -lsll
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DSYS_UNIX=1
CFLAGS= -O $(DEFINES)
SRCS = insert.c
OBJS = insert.o
.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
clean:
rm -f $(OBJS) $(PROGNAME) core
+186
View File
@@ -0,0 +1,186 @@
/*
** test inserting a node at the beginning of the list. print the result
** and then free the memory. a user defined function is called to free
** the data.
**
** Development History:
** who when why
** ma_muquit@fccc.edu Aug-09-1998 first cut
*/
#include <sll.h>
#include <string.h>
typedef struct _addr
{
char
*name,
*city,
*state;
} Addr;
static void freeData(void **data);
int main (int argc,char **argv)
{
Sll
*l,
*head=NULL,
*new=NULL;
Addr
*addr;
int
n=0;
(void) fprintf(stderr,
"=========================================================================\n");
(void) fprintf(stderr," Testing Insert a node at the beginning of a list\n");
(void) fprintf(stderr,
"=========================================================================\n");
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
/*
** it will be the last node
*/
addr->name=strdup("Muhammad A Muquit");
addr->city=strdup("Philadelphia");
addr->state=strdup("PA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
insertNode(&head,&new);
(void) fprintf(stderr,"Inserting Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** insert node before the last one
*/
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
addr->name=strdup("Janet Hunter");
addr->city=strdup("Santa Clara");
addr->state=strdup("CA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
insertNode(&head,&new);
(void) fprintf(stderr,"Inserting Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** insert node before the last one
*/
addr=(Addr *) malloc(sizeof(Addr));
if (addr == NULL)
{
(void) fprintf(stderr," malloc failed\n");
exit(-1);
}
addr->name=strdup("Babs Jensen");
addr->city=strdup("Cupertino");
addr->state=strdup("CA");
if ((addr->name == NULL) ||
(addr->city == NULL) ||
(addr->state == NULL))
{
(void) fprintf(stderr,"malloc failed\n");
exit(-1);
}
new=allocateNode((void *) addr);
insertNode(&head,&new);
(void) fprintf(stderr,"Inserting Node: %d\n", ++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n",addr->state);
/*
** print
*/
(void) fprintf(stderr,"\n\nPrinting........\n");
n=0;
for (l=head; l; l=l->next)
{
addr=(Addr *) l->data;
(void) fprintf(stderr,"Node: %d\n",++n);
(void) fprintf(stderr," %s\n",addr->name);
(void) fprintf(stderr," %s\n",addr->city);
(void) fprintf(stderr," %s\n\n",addr->state);
}
/*
** free nodes
*/
destroyNodes(&head,freeData);
exit(0);
}
/*
** routine to free the user data
*/
static void freeData(void **data)
{
Addr
**addr=(Addr **) data;
static int
n=0;
n++;
if (*addr)
{
if ((*addr)->name)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->name);
(void) free((char *) (*addr)->name);
}
if ((*addr)->city)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->city);
(void) free ((char *) (*addr)->city);
}
if ((*addr)->state)
{
(void) fprintf(stderr," Freeing: %s\n",(*addr)->state);
(void) free ((char *) (*addr)->state);
}
(void) fprintf(stderr,"Freeing the node %d itself\n\n",n);
(void) free((char *) (*addr));
(*addr)=NULL;
}
}
@@ -0,0 +1,35 @@
##
# Makefile automatically generated by genmake 1.0, Mar-27-2001
# genmake 1.0 by muquit@muquit.com http://www.muquit.com/
##
CC= cl
DEFS= -nologo -G3
PROGNAME= insert
LINKER=link -nologo
INCLUDES= -I. -I../../
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS) -DWINNT=1 -DSYS_WIN32=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1
CFLAGS= -O $(DEFINES)
SLL_LIB= ../../sll.lib
LIBS=$(SLL_LIB) user32.lib gdi32.lib winmm.lib comdlg32.lib comctl32.lib
RC=rc
RCVARS=-r -DWIN32
SRCS = insert.c
OBJS = insert.obj
.c.obj:
$(CC) $(CFLAGS) -c $< -Fo$@
all: $(PROGNAME)
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
clean:
del $(OBJS) $(PROGNAME)
+79
View File
@@ -0,0 +1,79 @@
function description of singly linked list library
Data structure
--------------
typedef struct _Sll
{
void
*data; /* void pointer for user data */
struct _Sll
*next; /* pointer to next node */
} Sll;
Functions description
=====================
void initList (Sll **list);
Initializes *list by setting the list pointer to NULL.
Sll *allocateNode (void *data);
Allocates space for a new node and initializes the data fields. The user
is responsible for passing a valid pointer to data. The pointer to data
can be anything. If a large amount data needs to used, put all the data
in a structure and send pointer to a structure.
void appendNode(Sll **head,Sll **new)
Appends a node to the end of a list. list gets modified and new is the
node to be appended.
void appendNodeSorted(Sll **head,Sll **new,Ifunc compFunc);
Appends a node to the end of a list sorted. The data of two lists are
passwd to the user defined function compFunction for sorting. The function
returns an integer 0 or > 0.
void insertNode(Sll **head,Sll **new)
Insert a node at the beginning of a list. Insert node new at the beginning
of list "list". Note, the list "list" gets modified.
Bool emptyList(Sll *list)
Checks if a list is empty.
void delNode(Sll **head,Sll *node)
Deletes a node from the list. "lsit" is the list to modify and node is the
node to remove.
void freeNode(Sll **list)
Frees a node. It does not do free the data. It checks before freeing if
the list is NULL or not. If not NULL, it will be freed. Therefore, list
must point to a valid location in memory.
Sll *getNthNode(Sll *head,int n)
Returns the nth node in a list. Node starts at 1. If there is no such
node, NULL is returned.
void destroyNode(Sll **head,Sll *node,void (*freeFunc)(void **))
head -- the entire list, gets modifed
node -- the node to destroy
freeFunc -- the function to call to free the data.
Frees memory allocated for a node and the data associated with the
node. The caller is responsible to write the function to free the memory
for the data.
void destroyNodes(Sll **head,void (*freeFunc)(void **))
head -- the head node of the list
freeFunc - function to free data
Fress the entire list and the data. The caller is responsible to write the
function to free data and pass it in the function.
int numNodes(Sll **head)
Returns number of nodes in the list.
--
Muhammad A Muquit
Aug-09-1998
Saturday
+30
View File
@@ -0,0 +1,30 @@
#--------------------------------------------
# Makefile for MS Visual C++
# muquit@muquit.com
#--------------------------------------------
CC= cl /MD
DEFS= -DWINNT=1 -DSTRICT_MODE=1 -DHAVE_STRING_H=1 -DHAVE_FCNTL_H=1
INCLUDES= -I.
LIBRARY=sll.lib
# replace -O with -g in order to debug
DEFINES= $(INCLUDES) $(DEFS)
#CFLAGS= $(cvars) $(cdebug) -nologo -G4 $(DEFINES)
SRCS = sll.c
OBJS = sll.obj
.c.obj:
$(CC) $(CFLAGS) -c $< -Fo$@
all: $(LIBRARY)
$(LIBRARY): $(OBJS)
link /lib /OUT:$(LIBRARY) $(OBJS)
clean:
del $(OBJS) $(LIBRARY) *.bak
+46
View File
@@ -0,0 +1,46 @@
#!/bin/sh
#
# create a gzip compressed tar archive of the current working directory.
# the name of the file will be dir.tar.gz
#
. ./VERSION
pwd=`pwd`
pwd_head=`basename $pwd`
#
# first check if we'r at the corrent directory
#
if [ $pwd_head != $SLL_VERSION ]; then
echo "You are in wrong base directory"
echo "Expected: $SLL_VERSION"
echo "Found: $pwd_head"
echo "exiting ..."
exit 1
fi
tar_filename=$pwd_head.tar
#
# remove the tar file if any in the current working directoyr
#
if [ -f ./$tar_filename.gz ]; then
echo "removing $tar_filename.gz"
rm -f ./$tar_filename.gz
fi
make clean > /dev/null 2>&1
#
# go up
#
cd ..
tar -cf /tmp/$tar_filename ./$pwd_head
if [ $? -eq 0 ]; then
gzip -f -v -9 /tmp/$tar_filename
mv /tmp/$tar_filename.gz ./$pwd_head
cd $pwd
ls -l $tar_filename.gz
fi
+27
View File
@@ -0,0 +1,27 @@
/*
* Styles for the base documents used by the CGI RFC project.
*/
BODY
{
background-color: #FFFFFF;
}
/*
* Standard styles for marking up drafts and RFC documents.
*/
.shabuj
{
color: green;
}
.lal
{
color: red;
}
.fuchsia
{
color: fuchsia;
}
View File
View File
Binary file not shown.
+127 -17
View File
@@ -8,6 +8,7 @@
#include <math.h>
#include "mutils.h"
#include "msock.h"
#include "sll.h"
@@ -28,6 +29,7 @@
#endif /* HAVE_OPENSSL */
/*
** header for mailsend - a simple mail sender via SMTP
** $Id: mailsend.h,v 1.3 2002/06/22 21:17:29 muquit Exp $
@@ -37,31 +39,30 @@
** muquit@muquit.com Mar-23-2001 first cut
*/
#define BUFSIZ 32768
#define MFL __FILE__,__LINE__
#define MAILSEND_VERSION "@(#) mailsend v1.15b5"
#define MAILSEND_VERSION "@(#) mailsend v1.20b2"
#define MAILSEND_PROG "mailsend"
#define MAILSEND_AUTHOR "muquit@muquit.com"
#define MAILSEND_URL "http://www.muquit.com/"
#define NO_SPAM_STATEMENT "GNU GPL. It is illegal to use this software for Spamming"
#define NO_SPAM_STATEMENT "BSD. It is illegal to use this software for Spamming"
#define MAILSEND_SMTP_PORT 587 // 25
#define MAILSEND_SMTP_PORT 25
#define MAILSEND_DEF_SUB ""
#define A_SPACE ' '
#define A_DASH '-'
#define EMPTY_OK 0x01
#define EMPTY_NOT_OK 0x02
#define ATTACHMENT_SEP ','
#define FILE_TYPE_DOS 0x00000001
#define FILE_TYPE_UNIX 0x00000002
#define FILE_TYPE_BINARY 0x00000004
#define DEFAULT_CONNECT_TIMEOUT 5 /* seconds */
#define DEFAULT_READ_TIMEOUT 5 /* seconds */
#ifdef EXTERN
#undef EXTERN
@@ -69,7 +70,7 @@
#ifndef __MAIN__
#define EXTERN extern
#else
#else
#define EXTERN
#endif /* __MAIN__ */
@@ -113,10 +114,45 @@ do \
}\
}while(0)
#define RETURN_IF_NOT_ZERO(rc) \
do \
{ \
if (rc != 0) \
{ \
return(rc); \
} \
}while(0)
#define CHECK_WRITE_STATUS(n) \
do \
{ \
if (n <= 0) \
{ \
goto ExitProcessing; \
} \
}while(0)
#define ERR_STR strerror(errno)
#define CONTENT_DISPOSITION_INLINE 0x01
#define CONTENT_DISPOSITION_ATTACHMENT 0x02
/* only suport base64 at this time */
/* as of Jul-01-2013 */
#define ENCODE_7BIT 0x01 /* default for text/plain */
#define ENCODE_8BIT 0x02
#define ENCODE_BASE64 0x03
#define ENCODE_QUOTED_PRINTABLE 0x04
#define ENCODE_NONE 0x05
#define DEFAULT_CHARSET "utf-8"
EXTERN int g_verbose;
EXTERN int g_connect_timeout;
EXTERN int g_read_timeout;
EXTERN int g_wait_for_cr;
EXTERN int g_do_ssl;
EXTERN int g_do_starttls;
EXTERN int g_quiet;
EXTERN int g_do_auth;
@@ -128,12 +164,25 @@ EXTERN char g_charset[33];
EXTERN char g_username[64];
EXTERN char g_userpass[64];
EXTERN char g_from_name[64];
EXTERN char g_content_transfer_encoding[32];
EXTERN FILE *g_log_fp;
EXTERN char g_log_file[MUTILS_PATH_MAX];
EXTERN int g_show_attachment_in_log;
EXTERN int g_use_protocol;
EXTERN char g_content_type[64];
EXTERN char g_attach_sep[4];
EXTERN char g_attach_name[64];
EXTERN char g_content_disposition[32];
EXTERN char g_content_id[64];
EXTERN char g_mime_type[64];
EXTERN int g_force;
typedef struct _Address
{
/*
** label holds strings like "To" "Cc" "Bcc".
** label holds strings like "To" "Cc" "Bcc".
** The address is the email address.
*/
@@ -146,11 +195,31 @@ typedef struct _Attachment
{
char
*file_path,
*file_name;
*file_name,
*attachment_name,
*content_id;
char
*oneline_msg;
char
*mime_type;
char
*content_disposition;
char
*content_transfer_encoding,
*charset;
int
attach_separator;
FILE
*fp_read;
char
mime_tmpfile[MUTILS_PATH_MAX];
}Attachment;
/* the mail sturct */
@@ -182,34 +251,58 @@ typedef struct _Mailsendrc
}Mailsendrc;
/* function prototypes */
char *xStrdup(char *string);
char *xStrdup(const char *string);
int addAddressToList(char *a,char *label);
TheMail *initTheMail(void);
Address *newAddress(void);
Sll *getAddressList(void);
void printAddressList(void);
void print_server_caps(void);
void print_one_lines(void);
char *check_server_cap(char *what);
int read_smtp_line();
void show_smtp_info(char *smtp_server,int port,char *domain);
int read_smtp_line(void);
int read_smtp_multi_lines(void);
int show_smtp_info(char *smtp_server,int port,char *domain);
int send_the_mail(char *from,char *to,char *cc,char *bcc,char *sub,
char *smtp_server,int smtp_port,char *helo_domain,
char *attach_file,char *txt_msg_file,char *the_msg,
int is_mime,char *rrr,char *rt,int add_dateh);
int is_mime,char *rrr,char *rt,int add_dateh,char* return_path_addr);
TheMail *newTheMail(void);
void errorMsg(char *format,...);
void showVerbose(char *format,...);
void print_info(char *format,...);
void write_log(char *format,...);
void open_log(const char *log_file);
void close_log(void);
void exit_ok(void);
void exit_error(void);
void log_info(const char *fmt, ...);
void log_debug(const char *fmt, ...);
void log_error(const char *fmt, ...);
void log_fatal(const char *fmt, ...);
int addAddressesFromFileToList(char *adress_list_file);
int validateMusts(char *from,char *to,char *smtp_server,
char *helo_domain);
char *askFor(char *buf,int buflen,char *label,int loop);
int isInConsole(int fd);
int add_one_line_to_list(char *line);
int add_msg_body_files_to_list(char *file_path);
int add_embed_image_to_attachment_list(const char *image_file);
int add_customer_header_to_list(char *line);
int add_attachment_to_list(char *file_path_mime);
int add_oneline_to_attachment_list(char *one_line_msg);
int add_msg_body_to_attachment_list(const char *msg_body_file);
int add_server_cap_to_list(char *capability);
Sll *get_attachment_list();
Sll *get_server_caps_list();
void print_attachemtn_list();
Sll *get_one_line_list(void);
Sll *get_custom_header_list(void);
Sll *get_attachment_list(void);
Sll *get_oneline_attachment_list(void);
Sll *get_msg_body_attachment_list(void);
Sll *get_embed_image_attachment_list(void);
Sll *get_server_caps_list(void);
Sll *get_msg_body_files_list(void);
void print_attachment_list(void);
void print_oneline_attachment_list(void);
char *fix_to(char *to);
int isInteractive(void);
int get_filepath_mimetype(char *str,char *filename,int fn_size,
@@ -221,8 +314,25 @@ int do_tls(int sfd);
void initialize_openssl(char *cipher);
char *encode_cram_md5(char *challenge,char *user,char *pass);
int guess_file_type(char *path,unsigned int *flag);
void generate_encrypted_password(const char *plaintext);
void print_copyright(void);
int get_encoding_type(const char *type);
int get_content_disposition(const char *disposition);
Attachment *allocate_attachment(void);
int write_to_socket(char *str);
int print_content_type_header(const char *boundary);
int send_attachment(Attachment *a, const char *boundary);
int process_attachments(const char *boundary);
int process_oneline_messages(const char *boundary);
int process_embeded_images(const char *boundary);
int encode2base64andwrite2socket(const char *str);
int include_msg_body(void);
int include_image(void);
void show_examples(void);
char *get_mime_type(char *path);
#ifdef HAVE_OPENSSL
void print_cert_info(SSL *ssl);
void show_mime_types(void);
#endif /* HAVE_OPENSSL */
#endif /* ! MAIL_SEND_H */
Regular → Executable
+687 -178
View File
File diff suppressed because it is too large Load Diff
+831
View File
@@ -0,0 +1,831 @@
###############################################################################
#
# MIME-TYPES and the extensions that represent them
#
# The format of this file is a MIME type on the left and zero or more
# filename extensions on the right. Programs using this file will map
# files ending with those extensions to the associated type.
#
# This file is part of the "mime-support" package. Please send email (not a
# bug report) to mime-support@packages.debian.org if you would like new types
# and/or extensions to be added.
#
# The reason that all types are managed by the mime-support package instead
# allowing individual packages to install types in much the same way as they
# add entries in to the mailcap file is so these types can be referenced by
# other programs (such as a web server) even if the specific support package
# for that type is not installed.
#
# Users can add their own types if they wish by creating a ".mime.types"
# file in their home directory. Definitions included there will take
# precedence over those listed here.
#
# Note: Compression schemes like "gzip", "bzip", and "compress" are not
# actually "mime-types". They are "encodings" and hence must _not_ have
# entries in this file to map their extensions. The "mime-type" of an
# encoded file refers to the type of data that has been encoded, not the
# type of encoding.
#
###############################################################################
application/activemessage
application/andrew-inset ez
application/annodex anx
application/applefile
application/atom+xml atom
application/atomcat+xml atomcat
application/atomicmail
application/atomserv+xml atomsrv
application/batch-SMTP
application/bbolin lin
application/beep+xml
application/cals-1840
application/commonground
application/cu-seeme cu
application/cybercash
application/davmount+xml davmount
application/dca-rft
application/dec-dx
application/dicom dcm
application/docbook+xml
application/dsptype tsp
application/dvcs
application/ecmascript es
application/edi-consent
application/edi-x12
application/edifact
application/eshop
application/font-tdpfr
application/futuresplash spl
application/ghostview
application/hta hta
application/http
application/hyperstudio
application/iges
application/index
application/index.cmd
application/index.obj
application/index.response
application/index.vnd
application/iotp
application/ipp
application/isup
application/java-archive jar
application/java-serialized-object ser
application/java-vm class
application/javascript js
application/json json
application/m3g m3g
application/mac-binhex40 hqx
application/mac-compactpro cpt
application/macwriteii
application/marc
application/mathematica nb nbp
application/mbox mbox
application/ms-tnef
application/msaccess mdb
application/msword doc dot
application/mxf mxf
application/news-message-id
application/news-transmission
application/ocsp-request
application/ocsp-response
application/octet-stream bin
application/oda oda
application/ogg ogx
application/onenote one onetoc2 onetmp onepkg
application/parityfec
application/pdf pdf
application/pgp-encrypted pgp
application/pgp-keys key
application/pgp-signature sig
application/pics-rules prf
application/pkcs10
application/pkcs7-mime
application/pkcs7-signature
application/pkix-cert
application/pkix-crl
application/pkixcmp
application/postscript ps ai eps epsi epsf eps2 eps3
application/prs.alvestrand.titrax-sheet
application/prs.cww
application/prs.nprend
application/qsig
application/rar rar
application/rdf+xml rdf
application/remote-printing
application/riscos
application/rtf rtf
application/sdp
application/set-payment
application/set-payment-initiation
application/set-registration
application/set-registration-initiation
application/sgml
application/sgml-open-catalog
application/sieve
application/sla stl
application/slate
application/smil smi smil
application/timestamp-query
application/timestamp-reply
application/vemmi
application/whoispp-query
application/whoispp-response
application/wita
application/x400-bp
application/xhtml+xml xhtml xht
application/xml xml xsl xsd
application/xml-dtd
application/xml-external-parsed-entity
application/xspf+xml xspf
application/zip zip
application/vnd.3M.Post-it-Notes
application/vnd.accpac.simply.aso
application/vnd.accpac.simply.imp
application/vnd.acucobol
application/vnd.aether.imp
application/vnd.android.package-archive apk
application/vnd.anser-web-certificate-issue-initiation
application/vnd.anser-web-funds-transfer-initiation
application/vnd.audiograph
application/vnd.bmi
application/vnd.businessobjects
application/vnd.canon-cpdl
application/vnd.canon-lips
application/vnd.cinderella cdy
application/vnd.claymore
application/vnd.commerce-battelle
application/vnd.commonspace
application/vnd.comsocaller
application/vnd.contact.cmsg
application/vnd.cosmocaller
application/vnd.ctc-posml
application/vnd.cups-postscript
application/vnd.cups-raster
application/vnd.cups-raw
application/vnd.cybank
application/vnd.dna
application/vnd.dpgraph
application/vnd.dxr
application/vnd.ecdis-update
application/vnd.ecowin.chart
application/vnd.ecowin.filerequest
application/vnd.ecowin.fileupdate
application/vnd.ecowin.series
application/vnd.ecowin.seriesrequest
application/vnd.ecowin.seriesupdate
application/vnd.enliven
application/vnd.epson.esf
application/vnd.epson.msf
application/vnd.epson.quickanime
application/vnd.epson.salt
application/vnd.epson.ssf
application/vnd.ericsson.quickcall
application/vnd.eudora.data
application/vnd.fdf
application/vnd.ffsns
application/vnd.flographit
application/vnd.framemaker
application/vnd.fsc.weblaunch
application/vnd.fujitsu.oasys
application/vnd.fujitsu.oasys2
application/vnd.fujitsu.oasys3
application/vnd.fujitsu.oasysgp
application/vnd.fujitsu.oasysprs
application/vnd.fujixerox.ddd
application/vnd.fujixerox.docuworks
application/vnd.fujixerox.docuworks.binder
application/vnd.fut-misnet
application/vnd.google-earth.kml+xml kml
application/vnd.google-earth.kmz kmz
application/vnd.grafeq
application/vnd.groove-account
application/vnd.groove-identity-message
application/vnd.groove-injector
application/vnd.groove-tool-message
application/vnd.groove-tool-template
application/vnd.groove-vcard
application/vnd.hhe.lesson-player
application/vnd.hp-HPGL
application/vnd.hp-PCL
application/vnd.hp-PCLXL
application/vnd.hp-hpid
application/vnd.hp-hps
application/vnd.httphone
application/vnd.hzn-3d-crossword
application/vnd.ibm.MiniPay
application/vnd.ibm.afplinedata
application/vnd.ibm.modcap
application/vnd.informix-visionary
application/vnd.intercon.formnet
application/vnd.intertrust.digibox
application/vnd.intertrust.nncp
application/vnd.intu.qbo
application/vnd.intu.qfx
application/vnd.irepository.package+xml
application/vnd.is-xpr
application/vnd.japannet-directory-service
application/vnd.japannet-jpnstore-wakeup
application/vnd.japannet-payment-wakeup
application/vnd.japannet-registration
application/vnd.japannet-registration-wakeup
application/vnd.japannet-setstore-wakeup
application/vnd.japannet-verification
application/vnd.japannet-verification-wakeup
application/vnd.koan
application/vnd.lotus-1-2-3
application/vnd.lotus-approach
application/vnd.lotus-freelance
application/vnd.lotus-notes
application/vnd.lotus-organizer
application/vnd.lotus-screencam
application/vnd.lotus-wordpro
application/vnd.mcd
application/vnd.mediastation.cdkey
application/vnd.meridian-slingshot
application/vnd.mif
application/vnd.minisoft-hp3000-save
application/vnd.mitsubishi.misty-guard.trustweb
application/vnd.mobius.daf
application/vnd.mobius.dis
application/vnd.mobius.msl
application/vnd.mobius.plc
application/vnd.mobius.txf
application/vnd.motorola.flexsuite
application/vnd.motorola.flexsuite.adsi
application/vnd.motorola.flexsuite.fis
application/vnd.motorola.flexsuite.gotap
application/vnd.motorola.flexsuite.kmr
application/vnd.motorola.flexsuite.ttc
application/vnd.motorola.flexsuite.wem
application/vnd.mozilla.xul+xml xul
application/vnd.ms-artgalry
application/vnd.ms-asf
application/vnd.ms-excel xls xlb xlt
application/vnd.ms-excel.addin.macroEnabled.12 xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
application/vnd.ms-excel.template.macroEnabled.12 xltm
application/vnd.ms-fontobject eot
application/vnd.ms-lrm
application/vnd.ms-officetheme thmx
application/vnd.ms-pki.seccat cat
#application/vnd.ms-pki.stl stl
application/vnd.ms-powerpoint ppt pps
application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
application/vnd.ms-powerpoint.slide.macroEnabled.12 sldm
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
application/vnd.ms-powerpoint.template.macroEnabled.12 potm
application/vnd.ms-project
application/vnd.ms-tnef
application/vnd.ms-word.document.macroEnabled.12 docm
application/vnd.ms-word.template.macroEnabled.12 dotm
application/vnd.ms-works
application/vnd.mseq
application/vnd.msign
application/vnd.music-niff
application/vnd.musician
application/vnd.netfpx
application/vnd.noblenet-directory
application/vnd.noblenet-sealer
application/vnd.noblenet-web
application/vnd.novadigm.EDM
application/vnd.novadigm.EDX
application/vnd.novadigm.EXT
application/vnd.oasis.opendocument.chart odc
application/vnd.oasis.opendocument.database odb
application/vnd.oasis.opendocument.formula odf
application/vnd.oasis.opendocument.graphics odg
application/vnd.oasis.opendocument.graphics-template otg
application/vnd.oasis.opendocument.image odi
application/vnd.oasis.opendocument.presentation odp
application/vnd.oasis.opendocument.presentation-template otp
application/vnd.oasis.opendocument.spreadsheet ods
application/vnd.oasis.opendocument.spreadsheet-template ots
application/vnd.oasis.opendocument.text odt
application/vnd.oasis.opendocument.text-master odm
application/vnd.oasis.opendocument.text-template ott
application/vnd.oasis.opendocument.text-web oth
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/vnd.openxmlformats-officedocument.presentationml.slide sldx
application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
application/vnd.openxmlformats-officedocument.presentationml.template potx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/vnd.osa.netdeploy
application/vnd.palm
application/vnd.pg.format
application/vnd.pg.osasli
application/vnd.powerbuilder6
application/vnd.powerbuilder6-s
application/vnd.powerbuilder7
application/vnd.powerbuilder7-s
application/vnd.powerbuilder75
application/vnd.powerbuilder75-s
application/vnd.previewsystems.box
application/vnd.publishare-delta-tree
application/vnd.pvi.ptid1
application/vnd.pwg-xhtml-print+xml
application/vnd.rapid
application/vnd.rim.cod cod
application/vnd.s3sms
application/vnd.seemail
application/vnd.shana.informed.formdata
application/vnd.shana.informed.formtemplate
application/vnd.shana.informed.interchange
application/vnd.shana.informed.package
application/vnd.smaf mmf
application/vnd.sss-cod
application/vnd.sss-dtf
application/vnd.sss-ntf
application/vnd.stardivision.calc sdc
application/vnd.stardivision.chart sds
application/vnd.stardivision.draw sda
application/vnd.stardivision.impress sdd
application/vnd.stardivision.math sdf
application/vnd.stardivision.writer sdw
application/vnd.stardivision.writer-global sgl
application/vnd.street-stream
application/vnd.sun.xml.calc sxc
application/vnd.sun.xml.calc.template stc
application/vnd.sun.xml.draw sxd
application/vnd.sun.xml.draw.template std
application/vnd.sun.xml.impress sxi
application/vnd.sun.xml.impress.template sti
application/vnd.sun.xml.math sxm
application/vnd.sun.xml.writer sxw
application/vnd.sun.xml.writer.global sxg
application/vnd.sun.xml.writer.template stw
application/vnd.svd
application/vnd.swiftview-ics
application/vnd.symbian.install sis
application/vnd.tcpdump.pcap cap pcap
application/vnd.triscape.mxs
application/vnd.trueapp
application/vnd.truedoc
application/vnd.tve-trigger
application/vnd.ufdl
application/vnd.uplanet.alert
application/vnd.uplanet.alert-wbxml
application/vnd.uplanet.bearer-choice
application/vnd.uplanet.bearer-choice-wbxml
application/vnd.uplanet.cacheop
application/vnd.uplanet.cacheop-wbxml
application/vnd.uplanet.channel
application/vnd.uplanet.channel-wbxml
application/vnd.uplanet.list
application/vnd.uplanet.list-wbxml
application/vnd.uplanet.listcmd
application/vnd.uplanet.listcmd-wbxml
application/vnd.uplanet.signal
application/vnd.vcx
application/vnd.vectorworks
application/vnd.vidsoft.vidconference
application/vnd.visio vsd
application/vnd.vividence.scriptfile
application/vnd.wap.sic
application/vnd.wap.slc
application/vnd.wap.wbxml wbxml
application/vnd.wap.wmlc wmlc
application/vnd.wap.wmlscriptc wmlsc
application/vnd.webturbo
application/vnd.wordperfect wpd
application/vnd.wordperfect5.1 wp5
application/vnd.wrq-hp3000-labelled
application/vnd.wt.stf
application/vnd.xara
application/vnd.xfdl
application/vnd.yellowriver-custom-menu
application/x-123 wk
application/x-7z-compressed 7z
application/x-abiword abw
application/x-apple-diskimage dmg
application/x-bcpio bcpio
application/x-bittorrent torrent
application/x-cab cab
application/x-cbr cbr
application/x-cbz cbz
application/x-cdf cdf cda
application/x-cdlink vcd
application/x-chess-pgn pgn
application/x-comsol mph
application/x-core
application/x-cpio cpio
application/x-csh csh
application/x-debian-package deb udeb
application/x-director dcr dir dxr
application/x-dms dms
application/x-doom wad
application/x-dvi dvi
application/x-executable
application/x-font pfa pfb gsf pcf pcf.Z
application/x-font-woff woff
application/x-freemind mm
application/x-futuresplash spl
application/x-ganttproject gan
application/x-gnumeric gnumeric
application/x-go-sgf sgf
application/x-graphing-calculator gcf
application/x-gtar gtar
application/x-gtar-compressed tgz taz
application/x-hdf hdf
#application/x-httpd-eruby rhtml
#application/x-httpd-php phtml pht php
#application/x-httpd-php-source phps
#application/x-httpd-php3 php3
#application/x-httpd-php3-preprocessed php3p
#application/x-httpd-php4 php4
#application/x-httpd-php5 php5
application/x-hwp hwp
application/x-ica ica
application/x-info info
application/x-internet-signup ins isp
application/x-iphone iii
application/x-iso9660-image iso
application/x-jam jam
application/x-java-applet
application/x-java-bean
application/x-java-jnlp-file jnlp
application/x-jmol jmz
application/x-kchart chrt
application/x-kdelnk
application/x-killustrator kil
application/x-koan skp skd skt skm
application/x-kpresenter kpr kpt
application/x-kspread ksp
application/x-kword kwd kwt
application/x-latex latex
application/x-lha lha
application/x-lyx lyx
application/x-lzh lzh
application/x-lzx lzx
application/x-maker frm maker frame fm fb book fbdoc
application/x-md5 md5
application/x-mif mif
application/x-mpegURL m3u8
application/x-ms-wmd wmd
application/x-ms-wmz wmz
application/x-msdos-program com exe bat dll
application/x-msi msi
application/x-netcdf nc
application/x-ns-proxy-autoconfig pac dat
application/x-nwc nwc
application/x-object o
application/x-oz-application oza
application/x-pkcs7-certreqresp p7r
application/x-pkcs7-crl crl
application/x-python-code pyc pyo
application/x-qgis qgs shp shx
application/x-quicktimeplayer qtl
application/x-rdp rdp
application/x-redhat-package-manager rpm
application/x-rss+xml rss
application/x-ruby rb
application/x-rx
application/x-scilab sci sce
application/x-scilab-xcos xcos
application/x-sh sh
application/x-sha1 sha1
application/x-shar shar
application/x-shellscript
application/x-shockwave-flash swf swfl
application/x-silverlight scr
application/x-sql sql
application/x-stuffit sit sitx
application/x-sv4cpio sv4cpio
application/x-sv4crc sv4crc
application/x-tar tar
application/x-tcl tcl
application/x-tex-gf gf
application/x-tex-pk pk
application/x-texinfo texinfo texi
application/x-trash ~ % bak old sik
application/x-troff t tr roff
application/x-troff-man man
application/x-troff-me me
application/x-troff-ms ms
application/x-ustar ustar
application/x-videolan
application/x-wais-source src
application/x-wingz wz
application/x-x509-ca-cert crt
application/x-xcf xcf
application/x-xfig fig
application/x-xpinstall xpi
audio/32kadpcm
audio/3gpp
audio/amr amr
audio/amr-wb awb
audio/amr amr
audio/amr-wb awb
audio/annodex axa
audio/basic au snd
audio/csound csd orc sco
audio/flac flac
audio/g.722.1
audio/l16
audio/midi mid midi kar
audio/mp4a-latm
audio/mpa-robust
audio/mpeg mpga mpega mp2 mp3 m4a
audio/mpegurl m3u
audio/ogg oga ogg spx
audio/parityfec
audio/prs.sid sid
audio/telephone-event
audio/tone
audio/vnd.cisco.nse
audio/vnd.cns.anp1
audio/vnd.cns.inf1
audio/vnd.digital-winds
audio/vnd.everad.plj
audio/vnd.lucent.voice
audio/vnd.nortel.vbk
audio/vnd.nuera.ecelp4800
audio/vnd.nuera.ecelp7470
audio/vnd.nuera.ecelp9600
audio/vnd.octel.sbc
audio/vnd.qcelp
audio/vnd.rhetorex.32kadpcm
audio/vnd.vmx.cvsd
audio/x-aiff aif aiff aifc
audio/x-gsm gsm
audio/x-mpegurl m3u
audio/x-ms-wma wma
audio/x-ms-wax wax
audio/x-pn-realaudio-plugin
audio/x-pn-realaudio ra rm ram
audio/x-realaudio ra
audio/x-scpls pls
audio/x-sd2 sd2
audio/x-wav wav
chemical/x-alchemy alc
chemical/x-cache cac cache
chemical/x-cache-csf csf
chemical/x-cactvs-binary cbin cascii ctab
chemical/x-cdx cdx
chemical/x-cerius cer
chemical/x-chem3d c3d
chemical/x-chemdraw chm
chemical/x-cif cif
chemical/x-cmdf cmdf
chemical/x-cml cml
chemical/x-compass cpa
chemical/x-crossfire bsd
chemical/x-csml csml csm
chemical/x-ctx ctx
chemical/x-cxf cxf cef
#chemical/x-daylight-smiles smi
chemical/x-embl-dl-nucleotide emb embl
chemical/x-galactic-spc spc
chemical/x-gamess-input inp gam gamin
chemical/x-gaussian-checkpoint fch fchk
chemical/x-gaussian-cube cub
chemical/x-gaussian-input gau gjc gjf
chemical/x-gaussian-log gal
chemical/x-gcg8-sequence gcg
chemical/x-genbank gen
chemical/x-hin hin
chemical/x-isostar istr ist
chemical/x-jcamp-dx jdx dx
chemical/x-kinemage kin
chemical/x-macmolecule mcm
chemical/x-macromodel-input mmd mmod
chemical/x-mdl-molfile mol
chemical/x-mdl-rdfile rd
chemical/x-mdl-rxnfile rxn
chemical/x-mdl-sdfile sd sdf
chemical/x-mdl-tgf tgf
#chemical/x-mif mif
chemical/x-mmcif mcif
chemical/x-mol2 mol2
chemical/x-molconn-Z b
chemical/x-mopac-graph gpt
chemical/x-mopac-input mop mopcrt mpc zmt
chemical/x-mopac-out moo
chemical/x-mopac-vib mvb
chemical/x-ncbi-asn1 asn
chemical/x-ncbi-asn1-ascii prt ent
chemical/x-ncbi-asn1-binary val aso
chemical/x-ncbi-asn1-spec asn
chemical/x-pdb pdb ent
chemical/x-rosdal ros
chemical/x-swissprot sw
chemical/x-vamas-iso14976 vms
chemical/x-vmd vmd
chemical/x-xtel xtel
chemical/x-xyz xyz
image/cgm
image/g3fax
image/gif gif
image/ief ief
image/jpeg jpeg jpg jpe
image/naplps
image/pcx pcx
image/png png
image/prs.btif
image/prs.pti
image/svg+xml svg svgz
image/tiff tiff tif
image/vnd.cns.inf2
image/vnd.djvu djvu djv
image/vnd.dwg
image/vnd.dxf
image/vnd.fastbidsheet
image/vnd.fpx
image/vnd.fst
image/vnd.fujixerox.edmics-mmr
image/vnd.fujixerox.edmics-rlc
image/vnd.microsoft.icon ico
image/vnd.mix
image/vnd.net-fpx
image/vnd.svf
image/vnd.wap.wbmp wbmp
image/vnd.xiff
image/x-canon-cr2 cr2
image/x-canon-crw crw
image/x-cmu-raster ras
image/x-coreldraw cdr
image/x-coreldrawpattern pat
image/x-coreldrawtemplate cdt
image/x-corelphotopaint cpt
image/x-epson-erf erf
image/x-icon
image/x-jg art
image/x-jng jng
image/x-ms-bmp bmp
image/x-nikon-nef nef
image/x-olympus-orf orf
image/x-photoshop psd
image/x-portable-anymap pnm
image/x-portable-bitmap pbm
image/x-portable-graymap pgm
image/x-portable-pixmap ppm
image/x-rgb rgb
image/x-xbitmap xbm
image/x-xpixmap xpm
image/x-xwindowdump xwd
inode/chardevice
inode/blockdevice
inode/directory-locked
inode/directory
inode/fifo
inode/socket
message/delivery-status
message/disposition-notification
message/external-body
message/http
message/s-http
message/news
message/partial
message/rfc822 eml
model/iges igs iges
model/mesh msh mesh silo
model/vnd.dwf
model/vnd.flatland.3dml
model/vnd.gdl
model/vnd.gs-gdl
model/vnd.gtw
model/vnd.mts
model/vnd.vtu
model/vrml wrl vrml
model/x3d+vrml x3dv
model/x3d+xml x3d
model/x3d+binary x3db
multipart/alternative
multipart/appledouble
multipart/byteranges
multipart/digest
multipart/encrypted
multipart/form-data
multipart/header-set
multipart/mixed
multipart/parallel
multipart/related
multipart/report
multipart/signed
multipart/voice-message
text/cache-manifest appcache
text/calendar ics icz
text/css css
text/csv csv
text/directory
text/english
text/enriched
text/h323 323
text/html html htm shtml
text/iuls uls
text/mathml mml
text/parityfec
text/plain asc txt text pot brf srt
text/prs.lines.tag
text/rfc822-headers
text/richtext rtx
text/rtf
text/scriptlet sct wsc
text/t140
text/texmacs tm
text/tab-separated-values tsv
text/uri-list
text/vnd.abc
text/vnd.curl
text/vnd.DMClientScript
text/vnd.flatland.3dml
text/vnd.fly
text/vnd.fmi.flexstor
text/vnd.in3d.3dml
text/vnd.in3d.spot
text/vnd.IPTC.NewsML
text/vnd.IPTC.NITF
text/vnd.latex-z
text/vnd.motorola.reflex
text/vnd.ms-mediapackage
text/vnd.sun.j2me.app-descriptor jad
text/vnd.wap.si
text/vnd.wap.sl
text/vnd.wap.wml wml
text/vnd.wap.wmlscript wmls
text/x-bibtex bib
text/x-boo boo
text/x-c++hdr h++ hpp hxx hh
text/x-c++src c++ cpp cxx cc
text/x-chdr h
text/x-component htc
text/x-crontab
text/x-csh csh
text/x-csrc c
text/x-dsrc d
text/x-diff diff patch
text/x-haskell hs
text/x-java java
text/x-lilypond ly
text/x-literate-haskell lhs
text/x-makefile
text/x-moc moc
text/x-pascal p pas
text/x-pcs-gcd gcd
text/x-perl pl pm
text/x-python py
text/x-scala scala
text/x-server-parsed-html
text/x-setext etx
text/x-sfv sfv
text/x-sh sh
text/x-tcl tcl tk
text/x-tex tex ltx sty cls
text/x-vcalendar vcs
text/x-vcard vcf
video/3gpp 3gp
video/annodex axv
video/dl dl
video/dv dif dv
video/fli fli
video/gl gl
video/mpeg mpeg mpg mpe
video/MP2T ts
video/mp4 mp4
video/quicktime qt mov
video/mp4v-es
video/ogg ogv
video/parityfec
video/pointer
video/webm webm
video/vnd.fvt
video/vnd.motorola.video
video/vnd.motorola.videop
video/vnd.mpegurl mxu
video/vnd.mts
video/vnd.nokia.interleaved-multimedia
video/vnd.vivo
video/x-flv flv
video/x-la-asf lsf lsx
video/x-mng mng
video/x-ms-asf asf asx
video/x-ms-wm wm
video/x-ms-wmv wmv
video/x-ms-wmx wmx
video/x-ms-wvx wvx
video/x-msvideo avi
video/x-sgi-movie movie
video/x-matroska mpv mkv
x-conference/x-cooltalk ice
x-epoc/x-sisx-app sisx
x-world/x-vrml vrm vrml wrl
+542
View File
@@ -0,0 +1,542 @@
/*
** WARNING: This file is auto generated. DO NOT MODIFY
** Generated by ./mk_mime_types_h.rb from /Users/muquit/svndev/mailsend/mime.types
** 2013-12-15 18:17:07 -0500
*/
{ "ez","application/andrew-inset"},
{ "anx","application/annodex"},
{ "atom","application/atom+xml"},
{ "atomcat","application/atomcat+xml"},
{ "atomsrv","application/atomserv+xml"},
{ "lin","application/bbolin"},
{ "cu","application/cu-seeme"},
{ "davmount","application/davmount+xml"},
{ "dcm","application/dicom"},
{ "tsp","application/dsptype"},
{ "es","application/ecmascript"},
{ "spl","application/futuresplash"},
{ "hta","application/hta"},
{ "jar","application/java-archive"},
{ "ser","application/java-serialized-object"},
{ "class","application/java-vm"},
{ "js","application/javascript"},
{ "json","application/json"},
{ "m3g","application/m3g"},
{ "hqx","application/mac-binhex40"},
{ "cpt","application/mac-compactpro"},
{ "nb","application/mathematica"},
{ "nbp","application/mathematica"},
{ "mbox","application/mbox"},
{ "mdb","application/msaccess"},
{ "doc","application/msword"},
{ "dot","application/msword"},
{ "mxf","application/mxf"},
{ "bin","application/octet-stream"},
{ "oda","application/oda"},
{ "ogx","application/ogg"},
{ "one","application/onenote"},
{ "onetoc2","application/onenote"},
{ "onetmp","application/onenote"},
{ "onepkg","application/onenote"},
{ "pdf","application/pdf"},
{ "pgp","application/pgp-encrypted"},
{ "key","application/pgp-keys"},
{ "sig","application/pgp-signature"},
{ "prf","application/pics-rules"},
{ "ps","application/postscript"},
{ "ai","application/postscript"},
{ "eps","application/postscript"},
{ "epsi","application/postscript"},
{ "epsf","application/postscript"},
{ "eps2","application/postscript"},
{ "eps3","application/postscript"},
{ "rar","application/rar"},
{ "rdf","application/rdf+xml"},
{ "rtf","application/rtf"},
{ "stl","application/sla"},
{ "smi","application/smil"},
{ "smil","application/smil"},
{ "xhtml","application/xhtml+xml"},
{ "xht","application/xhtml+xml"},
{ "xml","application/xml"},
{ "xsl","application/xml"},
{ "xsd","application/xml"},
{ "xspf","application/xspf+xml"},
{ "zip","application/zip"},
{ "apk","application/vnd.android.package-archive"},
{ "cdy","application/vnd.cinderella"},
{ "kml","application/vnd.google-earth.kml+xml"},
{ "kmz","application/vnd.google-earth.kmz"},
{ "xul","application/vnd.mozilla.xul+xml"},
{ "xls","application/vnd.ms-excel"},
{ "xlb","application/vnd.ms-excel"},
{ "xlt","application/vnd.ms-excel"},
{ "xlam","application/vnd.ms-excel.addin.macroEnabled.12"},
{ "xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"},
{ "xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"},
{ "xltm","application/vnd.ms-excel.template.macroEnabled.12"},
{ "eot","application/vnd.ms-fontobject"},
{ "thmx","application/vnd.ms-officetheme"},
{ "cat","application/vnd.ms-pki.seccat"},
{ "ppt","application/vnd.ms-powerpoint"},
{ "pps","application/vnd.ms-powerpoint"},
{ "ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"},
{ "pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"},
{ "sldm","application/vnd.ms-powerpoint.slide.macroEnabled.12"},
{ "ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"},
{ "potm","application/vnd.ms-powerpoint.template.macroEnabled.12"},
{ "docm","application/vnd.ms-word.document.macroEnabled.12"},
{ "dotm","application/vnd.ms-word.template.macroEnabled.12"},
{ "odc","application/vnd.oasis.opendocument.chart"},
{ "odb","application/vnd.oasis.opendocument.database"},
{ "odf","application/vnd.oasis.opendocument.formula"},
{ "odg","application/vnd.oasis.opendocument.graphics"},
{ "otg","application/vnd.oasis.opendocument.graphics-template"},
{ "odi","application/vnd.oasis.opendocument.image"},
{ "odp","application/vnd.oasis.opendocument.presentation"},
{ "otp","application/vnd.oasis.opendocument.presentation-template"},
{ "ods","application/vnd.oasis.opendocument.spreadsheet"},
{ "ots","application/vnd.oasis.opendocument.spreadsheet-template"},
{ "odt","application/vnd.oasis.opendocument.text"},
{ "odm","application/vnd.oasis.opendocument.text-master"},
{ "ott","application/vnd.oasis.opendocument.text-template"},
{ "oth","application/vnd.oasis.opendocument.text-web"},
{ "pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"},
{ "sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"},
{ "ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"},
{ "potx","application/vnd.openxmlformats-officedocument.presentationml.template"},
{ "xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
{ "xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
{ "xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"},
{ "xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"},
{ "docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
{ "dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"},
{ "cod","application/vnd.rim.cod"},
{ "mmf","application/vnd.smaf"},
{ "sdc","application/vnd.stardivision.calc"},
{ "sds","application/vnd.stardivision.chart"},
{ "sda","application/vnd.stardivision.draw"},
{ "sdd","application/vnd.stardivision.impress"},
{ "sdf","application/vnd.stardivision.math"},
{ "sdw","application/vnd.stardivision.writer"},
{ "sgl","application/vnd.stardivision.writer-global"},
{ "sxc","application/vnd.sun.xml.calc"},
{ "stc","application/vnd.sun.xml.calc.template"},
{ "sxd","application/vnd.sun.xml.draw"},
{ "std","application/vnd.sun.xml.draw.template"},
{ "sxi","application/vnd.sun.xml.impress"},
{ "sti","application/vnd.sun.xml.impress.template"},
{ "sxm","application/vnd.sun.xml.math"},
{ "sxw","application/vnd.sun.xml.writer"},
{ "sxg","application/vnd.sun.xml.writer.global"},
{ "stw","application/vnd.sun.xml.writer.template"},
{ "sis","application/vnd.symbian.install"},
{ "cap","application/vnd.tcpdump.pcap"},
{ "pcap","application/vnd.tcpdump.pcap"},
{ "vsd","application/vnd.visio"},
{ "wbxml","application/vnd.wap.wbxml"},
{ "wmlc","application/vnd.wap.wmlc"},
{ "wmlsc","application/vnd.wap.wmlscriptc"},
{ "wpd","application/vnd.wordperfect"},
{ "wp5","application/vnd.wordperfect5.1"},
{ "wk","application/x-123"},
{ "7z","application/x-7z-compressed"},
{ "abw","application/x-abiword"},
{ "dmg","application/x-apple-diskimage"},
{ "bcpio","application/x-bcpio"},
{ "torrent","application/x-bittorrent"},
{ "cab","application/x-cab"},
{ "cbr","application/x-cbr"},
{ "cbz","application/x-cbz"},
{ "cdf","application/x-cdf"},
{ "cda","application/x-cdf"},
{ "vcd","application/x-cdlink"},
{ "pgn","application/x-chess-pgn"},
{ "mph","application/x-comsol"},
{ "cpio","application/x-cpio"},
{ "csh","application/x-csh"},
{ "deb","application/x-debian-package"},
{ "udeb","application/x-debian-package"},
{ "dcr","application/x-director"},
{ "dir","application/x-director"},
{ "dxr","application/x-director"},
{ "dms","application/x-dms"},
{ "wad","application/x-doom"},
{ "dvi","application/x-dvi"},
{ "pfa","application/x-font"},
{ "pfb","application/x-font"},
{ "gsf","application/x-font"},
{ "pcf","application/x-font"},
{ "pcf.Z","application/x-font"},
{ "woff","application/x-font-woff"},
{ "mm","application/x-freemind"},
{ "spl","application/x-futuresplash"},
{ "gan","application/x-ganttproject"},
{ "gnumeric","application/x-gnumeric"},
{ "sgf","application/x-go-sgf"},
{ "gcf","application/x-graphing-calculator"},
{ "gtar","application/x-gtar"},
{ "tgz","application/x-gtar-compressed"},
{ "taz","application/x-gtar-compressed"},
{ "hdf","application/x-hdf"},
{ "hwp","application/x-hwp"},
{ "ica","application/x-ica"},
{ "info","application/x-info"},
{ "ins","application/x-internet-signup"},
{ "isp","application/x-internet-signup"},
{ "iii","application/x-iphone"},
{ "iso","application/x-iso9660-image"},
{ "jam","application/x-jam"},
{ "jnlp","application/x-java-jnlp-file"},
{ "jmz","application/x-jmol"},
{ "chrt","application/x-kchart"},
{ "kil","application/x-killustrator"},
{ "skp","application/x-koan"},
{ "skd","application/x-koan"},
{ "skt","application/x-koan"},
{ "skm","application/x-koan"},
{ "kpr","application/x-kpresenter"},
{ "kpt","application/x-kpresenter"},
{ "ksp","application/x-kspread"},
{ "kwd","application/x-kword"},
{ "kwt","application/x-kword"},
{ "latex","application/x-latex"},
{ "lha","application/x-lha"},
{ "lyx","application/x-lyx"},
{ "lzh","application/x-lzh"},
{ "lzx","application/x-lzx"},
{ "frm","application/x-maker"},
{ "maker","application/x-maker"},
{ "frame","application/x-maker"},
{ "fm","application/x-maker"},
{ "fb","application/x-maker"},
{ "book","application/x-maker"},
{ "fbdoc","application/x-maker"},
{ "md5","application/x-md5"},
{ "mif","application/x-mif"},
{ "m3u8","application/x-mpegURL"},
{ "wmd","application/x-ms-wmd"},
{ "wmz","application/x-ms-wmz"},
{ "com","application/x-msdos-program"},
{ "exe","application/x-msdos-program"},
{ "bat","application/x-msdos-program"},
{ "dll","application/x-msdos-program"},
{ "msi","application/x-msi"},
{ "nc","application/x-netcdf"},
{ "pac","application/x-ns-proxy-autoconfig"},
{ "dat","application/x-ns-proxy-autoconfig"},
{ "nwc","application/x-nwc"},
{ "o","application/x-object"},
{ "oza","application/x-oz-application"},
{ "p7r","application/x-pkcs7-certreqresp"},
{ "crl","application/x-pkcs7-crl"},
{ "pyc","application/x-python-code"},
{ "pyo","application/x-python-code"},
{ "qgs","application/x-qgis"},
{ "shp","application/x-qgis"},
{ "shx","application/x-qgis"},
{ "qtl","application/x-quicktimeplayer"},
{ "rdp","application/x-rdp"},
{ "rpm","application/x-redhat-package-manager"},
{ "rss","application/x-rss+xml"},
{ "rb","application/x-ruby"},
{ "sci","application/x-scilab"},
{ "sce","application/x-scilab"},
{ "xcos","application/x-scilab-xcos"},
{ "sh","application/x-sh"},
{ "sha1","application/x-sha1"},
{ "shar","application/x-shar"},
{ "swf","application/x-shockwave-flash"},
{ "swfl","application/x-shockwave-flash"},
{ "scr","application/x-silverlight"},
{ "sql","application/x-sql"},
{ "sit","application/x-stuffit"},
{ "sitx","application/x-stuffit"},
{ "sv4cpio","application/x-sv4cpio"},
{ "sv4crc","application/x-sv4crc"},
{ "tar","application/x-tar"},
{ "tcl","application/x-tcl"},
{ "gf","application/x-tex-gf"},
{ "pk","application/x-tex-pk"},
{ "texinfo","application/x-texinfo"},
{ "texi","application/x-texinfo"},
{ "~","application/x-trash"},
{ "%","application/x-trash"},
{ "bak","application/x-trash"},
{ "old","application/x-trash"},
{ "sik","application/x-trash"},
{ "t","application/x-troff"},
{ "tr","application/x-troff"},
{ "roff","application/x-troff"},
{ "man","application/x-troff-man"},
{ "me","application/x-troff-me"},
{ "ms","application/x-troff-ms"},
{ "ustar","application/x-ustar"},
{ "src","application/x-wais-source"},
{ "wz","application/x-wingz"},
{ "crt","application/x-x509-ca-cert"},
{ "xcf","application/x-xcf"},
{ "fig","application/x-xfig"},
{ "xpi","application/x-xpinstall"},
{ "amr","audio/amr"},
{ "awb","audio/amr-wb"},
{ "amr","audio/amr"},
{ "awb","audio/amr-wb"},
{ "axa","audio/annodex"},
{ "au","audio/basic"},
{ "snd","audio/basic"},
{ "csd","audio/csound"},
{ "orc","audio/csound"},
{ "sco","audio/csound"},
{ "flac","audio/flac"},
{ "mid","audio/midi"},
{ "midi","audio/midi"},
{ "kar","audio/midi"},
{ "mpga","audio/mpeg"},
{ "mpega","audio/mpeg"},
{ "mp2","audio/mpeg"},
{ "mp3","audio/mpeg"},
{ "m4a","audio/mpeg"},
{ "m3u","audio/mpegurl"},
{ "oga","audio/ogg"},
{ "ogg","audio/ogg"},
{ "spx","audio/ogg"},
{ "sid","audio/prs.sid"},
{ "aif","audio/x-aiff"},
{ "aiff","audio/x-aiff"},
{ "aifc","audio/x-aiff"},
{ "gsm","audio/x-gsm"},
{ "m3u","audio/x-mpegurl"},
{ "wma","audio/x-ms-wma"},
{ "wax","audio/x-ms-wax"},
{ "ra","audio/x-pn-realaudio"},
{ "rm","audio/x-pn-realaudio"},
{ "ram","audio/x-pn-realaudio"},
{ "ra","audio/x-realaudio"},
{ "pls","audio/x-scpls"},
{ "sd2","audio/x-sd2"},
{ "wav","audio/x-wav"},
{ "alc","chemical/x-alchemy"},
{ "cac","chemical/x-cache"},
{ "cache","chemical/x-cache"},
{ "csf","chemical/x-cache-csf"},
{ "cbin","chemical/x-cactvs-binary"},
{ "cascii","chemical/x-cactvs-binary"},
{ "ctab","chemical/x-cactvs-binary"},
{ "cdx","chemical/x-cdx"},
{ "cer","chemical/x-cerius"},
{ "c3d","chemical/x-chem3d"},
{ "chm","chemical/x-chemdraw"},
{ "cif","chemical/x-cif"},
{ "cmdf","chemical/x-cmdf"},
{ "cml","chemical/x-cml"},
{ "cpa","chemical/x-compass"},
{ "bsd","chemical/x-crossfire"},
{ "csml","chemical/x-csml"},
{ "csm","chemical/x-csml"},
{ "ctx","chemical/x-ctx"},
{ "cxf","chemical/x-cxf"},
{ "cef","chemical/x-cxf"},
{ "emb","chemical/x-embl-dl-nucleotide"},
{ "embl","chemical/x-embl-dl-nucleotide"},
{ "spc","chemical/x-galactic-spc"},
{ "inp","chemical/x-gamess-input"},
{ "gam","chemical/x-gamess-input"},
{ "gamin","chemical/x-gamess-input"},
{ "fch","chemical/x-gaussian-checkpoint"},
{ "fchk","chemical/x-gaussian-checkpoint"},
{ "cub","chemical/x-gaussian-cube"},
{ "gau","chemical/x-gaussian-input"},
{ "gjc","chemical/x-gaussian-input"},
{ "gjf","chemical/x-gaussian-input"},
{ "gal","chemical/x-gaussian-log"},
{ "gcg","chemical/x-gcg8-sequence"},
{ "gen","chemical/x-genbank"},
{ "hin","chemical/x-hin"},
{ "istr","chemical/x-isostar"},
{ "ist","chemical/x-isostar"},
{ "jdx","chemical/x-jcamp-dx"},
{ "dx","chemical/x-jcamp-dx"},
{ "kin","chemical/x-kinemage"},
{ "mcm","chemical/x-macmolecule"},
{ "mmd","chemical/x-macromodel-input"},
{ "mmod","chemical/x-macromodel-input"},
{ "mol","chemical/x-mdl-molfile"},
{ "rd","chemical/x-mdl-rdfile"},
{ "rxn","chemical/x-mdl-rxnfile"},
{ "sd","chemical/x-mdl-sdfile"},
{ "sdf","chemical/x-mdl-sdfile"},
{ "tgf","chemical/x-mdl-tgf"},
{ "mcif","chemical/x-mmcif"},
{ "mol2","chemical/x-mol2"},
{ "b","chemical/x-molconn-Z"},
{ "gpt","chemical/x-mopac-graph"},
{ "mop","chemical/x-mopac-input"},
{ "mopcrt","chemical/x-mopac-input"},
{ "mpc","chemical/x-mopac-input"},
{ "zmt","chemical/x-mopac-input"},
{ "moo","chemical/x-mopac-out"},
{ "mvb","chemical/x-mopac-vib"},
{ "asn","chemical/x-ncbi-asn1"},
{ "prt","chemical/x-ncbi-asn1-ascii"},
{ "ent","chemical/x-ncbi-asn1-ascii"},
{ "val","chemical/x-ncbi-asn1-binary"},
{ "aso","chemical/x-ncbi-asn1-binary"},
{ "asn","chemical/x-ncbi-asn1-spec"},
{ "pdb","chemical/x-pdb"},
{ "ent","chemical/x-pdb"},
{ "ros","chemical/x-rosdal"},
{ "sw","chemical/x-swissprot"},
{ "vms","chemical/x-vamas-iso14976"},
{ "vmd","chemical/x-vmd"},
{ "xtel","chemical/x-xtel"},
{ "xyz","chemical/x-xyz"},
{ "gif","image/gif"},
{ "ief","image/ief"},
{ "jpeg","image/jpeg"},
{ "jpg","image/jpeg"},
{ "jpe","image/jpeg"},
{ "pcx","image/pcx"},
{ "png","image/png"},
{ "svg","image/svg+xml"},
{ "svgz","image/svg+xml"},
{ "tiff","image/tiff"},
{ "tif","image/tiff"},
{ "djvu","image/vnd.djvu"},
{ "djv","image/vnd.djvu"},
{ "ico","image/vnd.microsoft.icon"},
{ "wbmp","image/vnd.wap.wbmp"},
{ "cr2","image/x-canon-cr2"},
{ "crw","image/x-canon-crw"},
{ "ras","image/x-cmu-raster"},
{ "cdr","image/x-coreldraw"},
{ "pat","image/x-coreldrawpattern"},
{ "cdt","image/x-coreldrawtemplate"},
{ "cpt","image/x-corelphotopaint"},
{ "erf","image/x-epson-erf"},
{ "art","image/x-jg"},
{ "jng","image/x-jng"},
{ "bmp","image/x-ms-bmp"},
{ "nef","image/x-nikon-nef"},
{ "orf","image/x-olympus-orf"},
{ "psd","image/x-photoshop"},
{ "pnm","image/x-portable-anymap"},
{ "pbm","image/x-portable-bitmap"},
{ "pgm","image/x-portable-graymap"},
{ "ppm","image/x-portable-pixmap"},
{ "rgb","image/x-rgb"},
{ "xbm","image/x-xbitmap"},
{ "xpm","image/x-xpixmap"},
{ "xwd","image/x-xwindowdump"},
{ "eml","message/rfc822"},
{ "igs","model/iges"},
{ "iges","model/iges"},
{ "msh","model/mesh"},
{ "mesh","model/mesh"},
{ "silo","model/mesh"},
{ "wrl","model/vrml"},
{ "vrml","model/vrml"},
{ "x3dv","model/x3d+vrml"},
{ "x3d","model/x3d+xml"},
{ "x3db","model/x3d+binary"},
{ "appcache","text/cache-manifest"},
{ "ics","text/calendar"},
{ "icz","text/calendar"},
{ "css","text/css"},
{ "csv","text/csv"},
{ "323","text/h323"},
{ "html","text/html"},
{ "htm","text/html"},
{ "shtml","text/html"},
{ "uls","text/iuls"},
{ "mml","text/mathml"},
{ "asc","text/plain"},
{ "txt","text/plain"},
{ "text","text/plain"},
{ "pot","text/plain"},
{ "brf","text/plain"},
{ "srt","text/plain"},
{ "rtx","text/richtext"},
{ "sct","text/scriptlet"},
{ "wsc","text/scriptlet"},
{ "tm","text/texmacs"},
{ "tsv","text/tab-separated-values"},
{ "jad","text/vnd.sun.j2me.app-descriptor"},
{ "wml","text/vnd.wap.wml"},
{ "wmls","text/vnd.wap.wmlscript"},
{ "bib","text/x-bibtex"},
{ "boo","text/x-boo"},
{ "h++","text/x-c++hdr"},
{ "hpp","text/x-c++hdr"},
{ "hxx","text/x-c++hdr"},
{ "hh","text/x-c++hdr"},
{ "c++","text/x-c++src"},
{ "cpp","text/x-c++src"},
{ "cxx","text/x-c++src"},
{ "cc","text/x-c++src"},
{ "h","text/x-chdr"},
{ "htc","text/x-component"},
{ "csh","text/x-csh"},
{ "c","text/x-csrc"},
{ "d","text/x-dsrc"},
{ "diff","text/x-diff"},
{ "patch","text/x-diff"},
{ "hs","text/x-haskell"},
{ "java","text/x-java"},
{ "ly","text/x-lilypond"},
{ "lhs","text/x-literate-haskell"},
{ "moc","text/x-moc"},
{ "p","text/x-pascal"},
{ "pas","text/x-pascal"},
{ "gcd","text/x-pcs-gcd"},
{ "pl","text/x-perl"},
{ "pm","text/x-perl"},
{ "py","text/x-python"},
{ "scala","text/x-scala"},
{ "etx","text/x-setext"},
{ "sfv","text/x-sfv"},
{ "sh","text/x-sh"},
{ "tcl","text/x-tcl"},
{ "tk","text/x-tcl"},
{ "tex","text/x-tex"},
{ "ltx","text/x-tex"},
{ "sty","text/x-tex"},
{ "cls","text/x-tex"},
{ "vcs","text/x-vcalendar"},
{ "vcf","text/x-vcard"},
{ "3gp","video/3gpp"},
{ "axv","video/annodex"},
{ "dl","video/dl"},
{ "dif","video/dv"},
{ "dv","video/dv"},
{ "fli","video/fli"},
{ "gl","video/gl"},
{ "mpeg","video/mpeg"},
{ "mpg","video/mpeg"},
{ "mpe","video/mpeg"},
{ "ts","video/MP2T"},
{ "mp4","video/mp4"},
{ "qt","video/quicktime"},
{ "mov","video/quicktime"},
{ "ogv","video/ogg"},
{ "webm","video/webm"},
{ "mxu","video/vnd.mpegurl"},
{ "flv","video/x-flv"},
{ "lsf","video/x-la-asf"},
{ "lsx","video/x-la-asf"},
{ "mng","video/x-mng"},
{ "asf","video/x-ms-asf"},
{ "asx","video/x-ms-asf"},
{ "wm","video/x-ms-wm"},
{ "wmv","video/x-ms-wmv"},
{ "wmx","video/x-ms-wmx"},
{ "wvx","video/x-ms-wvx"},
{ "avi","video/x-msvideo"},
{ "movie","video/x-sgi-movie"},
{ "mpv","video/x-matroska"},
{ "mkv","video/x-matroska"},
{ "ice","x-conference/x-cooltalk"},
{ "sisx","x-epoc/x-sisx-app"},
{ "vrm","x-world/x-vrml"},
{ "vrml","x-world/x-vrml"},
{ "wrl","x-world/x-vrml"},
+12
View File
@@ -0,0 +1,12 @@
# File can contain address to send mail to
# A line can start with To: email_address,
# Cc: email_address, BCc: email_address or
# just addresses
# Any line starts with a # or ; is considered a comment
#muquit
#muquit@muquit.com
To: blah@example.com
Cc: foo@bar.com
jdoe@gmail.com
mjane@yahoo.com
+5
View File
@@ -0,0 +1,5 @@
1 this is a text file for msg body
2 this is a text file for msg body
3 this is a text file for msg body
4 this is a text file for msg body
5 this is a text file for msg body
+95
View File
@@ -0,0 +1,95 @@
Show server info
================
mailsend -v -info -port 587 -smtp smtp.gmail.com
mailsend -v -info -ssl -port 465 -smtp smtp.gmail.com
STARTTLS + AUTHENTICATION
=========================
mailsend -to user@gmail.com -from user@gmail.com
-starttls -port 587 -auth
-smtp smtp.gmail.com
-sub test +cc +bc -v
-user you -pass "your_password"
Note: Password can be set by env var SMTP_USER_PASS instead of -pass
SSL + AUTHENTICATION
====================
mailsend -to user@gmail.com -from user@gmail.com
-ssl -port 465 -auth
-smtp smtp.gmail.com
-sub test +cc +bc -v
-user you -pass "your_password"
As -auth is specified, CRAM-MD5, LOGIN, PLAIN will be tried in that order.
Use -auth-cram-md5, -auth-plan, -auth-login for specific auth mechanism.
Note: Password can be set by env var SMTP_USER_PASS instead of -pass
One line messages
=================
One line messages are specified with -M. Each message can have its own
MIME type, character set and encoding type:
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub "testing oneline messages"
-cs "us-ascii"
-enc-type "7bit"
-M "This is a test"
-cs "iso-8859-1"
-enc-type "8bit"
-M "Das Vetter ist schön!"
-cs "Big5"
-enc-type "base64"
-M "中文測試"
Attachments
===========
Only requirement of -attach is the path of the file. All other
attributes can be specified before -attach with appropriate
flags. Note: The flags must be specified correctly for each attachment,
otherwise the one specified in previous attachment will be used.
By default MIME type is guessed from filename extension, default
encoding type base64 is used:
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub "this is a test"
-attach "file.pdf" -attach "file.jpg"
But all espects of attachments can be controlled:
mailsend -f user@example.com -smtp 10.100.30.1
-t user@example.com -sub test
-mime-type "text/plain"
-enc-type "7bit"
-charset "us-ascii"
-attach "file.txt"
-enc-type "8bit"
-charset "iso-8859-1"
-attach "deutsch.txt"
-mime-type "image/gif"
-enc-type "base64"
-aname "flower.gif"
-attach "/usr/file.gif"
-mime-type "image/jpeg"
-enc-type "base64"
-attach "file.jpeg"
By default, content disposition of all atachments are attachment, use
-disposition "inline" to give hint to the mail reader to display it as
mail body. Look at FAQ# 1 for details.
Including a body
================
Only one file can be included as a body of the mail. If the
file is not us-ascii, the SMTP server has to support it. If you
include a binary file, result is undefined.
mailsend -f user@gmail -t user@example.com -smtp smtp.gamil.com
-port 587 -starttls -auth -user user@gmail.com -pass secret
-charset "utf-8"
-mime-type "text/plain"
-msg-body "file.txt"
+14
View File
@@ -0,0 +1,14 @@
bfish
muquit.com
muquit@muquit.com
muquit@localhost
This is the subject
Mail body starts here.
This file can be used to feed to the mailsend program.
The first line is the smtp server addess or IP address.
The second line is the domain used in SMTP HELO.
The third line is the From address.
The fourth line the To address/es. They can be command separated.
Right after the From, the mail body starts.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

+40
View File
@@ -0,0 +1,40 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id: mkinstalldirs,v 1.1 2000/09/20 19:05:51 gson Exp $
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env ruby
require 'iconv'
########################################################################
# convert ChangeLog to google code wiki
# muquit@muquit.com Mar-17-2013
########################################################################
class ChangeLogToWiki
ME = $0
ME_SHORT = File.basename(ME)
def initialize
$stdout.sync = true
@url = "https://mailsend.googlecode.com/svn/trunk/changelog2wiki.rb"
end
def kprint(line)
Kernel.print line
end
def escape_html(line)
line = line.gsub(/</,"`<")
line = line.gsub(/>/,">`")
return line
end
def doit
file = ''
file = Dir.pwd + "/ChangeLog" if File.exists?(Dir.pwd + "/ChangeLog")
file = Dir.pwd + "/ChangeLog.txt" if File.exists?(Dir.pwd + "/ChangeLog.txt")
f = File.open(file)
list_found = false
project=File.basename(Dir.pwd)
puts <<EOD
#summary ChangeLog of #{project}
#sidebar Toc
#labels Featured
<wiki:toc />
EOD
while ((line = f.gets))
line.chomp! if line
line.strip! if line
line = Iconv.conv('UTF-8', 'iso8859-1',line)
if line =~ /^=/
puts line
next
end
if line =~ /^[0-9]+\..*$/
puts "=#{line}="
next
end
if line =~ /^-/
line.gsub!(/^-/,"")
line = line.gsub("/\n","")
line = escape_html(line)
if list_found
kprint "\n *#{line}"
else
kprint " *#{line}"
end
list_found = true
else
if line =~ /^\([a-zA-Z]+-[0-9]+-[0-9]+\)$/
puts "\n_#{line}_"
list_found = false
else
next if line.length == 0
line = line.gsub("/\n","")
line = escape_html(line)
if list_found
kprint " #{line}"
else
puts " #{line}"
end
end
end
end
t = Time.new
puts <<EOD
----
This wiki is auto generated by [#{@url} #{ME_SHORT}] on #{t}.
EOD
end
end
if __FILE__ == $0
ChangeLogToWiki.new.doit
end
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env ruby
########################################################################
# make array of pointer to char from copyright file
# muquit@muquit.com Oct-12-2013
########################################################################
class CopyrightTwoArrayOfPointerToChar
ME = File.basename($0)
COPYRIGHT_FILE = Dir.pwd + "/COPYRIGHT"
def initialize
end
def doit
lines = File.readlines(COPYRIGHT_FILE)
if !lines
puts "Error: could not read #{COPYRIGHT_FILE}"
exit
end
t = Time.new
puts <<-EOF
#ifndef COPYRIGHT_H
#define COPYRIGHT_H
/*
** Automatically generated by #{ME}.
** #{t}
*/
static char
*mailsend_copyright[] =
{
EOF
lines.each do |line|
line.chomp!
line = line.gsub(/\"/,"\\\"")
puts "\"#{line}\","
end
puts <<-EOF
(char *) NULL
};
#endif /* COPYRIGHT_H */
EOF
end
end
if __FILE__ == $0
CopyrightTwoArrayOfPointerToChar.new.doit
end
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env ruby
# copy to mailsned_binary and add to svn
# muquit@muquit.com Mar-16-2013
require 'fileutils'
begin
version = nil
prog = Dir.pwd + "/mailsend"
l = `#{prog} -V 2>&1`
lines = l.split("\n")
lines.each do |line|
line = line.chomp
line = line.strip
if line =~ /.*mailsend v(.*)$/
version = $1
end
end
if version
to_dir = "../mailsend_bins/#{version}"
if !File.exists?(to_dir)
puts "Creating dir: #{to_dir}"
FileUtils.mkdir_p(to_dir)
end
files = []
files << "mailsend-#{version}.tar.gz"
files << "mailsend#{version}.exe.zip"
files << "mailsend_#{version}-ubuntu_i386.deb"
files.each do |file|
if !File.exists?(file)
puts "Error: File #{file} does not exist"
exit 1
end
puts "File: #{file} -> #{to_dir}"
FileUtils.cp(file,to_dir)
end
else
puts "Could not determine version"
end
rescue => e
puts "Error: #{e}"
end
+135
View File
@@ -0,0 +1,135 @@
#!/usr/bin/env ruby
########################################################################
# Generate google code wiki from mailsend -ex output
# Mar-17-2013
########################################################################
class GenerateMailsendExample
ME = $0
ME_SHORT = File.basename(ME)
PROG = Dir.pwd + "/mailsend"
def initialize
$stdout.sync = true
@url = "https://mailsend.googlecode.com/svn/trunk/ex2wiki.rb"
end
def error(msg)
puts "Error: #{msg}"
exit 1
end
def doit
if !File.exists?(PROG)
error "Program mailsend does not exist"
end
mhash = {}
a = []
last_header = nil
block_found = false
mailsend_found = false
header = nil
headers = []
o = `#{PROG} -ex`
new_lines = []
last_h = ''
lines = o.split("\n")
lines.each_index do |i|
line = lines[i]
line.chomp!
line.strip!
if line =~ /^Example .*$/
next
end
line1 = line
line1.chomp! if line1
line1.strip! if line1
line2 = lines[i + 1]
line2.chomp! if line2
line2.strip! if line2
if line2 =~ /^==.*$/
last_h = line1
if last_header && a
headers << last_header
mhash[last_header] = a
a = []
end
block_found = true
last_header = line1
header = line1
next
end
x = lines[i]
x.chomp! if x
x.strip! if x
if x !~ /^==.*$/
a << x;
end
end
# handle last one
headers << last_h
mhash[last_h] = a
puts <<EOD
#summary Examples of mailasend
#sidebar Toc
#labels Featured
<wiki:toc />
EOD
# print version info first
v = `mailsend -V 2>&1`.chomp
v = v.gsub('^\s+','')
puts <<-EOS
=VERSION=
These examples are generated using
{{{
$ mailsend -V
#{v}
}}}
EOS
headers.each do |h|
puts "=#{h}="
a = mhash[h]
a.each do |line|
next if line =~ /^==.*$/
if line =~ /^mailsend .*$/
puts "}}}" if mailsend_found
mailsend_found = true
puts "{{{"
puts " $ #{line}"
next
end
if line =~ /^-.*$/
puts " #{line}"
else
if mailsend_found && line.length == 0
puts "}}}"
mailsend_found = false
elsif mailsend_found && line !~ /^-.*$/
puts "}}}"
mailsend_found = false
else
puts " #{line}"
end
end
end
end
t = Time.new
puts <<EOD
}}}
----
This wiki is auto generated by [#{@url} #{ME_SHORT}] on #{t}.
EOD
end
end
if __FILE__ == $0
GenerateMailsendExample.new.doit
end
+193
View File
@@ -0,0 +1,193 @@
#!/usr/bin/env ruby
##################################################
# make a debian binary package for ubuntu
# muquit@muquit.com Mar-28-2012
##################################################
#
require 'fileutils'
class MakeDebianPackage
def initialize
@dirs = []
@dirs << Dir.pwd + "/debian/DEBIAN"
@dirs << Dir.pwd + "/debian/usr/bin"
@dirs << Dir.pwd + "/debian/usr/share/doc/mailsend"
@dirs << Dir.pwd + "/debian/usr/share/man/man1"
@depends = "libc6 (>= 2.4)" # XXX CHANGE if needed
@mailsend_ver = ''
@package_name = ''
@control_file = Dir.pwd + "/debian/DEBIAN/control"
end
def log(msg)
t = Time.new
puts "#{t}: #{msg}"
end
def check
file = Dir.pwd + "/mailsend"
if !File.exists?(file)
log "#{file} does not exist, compile first"
exit(1)
end
file = Dir.pwd + "/changelog.debian"
if !File.exists?(file)
log "#{file} does not exist, compile first"
exit(1)
end
end
def gen_control_file
mailsend_version
begin
f = File.open(@control_file, "w")
f.puts <<EOD
Package: mailsend
Section: utils
Version: #{@mailsend_ver}-ubuntu
Maintainer: Muhammad Muquit <muquit@muquit.com>
Installed-Size: 104
Homepage: http://muquit.com/muquit/software/mailsend/mailsend.html
Priority: optional
Architecture: i386
Depends: #{@depends}
Description: Send mail via SMTP protocol
mailsend is a simple command line program to send mail via SMTP protocol.
Among other things it supports ESMTP authentication and MIME attachments.
STARTTLS and SMTP over SSL is also supported. It was originally written
for Microsoft Windows but later on ported to Linux/Unix. The Homepage of
mailsend is at: http://muquit.com/muquit/software/mailsend/mailsend.html
License is BSD.
EOD
f.close
rescue => ex
log "Could not create '#{@control_file}' (#{ex})"
end
end
def gen_copyright
f = File.open("./debian/usr/share/doc/mailsend/COPYRIGHT", "w")
year = Time.new.year
f.puts <<EOD
mailsend
Copyright #{year} Muhammad Muquit <muquit@muquit.com>
License: BSD
On Debian systems, the full text of the BSD can be found at
/usr/share/common-licenses/BSD
EOD
f.close
end
def compress(file)
cmd = "gzip --force --best #{file}"
system(cmd)
end
def strip_binary(file)
cmd = "strip #{file}"
system(cmd)
end
def copy_files
FileUtils.copy("./mailsend", "./debian/usr/bin")
strip_binary("./debian/usr/bin/mailsend")
FileUtils.copy("./doc/mailsend.1.gz", "./debian/usr/share/man/man1")
file = "./debian/usr/share/doc/mailsend/changelog"
FileUtils.copy("./changelog.debian", file)
compress(file)
file = "./debian/usr/share/doc/mailsend/changelog.Debian"
FileUtils.copy("./changelog.debian", file)
compress(file)
end
def make_dirs
@dirs.each do |dir|
log "Make directory: #{dir}"
FileUtils.mkdir_p(dir)
end
end
def lintian
package_name = get_package_name
log "Running lintian on #{package_name}"
cmd = "lintian #{package_name}"
system(cmd)
end
def mailsend_version
ver = `./mailsend -V 2>&1`
a = ver.split("\n")
l = a[0].to_s.chomp
if l =~ /.*v(.*)$/
@mailsend_ver = $1
log "mailsend version: '#{@mailsend_ver}'"
else
log "Could not determine mailsend version"
exit(1)
end
end
def get_package_name
pname = "mailsend_#{@mailsend_ver}-ubuntu_i386.deb"
@package_name = pname
return pname
end
def make_package
package_name = get_package_name
FileUtils.remove("./debian.deb") if File.exists?("./debian.deb")
cmd = "fakeroot dpkg-deb --build debian"
log "Running: #{cmd}"
system(cmd)
FileUtils.mv("debian.deb", package_name)
log "Package: #{package_name}"
end
def print_install_inst
puts <<EOD
##########################################
To install the package, type:
sudo dpkg -i #{@package_name}
To remove the package, type:
sudo dpkg -r mailsend
##########################################
EOD
end
def doit
check
make_dirs
gen_control_file
gen_copyright
copy_files
make_package
lintian
print_install_inst
end
end
if __FILE__ == $0
deb = MakeDebianPackage.new
deb.doit
end
+108
View File
@@ -0,0 +1,108 @@
#!/usr/bin/env ruby
# make the minimal pod doc and then generate man page from it
# muquit@muquit.com Mar-27-2012
class MakeMailsendPod
PROG = Dir.pwd + "/mailsend"
def initialize
@mailsend_ver = ''
@copyright
end
def log(msg)
t = Time.new
puts "#{t}: #{msg}"
end
def mailsend_version
ver = `#{PROG} -V 2>&1`
a = ver.split("\n")
l = a[0].to_s.chomp
if l =~ /.*v(.*)$/
@mailsend_ver = $1
log "mailsend version: '#{@mailsend_ver}'"
else
log "Could not determine mailsend version"
exit(1)
end
end
def check_binary
if !File.exists?("#{PROG}")
log "#{PROG} does not exist. exiting"
exit
end
end
def gen_pod
synopsis = `#{PROG} -h`
ex = `#{PROG} -ex`
f = File.open(Dir.pwd + "/doc/mailsend.pod", "w")
f.puts <<EOD
=head1 NAME
mailsend - A command line program to send mail via SMTP protocol
=head1 SYNOPSYS
#{synopsis}
=head1 DESCRIPTION
mailsend is a simple command line program to send mail via SMTP protocol
for Windows, Linux/Unix.
For deatils, please look at the web page:
L<http://muquit.com/muquit/software/mailsend/mailsend.html>
=head1 EXAMPLES
#{ex}
=head1 SEE ALSO
Please look at the web page for latest version and documentation:
L<http://muquit.com/muquit/software/mailsend/mailsend.html>
=head1 LICENSE
#{@copyright}
=head1 AUTHOR
mailsend is written by Muhammad Muquit E<lt>muquit@muquit.comE<gt>.
Homepage: L<http://www.muquit.com/>.
EOD
;
f.close
end
def read_copyright
@copyright = File.read("./COPYRIGHT")
end
def gen_man
cmd = "pod2man --release \"mailsend #{@mailsend_ver}\" -c \"User Commands\" doc/mailsend.pod > doc/mailsend.1"
system(cmd)
# compress
cmd = "gzip --best -c doc/mailsend.1 > doc/mailsend.1.gz"
system(cmd)
end
def doit
check_binary
mailsend_version
read_copyright
gen_pod
gen_man
end
end
if __FILE__ == $0
MakeMailsendPod.new.doit
end
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env ruby
##################################################
# make examples.c file from misc/examples.
# muquit@muquit.com Dec-14-2013
##################################################
#
require 'fileutils'
class MakeExamples
ME = __FILE__
EXAMPLE_FILE = Dir.pwd + "/misc/examples.txt"
PROG = Dir.pwd + "/mailsend"
def initialize
end
def log(msg)
t = Time.new
puts "#{t}: #{msg}"
end
def make_examples
v = `#{PROG} -V 2>&1`
va = v.split("\n")
puts <<-EOF
#include "mailsend.h"
void show_examples(void)
{
(void) fprintf(stdout, "Examples of #{va[0]}\\n\\n");
(void) fprintf(stdout,
EOF
lines = File.read(EXAMPLE_FILE)
lines.each do |line|
line = line.chomp
line = line.gsub(/\"/,'\"')
if line.length == 0
puts " \"\\n\""
else
puts " \" #{line}\\n\""
end
end
puts <<-EOF
);
}
EOF
end
def doit
make_examples
end
end
if __FILE__ == $0
MakeExamples.new.doit
end
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env ruby
##################################################
# make mime_types.h file from mime.types file
# muquit@muquit.com Dec-14-2013
##################################################
#
require 'fileutils'
class MakeMimeTypesH
ME = __FILE__
MIME_TYPES_FILE = Dir.pwd + "/mime.types"
def initialize
end
def log(msg)
t = Time.new
puts "#{t}: #{msg}"
end
def make_mime_types_h
lines = File.read(MIME_TYPES_FILE) if File.exists?(MIME_TYPES_FILE)
t = Time.new
puts <<-EOF
/*
** WARNING: This file is auto generated. DO NOT MODIFY
** Generated by #{ME} from #{MIME_TYPES_FILE}
** #{t}
*/
EOF
linesa = lines.split("\n")
linesa.each do |line|
line.chomp if line
next if line =~ /^#/ || line.length == 0
if line =~ /(.+)\t+(.+)$/
type = $1
exts = $2
type = type.gsub(/\t+/,'')
extsa = exts.split("\s")
extsa.each do |e|
puts "{ \"#{e}\",\"#{type}\"},"
end
end
end
end
def doit
make_mime_types_h
end
end
if __FILE__ == $0
MakeMimeTypesH.new.doit
end
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby
# print the date in debian changelog format
# Example: Wed, 28 Mar 2012 20:45:31 -0400
# muquit@muquit.com Mar-28-2012
require 'date'
offset = DateTime.now.zone.to_s
offset = offset.sub(/:/,'')
t = Time.new
d = t.strftime("%a, %d %b %Y %H:%M:%S #{offset}")
puts " -- Muhammad Muquit <muquit@muquit.com> #{d}"
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env ruby
# If config.log exists, try to determine how the configure was run last time
# and generate Makefiles.
# muquit@muquit.com Apr-18-2012
class RunConfigure
def doit
cmd = "sh ./configure"
file = "./config.log"
if File.exists?(file)
f = File.open(file, "r")
while (line = f.gets)
line = line.chomp
# $ ./configure --with-openssl=/usr
if line =~ /^\s+\$ (.*configure.*)$/
cmd = $1
puts "line: #{line}\n";
break
end
end
f.close
end
puts cmd
system(cmd)
end
end
if __FILE__ == $0
r = RunConfigure.new
r.doit
end
+1
View File
@@ -0,0 +1 @@
$ ./configure --target=mipsel-linux --host=mipsel-linux --build=i686-pc-linux-gnu
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
# test
to="muquit@gmail.com"
from="muquit@muquit.com"
mailsend="./mailsend"
date=`date`
#$mailsend -v -d localhost -t $to +cc +bc -sub test \
# -from $from -a nf.jpg,image/jpeg,a -sub test
$mailsend -d localhost -t $to +cc +bc \
-from $from -sub "test-$date" ${1+"$@"}
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env ruby
########################################################
# update the debian changelog file with dch.
# To udpdate the changelog file:
# ./update_deb_changelog.rb
# To increment the version:
# ./update_deb_changelog.rb blah
# muquit@muquit.com May-11-2012
########################################################
class UpdateDebianChangelog
def initialize
ENV['CHANGELOG'] = Dir.pwd + '/changelog.debian'
ENV['DEBFULLNAME'] = 'Muhammad Muquit'
ENV['DEBEMAIL'] = 'muquit@muquit.com'
ENV['VISUAL'] = 'vi'
end
def doit
if ARGV.length > 0
system("dch -i")
else
system("dch")
end
end
end
if __FILE__ == $0
dcl = UpdateDebianChangelog.new.doit
end

Some files were not shown because too many files have changed in this diff Show More