diff --git a/Docs/ConfigFile.txt b/Docs/ConfigFile.txt new file mode 100644 index 0000000..f228b7c --- /dev/null +++ b/Docs/ConfigFile.txt @@ -0,0 +1,50 @@ +Movgrab supports a preferences file, either a global one in /etc/movgrab.conf or a per user in ~/.movgrab.conf. + +Entries in the file can be: + +mediafmt + + A comma-seperated list of preferred file formats and resolutions in preference order, for example: + +mediafmt mp4:480x360,mp4,webm,mp3,* + + + +player + + Entries of this form are used in combination with the '-P auto' command line option. Each entry defines a player program for a particular content-type, as in the following examples. + + player audio/mpeg /usr/bin/mpg123 + player audio/ogg /usr/bin/ogg123 + player application/ogg /usr/bin/ogg123 + player * /usr/bin/mplayer + + + +useragent + + Sets the useragent string to be used in http/https communications. + + + +proxy + + Sets a proxy to be used for network access. The url is in the form :@::, for example: + + socks4:192.168.1.1:8080 + socks5:user1:secret@192.168.1.1:5050 + http:192.168.6.6:1080 + + + +ssllevel + + Minium ssl version to use. Options are: ssl, tls, tls1.1, tls1.2 (note, 'ssl' is SSLv3) + + + +sslciphers + + list of permitted ssl ciphers + + diff --git a/Docs/Proxys.txt b/Docs/Proxys.txt index efa219d..bfa668f 100755 --- a/Docs/Proxys.txt +++ b/Docs/Proxys.txt @@ -21,7 +21,7 @@ This is particularly useful in combination with ssh. The ssh command: will connect to 'myhost' and open a socks4/socks5 proxy service locally on port 5050. Movgrab can then be told: - movgrab -p 127.0.0.1:5050 http://www.youtube.com/?watch=ejfelefffDD + movgrab -p 127.0.0.1:5050 http://www.youtube.com/watch?v=5Lp-rXQqwH8 and all it's communications will be routed through ssh and appear to come from 'myhost'. diff --git a/Docs/Radio.txt b/Docs/Radio.txt index 1cc47a8..b00184a 100755 --- a/Docs/Radio.txt +++ b/Docs/Radio.txt @@ -14,7 +14,7 @@ Similarly mpg123 can be used thusly movgrab -o - 'http://www.triplag.com/webradio/darkpsy/triplag-darkpsy-playlist.asx' | mpg123 - -For ogg-vorbis streams there's "ogg123" which comes as part of the vorbis distrobution. +For ogg-vorbis streams there's "ogg123" which comes as part of the vorbis distribution. Of course, movgrab can also write the stream to a file, diff --git a/Makefile b/Makefile index a7da963..9cd0a18 100644 --- a/Makefile +++ b/Makefile @@ -7,14 +7,14 @@ prefix=/usr/local bindir=$(prefix)${exec_prefix}/bin DESTDIR= FLAGS=$(CFLAGS) -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_LIBZ=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBSSL=1 -DHAVE_LIBCRYPTO=1 -OBJ=common.o settings.o containerfiles.o outputfiles.o servicetypes.o extract_text.o download.o display.o selectformat.o ehow.o ign.o youtube.o +OBJ=common.o settings.o containerfiles.o outputfiles.o servicetypes.o extract_text.o download.o display.o players.o selectformat.o ehow.o ign.o youtube.o all: $(OBJ) - @cd libUseful-2.6; $(MAKE) - $(CC) $(FLAGS) -o movgrab main.c $(LIBS) $(OBJ) libUseful-2.6/libUseful-2.6.a + @cd libUseful-2.8; $(MAKE) + $(CC) $(FLAGS) -o movgrab main.c $(LIBS) $(OBJ) libUseful-2.8/libUseful-2.8.a clean: - @rm -f movgrab *.o libUseful-2.6/*.o libUseful-2.6/*.a libUseful-2.6/*.so + @rm -f movgrab *.o libUseful-2.8/*.o libUseful-2.8/*.a libUseful-2.8/*.so common.o: common.c common.h $(CC) $(FLAGS) -c common.c @@ -46,6 +46,9 @@ download.o: download.c download.h display.o: display.c display.h $(CC) $(FLAGS) -c display.c +players.o: players.c players.h + $(CC) $(FLAGS) -c players.c + selectformat.o: selectformat.c selectformat.h $(CC) $(FLAGS) -c selectformat.c diff --git a/Makefile.in b/Makefile.in index e99ff5d..5623a19 100755 --- a/Makefile.in +++ b/Makefile.in @@ -7,14 +7,14 @@ prefix=@prefix@ bindir=$(prefix)@bindir@ DESTDIR= FLAGS=$(CFLAGS) @DEFS@ -OBJ=common.o settings.o containerfiles.o outputfiles.o servicetypes.o extract_text.o download.o display.o selectformat.o ehow.o ign.o youtube.o +OBJ=common.o settings.o containerfiles.o outputfiles.o servicetypes.o extract_text.o download.o display.o players.o selectformat.o ehow.o ign.o youtube.o all: $(OBJ) - @cd libUseful-2.6; $(MAKE) - $(CC) $(FLAGS) -o movgrab main.c $(LIBS) $(OBJ) libUseful-2.6/libUseful-2.6.a + @cd libUseful-2.8; $(MAKE) + $(CC) $(FLAGS) -o movgrab main.c $(LIBS) $(OBJ) libUseful-2.8/libUseful-2.8.a clean: - @rm -f movgrab *.o libUseful-2.6/*.o libUseful-2.6/*.a libUseful-2.6/*.so + @rm -f movgrab *.o libUseful-2.8/*.o libUseful-2.8/*.a libUseful-2.8/*.so common.o: common.c common.h $(CC) $(FLAGS) -c common.c @@ -46,6 +46,9 @@ download.o: download.c download.h display.o: display.c display.h $(CC) $(FLAGS) -c display.c +players.o: players.c players.h + $(CC) $(FLAGS) -c players.c + selectformat.o: selectformat.c selectformat.h $(CC) $(FLAGS) -c selectformat.c diff --git a/common.c b/common.c index 47a8cf4..af924ca 100755 --- a/common.c +++ b/common.c @@ -1,14 +1,9 @@ #include "common.h" #include "download.h" -char *FileTypes[]={".flv",".mp3",".mp4",".mov",".wma",".m4a",".m4v",".wmv",".webm",".avi",".3gp","m3u8",NULL}; -char *ItemSelectionArg=NULL; -char *NowPlayingFile=NULL; -char *FormatPreference=NULL; +char *FileTypes[]={".flv",".mp3",".ogg",".aac",".mp4",".mov",".wma",".m4a",".m4v",".wmv",".webm",".avi",".3gp","m3u8",NULL}; char *Username=NULL, *Password=NULL; -char *Proxy=NULL; -char *ProgName=NULL, *CmdLine=NULL, *UserAgent=NULL; -int STREAMTimeout=300; +char *ProgName=NULL, *CmdLine=NULL; STREAM *StdIn=NULL; int Flags=0; @@ -117,7 +112,7 @@ if (STREAMCheckForBytes(StdIn)) { Tempstr=STREAMReadLine(Tempstr,StdIn); StripTrailingWhitespace(Tempstr); - if (StrLen(Tempstr)) + if (StrValid(Tempstr)) { ListAddItem(DownloadQueue,CopyStr(NULL,Tempstr)); if (! (Flags & FLAG_QUIET)) fprintf(stderr,"\r\nQUEUED: %s\n",Tempstr); diff --git a/common.h b/common.h index 6064e61..286e08e 100755 --- a/common.h +++ b/common.h @@ -3,9 +3,9 @@ #define MOVGRAB_COMMON //This is doable through autoconf, but I'm sick of fighting with it -#define Version "3.0.3" +#define Version "3.1.0" -#include "libUseful-2.6/libUseful.h" +#include "libUseful-2.8/libUseful.h" #include #include #include "extract_text.h" @@ -30,6 +30,7 @@ #define FLAG_RESUME 65536 #define FLAG_HTTPS 131072 #define FLAG_POST 262144 +#define FLAG_PLAYER_AUTO 524288 extern int Type, Flags; diff --git a/configure b/configure index 5633922..a3f8b12 100755 --- a/configure +++ b/configure @@ -655,7 +655,7 @@ LDFLAGS LIBS CPPFLAGS CPP' -ac_subdirs_all='libUseful-2.6' +ac_subdirs_all='libUseful-2.8' # Initialize some variables set by options. ac_init_help= @@ -1904,7 +1904,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. -subdirs="$subdirs libUseful-2.6" +subdirs="$subdirs libUseful-2.8" ac_ext=c diff --git a/configure.ac b/configure.ac index f212d7e..ec2464a 100755 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ AC_INIT([main.c]) VERSION="1.2.1" AC_SUBST(VERSION) -AC_CONFIG_SUBDIRS([libUseful-2.6]) +AC_CONFIG_SUBDIRS([libUseful-2.8]) AC_PROG_CC AC_LANG_C diff --git a/display.c b/display.c index 2e7e407..58a7b03 100755 --- a/display.c +++ b/display.c @@ -1,23 +1,11 @@ #include "display.h" #include "outputfiles.h" +#include "settings.h" -pid_t PlayerPid=0; -char *Player=NULL; -int PlayerLaunchPercent=25; int DisplayTitleWidth=50; extern char *CmdLine, *ProgName; -//this shouldn't really be in here, but the decision to launch an player happens in the 'DisplayProgress' function -void LaunchPlayer() -{ -char *Tempstr=NULL; - -Tempstr=MCopyStr(Tempstr,Player," ",OutputFilesGetFilePath(),NULL); -PlayerPid=Spawn(Tempstr,0,""); - -DestroyString(Tempstr); -} int DisplayAvailableFormats(ListNode *Vars, char *Formats, int ShowSize) @@ -26,12 +14,12 @@ char *URL=NULL, *Token=NULL, *TokenID=NULL, *Tempstr=NULL, *ptr; STREAM *S; int result=TRUE; -fprintf(stderr, "\nFormats available for this Movie: "); +fprintf(stderr, "\nAvailable media formats: "); ptr=GetToken(Formats," ",&Token,0); while (ptr) { -if (StrLen(Token)) TokenID=MCopyStr(TokenID,"item:",Token,NULL); +if (StrValid(Token)) TokenID=MCopyStr(TokenID,"item:",Token,NULL); URL=CopyStr(URL,GetVar(Vars,TokenID)); @@ -45,16 +33,10 @@ if (strcmp(Token,"reference") !=0) if (S) { Tempstr=CopyStr(Tempstr,STREAMGetValue(S,"HTTP:ResponseCode")); - if (strcmp(Tempstr,"403") ==0) - { - fprintf(stderr,"\nERROR: %s response for %s\n",Tempstr,URL); - result=FALSE; - break; - } - else if (strcmp(Tempstr,"200")==0) + if (strcmp(Tempstr,"200")==0) { Tempstr=CopyStr(Tempstr,STREAMGetValue(S,"HTTP:Content-length")); - fprintf(stderr, " (%s)",GetHumanReadableDataQty(strtod(Tempstr,NULL),FALSE)); + fprintf(stderr, " (%s)",ToMetric(strtod(Tempstr,NULL),FALSE)); STREAMClose(S); } } @@ -80,7 +62,7 @@ void WriteNowPlayingFile(const char *Title) { STREAM *S; -S=STREAMOpenFile(NowPlayingFile, SF_WRONLY | SF_CREAT | SF_TRUNC); +S=STREAMFileOpen(Settings.NowPlayingFile, SF_WRONLY | SF_CREAT | SF_TRUNC); if (S) { STREAMWriteLine(Title, S); @@ -116,8 +98,8 @@ if (! (Flags & FLAG_QUIET)) { if (PrintName) { - fprintf(stderr,"\nGetting: %s Size: %s Format: %s\n",Title,GetHumanReadableDataQty(DocSize,0), Format); - if (StrLen(NowPlayingFile)) WriteNowPlayingFile(Title); + fprintf(stderr,"\nGetting: %s Size: %s Format: %s\n",Title,ToMetric(DocSize,0), Format); + if (StrValid(Settings.NowPlayingFile)) WriteNowPlayingFile(Title); } } @@ -127,12 +109,12 @@ BpsStr=CopyStr(BpsStr,""); if (SpeedStart > 0) { Bps=(bytes_read - PrevBytesRead) / (Now-SpeedStart); - BpsStr=MCopyStr(BpsStr,GetHumanReadableDataQty(Bps,0),"/s ",NULL); + BpsStr=MCopyStr(BpsStr,ToMetric(Bps,0),"/s ",NULL); } if (DocSize) { - HUDocSize=CopyStr(HUDocSize,GetHumanReadableDataQty(DocSize,0)); + HUDocSize=CopyStr(HUDocSize,ToMetric(DocSize,0)); Percent=bytes_read * 100.0 / DocSize; @@ -145,21 +127,22 @@ if (DocSize) } else ETAStr=CopyStr(ETAStr,"??:??"); - fprintf(stderr," Progress: %0.2f%% %s of %s %s ETA: %s \r",Percent,GetHumanReadableDataQty(bytes_read,0),HUDocSize,BpsStr,ETAStr); + fprintf(stderr," Progress: %0.2f%% %s of %s %s ETA: %s \r",Percent,ToMetric(bytes_read,0),HUDocSize,BpsStr,ETAStr); } sprintf(CmdLine,"%s %0.2f%% %s \0",ProgName,Percent,Title); - if ((PlayerPid==0) && (Percent > PlayerLaunchPercent) && (Player)) LaunchPlayer(); } else { - if (! (Flags & FLAG_QUIET)) fprintf(stderr," Progress: %s %s \r",GetHumanReadableDataQty((double) bytes_read,0),BpsStr); + if (! (Flags & FLAG_QUIET)) fprintf(stderr," Progress: %s %s \r",ToMetric((double) bytes_read,0),BpsStr); sprintf(CmdLine,"%s %s \0",ProgName,Title); } +if ((DocSize == 0) || (Percent > Settings.PlayerLaunchPercent)) LaunchPlayer(); + fflush(NULL); if (Now - SpeedStart > 5) { diff --git a/display.h b/display.h index 0c15527..ff4d181 100755 --- a/display.h +++ b/display.h @@ -3,7 +3,6 @@ #include "common.h" -extern char *Player; extern int DisplayTitleWidth; int DisplayAvailableFormats(ListNode *Vars, char *Formats, int ShowSize); diff --git a/download.c b/download.c index 7ab86a9..fd50318 100755 --- a/download.c +++ b/download.c @@ -3,6 +3,7 @@ #include "display.h" #include "containerfiles.h" #include "servicetypes.h" +#include "settings.h" /* Functions relating to connecting to hosts and downloading webpages. @@ -10,7 +11,6 @@ All the HTTP stuff is in here */ ListNode *DownloadQueue=NULL; -extern int STREAMTimeout; STREAM *ConnectAndSendHeaders(const char *URL, int Flags, double BytesRange) { @@ -27,7 +27,7 @@ Info=HTTPInfoFromURL(Method, URL); if (Flags & FLAG_DEBUG3) Info->Flags |= HTTP_DEBUG; //Info->Flags |= HTTP_DEBUG; -if (StrLen(LastPage)) SetVar(Info->CustomSendHeaders,"Referer",LastPage); +if (StrValid(LastPage)) SetVar(Info->CustomSendHeaders,"Referer",LastPage); LastPage=CopyStr(LastPage, URL); if (BytesRange > 0) @@ -41,10 +41,15 @@ SetVar(Info->CustomSendHeaders,"Icy-MetaData","1"); Con=HTTPTransact(Info); if ((! Con) && (! (Flags & FLAG_QUIET))) { - if (StrLen(Info->ResponseCode)) fprintf(stderr,"ERROR: Server %s item '%s' not retrieved\nResponseCode: %s\n",Info->Host, Info->Doc,Info->ResponseCode); + if (StrValid(Info->ResponseCode)) fprintf(stderr,"ERROR: Server %s item '%s' not retrieved\nResponseCode: %s\n",Info->Host, Info->Doc,Info->ResponseCode); else fprintf(stderr,"ERROR: Connection failed to %s can't get file=%s \n",Info->Host, Info->Doc); } - +else if (Flags & FLAG_DEBUG) +{ + ptr=STREAMGetValue(Con, "SSL-Cipher"); + if (StrValid(ptr)) fprintf(stderr,"HTTP-Response: %s SSL-Cipher: %s\n",STREAMGetValue(Con, "HTTP:ResponseCode"), STREAMGetValue(Con, "SSL-Cipher")); + else fprintf(stderr,"HTTP Response: %s\n",STREAMGetValue(Con, "HTTP:ResponseCode")); +} DestroyString(Tempstr); DestroyString(Method); @@ -143,7 +148,7 @@ unsigned long IcyInterval=0, BlockRemaining=0; Title=CopyStr(Title, InitialTitle); ptr=STREAMGetValue(Con,"HTTP:icy-metaint"); -if (StrLen(ptr)) IcyInterval=strtoul(ptr,NULL,10); +if (StrValid(ptr)) IcyInterval=strtoul(ptr,NULL,10); DisplayProgress(Title, Format, *BytesRead, DocSize, PrintName); @@ -220,15 +225,16 @@ if (Flags & FLAG_DEBUG) fprintf(stderr,"Next URL: %s\n",URL); if (! Con) Con=ConnectAndRetryUntilDownload(URL, Flags, BytesRead); if (Con) { + ContentType=CopyStr(ContentType, STREAMGetValue(Con,"HTTP:Content-Type")); //Some sites throttle excessively - STREAMSetTimeout(Con,STREAMTimeout); + STREAMSetTimeout(Con, Settings.STREAMTimeout); if (strncmp(Format,"m3u8-stream:",12)==0) RetVal=M3UStreamDownload(Con, URL, Title); else { if (! (Flags & FLAG_TEST_SITES)) OpenOutputFiles(Title,URL,&BytesRead); Token=CopyStr(Token,STREAMGetValue(Con,"HTTP:Content-Range")); - if (StrLen(Token)) + if (StrValid(Token)) { ptr=strrchr(Token,'/'); ptr++; @@ -237,19 +243,20 @@ if (Con) else { Token=CopyStr(Token,STREAMGetValue(Con,"HTTP:content-length")); - if (StrLen(Token)) DocSize=strtod(Token,NULL); + if (StrValid(Token)) DocSize=strtod(Token,NULL); } if (Flags & FLAG_TEST_SITES) RetVal=TRUE; else { + if (Flags & FLAG_PLAYER_AUTO) SelectPlayer(ContentType); RetVal=TransferItem(Con,Title, URL, Format, DocSize, DocSize, &BytesRead,TRUE); Tempstr=CopyStr(Tempstr,URL); ptr=strrchr(Tempstr,'?'); if (ptr) *ptr='\0'; - Extn=CopyStr(Extn,GuessExtn(GetVar(Con->Values,"HTTP:Content-Type"), Format, Tempstr)); + Extn=CopyStr(Extn,GuessExtn(ContentType, Format, Tempstr)); CloseOutputFiles(Extn); } } diff --git a/extract_text.c b/extract_text.c index 0926510..b6f8609 100755 --- a/extract_text.c +++ b/extract_text.c @@ -40,7 +40,7 @@ int GTF=0; if (ExtractFlags & EXTRACT_DEQUOTE) Item=HTTPUnQuote(Item,Token); - else if (ExtractFlags & EXTRACT_DEHTMLQUOTE) Item=HtmlUnQuote(Item,Token); + else if (ExtractFlags & EXTRACT_DEHTMLQUOTE) Item=HTMLUnQuote(Item,Token); else if (ExtractFlags & EXTRACT_DESLASHQUOTE) Item=UnQuoteStr(Item,Token); else Item=CopyStr(Item,Token); StripLeadingWhitespace(Item); diff --git a/ign.c b/ign.c index af059c7..a93e82b 100644 --- a/ign.c +++ b/ign.c @@ -18,7 +18,7 @@ if (strcmp("height",Name)==0) height=atoi(Value); ptr=GetNameValuePair(ptr,",",":",&Name,&Value); } -if (width && height && StrLen(URL)) +if (width && height && StrValid(URL)) { Value=FormatStr(Value,"item:mp4:%dx%d",width,height); SetVar(Vars,Value,URL); diff --git a/libUseful-2.6/Compression.c b/libUseful-2.6/Compression.c deleted file mode 100755 index 41c553b..0000000 --- a/libUseful-2.6/Compression.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "DataProcessing.h" - -int CompressBytes(char **Out, char *Alg, char *In, int Len, int Level) -{ -TProcessingModule *Mod=NULL; -char *Tempstr=NULL; -int result, val; - -Tempstr=FormatStr(Tempstr,"CompressionLevel=%d",Level); -Mod=StandardDataProcessorCreate("compression",Alg,Tempstr); -if (! Mod) return(-1); - -val=Len *2; -*Out=SetStrLen(*Out,val); -result=Mod->Write(Mod,In,Len,Out,&Len,TRUE); - -DestroyString(Tempstr); -DataProcessorDestroy(Mod); - -return(result); -} diff --git a/libUseful-2.6/Compression.h b/libUseful-2.6/Compression.h deleted file mode 100755 index 1019dbf..0000000 --- a/libUseful-2.6/Compression.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef LIBUSEFUL_COMPRESSION_H -#define LIBUSEFUL_COMPRESSION_H - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int CompressBytes(char **Out, char *Alg, char *In, int Len, int Level); - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/ConnectManager.c b/libUseful-2.6/ConnectManager.c deleted file mode 100755 index af2974e..0000000 --- a/libUseful-2.6/ConnectManager.c +++ /dev/null @@ -1,333 +0,0 @@ -#include "ConnectManager.h" -#include "socket.h" -#include "SpawnPrograms.h" - -ListNode *ConnectManServers=NULL; -ListNode *ConnectManClients=NULL; -ListNode *Timers=NULL; - - -int ConnectManagerAddServer(int sock, char *Name, CONNECT_FUNC OnConnect, ONDATA_FUNC OnData) -{ -TConnectManagerItem *Item; - -if (! ConnectManServers) ConnectManServers=ListCreate(); - -if (sock==-1) return(FALSE); - -Item=(TConnectManagerItem *) calloc(1,sizeof(TConnectManagerItem)); -Item->OnConnect=OnConnect; -Item->OnData=OnData; -Item->Data=(void *) STREAMFromFD(sock); -Item->Name=CopyStr(Item->Name,Name); - -ListAddItem(ConnectManServers,Item); -return(TRUE); -} - - - - -STREAM *ConnectManagerAddClient(char *Host, int Port, int Flags, char *Name, CONNECT_FUNC OnConnect, ONDATA_FUNC OnData) -{ -STREAM *S; -char *Tempstr=NULL; -TConnectManagerItem *Item; - -if (! ConnectManClients) ConnectManClients=ListCreate(); - -S=STREAMCreate(); - -Tempstr=FormatStr(Tempstr,"%s:%d",Host,Port); -if (! STREAMConnect(S,Tempstr,Flags)) -{ -STREAMClose(S); -DestroyString(Tempstr); -return(NULL); -} - -Item=(TConnectManagerItem *) calloc(1,sizeof(TConnectManagerItem)); -Item->OnConnect=OnConnect; -Item->OnData=OnData; -Item->Data=(void *) S; -Item->Name=CopyStr(Item->Name,Name); -Item->Host=CopyStr(Item->Host,Host); -Item->Port=Port; - -if (Item->OnConnect && STREAMIsConnected(S)) Item->OnConnect(Item); - -ListAddItem(ConnectManClients,Item); - -DestroyString(Tempstr); -return(S); -} - - - -TConnectManagerItem *ConnectManagerAddIncoming(STREAM *S, char *Name, ONDATA_FUNC OnData) -{ -TConnectManagerItem *Item=NULL; - -if (! ConnectManClients) ConnectManClients=ListCreate(); - -Item=(TConnectManagerItem *) calloc(1,sizeof(TConnectManagerItem)); -Item->OnData=OnData; -Item->Data=(void *) S; -Item->Name=CopyStr(Item->Name,Name); - -ListAddItem(ConnectManClients,Item); -return(Item); -} - - - - -int ConnectManagerAddTimer(int Secs, char *Name, ONTIMER_FUNC OnTime, void *Data) -{ -TConnectManagerItem *Item; - -if (! Timers) Timers=ListCreate(); - -Item=(TConnectManagerItem *) calloc(1,sizeof(TConnectManagerItem)); -Item->OnData=(ONDATA_FUNC) OnTime; -Item->Name=CopyStr(Item->Name,Name); -Item->TimerVal=Secs; -Item->LastTimerFire=time(NULL); -Item->Data=Data; - -ListAddItem(Timers,Item); -return(TRUE); -} - - - -int ConnectManagerCountNamedConnections(char *Name) -{ -TConnectManagerItem *Item; -ListNode *Curr; -int count=0; - - Curr=ListGetNext(ConnectManClients); - while (Curr) - { - Item=(TConnectManagerItem *) Curr->Item; - if (strcmp(Item->Name,Name)==0) count++; - Curr=ListGetNext(Curr); - } - -return(count); -} - - -STREAM *ConnectManagerGetStreamByName(char *Name) -{ -TConnectManagerItem *Item; -ListNode *Curr; - - Curr=ListGetNext(ConnectManClients); - while (Curr) - { - Item=(TConnectManagerItem *) Curr->Item; - if (strcmp(Item->Name,Name)==0) return((STREAM *) Item->Data); - Curr=ListGetNext(Curr); - } - -return(NULL); -} - - -ListNode *ConnectManagerGetConnectionList() -{ - return(ConnectManClients); -} - -void ConnectManagerMainLoop() -{ -TConnectManagerItem *Item, *NewItem; -ListNode *Curr, *Prev; -int highfd=0; -fd_set ReadSet, WriteSet; -int sock, result, SelectResult, NextTimerFire; -STREAM *S, *NewS; -time_t Now; -struct timeval tv; -int MoreData=FALSE; - -while (1) -{ - MoreData=FALSE; - time(&Now); - NextTimerFire=60; - Curr=ListGetNext(Timers); - while (Curr) - { - Item=(TConnectManagerItem *) Curr->Item; - if (Item->LastTimerFire==0) Item->LastTimerFire=Now; - result=(Item->LastTimerFire + Item->TimerVal) - Now; - if (result < NextTimerFire) NextTimerFire=result; - Curr=ListGetNext(Curr); - } - - - - FD_ZERO(&ReadSet); - FD_ZERO(&WriteSet); - Curr=ListGetNext(ConnectManServers); - while (Curr) - { - Item=(TConnectManagerItem *) Curr->Item; - S=(STREAM *) Item->Data; - FD_SET(S->in_fd,&ReadSet); - if (S->in_fd > highfd) highfd=S->in_fd; - Curr=ListGetNext(Curr); - } - - - Curr=ListGetNext(ConnectManClients); - while (Curr) - { - Item=(TConnectManagerItem *) Curr->Item; - S=(STREAM *) Item->Data; - if (! S) - { - ListDeleteNode(Curr); - continue; - } - - if (S->State & SS_CONNECTING) - { - FD_SET(S->in_fd,&WriteSet); - } - if (S->InEnd > S->InStart) MoreData=TRUE; - else - { - //always add to read set - FD_SET(S->in_fd,&ReadSet); - if (S->in_fd > highfd) highfd=S->in_fd; - } - - Curr=ListGetNext(Curr); - } - - if (MoreData) - { - tv.tv_usec = 10; - tv.tv_sec = 0; - SelectResult=0; - } - else - { - //SELECT!!! - tv.tv_usec = 20000; - tv.tv_sec = NextTimerFire; - } - SelectResult=select(highfd+1,&ReadSet,&WriteSet,NULL,&tv); - - - if (SelectResult > 0) - { - Curr=ListGetNext(ConnectManServers); - while (Curr) - { - Item=(TConnectManagerItem *) Curr->Item; - - S=(STREAM *) Item->Data; - if (! S) - { - ListDeleteNode(Curr); - continue; - } - - - if (FD_ISSET(S->in_fd,&ReadSet)) - { - sock=TCPServerSockAccept(S->in_fd,&S->Path); - if (sock > -1) - { - S=STREAMFromFD(sock); - STREAMSetFlushType(S,FLUSH_LINE,0,0); - NewItem=ConnectManagerAddIncoming(S,Item->Name, Item->OnData); - if (Item->OnConnect) Item->OnConnect(NewItem); - } - } - - Curr=ListGetNext(Curr); - } - } - - - Curr=ListGetNext(ConnectManClients); - while (Curr) - { - Item=(TConnectManagerItem *) Curr->Item; - S=(STREAM *) Item->Data; - if (! S) - { - ListDeleteNode(Curr); - continue; - } - - if ((SelectResult > 0) && FD_ISSET(S->in_fd,&WriteSet)) - { - if (S->State & SS_CONNECTING) - { - if (STREAMIsConnected(S)) - { - STREAMSetFlags(S, 0, SF_NONBLOCK); - if (Item->OnConnect) Item->OnConnect(Item); - } - - } - } - - if ( - (S->InEnd > S->InStart) || - ((SelectResult > 0) && (FD_ISSET(S->in_fd,&ReadSet))) - ) - { - if (! (S->State & SS_CONNECTING)) - { - if (Item->OnData) - { - result=Item->OnData(S, Item->Name); - if (! result) - { - STREAMClose(S); - Prev=ListGetPrev(Curr); - ListDeleteNode(Curr); - free(Item); - Curr=Prev; - } - else if (result==RECONNECT) - { - NewS=STREAMCreate(); - STREAMConnect(NewS, S->Path, CONNECT_NONBLOCK); - Item->Data=(void *) NewS; - STREAMClose(S); - } - - } - } - } - Curr=ListGetNext(Curr); - } - - - time(&Now); - Curr=ListGetNext(Timers); - while (Curr) - { - Item=(TConnectManagerItem *) Curr->Item; - if ( (Now - Item->LastTimerFire) >= Item->TimerVal ) - { - if (Item->OnData) ((ONTIMER_FUNC)Item->OnData)(Item->Data,Item->Name); - Item->LastTimerFire=Now; - } - Curr=ListGetNext(Curr); - } - - -} - -} - diff --git a/libUseful-2.6/ConnectManager.h b/libUseful-2.6/ConnectManager.h deleted file mode 100755 index 7330029..0000000 --- a/libUseful-2.6/ConnectManager.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef LIBUSEFUL_CONNECT_MANAGER_H -#define LIBUSEFUL_CONNECT_MANAGER_H - -#include "file.h" -#include "includes.h" - -#define RECONNECT 2 - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct t_con_man_item TConnectManagerItem; - - -typedef int (*CONNECT_FUNC)(TConnectManagerItem *Item); -typedef int (*ONDATA_FUNC)(STREAM *S, char *Name); -typedef int (*ONTIMER_FUNC)(void *Data, char *Name); - - - -struct t_con_man_item -{ -char *Name; -void *Data; -int TimerVal; -int LastTimerFire; -char *Host; -int Port; -CONNECT_FUNC OnConnect; -ONDATA_FUNC OnData; -}; - - -int ConnectManagerAddServer(int sock, char *Name, CONNECT_FUNC OnConnect, ONDATA_FUNC OnData); -STREAM *ConnectManagerAddClient(char *Host, int Port, int Flags, char *Name, CONNECT_FUNC OnConnect, ONDATA_FUNC OnData); -TConnectManagerItem *ConnectManagerAddIncoming(STREAM *S, char *Name, ONDATA_FUNC OnData); -int ConnectManagerAddTimer(int Secs, char *Name, ONTIMER_FUNC OnTime, void *Data); -int ConnectManagerCountNamedConnections(char *Name); -STREAM *ConnectManagerGetStreamByName(char *Name); -ListNode *ConnectManagerGetConnectionList(); -void ConnectManagerMainLoop(); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/ConnectionChain.c b/libUseful-2.6/ConnectionChain.c deleted file mode 100755 index 77029c2..0000000 --- a/libUseful-2.6/ConnectionChain.c +++ /dev/null @@ -1,547 +0,0 @@ -#include "ConnectionChain.h" -#include "ParseURL.h" -#include "SpawnPrograms.h" -#include "expect.h" - -const char *HopTypes[]={"none","direct","httpc","ssh","sshtunnel","socks4","socks5","shell","telnet",NULL}; -typedef enum {CONNECT_HOP_NONE, CONNECT_HOP_TCP, CONNECT_HOP_HTTPTUNNEL, CONNECT_HOP_SSH, CONNECT_HOP_SSHTUNNEL, CONNECT_HOP_SOCKS4, CONNECT_HOP_SOCKS5, CONNECT_HOP_SHELL_CMD, CONNECT_HOP_TELNET} THopTypes; - -char *GlobalConnectionChain=NULL; - -int SetGlobalConnectionChain(const char *Chain) -{ -char *Token=NULL, *Type=NULL, *ptr; -int result=TRUE; - -ptr=GetToken(Chain, ",", &Token, 0); -while (ptr) -{ - GetToken(Token,":",&Type,0); - if (MatchTokenFromList(Type, HopTypes, 0)==-1) result=FALSE; - ptr=GetToken(ptr, ",", &Token, 0); -} - -GlobalConnectionChain=CopyStr(GlobalConnectionChain, Chain); - -DestroyString(Token); -DestroyString(Type); -return(result); -} - - - -int DoHTTPProxyTunnel(STREAM *S, const char *Host, int Port, const char *Destination, int Flags) -{ -char *Tempstr=NULL, *Token=NULL; -const char *ptr=NULL; -int result=FALSE; - - S->in_fd=TCPConnect(Host,Port,0); - S->out_fd=S->in_fd; - if (S->in_fd == -1) return(FALSE); - - ptr=Destination; - if (strncmp(ptr,"tcp:",4)==0) ptr+=4; - Tempstr=FormatStr(Tempstr,"CONNECT %s HTTP/1.1\r\n\r\n",ptr); - - STREAMWriteLine(Tempstr,S); - STREAMFlush(S); - - Tempstr=STREAMReadLine(Tempstr,S); - StripTrailingWhitespace(Tempstr); - - ptr=GetToken(Tempstr," ",&Token,0); - ptr=GetToken(ptr," ",&Token,0); - - if (*Token=='2') result=TRUE; - while (StrLen(Tempstr)) - { - Tempstr=STREAMReadLine(Tempstr,S); - StripTrailingWhitespace(Tempstr); - } - -DestroyString(Tempstr); -DestroyString(Token); - -return(result); -} - - -#define HT_IP4 1 -#define HT_DOMAIN 3 -#define HT_IP6 4 - - -int ConnectHopSocks5Auth(STREAM *S, const char *User, const char *Pass) -{ -char *Tempstr=NULL, *ptr; -int result, RetVal=FALSE; -uint8_t len; - -Tempstr=SetStrLen(Tempstr, 10); - -//socks5 version -Tempstr[0]=5; -//Number of Auth Methods (just 1, username/password) -Tempstr[1]=1; -//Auth method 2, username/password -if (StrLen(User)) Tempstr[2]=2; -else Tempstr[2]=0; - - -STREAMWriteBytes(S,Tempstr,3); -STREAMFlush(S); - -result=STREAMReadBytes(S,Tempstr,10); -if ((result > 1) && (Tempstr[0]==5)) -{ - // Second Byte is authentication type selected by the server - switch (Tempstr[1]) - { - //no authentication required - case 0: - RetVal=TRUE; - break; - - //gssapi - case 1: - break; - - //username/password - case 2: - Tempstr=SetStrLen(Tempstr, StrLen(User) + StrLen(Pass) + 10); - ptr=Tempstr; - //version 1 of username/password authentication - *ptr=1; - ptr++; - - //username - len=StrLen(User) & 0xFF; - *ptr=len; - ptr++; - memcpy(ptr, User, len); - ptr+=len; - - //password - len=StrLen(Pass) & 0xFF; - *ptr=len; - ptr++; - memcpy(ptr, Pass, len); - ptr+=len; - - STREAMWriteBytes(S,Tempstr,ptr-Tempstr); - STREAMFlush(S); - - result=STREAMReadBytes(S,Tempstr,10); - - //two bytes reply. Byte1 is Version Byte2 is 0 for success - if ((result > 1) && (Tempstr[0]==1) && (Tempstr[1]==0)) RetVal=TRUE; - break; - } -} - -DestroyString(Tempstr); - -return(RetVal); -} - - - -int ConnectHopSocks(STREAM *S, int Type, const char *Host, int Port, const char *User, const char *Pass, const char *Path) -{ -char *Tempstr=NULL; -uint8_t *ptr; -uint32_t IP; -char *Token=NULL; -const char *tptr; -int result, RetVal=FALSE, val; -uint8_t HostType=HT_IP4; - -S->in_fd=TCPConnect(Host,Port,0); -S->out_fd=S->in_fd; -if (S->in_fd == -1) return(FALSE); - - -if (Type==CONNECT_HOP_SOCKS5) -{ -if (! ConnectHopSocks5Auth(S, User, Pass)) return(FALSE); -} - -//Horrid binary protocol. -Tempstr=SetStrLen(Tempstr, StrLen(User) + 20 + StrLen(Path)); -ptr=Tempstr; - -//version -if (Type==CONNECT_HOP_SOCKS5) *ptr=5; -else *ptr=4; //version number -ptr++; - -//connection type -*ptr=1; //outward connection (2 binds a port for incoming) -ptr++; - -//Sort out path now -tptr=Path; -if (strncmp(tptr,"tcp:",4)==0) tptr+=4; -tptr=GetToken(tptr,":",&Token,0); -if (IsIP4Address(Token)) HostType=HT_IP4; -else if (IsIP6Address(Token)) HostType=HT_IP6; -else HostType=HT_DOMAIN; - - -if (Type==CONNECT_HOP_SOCKS5) -{ -//Socks 5 has a 'reserved' byte after the connection type - *ptr=0; - ptr++; - - *ptr=HostType; - ptr++; - switch (HostType) - { - case HT_IP4: - *((uint32_t *) ptr) =StrtoIP(Token); - ptr+=4; - break; - - case HT_IP6: - break; - - default: - val=StrLen(Token); - *ptr=val; - ptr++; - memcpy(ptr, Token, val); - ptr+=val; - break; - } -} - - -//destination port. By a weird coincidence this is in the right place -//for either socks4 or 5, despite the fact that it comes after the -//host in socks5, and before the host in socks4 -*((uint16_t *) ptr) =htons(atoi(tptr)); -ptr+=2; - -if (Type==CONNECT_HOP_SOCKS4) -{ - //destination host - switch (HostType) - { - case HT_IP4: - *((uint32_t *) ptr) =StrtoIP(Token); - ptr+=4; - val=StrLen(User)+1; - memcpy(ptr,User,val); - ptr+=val; - break; - - default: - *((uint32_t *) ptr) =StrtoIP("0.0.0.1"); - ptr+=4; - break; - } - - val=StrLen(User)+1; - memcpy(ptr, User, val); - ptr+=val; - - //+1 to include terminating \0 - val=StrLen(Token) +1; - memcpy(ptr, Token, val); - ptr+=val; -} - -STREAMWriteBytes(S,Tempstr,(char *)ptr-Tempstr); STREAMFlush(S); -Tempstr=SetStrLen(Tempstr, 32); -result=STREAMReadBytes(S,Tempstr,32); - - -if (Type==CONNECT_HOP_SOCKS5) -{ - if ((result > 8) && (Tempstr[0]==5) && (Tempstr[1]==0)) - { - RetVal=TRUE; - } -} -else -{ - //Positive response will be 0x00 0x5a 0x00 0x00 0x00 0x00 0x00 0x00 - //although only the leading two bytes (0x00 0x5a, or \0Z) matters - if ((result==8) && (Tempstr[0]=='\0') && (Tempstr[1]=='Z')) - { - RetVal=TRUE; - - IP=*(uint32_t *) (Tempstr + 4); - if (IP != 0) STREAMSetValue(S, "IPAddress", IPtoStr(IP)); - } -} - - -DestroyString(Tempstr); -DestroyString(Token); - -return(RetVal); -} - - - - -int SendPublicKeyToRemote(STREAM *S, char *KeyFile, char *LocalPath) -{ -char *Tempstr=NULL, *Line=NULL; -STREAM *LocalFile; - - -Tempstr=FormatStr(Tempstr,"rm -f %s ; touch %s; chmod 0600 %s\n",KeyFile,KeyFile,KeyFile); -STREAMWriteLine(Tempstr,S); -LocalFile=STREAMOpenFile(LocalPath,SF_RDONLY); -if (LocalFile) -{ -Line=STREAMReadLine(Line,LocalFile); -while (Line) -{ -StripTrailingWhitespace(Line); -Tempstr=FormatStr(Tempstr,"echo '%s' >> %s\n",Line,KeyFile); -STREAMWriteLine(Tempstr,S); -Line=STREAMReadLine(Line,LocalFile); -} -STREAMClose(LocalFile); -} - -return(TRUE); -} - - - -int ConnectHopSSH(STREAM *S,int Type, char *Host, int Port, char *User, char *Pass, char *NextHop) -{ -char *Tempstr=NULL, *KeyFile=NULL, *Token=NULL, *Token2=NULL; -STREAM *AuthS; -int result=FALSE, val; -unsigned int TunnelPort=0; - -if (Type==CONNECT_HOP_SSHTUNNEL) -{ - TunnelPort=(rand() % (0xFFFF - 9000)) +9000; - //Host will be Token, and port Token2 - ParseConnectDetails(NextHop, NULL, &Token, &Token2, NULL, NULL, NULL); - Tempstr=FormatStr(Tempstr,"ssh -2 -N %s@%s -L %d:%s:%s ",User,Host,TunnelPort,Token,Token2); - -} -else Tempstr=MCopyStr(Tempstr,"ssh -2 -T ",User,"@",Host, " ", NULL ); - -if (strncmp(Pass,"keyfile:",8)==0) -{ - - if (S->in_fd != -1) - { - Token=FormatStr(Token,".%d-%d",getpid(),time(NULL)); - SendPublicKeyToRemote(S,Token,Pass+8); - KeyFile=CopyStr(KeyFile,Token); - } - Tempstr=MCatStr(Tempstr,"-i ",KeyFile," ",NULL); - } - - if (Port > 0) - { - Token=FormatStr(Token," -p %d ",Port); - Tempstr=CatStr(Tempstr,Token); - } - - if (Type==CONNECT_HOP_SSHTUNNEL) - { - Tempstr=CatStr(Tempstr, " 2> /dev/null"); - AuthS=STREAMSpawnCommand(Tempstr, COMMS_BY_PTY, ""); - STREAMSetValue(S,"HelperPID:SSH",STREAMGetValue(AuthS,"PeerPID")); - } - else if (S->in_fd==-1) - { - Tempstr=CatStr(Tempstr, " 2> /dev/null"); - PseudoTTYSpawn(&S->in_fd,Tempstr,0,""); - S->out_fd=S->in_fd; - if (S->in_fd > -1) - { - result=TRUE; - STREAMSetFlushType(S,FLUSH_LINE,0,0); - } - AuthS=S; - } - else - { - if (StrLen(KeyFile)) Tempstr=MCatStr(Tempstr," ; rm -f ",KeyFile,NULL); - Tempstr=CatStr(Tempstr,"; exit\n"); - STREAMWriteLine(Tempstr,S); - result=TRUE; - AuthS=S; - } - - if ((StrLen(KeyFile)==0) && (StrLen(Pass) > 0)) - { - Token=MCopyStr(Token,Pass,"\n",NULL); - for (val=0; val < 3; val++) - { - if (STREAMExpectAndReply(AuthS,"assword:",Token)) break; - } - } - STREAMSetTimeout(AuthS,100); - //STREAMExpectSilence(AuthS); - sleep(3); - - if (Type==CONNECT_HOP_SSHTUNNEL) - { - S->in_fd=TCPConnect("127.0.0.1",TunnelPort,0); - S->out_fd=S->in_fd; - if (S->in_fd > -1) result=TRUE; - } - - -DestroyString(Tempstr); -DestroyString(KeyFile); -DestroyString(Token2); -DestroyString(Token); - -return(result); -} - - -int STREAMProcessConnectHop(STREAM *S, char *HopURL, int LastHop) -{ -int val, result=FALSE; -char *Token=NULL, *Token2=NULL; -char *Tempstr=NULL; -char *User=NULL, *Host=NULL,*Pass=NULL, *KeyFile=NULL; -int Port=0; - -ParseConnectDetails(HopURL, &Token, &Host, &Token2, &User, &Pass, NULL); - -Port=atoi(Token2); - -val=MatchTokenFromList(Token,HopTypes,0); -switch (val) -{ - case CONNECT_HOP_TCP: - if (S->in_fd==-1) - { - S->in_fd=TCPConnect(Host,Port,0); - S->out_fd=S->in_fd; - if (S->in_fd > -1) result=TRUE; - } - break; - - case CONNECT_HOP_HTTPTUNNEL: - result=DoHTTPProxyTunnel(S, Host, Port, S->Path, 0); - break; - - case CONNECT_HOP_SSH: - case CONNECT_HOP_SSHTUNNEL: - result=ConnectHopSSH(S, val, Host, Port, User, Pass, S->Path); - break; - - case CONNECT_HOP_SOCKS4: - case CONNECT_HOP_SOCKS5: - result=ConnectHopSocks(S, val, Host, Port, User, Pass, S->Path); - break; - - case CONNECT_HOP_SHELL_CMD: - break; - - case CONNECT_HOP_TELNET: - if (Port > 0) - { - Tempstr=FormatStr(Tempstr,"telnet -8 %s %d ",Host, Port); - } - else Tempstr=FormatStr(Tempstr,"telnet -8 %s ",Host); - - if (S->in_fd==-1) - { - PseudoTTYSpawn(& S->in_fd,Tempstr,0,""); - S->out_fd=S->in_fd; - if (S->in_fd > -1) - { - result=TRUE; - STREAMSetFlushType(S,FLUSH_LINE,0,0); - } - - } - else - { - Tempstr=CatStr(Tempstr,";exit\n"); - STREAMWriteLine(Tempstr,S); - result=TRUE; - } - if (StrLen(User) > 0) - { - Tempstr=MCopyStr(Tempstr,User,"\n",NULL); - STREAMExpectAndReply(S,"ogin:",Tempstr); - } - if (StrLen(Pass) > 0) - { - Tempstr=MCopyStr(Tempstr,Pass,"\n",NULL); - STREAMExpectAndReply(S,"assword:",Tempstr); - } - STREAMExpectSilence(S,2); - break; - - -} - -DestroyString(Tempstr); -DestroyString(Token); -DestroyString(KeyFile); -DestroyString(Host); -DestroyString(User); -DestroyString(Pass); - -STREAMFlush(S); -return(result); -} - - -/* -int STREAMInternalLastHop(STREAM *S,char *DesiredHost,int DesiredPort, char *LastHop) -{ -int result, Type,Port; -char *Host=NULL, *User=NULL, *Pass=NULL, *KeyFile=NULL; - -ParseConnectHop(LastHop, &Type, &Host, &User, &Pass, &KeyFile, &Port); -switch (Type) -{ - -} -result=STREAMProcessConnectHop(S, Tempstr, TRUE); - -DestroyString(Tempstr); -DestroyString(Host); -DestroyString(User); -DestroyString(Pass); -DestroyString(KeyFile); -return(result); -} -*/ - - - -int STREAMAddConnectionHop(STREAM *S, char *HopsString) -{ -char *Tempstr=NULL, *Value=NULL, *ptr; - -if (! S->Values) S->Values=ListCreate(); - -ptr=GetToken(HopsString, ",", &Value,0); -while (ptr) -{ -StripTrailingWhitespace(Value); -StripLeadingWhitespace(Value); - -Tempstr=FormatStr(Tempstr,"ConnectHop:%d",ListSize(S->Values)); -STREAMSetValue(S,Tempstr,Value); -ptr=GetToken(ptr, ",", &Value,0); -} - -DestroyString(Tempstr); -DestroyString(Value); -return(TRUE); -} - diff --git a/libUseful-2.6/ConnectionChain.h b/libUseful-2.6/ConnectionChain.h deleted file mode 100755 index 830a7c4..0000000 --- a/libUseful-2.6/ConnectionChain.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef LIBUSEFUL_CONNECTCHAIN -#define LIBUSEFUL_CONNECTCHAIN - -#define PMATCH_SUBSTR 1 -#define PMATCH_NOWILDCARDS 2 -#define PMATCH_NOCASE 4 -#define PMATCH_NOEXTRACT 8 -#define PMATCH_NEWLINEEND 16 -#define PMATCH_NOTSTART 32 -#define PMATCH_NOTEND 64 - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int STREAMProcessConnectHop(STREAM *S, char *Value, int LastHop); -int STREAMAddConnectionHop(STREAM *S, char *Value); - -#ifdef __cplusplus -} -#endif - -#endif - - - diff --git a/libUseful-2.6/DataProcessing.c b/libUseful-2.6/DataProcessing.c deleted file mode 100755 index 0ad205a..0000000 --- a/libUseful-2.6/DataProcessing.c +++ /dev/null @@ -1,1062 +0,0 @@ -#include "DataProcessing.h" -#include "SpawnPrograms.h" -#include "FileSystem.h" -#include "Hash.h" -#include "file.h" - -#ifdef HAVE_LIBSSL - -#include -#include -#include -#include -#include -#include - - -typedef struct -{ -char *Key; -int KeyLen; -char *InputVector; -int InputVectorLen; -int BlockSize; -const EVP_CIPHER *Cipher; -EVP_CIPHER_CTX *enc_ctx; -EVP_CIPHER_CTX *dec_ctx; -} libCryptoProcessorData; -#endif - - -void DataProcessorDestroy(void *In) -{ -TProcessingModule *Mod; - -Mod=(TProcessingModule *) In; -if (! Mod) return; -if (Mod->Close) Mod->Close(Mod); -DestroyString(Mod->Name); -DestroyString(Mod->Args); -DestroyString(Mod->ReadBuff); -DestroyString(Mod->WriteBuff); -free(Mod); -} - - - -char *DataProcessorGetValue(TProcessingModule *M, const char *Name) -{ -ListNode *Curr; - -if (! M->Values) return(NULL); -Curr=ListFindNamedItem(M->Values,Name); -if (Curr) return(Curr->Item); -return(NULL); -} - - -void DataProcessorSetValue(TProcessingModule *M, const char *Name, const char *Value) -{ -ListNode *Curr; - -if (! M->Values) M->Values=ListCreate(); -Curr=ListFindNamedItem(M->Values,Name); -if (Curr) Curr->Item = (void *) CopyStr( (char *) Curr->Item, Value); -else ListAddNamedItem(M->Values,Name,CopyStr(NULL,Value)); -} - - - -void DataProcessorUpdateBuffer(char **Buffer, int *Used, int *Size, const char *Data, int DataLen) -{ -int len; - -if (DataLen < 1) return; - -len=*Used+DataLen; - - -if (len > *Size) -{ - *Buffer=(char *) realloc(*Buffer,len); - *Size=len; -} - -//if we've been supplied actual data to put in the buffer, then do so -//otherwise just expand it if needed -if (Data) -{ - memcpy((*Buffer) + (*Used) ,Data,DataLen); - *Used=len; -} -} - - -int PipeCommandProcessorInit(TProcessingModule *ProcMod, const char *Args) -{ -int result=FALSE; -char *Tempstr=NULL; -char *Name=NULL, *Value=NULL, *ptr; -STREAM *S; - -ptr=GetNameValuePair(Args,"\\S","=",&Name,&Value); -while (ptr) -{ - if (strcasecmp(Name,"Command")==0) Tempstr=CopyStr(Tempstr,Value); - -ptr=GetNameValuePair(ptr,"\\S","=",&Name,&Value); -} - -if (! StrLen(Tempstr) ) -{ - DestroyString(Name); - DestroyString(Value); - DestroyString(Tempstr); - return(FALSE); -} - -GetToken(Tempstr,"\\S",&Name,0); -Value=FindFileInPath(Value,Name,getenv("PATH")); - -if (! StrLen(Value) ) -{ - DestroyString(Name); - DestroyString(Value); - DestroyString(Tempstr); - return(FALSE); -} - - -S=STREAMSpawnCommand(Value, COMMS_BY_PIPE, ""); -ProcMod->Data=(void *) S; -result=TRUE; - -DestroyString(Name); -DestroyString(Value); -DestroyString(Tempstr); - -return(result); -} - - -int PipeCommandProcessorWrite(TProcessingModule *ProcMod, const char *InData, int InLen, char **OutData, int *OutLen, int Flush) -{ -STREAM *S; - -S=(STREAM *) ProcMod->Data; -if (InLen > 0) -{ - STREAMWriteBytes(S,InData,InLen); - STREAMFlush(S); -} - -if (Flush) -{ - if (S->out_fd > -1) close(S->out_fd); - S->out_fd=-1; -} -else if (! STREAMCheckForBytes(S)) return(0); -return(STREAMReadBytes(S,*OutData,*OutLen)); -} - - -int PipeCommandProcessorClose(TProcessingModule *ProcMod) -{ -STREAMClose((STREAM *) ProcMod->Data); -ProcMod->Data=NULL; - -return(TRUE); -} - - - -void InitialiseEncryptionComponents(const char *Args, char **Cipher, char **InputVector, int *IVLen, char **Key, int *KeyLen, int *Flags) -{ -char *TmpKey=NULL, *Tempstr=NULL; -int klen=0, slen=0; -char *Name=NULL, *Value=NULL, *ptr; -char *Salt=NULL; - -*IVLen=0; -ptr=GetNameValuePair(Args,"\\S","=",&Name,&Value); -while (ptr) -{ - if (StrLen(Name)) - { - if (strcasecmp(Name,"Cipher")==0) - { - *Cipher=CopyStr(*Cipher,Value); - } - - - if (strcasecmp(Name,"Key")==0) - { - TmpKey=CopyStr(TmpKey,Value); - klen=StrLen(TmpKey); - } - - if (strcasecmp(Name,"Salt")==0) - { - Salt=CopyStr(Salt,Value); - slen=StrLen(Salt); - } - - - - if ( - (strcasecmp(Name,"iv")==0) || - (strcasecmp(Name,"InputVector")==0) - ) - { - *InputVector=CopyStr(*InputVector,Value); - *IVLen=StrLen(*InputVector); - } - - if (strcasecmp(Name,"HexKey")==0) - { - klen=HexStrToBytes(&TmpKey, Value); - } - - if ( - (strcasecmp(Name,"HexIV")==0) || - (strcasecmp(Name,"HexInputVector")==0) - ) - - { - *IVLen=HexStrToBytes(InputVector,Value); - } - - if (strcasecmp(Name,"PadBlock")==0) - { - if (strcasecmp(Value,"N")==0) *Flags |= DPM_NOPAD_DATA; - } - - } - -ptr=GetNameValuePair(ptr,"\\S","=",&Name,&Value); -} - - -Tempstr=SetStrLen(Tempstr,klen+slen); -memcpy(Tempstr,Salt,slen); -memcpy(Tempstr+slen,TmpKey,klen); - -*KeyLen=HashBytes(Key,"md5",Tempstr,slen+klen,0); - - -DestroyString(Name); -DestroyString(Value); -DestroyString(Tempstr); -DestroyString(TmpKey); -DestroyString(Salt); -} - - - -#ifdef HAVE_LIBCRYPTO - -typedef enum {CI_BLOWFISH, CI_RC2, CI_RC4, CI_RC5, CI_DES, CI_DESX, CI_CAST,CI_IDEA,CI_AES, CI_AES_256} LIBUSEFUL_CRYPT_CIPHERS; - -int libCryptoCipherAvailable(int CipherNum) -{ -switch(CipherNum) -{ - case CI_BLOWFISH: - #ifdef HAVE_EVP_BF_CBC - return(TRUE); - #endif - break; - - case CI_RC2: - #ifdef HAVE_EVP_RC2_CBC - return(TRUE); - #endif - break; - - case CI_RC4: - #ifdef HAVE_EVP_RC4_CBC - return(TRUE); - #endif - break; - - case CI_RC5: - #ifdef HAVE_EVP_RC5_CBC - return(TRUE); - #endif - break; - - case CI_DES: - #ifdef HAVE_EVP_DES_CBC - return(TRUE); - #endif - break; - - case CI_DESX: - #ifdef HAVE_EVP_DESX_CBC - return(TRUE); - #endif - break; - - case CI_CAST: - #ifdef HAVE_EVP_CAST5_CBC - return(TRUE); - #endif - break; - - case CI_IDEA: - #ifdef HAVE_EVP_IDEA_CBC - return(TRUE); - #endif - break; - - case CI_AES: - #ifdef HAVE_EVP_AES_129_CBC - return(TRUE); - #endif - break; - - case CI_AES_256: - #ifdef HAVE_EVP_AES_256_CBC - return(TRUE); - #endif - break; -} -return(FALSE); -} - - -int libCryptoProcessorInit(TProcessingModule *ProcMod, const char *Args) -{ -int result=FALSE; - -#ifdef HAVE_LIBSSL -libCryptoProcessorData *Data; -EVP_CIPHER_CTX *ctx; -const char *CipherList[]={"blowfish","rc2","rc4","rc5","des","desx","cast","idea","aes","aes-256",NULL}; -int val; -char *Tempstr=NULL; - -val=MatchTokenFromList(ProcMod->Name,CipherList,0); -if (val==-1) return(FALSE); -if (! libCryptoCipherAvailable(val)) return(FALSE); -Data=(libCryptoProcessorData *) calloc(1,sizeof(libCryptoProcessorData)); - -//Tempstr here holds the cipher name -InitialiseEncryptionComponents(Args, &Tempstr, &Data->InputVector, &Data->InputVectorLen, & Data->Key, &Data->KeyLen,&ProcMod->Flags); - -if (StrLen(ProcMod->Name)==0) ProcMod->Name=CopyStr(ProcMod->Name,Tempstr); - -switch(val) -{ -/* - case CI_NONE: - Data->Cipher=EVP_enc_null(); - break; -*/ - - case CI_BLOWFISH: - #ifdef HAVE_EVP_BF_CBC - Data->Cipher=EVP_bf_cbc(); - #endif - break; - - case CI_RC2: - #ifdef HAVE_EVP_RC2_CBC - Data->Cipher=EVP_rc2_cbc(); - #endif - break; - - case CI_RC4: - #ifdef HAVE_EVP_RC4_CBC - Data->Cipher=EVP_rc4(); - #endif - break; - - case CI_RC5: - #ifdef HAVE_EVP_RC5_32_12_16_CBC - //Data->Cipher=EVP_rc5_32_12_16_cbc(); - #endif - break; - - case CI_DES: - #ifdef HAVE_EVP_DES_CBC - Data->Cipher=EVP_des_cbc(); - #endif - break; - - case CI_DESX: - #ifdef HAVE_EVP_DESX_CBC - Data->Cipher=EVP_desx_cbc(); - #endif - break; - - case CI_CAST: - #ifdef HAVE_EVP_CAST5_CBC - Data->Cipher=EVP_cast5_cbc(); - #endif - break; - - case CI_IDEA: - #ifdef HAVE_EVP_IDEA_CBC - Data->Cipher=EVP_idea_cbc(); - #endif - break; - - case CI_AES: - #ifdef HAVE_EVP_AES_128_CBC - Data->Cipher=EVP_aes_128_cbc(); - #endif - break; - - case CI_AES_256: - #ifdef HAVE_EVP_AES_256_CBC - Data->Cipher=EVP_aes_256_cbc(); - #endif - break; -} - - -if (Data->Cipher) -{ -Data->enc_ctx=(EVP_CIPHER_CTX *) calloc(1,sizeof(EVP_CIPHER_CTX)); -Data->dec_ctx=(EVP_CIPHER_CTX *) calloc(1,sizeof(EVP_CIPHER_CTX)); -EVP_CIPHER_CTX_init(Data->enc_ctx); -EVP_CIPHER_CTX_init(Data->dec_ctx); -Data->BlockSize=EVP_CIPHER_block_size(Data->Cipher); - -EVP_EncryptInit_ex(Data->enc_ctx,Data->Cipher,NULL,Data->Key,Data->InputVector); -EVP_DecryptInit_ex(Data->dec_ctx,Data->Cipher,NULL,Data->Key,Data->InputVector); - -if (ProcMod->Flags & DPM_NOPAD_DATA) EVP_CIPHER_CTX_set_padding(Data->enc_ctx,FALSE); - -ProcMod->Data=Data; -result=TRUE; - -DataProcessorSetValue(ProcMod,"Cipher",Tempstr); -Tempstr=FormatStr(Tempstr,"%d",Data->BlockSize); -DataProcessorSetValue(ProcMod,"BlockSize",Tempstr); -} - -DestroyString(Tempstr); -#endif -return(result); -} - - -int libCryptoProcessorClose(TProcessingModule *ProcMod) -{ -#ifdef HAVE_LIBSSL -libCryptoProcessorData *Data; -EVP_CIPHER_CTX *ctx; - -Data=(libCryptoProcessorData *) ProcMod->Data; -if (Data) -{ -EVP_CIPHER_CTX_cleanup(Data->enc_ctx); -EVP_CIPHER_CTX_cleanup(Data->dec_ctx); - -DestroyString(Data->Key); -DestroyString(Data->InputVector); -free(Data); -} -ProcMod->Data=NULL; -#endif -return(TRUE); -} - - - - - - - -int libCryptoProcessorWrite(TProcessingModule *ProcMod, const char *InData, int InLen, char **OutData, int *OutLen, int Flush) -{ -int wrote=0; - -#ifdef HAVE_LIBSSL -/* -int len, result=0, val; -libCryptoProcessorData *Data; -EVP_CIPHER_CTX *ctx; -char *ptr, *Tempstr=NULL; - -if (ProcMod->Flags & DPM_WRITE_FINAL) return(0); -ptr=OutData; - -Data=(libCryptoProcessorData *) ProcMod->Data; -ctx=Data->enc_ctx; - -ProcMod->Flags = ProcMod->Flags & ~DPM_WRITE_FINAL; - -if (ProcMod->Flags & DPM_NOPAD_DATA) -{ - val=InLen % Data->BlockSize; - Tempstr=CopyStrLen(Tempstr,InData,InLen); - if (val !=0) - { - Tempstr=SetStrLen(Tempstr,InLen + (Data->BlockSize-val)); - memset(Tempstr+InLen,' ', (Data->BlockSize-val)); - val=InLen+(Data->BlockSize-val); - } - else val=InLen; - - result=EVP_EncryptUpdate(ctx, ptr, &len, Tempstr, val); -} -else -{ - result=EVP_EncryptUpdate(ctx, ptr, &len, InData, InLen); -} - - -if (! result) wrote=0; -else wrote=len; - -DestroyString(Tempstr); -*/ -#endif -return(wrote); -} - - - -int libCryptoProcessorFlush(TProcessingModule *ProcMod, const char *InData, int InLen, char *OutData, int OutLen) -{ -int wrote=0; - -/* -int result=0, len; -libCryptoProcessorData *Data; - -if (ProcMod->Flags & DPM_WRITE_FINAL) return(0); -Data=(libCryptoProcessorData *) ProcMod->Data; - -if (Data) -{ -if (InLen > 0) -{ -result=libCryptoProcessorWrite(ProcMod, InData, InLen, OutData, OutLen,TRUE); -if (result > 0) return(result); -} - -len=OutLen; -result=EVP_EncryptFinal_ex(Data->enc_ctx, OutData, &len); -ProcMod->Flags |= DPM_WRITE_FINAL; -} -if (! result) wrote=0; -else wrote=len; - -*/ - -return(wrote); -} - - -int libCryptoProcessorRead(TProcessingModule *ProcMod, const char *InData, int InLen, char **OutData, int *OutLen, int Flush) -{ -int bytes_read=0; -#ifdef HAVE_LIBSSL -/* -int len, ivlen, result, val; -libCryptoProcessorData *Data; -EVP_CIPHER_CTX *ctx; -char *ptr; - -ptr=OutData; - -Data=(libCryptoProcessorData *) ProcMod->Data; -if (!Data) return(0); - -if (ProcMod->Flags & DPM_READ_FINAL) -{ - if (InLen==0) return(0); - EVP_DecryptInit_ex(Data->dec_ctx,Data->Cipher,NULL,Data->Key,Data->InputVector); - -} - -ctx=Data->dec_ctx; - -if (InLen==0) -{ - len=0; - result=EVP_DecryptFinal_ex(ctx, ptr, &len); - ProcMod->Flags |= DPM_READ_FINAL; //this so we don't try - //another read - -} -else -{ - len=OutLen; - result=EVP_DecryptUpdate(ctx, ptr, &len, InData, InLen); -} - -if (! result) bytes_read=-1; -else bytes_read+=InLen; //should be 'len' but DecryptUpdate returns the - //number of bytes output, not the number consumed -*/ - -#endif -return(bytes_read); -} - -#endif - - - -#ifdef HAVE_LIBZ - -#include - -typedef struct -{ -z_stream z_in; -z_stream z_out; -} zlibData; -#endif - - -int zlibProcessorInit(TProcessingModule *ProcMod, const char *Args) -{ -int result=FALSE; - -#ifdef HAVE_LIBZ -zlibData *ZData; -int CompressionLevel=5; -char *ptr, *Name=NULL, *Value=NULL; - -ptr=GetNameValuePair(Args,"\\S","=",&Name,&Value); -while (ptr) -{ - if (strcasecmp(Name,"CompressionLevel")==0) CompressionLevel=atoi(Value); - if (strcasecmp(Name,"Level")==0) CompressionLevel=atoi(Value); -ptr=GetNameValuePair(ptr,"\\S","=",&Name,&Value); -} - - -ProcMod->ReadMax=4096; -ProcMod->WriteMax=4096; - - -ZData=(zlibData *) calloc(1,sizeof(zlibData)); -ZData->z_in.avail_in=0; -ZData->z_in.avail_out=0; -result=inflateInit(&ZData->z_in); - -ZData->z_out.avail_in=0; -ZData->z_out.avail_out=0; -deflateInit(&ZData->z_out,CompressionLevel); - - -ProcMod->Data=(void *) ZData; -result=TRUE; - -DestroyString(Name); -DestroyString(Value); - -#endif -return(result); -} - - -int gzipProcessorInit(TProcessingModule *ProcMod, const char *Args) -{ -int result=FALSE; - -#ifdef HAVE_LIBZ -zlibData *ZData; -int CompressionLevel=5; -char *ptr, *Name=NULL, *Value=NULL; - -ptr=GetNameValuePair(Args,"\\S","=",&Name,&Value); -while (ptr) -{ - if (strcasecmp(Name,"CompressionLevel")==0) CompressionLevel=atoi(Value); - if (strcasecmp(Name,"Level")==0) CompressionLevel=atoi(Value); -ptr=GetNameValuePair(ptr,"\\S","=",&Name,&Value); -} - -ProcMod->ReadMax=4096; -ProcMod->WriteMax=4096; - -ZData=(zlibData *) calloc(1,sizeof(zlibData)); -ZData->z_in.avail_in=0; -ZData->z_in.avail_out=0; -result=inflateInit2(&ZData->z_in,47); - -ZData->z_out.avail_in=0; -ZData->z_out.avail_out=0; -deflateInit2(&ZData->z_out,5,Z_DEFLATED,30,8,Z_DEFAULT_STRATEGY); - -ProcMod->Data=(void *) ZData; -result=TRUE; - -DestroyString(Name); -DestroyString(Value); - -#endif -return(result); -} - - -//Zlib is a little weird. It accepts a pointer to a buffer (next_in) and a buffer length (avail_in) to specify the input -//and another buffer (next_out) and length (avail_out) to write data into. When called it reads bytes from next_in, updates -//next_in to point to the end of what it read, and subtracts the number of bytes it read from avail_in so that avail_in -//now says how many UNUSED bytes there are pointed to by next_in. Similarly it writes to next_out, updating that pointer -//to point to the end of the write, and updating avail_out to say how much room is LEFT usused in the output buffer -// -//However, if zlib doesn't use all avail_in, then you can't mess with that buffer until it has. Hence you can't take the unusued -//data from next_in/avail_in and copy it to a new buffer and pass that buffer into deflate/inflate on the next call. If zlib -//doesn't use all the input the only way to handle it is to grow the output buffer and call inflate/deflate again, so that it -//can write into the expanded buffer until it's used up all input. -// -//Finally, when you've supplied all the input you've got, you have to call deflate with 'Z_FINISH' so that it knows there's no -//more data coming. - -int zlibProcessorWrite(TProcessingModule *ProcMod, const char *InData, int InLen, char **OutData, int *OutLen, int Flush) -{ -int wrote=0; -#ifdef HAVE_LIBZ -int val=0; -zlibData *ZData; - -if (ProcMod->Flags & DPM_WRITE_FINAL) return(STREAM_CLOSED); -ZData=(zlibData *) ProcMod->Data; - - - ZData->z_out.avail_in=InLen; - ZData->z_out.next_in=(char *) InData; - ZData->z_out.avail_out=*OutLen; - ZData->z_out.next_out=*OutData; - - while ((ZData->z_out.avail_in > 0) || Flush) - { - if (Flush) val=deflate(& ZData->z_out, Z_FINISH); - else val=deflate(& ZData->z_out, Z_NO_FLUSH); - - wrote=*OutLen-ZData->z_out.avail_out; - if (val==Z_STREAM_END) - { - ProcMod->Flags |= DPM_WRITE_FINAL; - break; - } - - if ((ZData->z_out.avail_in > 0) || Flush) - { - *OutLen+=BUFSIZ; - *OutData=(char *) realloc(*OutData,*OutLen); - ZData->z_out.avail_out+=BUFSIZ; - } - - } - - - -#endif -return(wrote); -} - - -int zlibProcessorRead(TProcessingModule *ProcMod, const char *InData, int InLen, char **OutData, int *OutLen, int Flush) -{ -int wrote=0; -#ifdef HAVE_LIBZ -int result=0; -zlibData *ZData; - -if (ProcMod->Flags & DPM_READ_FINAL) return(STREAM_CLOSED); -ZData=(zlibData *) ProcMod->Data; - - - ZData->z_in.avail_in=InLen; - ZData->z_in.next_in=(char *) InData; - ZData->z_in.avail_out=*OutLen; - ZData->z_in.next_out=*OutData; - - while ((ZData->z_in.avail_in > 0) || Flush) - { - if (Flush) result=inflate(& ZData->z_in, Z_FINISH); - else result=inflate(& ZData->z_in, Z_NO_FLUSH); - - wrote=(*OutLen)-ZData->z_in.avail_out; - - fprintf(stderr,"result=%d %d %d\n",result,InLen,Flush); - - switch (result) - { - case Z_DATA_ERROR: inflateSync(&ZData->z_in); break; - case Z_ERRNO: if (Flush) ProcMod->Flags |= DPM_READ_FINAL; break; - case Z_STREAM_ERROR: - case Z_STREAM_END: ProcMod->Flags |= DPM_READ_FINAL; break; - } - - if (ProcMod->Flags & DPM_READ_FINAL) break; - if ((ZData->z_in.avail_in > 0) || Flush) - { - (*OutLen)+=BUFSIZ; - *OutData=(char *) realloc(*OutData,*OutLen); - ZData->z_in.next_out=(*OutData) + wrote; - ZData->z_in.avail_out=(*OutLen) - wrote; - } - - } - - -#endif -return(wrote); -} - - -/* -int zlibProcessorRead(TProcessingModule *ProcMod, const char *InData, int InLen, char **OutData, int *OutLen, int Flush) -{ -int wrote=0, result; -#ifdef HAVE_LIBZ -zlibData *ZData; -int len; - -ZData=(zlibData *) ProcMod->Data; - -if (InLen > 0) -{ -DataProcessorUpdateBuffer(&ProcMod->ReadBuff, &ProcMod->ReadUsed, &ProcMod->ReadSize, InData, InLen); - -ZData->z_in.next_in=ProcMod->ReadBuff; -ZData->z_in.avail_in=ProcMod->ReadUsed; - -ZData->z_in.avail_out=*OutLen; -ZData->z_in.next_out=*OutData; - -if (InLen==0) result=inflate(& ZData->z_in, Z_FINISH); -else result=inflate(& ZData->z_in, Z_NO_FLUSH); - -if (ZData->z_in.avail_in > 0) memmove(ProcMod->ReadBuff,ZData->z_in.next_in,ZData->z_in.avail_in); -ProcMod->ReadUsed=ZData->z_in.avail_in; - -wrote=OutLen-ZData->z_in.avail_out; -} - -#endif -return(wrote); -} -*/ - - -int zlibProcessorClose(TProcessingModule *ProcMod) -{ -#ifdef HAVE_LIBZ -zlibData *ZData; - -ZData=(zlibData *) ProcMod->Data; -if (ZData) -{ -inflateEnd(&ZData->z_in); -deflateEnd(&ZData->z_out); - -free(ZData); -ProcMod->Data=NULL; -} -#endif -return(TRUE); -} - - - -TProcessingModule *StandardDataProcessorCreate(const char *Class, const char *Name, const char *iArgs) -{ -char *Args=NULL; -TProcessingModule *Mod=NULL; - -Args=CopyStr(Args,iArgs); -#ifdef HAVE_LIBSSL - #ifdef HAVE_LIBCRYPTO - if (strcasecmp(Class,"crypto")==0) - { - Mod=(TProcessingModule *) calloc(1,sizeof(TProcessingModule)); - Mod->Args=CopyStr(Mod->Args,Args); - Mod->Name=CopyStr(Mod->Name,Name); - Mod->Init=libCryptoProcessorInit; - Mod->Write=libCryptoProcessorWrite; - Mod->Read=libCryptoProcessorRead; - Mod->Close=libCryptoProcessorClose; - } - #endif -#endif - - - -if (strcasecmp(Class,"compress")==0) -{ - Mod=(TProcessingModule *) calloc(1,sizeof(TProcessingModule)); - Mod->Args=CopyStr(Mod->Args,Args); - Mod->Name=CopyStr(Mod->Name,Name); - - if (strcasecmp(Name,"zlib")==0) - { - #ifdef HAVE_LIBZ - Mod->Init=zlibProcessorInit; - Mod->Write=zlibProcessorWrite; - Mod->Close=zlibProcessorClose; - #endif - } - else if (strcasecmp(Name,"gzip")==0) - { - #ifdef HAVE_LIBZ - Mod->Init=gzipProcessorInit; - Mod->Write=zlibProcessorWrite; - Mod->Close=zlibProcessorClose; - #endif - } - else if (strcasecmp(Name,"bzip2")==0) - { - Args=MCopyStr(Args,"Command='bzip2 --stdout -' ",iArgs,NULL); - Mod->Init=PipeCommandProcessorInit; - Mod->Write=PipeCommandProcessorWrite; - Mod->Close=PipeCommandProcessorClose; - } - else if (strcasecmp(Name,"xz")==0) - { - Args=MCopyStr(Args,"Command='xz --stdout -' ",iArgs,NULL); - Mod->Init=PipeCommandProcessorInit; - Mod->Write=PipeCommandProcessorWrite; - Mod->Close=PipeCommandProcessorClose; - } - -} - - -if (strcasecmp(Class,"uncompress")==0) -{ - Mod=(TProcessingModule *) calloc(1,sizeof(TProcessingModule)); - Mod->Args=CopyStr(Mod->Args,Args); - Mod->Name=CopyStr(Mod->Name,Name); - - if (strcasecmp(Name,"zlib")==0) - { - #ifdef HAVE_LIBZ - Mod->Init=zlibProcessorInit; - Mod->Read=zlibProcessorRead; - Mod->Close=zlibProcessorClose; - #endif - } - else if (strcasecmp(Name,"gzip")==0) - { - #ifdef HAVE_LIBZ - Mod->Init=gzipProcessorInit; - Mod->Read=zlibProcessorRead; - Mod->Close=zlibProcessorClose; - #endif - } - else if (strcasecmp(Name,"bzip2")==0) - { - Args=MCopyStr(Args,"Command='bzip2 -d --stdout -' ",iArgs,NULL); - Mod->Init=PipeCommandProcessorInit; - Mod->Read=PipeCommandProcessorWrite; - Mod->Close=PipeCommandProcessorClose; - } - else if (strcasecmp(Name,"xz")==0) - { - Args=MCopyStr(Args,"Command='xz -d --stdout -' ",iArgs,NULL); - Mod->Init=PipeCommandProcessorInit; - Mod->Read=PipeCommandProcessorWrite; - Mod->Close=PipeCommandProcessorClose; - } - -} - - - -if (Mod && Mod->Init && Mod->Init(Mod, Args)) return(Mod); - -DestroyString(Args); - -DataProcessorDestroy(Mod); -return(NULL); -} - - - - - -int STREAMAddDataProcessor(STREAM *S, TProcessingModule *Mod, const char *Args) -{ -ListNode *Curr; -char *Tempstr=NULL; -int len; - -STREAMFlush(S); - -if (! S->ProcessingModules) S->ProcessingModules=ListCreate(); -Tempstr=MCopyStr(Tempstr,Mod->Name,NULL); -ListAddNamedItem(S->ProcessingModules,Tempstr,Mod); - -len=S->InEnd - S->InStart; -Tempstr=SetStrLen(Tempstr,len); -memcpy(Tempstr,S->InputBuff + S->InStart,len); -STREAMResetInputBuffers(S); - -Curr=ListGetNext(Mod->Values); -while (Curr) -{ - STREAMSetValue(S,Curr->Tag,(char *) Curr->Item); - Curr=ListGetNext(Curr); -} - -STREAMReadThroughProcessors(S, Tempstr, len); - -DestroyString(Tempstr); -return(TRUE); -} - - -int STREAMDeleteDataProcessor(STREAM *S, char *Class, char *Name) -{ -ListNode *Curr; -char *Tempstr=NULL; - -STREAMFlush(S); - -Tempstr=MCopyStr(Tempstr,Class,":",Name,NULL); -Curr=ListFindNamedItem(S->ProcessingModules,Tempstr); -ListDeleteNode(Curr); - -DestroyString(Tempstr); -return(TRUE); -} - - - -int DataProcessorAvailable(const char *Class, const char *Name) -{ -int result=FALSE; -TProcessingModule *Mod; - -Mod=StandardDataProcessorCreate(Class,Name,""); -if (Mod) result=TRUE; - -DataProcessorDestroy(Mod); -return(result); -} - - -int STREAMAddStandardDataProcessor(STREAM *S, const char *Class, const char *Name, const char *Args) -{ -TProcessingModule *Mod=NULL; - -Mod=StandardDataProcessorCreate(Class,Name,Args); -if (Mod) -{ -STREAMAddDataProcessor(S, Mod, Args); -return(TRUE); -} - -return(FALSE); -} - - -void STREAMClearDataProcessors(STREAM *S) -{ -STREAMFlush(S); -STREAMResetInputBuffers(S); -ListDestroy(S->ProcessingModules, DataProcessorDestroy); -} - diff --git a/libUseful-2.6/DataProcessing.h b/libUseful-2.6/DataProcessing.h deleted file mode 100755 index 52ab130..0000000 --- a/libUseful-2.6/DataProcessing.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef LIBUSEFUL_DATA_PROCESSING_H -#define LIBUSEFUL_DATA_PROCESSING_H - -#include "includes.h" - - - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct t_dpmod TProcessingModule; - -typedef int (*DATA_PROCESS_INIT_FUNC)(TProcessingModule *Mod, const char *Args); -typedef int (*DATA_PROCESS_RW_FUNC)(TProcessingModule *, const char *Data, int len, char **OutBuff, int *OutBuffLen, int Flush); -typedef int (*DATA_PROCESS_CLOSE_FUNC)(TProcessingModule *Mod); - -#define DPM_READ_FINAL 1 -#define DPM_WRITE_FINAL 2 -#define DPM_NOPAD_DATA 4 - -struct t_dpmod -{ -char *Name; -char *Args; -int Flags; -char *ReadBuff, *WriteBuff; -int ReadSize, WriteSize; -int ReadUsed, WriteUsed; -int ReadMax, WriteMax; -ListNode *Values; -DATA_PROCESS_INIT_FUNC Init; -DATA_PROCESS_RW_FUNC Read; -DATA_PROCESS_RW_FUNC Write; -DATA_PROCESS_CLOSE_FUNC Close; -void *Data; -}; - - -TProcessingModule *StandardDataProcessorCreate(const char *Class, const char *Name, const char *Arg); -int DataProcessorInit(TProcessingModule *ProcMod, const char *Key, const char *InputVector); -void DataProcessorDestroy(void *ProcMod); -char *DataProcessorGetValue(TProcessingModule *M, const char *Name); -void DataProcessorSetValue(TProcessingModule *M, const char *Name, const char *Value); - - -void InitialiseEncryptionComponents(const char *Args, char **CipherName, char **InputVector, int *InputVectorLen, char **Key, int *KeyLen, int *Flags); - - -int STREAMAddDataProcessor(STREAM *S, TProcessingModule *Mod, const char *Args); -int DataProcessorAvailable(const char *Class, const char *Name); -int STREAMAddStandardDataProcessor(STREAM *S, const char *Class, const char *Name, const char *Args); -void STREAMClearDataProcessors(STREAM *S); -int STREAMDeleteDataProcessor(STREAM *S, char *Class, char *Name); - - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/Docs/ConnectManager.txt b/libUseful-2.6/Docs/ConnectManager.txt deleted file mode 100755 index 02f574c..0000000 --- a/libUseful-2.6/Docs/ConnectManager.txt +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef LIBUSEFUL_CONNECT_MANAGER_H -#define LIBUSEFUL_CONNECT_MANAGER_H - -#include "file.h" -#include "includes.h" - -#define RECONNECT 2 - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct t_con_man_item TConnectManagerItem; - - -typedef int (*CONNECT_FUNC)(TConnectManagerItem *Item); -typedef int (*ONDATA_FUNC)(STREAM *S, char *Name); -typedef int (*ONTIMER_FUNC)(void *Data, char *Name); - - - -typedef struct t_con_man_item -{ -char *Name; -void *Data; -int TimerVal; -int LastTimerFire; -char *Host; -int Port; -CONNECT_FUNC OnConnect; -ONDATA_FUNC OnData; -}; - - -int ConnectManagerAddServer(int sock, char *Name, CONNECT_FUNC OnConnect, ONDATA_FUNC OnData); -STREAM *ConnectManagerAddClient(char *Host, int Port, int Flags, char *Name, CONNECT_FUNC OnConnect, ONDATA_FUNC OnData); -TConnectManagerItem *ConnectManagerAddIncoming(STREAM *S, char *Name, ONDATA_FUNC OnData); -int ConnectManagerAddTimer(int Secs, char *Name, ONTIMER_FUNC OnTime, void *Data); -int ConnectManagerCountNamedConnections(char *Name); -STREAM *ConnectManagerGetStreamByName(char *Name); -ListNode *ConnectManagerGetConnectionList(); -void ConnectManagerMainLoop(); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/Docs/DataProcessing.txt b/libUseful-2.6/Docs/DataProcessing.txt deleted file mode 100755 index be9944b..0000000 --- a/libUseful-2.6/Docs/DataProcessing.txt +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef LIBUSEFUL_DATA_PROCESSING_H -#define LIBUSEFUL_DATA_PROCESSING_H - -#include "includes.h" - - - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct t_dpmod TProcessingModule; - -typedef int (*DATA_PROCESS_INIT_FUNC)(TProcessingModule *Mod, const char *Args); -typedef int (*DATA_PROCESS_WRITE_FUNC)(TProcessingModule *, const char *Data, int len, char *OutBuff, int OutBuffLen); -typedef int (*DATA_PROCESS_CLOSE_FUNC)(TProcessingModule *Mod); - -#define DPM_READ_FINAL 1 -#define DPM_WRITE_FINAL 2 -#define DPM_NOPAD_DATA 4 - -struct t_dpmod -{ -char *Name; -char *Args; -int Flags; -char *Buffer; -int BuffSize; -ListNode *Values; -DATA_PROCESS_INIT_FUNC Init; -DATA_PROCESS_WRITE_FUNC Read; -DATA_PROCESS_WRITE_FUNC Write; -DATA_PROCESS_WRITE_FUNC Flush; -DATA_PROCESS_CLOSE_FUNC Close; -void *Data; -}; - - -TProcessingModule *StandardDataProcessorCreate(const char *Class, const char *Name, const char *Arg); -int DataProcessorInit(TProcessingModule *ProcMod, const char *Key, const char *InputVector); -int DataProcessorWrite(TProcessingModule *ProcMod, const char *InData, int InLen, char *OutData, int OutLen); -void DataProcessorDestroy(void *ProcMod); -char *DataProcessorGetValue(TProcessingModule *M, const char *Name); -void DataProcessorSetValue(TProcessingModule *M, const char *Name, const char *Value); - - -void InitialiseEncryptionComponents(const char *Args, char **CipherName, char **InputVector, int *InputVectorLen, char **Key, int *KeyLen, int *Flags); - - -int STREAMAddDataProcessor(STREAM *S, TProcessingModule *Mod, const char *Args); -int DataProcessorAvailable(const char *Class, const char *Name); -int STREAMAddStandardDataProcessor(STREAM *S, const char *Class, const char *Name, const char *Args); -void STREAMClearDataProcessors(STREAM *S); -int STREAMDeleteDataProcessor(STREAM *S, char *Class, char *Name); - - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/Docs/EncryptedFiles.txt b/libUseful-2.6/Docs/EncryptedFiles.txt deleted file mode 100755 index 2a2b360..0000000 --- a/libUseful-2.6/Docs/EncryptedFiles.txt +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef LIBUSEFUL_ENCRYPTEDFILES_H -#define LIBUSEFUL_ENCRYPTEDFILES_H - -#include "DataProcessing.h" -#include "file.h" - -#define FLAG_ENCRYPT 1 -#define FLAG_DECRYPT 2 -#define FLAG_HEXKEY 4 -#define FLAG_HEXIV 8 -#define FLAG_HEXSALT 16 -#define FLAG_VERBOSE 32 -#define FLAG_SPEED 64 -#define FLAG_NOPAD_DATA 128 - - - -#ifdef __cplusplus -extern "C" { -#endif - -char *FormatEncryptArgs(char *RetBuff,int Flags, const char *Cipher, const char *Key, const char *InitVector, const char *Salt ); -int AddEncryptionHeader(STREAM *S, int Flags, const char *Cipher, const char *Key, const char *InitVector, const char *Salt); -void HandleDecryptionHeader(STREAM *S, const char *Header, const char *Key); - - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/Docs/GeneralFunctions.txt b/libUseful-2.6/Docs/GeneralFunctions.txt deleted file mode 100755 index 4adbace..0000000 --- a/libUseful-2.6/Docs/GeneralFunctions.txt +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef LIBUSEFUL_GENERAL_H -#define LIBUSEFUL_GENERAL_H - -#include -#include "defines.h" - - - -#ifdef __cplusplus -extern "C" { -#endif - -void WritePidFile(char *ProgName); -int HexStrToBytes(char **Buffer, char *HexStr); -char *BytesToHexStr(char *Buffer, char *Bytes, int len); -int demonize(); - -void SwitchProgram(char *CommandLine); -int Spawn(char *CommandLine); -int SpawnWithIO(char *CommandLine, int StdIn, int StdOut, int StdErr); -int ForkWithIO(int StdIn, int StdOut, int StdErr); -int PipeSpawnFunction(int *infd, int *outfd, int *errfd, BASIC_FUNC Func, void *Data); -int PipeSpawn(int *infd, int *outfd, int *errfd, char *CommandLine); -int FileExists(char *); -int LogToFile(char *,char *,...); -int LogFileSetValues(char *FileName, int Flags, int MaxSize, int FlushInterval); -void LogFileFlushAll(int ForceFlush); -void ColLibDefaultSignalHandler(int sig); -void SetTimeout(int timeout); -int CreateLockFile(char *FilePath,int Timeout); -char *GetDateStr(char *Format, char *Timezone); -char *GetDateStrFromSecs(char *Format, time_t Secs, char *Timezone); -time_t DateStrToSecs(char *Format, char *Str); -double EvaluateMathStr(char *String); -int MakeDirPath(char *Path, int DirMask); - -int SwitchUser(char *User); -int SwitchGroup(char *Group); -char *GetCurrUserHomeDir(); -char *GetNameValuePair(const char *Input, const char *PairDelim, const char *NameValueDelim, char **Name, char **Value); - -void SetVar(ListNode *Vars, char *Name, char *Data); -char *GetVar(ListNode *Vars, char *Name); -void UnsetVar(ListNode *Vars,char *VarName); -void ClearVars(ListNode *Vars); -void CopyVars(ListNode *Dest,ListNode *Source); - -char *SubstituteVarsInString(char *Buffer, char *Fmt, ListNode *Vars, int Flags); -int ExtractVarsFromString(char *Data, char *FormatStr, ListNode *Vars); -char *GetRandomData(char *RetBuff, int len, char *AllowedChars); -char *GetRandomHexStr(char *RetBuff, int len); -char *GetRandomAlphabetStr(char *RetBuff, int len); - -void CloseOpenFiles(); -int ChangeFileExtension(char *FilePath, char *NewExt); - -int BASIC_FUNC_EXEC_COMMAND(void *Data); - -char *XMLGetTag(char *Input, char **TagType, char **TagData); -char *XMLDeQuote(char *RetStr, char *Data); - - -double ParseHumanReadableDataQty(char *Data, int Type); -char *GetHumanReadableDataQty(double Size, int Type); -char *FindFileInPath(char *InBuff, char *File, char *Path); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/Docs/Hash.txt b/libUseful-2.6/Docs/Hash.txt deleted file mode 100755 index 145a5d1..0000000 --- a/libUseful-2.6/Docs/Hash.txt +++ /dev/null @@ -1,56 +0,0 @@ -Hashing functions. Call 'HashInit' - -THash *HashInit(char *Type); - -passing in a type (either "sha1", "md5" or "crc32". This will return a THash structure (or NULL on error). The Hash structure contains too functions, 'Update' and 'Finish', of the forms: - -Hash->Update(THash *Hash, char *Data, int DataLen); -Hash->Finish(THash *Hash, int Encoding, char **RetStr); - -The 'Encoding' argument to 'Finish' can be either of the #defined values ENCODE_HEX or ENCODE_BASE64. - -Example: - -THash *Hash; -STREAM *S; -char *Tempstr=NULL; -int result; - -Hash=InitHash("md5"); -S=STREAMOpenFile("testfile",O_RDONLY); - -if (S) -{ - Tempstr=SetStrLen(Tempstr,4096); - result=STREAMReadBytes(S,Tempstr,4096); - while (Tempstr) - { - Hash->Update(Hash,Tempstr,result); - result=STREAMReadBytes(S,Tempstr,4096); - } - - Hash->Finish(Hash,ENCODE_HEX,&Tempstr); - printf("MD5 Digest of file is: %s\n",Tempstr); -STREAMClose(S); -} -else printf("Couldn't open file\n"); - - - -char *HashBytes(char *Return, char *Type, char *text, int len, int Encoding); - -A simpler interface to the hashing functions, for when you just want to hash a string of bytes. - -Example - -char *Str="I wonder what the sha1 hash of this sentence is?"; -char *Digest=NULL; - -Digest=HashBytes(Digest,"sha1",Str,StrLen,ENCODE_HEX); - -printf("hash is: %s\n",Digest); - - -char *EncodeBase64(char *Return, char *Text, int len); -char *DecodeBase64(char *Return, int *len, char *Text); - diff --git a/libUseful-2.6/Docs/Log.txt b/libUseful-2.6/Docs/Log.txt deleted file mode 100755 index e187382..0000000 --- a/libUseful-2.6/Docs/Log.txt +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef LIBUSEFUL_LOG_H -#define LIBUSEFUL_LOG_H - -#include "includes.h" -#include "defines.h" -#include "file.h" - -#define LOGFILE_FLUSH 1 -#define LOGFILE_SYSLOG 2 -#define LOGFILE_LOGPID 4 -#define LOGFILE_LOGUSER 8 - -extern char *G_LogFilePath; - -int LogFileSetValues(char *FileName, int Flags, int MaxSize, int FlushInterval); -int LogToSTREAM(STREAM *S, int Flags, char *Str); -void LogFileFlushAll(int Force); -int LogToFile(char *FileName,char *fmt, ...); -void LogFileClose(char *Path); -int LogFileAppendTempLog(char *LogPath, char *TmpLogPath); - - -#endif diff --git a/libUseful-2.6/Docs/directory b/libUseful-2.6/Docs/directory deleted file mode 100755 index 8355d29..0000000 --- a/libUseful-2.6/Docs/directory +++ /dev/null @@ -1 +0,0 @@ -cat: /home/metacosm89/fileferry-1.0/libUseful-2.0/Docs/directory: No such file or directory diff --git a/libUseful-2.6/Docs/expect.txt b/libUseful-2.6/Docs/expect.txt deleted file mode 100755 index 92e3d3a..0000000 --- a/libUseful-2.6/Docs/expect.txt +++ /dev/null @@ -1,43 +0,0 @@ -Functions that implement an 'expect'-style interface, in which strings are read from a stream, and when certain strings are seen certain responses are sent. - - -int STREAMExpectAndReply(STREAM *S, char *Expect, char *Reply); - -Simple interface, wait to see the string 'Expect' on a stream, and send 'Reply' when you see it. - -Example: - -int STREAMExpectAndReply(S, "assword:", "MyP@55W0rd"); - -The STREAM can be anything that can be represented by a file descriptor. Thus it can be a pipe, socket, file, pseudo-tty. Streams can be made from file descriptors using 'STREAMFromFD(int fd)' or 'STREAMFromDualFD(int fd)' - -void DialogAdd(ListNode *Dialogs, char *Expect, char *Reply, int Flags); - -Add 'Dialogs' to a list. A dialog is an expected string, and a reply that's sent to it. The list is of the type described in 'lists.txt'. - -Example: - -DialogAdd(Diags,"assword:","MyP@55W0rd",0); - - - - - - -#define FLAG_FINAL_DIALOG 1 -#define FLAG_DIALOG_FAIL 2 - -typedef struct -{ -int Flags; -int Match; -char *Expect; -char *Reply; -} TDialog; - - - -int STREAMExpectSilence(STREAM *S, int wait); -int STREAMDialog(STREAM *S, ListNode *Dialogs); - - diff --git a/libUseful-2.6/Docs/file.txt b/libUseful-2.6/Docs/file.txt deleted file mode 100755 index 75f4ca7..0000000 --- a/libUseful-2.6/Docs/file.txt +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef LIBUSEFUL_FILE_H -#define LIBUSEFUL_FILE_H - -#include -#include "list.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define STREAM_CLOSED -1 -#define STREAM_NODATA -2 -#define STREAM_TIMEOUT -3 -#define STREAM_DATA_ERROR -4 - -#define FLUSH_FULL 0 -#define FLUSH_LINE 1 -#define SF_AUTH 2 -#define SF_SYMLINK_OK 4 -#define SF_CONNECTING 8 -#define SF_CONNECTED 16 -#define SF_HANDSHAKE_DONE 32 -#define SF_WRONLY 64 -#define SF_RDONLY 128 -#define SF_RDWR 256 -#define SF_SSL 512 -#define SF_DATA_ERROR 1024 -#define SF_WRITE_ERROR 2048 -#define SF_NONBLOCK 4096 - -#define STREAM_TYPE_FILE 0 -#define STREAM_TYPE_UNIX 1 -#define STREAM_TYPE_UNIX_DGRAM 2 -#define STREAM_TYPE_TCP 3 -#define STREAM_TYPE_UDP 4 -#define STREAM_TYPE_SSL 5 -#define STREAM_TYPE_HTTP 6 -#define STREAM_TYPE_CHUNKED_HTTP 7 - -#define O_LOCK O_NOCTTY - -#define COMMS_BY_PIPE 0 -#define COMMS_BY_PTY 1 - -typedef struct -{ -char *InputBuff; -char *OutputBuff; -int Timeout; -int in_fd, out_fd; -int Type; -int Flags; -unsigned int BuffSize; -unsigned int InStart, InEnd; -unsigned int OutStart, OutEnd; -unsigned int BytesRead; -unsigned int BytesWritten; -char *Path; -void *Extra; -ListNode *Values; -ListNode *ProcessingModules; -ListNode *Index; -} STREAM; - - -STREAM *STREAMCreate(); -STREAM *STREAMOpenFile(char *Path, int Mode); -STREAM *STREAMClose(STREAM *Stream); -void STREAMSetNonBlock(STREAM *S, int val); -int STREAMLock(STREAM *S, int val); -int STREAMFlush(STREAM *Stream); -void STREAMClear(STREAM *Stream); -int STREAMTell(STREAM *Stream); -int STREAMSeek(STREAM *Stream, off_t offset, int whence); -void STREAMResizeBuffer(STREAM *, int); -void STREAMSetTimeout(STREAM *, int); -void STREAMSetFlushType(STREAM *Stream, int Type, int val); -int STREAMReadChar(STREAM *); -int STREAMWriteChar(STREAM *, char); -char* STREAMReadLine(char *Buffer, STREAM *); -int ReadBytesToTerm(STREAM *S, char *Buffer, int BuffSize, char Term); -char* STREAMReadToTerminator(char *Buffer, STREAM *, char Term); -char* STREAMReadToMultiTerminator(char *Buffer, STREAM *, char *Terms); -int STREAMWriteString(char *Buffer, STREAM *); -int STREAMWriteLine(char *Buffer, STREAM *); -STREAM *STREAMFromFD(int fd); -STREAM *STREAMFromDualFD(int in_fd, int out_fd); -STREAM *STREAMSpawnCommand(char *Command, int type); - - int STREAMDisassociateFromFD(STREAM *Stream); - int STREAMPeekChar(STREAM *); - -int STREAMReadBytes(STREAM *, char *Buffer, int Bytes); -int STREAMWriteBytes(STREAM *, char *Buffer, int Bytes); -int FDCheckForBytes(int); -int STREAMCheckForBytes(STREAM *); -int STREAMCheckForWaitingChar(STREAM *S, char check_char); -int STREAMCountWaitingBytes(STREAM *); - - -int IndexedFileLoad(STREAM *S); -int IndexedFileFind(STREAM *S, char *Key); -int IndexedFileWrite(STREAM *S, char *Line); - - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/Docs/http.txt b/libUseful-2.6/Docs/http.txt deleted file mode 100755 index 589b663..0000000 --- a/libUseful-2.6/Docs/http.txt +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef LIBUSEFUL_HTTP_H -#define LIBUSEFUL_HTTP_H - -#include "includes.h" -#include "defines.h" -#include "file.h" - -#define HTTP_AUTH_BASIC 1 -#define HTTP_AUTH_DIGEST 2 -#define HTTP_SENT_AUTH 4 -#define HTTP_PROXY_AUTH 8 - - -#define HTTP_OKAY 0 -#define HTTP_NOCONNECT 1 -#define HTTP_NOTFOUND 2 -#define HTTP_REDIRECT 3 -#define HTTP_ERROR 4 -#define HTTP_CIRCULAR_REDIRECTS 5 -#define HTTP_NOTMODIFIED 6 - -#define HTTP_VER1_0 1 -#define HTTP_DEBUG 2 -#define HTTP_CHUNKED 4 -#define HTTP_HEADERS_SENT 8 -#define HTTP_NOCOMPRESS 16 -#define HTTP_NOREDIRECT 32 -#define HTTP_KEEPALIVE 128 -#define HTTP_PROXY 512 -#define HTTP_SSL 1024 -#define HTTP_SSL_REWRITE 2048 -#define HTTP_GZIP 8192 -#define HTTP_DEFLATE 16384 - - -typedef struct -{ -int Flags; -char *AuthRealm; -char *AuthQOP; -char *AuthNonce; -char *AuthOpaque; -char *Logon; -char *Password; -} HTTPAuthStruct; - - -typedef struct -{ -char *Host; -int Port; -char *Method; -char *Doc; -char *Destination; -char *ResponseCode; -int Flags; -char *RedirectPath; -char *PreviousRedirect; -char *ContentType; -char *Timestamp; -int ContentLength; -int Depth; -char *PostData; -char *PostContentType; -int PostContentLength; -char *Proxy; -time_t IfModifiedSince; -ListNode *CustomSendHeaders; -HTTPAuthStruct *Authorization; -HTTPAuthStruct *ProxyAuthorization; -STREAM *S; -} HTTPInfoStruct; - - - -char *HTTPQuote(char *, char*); -char *HTTPQuoteChars(char *RetBuff, char *Str, char *CharList); -char *HTTPUnQuote(char *, char*); - - -void HTTPInfoDestroy(void *p_Info); -void HTTPInfoSetValues(HTTPInfoStruct *Info, char *Host, int Port, char *Logon, char *Password, char *Method, char *Doc, char *ContentType, int ContentLength); -HTTPInfoStruct *HTTPInfoCreate(char *Host, int Port, char *Logon, char *Password, char *Method, char *Doc, char *ContentType, int ContentLength); -STREAM *HTTPConnect(HTTPInfoStruct *Info); -STREAM *HTTPTransact(HTTPInfoStruct *Info); -HTTPInfoStruct *HTTPInfoFromURL(char *Method, char *URL); -STREAM *HTTPMethod(char *Method, char *URL, char *Logon, char *Password); -STREAM *HTTPGet(char *URL, char *Logon, char *Password); -STREAM *HTTPPost(char *URL, char *Logon, char *Password, char *ContentType, char *Content); -int HTTPReadBytes(STREAM *Con, char **Buffer); -void HTTPCopyToSTREAM(STREAM *Con, STREAM *S); -int HTTPDownload(char *URL, char *Login, char *Password, STREAM *S); -void HTTPSetUserAgent(char *AgentName); -void HTTPSetProxy(char *Proxy); -void HTTPSetFlags(int Flags); -char *HTTPParseURL(char *URL, char **Proto, char **Host, int *Port, char **Login, char **Password); - -#endif diff --git a/libUseful-2.6/Docs/includes.txt b/libUseful-2.6/Docs/includes.txt deleted file mode 100755 index 477e25e..0000000 --- a/libUseful-2.6/Docs/includes.txt +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef LIBUSEFUL_INCLUDES_H -#define LIBUSEFUL_INCLUDES_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "defines.h" -#include "string.h" -#include "list.h" -#include "GeneralFunctions.h" -#include "file.h" -#include "socket.h" - - -#endif diff --git a/libUseful-2.6/Docs/inet.txt b/libUseful-2.6/Docs/inet.txt deleted file mode 100755 index 4921236..0000000 --- a/libUseful-2.6/Docs/inet.txt +++ /dev/null @@ -1,29 +0,0 @@ -inet.h contains functions that relates to utility services offered by sites on the web. - -At the moment this is just IP Geolocation and discovery of your External (out on the internet) IP address - - -char *GetExternalIP(char *RetStr); - -Pass a char * string into this function, and the function will print your external IP address into it, if it can determine it, and return the string (or null if IP cannot be determined). - -Look in the documentation for string.h (string.txt) to understand libUseful strings - - - -int IPGeoLocate(char *IP, ListNode *Vars); - -Pass in an quad-format IP address or a hostname, and this function will do geolocation and return the information as a list that holds strings. Look into list.txt to understand libUseful lists. - - - - -char *ExtractFromWebpage(char *RetStr, char *URL, char *ExtractStr, int MinLength); - -This is a function for screen-scraping data items from webpages. - -example: - - RetStr=ExtractFromWebpage(RetStr,"http://checkip.dyndns.org", "Current IP Address: $(extract_item)",4); - -pass in a blank string as the first argument, and the function will print it's results into it and return it. The second argument is the URL of the web-page to get. The third argument is a string to search for, and clip out that part of the string that is here represented by '$(extract_item)'. diff --git a/libUseful-2.6/Docs/list.txt b/libUseful-2.6/Docs/list.txt deleted file mode 100755 index 0663ab6..0000000 --- a/libUseful-2.6/Docs/list.txt +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef LIB_USEFUL_LIST -#define LIB_USEFUL_LIST - - -#ifdef __cplusplus -extern "C" { -#endif - -#define LIST_FLAG_DELETE 1 - -typedef struct lnode -{ -int ItemType; -int Flags; -char *Tag; -void *Item; -struct lnode *Head; -struct lnode *Jump; -struct lnode *Prev; -struct lnode *Next; -} ListNode; - -typedef void (*LIST_ITEM_DESTROY_FUNC)(void *); -typedef void *(*LIST_ITEM_CLONE_FUNC)(void *); - -ListNode *ListCreate(); -void *IndexArrayOnList(ListNode *); -void *AddItemToArray(void *Array,int size, void *Item); -void *DeleteItemFromArray(void *Array,int size, int ItemNo); -void ListDestroy(ListNode *, LIST_ITEM_DESTROY_FUNC); -void ListClear(ListNode *, LIST_ITEM_DESTROY_FUNC); -ListNode *ListAddItemt(ListNode *,void *); -ListNode *ListAddNamedItem(ListNode *, const char *Name, void *); -ListNode *ListInsertItem(ListNode *,void *); -ListNode *ListInsertNamedItem(ListNode *,const char *,void *); -ListNode *OrderedListAddNamedItem(ListNode *Head, const char *Name, void *Item); -ListNode *SortedListInsertItem(ListNode *, void *, int (*LessThanFunc)(void *, void *, void *)); -ListNode *ListAddNamedItemAfter(ListNode *ListStart,const char *Name,void *Item); -void *ListDeleteNode(ListNode *); -ListNode *ListGetNext(ListNode *); -ListNode *ListGetPrev(ListNode *); -ListNode *ListGetHead(ListNode *); -ListNode *ListGetLast(ListNode *); -ListNode *ListGetNth(ListNode *Head, int n); -ListNode *ListFindNamedItem(ListNode *Head, const char *Name); -ListNode *ListFindItem(ListNode *Head, void *Item); -ListNode *ListJoin(ListNode *, ListNode *); -ListNode *ListClone(ListNode *, LIST_ITEM_CLONE_FUNC); -void ListSort(ListNode *, void *Data, int (*LessThanFunc)(void *, void *, void *)); -void ListSwapItems(ListNode *, ListNode *); -int ListSize(ListNode *); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/Docs/pty.txt b/libUseful-2.6/Docs/pty.txt deleted file mode 100755 index b57e21b..0000000 --- a/libUseful-2.6/Docs/pty.txt +++ /dev/null @@ -1,48 +0,0 @@ -Functions for tty lines and pty pseudo-terminals. - - -int OpenTTY(char *devname, int LineSpeed, int Flags); - -Opens a serial device. 'devname' is the path (like /dev/ttyS0) and LineSpeed is the baudrate. Flags can be: - -TTYFLAG_ECHO Turn on character echo. -TTYFLAG_CRLF Lines end with /r/n -TTYFLAG_LFCR Lines end with /n/r -TTYFLAG_NONBLOCK Nonblocking reads -TTYFLAG_CANON Canonical mode tty -TTYFLAG_HARDWARE_FLOW Hardwre flow control -TTYFLAG_SOFTWARE_FLOW Software flow control -TTYFLAG_CRLF_KEEP Don't set CRLF or LFCR, just stick with current setting - - -void HangUpLine(int tty); - -Hang up a tty previously opened with 'OpenTTY' - - -InitTTY(int tty, int LineSpeed, int Flags); - -Like 'OpenTTY', but tty device has already been opened with 'open' - - - -void ResetTTY(int tty); - -Reset tty - - - -int GrabPseudoTTY(int *pty, int *tty); - -Open a pseudo tty. The master end is returned as pty, the slave is returned as tty. - - - -int PseudoTTYSpawnFunction(int *pty, BASIC_FUNC Func, void *Data); - - -Fork a process running a function that will talk back to the main program via Pseudo tty (pty). The funtion's end of the pipe will appear as its stdin and stdout. - -int PseudoTTYSpawn(int *pty, const char *Command); - -Launch a Command that will think it's talking to a serial line on stdin/stdout, but is actually talking via Pseudo tty (pty) to the main program. diff --git a/libUseful-2.6/Docs/socket.txt b/libUseful-2.6/Docs/socket.txt deleted file mode 100755 index 8205a16..0000000 --- a/libUseful-2.6/Docs/socket.txt +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef LIBUSEFUL_SOCK -#define LIBUSEFUL_SOCK - -#include -#include "file.h" - -#define CONNECT_NONBLOCK 1 -#define CONNECT_SSL 2 -#define CONNECT_HTTP_PROXY 4 -#define CONNECT_SOCKS_PROXY 8 - -#define CONNECT_HOP_TCP 1 -#define CONNECT_HOP_HTTP_PROXY 2 -#define CONNECT_HOP_SSH 3 -#define CONNECT_HOP_SHELL_CMD 4 -#define CONNECT_HOP_TELNET 5 - -#define SOCK_CONNECTED 1 -#define SOCK_CONNECTING -1 - -#ifdef __cplusplus -extern "C" { -#endif - - - -/* Server Socket Funcs*/ -int InitServerSock(char *Address, int Port); -int InitUnixServerSock(char *Path); -int TCPServerSockAccept(int ServerSock,int *Addr); -int UnixServerSockAccept(int ServerSock); - -int GetSockDetails(int fd, char **LocalAddress, int *LocalPort, char **RemoteAddress, int *RemotePort); - -/* Client Socket Funcs*/ -int IsSockConnected(int sock); -int ReconnectSock(int sock, char *Host, int Port, int Flags); -int ConnectToHost(char *Host, int Port, int Flags); -/* int CheckForData(int sock); */ -int SendText(int sock, char *Text); -int ReadText(int sock, char *Buffer, int MaxLen); -int ReadToCR(int fd, char *Buffer, int MaxLen); - - -STREAM *STREAMOpenUDP(int Port,int NonBlock); -int STREAMSendDgram(STREAM *S, char *Host, int Port, char *Bytes, int len); -int STREAMConnectToHost(STREAM *S, char *Host, int Port, int Flags); -int STREAMIsConnected(STREAM *S); -int DoPostConnect(STREAM *S, int Flags); -int DoSSLClientNegotiation(STREAM *S, int Flags); -int DoSSLServerNegotiation(STREAM *S, int Flags); -void STREAMSetValue(STREAM *S, char *Name, char *Value); -char *STREAMGetValue(STREAM *S, char *Name); -const char *STREAMQuerySSLCipher(STREAM *S); -int STREAMIsPeerAuth(STREAM *S); - -/* Stuff relating to standard inet download procedure (until \r\n.\r\n) */ -typedef struct -{ -STREAM *Input; -STREAM *Output; -char *TermStr; -int TermPos; -} DownloadContext; - -int ProcessIncommingBytes(DownloadContext *); -//int DownloadToDot(int sock, FILE *SaveFile); -int DownloadToDot(STREAM *Connection, STREAM *SaveFile); -int DownloadToTermStr(STREAM *Connection, STREAM *SaveFile, char *TermStr); -void ParseConnectDetails(char *Str, char **Type, char **Host, int *Port, char **User, char **Pass, char **InitDir); - - -/* IP Address and host lookup functions */ -char *LookupHostIP(char *Host); -char *GetRemoteIP(int sock); -char *IPStrToHostName(char *); -char *IPtoStr(unsigned long); -unsigned long StrtoIP(char *); -int IsIPAddress(char *); - - -int STREAMAddConnectionHop(STREAM *S, char *Value); -void STREAMAddConnectionHopList(STREAM *S, char *HopList); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/Docs/sound.txt b/libUseful-2.6/Docs/sound.txt deleted file mode 100755 index d9470a3..0000000 --- a/libUseful-2.6/Docs/sound.txt +++ /dev/null @@ -1,55 +0,0 @@ -A few simple functions for playing and recording sound. Depending on how libUseful was compiled these will either work via Esound (esd) or Open Sound System. - -For systems with ALSA, playback, record and volume control can be enabled by loading the kernel modules snd-mixer-oss and snd-pcm-oss. These will create a 'fake' oss style device (/dev/dsp) which allows oss-style programs to talk to ALSA. - -int SoundPlayFile(char *Path, int Vol, int Flags); - -A very simple function to play .au or .wav files. - -'Path' is the path to the file. - -'Vol' is a value between 0 and 255. The #defined value 'VOLUME_LEAVEALONE' can be passed as 'Vol', this means don't alter the volume when playing the file. - -'Flags' currently only accepts the #defined value 'PLAYSOUND_NONBLOCK', which will cause a background process to be forked off so that the program isn't delayed while the sound plays. - - - -TAudioInfo *SoundReadAU(STREAM *S); -TAudioInfo *SoundReadWAV(STREAM *S); - -These functions read header info from .wav or .au files. The information is returned in a TAudioInfo structure: - - -typedef struct -{ -unsigned int Format; -unsigned int Channels; -unsigned int SampleRate; -unsigned int SampleSize; -unsigned int DataSize; -}TAudioInfo; - -The file is passed in as a STREAM. Look in file.txt for documentation on the STREAM class. - - - -int SoundOpenOutput(char *Dev, TAudioInfo *Info); - -This function opens an output device, with channels, audioformat, samplerate, etc, etc set using the TAudioInfo struct described above. - -If 'Dev' is set to 'esd:" followed by a hostname, e.g. "esd:localhost", "esd:192.168.1.5", then the ESPEAKER environment variable will be set to the hostname, and sound will be send to that host. If the 'Dev' argument is of non-zero length, but does not start with 'esd', then it will be taken to be an OSS device path. - -If 'Dev' is of zero length, then localhost esound will be tried first, falling back to OSS on /dev/dsp. - - -int SoundOpenInput(char *Dev, TAudioInfo *Info); - -As 'SoundOpenOutput', but for reading/recording sound. - - - -int SoundAlterVolume(char *Dev, char *Channel, int delta); - -Change the volume on the OSS sound device at 'Dev' (usually /dev/mixer). 'Channel' is the sound channel, one of: "master", "pcm", "cd", "mic", "line", "video", "phonein", "phoneout" or "all". - -'Delta' is the amount to increase by, +- in the range 0-255. diff --git a/libUseful-2.6/Docs/string.txt b/libUseful-2.6/Docs/string.txt deleted file mode 100755 index 162ccae..0000000 --- a/libUseful-2.6/Docs/string.txt +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef LIBUSEFUL_STRING -#define LIBUSEFUL_STRING - -#include -#include //for strlen, used below in StrLen - -#define GETTOKEN_QUOTES 1 -#define GETTOKEN_MULTI_SEPARATORS 2 - -#define MATCH_TOKEN_PART 1 -#define MATCH_TOKEN_CASE 2 - -#ifdef __cplusplus -extern "C" { -#endif - -//A few very simple and frequently used functions can be reduced -//down to macros using weird stuff like the ternary condition -//operator '?' and the dreaded comma operator ',' -#define StrLen(str) ( str ? strlen(str) : 0 ) - -//int StrLen(char *Str); -char *DestroyString(char *); -int CompareStr(const char *S1, const char *S2); -char *CopyStrLen(char *,const char *,int); -char *CopyStr(char *, const char *); -char *MCatStr(char *, const char *, ...); -char *MCopyStr(char *, const char *, ...); -char *CatStr(char *, const char *); -char *CatStrLen(char *,const char *,int); -char *VFormatStr(char *,const char *,va_list); -char *FormatStr(char *,const char *,...); -char *AddCharToStr(char *,char); -inline char *AddCharToBuffer(char *Buffer, int BuffLen, char Char); -inline char *AddBytesToBuffer(char *Buffer, int BuffLen, char *Bytes, int Len); -char *SetStrLen(char *,int); -char *strlwr(char *); -char *strrep(char *,char, char); -char *CloneString(const char *); -void StripTrailingWhitespace(char *); -void StripLeadingWhitespace(char *); -void StripCRLF(char *); -void StripQuotes(char *); -char *QuoteCharsInStr(char *Buffer, const char *String,const char *QuoteChars); -char *DeQuoteStr(char *Buffer, const char *Line); -char *EnquoteStr(char *Out, const char *In); -int MatchTokenFromList(const char *Token,char **List, int Flags); -int MatchLineStartFromList(const char *Token,char **List); -char *GetToken(const char *SearchStr, const char *Delim, char **Token, int Flags); - -#ifdef __cplusplus -} -#endif - - - - -#endif - diff --git a/libUseful-2.6/Docs/unix_socket.txt b/libUseful-2.6/Docs/unix_socket.txt deleted file mode 100755 index aabed9a..0000000 --- a/libUseful-2.6/Docs/unix_socket.txt +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef LIBUSEFUL_UNIXSOCK_H -#define LIBUSEFUL_UNIXSOCK_H - -#include "file.h" -#include "defines.h" - -int InitUnixServerSocket(const char *Path, int SockType); -int OpenUnixSocket(const char *Path, int SockType); -int STREAMConnectUnixSocket(STREAM *S, const char *Path, int SockType); - -#endif diff --git a/libUseful-2.6/EncryptedFiles.c b/libUseful-2.6/EncryptedFiles.c deleted file mode 100755 index 18d38e5..0000000 --- a/libUseful-2.6/EncryptedFiles.c +++ /dev/null @@ -1,80 +0,0 @@ -#include "EncryptedFiles.h" - -char *FormatEncryptArgs(char *RetBuff, int Flags, const char *Cipher, const char *Key, const char *InitVector, const char *Salt ) -{ -char *EncryptArgs=NULL, *Tempstr=NULL; - -EncryptArgs=CopyStr(RetBuff,""); - -EncryptArgs=CopyStr(EncryptArgs,"Cipher="); -EncryptArgs=CatStr(EncryptArgs,Cipher); - - -if (StrLen(Key)) -{ -if (Flags & FLAG_HEXKEY) Tempstr=FormatStr(Tempstr," hexkey='%s'",Key); -else Tempstr=FormatStr(Tempstr," key='%s'",Key); -EncryptArgs=CatStr(EncryptArgs,Tempstr); -} - -if (StrLen(InitVector)) -{ -if (Flags & FLAG_HEXIV) Tempstr=FormatStr(Tempstr," hexiv='%s'",InitVector); -else Tempstr=FormatStr(Tempstr," iv='%s'",InitVector); -EncryptArgs=CatStr(EncryptArgs,Tempstr); -} - -if (StrLen(Salt)) -{ -if (Flags & FLAG_HEXSALT) Tempstr=FormatStr(Tempstr," hexsalt='%s'",Salt); -else Tempstr=FormatStr(Tempstr," salt='%s'",Salt); -EncryptArgs=CatStr(EncryptArgs,Tempstr); -} - - -if (Flags & FLAG_NOPAD_DATA) EncryptArgs=CatStr(EncryptArgs," PadBlock=N"); - -return(EncryptArgs); -} - - - -int AddEncryptionHeader(STREAM *S, int Flags, const char *Cipher, const char *Key, const char *InitVector, const char *Salt) -{ -char *EncryptArgs=NULL; -char *Tempstr=NULL; -int result=FALSE; - - -EncryptArgs=FormatEncryptArgs(EncryptArgs,Flags, Cipher, Key, InitVector,Salt); -if (STREAMAddStandardDataProcessor(S,"Crypto",Cipher,EncryptArgs)) -{ - EncryptArgs=FormatEncryptArgs(EncryptArgs,Flags, Cipher, "", InitVector,Salt); - Tempstr=FormatStr(Tempstr,"ENCR %s\n",EncryptArgs); - STREAMWriteLine(Tempstr,S); - result=TRUE; -} - -DestroyString(Tempstr); -DestroyString(EncryptArgs); - -return(result); -} - - - -void HandleDecryptionHeader(STREAM *S, const char *Header, const char *Key) -{ -const char *ptr; -char *Tempstr=NULL; - -ptr=Header; -if (strncmp(ptr,"ENCR ",5)==0) ptr+=5; -Tempstr=MCopyStr(Tempstr,ptr," key='",Key,"'",NULL); - -fprintf(stderr,"SASDP: [%s]\n",Tempstr); -STREAMAddStandardDataProcessor(S,"crypto","",Tempstr); -DestroyString(Tempstr); -} - - diff --git a/libUseful-2.6/EncryptedFiles.h b/libUseful-2.6/EncryptedFiles.h deleted file mode 100755 index bbeb0ff..0000000 --- a/libUseful-2.6/EncryptedFiles.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef LIBUSEFUL_ENCRYPTEDFILES_H -#define LIBUSEFUL_ENCRYPTEDFILES_H - -#include "DataProcessing.h" -#include "file.h" - -#define FLAG_ENCRYPT 1 -#define FLAG_DECRYPT 2 -#define FLAG_HEXKEY 4 -#define FLAG_HEXIV 8 -#define FLAG_HEXSALT 16 -#define FLAG_SPEED 64 -#define FLAG_NOPAD_DATA 128 - - - -#ifdef __cplusplus -extern "C" { -#endif - -char *FormatEncryptArgs(char *RetBuff,int Flags, const char *Cipher, const char *Key, const char *InitVector, const char *Salt ); -int AddEncryptionHeader(STREAM *S, int Flags, const char *Cipher, const char *Key, const char *InitVector, const char *Salt); -void HandleDecryptionHeader(STREAM *S, const char *Header, const char *Key); - - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/FileSystem.c b/libUseful-2.6/FileSystem.c deleted file mode 100755 index 34e2704..0000000 --- a/libUseful-2.6/FileSystem.c +++ /dev/null @@ -1,253 +0,0 @@ -#include "FileSystem.h" -#include - -const char *GetBasename(const char *Path) -{ -const char *ptr; -int len; - -len=StrLen(Path); -if (len==0) return(""); -if (len==1) return(Path); - -ptr=Path+len-1; -while (ptr > Path) -{ - if ((*ptr=='/') && (*(ptr+1) != '\0')) break; - ptr--; -} - -if ((*ptr=='/') && (*(ptr+1) != '\0')) ptr++; - -return(ptr); -} - - -char *SlashTerminateDirectoryPath(char *DirPath) -{ -char *ptr, *RetStr=NULL; - -if (! DirPath) return(CopyStr(DirPath,"/")); -RetStr=DirPath; -ptr=RetStr+StrLen(RetStr)-1; -if (*ptr != '/') RetStr=AddCharToStr(RetStr,'/'); - -return(RetStr); -} - - -char *StripDirectorySlash(char *DirPath) -{ -char *ptr; - -//don't strip '/' (root dir) -if (StrLen(DirPath)==1) return(DirPath); -ptr=DirPath+StrLen(DirPath)-1; - -if (*ptr == '/') *ptr='\0'; - -return(DirPath); -} - - -int MakeDirPath(const char *Path, int DirMask) -{ - const char *ptr; - char *Tempstr=NULL; - int result=-1; - - ptr=Path; - if (*ptr=='/') ptr++; - ptr=strchr(ptr, '/'); - while (ptr) - { - Tempstr=CopyStrLen(Tempstr,Path,ptr-Path); - result=mkdir(Tempstr, DirMask); - if ((result==-1) && (errno != EEXIST)) break; - ptr=strchr(++ptr, '/'); - } - DestroyString(Tempstr); - if (result==0) return(TRUE); - return(FALSE); -} - - - -int ChangeFileExtension(const char *FilePath, const char *NewExt) -{ -char *ptr; -char *Tempstr=NULL; -int result; - -Tempstr=CopyStr(Tempstr,FilePath); -ptr=strrchr(Tempstr,'/'); -if (!ptr) ptr=Tempstr; -ptr=strrchr(ptr,'.'); -if (! ptr) ptr=Tempstr+StrLen(Tempstr); -*ptr='\0'; - -if (*NewExt=='.') Tempstr=CatStr(Tempstr,NewExt); -else Tempstr=MCatStr(Tempstr,".",NewExt,NULL); -result=rename(FilePath,Tempstr); - -DestroyString(Tempstr); -if (result==0) return(TRUE); -else return(FALSE); -} - - -int FindFilesInPath(const char *File, const char *Path, ListNode *Files) -{ -char *Tempstr=NULL, *CurrPath=NULL, *ptr; -int i; -glob_t Glob; - -if (*File=='/') -{ - CurrPath=CopyStr(CurrPath,""); - ptr=""; //so we execute once below -} -else ptr=GetToken(Path,":",&CurrPath,0); -while (ptr) -{ -CurrPath=SlashTerminateDirectoryPath(CurrPath); -Tempstr=MCopyStr(Tempstr,CurrPath,File,NULL); - -glob(Tempstr,0,0,&Glob); -for (i=0; i < Glob.gl_pathc; i++) ListAddItem(Files,CopyStr(NULL,Glob.gl_pathv[i])); -globfree(&Glob); - -ptr=GetToken(ptr,":",&CurrPath,0); -} - -DestroyString(Tempstr); -DestroyString(CurrPath); - -return(ListSize(Files)); -} - - - -char *FindFileInPath(char *InBuff, const char *File, const char *Path) -{ -char *Tempstr=NULL, *CurrPath=NULL, *RetStr=NULL, *ptr; - -RetStr=CopyStr(InBuff,""); - -if (*File=='/') -{ - CurrPath=CopyStr(CurrPath,""); - ptr=""; //so we execute once below -} -else ptr=GetToken(Path,":",&CurrPath,0); - -while (ptr) -{ -CurrPath=SlashTerminateDirectoryPath(CurrPath); -Tempstr=MCopyStr(Tempstr,CurrPath,File,NULL); -if (access(Tempstr,F_OK)==0) -{ -RetStr=CopyStr(RetStr,Tempstr); -break; -} - -ptr=GetToken(ptr,":",&CurrPath,0); -} - -DestroyString(Tempstr); -DestroyString(CurrPath); - -return(RetStr); -} - - -/* This checks if a certain file exists (not if we can open it etc, just if */ -/* we can stat it, this is useful for checking pid files etc). */ -int FileExists(const char *FileName) -{ -struct stat StatData; - -if (stat(FileName,&StatData) == 0) return(1); -else return(0); -} - - -#ifdef HAVE_FANOTIFY - -#include -#include -#include - - -/* -+ fd = fanotify_init (0, 0); -+ if (fd < 0 && 0) -+ { -+ if (errno == ENOSYS) -+ { -+ puts ("SKIP: missing support for fanotify (check CONFIG_FANOTIFY=y)"); -+ return 0; -+ } -+ -+ perror ("fanotify_init (0, 0) failed"); -+ return 1; -+ } -+ -+ ret = fanotify_mark (fd, FAN_MARK_ADD | FAN_MARK_MOUNT, FAN_ACCESS -+ | FAN_MODIFY | FAN_OPEN | FAN_CLOSE | FAN_ONDIR -+ | FAN_EVENT_ON_CHILD, AT_FDCWD, "."); -+ if (ret) -+ { -+ perror ("fanotify_mark (...) failed"); -+ return 1; -+ } -+ -+ puts ("All OK"); -+ return 0; -+} -*/ - - -int FileNotifyInit(const char *Path, int Flags) -{ -char *Token=NULL, *ptr; -int fd; - -fd=fanotify_init(Flags, O_RDWR); -if (fd==-1) return(fd); - -ptr=GetToken(Path,":",&Token,0); -while (ptr) -{ - fanotify_mark(fd, FAN_MARK_ADD, FAN_CLOSE_WRITE, -1, NULL); - - ptr=GetToken(ptr,":",&Token,0); -} - -DestroyString(Token); - -return(fd); -} - - -int FileNotifyGetNext(int fd, char **Path) -{ -struct fanotify_event_metadata metadata; -char *Tempstr=NULL; -int result; - -result=read(fd, &metadata, sizeof(struct fanotify_event_metadata)); -if (result < sizeof(struct fanotify_event_metadata)) return(-1); - -if (Path) -{ - Tempstr=FormatStr(Tempstr, "/proc/self/fd/%d", metadata.fd); - *Path=SetStrLen(*Path,PATH_MAX +1); - readlink(Tempstr,*Path,PATH_MAX +1); -} - -DestroyString(Tempstr); -return(metadata.fd); -} - -#endif diff --git a/libUseful-2.6/FileSystem.h b/libUseful-2.6/FileSystem.h deleted file mode 100755 index 80a06f9..0000000 --- a/libUseful-2.6/FileSystem.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef LIBUSEFUL_FILEPATH_H -#define LIBUSEFUL_FILEPATH_H - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -const char *GetBasename(const char *Path); -char *SlashTerminateDirectoryPath(char *DirPath); -char *StripDirectorySlash(char *DirPath); -int FileExists(const char *); -int MakeDirPath(const char *Path, int DirMask); -int FindFilesInPath(const char *File, const char *Path, ListNode *Files); -char *FindFileInPath(char *InBuff, const char *File, const char *Path); -int ChangeFileExtension(const char *FilePath, const char *NewExt); -int FindFilesInPath(const char *File, const char *Path, ListNode *Files); - - -int FileNotifyInit(const char *Path, int Flags); -int FileNotifyGetNext(int fd, char **Path); - - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/GeneralFunctions.c b/libUseful-2.6/GeneralFunctions.c deleted file mode 100755 index dddb66c..0000000 --- a/libUseful-2.6/GeneralFunctions.c +++ /dev/null @@ -1,526 +0,0 @@ -#include "includes.h" -#include "base64.h" -#include "Hash.h" -#include "Time.h" -#include -#include -#include "base64.h" - -//xmemset uses a 'volatile' pointer so that it won't be optimized out -void xmemset(char *Str, char fill, off_t size) -{ -volatile char *p; - -for (p=Str; p < (Str+size); p++) *p=fill; -} - - -int WritePidFile(char *ProgName) -{ -char *Tempstr=NULL; -int fd; - - -if (*ProgName=='/') Tempstr=CopyStr(Tempstr,ProgName); -else Tempstr=FormatStr(Tempstr,"/var/run/%s.pid",ProgName); - -fd=open(Tempstr,O_CREAT | O_TRUNC | O_WRONLY,0600); -if (fd > -1) -{ - fchmod(fd,0644); - if (flock(fd,LOCK_EX|LOCK_NB) !=0) - { - close(fd); - exit(1); - } - Tempstr=FormatStr(Tempstr,"%d\n",getpid()); - write(fd,Tempstr,StrLen(Tempstr)); -} - -//Don't close 'fd'! - -DestroyString(Tempstr); - -return(fd); -} - - -void CloseOpenFiles() -{ - int i; - - for (i=3; i < 1024; i++) close(i); -} - - -char *BytesToHexStr(char *Buffer, char *Bytes, int len) -{ -int i; -char *Str=NULL, *ptr; - - -Str=SetStrLen(Buffer,(len *2) +1); -ptr=Str; -for (i=0; i < len; i++) -{ - snprintf(ptr,2,"%02x",Bytes[i]); - ptr+=2; -} -*ptr='\0'; - -return(Str); -} - - -int HexStrToBytes(char **Buffer, char *HexStr) -{ -int i, len; -char *Str=NULL, *ptr; - -len=StrLen(HexStr); -*Buffer=SetStrLen(*Buffer,len / 2); -ptr=*Buffer; -for (i=0; i < len; i+=2) -{ - Str=CopyStrLen(Str,HexStr+i,2); - *ptr=strtol(Str,NULL,16); - ptr++; -} - -DestroyString(Str); -return(len / 2); -} - - -char *Ascii85(char *RetStr, const char *Bytes, int ilen, const char *CharMap) -{ -const char *ptr, *block, *end; -uint32_t val, mod; -int olen=0, i; -char Buff[6]; - -end=Bytes+ilen; -for (ptr=Bytes; ptr < end; ) -{ - block=ptr; - val = ((*ptr & 0xFF) << 24); ptr++; - if (ptr < end) - { - val |= ((*ptr & 0xFF) << 16); ptr++; - } - - if (ptr < end) - { - val |= ((*ptr & 0xFF) << 8); ptr++; - } - - if (ptr < end) - { - val |= (*ptr & 0xFF); ptr++; - } - - if (val==0) strcpy(Buff,"z"); - else for (i=4; i >-1; i--) - { - mod=val % 85; - val /= 85; - Buff[i]=CharMap[mod & 0xFF]; - } - - //we only add as many characters as we encoded - //so for the last chracter - RetStr=CatStrLen(RetStr,Buff,ptr-block); -} - -return(RetStr); -} - - -char *EncodeBytes(char *Buffer, const char *Bytes, int len, int Encoding) -{ -char *Tempstr=NULL, *RetStr=NULL; -int i; - -RetStr=CopyStr(Buffer,""); -switch (Encoding) -{ - case ENCODE_BASE64: - RetStr=SetStrLen(RetStr,len * 4); - to64frombits((unsigned char *) RetStr,(unsigned char *) Bytes,len); break; - break; - - case ENCODE_IBASE64: - RetStr=SetStrLen(RetStr,len * 4); - Radix64frombits((unsigned char *) RetStr,(unsigned char *) Bytes,len,IBASE64_CHARS,'\0'); break; - break; - - case ENCODE_PBASE64: - RetStr=SetStrLen(RetStr,len * 4); - Radix64frombits((unsigned char *) RetStr,(unsigned char *) Bytes,len,SBASE64_CHARS,'\0'); break; - break; - - - case ENCODE_CRYPT: - RetStr=SetStrLen(RetStr,len * 4); - Radix64frombits((unsigned char *) RetStr,(unsigned char *) Bytes,len,CRYPT_CHARS,'\0'); break; - break; - - case ENCODE_XXENC: - RetStr=SetStrLen(RetStr,len * 4); - Radix64frombits((unsigned char *) RetStr,(unsigned char *) Bytes,len,XXENC_CHARS,'+'); break; - break; - - case ENCODE_UUENC: - RetStr=SetStrLen(RetStr,len * 4); - Radix64frombits((unsigned char *) RetStr,(unsigned char *) Bytes,len,UUENC_CHARS,'\''); break; - break; - - case ENCODE_ASCII85: - RetStr=Ascii85(RetStr,Bytes,len,ASCII85_CHARS); break; - break; - - case ENCODE_Z85: - RetStr=Ascii85(RetStr,Bytes,len,Z85_CHARS); break; - break; - - case ENCODE_OCTAL: - for (i=0; i < len; i++) - { - Tempstr=FormatStr(Tempstr,"%03o",Bytes[i] & 255); - RetStr=CatStr(RetStr,Tempstr); - } - break; - - case ENCODE_DECIMAL: - for (i=0; i < len; i++) - { - Tempstr=FormatStr(Tempstr,"%03d",Bytes[i] & 255); - RetStr=CatStr(RetStr,Tempstr); - } - break; - - case ENCODE_HEX: - for (i=0; i < len; i++) - { - Tempstr=FormatStr(Tempstr,"%02x",Bytes[i] & 255); - RetStr=CatStr(RetStr,Tempstr); - } - break; - - case ENCODE_HEXUPPER: - for (i=0; i < len; i++) - { - Tempstr=FormatStr(Tempstr,"%02X",Bytes[i] & 255); - RetStr=CatStr(RetStr,Tempstr); - } - break; - - - default: - RetStr=SetStrLen(RetStr,len ); - memcpy(RetStr,Bytes,len); - RetStr[len]='\0'; - break; -} - -DestroyString(Tempstr); -return(RetStr); -} - - - -#include -#include - -int SwitchUser(const char *NewUser) -{ -struct passwd *pwent; -char *ptr; - - pwent=getpwnam(NewUser); - if (! pwent) - { - syslog(LOG_ERR,"ERROR: Cannot switch to user '%s'. No such user",NewUser); - ptr=LibUsefulGetValue("SwitchUserAllowFail"); - if (ptr && (strcasecmp(ptr,"yes")==0)) return(FALSE); - exit(1); - } - - - if (setreuid(pwent->pw_uid,pwent->pw_uid) !=0) - { - syslog(LOG_ERR,"ERROR: Switch to user '%s' failed. Error was: %s",NewUser,strerror(errno)); - ptr=LibUsefulGetValue("SwitchUserAllowFail"); - if (ptr && (strcasecmp(ptr,"yes")==0)) return(FALSE); - exit(1); - } - - return(TRUE); -} - - -int SwitchGroup(const char *NewGroup) -{ -struct group *grent; -char *ptr; - - grent=getgrnam(NewGroup); - if (! grent) - { - syslog(LOG_ERR,"ERROR: Cannot switch to group '%s'. No such group",NewGroup); - ptr=LibUsefulGetValue("SwitchGroupAllowFail"); - if (ptr && (strcasecmp(ptr,"yes")==0)) return(FALSE); - exit(1); - } - - - if (setgid(grent->gr_gid) !=0) - { - syslog(LOG_ERR,"ERROR: Switch to group '%s' failed. Error was: %s",NewGroup,strerror(errno)); - ptr=LibUsefulGetValue("SwitchGroupAllowFail"); - if (ptr && (strcasecmp(ptr,"yes")==0)) return(FALSE); - exit(1); - } - - return(TRUE); -} - - - -char *GetCurrUserHomeDir() -{ -struct passwd *pwent; - - pwent=getpwuid(getuid()); - if (! pwent) return(NULL); - return(pwent->pw_dir); -} - - - -void ColLibDefaultSignalHandler(int sig) -{ - -} - - -int CreateLockFile(char *FilePath, int Timeout) -{ -int fd, result; - -SetTimeout(Timeout); -fd=open(FilePath, O_CREAT | O_RDWR, 0600); -if (fd <0) return(-1); -result=flock(fd,LOCK_EX); -alarm(0); - -if (result==-1) -{ - close(fd); - return(-1); -} -return(fd); -} - - - -int GenerateRandomBytes(char **RetBuff, int ReqLen, int Encoding) -{ -struct utsname uts; -int i, len; -clock_t ClocksStart, ClocksEnd; -char *Tempstr=NULL, *RandomBytes=NULL; -int fd; - - -fd=open("/dev/urandom",O_RDONLY); -if (fd > -1) -{ - RandomBytes=SetStrLen(RandomBytes,ReqLen); - len=read(fd,RandomBytes,ReqLen); - close(fd); -} -else -{ - ClocksStart=clock(); - //how many clock cycles used here will depend on overall - //machine activity/performance/number of running processes - for (i=0; i < 100; i++) sleep(0); - uname(&uts); - ClocksEnd=clock(); - - - Tempstr=FormatStr(Tempstr,"%lu:%lu:%lu:%lu:%llu\n",getpid(),getuid(),ClocksStart,ClocksEnd,GetTime(TIME_MILLISECS)); - //This stuff should be unique to a machine - Tempstr=CatStr(Tempstr, uts.sysname); - Tempstr=CatStr(Tempstr, uts.nodename); - Tempstr=CatStr(Tempstr, uts.machine); - Tempstr=CatStr(Tempstr, uts.release); - Tempstr=CatStr(Tempstr, uts.version); - - - len=HashBytes(&RandomBytes, "sha256", Tempstr, StrLen(Tempstr), 0); - if (len > ReqLen) len=ReqLen; -} - - -*RetBuff=EncodeBytes(*RetBuff, RandomBytes, len, Encoding); - -DestroyString(Tempstr); -DestroyString(RandomBytes); - -return(len); -} - - - - -char *GetRandomData(char *RetBuff, int len, char *AllowedChars) -{ -int fd; -char *Tempstr=NULL, *RetStr=NULL; -int i; -uint8_t val, max_val; - -srand(time(NULL)); -max_val=StrLen(AllowedChars); - -RetStr=CopyStr(RetBuff,""); -fd=open("/dev/urandom",O_RDONLY); -for (i=0; i < len ; i++) -{ - if (fd > -1) read(fd,&val,1); - else val=rand(); - - RetStr=AddCharToStr(RetStr,AllowedChars[val % max_val]); -} - -if (fd) close(fd); - -DestroyString(Tempstr); -return(RetStr); -} - - -char *GetRandomHexStr(char *RetBuff, int len) -{ -return(GetRandomData(RetBuff,len,HEX_CHARS)); -} - - -char *GetRandomAlphabetStr(char *RetBuff, int len) -{ -return(GetRandomData(RetBuff,len,ALPHA_CHARS)); -} - - - - - -#define KILOBYTE 1000 -#define MEGABYTE 1000000 -#define GIGABYTE 1000000000 -#define TERABYTE 1000000000000 - -#define KIBIBYTE 1024 -#define MEGIBYTE 1024 * 1024 -#define GIGIBYTE 1024 * 1024 * 1024 -#define TERIBYTE 1024 * 1024 * 1024 *1024 - -double ParseHumanReadableDataQty(char *Data, int Type) -{ -double val; -char *ptr=NULL; -double KAY,MEG,GIG,TERA; - -if (Type) -{ -KAY=KILOBYTE; -MEG=MEGABYTE; -GIG=GIGABYTE; -TERA=TERABYTE; -} -else -{ -KAY=KIBIBYTE; -MEG=MEGIBYTE; -GIG=GIGIBYTE; -TERA=TERIBYTE; -} - - val=strtod(Data,&ptr); - while (isspace(*ptr)) ptr++; - if (*ptr=='k') val=val * KAY; - if (*ptr=='M') val=val * MEG; - if (*ptr=='G') val=val * GIG; - if (*ptr=='T') val=val * TERA; - - -return(val); -} - - - -char *GetHumanReadableDataQty(double Size, int Type) -{ -static char *Str=NULL; -double val=0; -char kMGT=' '; -//Set to 0 to keep valgrind happy -double KAY=0,MEG=0,GIG=0,TERA=0; - -if (Type) -{ -KAY=KILOBYTE; -MEG=MEGABYTE; -GIG=GIGABYTE; -//TERA=TERABYTE; -} -else -{ -KAY=KIBIBYTE; -MEG=MEGIBYTE; -GIG=GIGIBYTE; -//TERA=TERIBYTE; -} - val=Size; - kMGT=' '; -/* if (val > (TERA)) - { - val=val / TERA; - kMGT='T'; - } - else*/ - if (val >= (GIG)) - { - val=val / GIG; - kMGT='G'; - } - else if (val >= (MEG)) - { - val=val / MEG; - kMGT='M'; - - } - else if (val >= (KAY)) - { - val=val / KAY; - kMGT='k'; - } - -Str=FormatStr(Str,"%0.1f%c",(float) val,kMGT); -return(Str); -} - - - -char *DecodeBase64(char *Return, int *len, char *Text) -{ -char *RetStr; - -RetStr=SetStrLen(Return,StrLen(Text) *2); -*len=from64tobits(RetStr,Text); - -return(RetStr); -} - diff --git a/libUseful-2.6/GeneralFunctions.h b/libUseful-2.6/GeneralFunctions.h deleted file mode 100755 index f5fa8bf..0000000 --- a/libUseful-2.6/GeneralFunctions.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef LIBUSEFUL_GENERAL_H -#define LIBUSEFUL_GENERAL_H - -#include -#include "defines.h" - - - -#ifdef __cplusplus -extern "C" { -#endif - -void xmemset(char *Str, char fill, off_t size); -int WritePidFile(char *ProgName); -int HexStrToBytes(char **Buffer, char *HexStr); -char *BytesToHexStr(char *Buffer, char *Bytes, int len); -char *EncodeBytes(char *Buffer, const char *Bytes, int len, int Encoding); - - -int SwitchUser(const char *User); -int SwitchGroup(const char *Group); -char *GetCurrUserHomeDir(); - - -void ColLibDefaultSignalHandler(int sig); -int CreateLockFile(char *FilePath,int Timeout); - -char *GetRandomData(char *RetBuff, int len, char *AllowedChars); -char *GetRandomHexStr(char *RetBuff, int len); -char *GetRandomAlphabetStr(char *RetBuff, int len); - -void CloseOpenFiles(); - -int BASIC_FUNC_EXEC_COMMAND(void *Data); - -double ParseHumanReadableDataQty(char *Data, int Type); -char *GetHumanReadableDataQty(double Size, int Type); - - -int GenerateRandomBytes(char **RetBuff, int ReqLen, int Encoding); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/Hash.c b/libUseful-2.6/Hash.c deleted file mode 100755 index 1f5f0ca..0000000 --- a/libUseful-2.6/Hash.c +++ /dev/null @@ -1,657 +0,0 @@ -#include "Hash.h" -#include "string.h" - -#define HMAC_BLOCKSIZE 64 - - -typedef void (*HASH_INIT_FUNC)(THash *Hash, int Len); - - -char *HashTypes[]={"md5","sha1","sha256","sha512","whirlpool","jh-224","jh-256","jh-384","jh-512",NULL}; - - -void HMACUpdate(THash *HMAC, char *Data, int Len) -{ -THash *Hash; - -Hash=(THash *) HMAC->Ctx; -Hash->Update(Hash,Data,Len); -} - - - -int HMACFinish(THash *HMAC, int Encoding, char **HashStr) -{ -THash *Hash; -int len, result; - - -Hash=(THash *) HMAC->Ctx; - -//We've done with this now, blank it and reuse for the inner result -HMAC->Key1=CopyStr(HMAC->Key1,""); -len=Hash->Finish(Hash,&HMAC->Key1); - -HMAC->Key2=SetStrLen(HMAC->Key2,HMAC_BLOCKSIZE+len); -memcpy(HMAC->Key2+HMAC_BLOCKSIZE,HMAC->Key1,len); - -//Hash->Type -result=HashBytes(HashStr,Hash->Type,HMAC->Key2,HMAC_BLOCKSIZE+len,Encoding); - -return(result); -} - - -void HMACPrepare(THash *HMAC, char *Data, int Len) -{ -int i; -char *Key=NULL, *Tempstr=NULL; - -//Whatever we've been given as a key, we have to turn it into a -//key of 'HMAC_BLOCKSIZE', either by hashing it to make it shorter -//or by padding with NULLS -Key=SetStrLen(Key,HMAC_BLOCKSIZE); -memset(Key,0,HMAC_BLOCKSIZE); - -if (Len > HMAC_BLOCKSIZE) -{ - HMAC->Key1Len=HashBytes(&Tempstr,HMAC->Type,HMAC->Key1,HMAC->Key1Len,0); - memcpy(Key,Tempstr,HMAC->Key1Len); -} -else -{ - memcpy(Key,HMAC->Key1,HMAC->Key1Len); -} - -HMAC->Key1=SetStrLen(HMAC->Key1,HMAC_BLOCKSIZE); -HMAC->Key2=SetStrLen(HMAC->Key2,HMAC_BLOCKSIZE); -HMAC->Key1Len=HMAC_BLOCKSIZE; -HMAC->Key2Len=HMAC_BLOCKSIZE; - -for (i=0; i < HMAC_BLOCKSIZE; i++) -{ -//inner key -HMAC->Key1[i]=Key[i] ^ 0x36; -//outer key -HMAC->Key2[i]=Key[i] ^ 0x5c; -} - - -//first thing to be hashed is the inner key, then data is 'concatted' onto it -HMACUpdate(HMAC, HMAC->Key1, HMAC->Key1Len); -HMACUpdate(HMAC, Data, Len); -HMAC->Update=HMACUpdate; - -DestroyString(Tempstr); -DestroyString(Key); -} - - -void HMACInit(THash *Hash) -{ -Hash->Ctx=(void *) HashInit(Hash->Type+5); - -Hash->Update=HMACPrepare; -Hash->Finish=HMACFinish; -} - - -void HMACSetKey(THash *HMAC, char *Key, int Len) -{ -HMAC->Key1=SetStrLen(HMAC->Key1,Len); -memcpy(HMAC->Key1,Key,Len); -HMAC->Key1Len=Len; -} - - - -#include "crc32.h" - -void HashUpdateCRC(THash *Hash, char *Data, int Len) -{ -crc32Update((unsigned long *) &Hash->Ctx, (unsigned char *) Data, Len); -} - - -THash *HashCloneCRC(THash *Hash) -{ -THash *NewHash; - -NewHash=(THash *) calloc(1,sizeof(THash)); -NewHash->Type=CopyStr(NewHash->Type,Hash->Type); -NewHash->Ctx=(void *) calloc(1,sizeof(unsigned long)); -memcpy(NewHash->Ctx, Hash->Ctx, sizeof(unsigned long)); - -return(NewHash); -} - - -int HashFinishCRC(THash *Hash, char **HashStr) -{ -unsigned long crc; -int len; - -len=sizeof(unsigned long); -crc32Finish((unsigned long *) Hash->Ctx); -crc=htonl(* (unsigned long *) Hash->Ctx); - -*HashStr=SetStrLen(*HashStr,len); -memcpy(*HashStr,&crc,len); -return(len); -} - - -void HashInitCRC(THash *Hash, int Len) -{ -Hash->Ctx=(void *) calloc(1,sizeof(unsigned long)); -crc32Init((unsigned long *) Hash->Ctx); -Hash->Update=HashUpdateCRC; -Hash->Finish=HashFinishCRC; -Hash->Clone=HashCloneCRC; -} - - -#include "md5.h" -#define MD5LEN 16 - -void HashUpdateMD5(THash *Hash, char *Data, int Len) -{ -MD5Update((MD5_CTX *) Hash->Ctx, Data, Len); -} - - -THash *HashCloneMD5(THash *Hash) -{ -THash *NewHash; - -NewHash=(THash *) calloc(1,sizeof(THash)); -NewHash->Type=CopyStr(NewHash->Type,Hash->Type); -NewHash->Ctx=(void *) calloc(1,sizeof(MD5_CTX)); -memcpy(NewHash->Ctx, Hash->Ctx, sizeof(MD5_CTX)); -NewHash->Update=Hash->Update; -NewHash->Finish=Hash->Finish; -NewHash->Clone=Hash->Clone; - -return(NewHash); -} - - -int HashFinishMD5(THash *Hash, char **HashStr) -{ -int len; -char *DigestBuff=NULL; - -DigestBuff=(char *) calloc(1,MD5LEN+1); -MD5Final((unsigned char *) DigestBuff, (MD5_CTX *) Hash->Ctx); - -len=MD5LEN; -*HashStr=SetStrLen(*HashStr,len); -memcpy(*HashStr,DigestBuff,len); - -DestroyString(DigestBuff); - -return(len); -} - - -void HashInitMD5(THash *Hash, int Len) -{ -Hash->Ctx=(void *) calloc(1,sizeof(MD5_CTX)); -MD5Init((MD5_CTX *) Hash->Ctx); -Hash->Update=HashUpdateMD5; -Hash->Finish=HashFinishMD5; -Hash->Clone=HashCloneMD5; -} - -#include "sha1.h" -#define SHA1LEN 20 - -void HashUpdateSHA1(THash *Hash, char *Data, int Len) -{ -sha1_process_bytes(Data,Len,(struct sha1_ctx *) Hash->Ctx); -} - - -THash *HashCloneSHA1(THash *Hash) -{ -THash *NewHash; - -NewHash=(THash *) calloc(1,sizeof(THash)); -NewHash->Type=CopyStr(NewHash->Type,Hash->Type); -NewHash->Ctx=(void *) calloc(1,sizeof(struct sha1_ctx)); -memcpy(NewHash->Ctx, Hash->Ctx, sizeof(struct sha1_ctx)); - -return(NewHash); -} - - -int HashFinishSHA1(THash *Hash, char **HashStr) -{ -int len; -char *DigestBuff=NULL; - -DigestBuff=(char *) calloc(1,SHA1LEN+1); -sha1_finish_ctx((struct sha1_ctx *) Hash->Ctx, DigestBuff); - -len=SHA1LEN; -*HashStr=SetStrLen(*HashStr,len); -memcpy(*HashStr,DigestBuff,len); - -DestroyString(DigestBuff); - -return(len); -} - - - -#include "sha2.h" - -int HashFinishSHA256(THash *Hash, char **HashStr) -{ -int len; -char *DigestBuff=NULL; - -DigestBuff=(char *) calloc(1,SHA2_SHA256_DIGEST_LENGTH+1); -SHA2_SHA256_Final((unsigned char *) DigestBuff, (SHA2_SHA256_CTX *) Hash->Ctx); - -len=SHA2_SHA256_DIGEST_LENGTH; -*HashStr=SetStrLen(*HashStr,len); -memcpy(*HashStr,DigestBuff,len); - -DestroyString(DigestBuff); - -return(len); -} - - -THash *HashCloneSHA256(THash *Hash) -{ -THash *NewHash; - -NewHash=(THash *) calloc(1,sizeof(THash)); -NewHash->Type=CopyStr(NewHash->Type,Hash->Type); -NewHash->Ctx=(void *) calloc(1,sizeof(SHA2_SHA256_CTX)); -memcpy(NewHash->Ctx, Hash->Ctx, sizeof(SHA2_SHA256_CTX)); - -return(NewHash); -} - - -void HashUpdateSHA256(THash *Hash, char *Data, int Len) -{ -SHA2_SHA256_Update((SHA2_SHA256_CTX *) Hash->Ctx, (unsigned char *) Data, Len); -} - - -int HashFinishSHA512(THash *Hash, char **HashStr) -{ -int len; -char *DigestBuff=NULL; - -DigestBuff=(char *) calloc(1,SHA2_SHA512_DIGEST_LENGTH+1); -SHA2_SHA512_Final((unsigned char *) DigestBuff, (SHA2_SHA512_CTX *) Hash->Ctx); - -len=SHA2_SHA512_DIGEST_LENGTH; -*HashStr=SetStrLen(*HashStr,len); -memcpy(*HashStr,DigestBuff,len); - -DestroyString(DigestBuff); - -return(len); -} - - -void HashUpdateSHA512(THash *Hash, char *Data, int Len) -{ -SHA2_SHA512_Update((SHA2_SHA512_CTX *) Hash->Ctx, (unsigned char *) Data, Len); -} - - -THash *HashCloneSHA512(THash *Hash) -{ -THash *NewHash; - -NewHash=(THash *) calloc(1,sizeof(THash)); -NewHash->Type=CopyStr(NewHash->Type,Hash->Type); -NewHash->Ctx=(void *) calloc(1,sizeof(SHA2_SHA512_CTX)); -memcpy(NewHash->Ctx, Hash->Ctx, sizeof(SHA2_SHA512_CTX)); - -return(NewHash); -} - - - - -void HashInitSHA(THash *Hash, int Len) -{ - -switch (Len) -{ -case 512: -Hash->Ctx=(void *) calloc(1,sizeof(SHA2_SHA512_CTX)); -SHA2_SHA512_Init((SHA2_SHA512_CTX *) Hash->Ctx); -Hash->Update=HashUpdateSHA512; -Hash->Finish=HashFinishSHA512; -Hash->Clone=HashCloneSHA512; -break; - -case 256: -Hash->Ctx=(void *) calloc(1,sizeof(SHA2_SHA256_CTX)); -SHA2_SHA256_Init((SHA2_SHA256_CTX *) Hash->Ctx); -Hash->Update=HashUpdateSHA256; -Hash->Finish=HashFinishSHA256; -Hash->Clone=HashCloneSHA256; -break; - -default: -Hash->Ctx=(void *) calloc(1,sizeof(struct sha1_ctx)); -sha1_init_ctx((struct sha1_ctx *) Hash->Ctx); -Hash->Update=HashUpdateSHA1; -Hash->Finish=HashFinishSHA1; -Hash->Clone=HashCloneSHA1; -break; -} - -} - - - -#include "whirlpool.h" - -int HashFinishWhirlpool(THash *Hash, char **HashStr) -{ -int len; -char *DigestBuff=NULL; - -DigestBuff=(char *) calloc(1,WHIRLPOOL_DIGESTBYTES+1); -WHIRLPOOLfinalize((WHIRLPOOLstruct *) Hash->Ctx, (unsigned char *) DigestBuff); - -len=WHIRLPOOL_DIGESTBYTES; -*HashStr=SetStrLen(*HashStr,len); -memcpy(*HashStr,DigestBuff,len); - -DestroyString(DigestBuff); - -return(len); -} - - -void HashUpdateWhirlpool(THash *Hash, char *Data, int Len) -{ -WHIRLPOOLadd((unsigned char *) Data, Len * 8, (WHIRLPOOLstruct *) Hash->Ctx); -} - - -THash *HashCloneWhirlpool(THash *Hash) -{ -THash *NewHash; - -NewHash=(THash *) calloc(1,sizeof(THash)); -NewHash->Type=CopyStr(NewHash->Type,Hash->Type); -NewHash->Ctx=(void *) calloc(1,sizeof(WHIRLPOOLstruct *)); -memcpy(NewHash->Ctx, Hash->Ctx, sizeof(WHIRLPOOLstruct *)); - -return(NewHash); -} - - - -void HashInitWhirlpool(THash *Hash, int Len) -{ -Hash->Ctx=(void *) calloc(1,sizeof(WHIRLPOOLstruct)); -WHIRLPOOLinit((WHIRLPOOLstruct *) Hash->Ctx); -Hash->Update=HashUpdateWhirlpool; -Hash->Finish=HashFinishWhirlpool; -Hash->Clone=HashCloneWhirlpool; -} - - -#include "jh_ref.h" - -int HashFinishJH(THash *Hash, char **HashStr) -{ -int len; -char *DigestBuff=NULL; - -DigestBuff=(char *) calloc(1,1024); - -len=JHFinal((hashState *) Hash->Ctx, (unsigned char *) DigestBuff); -*HashStr=SetStrLen(*HashStr,len); -memcpy(*HashStr,DigestBuff,len); - -DestroyString(DigestBuff); - -return(len); -} - - - -void HashUpdateJH(THash *Hash, char *Data, int Len) -{ - JHUpdate( (hashState *) Hash->Ctx, (unsigned char *) Data, Len); -} - - -THash *HashCloneJH(THash *Hash) -{ -THash *NewHash; - -NewHash=(THash *) calloc(1,sizeof(THash)); -NewHash->Type=CopyStr(NewHash->Type,Hash->Type); -NewHash->Ctx=(void *) calloc(1,sizeof(hashState *)); -memcpy(NewHash->Ctx, Hash->Ctx, sizeof(hashState *)); - -return(NewHash); -} - - - -int HashInitJH(THash *Hash, int Length) -{ - -switch (Length) -{ - case 224: - case 256: - case 384: - case 512: - Hash->Ctx=(void *) calloc(1,sizeof(hashState)); - JHInit((hashState *) Hash->Ctx, Length); - Hash->Update=HashUpdateJH; - Hash->Finish=HashFinishJH; - Hash->Clone=HashCloneJH; - break; - - default: - return(FALSE); - break; -} - -return(TRUE); -} - - - - - - - -void HashDestroy(THash *Hash) -{ -//Hash->Ctx is destroyed in 'HashFinish' -DestroyString(Hash->Key1); -DestroyString(Hash->Key2); -DestroyString(Hash->Type); -if (Hash->Ctx) free(Hash->Ctx); -free(Hash); -} - - -void HashAvailableTypes(ListNode *Vars) -{ -int i; - -for (i=0; HashTypes[i] !=NULL; i++) SetVar(Vars,HashTypes[i], HashTypes[i]); - -} - - -THash *HashInit(const char *Type) -{ -THash *Hash=NULL; -char *InitialType=NULL; - -Hash=(THash *) calloc(1,sizeof(THash)); -Hash->Type=CopyStr(Hash->Type,Type); -strrep(Hash->Type,',',' '); - -GetToken(Hash->Type,"\\S",&InitialType,0); -if (strcasecmp(InitialType,"md5")==0) HashInitMD5(Hash, 0); -else if (strcasecmp(InitialType,"sha")==0) HashInitSHA(Hash, 0); -else if (strcasecmp(InitialType,"sha1")==0) HashInitSHA(Hash, 0); -else if (strcasecmp(InitialType,"sha256")==0) HashInitSHA(Hash, 256); -else if (strcasecmp(InitialType,"sha512")==0) HashInitSHA(Hash, 512); -else if (strcasecmp(InitialType,"sha-256")==0) HashInitSHA(Hash, 256); -else if (strcasecmp(InitialType,"sha-512")==0) HashInitSHA(Hash, 512); -else if (strcasecmp(InitialType,"whirl")==0) HashInitWhirlpool(Hash, 0); -else if (strcasecmp(InitialType,"whirlpool")==0) HashInitWhirlpool(Hash, 0); -else if (strcasecmp(InitialType,"jh224")==0) HashInitJH(Hash,224); -else if (strcasecmp(InitialType,"jh256")==0) HashInitJH(Hash,256); -else if (strcasecmp(InitialType,"jh384")==0) HashInitJH(Hash,384); -else if (strcasecmp(InitialType,"jh512")==0) HashInitJH(Hash,512); -else if (strcasecmp(InitialType,"jh-224")==0) HashInitJH(Hash,224); -else if (strcasecmp(InitialType,"jh-256")==0) HashInitJH(Hash,256); -else if (strcasecmp(InitialType,"jh-384")==0) HashInitJH(Hash,384); -else if (strcasecmp(InitialType,"jh-512")==0) HashInitJH(Hash,512); -//else if (strcasecmp(InitialType,"crc32")==0) HashInitCRC(Hash, 0); -else if (strncasecmp(InitialType,"hmac-",5)==0) HMACInit(Hash); -else -{ - HashDestroy(Hash); - Hash=NULL; -} - -DestroyString(InitialType); -return(Hash); -} - - -int HashFinish(THash *Hash, int Encoding, char **Return) -{ -char *Token=NULL, *Bytes=NULL, *Hashed=NULL, *ptr; -int len; - -ptr=GetToken(Hash->Type, "\\S", &Token, 0); -len=Hash->Finish(Hash, &Bytes); - -while (StrValid(ptr)) -{ - ptr=GetToken(ptr, "\\S", &Token, 0); - len=HashBytes(&Hashed, Token, Bytes, len, 0); - Bytes=SetStrLen(Bytes, len); - memcpy(Bytes,Hashed,len); -} - -if (Encoding > 0) -{ -*Return=EncodeBytes(*Return, Bytes, len, Encoding); -len=StrLen(*Return); -} -else -{ - *Return=SetStrLen(*Return, len); - memcpy(*Return, Bytes, len); -} - -HashDestroy(Hash); -DestroyString(Hashed); -DestroyString(Token); -DestroyString(Bytes); - -return(len); -} - - -int HashBytes(char **Return, char *Type, char *text, int len, int Encoding) -{ -THash *Hash; -int result; - -Hash=HashInit(Type); -if (! Hash) return(0); -Hash->Update(Hash, text, len); -result=HashFinish(Hash, Encoding, Return); - -return(result); -} - -int PBK2DF2(char **Return, char *Type, char *Bytes, int Len, char *Salt, int SaltLen, uint32_t Rounds, int Encoding) -{ -char *Tempstr=NULL, *Hash=NULL; -uint32_t RoundsBE; -int i, len, hlen; - -//Network byte order is big endian -RoundsBE=htonl(Rounds); - -Tempstr=SetStrLen(Tempstr, Len + SaltLen + 20); -memcpy(Tempstr, Bytes, Len); -memcpy(Tempstr+Len, Salt, SaltLen); -memcpy(Tempstr+Len+SaltLen, &RoundsBE, sizeof(uint32_t)); -len=Len+SaltLen+sizeof(uint32_t); - -for (i=0; i Update(Hash, Tempstr, result); - result=STREAMReadBytes(S,Tempstr,4096); -} - -DestroyString(Tempstr); -STREAMClose(S); - -result=HashFinish(Hash, Encoding, Return); - -return(result); -} - - - - diff --git a/libUseful-2.6/Hash.h b/libUseful-2.6/Hash.h deleted file mode 100755 index 1f0b79a..0000000 --- a/libUseful-2.6/Hash.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef LIBUSEFUL_HASH_H -#define LIBUSEFUL_HASH_H - -#include "file.h" -#include "includes.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct t_hash THash; - -typedef void (*HASH_UPDATE)(THash *Hash, char *Data, int DataLen); -typedef THash *(*HASH_CLONE)(THash *Hash); -typedef int (*HASH_FINISH)(THash *Hash, char **RetStr); - -struct t_hash -{ -char *Type; -char *Key1; -unsigned int Key1Len; -char *Key2; -unsigned int Key2Len; -void *Ctx; -HASH_UPDATE Update; -HASH_FINISH Finish; -HASH_CLONE Clone; -}; - -void HashAvailableTypes(ListNode *Vars); -THash *HashInit(const char *Type); -int HashFinish(THash *Hash, int Encoding, char **Return); -void HMACSetKey(THash *HMAC, char *Key, int Len); -void HashDestroy(THash *Hash); -int HashBytes(char **Return, char *Type, char *text, int len, int Encoding); -int HashFile(char **Return, char *Type, char *Path, int Encoding); -int PBK2DF2(char **Return, char *Type, char *Bytes, int Len, char *Salt, int SaltLen, uint32_t Rounds, int Encoding); - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/LICENCE b/libUseful-2.6/LICENCE deleted file mode 100755 index 94a9ed0..0000000 --- a/libUseful-2.6/LICENCE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/libUseful-2.6/Log.c b/libUseful-2.6/Log.c deleted file mode 100755 index 62bd83e..0000000 --- a/libUseful-2.6/Log.c +++ /dev/null @@ -1,373 +0,0 @@ -#include "Log.h" -#include "Time.h" -#include - - - -//When logs are used by 'child processes', it's only the 'parent' process that should be -//able to delete/reopen the log. Otherwise the child can delete a log that the parent -//keeps writing to, and keeps handing to child processes. Thus we record the parent pid -pid_t ParentPID=0; - - - -ListNode *LogFiles=NULL; -TLogFile *LogFileDefaults=NULL; - - -STREAM *LogFileInternalDoRotate(TLogFile *LogFile); - - -int LogFileSetDefaults(int Flags, int MaxSize, int MaxRotate, int FlushInterval) -{ - LogFileDefaults=(TLogFile *) calloc(1,sizeof(TLogFile)); - LogFileDefaults->Flags=Flags; - LogFileDefaults->MaxSize=MaxSize; - LogFileDefaults->MaxRotate=MaxRotate; - LogFileDefaults->FlushInterval=FlushInterval; - LogFileDefaults->LogFacility=LOG_USER; - if (ParentPID==0) ParentPID=getpid(); -} - -TLogFile *LogFileGetEntry(const char *FileName) -{ - ListNode *Node; - TLogFile *LogFile=NULL; - STREAM *S=NULL; - - if (! StrLen(FileName)) return(NULL); - if (! LogFiles) LogFiles=ListCreate(); - if (! LogFileDefaults) LogFileSetDefaults(LOGFILE_TIMESTAMP | LOGFILE_FLUSH | LOGFILE_LOGPID | LOGFILE_LOGUSER, 100000000, 0, 1); - - Node=ListFindNamedItem(LogFiles,FileName); - if (Node) LogFile=(TLogFile *) Node->Item; - else - { - if (strcmp(FileName,"STDOUT")==0) S=STREAMFromFD(1); - else if (strcmp(FileName,"STDERR")==0) S=STREAMFromFD(2); - else if (strcmp(FileName,"SYSLOG")==0) S=STREAMCreate(); - else - { - S=STREAMOpenFile(FileName,SF_CREAT | SF_APPEND | SF_WRONLY | SF_NOCACHE); - } - - if (S) - { - LogFile=(TLogFile *) calloc(1,sizeof(TLogFile)); - LogFile->Path=CopyStr(LogFile->Path,FileName); - LogFile->LogFacility=LogFileDefaults->LogFacility; - LogFile->Flags=LogFileDefaults->Flags; - LogFile->MaxSize=LogFileDefaults->MaxSize; - LogFile->MaxRotate=LogFileDefaults->MaxRotate; - LogFile->FlushInterval=LogFileDefaults->FlushInterval; - LogFile->S=S; - - if (strcmp(FileName,"SYSLOG")==0) LogFile->Flags |= LOGFILE_SYSLOG; - ListAddNamedItem(LogFiles,FileName,LogFile); - STREAMSetItem(S,"TLogFile",LogFile); - STREAMSetFlushType(S, FLUSH_FULL, 0, 0); - - //it might already be too big! - LogFile->S=LogFileInternalDoRotate(LogFile); - } - } - - return(LogFile); -} - - - -void LogFileClose(const char *Path) -{ -ListNode *Node; -TLogFile *LogFile; - -Node=ListFindNamedItem(LogFiles,Path); -if (Node) -{ -LogFile=(TLogFile *) Node->Item; -ListDeleteNode(Node); -DestroyString(LogFile->Path); -STREAMClose(LogFile->S); -free(LogFile); -} -} - - -char *LogFileInternalGetRotateDestinationPath(char *RetStr, TLogFile *LogFile) -{ -char *Tempstr=NULL; - - Tempstr=CopyStr(Tempstr, STREAMGetValue(LogFile->S,"RotatePath")); - if (StrLen(Tempstr) && strchr(Tempstr,'$')) - { - STREAMSetValue(LogFile->S, "Date",GetDateStr("%Y_%m_%d",NULL)); - STREAMSetValue(LogFile->S, "Time",GetDateStr("%H:%M:%S",NULL)); - RetStr=SubstituteVarsInString(RetStr,Tempstr,LogFile->S->Values,0); - } - else RetStr=CopyStr(RetStr,LogFile->Path); - - DestroyString(Tempstr); - -return(RetStr); -} - - -STREAM *LogFileInternalDoRotate(TLogFile *LogFile) -{ - struct stat FStat; - char *Tempstr=NULL, *Path=NULL, *PrevPath=NULL; - int i; - - if (! LogFile) return(NULL); - if (! LogFile->S) return(NULL); - if (strcmp(LogFile->Path,"SYSLOG")==0) return(LogFile->S); - if (strcmp(LogFile->Path,"STDOUT")==0) return(LogFile->S); - if (strcmp(LogFile->Path,"STDERR")==0) return(LogFile->S); - if (getpid() != ParentPID) return(LogFile->S); - - if (LogFile->MaxSize > 0) - { - if (LogFile->S) fstat(LogFile->S->out_fd,&FStat); - else stat(LogFile->Path,&FStat); - if (FStat.st_size > LogFile->MaxSize) - { - Tempstr=LogFileInternalGetRotateDestinationPath(Tempstr, LogFile); - for (i=LogFile->MaxRotate; i > 0; i--) - { - Path=FormatStr(Path,"%s.%d",Tempstr,i); - if (i==LogFile->MaxRotate) unlink(Path); - else rename(Path,PrevPath); - PrevPath=CopyStr(PrevPath,Path); - } - - if (LogFile->S) STREAMClose(LogFile->S); - if (PrevPath) rename(LogFile->Path,PrevPath); - LogFile->S=STREAMOpenFile(LogFile->Path,SF_CREAT | SF_APPEND | SF_WRONLY | SF_NOCACHE); - if (LogFile->S) STREAMSetFlushType(LogFile->S, FLUSH_FULL, 0, 0); - } - } - - DestroyString(PrevPath); - DestroyString(Tempstr); - DestroyString(Path); - return(LogFile->S); -} - - - -void LogFileSetValues(TLogFile *LogFile, int Flags, int MaxSize, int MaxRotate, int FlushInterval) -{ - if (! LogFileDefaults) LogFileSetDefaults(LOGFILE_TIMESTAMP | LOGFILE_FLUSH | LOGFILE_LOGPID | LOGFILE_LOGUSER, 100000000, 0, 1); - if (ParentPID==0) ParentPID=getpid(); - - if (LogFile) - { - LogFile->MaxSize=MaxSize; - LogFile->MaxRotate=MaxRotate; - LogFile->FlushInterval=FlushInterval; - LogFile->Flags=Flags; - } -} - - -int LogFileFindSetValues(const char *FileName, int Flags, int MaxSize, int MaxRotate, int FlushInterval) -{ - TLogFile *LogFile; - - if (StrLen(FileName)==0) LogFile=LogFileDefaults; - else LogFile=LogFileGetEntry(FileName); - - if (LogFile) - { - LogFileSetValues(LogFile, Flags, MaxSize, MaxRotate, FlushInterval); - if (strcmp(FileName,"SYSLOG")==0) LogFile->Flags |= LOGFILE_SYSLOG; - } - else return(FALSE); - - return(TRUE); -} - - -int LogFileInternalWrite(TLogFile *LF, STREAM *S, int Flags, const char *Str) -{ - char *Tempstr=NULL, *LogStr=NULL; - struct timeval Now; - struct tm *TimeStruct; - int result=FALSE; - - - if (ParentPID==0) ParentPID=getpid(); - if (LF) S=LogFileInternalDoRotate(LF); - if (! S) return(FALSE); - - gettimeofday(&Now,NULL); - if (Flags & LOGFILE_TIMESTAMP) - { - TimeStruct=localtime(&Now.tv_sec); - LogStr=SetStrLen(LogStr,40); - strftime(LogStr,20,"%Y/%m/%d %H:%M:%S",TimeStruct); - - if (Flags & LOGFILE_MILLISECS) - { - Tempstr=FormatStr(Tempstr,".%03d ",Now.tv_usec / 1000); - LogStr=CatStr(LogStr,Tempstr); - } - else LogStr=CatStr(LogStr," "); - } - - if (Flags & LOGFILE_LOGPID) - { - Tempstr=FormatStr(Tempstr,"[%d] ",getpid()); - LogStr=CatStr(LogStr,Tempstr); - } - - if (Flags & LOGFILE_LOGUSER) - { - Tempstr=FormatStr(Tempstr,"user=%d ",getuid()); - LogStr=CatStr(LogStr,Tempstr); - } - LogStr=MCatStr(LogStr,Str,"\n",NULL); - - if (S) - { - if (Flags & LOGFILE_LOCK) S->Flags |= SF_WRLOCK; - else S->Flags &= ~SF_WRLOCK; - - if (LF && ((Now.tv_sec-LF->LastFlushTime) > LF->FlushInterval)) Flags |= LOGFILE_FLUSH; - STREAMWriteLine(LogStr,S); - - if (Flags & LOGFILE_FLUSH) - { - STREAMFlush(S); - } - - result=TRUE; - } - - if (Flags & LOGFILE_SYSLOG) - { - syslog(LOG_INFO,"%s",LogStr); - result=TRUE; - } - if (LF) LF->LastFlushTime=Now.tv_sec; - - DestroyString(Tempstr); - DestroyString(LogStr); - - return(result); -} - - - - - - -int LogToSTREAM(STREAM *S, int Flags, const char *Str) -{ -if (! S) return(FALSE); - -return(LogFileInternalWrite(NULL, S, LOGFILE_FLUSH, Str)); -} - - -int LogWrite(TLogFile *Log, const char *Str) -{ -return(LogFileInternalWrite(Log, Log->S, Log->Flags, Str)); -} - - -void LogFileFlushAll(int Force) -{ - time_t Now; - ListNode *Curr; - TLogFile *Log; - - Now=GetTime(FALSE); - Curr=ListGetNext(LogFiles); - while (Curr) - { - Log=(TLogFile *) Curr->Item; - - if (Force && Log->S) - { - STREAMFlush(Log->S); - Log->LastFlushTime=Now; - } - else if (Log->S && ((Now - Log->LastFlushTime) > Log->FlushInterval) ) - { - STREAMFlush(Log->S); - Log->LastFlushTime=Now; - } - Curr=ListGetNext(Curr); - } -} - - - -int LogToFile(const char *FileName, const char *fmt, ...) -{ - char *Tempstr=NULL; - va_list args; - int result=FALSE, val; - TLogFile *LogFile; - - LogFile=LogFileGetEntry(FileName); - if (LogFile) - { - va_start(args,fmt); - Tempstr=VFormatStr(Tempstr,fmt,args); - va_end(args); - StripTrailingWhitespace(Tempstr); - result=LogFileInternalWrite(LogFile,LogFile->S,LogFile->Flags, Tempstr); - } - -DestroyString(Tempstr); -return(result); -} - - - -int LogFileAppendTempLog(const char *LogPath, const char *TmpLogPath) -{ -TLogFile *LogFile; -char *Tempstr=NULL; -STREAM *S; -int result=FALSE; - - LogFile=LogFileGetEntry(LogPath); - LogFileClose(TmpLogPath); - S=STREAMOpenFile(TmpLogPath,SF_RDONLY); - if (LogFile && S) - { - - STREAMLock(LogFile->S,LOCK_EX); - Tempstr=STREAMReadLine(Tempstr,S); - while(Tempstr) - { - STREAMWriteLine(Tempstr,LogFile->S); - Tempstr=STREAMReadLine(Tempstr,S); - } - if (LogFile->Flags & LOGFILE_FLUSH) STREAMFlush(LogFile->S); - STREAMLock(LogFile->S,LOCK_UN); - unlink(TmpLogPath); - result=TRUE; - } - if (S) STREAMClose(S); - -DestroyString(Tempstr); - -return(result); -} - - -void LogFileCheckRotate(const char *FileName) -{ -TLogFile *LogFile; - - LogFile=LogFileGetEntry(FileName); - if (LogFile) - { - LogFileInternalDoRotate(LogFile); - } -} diff --git a/libUseful-2.6/Log.h b/libUseful-2.6/Log.h deleted file mode 100755 index 83a8a1c..0000000 --- a/libUseful-2.6/Log.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef LIBUSEFUL_LOG_H -#define LIBUSEFUL_LOG_H - -#include "includes.h" -#include "defines.h" -#include "file.h" - -#define LOGFILE_FLUSH 1 -#define LOGFILE_SYSLOG 2 -#define LOGFILE_LOGPID 4 -#define LOGFILE_LOGUSER 8 -#define LOGFILE_LOCK 16 -#define LOGFILE_TIMESTAMP 32 -#define LOGFILE_MILLISECS 64 -#define LOGFILE_ROTATE_NUMBERS 128 -#define LOGFILE_ROTATE_MINUS 256 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct -{ - char *Path; - int Flags; - int MaxSize; - int MaxRotate; - int LogFacility; - int LastFlushTime; - int FlushInterval; - char *LastMessage; - int RepeatMessage; - STREAM *S; -} TLogFile; - -TLogFile *LogFileGetEntry(const char *FileName); -int LogFileSetDefaults(int Flags, int MaxSize, int MaxRotate, int FlushInterval); -void LogFileSetValues(TLogFile *LogFile, int Flags, int MaxSize, int MaxRotate, int FlushInterval); -int LogFileFindSetValues(const char *FileName, int Flags, int MaxSize, int MaxRotate, int FlushInterval); -void LogFileFlushAll(int Force); -void LogFileClose(const char *Path); -int LogFileAppendTempLog(const char *LogPath, const char *TmpLogPath); -void LogFileCheckRotate(const char *FileName); - - -int LogToSTREAM(STREAM *S, int Flags, const char *Str); -int LogWrite(TLogFile *Log, const char *Str); -int LogToFile(const char *FileName, const char *fmt, ...); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/Makefile b/libUseful-2.6/Makefile deleted file mode 100644 index 0854d6c..0000000 --- a/libUseful-2.6/Makefile +++ /dev/null @@ -1,151 +0,0 @@ -CC = gcc -VERSION = 0.0.1 -CFLAGS = -g -O2 -LIBS = -lcrypto -lssl -lc -FLAGS=$(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -fPIC -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBC=1 -DHAVE_PTSNAME_R=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 -DUSE_SENDFILE=1 -DHAVE_LIBSSL=1 -DHAVE_LIBCRYPTO=1 -DHAVE_EVP_BF_CBC=1 -DHAVE_EVP_RC2_CBC=1 -DHAVE_EVP_RC4=1 -DHAVE_EVP_DES_CBC=1 -DHAVE_EVP_DESX_CBC=1 -DHAVE_EVP_CAST5_CBC=1 -DHAVE_EVP_IDEA_CBC=1 -DHAVE_EVP_AES_128_CBC=1 -DHAVE_EVP_AES_256_CBC=1 -DUSE_OPENSSL_ADD_ALL_ALGORITHMS=1 -DHAVE_OSS=1 -DHAVE_MADVISE -DHAVE_MADVISE_NOFORK -DHAVE_MADVISE_DONTDUMP -DHAVE_MLOCK -prefix=/usr/local -OBJ=string.o list.o socket.o unix_socket.o file.o tar.o ansi.o FileSystem.o GeneralFunctions.o DataProcessing.o EncryptedFiles.o ConnectManager.o sound.o pty.o Log.o http.o inet.o expect.o base64.o crc32.o md5c.o sha1.o sha2.o whirlpool.o jh_ref.o Hash.o ssh.o Compression.o oauth.o libsettings.o Vars.o MathExpr.o Time.o Markup.o SpawnPrograms.o Tokenizer.o PatternMatch.o ParseURL.o ConnectionChain.o openssl.o proctitle.o securemem.o - - -all: $(OBJ) - $(CC) $(FLAGS) -shared -o libUseful-2.6.so $(OBJ) $(LIBS) - #ld -i -o libUseful-2.6.a $(OBJ) - ar rcs libUseful-2.6.a $(OBJ) - - -string.o: string.h string.c - $(CC) $(FLAGS) -c string.c - -list.o: list.h list.c - $(CC) $(FLAGS) -c list.c - -socket.o: socket.h socket.c - $(CC) $(FLAGS) -c socket.c - -sound.o: sound.h sound.c - $(CC) $(FLAGS) -c sound.c - -pty.o: pty.h pty.c - $(CC) $(FLAGS) -c pty.c - -http.o: http.h http.c - $(CC) $(FLAGS) -c http.c - -file.o: file.h file.c - $(CC) $(FLAGS) -c file.c - -tar.o: tar.h tar.c - $(CC) $(FLAGS) -c tar.c - -ansi.o: ansi.h ansi.c - $(CC) $(FLAGS) -c ansi.c - -Log.o: Log.h Log.c - $(CC) $(FLAGS) -c Log.c - -unix_socket.o: unix_socket.h unix_socket.c - $(CC) $(FLAGS) -c unix_socket.c - -PatternMatch.o: PatternMatch.h PatternMatch.c - $(CC) $(FLAGS) -c PatternMatch.c - -FileSystem.o: FileSystem.h FileSystem.c - $(CC) $(FLAGS) -c FileSystem.c - -MathExpr.o: MathExpr.h MathExpr.c - $(CC) $(FLAGS) -c MathExpr.c - -Time.o: Time.h Time.c - $(CC) $(FLAGS) -c Time.c - -Tokenizer.o: Tokenizer.h Tokenizer.c - $(CC) $(FLAGS) -c Tokenizer.c - -Markup.o: Markup.h Markup.c - $(CC) $(FLAGS) -c Markup.c - -ParseURL.o: ParseURL.h ParseURL.c - $(CC) $(FLAGS) -c ParseURL.c - -inet.o: inet.h inet.c - $(CC) $(FLAGS) -c inet.c - -expect.o: expect.h expect.c - $(CC) $(FLAGS) -c expect.c - -securemem.o: securemem.h securemem.c - $(CC) $(FLAGS) -c securemem.c - -GeneralFunctions.o: GeneralFunctions.h GeneralFunctions.c - $(CC) $(FLAGS) -c GeneralFunctions.c - -DataProcessing.o: DataProcessing.h DataProcessing.c - $(CC) $(FLAGS) -c DataProcessing.c - -EncryptedFiles.o: EncryptedFiles.h EncryptedFiles.c - $(CC) $(FLAGS) -c EncryptedFiles.c - -Hash.o: Hash.h Hash.c - $(CC) $(FLAGS) -c Hash.c - -ssh.o: ssh.h ssh.c - $(CC) $(FLAGS) -c ssh.c - -Compression.o: Compression.h Compression.c - $(CC) $(FLAGS) -c Compression.c - -ConnectionChain.o: ConnectionChain.h ConnectionChain.c - $(CC) $(FLAGS) -c ConnectionChain.c - -ConnectManager.o: ConnectManager.h ConnectManager.c - $(CC) $(FLAGS) -c ConnectManager.c - -base64.o: base64.c base64.h - $(CC) $(FLAGS) -c base64.c - -crc32.o: crc32.c crc32.h - $(CC) $(FLAGS) -c crc32.c - -md5c.o: md5c.c md5-global.h md5.h - $(CC) $(FLAGS) -c md5c.c - -sha1.o: sha1.c sha1.h - $(CC) $(FLAGS) -c sha1.c - -sha2.o: sha2.c sha2.h - $(CC) $(FLAGS) -c sha2.c - -whirlpool.o: whirlpool.c whirlpool.h - $(CC) $(FLAGS) -c whirlpool.c - -jh_ref.o: jh_ref.c jh_ref.h - $(CC) $(FLAGS) -c jh_ref.c - -oauth.o: oauth.c oauth.h - $(CC) $(FLAGS) -c oauth.c - -openssl.o: openssl.c openssl.h - $(CC) $(FLAGS) -c openssl.c - -proctitle.o: proctitle.c proctitle.h - $(CC) $(FLAGS) -c proctitle.c - -Vars.o: Vars.c Vars.h - $(CC) $(FLAGS) -c Vars.c - -SpawnPrograms.o: SpawnPrograms.c SpawnPrograms.h - $(CC) $(FLAGS) -c SpawnPrograms.c - -#No dependancies, must always be compiled -libsettings.o: libsettings.h libsettings.c - $(CC) $(FLAGS) -c libsettings.c - -clean: - -rm -f *.o *.so *.a - -rm config.log config.status - -rm -r autom4te.cache config.cache - -install: - @ln -s libUseful-2.6.so libUseful.so - @ln -s libUseful-2.6.a libUseful.a - @cp *.so *.a $(prefix)/lib ; mkdir $(prefix)/include/libUseful-$(VERSION) ; cp *.h $(prefix)/include/libUseful-$(VERSION) diff --git a/libUseful-2.6/Makefile.in b/libUseful-2.6/Makefile.in deleted file mode 100755 index f3b2ffa..0000000 --- a/libUseful-2.6/Makefile.in +++ /dev/null @@ -1,151 +0,0 @@ -CC = @CC@ -VERSION = @VERSION@ -CFLAGS = @CFLAGS@ -LIBS = @LIBS@ -FLAGS=$(LDFLAGS) $(CPPFLAGS) $(CFLAGS) -fPIC @DEFS@ -DHAVE_MADVISE -DHAVE_MADVISE_NOFORK -DHAVE_MADVISE_DONTDUMP -DHAVE_MLOCK -prefix=@prefix@ -OBJ=string.o list.o socket.o unix_socket.o file.o tar.o ansi.o FileSystem.o GeneralFunctions.o DataProcessing.o EncryptedFiles.o ConnectManager.o sound.o pty.o Log.o http.o inet.o expect.o base64.o crc32.o md5c.o sha1.o sha2.o whirlpool.o jh_ref.o Hash.o ssh.o Compression.o oauth.o libsettings.o Vars.o MathExpr.o Time.o Markup.o SpawnPrograms.o Tokenizer.o PatternMatch.o ParseURL.o ConnectionChain.o openssl.o proctitle.o securemem.o - - -all: $(OBJ) - $(CC) $(FLAGS) -shared -o libUseful-2.6.so $(OBJ) $(LIBS) - #ld -i -o libUseful-2.6.a $(OBJ) - ar rcs libUseful-2.6.a $(OBJ) - - -string.o: string.h string.c - $(CC) $(FLAGS) -c string.c - -list.o: list.h list.c - $(CC) $(FLAGS) -c list.c - -socket.o: socket.h socket.c - $(CC) $(FLAGS) -c socket.c - -sound.o: sound.h sound.c - $(CC) $(FLAGS) -c sound.c - -pty.o: pty.h pty.c - $(CC) $(FLAGS) -c pty.c - -http.o: http.h http.c - $(CC) $(FLAGS) -c http.c - -file.o: file.h file.c - $(CC) $(FLAGS) -c file.c - -tar.o: tar.h tar.c - $(CC) $(FLAGS) -c tar.c - -ansi.o: ansi.h ansi.c - $(CC) $(FLAGS) -c ansi.c - -Log.o: Log.h Log.c - $(CC) $(FLAGS) -c Log.c - -unix_socket.o: unix_socket.h unix_socket.c - $(CC) $(FLAGS) -c unix_socket.c - -PatternMatch.o: PatternMatch.h PatternMatch.c - $(CC) $(FLAGS) -c PatternMatch.c - -FileSystem.o: FileSystem.h FileSystem.c - $(CC) $(FLAGS) -c FileSystem.c - -MathExpr.o: MathExpr.h MathExpr.c - $(CC) $(FLAGS) -c MathExpr.c - -Time.o: Time.h Time.c - $(CC) $(FLAGS) -c Time.c - -Tokenizer.o: Tokenizer.h Tokenizer.c - $(CC) $(FLAGS) -c Tokenizer.c - -Markup.o: Markup.h Markup.c - $(CC) $(FLAGS) -c Markup.c - -ParseURL.o: ParseURL.h ParseURL.c - $(CC) $(FLAGS) -c ParseURL.c - -inet.o: inet.h inet.c - $(CC) $(FLAGS) -c inet.c - -expect.o: expect.h expect.c - $(CC) $(FLAGS) -c expect.c - -securemem.o: securemem.h securemem.c - $(CC) $(FLAGS) -c securemem.c - -GeneralFunctions.o: GeneralFunctions.h GeneralFunctions.c - $(CC) $(FLAGS) -c GeneralFunctions.c - -DataProcessing.o: DataProcessing.h DataProcessing.c - $(CC) $(FLAGS) -c DataProcessing.c - -EncryptedFiles.o: EncryptedFiles.h EncryptedFiles.c - $(CC) $(FLAGS) -c EncryptedFiles.c - -Hash.o: Hash.h Hash.c - $(CC) $(FLAGS) -c Hash.c - -ssh.o: ssh.h ssh.c - $(CC) $(FLAGS) -c ssh.c - -Compression.o: Compression.h Compression.c - $(CC) $(FLAGS) -c Compression.c - -ConnectionChain.o: ConnectionChain.h ConnectionChain.c - $(CC) $(FLAGS) -c ConnectionChain.c - -ConnectManager.o: ConnectManager.h ConnectManager.c - $(CC) $(FLAGS) -c ConnectManager.c - -base64.o: base64.c base64.h - $(CC) $(FLAGS) -c base64.c - -crc32.o: crc32.c crc32.h - $(CC) $(FLAGS) -c crc32.c - -md5c.o: md5c.c md5-global.h md5.h - $(CC) $(FLAGS) -c md5c.c - -sha1.o: sha1.c sha1.h - $(CC) $(FLAGS) -c sha1.c - -sha2.o: sha2.c sha2.h - $(CC) $(FLAGS) -c sha2.c - -whirlpool.o: whirlpool.c whirlpool.h - $(CC) $(FLAGS) -c whirlpool.c - -jh_ref.o: jh_ref.c jh_ref.h - $(CC) $(FLAGS) -c jh_ref.c - -oauth.o: oauth.c oauth.h - $(CC) $(FLAGS) -c oauth.c - -openssl.o: openssl.c openssl.h - $(CC) $(FLAGS) -c openssl.c - -proctitle.o: proctitle.c proctitle.h - $(CC) $(FLAGS) -c proctitle.c - -Vars.o: Vars.c Vars.h - $(CC) $(FLAGS) -c Vars.c - -SpawnPrograms.o: SpawnPrograms.c SpawnPrograms.h - $(CC) $(FLAGS) -c SpawnPrograms.c - -#No dependancies, must always be compiled -libsettings.o: libsettings.h libsettings.c - $(CC) $(FLAGS) -c libsettings.c - -clean: - -rm -f *.o *.so *.a - -rm config.log config.status - -rm -r autom4te.cache config.cache - -install: - @ln -s libUseful-2.6.so libUseful.so - @ln -s libUseful-2.6.a libUseful.a - @cp *.so *.a $(prefix)/lib ; mkdir $(prefix)/include/libUseful-$(VERSION) ; cp *.h $(prefix)/include/libUseful-$(VERSION) diff --git a/libUseful-2.6/Markup.c b/libUseful-2.6/Markup.c deleted file mode 100755 index b02d112..0000000 --- a/libUseful-2.6/Markup.c +++ /dev/null @@ -1,270 +0,0 @@ -#include "Markup.h" - -char *XMLGetTag(char *Input, char **Namespace, char **TagType, char **TagData) -{ -char *ptr, *tptr; -int len=0, InTag=FALSE, TagHasName=FALSE; - -if (! Input) return(NULL); -if (*Input=='\0') return(NULL); -ptr=Input; - -//This ensures we are never dealing with nulls -if (! *TagType) *TagType=CopyStr(*TagType,""); -if (! *TagData) *TagData=CopyStr(*TagData,""); - -if (*ptr=='<') -{ - ptr++; - while (isspace(*ptr)) ptr++; - - len=0; - InTag=TRUE; - TagHasName=TRUE; - - //if we start with a slash tag, then add that to the tag name - if (*ptr=='/') - { - *TagType=AddCharToBuffer(*TagType,len,*ptr); - len++; - ptr++; - } - - while (InTag) - { - switch (*ptr) - { - //These all cause us to end. NONE OF THEM REQUIRE ptr++ - //ptr++ will happen when we read tag data - case '>': - case '\0': - case ' ': - case ' ': - case '\n': - InTag=FALSE; - break; - - //If a namespace return value is supplied, break the name up into namespace and - //tag. Otherwise don't - case ':': - if (Namespace) - { - tptr=*TagType; - if (*tptr=='/') - { - tptr++; - len=1; - } - else len=0; - *Namespace=CopyStr(*Namespace,tptr); - } - else - { - *TagType=AddCharToBuffer(*TagType,len,*ptr); - len++; - } - ptr++; - - break; - - - - case '\r': - ptr++; - break; - - default: - *TagType=AddCharToBuffer(*TagType,len,*ptr); - len++; - ptr++; - break; - } - - } -} - -//End of Parse TagName. Strip any '/' -tptr=*TagType; -if ((len > 0) && (tptr[len-1]=='/')) tptr[len-1]='\0'; -tptr[len]='\0'; - -while (isspace(*ptr)) ptr++; - - -len=0; -InTag=TRUE; -while (InTag) -{ - switch (*ptr) - { - //End of tag, skip '>' and fall through - case '>': - ptr++; - - //Start of next tag or end of text - case '<': - case '\0': - InTag=FALSE; - break; - - //Quotes! - case '\'': - case '\"': - - //Somewhat ugly code. If we're dealing with an actual tag, then TagHasName - //will be set. This means we're dealing with data within a tag and quotes mean something. - //Otherwise we are dealing with text outside of tags and we just add the char to - //TagData and continue - if (TagHasName) - { - tptr=ptr; - while (*tptr != *ptr) - { - *TagData=AddCharToBuffer(*TagData,len,*ptr); - len++; - ptr++; - } - } - *TagData=AddCharToBuffer(*TagData,len,*ptr); - len++; - ptr++; - break; - - default: - *TagData=AddCharToBuffer(*TagData,len,*ptr); - len++; - ptr++; - break; - } - -} - -//End of Parse TagData. Strip any '/' -tptr=*TagData; -if ((len > 0) && (tptr[len-1]=='/')) tptr[len-1]='\0'; -tptr[len]='\0'; - -strlwr(*TagType); -while (isspace(*ptr)) ptr++; - -return(ptr); -} - - - - -char *HtmlGetTag(char *Input, char **TagType, char **TagData) -{ -if (! Input) return(NULL); -if (*Input=='\0') return(NULL); - -return(XMLGetTag(Input, NULL, TagType, TagData)); -} - - - -char *HTMLQuote(char *RetBuff, char *Str) -{ -char *RetStr=NULL, *Token=NULL, *ptr; -int len; - -RetStr=CopyStr(RetStr,""); -len=StrLen(Str); - -for (ptr=Str; ptr < (Str+len); ptr++) -{ - -switch (*ptr) -{ -case '&': RetStr=CatStr(RetStr,"&"); break; -case '<': RetStr=CatStr(RetStr,"<"); break; -case '>': RetStr=CatStr(RetStr,">"); break; - -default: - RetStr=AddCharToStr(RetStr,*ptr); -break; -} - -} - -DestroyString(Token); -return(RetStr); -} - - - - -char *HtmlUnQuote(char *RetStr, char *Data) -{ -char *Output=NULL, *Token=NULL, *ptr; -int len=0; - -Output=CopyStr(RetStr,Output); -ptr=Data; - -while (ptr && (*ptr != '\0')) -{ - if (*ptr=='&') - { - ptr++; - ptr=GetToken(ptr,";",&Token,0); - - if (*Token=='#') - { - Output=AddCharToBuffer(Output,len,strtol(Token+1,NULL,16)); - len++; - } - else if (strcmp(Token,"amp")==0) - { - Output=AddCharToBuffer(Output,len,'&'); - len++; - } - else if (strcmp(Token,"lt")==0) - { - Output=AddCharToBuffer(Output,len,'<'); - len++; - } - else if (strcmp(Token,"gt")==0) - { - Output=AddCharToBuffer(Output,len,'>'); - len++; - } - else if (strcmp(Token,"quot")==0) - { - Output=AddCharToBuffer(Output,len,'"'); - len++; - } - else if (strcmp(Token,"apos")==0) - { - Output=AddCharToBuffer(Output,len,'\''); - len++; - } - else if (strcmp(Token,"tilde")==0) - { - Output=AddCharToBuffer(Output,len,'~'); - len++; - } - else if (strcmp(Token,"circ")==0) - { - Output=AddCharToBuffer(Output,len,'^'); - len++; - } - - - - - } - else - { - Output=AddCharToBuffer(Output,len,*ptr); - len++; - ptr++; - } -} - -DestroyString(Token); - -return(Output); -} - - diff --git a/libUseful-2.6/Markup.h b/libUseful-2.6/Markup.h deleted file mode 100755 index 33c502b..0000000 --- a/libUseful-2.6/Markup.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LIBUSEFUL_MARKUP_H -#define LIBUSEFUL_MARKUP_H - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -char *XMLGetTag(char *Input, char **Namespace, char **TagType, char **TagData); -char *HtmlGetTag(char *Input, char **TagType, char **TagData); -char *HTMLQuote(char *RetBuff, char *Str); -char *HtmlUnQuote(char *RetStr, char *Data); - - - - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/MathExpr.c b/libUseful-2.6/MathExpr.c deleted file mode 100755 index 045b47b..0000000 --- a/libUseful-2.6/MathExpr.c +++ /dev/null @@ -1,256 +0,0 @@ -#include "MathExpr.h" - -typedef struct -{ -int operator; -double value; -} ExprToken; - -const char *OpStrings[]={"0","+","-","*","/","(",")","%","^",NULL}; -typedef enum Ops {OP_VAL,OP_PLUS,OP_MINUS,OP_TIMES,OP_DIVIDE,OP_OPEN,OP_CLOSE,OP_MOD,OP_POW} LIBUSEFUL_TMATHOPS; - -char *GetMathExprToken(char *String, char **Token) -{ -char *ptr, *start; -int count, found=FALSE; - -ptr=String; -if (! ptr) return(NULL); -if (*ptr=='\0') return(NULL); - -while (isspace(*ptr)) ptr++; -start=ptr; - -while (ptr) -{ - if (*ptr=='\0') - { - - *Token=CopyStr(*Token,start); - break; - } - - for (count=1; OpStrings[count] !=NULL; count++) - { - if (strncmp(ptr,OpStrings[count],StrLen(OpStrings[count]))==0) - { - // we have come to an Operator at the start, so - // that is our token - if (start==ptr) - { - *Token=CopyStr(*Token,OpStrings[count]); ptr+=StrLen(OpStrings[count]); - } - else - { - *Token=CopyStrLen(*Token,start,ptr-start); - } - found=TRUE; - break; - } - } - if (found) break; - ptr++; -} - -return(ptr); -} - - -double ProcessMathExpression(ListNode *Tokens); - -double ProcessSumExpression(ListNode *Tokens) -{ -ListNode *Curr; -ExprToken *Tok, *NextTok; -double val=0; - -Curr=ListGetNext(Tokens); -Tok=(ExprToken *) Curr->Item; -val=Tok->value; -Curr=ListGetNext(Curr); -while (Curr) -{ - Tok=(ExprToken *) Curr->Item; - Curr=ListGetNext(Curr); - NextTok=(ExprToken *) Curr->Item; - - - if (Tok->operator==OP_PLUS) val+=NextTok->value; - else if (Tok->operator==OP_MINUS) val-=NextTok->value; - else if (Tok->operator==OP_VAL) val=Tok->value; - Curr=ListGetNext(Curr); -} -ListClear(Tokens,free); -Tokens->Next=NULL; -Tokens->Head=NULL; -Tok=(ExprToken *) calloc(1,sizeof(ExprToken)); -Tok->operator=OP_VAL; -Tok->value=val; -ListAddItem(Tokens,Tok); -return(val); -} - - -double ProcessMultDiv(ListNode *Tokens) -{ -ListNode *Curr; -ExprToken *Tok, *PrevTok, *NextTok; -double val=0; - -Curr=ListGetNext(Tokens); -while (Curr) -{ - Tok=Curr->Item; - if ( - (Tok->operator==OP_TIMES) || - (Tok->operator==OP_DIVIDE) - ) - { - PrevTok=(ExprToken *) Curr->Prev->Item; - NextTok=(ExprToken *) Curr->Next->Item; - if (Tok->operator==OP_TIMES) val=PrevTok->value * NextTok->value; - if (Tok->operator==OP_DIVIDE) val=PrevTok->value / NextTok->value; - ListDeleteNode(Curr->Prev); - ListDeleteNode(Curr->Next); - free(PrevTok); - free(NextTok); - Tok->operator=OP_VAL; - Tok->value=val; - } - - Curr=ListGetNext(Curr); -} - -return(val); -} - -double ProcessExpn(ListNode *Tokens) -{ -ListNode *Curr; -ExprToken *Tok, *PrevTok, *NextTok; -double val=0; -int count; - -Curr=ListGetNext(Tokens); -while (Curr) -{ - Tok=Curr->Item; - if ( - (Tok->operator==OP_MOD) || - (Tok->operator==OP_POW) - ) - { - PrevTok=(ExprToken *) Curr->Prev->Item; - NextTok=(ExprToken *) Curr->Next->Item; - if (Tok->operator==OP_MOD) val=(int) PrevTok->value % (int) NextTok->value; - if (Tok->operator==OP_POW) - { - val=1.0; - for (count=0; count < NextTok->value; count++) - { - val=val * PrevTok->value; - } - } - ListDeleteNode(Curr->Prev); - ListDeleteNode(Curr->Next); - free(PrevTok); - free(NextTok); - Tok->operator=OP_VAL; - Tok->value=val; - } - - Curr=ListGetNext(Curr); -} - -return(val); -} - - -void ProcessBrackets(ListNode *Tokens) -{ -ListNode *Start=NULL, *Curr, *SubExpr=NULL, *SubCurr=NULL; -ExprToken *Tok; - -Curr=ListGetNext(Tokens); -while (Curr) -{ - Tok=(ExprToken *) Curr->Item; - if (Start) - { - if (Tok->operator==OP_CLOSE) - { - SubCurr->Next=NULL; - //replace end brace with val - Tok->operator=OP_VAL; - Tok->value=ProcessMathExpression(SubExpr); - Start->Next=Curr; - Curr->Prev=Start; - Start=NULL; - } - else - { - SubCurr->Next=Curr; - Curr->Prev=SubCurr; - SubCurr=SubCurr->Next; - } - } - else if (Tok->operator==OP_OPEN) - { - Start=Curr->Prev; - //get rid of pesky leading brace - ListDeleteNode(Curr); - free(Tok); - Curr=Start; - SubExpr=ListCreate(); - SubCurr=SubExpr; - } - Curr=ListGetNext(Curr); -} - -if (SubExpr) ListDestroy(SubExpr,free); -} - -double ProcessMathExpression(ListNode *Tokens) -{ -double val; - -ProcessBrackets(Tokens); -ProcessExpn(Tokens); -ProcessMultDiv(Tokens); -val=ProcessSumExpression(Tokens); -return(val); -} - - -double EvaluateMathStr(char *String) -{ -double val; -char *ptr, *Token=NULL; -int operator; -ListNode *Tokens; -ExprToken *Tok; - -Tokens=ListCreate(); -ptr=GetMathExprToken(String,&Token); -while (ptr) -{ - operator=MatchTokenFromList(Token,OpStrings,0); - if (operator==-1) operator=OP_VAL; - Tok=(ExprToken *) calloc(1,sizeof(ExprToken)); - Tok->operator=operator; - if (operator==OP_VAL) - { - Tok->value=atof(Token); - } - ListAddItem(Tokens,Tok); - ptr=GetMathExprToken(ptr,&Token); -} - -val=ProcessMathExpression(Tokens); - -ListDestroy(Tokens,free); -DestroyString(Token); - -return(val); -} - diff --git a/libUseful-2.6/MathExpr.h b/libUseful-2.6/MathExpr.h deleted file mode 100755 index 5614937..0000000 --- a/libUseful-2.6/MathExpr.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LIBUSEFUL_MATHEXPR_H -#define LIBUSEFUL_MATHEXPR_H - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -double EvaluateMathStr(char *String); - - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/MessageBus.c b/libUseful-2.6/MessageBus.c deleted file mode 100755 index 1f8640e..0000000 --- a/libUseful-2.6/MessageBus.c +++ /dev/null @@ -1,364 +0,0 @@ -#include "MessageBus.h" -#include "defines.h" -#include "SpawnPrograms.h" -#include "http.h" - -#define MESSAGEAGENT_BUSY 1 - -typedef struct -{ -char *URL; -int MaxConnections; -int Timeout; -ListNode *Connections; -MSG_FUNC AgentFunction; -} TMessageBus; - -ListNode *MessageBusConnections=NULL; -STREAM *MessageS=NULL; - -// typedef void (*MSG_FUNC)(const char *PeerName, ListNode *Variables); - -void MessageBusRegister(const char *URL, int MaxConnections, int Timeout, MSG_FUNC AgentFunction) -{ -TMessageBus *MA; - -if (! MessageBusConnections) MessageBusConnections=ListCreate(); - -MA=(TMessageBus *) calloc(1,sizeof(TMessageBus)); -MA->URL=CopyStr(MA->URL, URL); -MA->Connections=ListCreate(); -MA->AgentFunction=AgentFunction; -ListAddItem(MessageBusConnections, MA); -} - - - -int MessageBusNativeRecv(STREAM *S, char **Source, ListNode *Vars) -{ -char *Tempstr=NULL, *EncName=NULL, *EncValue=NULL; -const char *ptr; -ListNode *Node; - -Tempstr=STREAMReadLine(Tempstr, S); -if (StrEnd(Tempstr)) -{ - //could be blank (timeout) or null. DestroyString will figure it out - DestroyString(Tempstr); - return(FALSE); -} - -StripTrailingWhitespace(Tempstr); -ptr=GetToken(Tempstr, "?", Source, 0); -while (ptr) -{ - ptr=GetNameValuePair(ptr, "&","=", &EncName, &EncValue); - Node=ListAddItem(Vars, NULL); - Node->Tag=HTTPUnQuote(Node->Tag, EncName); - Node->Item=HTTPUnQuote(Node->Item, EncValue); -} - -DestroyString(Tempstr); -DestroyString(EncValue); -DestroyString(EncName); - -return(TRUE); -} - - -void JSONParse(const char *Doc, ListNode *Vars) -{ -char *Prefix=NULL, *Name=NULL, *Value=NULL, *Tempstr=NULL, *tptr; -const char *ptr; - -ptr=Doc; -while (isspace(*ptr) || (*ptr=='{')) ptr++; -while (ptr) -{ - ptr=GetToken(ptr,",|:", &Name, GETTOKEN_MULTI_SEPARATORS); - if (strcmp(Name,"}")==0) - { - //we've come out of one level of nesting. remove last item from prefix - if (StrValid(Prefix)) - { - tptr=strrchr(Prefix, ':'); - if (tptr) - { - *tptr='\0'; - tptr=strrchr(tptr, ':'); - if (tptr) *tptr='\0'; - } - } - } - else - { - ptr=GetToken(ptr,",|:",&Value, GETTOKEN_MULTI_SEPARATORS); - if (strcmp(Value,"{")==0) Prefix=MCatStr(Prefix,Name,":",NULL); - else - { - Tempstr=MCopyStr(Tempstr, Prefix, Name, NULL); - SetVar(Vars, Tempstr, Value); - } - } -} - -DestroyString(Tempstr); -DestroyString(Prefix); -DestroyString(Name); -DestroyString(Value); -} - - -void XMLParse(const char *Doc, ListNode *Vars) -{ -char *Name=NULL, *Value=NULL, *Data=NULL, *Extra=NULL; -const char *ptr; - -ptr=XMLGetTag(Doc, NULL, &Name, &Data); -while (ptr) -{ - if (StrValid(Name)) - { - ptr=XMLGetTag(ptr, NULL, &Extra, &Value); - if (StrValid(Extra)) - { - if (*Name != '/') SetVar(Vars, Name, ""); - Name=CopyStr(Name, Extra); - } - else - { - if (*Name != '/')SetVar(Vars, Name, Value); - ptr=XMLGetTag(ptr, NULL, &Name, &Data); - } - } - else ptr=XMLGetTag(ptr, NULL, &Name, &Data); -} - -DestroyString(Name); -DestroyString(Data); -DestroyString(Value); -DestroyString(Extra); -} - - - -int MessageBusRecv(STREAM *S, char **Source, ListNode *Vars) -{ -char *Doc=NULL, *ptr; -HTTPInfoStruct *Info; -ListNode *Curr; -TMessageBus *MA; -int result=FALSE; - -if (! Vars) return(FALSE); -if (! S) return(FALSE); -ListClear(Vars, DestroyString); - -if (S->Type==STREAM_TYPE_HTTP) -{ - Info=(HTTPInfoStruct *) STREAMGetItem(S, "HTTPInfo"); - if (Info) - { - HTTPTransact(Info); - Doc=HTTPReadDocument(Doc, S); - ptr=STREAMGetValue(S, "HTTP:Content-Type"); - if (strcmp(ptr, "application/json")==0) JSONParse(Doc, Vars); - if (strcmp(ptr, "application/xml")==0) XMLParse(Doc, Vars); - - HTTPInfoDestroy(Info); - DestroyString(Doc); - result=TRUE; - } -} -else result=MessageBusNativeRecv(S, Source, Vars); - -MA=(TMessageBus *) STREAMGetItem(S, "MessageBus:Agent"); -Curr=ListFindItem(MA->Connections, S); -if (Curr) Curr->ItemType=0; -if (! result) -{ - if (Curr) ListDeleteNode(Curr); - STREAMClose(S); -} - -return(result); -} - - -int MessageBusHandler(void *p_MA) -{ -char *URL=NULL; -ListNode *Vars; -TMessageBus *MA; - -MA=(TMessageBus *) p_MA; -Vars=ListCreate(); -MessageS=STREAMFromDualFD(0,1); -MessageS->Type=STREAM_TYPE_MESSAGEBUS; -STREAMSetTimeout(MessageS, MA->Timeout * 100); -STREAMSetItem(MessageS, "MessageBus:Agent", MA); -while (MessageBusRecv(MessageS, &URL, Vars)) -{ - if (MA->AgentFunction) MA->AgentFunction(URL, Vars); -} - -ListDestroy(Vars,DestroyString); -DestroyString(URL); -} - - - -STREAM *MessageBusConnect(TMessageBus *MA, const char *Args) -{ -STREAM *S; -char *Tempstr=NULL; -HTTPInfoStruct *HTTPInfo; - -Tempstr=MCopyStr(Tempstr, MA->URL, Args, NULL); -if (strncmp(MA->URL,"http:",5)==0) -{ - HTTPInfo=HTTPInfoFromURL("GET", MA->URL); - S=HTTPConnect(HTTPInfo); - STREAMSetItem(S, "HTTPInfo", HTTPInfo); -} -else -{ - S=STREAMSpawnFunction(MessageBusHandler, MA); - S->Type=STREAM_TYPE_MESSAGEBUS; -} - -if (S) STREAMSetItem(S, "MessageBus:Agent", MA); -DestroyString(Tempstr); -return(S); -} - - - -STREAM *MessageBusAgentFindConnect(TMessageBus *MA, const char *Args) -{ -STREAM *S=NULL; -ListNode *Curr; - - Curr=ListGetNext(MA->Connections); - while (Curr) - { - if (! Curr->ItemType) S=(STREAM *) Curr->Item; - Curr=ListGetNext(Curr); - } - - if (! S) - { - S=MessageBusConnect(MA, Args); - Curr=ListAddItem(MA->Connections, S); - Curr->ItemType=MESSAGEAGENT_BUSY; - } - -return(S); -} - - - - -STREAM *MessageBusFindConnect(const char *URL, const char *Args) -{ -ListNode *Curr; -TMessageBus *MA, *Found=NULL; -STREAM *S=NULL; - -Curr=ListGetNext(MessageBusConnections); -while (Curr) -{ - MA=(TMessageBus *) Curr->Item; - if (strcmp(MA->URL, URL)==0) - { - Found=MA; - break; - } - Curr=ListGetNext(Curr); -} - -if (Found) -{ - S=MessageBusAgentFindConnect(MA, Args); -} - -return(S); -} - - -STREAM *MessageBusWrite(const char *URL, const char *Args) -{ -char *Message=NULL; -STREAM *S=NULL; - -//we are a messagebus 'client' with a connection to a parent process -//so just write out of that -if (MessageS) S=MessageS; -else -{ - //we are a messagebus 'server' in the parent process, and must find the - //right connection to write to - S=MessageBusFindConnect(URL, Args); - if (! S) return(NULL); -} - - -if (S->Type == STREAM_TYPE_MESSAGEBUS) -{ - Message=MCopyStr(Message, URL, "?", Args, "\r\n", NULL); - STREAMWriteLine(Message, S); - STREAMFlush(S); -} - - -DestroyString(Message); -return(S); -} - - -STREAM *MessageBusSend(const char *URL, ListNode *Args) -{ -char *Tempstr=NULL, *EncodedName=NULL, *EncodedValue=NULL; -ListNode *Curr; -STREAM *S; -int result; - -Tempstr=MCopyStr(Tempstr, URL, "?", NULL); -Curr=ListGetNext(Args); -while (Curr) -{ - EncodedName=HTTPQuote(EncodedName, Curr->Tag); - EncodedValue=HTTPQuote(EncodedValue, (char *) Curr->Item); - Tempstr=MCatStr(Tempstr, EncodedName, "=", EncodedValue, "&", NULL); - Curr=ListGetNext(Curr); -} - -S=MessageBusWrite(URL, Tempstr); - -DestroyString(Tempstr); -DestroyString(EncodedName); -DestroyString(EncodedValue); - -return(S); -} - - - - -int MessageQueueAddToSelect(ListNode *SelectList) -{ -ListNode *Curr; -TMessageBus *MA; - -Curr=ListGetNext(MessageBusConnections); -while (Curr) -{ - MA=(TMessageBus *) Curr->Item; - ListAppendItems(SelectList, MA->Connections, NULL); - Curr=ListGetNext(Curr); -} - -return(TRUE); -} - - diff --git a/libUseful-2.6/MessageBus.h b/libUseful-2.6/MessageBus.h deleted file mode 100755 index ade5def..0000000 --- a/libUseful-2.6/MessageBus.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LIBUSEFUL_MESSAGE_BUS_H -#define LIBUSEFUL_MESSAGE_BUS_H - -//Vars gives us list node, and also 'GetVar' which is used in the -//.c module of this .h -#include "Vars.h" -#include "file.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*MSG_FUNC)(const char *PeerName, ListNode *Variables); - -void MessageBusRegister(const char *URL, int MaxConnections, int Timeout, MSG_FUNC); -STREAM *MessageBusWrite(const char *URL, const char *Args); -STREAM *MessageBusSend(const char *URL, ListNode *Args); -int MessageBusRecv(STREAM *S, char **Source, ListNode *Vars); -int MessageQueueAddToSelect(ListNode *SelectList); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libUseful-2.6/ParseURL.c b/libUseful-2.6/ParseURL.c deleted file mode 100755 index e45b0e8..0000000 --- a/libUseful-2.6/ParseURL.c +++ /dev/null @@ -1,138 +0,0 @@ -#include "ParseURL.h" - -const char *ParseHostDetails(const char *Data,char **Host,char **Port,char **User, char **Password) -{ -char *Token=NULL, *tptr; -const char *ptr; - -if (Port) *Port=CopyStr(*Port,""); -if (Host) *Host=CopyStr(*Host,""); -if (User) *User=CopyStr(*User,""); -if (Password) *Password=CopyStr(*Password,""); - -ptr=strrchr(Data,'@'); -if (ptr) -{ - //in some cases there will be an '@' in the username, so GETTOKEN_QUOTES - //should handle any @ which is prefixed with a \ to quote it out - ptr=GetToken(Data,"@",&Token, GETTOKEN_QUOTES); - if (User) - { - tptr=GetToken(Token,":",User,0); - if (StrLen(tptr)) *Password=CopyStr(*Password,tptr); - } -} -else ptr=Data; - -if (Host) ptr=GetToken(ptr,"/",&Token,0); -tptr=strchr(Token,':'); -if (tptr) -{ -*tptr='\0'; -if (Port) *Port=CopyStr(*Port,tptr+1); -} -*Host=CopyStr(*Host, Token); - -DestroyString(Token); - -return(ptr); -} - -void ParseURL(const char *URL, char **Proto, char **Host, char **Port, char **User, char **Password, char **Path, char **Args) -{ -const char *ptr; -char *Token=NULL, *tProto=NULL, *aptr; - - -//Even if they pass NULL for protocol, we need to take a copy for use in -//the 'guess the port' section below -ptr=strchr(URL,':'); -if (ptr) -{ - tProto=CopyStrLen(tProto,URL,ptr-URL); - strlwr(tProto); - if (Proto) *Proto=CopyStr(*Proto,tProto); - - ptr++; - //some number of '//' follow protocol - while (*ptr=='/') ptr++; - - ptr=GetToken(ptr,"/",&Token,0); - ParseHostDetails(Token,Host,Port,User,Password); -} -else ptr=URL; - -while (*ptr=='/') ptr++; - -if (ptr) -{ -if (Path) -{ - *Path=MCopyStr(*Path,"/",ptr,NULL); - - //Only split the HTTP CGI arguments from the document path if we were - //asked to return the args seperately - if (Args) - { - aptr=strrchr(*Path,'?'); - if (aptr) - { - *aptr='\0'; - aptr++; - *Args=CopyStr(*Args,aptr); - } - } -} -} - -//the 'GetToken' call will have thrown away the '/' at the start of the path -//add it back in - -if (Port && (! StrLen(*Port)) && StrLen(tProto)) -{ - if (strcmp(tProto,"http")==0) *Port=CopyStr(*Port,"80"); - else if (strcmp(tProto,"https")==0) *Port=CopyStr(*Port,"443"); - else if (strcmp(tProto,"ssh")==0) *Port=CopyStr(*Port,"22"); - else if (strcmp(tProto,"ftp")==0) *Port=CopyStr(*Port,"21"); - else if (strcmp(tProto,"telnet")==0) *Port=CopyStr(*Port,"23"); - else if (strcmp(tProto,"smtp")==0) *Port=CopyStr(*Port,"25"); - else if (strcmp(tProto,"mailto")==0) *Port=CopyStr(*Port,"25"); - -} - - -DestroyString(Token); -DestroyString(tProto); -} - - - - - - -void ParseConnectDetails(const char *Str, char **Type, char **Host, char **Port, char **User, char **Pass, char **Path) -{ -char *ptr, *Token=NULL, *Args=NULL; - -ptr=GetToken(Str," ",&Token,0); -ParseURL(Token, Type, Host, Port, User, Pass, Path, &Args); - -if (Path && StrLen(Args)) *Path=MCatStr(*Path,"?",Args,NULL); - -while (ptr) -{ - if (strcmp(Token,"-password")==0) ptr=GetToken(ptr," ",Pass,0); - else if (strcmp(Token,"-keyfile")==0) - { - ptr=GetToken(ptr," ",&Token,0); - *Pass=MCopyStr(*Pass,"keyfile:",Token,NULL); - } -ptr=GetToken(ptr," ",&Token,0); -} - -DestroyString(Token); -DestroyString(Args); -} - - - diff --git a/libUseful-2.6/ParseURL.h b/libUseful-2.6/ParseURL.h deleted file mode 100755 index 69e7a1a..0000000 --- a/libUseful-2.6/ParseURL.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef LIBUSEFUL_PARSEURL -#define LIBUSEFUL_PARSEURL - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void ParseURL(const char *URL, char **Proto, char **Host, char **Port, char **User, char **Password, char **Path, char **Args); -void ParseConnectDetails(const char *Str, char **Type, char **Host, char **Port, char **User, char **Pass, char **InitDir); -void ParseConnectHop(const char *Line, int *Type, char **Host, char **User, char **Password, char **KeyFile, int *Port); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libUseful-2.6/PatternMatch.c b/libUseful-2.6/PatternMatch.c deleted file mode 100755 index cdf6092..0000000 --- a/libUseful-2.6/PatternMatch.c +++ /dev/null @@ -1,597 +0,0 @@ -#include "PatternMatch.h" - -typedef enum {MATCH_FAIL, MATCH_FOUND, MATCH_ONE, MATCH_MANY, MATCH_REPEAT, MATCH_NEXT, MATCH_CONT, MATCH_QUOT, MATCH_START, MATCH_CHARLIST, MATCH_HEX, MATCH_OCTAL, MATCH_SWITCH_ON, MATCH_SWITCH_OFF} TPMatchElements; - -//Gets Called recursively -int pmatch_char(char **P_PtrPtr, char **S_PtrPtr, int *Flags); -int pmatch_search(char *Pattern, char **S_PtrPtr, char *S_End, char **Start, char **End, int *Flags); - - -int pmatch_ascii(char *P_Ptr,char S_Char,int Type) -{ -char ValStr[4]; -int P_Char=-1; - -if (Type==MATCH_HEX) -{ - strncpy(ValStr,P_Ptr,2); - P_Char=strtol(P_Ptr,NULL,16); -} - -if (Type==MATCH_OCTAL) -{ - strncpy(ValStr,P_Ptr,3); - P_Char=strtol(P_Ptr,NULL,8); -} - -if (P_Char==-1) return(FALSE); - -if (P_Char==S_Char) return(TRUE); - -return(FALSE); -} - - -void pmatch_switch(char SwitchType, char SwitchOnOrOff, int *Flags) -{ -int NewFlag=0, OnOrOff=FALSE; - -if (SwitchOnOrOff==MATCH_SWITCH_ON) OnOrOff=TRUE; -else if (SwitchOnOrOff==MATCH_SWITCH_OFF) OnOrOff=FALSE; -else return; - -switch (SwitchType) -{ -//These switches have the opposite meaning to the flags they control. -//+C turns case sensitivity on, but the flag is 'PMATCH_NOCASE' that -//turns it off, so we need to invert the sense of 'OnOrOff' -case 'C': NewFlag=PMATCH_NOCASE; OnOrOff= !OnOrOff; break; -case 'W': NewFlag=PMATCH_NOWILDCARDS; OnOrOff= !OnOrOff; break; -case 'X': NewFlag=PMATCH_NOEXTRACT; OnOrOff= !OnOrOff; break; - -case 'N': NewFlag=PMATCH_NEWLINEEND; break; -} - -if (OnOrOff) *Flags |= NewFlag; -else *Flags &= ~NewFlag; - -} - - -int pmatch_quot_analyze(char P_Char, char S_Char) -{ -int result=MATCH_FAIL; - -switch (P_Char) -{ - case 'a': if (S_Char==7) result=MATCH_ONE; break; - case 'b': if (S_Char=='\b') result=MATCH_ONE; break; - case 'd': if (S_Char==127) result=MATCH_ONE; break; - case 'e': if (S_Char==27) result=MATCH_ONE; break; //escape - case 'n': if (S_Char=='\n') result=MATCH_ONE; break; - case 'r': if (S_Char=='\r') result=MATCH_ONE; break; - case 't': if (S_Char==' ') result=MATCH_ONE; break; - case 'l': if (islower(S_Char)) result=MATCH_ONE; break; - case 'x': result=MATCH_HEX; break; - case 'A': if (isalpha(S_Char)) result=MATCH_ONE; break; - case 'B': if (isalnum(S_Char)) result=MATCH_ONE; break; - case 'C': if (isprint(S_Char)) result=MATCH_ONE; break; - case 'D': if (isdigit(S_Char)) result=MATCH_ONE; break; - case 'S': if (isspace(S_Char)) result=MATCH_ONE; break; - case 'P': if (ispunct(S_Char)) result=MATCH_ONE; break; - case 'X': if (isxdigit(S_Char)) result=MATCH_ONE; break; - case 'U': if (isupper(S_Char)) result=MATCH_ONE; break; - case '+': result=MATCH_SWITCH_ON; break; - case '-': result=MATCH_SWITCH_OFF; break; - - default: if (S_Char==P_Char) result=MATCH_ONE; break; -} - -return(result); -} - - - -int pmatch_quot(char **P_PtrPtr, char **S_PtrPtr, int *Flags) -{ -int result=MATCH_FAIL, OldFlags; -char P_Char, S_Char, *OldPos, *ptr; - -P_Char=**P_PtrPtr; -S_Char=**S_PtrPtr; - - -result=pmatch_quot_analyze(P_Char, S_Char); - -switch (result) -{ - case MATCH_ONE: - (*P_PtrPtr)++; - break; - - case MATCH_HEX: - if (! pmatch_ascii((*P_PtrPtr)+1,S_Char,MATCH_HEX)) return(MATCH_FAIL); - (*P_PtrPtr)+=2; - break; - - case MATCH_OCTAL: - if (! pmatch_ascii((*P_PtrPtr)+1,S_Char,MATCH_OCTAL)) return(MATCH_FAIL); - (*P_PtrPtr)+=3; - break; - - case MATCH_SWITCH_ON: - case MATCH_SWITCH_OFF: - //some switches need to be applied in order for a pattern to match - //(like the case-insensitive switch) others should only be applied if - //it matches. So we apply the switch, but if the subsequent pmatch_char fails - //we unapply it - OldFlags=*Flags; - OldPos=*P_PtrPtr; - (*P_PtrPtr)++; //go past the + or - to the actual type - pmatch_switch(**P_PtrPtr, result, Flags); - (*P_PtrPtr)++; - result=pmatch_char(P_PtrPtr, S_PtrPtr, Flags); - - if ((result==MATCH_FAIL) || (result==MATCH_CONT)) - { - *P_PtrPtr=OldPos; - *Flags=OldFlags; - } - return(result); - break; - - case MATCH_FAIL: - if (*Flags & PMATCH_SUBSTR) return(MATCH_CONT); - return(MATCH_FAIL); - break; -} - -return(MATCH_ONE); -} - - -#define CHARLIST_NOT 1 - -int pmatch_charlist(char **P_PtrPtr,char S_Char, int Flags) -{ -char P_Char, Prev_Char=0; -int result=MATCH_CONT; -int mode=0; - - -while (**P_PtrPtr != '\0') -{ - if (Flags & PMATCH_NOCASE) P_Char=tolower(**P_PtrPtr); - else P_Char=**P_PtrPtr; - - if (P_Char==']') break; - - switch (P_Char) - { - case '\\': - (*P_PtrPtr)++; - if (Flags & PMATCH_NOCASE) P_Char=tolower(**P_PtrPtr); - else P_Char=**P_PtrPtr; - break; - - case '-': - (*P_PtrPtr)++; - if (Flags & PMATCH_NOCASE) P_Char=tolower(**P_PtrPtr); - else P_Char=**P_PtrPtr; - - if ((S_Char >= Prev_Char) && (S_Char <= P_Char)) result=MATCH_ONE; - break; - - case '!': - mode |= CHARLIST_NOT; - break; - - default: - if (P_Char == S_Char) result=MATCH_ONE; - break; - } - - Prev_Char=P_Char; - (*P_PtrPtr)++; -} - -//go beyond ']' -(*P_PtrPtr)++; - -if (mode & CHARLIST_NOT) -{ - if (result==MATCH_ONE) result=MATCH_CONT; - else result=MATCH_ONE; -} - -return(result); -} - - - -int pmatch_repeat(char **P_PtrPtr, char **S_PtrPtr, char *S_End, int *Flags) -{ -char *SubPattern=NULL, *sp_ptr, *ptr; -int count=0, i, val=0, result=MATCH_FAIL; - -ptr=*P_PtrPtr; -while ( ((**P_PtrPtr) != '}') && ((**P_PtrPtr) != '\0') ) (*P_PtrPtr)++; -if ((**P_PtrPtr)=='\0') return(MATCH_FAIL); - -SubPattern=CopyStrLen(SubPattern,ptr,*P_PtrPtr - ptr); - -sp_ptr=strchr(SubPattern,'|'); -if (sp_ptr) -{ - *sp_ptr='\0'; - sp_ptr++; - count=atoi(SubPattern); - for (i=0; i < count; i++) - { - val=0; - result=pmatch_search(sp_ptr, S_PtrPtr, S_End, NULL, NULL, &val); - if (result==MATCH_CONT) result=MATCH_FAIL; - if (result==MATCH_FAIL) break; - } -} - -(*S_PtrPtr)--; -(*P_PtrPtr)++; -DestroyString(SubPattern); -return(result); -} - - - - -int pmatch_char(char **P_PtrPtr, char **S_PtrPtr, int *Flags) -{ -char P_Char, S_Char, *P_Start; -int result=MATCH_FAIL; - -P_Start=*P_PtrPtr; -if (*Flags & PMATCH_NOCASE) -{ - P_Char=tolower(**P_PtrPtr); - S_Char=tolower(**S_PtrPtr); -} -else -{ - P_Char=**P_PtrPtr; - S_Char=**S_PtrPtr; -} - - -//we must still honor switches even if 'nowildcards' is set, as we may want to turn -//'nowildcards' off, or turn case or extraction features on or off -if (*Flags & PMATCH_NOWILDCARDS) -{ - if ( - (P_Char=='\\') && - ((*(*P_PtrPtr+1)=='+') || (*(*P_PtrPtr+1)=='-')) - ) /*This is a switch, fall through and process it */ ; - else if (P_Char==S_Char) return(MATCH_ONE); - else return(MATCH_FAIL); -} - -switch (P_Char) -{ - case '\0': result=MATCH_FOUND; break; - case '|': result=MATCH_FOUND; break; - case '*': result=MATCH_MANY; break; - case '?': (*P_PtrPtr)++; result=MATCH_ONE; break; - case '^': (*P_PtrPtr)++; result=MATCH_START; break; - case '$': - if (S_Char=='\0') result=MATCH_FOUND; - else if ((*Flags & PMATCH_NEWLINEEND) && (S_Char=='\n')) result=MATCH_FOUND; - break; - - //This is akin to $ (match end) but matches any 'breaking' character - case '%': - switch (S_Char) - { - case '\0': - case '\r': - case '\n': - case ' ': - case ' ': - case '-': - case '_': - case '.': - case ',': - case ':': - case ';': - result=MATCH_FOUND; - break; - } - break; - - case '[': (*P_PtrPtr)++; result=pmatch_charlist(P_PtrPtr,S_Char,*Flags); break; - - case '{': (*P_PtrPtr)++; result=MATCH_REPEAT; break; - - case '\\': - //results here can either be MATCH_FAIL, MATCH_CONT, MATCH_ONE - (*P_PtrPtr)++; - result=pmatch_quot(P_PtrPtr, S_PtrPtr, Flags); - break; - - default: - (*P_PtrPtr)++; - if (P_Char==S_Char) result=MATCH_ONE; - else if (*Flags & PMATCH_SUBSTR) result=MATCH_CONT; - else result=MATCH_FAIL; - break; -} - -if ((result==MATCH_CONT) || (result==MATCH_FAIL)) *(P_PtrPtr)=P_Start; - -return(result); -} - - -//pmatch_many looks ahead to see if the next character can be included in the match -int pmatch_many(char *P_Ptr, char *S_Ptr, char *S_End, int *Flags) -{ -int result=MATCH_FAIL; -char *p_ptr, *s_ptr; - -//This is a LOOKAHEAD function, so we don't want to change any pointer positions -//thus we use local pointers to do all the searching -p_ptr=P_Ptr; -s_ptr=S_Ptr; - -switch (*p_ptr) -{ - //we are at end of pattern. If we are also at end of string, then it's a match - case '\0': - if (s_ptr == S_End) return(MATCH_FOUND); - break; - - //we have a quoted char. Could be a switch, in which case we skip over it - case '\\': - p_ptr++; - result=pmatch_quot_analyze(*p_ptr, *s_ptr); - p_ptr++; - //just ignore switches - if ((result==MATCH_SWITCH_ON) || (result==MATCH_SWITCH_OFF)) - { - p_ptr++; - return(pmatch_many(p_ptr, s_ptr, S_End, Flags)); - } - break; - - default: - //if we've consumed all string, BUT ARE NOT AT END OF PATTERN, then we've failed to find a match - if (s_ptr == S_End) return(MATCH_FAIL); - else result=pmatch_char(&p_ptr, &s_ptr, Flags); - - break; -} - -//if the next character is a match, then we're at the end -//of match many -if (result==MATCH_FAIL) return(MATCH_MANY); - -return(result); -} - - - -//Somewhat ugly, as we need to iterate through the string, so we need it passed as a ** -int pmatch_search(char *Pattern, char **S_PtrPtr, char *S_End, char **MatchStart, char **MatchEnd, int *Flags) -{ -int result; -char *P_Ptr, *ptr, *S_Start; - - if (MatchStart) *MatchStart=NULL; - if (MatchEnd) *MatchEnd=NULL; - - P_Ptr=Pattern; - S_Start=*S_PtrPtr; - result=pmatch_char(&P_Ptr, S_PtrPtr, Flags); - while (*S_PtrPtr <= S_End) - { - switch (result) - { - case MATCH_FAIL: - if (*Flags & PMATCH_SUBSTR) return(MATCH_CONT); - return(MATCH_FAIL); - break; - - //Match failed, but we're looking for a substring of 'String' so continue searching for match - case MATCH_CONT: - if (! (*Flags & PMATCH_SUBSTR)) return(MATCH_FAIL); - //if we were some ways through a pattern before hitting the character - //that failed the match, then we must rewind to reconsider that character - //as a fresh match - //if ((*P_Ptr != *Pattern) && (*Pattern != '^')) (*S_PtrPtr)--; - if ((*P_Ptr != *Pattern) ) (*S_PtrPtr)--; - P_Ptr=Pattern; - break; - - case MATCH_START: - if (*Flags & PMATCH_NOTSTART) return(MATCH_FAIL); - (*S_PtrPtr)--; //naughty, were are now pointing before String, but the - //S_Ptr++ below will correct this - break; - - - //Match many is a special case. We have too look ahead to see if the next char - //Matches, and thus takes us out of 'match many' howerver, If the call to pmatch_char - //fails then we have to rewind the pattern pointer to match many's '*' and go round again - case MATCH_MANY: - result=pmatch_many(P_Ptr+1, (*S_PtrPtr)+1, S_End, Flags); - - if (result == MATCH_FAIL) return(MATCH_FAIL); - if (result == MATCH_ONE) - { - result=MATCH_NEXT; - P_Ptr++; - } - break; - - case MATCH_FOUND: - if (! (*Flags & PMATCH_NOEXTRACT) ) - { - //This is to prevent returning NULL strings in 'MatchStart' and 'MatchEnd' - if (MatchStart && (! *MatchStart)) *MatchStart=S_Start; - if (MatchEnd && (! *MatchEnd)) *MatchEnd=*MatchStart; - } - return(MATCH_ONE); - break; - - case MATCH_REPEAT: - result=pmatch_repeat(&P_Ptr, S_PtrPtr, S_End, Flags); - if (result==MATCH_FAIL) - { - if (*Flags & PMATCH_SUBSTR) return(MATCH_CONT); - return(MATCH_FAIL); - } - break; - } - - - if (result==MATCH_NEXT) /*do nothing */ ; - else if (result==MATCH_FOUND) continue; - else if ((result==MATCH_CONT) ) - { - if (MatchStart) *MatchStart=NULL; - if (MatchEnd) *MatchEnd=NULL; - } - else if (! (*Flags & PMATCH_NOEXTRACT)) - { - if (MatchStart && (*S_PtrPtr >= S_Start) && (! *MatchStart)) *MatchStart=*S_PtrPtr; - if (MatchEnd && ((*(S_PtrPtr)+1) < S_End)) *MatchEnd=(*S_PtrPtr)+1; - } - - //Handle 'MATCH_FOUND' in the switch statement, don't iterate further through Pattern or String - - (*S_PtrPtr)++; - - result=pmatch_char(&P_Ptr, S_PtrPtr, Flags); - } - -//if pattern not exhausted then we didn't get a match -if (*P_Ptr !='\0') return(MATCH_CONT); - -return(MATCH_ONE); -} - - - - -//Wrapper around pmatch_search to make it more user friendly -int pmatch_one(char *Pattern, char *String, int len, char **Start, char **End, int Flags) -{ -char *S_Ptr, *S_End; -int result; - -if (! String) return(FALSE); -if (! Pattern) return(FALSE); - - S_Ptr=String; - S_End=String+len; - if (Start) *Start=NULL; - if (End) *End=NULL; - -result=pmatch_search(Pattern, &S_Ptr, S_End, Start, End, &Flags); - -if (result == MATCH_ONE) return(TRUE); -if (result == MATCH_FOUND) return(TRUE); - -return(FALSE); -} - - - - -int pmatch_process(char **Compiled, char *String, int len, ListNode *Matches, int iFlags) -{ -//p_ptr points to the pattern from 'Compiled' that's currently being -//tested. s_ptr holds our progress through the string -char **p_ptr; -char *s_ptr, *s_end; -char *Start=NULL, *End=NULL; -int result, Flags; -TPMatch *Match; -int NoOfItems=0; - -Flags=iFlags &= ~PMATCH_SUBSTR; -s_end=String+len; -//We handle PMATCH substr in this function -for (s_ptr=String; s_ptr < s_end; s_ptr++) -{ - for (p_ptr=Compiled; *p_ptr != NULL; p_ptr++) - { - if (pmatch_one(*p_ptr, s_ptr, s_end-s_ptr, &Start, &End, Flags)) - { - NoOfItems++; - if (Matches) - { - Match=(TPMatch *) calloc(1, sizeof(TPMatch)); - Match->Start=Start; - Match->End=End; - ListAddItem(Matches,Match); - - //if we allow matches to overlap, then we'll check for a match - //at every position, otherwise we jump to end of this match - if (! (Flags & PMATCH_OVERLAP)) - { - s_ptr=End; - s_ptr--; - } - } - } - } - Flags |= PMATCH_NOTSTART; -} - -return(NoOfItems); -} - - - -void pmatch_compile(char *Pattern, char ***Compiled) -{ -int NoOfRecords=0, NoOfItems=0; -char *ptr; - -ptr=Pattern; - -while (ptr && (*ptr != '\0')) -{ - //while ((*ptr=='?') || (*ptr=='*')) ptr++; - NoOfItems++; - if (NoOfItems >= NoOfRecords) - { - NoOfRecords+=10; - *Compiled=(char **) realloc(*Compiled,NoOfRecords*sizeof(char *)); - - } - (*Compiled)[NoOfItems-1]=ptr; - while ((*ptr !='\0') && (*ptr != '|')) ptr++; - if (*ptr=='|') ptr++; -} - -*Compiled=(char **) realloc(*Compiled,(NoOfRecords+1)*sizeof(char *)); -(*Compiled)[NoOfItems]=NULL; -} - - - -int pmatch(char *Pattern, char *String, int Len, ListNode *Matches, int Flags) -{ -char *ptr, **Compiled=NULL; -int result, len; - - pmatch_compile(Pattern,&Compiled); - - ptr=String; - len=Len; - - result=pmatch_process(Compiled, ptr, len, Matches, Flags); - - if (Compiled) free(Compiled); - return(result); -} diff --git a/libUseful-2.6/PatternMatch.c- b/libUseful-2.6/PatternMatch.c- deleted file mode 100755 index 0eaeed1..0000000 --- a/libUseful-2.6/PatternMatch.c- +++ /dev/null @@ -1,549 +0,0 @@ -#include "PatternMatch.h" - -typedef enum {MATCH_FAIL, MATCH_FOUND, MATCH_ONE, MATCH_MANY, MATCH_REPEAT, MATCH_CONT, MATCH_QUOT, MATCH_START, MATCH_CHARLIST, MATCH_HEX, MATCH_OCTAL, MATCH_SWITCH_ON, MATCH_SWITCH_OFF} TPMatchElements; - -//Gets Called recursively -int pmatch_char(char **P_PtrPtr, char **S_PtrPtr, int *Flags); -int pmatch_search(char *Pattern, char **S_PtrPtr, char *S_End, char **Start, char **End, int *Flags); - - -int pmatch_ascii(char *P_Ptr,char S_Char,int Type) -{ -char ValStr[4]; -int P_Char=-1; - -if (Type==MATCH_HEX) -{ - strncpy(ValStr,P_Ptr,2); - P_Char=strtol(P_Ptr,NULL,16); -} - -if (Type==MATCH_OCTAL) -{ - strncpy(ValStr,P_Ptr,3); - P_Char=strtol(P_Ptr,NULL,8); -} - -if (P_Char==-1) return(FALSE); - -if (P_Char==S_Char) return(TRUE); - -return(FALSE); -} - - -void pmatch_switch(char SwitchType, char SwitchOnOrOff, int *Flags) -{ -int NewFlag=0, OnOrOff=FALSE; - -if (SwitchOnOrOff==MATCH_SWITCH_ON) OnOrOff=TRUE; -else if (SwitchOnOrOff==MATCH_SWITCH_OFF) OnOrOff=FALSE; -else return; - -switch (SwitchType) -{ -//These switches have the opposite meaning to the flags they control. -//+C turns case sensitivity on, but the flag is 'PMATCH_NOCASE' that -//turns it off, so we need to invert the sense of 'OnOrOff' -case 'C': NewFlag=PMATCH_NOCASE; OnOrOff= !OnOrOff; break; -case 'W': NewFlag=PMATCH_NOWILDCARDS; OnOrOff= !OnOrOff; break; -case 'X': NewFlag=PMATCH_NOEXTRACT; OnOrOff= !OnOrOff; break; - -case 'N': NewFlag=PMATCH_NEWLINEEND; break; -} - -if (OnOrOff) *Flags |= NewFlag; -else *Flags &= ~NewFlag; - -} - - - -int pmatch_quot(char **P_PtrPtr, char **S_PtrPtr, int *Flags) -{ -int result=MATCH_FAIL, OldFlags; -char P_Char, S_Char, *OldPos; - -P_Char=**P_PtrPtr; -S_Char=**S_PtrPtr; - -switch (P_Char) -{ - case 'b': if (S_Char=='\b') result=MATCH_ONE; break; - case 'e': if (S_Char==27) result=MATCH_ONE; break; //escape - case 'n': if (S_Char=='\n') result=MATCH_ONE; break; - case 'r': if (S_Char=='\r') result=MATCH_ONE; break; - case 't': if (S_Char==' ') result=MATCH_ONE; break; - case 'l': if (islower(S_Char)) result=MATCH_ONE; break; - case 'x': result=MATCH_HEX; break; - case 'A': if (isalpha(S_Char)) result=MATCH_ONE; break; - case 'B': if (isalnum(S_Char)) result=MATCH_ONE; break; - case 'D': if (isdigit(S_Char)) result=MATCH_ONE; break; - case 'S': - /* - if ((S_Char=='\x1b') && (*((*S_PtrPtr)+1)=='[')) - { - //treat vt escape seqences as space - while ((S_Char !='m') && (S_Char != '\0')) - { - (*S_PtrPtr)++; - S_Char=**S_PtrPtr; - } - result=MATCH_ONE; - } - */ - if (isspace(S_Char)) result=MATCH_ONE; - break; - case 'P': if (ispunct(S_Char)) result=MATCH_ONE; break; - case 'X': if (isxdigit(S_Char)) result=MATCH_ONE; break; - case 'U': if (isupper(S_Char)) result=MATCH_ONE; break; - case '+': result=MATCH_SWITCH_ON; break; - case '-': result=MATCH_SWITCH_OFF; break; - - default: if (S_Char==P_Char) result=MATCH_ONE; break; -} - -switch (result) -{ - case MATCH_ONE: - (*P_PtrPtr)++; - break; - - case MATCH_HEX: - if (! pmatch_ascii((*P_PtrPtr)+1,S_Char,MATCH_HEX)) return(MATCH_FAIL); - (*P_PtrPtr)+=2; - break; - - case MATCH_OCTAL: - if (! pmatch_ascii((*P_PtrPtr)+1,S_Char,MATCH_OCTAL)) return(MATCH_FAIL); - (*P_PtrPtr)+=3; - break; - - case MATCH_SWITCH_ON: - case MATCH_SWITCH_OFF: - - - //some switches need to be applied in order for a pattern to match - //(like the case-insensitive switch) others should only be applied if - //it matches. So we apply the switch, but if the subsequent pmatch_char fails - //we unapply it - OldFlags=*Flags; - OldPos=*P_PtrPtr; - (*P_PtrPtr)++; //go past the + or - to the actual type - pmatch_switch(**P_PtrPtr, result, Flags); - (*P_PtrPtr)++; - result=pmatch_char(P_PtrPtr, S_PtrPtr, Flags); - - if ((result==MATCH_FAIL) || (result==MATCH_CONT)) - { - *P_PtrPtr=OldPos; - *Flags=OldFlags; - } - return(result); - break; - - case MATCH_FAIL: - if (*Flags & PMATCH_SUBSTR) return(MATCH_CONT); - return(MATCH_FAIL); - break; -} - -return(MATCH_ONE); -} - - -#define CHARLIST_NOT 1 - -int pmatch_charlist(char **P_PtrPtr,char S_Char, int Flags) -{ -char P_Char, Prev_Char=0; -int result=MATCH_CONT; -int mode=0; - - -while (**P_PtrPtr != '\0') -{ - if (Flags & PMATCH_NOCASE) P_Char=tolower(**P_PtrPtr); - else P_Char=**P_PtrPtr; - - if (P_Char==']') break; - - switch (P_Char) - { - case '\\': - (*P_PtrPtr)++; - if (Flags & PMATCH_NOCASE) P_Char=tolower(**P_PtrPtr); - else P_Char=**P_PtrPtr; - break; - - case '-': - (*P_PtrPtr)++; - if (Flags & PMATCH_NOCASE) P_Char=tolower(**P_PtrPtr); - else P_Char=**P_PtrPtr; - - if ((S_Char >= Prev_Char) && (S_Char <= P_Char)) result=MATCH_ONE; - break; - - case '!': - mode |= CHARLIST_NOT; - break; - - default: - if (P_Char == S_Char) result=MATCH_ONE; - break; - } - - Prev_Char=P_Char; - (*P_PtrPtr)++; -} - -//go beyond ']' -(*P_PtrPtr)++; - -if (mode & CHARLIST_NOT) -{ - if (result==MATCH_ONE) result=MATCH_CONT; - else result=MATCH_ONE; -} - -return(result); -} - - - -int pmatch_repeat(char **P_PtrPtr, char **S_PtrPtr, char *S_End, int *Flags) -{ -char *SubPattern=NULL, *sp_ptr, *ptr; -int count=0, i, val=0, result=MATCH_FAIL; - -ptr=*P_PtrPtr; -while ( ((**P_PtrPtr) != '}') && ((**P_PtrPtr) != '\0') ) (*P_PtrPtr)++; -if ((**P_PtrPtr)=='\0') return(MATCH_FAIL); - -SubPattern=CopyStrLen(SubPattern,ptr,*P_PtrPtr - ptr); - -sp_ptr=strchr(SubPattern,'|'); -if (sp_ptr) -{ - *sp_ptr='\0'; - sp_ptr++; - count=atoi(SubPattern); - for (i=0; i < count; i++) - { - val=0; - result=pmatch_search(sp_ptr, S_PtrPtr, S_End, NULL, NULL, &val); - if (result==MATCH_CONT) result=MATCH_FAIL; - if (result==MATCH_FAIL) break; - } -} - -(*S_PtrPtr)--; -(*P_PtrPtr)++; -DestroyString(SubPattern); -return(result); -} - - - - -int pmatch_char(char **P_PtrPtr, char **S_PtrPtr, int *Flags) -{ -char P_Char, S_Char, *P_Start; -int result=MATCH_FAIL; - -P_Start=*P_PtrPtr; -if (*Flags & PMATCH_NOCASE) -{ - P_Char=tolower(**P_PtrPtr); - S_Char=tolower(**S_PtrPtr); -} -else -{ - P_Char=**P_PtrPtr; - S_Char=**S_PtrPtr; -} - - - -//we must still honor switches even if 'nowildcards' is set, as we may want to turn -//'nowildcards' off, or turn case or extraction features on or off -if (*Flags & PMATCH_NOWILDCARDS) -{ - if ( - (P_Char=='\\') && - ((*(*P_PtrPtr+1)=='+') || (*(*P_PtrPtr+1)=='-')) - ) /*This is a switch, fall through and process it */ ; - else if (P_Char==S_Char) return(MATCH_ONE); - else return(MATCH_FAIL); -} - -switch (P_Char) -{ - case '\0': result=MATCH_FOUND; break; - case '|': result=MATCH_FOUND; break; - case '*': result=MATCH_MANY;break; - case '?': (*P_PtrPtr)++; result=MATCH_ONE;break; - case '^': (*P_PtrPtr)++; result=MATCH_START; break; - case '$': - if (S_Char=='\0') result=MATCH_FOUND; - else if ((*Flags & PMATCH_NEWLINEEND) && (S_Char=='\n')) result=MATCH_FOUND; - break; - - //This is akin to $ (match end) but matches any 'breaking' character - case '%': - switch (S_Char) - { - case '\0': - case '\r': - case '\n': - case ' ': - case ' ': - case '-': - case '_': - case '.': - case ',': - case ':': - case ';': - result=MATCH_FOUND; - break; - } - break; - - case '[': (*P_PtrPtr)++; result=pmatch_charlist(P_PtrPtr,S_Char,*Flags); break; - - case '{': (*P_PtrPtr)++; result=MATCH_REPEAT; break; - - case '\\': - //results here can either be MATCH_FAIL, MATCH_CONT, MATCH_ONE - (*P_PtrPtr)++; - result=pmatch_quot(P_PtrPtr, S_PtrPtr, Flags); - break; - - default: - (*P_PtrPtr)++; - if (P_Char==S_Char) result=MATCH_ONE; - else if (*Flags & PMATCH_SUBSTR) result=MATCH_CONT; - else result=MATCH_FAIL; - break; -} - -if ((result==MATCH_CONT) || (result==MATCH_FAIL)) *(P_PtrPtr)=P_Start; - -return(result); -} - - - -//Somewhat ugly, as we need to iterate through the string, so we need it passed as a ** -int pmatch_search(char *Pattern, char **S_PtrPtr, char *S_End, char **MatchStart, char **MatchEnd, int *Flags) -{ -int result; -char *P_Ptr, *ptr, *S_Start; - - if (MatchStart) *MatchStart=NULL; - if (MatchEnd) *MatchEnd=NULL; - - P_Ptr=Pattern; - S_Start=*S_PtrPtr; - result=pmatch_char(&P_Ptr, S_PtrPtr, Flags); - while (*S_PtrPtr <= S_End) - { - switch (result) - { - case MATCH_FAIL: - if (*Flags & PMATCH_SUBSTR) return(MATCH_CONT); - return(MATCH_FAIL); - break; - - //Match failed, but we're looking for a substring of 'String' so continue searching for match - case MATCH_CONT: - if (! (*Flags & PMATCH_SUBSTR)) return(MATCH_FAIL); - //if we were some ways through a pattern before hitting the character - //that failed the match, then we must rewind to reconsider that character - //as a fresh match - //if ((*P_Ptr != *Pattern) && (*Pattern != '^')) (*S_PtrPtr)--; - if ((*P_Ptr != *Pattern) ) (*S_PtrPtr)--; - P_Ptr=Pattern; - break; - - case MATCH_START: - if (*Flags & PMATCH_NOTSTART) return(MATCH_FAIL); - (*S_PtrPtr)--; //naughty, were are now pointing before String, but the - //S_Ptr++ below will correct this - break; - - - case MATCH_FOUND: - if (*Flags & PMATCH_NOEXTRACT) - { - //This is to prevent returning NULL strings in 'MatchStart' and 'MatchEnd' - if (MatchStart && (! *MatchStart)) *MatchStart=S_Start; - if (MatchEnd && (! *MatchEnd)) *MatchEnd=*MatchStart; - } - //else if (MatchEnd) *MatchEnd=*S_PtrPtr; - return(MATCH_ONE); - break; - - //Match many is a special case. We have too look ahead to see if the next char - //Matches, and thus takes us out of 'match many' howerver, If the call to pmatch_char - //fails then we have to rewind the pattern pointer to match many's '*' and go round again - case MATCH_MANY: - ptr=P_Ptr; - P_Ptr++; - - //pmatch_char will think that if we've reached the end of the pattern, then we've got - //a match, regardless of where we are in the string. However, this is the one case where - //'*' needs to be a little 'greedy'. If the last item in the pattern was '*' (match many) - //then we need to continue until we read the end of the string - if (*P_Ptr=='\0') - { - if (*S_PtrPtr == S_End) result=MATCH_FOUND; - else result=MATCH_FAIL; - } - else - { - if (*S_PtrPtr == S_End) result=MATCH_FAIL; - else result=pmatch_char(&P_Ptr, S_PtrPtr, Flags); - } - - if ((result==MATCH_FAIL) || (result==MATCH_CONT)) P_Ptr=ptr; - break; - - case MATCH_REPEAT: - result=pmatch_repeat(&P_Ptr, S_PtrPtr, S_End, Flags); - if (result==MATCH_FAIL) - { - if (*Flags & PMATCH_SUBSTR) return(MATCH_CONT); - return(MATCH_FAIL); - } - break; - } - - if ((result==MATCH_CONT) ) - { - if (MatchStart) *MatchStart=NULL; - if (MatchEnd) *MatchEnd=NULL; - } - else if (! (*Flags & PMATCH_NOEXTRACT)) - { - if (MatchStart && (*S_PtrPtr >= S_Start) && (! *MatchStart)) *MatchStart=*S_PtrPtr; - if (MatchEnd && ((*(S_PtrPtr)+1) < S_End)) *MatchEnd=(*S_PtrPtr)+1; - } - - //Handle 'MATCH_FOUND' in the switch statement, don't iterate further through Pattern or String - if (result==MATCH_FOUND) continue; - - (*S_PtrPtr)++; - //if (*S_PtrPtr > S_End) break; - - result=pmatch_char(&P_Ptr, S_PtrPtr, Flags); - } - -//if pattern not exhausted then we didn't get a match -if (*P_Ptr !='\0') return(MATCH_CONT); - -return(MATCH_ONE); -} - - - - -//Wrapper around pmatch_search to make it more user friendly -int pmatch_one(char *Pattern, char *String, int len, char **Start, char **End, int Flags) -{ -char *S_Ptr, *S_End; - - S_Ptr=String; - S_End=String+len; - if (Start) *Start=NULL; - if (End) *End=NULL; - - return(pmatch_search(Pattern, &S_Ptr, S_End, Start, End, &Flags)); -} - - - - -int pmatch_process(char **Compiled, char *String, int len, ListNode *Matches, int iFlags) -{ -//p_ptr points to the pattern from 'Compiled' that's currently being -//tested. s_ptr holds our progress through the string -char **p_ptr; -char *s_ptr, *s_end; -char *Start=NULL, *End=NULL; -int result, Flags; -TPMatch *Match; -int NoOfItems=0; - -Flags=iFlags &= ~PMATCH_SUBSTR; -s_end=String+len; -//We handle PMATCH substr in this function -for (p_ptr=Compiled; *p_ptr != NULL; p_ptr++) -{ - for (s_ptr=String; s_ptr < s_end; s_ptr++) - { - result=pmatch_one(*p_ptr, s_ptr, s_end-s_ptr, &Start, &End, Flags); - if (result==MATCH_ONE) - { - NoOfItems++; - if (Matches) - { - Match=(TPMatch *) calloc(1, sizeof(TPMatch)); - Match->Start=Start; - Match->End=End; - ListAddItem(Matches,Match); - } - } - else if (result==MATCH_FAIL) break; - } - Flags |= PMATCH_NOTSTART; -} - -return(NoOfItems); -} - - - -void pmatch_compile(char *Pattern, char ***Compiled) -{ -int NoOfRecords=0, NoOfItems=0; -char *ptr; - -ptr=Pattern; - -while (ptr && (*ptr != '\0')) -{ - //while ((*ptr=='?') || (*ptr=='*')) ptr++; - NoOfItems++; - if (NoOfItems >= NoOfRecords) - { - NoOfRecords+=10; - *Compiled=(char **) realloc(*Compiled,NoOfRecords*sizeof(char *)); - - } - (*Compiled)[NoOfItems-1]=ptr; - while ((*ptr !='\0') && (*ptr != '|')) ptr++; - if (*ptr=='|') ptr++; -} - -*Compiled=(char **) realloc(*Compiled,(NoOfRecords+1)*sizeof(char *)); -(*Compiled)[NoOfItems]=NULL; -} - - - -int pmatch(char *Pattern, char *String, int Len, ListNode *Matches, int Flags) -{ -char *ptr, **Compiled=NULL; -int result, len; - - pmatch_compile(Pattern,&Compiled); - - ptr=String; - len=Len; - - result=pmatch_process(Compiled, ptr, len, Matches, Flags); - - if (Compiled) free(Compiled); - return(result); -} diff --git a/libUseful-2.6/PatternMatch.h b/libUseful-2.6/PatternMatch.h deleted file mode 100755 index 278db15..0000000 --- a/libUseful-2.6/PatternMatch.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef LIBUSEFUL_MATCHPATTERN -#define LIBUSEFUL_MATCHPATTERN - -#define PMATCH_SUBSTR 1 -#define PMATCH_NOWILDCARDS 2 -#define PMATCH_NOCASE 4 -#define PMATCH_NOEXTRACT 8 -#define PMATCH_NEWLINEEND 16 -#define PMATCH_NOTSTART 32 -#define PMATCH_NOTEND 64 -#define PMATCH_OVERLAP 128 - - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct -{ -char *Start; -char *End; -} TPMatch; - - -int pmatch_one(char *Pattern, char *String, int len, char **Start, char **End, int Flags); -int pmatch(char *Pattern, char *String, int Len, ListNode *Matches, int Flags); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libUseful-2.6/README b/libUseful-2.6/README deleted file mode 100755 index b4b35ab..0000000 --- a/libUseful-2.6/README +++ /dev/null @@ -1,2 +0,0 @@ -libUseful is a 'C' library of useful functions. Documentation not yet prepared, but coming soonish. - diff --git a/libUseful-2.6/SpawnPrograms.c b/libUseful-2.6/SpawnPrograms.c deleted file mode 100755 index 67d2392..0000000 --- a/libUseful-2.6/SpawnPrograms.c +++ /dev/null @@ -1,479 +0,0 @@ -#include "SpawnPrograms.h" -#include "Log.h" -#include "pty.h" -#include "file.h" -#include "string.h" -#include -#include - -//This is the function we call in the child process for 'SpawnCommand' -int BASIC_FUNC_EXEC_COMMAND(void *Command) -{ -int result; - -result=execl("/bin/sh","/bin/sh","-c",(char *) Command,NULL); - -return(result); -} - -pid_t ForkWithContext(const char *User, const char *Dir, const char *Group) -{ -pid_t pid; - -LogFileFlushAll(TRUE); -pid=fork(); -if (pid==0) -{ - if (StrLen(Dir)) chdir(Dir); - if (StrLen(Group)) SwitchGroup(Group); - if (StrLen(User)) SwitchUser(User); -} -return(pid); -} - - -int ForkWithIO(int StdIn, int StdOut, int StdErr) -{ -pid_t pid; -int fd; - -pid=ForkWithContext(NULL, NULL, NULL); -if (pid==0) -{ - if (StdIn > -1) - { - if (StdIn !=0) - { - close(0); - dup(StdIn); - } - } - else - { - fd=open("/dev/null",O_RDONLY); - dup(fd); - close(fd); - } - - if (StdOut > -1) - { - if (StdOut !=1) - { - close(1); - dup(StdOut); - } - } - else - { - fd=open("/dev/null",O_WRONLY); - dup(fd); - close(fd); - } - - if (StdErr > -1) - { - if (StdErr !=2) - { - close(2); - dup(StdErr); - } - } -} - - -return(pid); -} - - -/* This function turns our process into a demon */ -int demonize() -{ -int result, i=0; - -LogFileFlushAll(TRUE); -//Don't fork with context here, as a demonize involves two forks, so -//it's wasted work here. -result=fork(); -if (result != 0) exit(0); - -/*we can only get to here if result= 0 i.e. we are the child process*/ -setsid(); - -result=ForkWithContext(NULL, NULL, NULL); -if (result !=0) exit(0); -umask(0); - -/* close stdin, stdout and std error, but only if they are a tty. In some */ -/* situations (like working out of cron) we may not have been given in/out/err */ -/* and thus the first files we open will be 0,1,2. If we close them, we will have */ -/* closed files that we need! Alternatively, the user may have used shell redirection */ -/* to send output for a file, and I'm sure they don't want us to close that file */ - -//for (i=0; i < 3; i++) -{ - if (isatty(i)) - { - close(i); - /* reopen to /dev/null so that any output gets thrown away */ - /* but the program still has somewhere to write to */ - open("/dev/null",O_RDWR); - } -} - - -return(1); -} - - - - -void SpawnApplyConfig(const char *Config, int Flags) -{ -char *User=NULL, *Group=NULL, *Dir=NULL; -char *Name=NULL, *Value=NULL; -const char *ptr; -struct rlimit limit; -rlim_t val; - -int i; - -//set all signal handlers to default -if (Flags & SPAWN_SIGDEF) -{ -for (i =0; i < NSIG; i++) signal(i,SIG_DFL); -} - -//Set controlling tty to be stdin. This means that CTRL-C, SIGWINCH etc is handled for the -//stdin file descriptor, not for any oher -if (Flags & SPAWN_DAEMON) demonize(); -else -{ - if (Flags & SPAWN_SETSID) setsid(); - if (Flags & SPAWN_CTRL_TTY) tcsetpgrp(0, getpgrp()); -} - -User=CopyStr(User,""); -Group=CopyStr(Group,""); -ptr=GetNameValuePair(Config,"\\S","=",&Name,&Value); -while (ptr) -{ - if (strcasecmp(Name,"User")==0) User=CopyStr(User, Value); - else if (strcasecmp(Name,"Group")==0) Group=CopyStr(Group, Value); - else if (strcasecmp(Name,"Dir")==0) Dir=CopyStr(Dir, Value); - else if (strcasecmp(Name,"PidFile")==0) WritePidFile(Value); - else if (strcasecmp(Name,"prio")==0) setpriority(PRIO_PROCESS, 0, atoi(Value)); - else if (strcasecmp(Name,"nice")==0) setpriority(PRIO_PROCESS, 0, atoi(Value)); - else if (strcasecmp(Name,"priority")==0) setpriority(PRIO_PROCESS, 0, atoi(Value)); - else if (strcasecmp(Name,"mem")==0) - { - val=(rlim_t) ParseHumanReadableDataQty(Value, 0); - limit.rlim_cur=val; - limit.rlim_max=val; - setrlimit(RLIMIT_DATA, &limit); - } - else if (strcasecmp(Name,"fsize")==0) - { - val=(rlim_t) ParseHumanReadableDataQty(Value, 0); - limit.rlim_cur=val; - limit.rlim_max=val; - setrlimit(RLIMIT_FSIZE, &limit); - } - else if (strcasecmp(Name,"files")==0) - { - val=(rlim_t) ParseHumanReadableDataQty(Value, 0); - limit.rlim_cur=val; - limit.rlim_max=val; - setrlimit(RLIMIT_NOFILE, &limit); - } - else if (strcasecmp(Name,"coredumps")==0) - { - val=(rlim_t) ParseHumanReadableDataQty(Value, 0); - limit.rlim_cur=val; - limit.rlim_max=val; - setrlimit(RLIMIT_CORE, &limit); - } - else if ( (strcasecmp(Name,"procs")==0) || (strcasecmp(Name,"nproc")==0) ) - { - val=(rlim_t) ParseHumanReadableDataQty(Value, 0); - limit.rlim_cur=val; - limit.rlim_max=val; - setrlimit(RLIMIT_NPROC, &limit); - } - ptr=GetNameValuePair(ptr,"\\S","=",&Name,&Value); -} - -// This allows us to chroot into a whole different unix directory tree, with its own -// password file etc -if (Flags & SPAWN_CHROOT) chroot("."); - -if (StrLen(Dir)) chdir(Dir); - -//Always do group first, otherwise we'll lose ability to switch user/group -if (StrLen(Group)) SwitchGroup(Group); -if (StrLen(User)) SwitchUser(User); - -//Must do this last! After parsing Config, and also after functions like -//SwitchUser that will need access to /etc/passwd -if (Flags & SPAWN_JAIL) chroot("."); - -DestroyString(Name); -DestroyString(Value); -DestroyString(User); -DestroyString(Group); -DestroyString(Dir); -} - - -//This Function eliminates characters from a string that can be used to trivially achieve code-exec via the shell -char *MakeShellSafeString(char *RetStr, const char *String, int SafeLevel) -{ -char *Tempstr=NULL; -char *BadChars=";|&`"; - -if (SafeLevel==SHELLSAFE_BLANK) -{ - Tempstr=CopyStr(RetStr,String); - strmrep(Tempstr,BadChars,' '); -} -else Tempstr=QuoteCharsInStr(RetStr,String,BadChars); - -if (strcmp(Tempstr,String) !=0) -{ - //if (EventCallback) EventCallback(String); -} -return(Tempstr); -} - - -void SwitchProgram(const char *CommandLine, int Flags, const char *Config) -{ -char **argv, *ptr; -char *Token=NULL, *SafeStr=NULL; -int i; - -if (Flags & SPAWN_TRUST_COMMAND) SafeStr=CopyStr(SafeStr,CommandLine); -else SafeStr=MakeShellSafeString(SafeStr, CommandLine, 0); - -SafeStr=MakeShellSafeString(SafeStr,CommandLine,0); -argv=(char **) calloc(101,sizeof(char *)); -ptr=SafeStr; -for (i=0; i < 100; i++) -{ - ptr=GetToken(ptr,"\\S",&Token,GETTOKEN_QUOTES); - if (! ptr) break; - argv[i]=CopyStr(argv[i],Token); -} - -SpawnApplyConfig(Config, Flags); - -DestroyString(Token); -DestroyString(SafeStr); - -/* we are the child so we continue */ -execv(argv[0],argv); -//no point trying to free stuff here, we will no longer -//be the main program -} - - - - -pid_t SpawnWithIO(const char *CommandLine, int Flags, const char *Config, int StdIn, int StdOut, int StdErr) -{ -pid_t pid; - -pid=ForkWithIO(StdIn,StdOut,StdErr); -if (pid==0) -{ -SwitchProgram(CommandLine, Flags, Config); -_exit(pid); -} - -return(pid); -} - - -int Spawn(const char *ProgName, int Flags, const char *Config) -{ -int pid; - -pid=ForkWithIO(0,1,2); -if (pid==0) -{ - SwitchProgram(ProgName, Flags, Config); - _exit(pid); -} -return(pid); -} - - -/* This creates a child process that we can talk to using a couple of pipes*/ -pid_t PipeSpawnFunction(int *infd,int *outfd,int *errfd, BASIC_FUNC Func, void *Data, int Flags, const char *Config) -{ -pid_t pid; -int channel1[2], channel2[2], channel3[2], DevNull=-1; - -if (infd) pipe(channel1); -if (outfd) pipe(channel2); -if (errfd) pipe(channel3); - -pid=ForkWithContext(NULL,NULL,NULL); -if (pid==0) -{ - /* we are the child */ - if (infd) close(channel1[1]); - else if (DevNull==-1) DevNull=open("/dev/null",O_RDWR); - if (outfd) close(channel2[0]); - else if (DevNull==-1) DevNull=open("/dev/null",O_RDWR); - if (errfd) close(channel3[0]); - else if (DevNull==-1) DevNull=open("/dev/null",O_RDWR); - - /*close stdin, stdout and stderr*/ - close(0); - close(1); - close(2); - /*channel 1 is going to be our stdin, so we close the writing side of it*/ - if (infd) dup(channel1[0]); - else dup(DevNull); - /* channel 2 is stdout */ - if (outfd) dup(channel2[1]); - else dup(DevNull); - /* channel 3 is stderr */ - if (errfd) - { - //Yes, we can pass an integer value as errfd, even though it's an int *. - //This is probably a bad idea, and will likely be changed in future releases - if (errfd==(int *) COMMS_COMBINE_STDERR) dup(channel2[1]); - else dup(channel3[1]); - } - else dup(DevNull); - - - SpawnApplyConfig(Config, Flags); - Func(Data); - exit(0); - } -else // This is the parent process, not the spawned child -{ - /* we close the appropriate halves of the link */ - if (infd) - { - close(channel1[0]); - *infd=channel1[1]; - } - if (outfd) - { - close(channel2[1]); - *outfd=channel2[0]; - } - if (errfd) - { - close(channel3[1]); - //Yes, we can pass an integer value as errfd, even though errfd is an int *. - //This is probably a bad idea, and will likely be changed in future releases - if (errfd != (int *) COMMS_COMBINE_STDERR) *errfd=channel3[0]; - } -} - -return(pid); -} - - - -pid_t PipeSpawn(int *infd,int *outfd,int *errfd, const char *Command, int Flags, const char *Config) -{ -return(PipeSpawnFunction(infd,outfd,errfd, BASIC_FUNC_EXEC_COMMAND, (void *) Command, Flags, Config)); -} - - - - -pid_t PseudoTTYSpawnFunction(int *ret_pty, BASIC_FUNC Func, void *Data, int Flags, const char *Config) -{ -pid_t pid=-1; -int tty, pty, i; - -if (GrabPseudoTTY(&pty, &tty, Flags)) -{ -pid=ForkWithContext(NULL,NULL,NULL); -if (pid==0) -{ -for (i=0; i < 4; i++) close(i); -close(pty); - -setsid(); -ioctl(tty,TIOCSCTTY,0); - -dup(tty); -dup(tty); -dup(tty); - -///now that we've dupped it, we don't need to keep it open -//as it will be open on stdin/stdout -close(tty); - -SpawnApplyConfig(Config, Flags); -Func((char *) Data); -_exit(0); -} - -close(tty); -} - -*ret_pty=pty; -return(pid); -} - - -pid_t PseudoTTYSpawn(int *pty, const char *Command, int Flags, const char *Config) -{ -return(PseudoTTYSpawnFunction(pty, BASIC_FUNC_EXEC_COMMAND, (void *) Command, Flags, Config)); -} - - - - - -STREAM *STREAMSpawnFunction(BASIC_FUNC Func, void *Data, int Flags, const char *Config) -{ -int to_fd, from_fd, *iptr; -pid_t pid=0; -STREAM *S=NULL; -char *Tempstr=NULL; - -if (Flags & COMMS_BY_PTY) -{ - pid=PseudoTTYSpawn(&to_fd, Tempstr, Flags, Config); -} -else -{ - iptr=NULL; - if (Flags & COMMS_COMBINE_STDERR) iptr=(int *) COMMS_COMBINE_STDERR; - pid=PipeSpawnFunction(&to_fd, &from_fd, iptr, Func, Data, Flags, Config); -} - -if (pid > 0) S=STREAMFromDualFD(from_fd, to_fd); -if (S) -{ - STREAMSetFlushType(S,FLUSH_LINE,0,0); - Tempstr=FormatStr(Tempstr,"%d",pid); - STREAMSetValue(S,"PeerPID",Tempstr); -} - -DestroyString(Tempstr); -return(S); -} - - -STREAM *STREAMSpawnCommand(const char *Command, int Flags, const char *Config) -{ -STREAM *S=NULL; -char *Tempstr=NULL; - -if (Flags & SPAWN_TRUST_COMMAND) Tempstr=CopyStr(Tempstr,Command); -else Tempstr=MakeShellSafeString(Tempstr, Command, 0); - -S=STREAMSpawnFunction(BASIC_FUNC_EXEC_COMMAND, Tempstr, Flags, Config); -DestroyString(Tempstr); -return(S); -} diff --git a/libUseful-2.6/SpawnPrograms.h b/libUseful-2.6/SpawnPrograms.h deleted file mode 100755 index 4dd21b6..0000000 --- a/libUseful-2.6/SpawnPrograms.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef LIBUSEFUL_SPAWN_H -#define LIBUSEFUL_SPAWN_H - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define COMMS_BY_PIPE 0 -#define COMMS_BY_PTY 1 -#define SPAWN_TRUST_COMMAND 2 -#define COMMS_COMBINE_STDERR 4 -#define SPAWN_DAEMON 8 -#define SPAWN_SETSID 16 -#define SPAWN_CTRL_TTY 32 -#define SPAWN_CHROOT 64 -#define SPAWN_JAIL 128 -#define SPAWN_SIGDEF 256 - -//up to 2048, beyond that is TTYFLAG_ - -#define SHELLSAFE_BLANK 1 - -char *MakeShellSafeString(char *RetStr, const char *String, int SafeLevel); -void SwitchProgram(const char *CommandLine, int Flags, const char *Config); -int ForkWithContext(); -/* This function turns our process into a demon */ -int demonize(); -int ForkWithIO(int StdIn, int StdOut, int StdErr); -int SpawnWithIO(const char *CommandLine, int Flags, const char *Config, int StdIn, int StdOut, int StdErr); -int Spawn(const char *ProgName, int Flags, const char *Config); -/* This creates a child process that we can talk to using a couple of pipes*/ -int PipeSpawnFunction(int *infd,int *outfd,int *errfd, BASIC_FUNC Func, void *Data, int Flags, const char *Config); -int PipeSpawn(int *infd,int *outfd,int *errfd, const char *Command, int Flags, const char *Config); -int PseudoTTYSpawn(int *pty, const char *Command, int Flags, const char *Config); -STREAM *STREAMSpawnCommand(const char *Command, int Flags, const char *Config); -STREAM *STREAMSpawnFunction(BASIC_FUNC Func, void *Data, int Flags, const char *Config); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/Time.c b/libUseful-2.6/Time.c deleted file mode 100755 index b2b6aef..0000000 --- a/libUseful-2.6/Time.c +++ /dev/null @@ -1,126 +0,0 @@ -#include "Time.h" -#define _XOPEN_SOURCE -#include - -//we cache seconds because we expect most questions about -//time to be in seconds, and this avoids multiplying millisecs up -time_t LU_CachedTime=0; -//This is cached millisecs since 1970 -uint64_t LU_CachedMillisecs=0; -struct tm LU_CachedTM; - - -uint64_t GetTime(int Flags) -{ -struct timeval tv; - -if ((! (Flags & TIME_CACHED)) || (LU_CachedTime==0)) -{ - gettimeofday(&tv, NULL); - LU_CachedTime=tv.tv_sec; - LU_CachedMillisecs=(tv.tv_sec * 1000) + (tv.tv_usec / 1000); -} - -if (Flags & TIME_MILLISECS) return(LU_CachedMillisecs); -else if (Flags & TIME_CENTISECS) return(LU_CachedMillisecs * 10); - -return((uint64_t) LU_CachedTime); -} - - -char *GetDateStrFromSecs(const char *DateFormat, time_t Secs, const char *TimeZone) -{ -time_t val; -struct tm *TMS; -static char *Buffer=NULL; -char *Tempstr=NULL; -#define DATE_BUFF_LEN 255 - - -if (StrLen(TimeZone)) -{ -if (getenv("TZ")) Tempstr=CopyStr(Tempstr,getenv("TZ")); -setenv("TZ",TimeZone,TRUE); -tzset(); -} - -/* -if (Secs==LU_CachedTime) TMS=&LU_CachedTM; -else -{ - val=Secs; - TMS=localtime(&val); - memcpy(&LU_CachedTM, TMS, sizeof(struct tm)); -} -*/ - - val=Secs; - TMS=localtime(&val); -if (StrLen(TimeZone)) -{ -if (! Tempstr) unsetenv("TZ"); -else setenv("TZ",Tempstr,TRUE); -tzset(); -} - -val=StrLen(DateFormat)+ DATE_BUFF_LEN; -Buffer=SetStrLen(Buffer,val); -strftime(Buffer,val,DateFormat,TMS); - -DestroyString(Tempstr); -return(Buffer); -} - - - -char *GetDateStr(const char *DateFormat, const char *TimeZone) -{ -return(GetDateStrFromSecs(DateFormat, (time_t) GetTime(0), TimeZone)); -} - - -time_t DateStrToSecs(const char *DateFormat, const char *Str, const char *TimeZone) -{ -time_t Secs=0; -struct tm TMS; -char *Tempstr=NULL; - -if (StrLen(DateFormat)==0) return(0); -if (StrLen(Str)==0) return(0); - -if (StrLen(TimeZone)) -{ - if (getenv("TZ")) Tempstr=CopyStr(Tempstr,getenv("TZ")); - setenv("TZ",TimeZone,TRUE); - tzset(); -} - -strptime(Str,DateFormat,&TMS); -TMS.tm_isdst=-1; -Secs=mktime(&TMS); - -if (StrLen(TimeZone)) -{ - if (! Tempstr) unsetenv("TZ"); - else setenv("TZ",Tempstr,TRUE); - tzset(); -} -return(Secs); -} - - - -/* A general 'Set Timer' function, Useful for timing out */ -/* socket connections etc */ -void SetTimeout(int timeout) -{ -struct sigaction SigAct; - -SigAct.sa_handler=&ColLibDefaultSignalHandler; -SigAct.sa_flags=SA_RESETHAND; -//SigAct.sa_restorer=NULL; - -sigaction(SIGALRM,&SigAct,NULL); -alarm(timeout); -} - diff --git a/libUseful-2.6/Time.h b/libUseful-2.6/Time.h deleted file mode 100755 index fa53d2b..0000000 --- a/libUseful-2.6/Time.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef LIBUSEFUL_TIME_H -#define LIBUSEFUL_TIME_H - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define TIME_MILLISECS 1 -#define TIME_CENTISECS 2 -#define TIME_CACHED 1024 - -uint64_t GetTime(int Flags); -char *GetDateStrFromSecs(const char *DateFormat, time_t Secs, const char *TimeZone); -char *GetDateStr(const char *DateFormat, const char *TimeZone); -time_t DateStrToSecs(const char *DateFormat, const char *Str, const char *TimeZone); -void SetTimeout(int timeout); - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/Tokenizer.c b/libUseful-2.6/Tokenizer.c deleted file mode 100755 index 3de1b1d..0000000 --- a/libUseful-2.6/Tokenizer.c +++ /dev/null @@ -1,373 +0,0 @@ -#include "includes.h" -#include "Tokenizer.h" -#include "string.h" - -#define TOK_SPACE 1 -#define TOK_CODE 2 - -#ifdef __MMX__ -#include -#endif - -int GetTokenSepMatch(const char *Pattern,const char **start, const char **end, int Flags) -{ -const char *pptr, *eptr; -char Quote='\0'; -int MatchType=0; - -//if start and end pointers are same, then we've no string -if (*start==*end) return(FALSE); - -pptr=Pattern; -eptr=*start; - - -while (1) -{ -//check the current 'pattern' char -switch (*pptr) -{ - //if we run out of pattern, then we got a match - case '\0': - *end=eptr; - return(TRUE); - break; - - //in multiseparator mode a '|' is the same as '\0' - case '|': - if (Flags & GETTOKEN_MULTI_SEPARATORS) - { - *end=eptr; - return(TRUE); - } - break; - - - //Quoted char - case '\\': - pptr++; - if (*pptr=='S') MatchType=TOK_SPACE; - if (*pptr=='X') MatchType=TOK_CODE; - break; - -} - -switch (*eptr) -{ - //if we run out of string, then we got a part match, but its not - //a full match, so we return fail - case '\0': return(FALSE); break; - - case '\\': - //if we got a quoted character we can't have found - //the separator, so return false - if (Flags & GETTOKEN_BACKSLASH) - { - if (*eptr != *pptr) return(FALSE); - } - else - { - eptr++; - *start=eptr; - return(FALSE); - } - break; - - case '"': - case '\'': - if (Flags & GETTOKEN_HONOR_QUOTES) - { - Quote=*eptr; - eptr++; - while ((*eptr != Quote) && (*eptr != '\0')) - { - //handle quoted chars - if ((*eptr=='\\') && (*(eptr+1) != '\0'))eptr++; - eptr++; - } - if (*eptr == '\0') eptr--; //because there's a ++ below - *start=eptr; - return(FALSE); - } - else if (*eptr != *pptr) return(FALSE); - break; - - case ' ': - case ' ': - case '\n': - case '\r': - if ((MatchType==TOK_SPACE) || (MatchType==TOK_CODE)) - { - while (isspace(*eptr)) eptr++; - eptr--; - MatchType=0; - } - else if (*eptr != *pptr) return(FALSE); - break; - - case '(': - case ')': - case '=': - case '!': - case '<': - case '>': - if (MatchType==TOK_CODE) MatchType=0; - else if (*eptr != *pptr) return(FALSE); - break; - - default: - if (MatchType != 0) return(FALSE); - if (*eptr != *pptr) return(FALSE); - break; -} - -pptr++; -eptr++; -} - -return(FALSE); -} - - - - - -/* -int GetTokenFindSeparator(const char *Pattern, const char *String, const char **SepStart, const char **SepEnd, int Flags) -{ -const char *start_ptr=NULL, *end_ptr=NULL, *ptr; -#ifdef __MMX__ -__m64 src, cmp1, cmp2; -#endif - - -start_ptr=String; - -while (*start_ptr != '\0') -{ - - if ((*start_ptr=='\\') && (! Flags & GETTOKEN_BACKSLASH)) - { - start_ptr++; - start_ptr++; - } - - ptr=Pattern; - while (ptr) - { - #ifdef __MMX__ - if (*ptr != '\\') - { - cmp1=_mm_set1_pi8(*ptr); - src=*(__m64 *) start_ptr; - cmp2=_mm_cmpeq_pi8(src,cmp1); - if ((uint64_t) cmp2==0) - { - cmp1=_mm_cmpeq_pi8(src,cmp2); - if ((uint64_t) cmp1 != 0) - { - while (*start_ptr !='\0') start_ptr++; - *SepStart=start_ptr; - return(FALSE); - } - start_ptr+=8; - continue; - } - } - #endif - - if (GetTokenSepMatch(ptr,&start_ptr, &end_ptr, Flags)) - { - *SepStart=start_ptr; - *SepEnd=end_ptr; - return(TRUE); - } - - if (Flags & GETTOKEN_MULTI_SEPARATORS) - { - ptr=strchr(ptr,'|'); - if (ptr) ptr++; - } - else ptr=NULL; - } - -if ((*start_ptr) !='\0') start_ptr++; -} - -//We found nothing, set sep start to equal end of string -*SepStart=start_ptr; - -return(FALSE); -} -*/ - -int GetTokenFindSeparator(const char *Pattern, const char *String, const char **SepStart, const char **SepEnd, int Flags) -{ -const char *start_ptr=NULL, *end_ptr=NULL, *ptr; -#ifdef __MMX__ -__m64 src, cmp1, cmp2; -#endif - - -ptr=Pattern; -while (ptr) -{ - start_ptr=String; - while (*start_ptr != '\0') - { - if ((*start_ptr=='\\') && (! (Flags & GETTOKEN_BACKSLASH))) - { - start_ptr++; - start_ptr++; - continue; - } - - #ifdef __MMX__ - if (*ptr != '\\') - { - cmp1=_mm_set1_pi8(*ptr); - src=*(__m64 *) start_ptr; - cmp2=_mm_cmpeq_pi8(src,cmp1); - if ((uint64_t) cmp2==0) - { - cmp1=_mm_cmpeq_pi8(src,cmp2); - if ((uint64_t) cmp1 != 0) - { - while (*start_ptr !='\0') start_ptr++; - *SepStart=start_ptr; - return(FALSE); - } - start_ptr+=8; - continue; - } - -/* - if (((uint64_t) cmp2 & 0xFFFFFFFF)==0) - { - cmp1=_mm_cmpeq_pi8(src,cmp2); - if (((uint64_t) cmp1 & 0xFFFFFFFF)==0) - { - while (*start_ptr !='\0') start_ptr++; - *SepStart=start_ptr; - return(FALSE); - } - start_ptr+=4; - continue; - } -*/ - - } - #endif - - if (GetTokenSepMatch(ptr,&start_ptr, &end_ptr, Flags)) - { - *SepStart=start_ptr; - *SepEnd=end_ptr; - return(TRUE); - } - if ((*start_ptr) !='\0') start_ptr++; - } - - if (Flags & GETTOKEN_MULTI_SEPARATORS) - { - ptr=strchr(ptr,'|'); - if (ptr) ptr++; - } - else ptr=NULL; -} - -//We found nothing, set sep start to equal end of string -*SepStart=start_ptr; - -return(FALSE); -} - - -char *GetToken(const char *SearchStr, const char *Separator, char **Token, int Flags) -{ -const char *SepStart=NULL, *SepEnd=NULL; -const char *sptr, *eptr; - - -/* this is a safety measure so that there is always something in Token*/ -if (Token) *Token=CopyStr(*Token,""); - -if ((! Token) || StrEnd(SearchStr)) -{ - #ifdef __MMX__ - if (! (Flags & GETTOKEN_NOEMMS)) _mm_empty(); - #endif - return(NULL); -} - -GetTokenFindSeparator(Separator, SearchStr, &SepStart, &SepEnd, Flags); - -sptr=SearchStr; - -if (Flags & GETTOKEN_INCLUDE_SEP) -{ - if (SepStart==SearchStr) eptr=SepEnd; - else - { - eptr=SepStart; - SepEnd=SepStart; - } -} -else if (Flags & GETTOKEN_APPEND_SEP) eptr=SepEnd; -else eptr=SepStart; - -if (Flags & GETTOKEN_STRIP_QUOTES) -{ - if ((*sptr=='"') || (*sptr=='\'')) - { - //is character before the sep a quote? If so, we copy one less char, and also start one character later - //else we copy the characters as well - eptr--; - if (*sptr==*eptr) sptr++; - else eptr++; - } -} - -*Token=CopyStrLen(*Token,sptr,eptr-sptr); - -if (Flags & GETTOKEN_STRIP_SPACE) -{ -StripTrailingWhitespace(*Token); -StripLeadingWhitespace(*Token); -} - -//return empty string, but not null -if ((! SepEnd) || (*SepEnd=='\0')) -{ - SepEnd=SearchStr+StrLen((char *) SearchStr); -} - -#ifdef __MMX__ -if (! (Flags & GETTOKEN_NOEMMS)) _mm_empty(); -#endif -return((char *) SepEnd); -} - - - - -char *GetNameValuePair(const char *Input, const char *PairDelim, const char *NameValueDelim, char **Name, char **Value) -{ -char *ptr, *ptr2; -char *Token=NULL; - -*Name=CopyStr(*Name,""); -*Value=CopyStr(*Value,""); -ptr=GetToken(Input,PairDelim,&Token,GETTOKEN_HONOR_QUOTES); -if (StrValid(Token)) -{ -ptr2=GetToken(Token,NameValueDelim,Name,GETTOKEN_HONOR_QUOTES); -ptr2=GetToken(ptr2,PairDelim,Value,GETTOKEN_HONOR_QUOTES); -StripQuotes(*Name); -StripQuotes(*Value); -} - -DestroyString(Token); -return(ptr); -} - diff --git a/libUseful-2.6/Tokenizer.h b/libUseful-2.6/Tokenizer.h deleted file mode 100755 index 32f13e5..0000000 --- a/libUseful-2.6/Tokenizer.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef LIBUSEFUL_TOKEN_H -#define LIBUSEFUL_TOKEN_H - -#include -#include - -#define GETTOKEN_MULTI_SEPARATORS 1 -#define GETTOKEN_MULTI_SEP 1 -#define GETTOKEN_HONOR_QUOTES 2 -#define GETTOKEN_STRIP_QUOTES 4 -#define GETTOKEN_QUOTES 6 -#define GETTOKEN_INCLUDE_SEPARATORS 8 -#define GETTOKEN_INCLUDE_SEP 8 -#define GETTOKEN_APPEND_SEPARATORS 16 -#define GETTOKEN_APPEND_SEP 16 -#define GETTOKEN_BACKSLASH 32 -#define GETTOKEN_STRIP_SPACE 64 -#define GETTOKEN_NOEMMS 4096 - -#ifdef __cplusplus -extern "C" { -#endif - -char *GetToken(const char *SearchStr, const char *Delim, char **Token, int Flags); -char *GetNameValuePair(const char *Input, const char *PairDelim, const char *NameValueDelim, char **Name, char **Value); - -#ifdef __cplusplus -} -#endif - - - - -#endif - diff --git a/libUseful-2.6/Vars.c b/libUseful-2.6/Vars.c deleted file mode 100755 index 1904302..0000000 --- a/libUseful-2.6/Vars.c +++ /dev/null @@ -1,379 +0,0 @@ -#include "includes.h" -#include "defines.h" -#include "list.h" -#include "Time.h" - -void SetDetailVar(ListNode *Vars, const char *Name, const char *Data, int ItemType, time_t Time) -{ -ListNode *Node; -char *Tempstr=NULL; - -if (! Vars) return; -Tempstr=CopyStr(Tempstr,Name); -//strlwr(Tempstr); -Node=ListFindNamedItem(Vars,Tempstr); -if (Node) Node->Item=(void *) CopyStr((char *) Node->Item,Data); -else Node=ListAddNamedItem(Vars,Tempstr,CopyStr(NULL,Data)); - -Node->ItemType=ItemType; -Node->Time=Time; - -DestroyString(Tempstr); -} - - -void SetTypedVar(ListNode *Vars, const char *Name, const char *Data, int ItemType) -{ -SetDetailVar(Vars, Name, Data, ItemType, 0); -} - - -void SetVar(ListNode *Vars, const char *Name, const char *Data) -{ -SetDetailVar(Vars, Name, Data,0, 0); -} - - -char *GetVar(ListNode *Vars, const char *Name) -{ -ListNode *Node; - -Node=ListFindNamedItem(Vars, Name); -if (Node) -{ - if ((Vars->Flags & LIST_FLAG_TIMEOUT) && (Node->Time > 0) && (Node->Time < GetTime(TIME_CACHED))) - { - DestroyString((char *) Node->Item); - return(NULL); - } - return((char *) Node->Item); -} -return(NULL); -} - - -void UnsetVar(ListNode *Vars,const char *Name) -{ -ListNode *Curr; -char *Str=NULL; -char *Tempstr=NULL; - -if (! Vars) return; -Tempstr=CopyStr(Tempstr,Name); -//strlwr(Tempstr); -Curr=ListFindNamedItem(Vars,Tempstr); -if (Curr) -{ - Str=ListDeleteNode(Curr); - DestroyString(Str); -} -DestroyString(Tempstr); -} - - -void ClearVars(ListNode *Vars) -{ -ListNode *Curr; -char *Str; - -if (! Vars) return; -Curr=ListGetNext(Vars); -while (Curr) -{ - Str=ListDeleteNode(Curr); - DestroyString(Str); -Curr=ListGetNext(Curr); -} - - -} - - - -void CopyVars(ListNode *Dest, ListNode *Source) -{ -ListNode *Curr; - -if (! Dest) return; -if (! Source) return; -Curr=ListGetNext(Source); -while (Curr) -{ -SetTypedVar(Dest,Curr->Tag,Curr->Item,Curr->ItemType); -Curr=ListGetNext(Curr); -} - -} - - - -char *ParseVar(char *Buff, const char **Line, ListNode *LocalVars, int Flags) -{ -char *VarName=NULL, *OutStr=NULL, *Tempstr=NULL; -const char *ptr, *vptr; - -OutStr=Buff; -ptr=*Line; - -switch (*ptr) -{ - //the var name is itself a var, dereference that first - case '$': - ptr++; - Tempstr=ParseVar(Tempstr,&ptr,LocalVars,Flags); - break; - - //Vars in brackets - case '(': - ptr++; - while ((*ptr !=')') && (*ptr !='\0')) - { - if (*ptr=='$') - { - ptr++; - Tempstr=ParseVar(Tempstr,&ptr,LocalVars,Flags); - VarName=CatStr(VarName,Tempstr); - } - else VarName=AddCharToStr(VarName,*ptr); - ptr++; - } - break; - - //vars seperated by spaces - default: - ptr++; - while ((! isspace(*ptr)) && (*ptr !='\0')) - { - if (*ptr=='$') - { - ptr++; - Tempstr=ParseVar(Tempstr,&ptr,LocalVars,Flags); - VarName=CatStr(VarName,Tempstr); - } - else VarName=AddCharToStr(VarName,*ptr); - ptr++; - } - break; -} - - -*Line=ptr; //very important! Otherwise the calling process will not - //know we have consumed some of the text! - - //Now lookup var/format/append to output - if (! (Flags & SUBS_CASE_VARNAMES)) strlwr(VarName); - - vptr=GetVar(LocalVars,VarName); - - if (Flags & SUBS_QUOTE_VARS) OutStr=CatStr(OutStr,"'"); - - if (Flags & SUBS_STRIP_VARS_WHITESPACE) - { - Tempstr=CopyStr(Tempstr,vptr); - StripTrailingWhitespace(Tempstr); - StripLeadingWhitespace(Tempstr); - OutStr=CatStr(OutStr,Tempstr); - } - else OutStr=CatStr(OutStr, vptr); - - if (Flags & SUBS_QUOTE_VARS) OutStr=CatStr(OutStr,"'"); - -DestroyString(VarName); -DestroyString(Tempstr); - -return(OutStr); -} - - -char SubstituteQuotedChar(char InChar) -{ - switch (InChar) - { - case '0': return(0); break; - case 'a': return(7); break; - case 'b': return(8); break; - case 'd': return(127); break; - case 'e': return(27); break; - case 'f': return(12); break; - case 't': return(' '); break; - case 'r': return('\r'); break; - case 'n': return('\n'); break; - } - -return(InChar); -} - - -char *SubstituteVarsInString(char *Buffer, const char *Fmt, ListNode *Vars, int Flags) -{ -char *ReturnStr=NULL, *VarName=NULL, *Tempstr=NULL; -const char *FmtPtr; -int len=0; - -ReturnStr=CopyStr(Buffer,""); - -if (! Fmt) return(ReturnStr); - - -FmtPtr=Fmt; -while (*FmtPtr !=0) -{ - switch (*FmtPtr) - { - case '\\': - if (Flags & SUBS_INTERPRET_BACKSLASH) - { - FmtPtr++; - ReturnStr=AddCharToBuffer(ReturnStr, len++, SubstituteQuotedChar(*FmtPtr)); - } - else - { - ReturnStr=AddCharToBuffer(ReturnStr,len++,*FmtPtr); - } - break; - - case '$': - FmtPtr++; - ReturnStr=ParseVar(ReturnStr, &FmtPtr, Vars, Flags); - len=StrLen(ReturnStr); - break; - - case '"': - if (Flags & SUBS_QUOTES) - { - FmtPtr++; - while (*FmtPtr && (*FmtPtr !='"')) - { - ReturnStr=AddCharToBuffer(ReturnStr,len++,*FmtPtr); - FmtPtr++; - } - } - else ReturnStr=AddCharToBuffer(ReturnStr,len++,*FmtPtr); - break; - - default: - ReturnStr=AddCharToBuffer(ReturnStr,len++,*FmtPtr); - break; - } - -FmtPtr++; -} - - -DestroyString(Tempstr); -DestroyString(VarName); -return(ReturnStr); -} - - - - - - -void ExtractVarsReadVar(const char **Fmt, const char **Msg, ListNode *Vars) -{ -const char *FmtPtr, *MsgPtr; -char *VarName=NULL; -int len=0; -ListNode *Node; - -FmtPtr=*Fmt; - - if (*FmtPtr=='(') FmtPtr++; - while (*FmtPtr != ')') - { - VarName=AddCharToBuffer(VarName,len,*FmtPtr); - len++; - FmtPtr++; - } - if (*FmtPtr==')') FmtPtr++; - -MsgPtr=*Msg; -while ((*MsgPtr !=0) && (*MsgPtr != *FmtPtr)) -{ - if (*MsgPtr=='"') - { - do - { - MsgPtr++; - } while ((*MsgPtr != '"') && (*MsgPtr != 0)); - } - MsgPtr++; -} - -Node=ListFindNamedItem(Vars,VarName); - -if (Node) Node->Item=(void *) CopyStrLen((char *) Node->Item, *Msg, MsgPtr-*Msg); -else Node=ListAddNamedItem(Vars,VarName,CopyStrLen(NULL, *Msg, MsgPtr-*Msg)); - -*Fmt=FmtPtr; -*Msg=MsgPtr; - -DestroyString(VarName); -} - -char *ExtractVarsGetLiteralString(char *Buffer, const char *InStr) -{ -char *RetStr; -const char *ptr; - -RetStr=Buffer; - -ptr=InStr; -while ((*ptr !=0) && (*ptr !='$') && (*ptr !='?') && (*ptr !='*')) ptr++; - -RetStr=CopyStrLen(Buffer,InStr,ptr-InStr); -return(RetStr); -} - -int ExtractVarsFromString(char *Data, const char *FormatStr, ListNode *Vars) -{ -const char *FmtPtr, *MsgPtr; -char *Token=NULL; -int Match=TRUE, len; - -FmtPtr=FormatStr; -MsgPtr=Data; - -while ( (*FmtPtr !=0) && (Match)) -{ - switch (*FmtPtr) - { - case '?': - FmtPtr++; - MsgPtr++; - break; - - case '*': - FmtPtr++; - Token=ExtractVarsGetLiteralString(Token,FmtPtr); - len=StrLen(Token); - while ( - (*MsgPtr !=0) && - (strncmp(MsgPtr,Token,len) !=0) - ) MsgPtr++; - - break; - - case '$': - FmtPtr++; - ExtractVarsReadVar(&FmtPtr, &MsgPtr, Vars); - break; - - default: - if (*FmtPtr != *MsgPtr) - { - Match=FALSE; - } - FmtPtr++; - MsgPtr++; - break; - } - -} -DestroyString(Token); - -return(Match); -} - - diff --git a/libUseful-2.6/Vars.h b/libUseful-2.6/Vars.h deleted file mode 100755 index 129e089..0000000 --- a/libUseful-2.6/Vars.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LIBUSEFUL_VARS_H -#define LIBUSEFUL_VARS_H - -#include "list.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void SetDetailVar(ListNode *Vars, const char *Name, const char *Data, int ItemType, time_t Time); -void SetTypedVar(ListNode *Vars, const char *Name, const char *Data, int Type); -void SetVar(ListNode *Vars, const char *Name, const char *Data); -char *GetVar(ListNode *Vars, const char *Name); -void UnsetVar(ListNode *Vars,const char *Name); -void ClearVars(ListNode *Vars); -void CopyVars(ListNode *Dest, ListNode *Source); -char *SubstituteVarsInString(char *Buffer, const char *Fmt, ListNode *Vars, int Flags); -int ExtractVarsFromString(char *Data, const char *FormatStr, ListNode *Vars); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libUseful-2.6/ansi.c b/libUseful-2.6/ansi.c deleted file mode 100755 index 68cc48e..0000000 --- a/libUseful-2.6/ansi.c +++ /dev/null @@ -1,106 +0,0 @@ -#include "ansi.h" - - -const char *ANSIColorStrings[]={"none","black","red","green","yellow","blue","magenta","cyan","white",NULL}; - - - -int ANSIParseColor(const char *Str) -{ -int val; - -val=MatchTokenFromList(Str, ANSIColorStrings, 0); -if (val==-1) val=ANSI_NONE; - -return(val); -} - -char *ANSICode(int Color, int BgColor, int Flags) -{ -static char *ANSI=NULL; -int FgVal, BgVal; - -if ((! Color) && (! Flags)) return(""); - -if ( (Color > 0) && (BgColor > 0) ) -{ - if (Color >= ANSI_DARKGREY) FgVal=90+Color - ANSI_DARKGREY; - else FgVal=30+Color-1; - - if (BgColor >= ANSI_DARKGREY) BgVal=100+BgColor - ANSI_DARKGREY; - else BgVal=40+BgColor-1; - - ANSI=FormatStr(ANSI,"\x1b[%d;%d",FgVal,BgVal); - if (Flags) ANSI=CatStr(ANSI,";"); -} -else if (Color > 0) -{ - if (Color >= ANSI_DARKGREY) FgVal=90+Color - ANSI_DARKGREY; - else FgVal=30+Color-1; - - ANSI=FormatStr(ANSI,"\x1b[%d",FgVal); - if (Flags) ANSI=CatStr(ANSI,";"); -} -else ANSI=CopyStr(ANSI,"\x1b["); - -if (Flags) -{ - if (Flags & ANSI_BOLD) ANSI=CatStr(ANSI,"01"); - if (Flags & ANSI_FAINT) ANSI=CatStr(ANSI,"02"); - if (Flags & ANSI_UNDER) ANSI=CatStr(ANSI,"04"); - if (Flags & ANSI_BLINK) ANSI=CatStr(ANSI,"05"); - if (Flags & ANSI_INVERSE) ANSI=CatStr(ANSI,"07"); -} -ANSI=CatStr(ANSI,"m"); - -return(ANSI); -} - - -char *TerminalReadText(char *RetStr, int Flags, STREAM *S) -{ -int inchar, len=0; -char outchar; - -inchar=STREAMReadChar(S); -while (inchar != EOF) -{ - if (Flags & TERM_SHOWTEXT) outchar=inchar & 0xFF; - if (Flags & TERM_SHOWSTARS) - { - if ((outchar & 0xFF) =='\n') outchar=inchar & 0xFF; - else if ((outchar & 0xFF) =='\b') outchar=inchar & 0xFF; - else outchar='*'; - } - - - if (Flags & TERM_SHOWTEXTSTARS) - { - switch (inchar) - { - - case '\n': - case '\r': - case 0x08: - break; - - default: - if (len > 0) STREAMWriteString("\x08*",S); - break; - } - - outchar=inchar & 0xFF; - } - - - STREAMWriteBytes(S, &outchar,1); - STREAMFlush(S); - if (inchar == '\n') break; - if (inchar == '\r') break; - - RetStr=AddCharToBuffer(RetStr,len++, inchar & 0xFF); - inchar=STREAMReadChar(S); -} - -return(RetStr); -} diff --git a/libUseful-2.6/ansi.h b/libUseful-2.6/ansi.h deleted file mode 100755 index 8ae688d..0000000 --- a/libUseful-2.6/ansi.h +++ /dev/null @@ -1,38 +0,0 @@ - -#ifndef LIBUSEFUL_ANSI_H -#define LIBUSEFUL_ANSI_H - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum {ANSI_NONE, ANSI_BLACK, ANSI_RED, ANSI_GREEN, ANSI_YELLOW, ANSI_BLUE, ANSI_MAGENTA, ANSI_CYAN, ANSI_WHITE, ANSI_RESET, ANSI_RESET2, ANSI_DARKGREY, ANSI_LIGHTRED, ANSI_LIGHTGREEN, ANSI_LIGHTYELLOW, ANSI_LIGHTBLUE, ANSI_LIGHTMAGENTA, ANSI_LIGHTCYAN, ANSI_LIGHTWHITE} T_ANSI_COLORS; - -#define TERM_SHOWTEXT 1 -#define TERM_SHOWSTARS 2 -#define TERM_SHOWTEXTSTARS 4 - -#define ANSI_HIDE 65536 -#define ANSI_BOLD 131072 -#define ANSI_FAINT 262144 -#define ANSI_UNDER 524288 -#define ANSI_BLINK 1048576 -#define ANSI_INVERSE 2097152 -#define ANSI_NORM "\x1b[0m" -#define ANSI_BACKSPACE 0x08 - - -char *ANSICode(int Color, int BgColor, int Flags); -int ANSIParseColor(const char *Str); -char *TerminalReadText(char *RetStr, int Flags, STREAM *S); - - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/base64.c b/libUseful-2.6/base64.c deleted file mode 100755 index 120d77b..0000000 --- a/libUseful-2.6/base64.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * base64.c -- base-64 conversion routines. - * - * For license terms, see the file COPYING in this directory. - * - * This base 64 encoding is defined in RFC2045 section 6.8, - * "Base64 Content-Transfer-Encoding", but lines must not be broken in the - * scheme used here. - */ -#include -#include "defines.h" - -#define BAD -1 -static const char base64val[] = { - BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, - BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, - BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD, 62, BAD,BAD,BAD, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,BAD,BAD, BAD,BAD,BAD,BAD, - BAD, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,BAD, BAD,BAD,BAD,BAD, - BAD, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,BAD, BAD,BAD,BAD,BAD -}; - -#define DECODE64(c) (isascii(c) ? base64val[c] : BAD) - - - -void Radix64frombits(unsigned char *out, const unsigned char *in, int inlen, const char *base64digits, char pad) -/* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ -{ - for (; inlen >= 3; inlen -= 3) - { - *out++ = base64digits[in[0] >> 2]; - *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; - *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; - *out++ = base64digits[in[2] & 0x3f]; - in += 3; - } - - if (inlen > 0) - { - unsigned char fragment; - - *out++ = base64digits[in[0] >> 2]; - fragment = (in[0] << 4) & 0x30; - if (inlen > 1) - fragment |= in[1] >> 4; - *out++ = base64digits[fragment]; - *out++ = (inlen < 2) ? pad : base64digits[(in[1] << 2) & 0x3c]; - *out++ = pad; - } - *out = '\0'; -} - - - -void to64frombits(char *out, const char *in, int inlen) -{ - Radix64frombits(out, in, inlen, BASE64_CHARS,'='); -} - - - - -int Radix64tobits(char *out, const char *in, const char *base64digits, char pad) -/* base 64 to raw bytes in quasi-big-endian order, returning count of bytes */ -{ - int len = 0; - register unsigned char digit1, digit2, digit3, digit4; - - if (in[0] == '+' && in[1] == ' ') - in += 2; - if (*in == '\r') - return(0); - - do { - digit1 = in[0]; - if (DECODE64(digit1) == BAD) - return(-1); - digit2 = in[1]; - if (DECODE64(digit2) == BAD) - return(-1); - digit3 = in[2]; - if (digit3 != pad && DECODE64(digit3) == BAD) - return(-1); - digit4 = in[3]; - if (digit4 != pad && DECODE64(digit4) == BAD) - return(-1); - in += 4; - *out++ = (DECODE64(digit1) << 2) | (DECODE64(digit2) >> 4); - ++len; - if (digit3 != pad) - { - *out++ = ((DECODE64(digit2) << 4) & 0xf0) | (DECODE64(digit3) >> 2); - ++len; - if (digit4 != pad) - { - *out++ = ((DECODE64(digit3) << 6) & 0xc0) | DECODE64(digit4); - ++len; - } - } - } while - (*in && *in != '\r' && digit4 != pad); - - return (len); -} - - - -int from64tobits(char *out, const char *in) -{ - return(Radix64tobits(out, in, BASE64_CHARS,'=')); -} - -/* base64.c ends here */ diff --git a/libUseful-2.6/base64.h b/libUseful-2.6/base64.h deleted file mode 100755 index 2721649..0000000 --- a/libUseful-2.6/base64.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef BASE_64_H -#define BASE_64_H - -#ifdef __cplusplus -extern "C" { -#endif - -void Radix64frombits(unsigned char *out, const unsigned char *in, int inlen, const char *base64digits, char pad); -int Radix64tobits(char *out, const char *in, const char *base64digits, char pad); - -void to64frombits(unsigned char *out, const unsigned char *in, int inlen); -int from64tobits(char *out, const char *in); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/buckets.c b/libUseful-2.6/buckets.c deleted file mode 100755 index 8635f2f..0000000 --- a/libUseful-2.6/buckets.c +++ /dev/null @@ -1,100 +0,0 @@ -#include "libUseful-2.0/libUseful.h" -#include - -#define FNV_INIT_VAL 2166136261 - -unsigned int fnv_data2bucket(unsigned char *key, int size, int NoOfItems) -{ - unsigned char *p, *end; - unsigned int h = FNV_INIT_VAL; - int i; - - end=key+size; - for (p=key; p < end ; p++ ) h = ( h * 16777619 ) ^ *p; - - return(h % NoOfItems); -} - -unsigned int fnv_string2bucket(unsigned char *key, int size, int NoOfItems) -{ - unsigned char *p; - unsigned int h = FNV_INIT_VAL; - int i; - - for (p=key; *p !='\0' ; p++ ) h = ( h * 16777619 ) ^ *p; - - return(h % NoOfItems); -} - - -unsigned int mmx_hash_bucket_data(unsigned char *key, int size, int NoOfItems) -{ - char *p, *end; - __m64 v1, v2, s; - int val; - - if (size < 8) return(fnv_data2bucket(key, size, NoOfItems)); - - p=key; - end=key+size; - _mm_empty(); // emms - v1=_mm_set1_pi32(FNV_INIT_VAL); - - while ((end-p) > 7) - { - v2=_mm_setr_pi32(*p,*(p+4)); - v1=_mm_add_pi16(v1, v2); - v1=_mm_slli_pi32(v1, 3); - p+=8; - } - - val=_mm_cvtsi64_si32(v1); - _mm_empty(); // emms - - if (val < 0) val=1-val; - val =val % NoOfItems; - return(val); -} - - - - - -main(int argc, char *argv[]) -{ -int val, len; -STREAM *S; -char *Tempstr=NULL; -clock_t start, mid, end; - -S=STREAMOpenFile(argv[1],SF_RDONLY); -start=clock(); -Tempstr=STREAMReadLine(Tempstr,S); -while (Tempstr) -{ - len=StrLen(Tempstr); - val=mmx_hash_bucket_data(Tempstr, len, 9999); - Tempstr=STREAMReadLine(Tempstr,S); -} -end=clock(); - -printf("MMX: %d\n",end-start,val,Tempstr); -STREAMSeek(S,0,SEEK_SET); - -start=clock(); -Tempstr=STREAMReadLine(Tempstr,S); -while (Tempstr) -{ - len=StrLen(Tempstr); - val=fnv_string2bucket(Tempstr,len, 9999); - Tempstr=STREAMReadLine(Tempstr,S); -} -end=clock(); -printf("FNV: %d\n",end-start,val,Tempstr); - - - - -STREAMClose(S); -} - diff --git a/libUseful-2.6/config.log b/libUseful-2.6/config.log deleted file mode 100755 index 7ba55f1..0000000 --- a/libUseful-2.6/config.log +++ /dev/null @@ -1,657 +0,0 @@ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by configure, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ ./configure --disable-option-checking --prefix=/usr/local --enable-ssl --cache-file=/dev/null --srcdir=. - -## --------- ## -## Platform. ## -## --------- ## - -hostname = lifebook -uname -m = i686 -uname -r = 4.7.3-p4-smp-hugemem -uname -s = Linux -uname -v = #1 SMP Mon Sep 12 21:20:39 BST 2016 - -/usr/bin/uname -p = unknown -/bin/uname -X = unknown - -/bin/arch = unknown -/usr/bin/arch -k = unknown -/usr/convex/getsysinfo = unknown -/usr/bin/hostinfo = unknown -/bin/machine = unknown -/usr/bin/oslevel = unknown -/bin/universe = unknown - -PATH: /usr/prebin -PATH: /usr/local/bin -PATH: /usr/bin -PATH: /usr/X11R7/bin -PATH: /bin -PATH: /usr/games/bin -PATH: /opt/wine-1.9.10/bin -PATH: /opt/git-2.8.3/bin -PATH: /opt/qemu-2.5.0/bin -PATH: /opt/Qt4/bin -PATH: /opt/SDL/bin -PATH: /opt/avr/bin -PATH: /opt/chkrootkit-0.50/bin -PATH: /opt/gdbm-1.11/bin -PATH: /opt/ghostscript-9.19/bin -PATH: /opt/gifprogs-5.1.2/bin -PATH: /opt/git-2.8.3/bin -PATH: /opt/jpegprogs-8c/bin -PATH: /opt/lxc-2.0.0/bin -PATH: /opt/mujs-b005928/bin -PATH: /opt/perl-5.22.2/bin -PATH: /opt/pngprogs-1.6.17/bin -PATH: /opt/poppler-0.43.0/bin -PATH: /opt/qemu-2.5.0/bin -PATH: /opt/tiffprogs-4.0.6/bin -PATH: /opt/wine-1.9.10/bin - - -## ----------- ## -## Core tests. ## -## ----------- ## - -configure:2148: checking for gcc -configure:2164: found /usr/bin/gcc -configure:2175: result: gcc -configure:2404: checking for C compiler version -configure:2413: gcc --version >&5 -gcc (GCC) 5.3.0 -Copyright (C) 2015 Free Software Foundation, Inc. -This is free software; see the source for copying conditions. There is NO -warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -configure:2424: $? = 0 -configure:2413: gcc -v >&5 -Using built-in specs. -COLLECT_GCC=gcc -COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i486-pc-linux-gnu/5.3.0/lto-wrapper -Target: i486-pc-linux-gnu -Configured with: ../gcc-5.3.0-src/configure --prefix=/usr --sysconfdir=/etc --includedir=/usr/include --localstatedir=/var --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,c++,go --host=i486-pc-linux-gnu --build=i486-pc-linux-gnu --target=i486-pc-linux-gnu --enable-bootstrap -Thread model: posix -gcc version 5.3.0 (GCC) -configure:2424: $? = 0 -configure:2413: gcc -V >&5 -gcc: error: unrecognized command line option '-V' -gcc: fatal error: no input files -compilation terminated. -configure:2424: $? = 1 -configure:2413: gcc -qversion >&5 -gcc: error: unrecognized command line option '-qversion' -gcc: fatal error: no input files -compilation terminated. -configure:2424: $? = 1 -configure:2444: checking whether the C compiler works -configure:2466: gcc conftest.c >&5 -configure:2470: $? = 0 -configure:2518: result: yes -configure:2521: checking for C compiler default output file name -configure:2523: result: a.out -configure:2529: checking for suffix of executables -configure:2536: gcc -o conftest conftest.c >&5 -configure:2540: $? = 0 -configure:2562: result: -configure:2584: checking whether we are cross compiling -configure:2592: gcc -o conftest conftest.c >&5 -configure:2596: $? = 0 -configure:2603: ./conftest -configure:2607: $? = 0 -configure:2622: result: no -configure:2627: checking for suffix of object files -configure:2649: gcc -c conftest.c >&5 -configure:2653: $? = 0 -configure:2674: result: o -configure:2678: checking whether we are using the GNU C compiler -configure:2697: gcc -c conftest.c >&5 -configure:2697: $? = 0 -configure:2706: result: yes -configure:2715: checking whether gcc accepts -g -configure:2735: gcc -c -g conftest.c >&5 -configure:2735: $? = 0 -configure:2776: result: yes -configure:2793: checking for gcc option to accept ISO C89 -configure:2856: gcc -c -g -O2 conftest.c >&5 -configure:2856: $? = 0 -configure:2869: result: none needed -configure:2895: checking whether make sets $(MAKE) -configure:2917: result: yes -configure:2932: checking how to run the C preprocessor -configure:2963: gcc -E conftest.c -configure:2963: $? = 0 -configure:2977: gcc -E conftest.c -conftest.c:9:28: fatal error: ac_nonexistent.h: No such file or directory -compilation terminated. -configure:2977: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| /* end confdefs.h. */ -| #include -configure:3002: result: gcc -E -configure:3022: gcc -E conftest.c -configure:3022: $? = 0 -configure:3036: gcc -E conftest.c -conftest.c:9:28: fatal error: ac_nonexistent.h: No such file or directory -compilation terminated. -configure:3036: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| /* end confdefs.h. */ -| #include -configure:3065: checking for grep that handles long lines and -e -configure:3123: result: /bin/grep -configure:3128: checking for egrep -configure:3190: result: /bin/grep -E -configure:3195: checking for ANSI C header files -configure:3215: gcc -c -g -O2 conftest.c >&5 -configure:3215: $? = 0 -configure:3288: gcc -o conftest -g -O2 conftest.c >&5 -configure:3288: $? = 0 -configure:3288: ./conftest -configure:3288: $? = 0 -configure:3299: result: yes -configure:3314: checking for special C compiler options needed for large files -configure:3359: result: no -configure:3365: checking for _FILE_OFFSET_BITS value needed for large files -configure:3390: gcc -c -g -O2 conftest.c >&5 -conftest.c:15:33: warning: left shift count >= width of type [-Wshift-count-overflow] - #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - ^ -conftest.c:16:23: note: in expansion of macro 'LARGE_OFF_T' - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - ^ -conftest.c:15:57: warning: left shift count >= width of type [-Wshift-count-overflow] - #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - ^ -conftest.c:16:23: note: in expansion of macro 'LARGE_OFF_T' - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - ^ -conftest.c:15:33: warning: left shift count >= width of type [-Wshift-count-overflow] - #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - ^ -conftest.c:17:13: note: in expansion of macro 'LARGE_OFF_T' - && LARGE_OFF_T % 2147483647 == 1) - ^ -conftest.c:15:57: warning: left shift count >= width of type [-Wshift-count-overflow] - #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - ^ -conftest.c:17:13: note: in expansion of macro 'LARGE_OFF_T' - && LARGE_OFF_T % 2147483647 == 1) - ^ -conftest.c:16:7: error: variably modified 'off_t_is_large' at file scope - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - ^ -configure:3390: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| #define STDC_HEADERS 1 -| /* end confdefs.h. */ -| #include -| /* Check that off_t can represent 2**63 - 1 correctly. -| We can't simply define LARGE_OFF_T to be 9223372036854775807, -| since some C++ compilers masquerading as C compilers -| incorrectly reject 9223372036854775807. */ -| #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) -| int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 -| && LARGE_OFF_T % 2147483647 == 1) -| ? 1 : -1]; -| int -| main () -| { -| -| ; -| return 0; -| } -configure:3414: gcc -c -g -O2 conftest.c >&5 -configure:3414: $? = 0 -configure:3422: result: 64 -configure:3517: checking for ptsname_r in -lc -configure:3542: gcc -o conftest -g -O2 conftest.c -lc >&5 -configure:3542: $? = 0 -configure:3551: result: yes -configure:3583: checking for sys/types.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3583: checking for sys/stat.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3583: checking for stdlib.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3583: checking for string.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3583: checking for memory.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3583: checking for strings.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3583: checking for inttypes.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3583: checking for stdint.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3583: checking for unistd.h -configure:3583: gcc -c -g -O2 conftest.c >&5 -configure:3583: $? = 0 -configure:3583: result: yes -configure:3595: checking sys/sendfile.h usability -configure:3595: gcc -c -g -O2 conftest.c >&5 -configure:3595: $? = 0 -configure:3595: result: yes -configure:3595: checking sys/sendfile.h presence -configure:3595: gcc -E conftest.c -configure:3595: $? = 0 -configure:3595: result: yes -configure:3595: checking for sys/sendfile.h -configure:3595: result: yes -configure:3634: checking for SSL_library_init in -lssl -configure:3659: gcc -o conftest -g -O2 conftest.c -lssl -lc >&5 -configure:3659: $? = 0 -configure:3668: result: yes -configure:3681: checking for EVP_CIPHER_CTX_init in -lcrypto -configure:3706: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3706: $? = 0 -configure:3715: result: yes -configure:3731: checking for OpenSSL_add_all_algorithms -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -/tmp/cciSJXvw.o: In function `main': -/home/meta/Movgrab/libUseful-2.6/conftest.c:59: undefined reference to `OpenSSL_add_all_algorithms' -collect2: error: ld returned 1 exit status -configure:3731: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| #define STDC_HEADERS 1 -| #define _FILE_OFFSET_BITS 64 -| #define HAVE_LIBC 1 -| #define HAVE_PTSNAME_R 1 -| #define HAVE_SYS_TYPES_H 1 -| #define HAVE_SYS_STAT_H 1 -| #define HAVE_STDLIB_H 1 -| #define HAVE_STRING_H 1 -| #define HAVE_MEMORY_H 1 -| #define HAVE_STRINGS_H 1 -| #define HAVE_INTTYPES_H 1 -| #define HAVE_STDINT_H 1 -| #define HAVE_UNISTD_H 1 -| #define USE_SENDFILE 1 -| #define HAVE_LIBSSL 1 -| #define HAVE_LIBCRYPTO 1 -| /* end confdefs.h. */ -| /* Define OpenSSL_add_all_algorithms to an innocuous variant, in case declares OpenSSL_add_all_algorithms. -| For example, HP-UX 11i declares gettimeofday. */ -| #define OpenSSL_add_all_algorithms innocuous_OpenSSL_add_all_algorithms -| -| /* System header to define __stub macros and hopefully few prototypes, -| which can conflict with char OpenSSL_add_all_algorithms (); below. -| Prefer to if __STDC__ is defined, since -| exists even on freestanding compilers. */ -| -| #ifdef __STDC__ -| # include -| #else -| # include -| #endif -| -| #undef OpenSSL_add_all_algorithms -| -| /* Override any GCC internal prototype to avoid an error. -| Use char because int might match the return type of a GCC -| builtin and then its argument prototype would still apply. */ -| #ifdef __cplusplus -| extern "C" -| #endif -| char OpenSSL_add_all_algorithms (); -| /* The GNU C library defines this for functions which it implements -| to always fail with ENOSYS. Some functions are actually named -| something starting with __ and the normal name is an alias. */ -| #if defined __stub_OpenSSL_add_all_algorithms || defined __stub___OpenSSL_add_all_algorithms -| choke me -| #endif -| -| int -| main () -| { -| return OpenSSL_add_all_algorithms (); -| ; -| return 0; -| } -configure:3731: result: no -configure:3731: checking for EVP_bf_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3731: checking for EVP_rc2_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3731: checking for EVP_rc4 -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3731: checking for EVP_rc5_32_12_16_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -/tmp/cccCPqnr.o: In function `main': -/home/meta/Movgrab/libUseful-2.6/conftest.c:62: undefined reference to `EVP_rc5_32_12_16_cbc' -collect2: error: ld returned 1 exit status -configure:3731: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| #define STDC_HEADERS 1 -| #define _FILE_OFFSET_BITS 64 -| #define HAVE_LIBC 1 -| #define HAVE_PTSNAME_R 1 -| #define HAVE_SYS_TYPES_H 1 -| #define HAVE_SYS_STAT_H 1 -| #define HAVE_STDLIB_H 1 -| #define HAVE_STRING_H 1 -| #define HAVE_MEMORY_H 1 -| #define HAVE_STRINGS_H 1 -| #define HAVE_INTTYPES_H 1 -| #define HAVE_STDINT_H 1 -| #define HAVE_UNISTD_H 1 -| #define USE_SENDFILE 1 -| #define HAVE_LIBSSL 1 -| #define HAVE_LIBCRYPTO 1 -| #define HAVE_EVP_BF_CBC 1 -| #define HAVE_EVP_RC2_CBC 1 -| #define HAVE_EVP_RC4 1 -| /* end confdefs.h. */ -| /* Define EVP_rc5_32_12_16_cbc to an innocuous variant, in case declares EVP_rc5_32_12_16_cbc. -| For example, HP-UX 11i declares gettimeofday. */ -| #define EVP_rc5_32_12_16_cbc innocuous_EVP_rc5_32_12_16_cbc -| -| /* System header to define __stub macros and hopefully few prototypes, -| which can conflict with char EVP_rc5_32_12_16_cbc (); below. -| Prefer to if __STDC__ is defined, since -| exists even on freestanding compilers. */ -| -| #ifdef __STDC__ -| # include -| #else -| # include -| #endif -| -| #undef EVP_rc5_32_12_16_cbc -| -| /* Override any GCC internal prototype to avoid an error. -| Use char because int might match the return type of a GCC -| builtin and then its argument prototype would still apply. */ -| #ifdef __cplusplus -| extern "C" -| #endif -| char EVP_rc5_32_12_16_cbc (); -| /* The GNU C library defines this for functions which it implements -| to always fail with ENOSYS. Some functions are actually named -| something starting with __ and the normal name is an alias. */ -| #if defined __stub_EVP_rc5_32_12_16_cbc || defined __stub___EVP_rc5_32_12_16_cbc -| choke me -| #endif -| -| int -| main () -| { -| return EVP_rc5_32_12_16_cbc (); -| ; -| return 0; -| } -configure:3731: result: no -configure:3731: checking for EVP_des_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3731: checking for EVP_desx_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3731: checking for EVP_cast5_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3731: checking for EVP_idea_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3731: checking for EVP_aes_128_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3731: checking for EVP_aes_256_cbc -configure:3731: gcc -o conftest -g -O2 conftest.c -lcrypto -lssl -lc >&5 -configure:3731: $? = 0 -configure:3731: result: yes -configure:3741: checking that OpenSSL Library is at least version 0.9.7 -configure:3755: result: yes -configure:3842: checking sys/soundcard.h usability -configure:3842: gcc -c -g -O2 conftest.c >&5 -configure:3842: $? = 0 -configure:3842: result: yes -configure:3842: checking sys/soundcard.h presence -configure:3842: gcc -E conftest.c -configure:3842: $? = 0 -configure:3842: result: yes -configure:3842: checking for sys/soundcard.h -configure:3842: result: yes -configure:4058: creating ./config.status - -## ---------------------- ## -## Running config.status. ## -## ---------------------- ## - -This file was extended by config.status, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = - CONFIG_HEADERS = - CONFIG_LINKS = - CONFIG_COMMANDS = - $ ./config.status - -on lifebook - -config.status:727: creating Makefile - -## ---------------- ## -## Cache variables. ## -## ---------------- ## - -ac_cv_c_compiler_gnu=yes -ac_cv_env_CC_set= -ac_cv_env_CC_value= -ac_cv_env_CFLAGS_set= -ac_cv_env_CFLAGS_value= -ac_cv_env_CPPFLAGS_set= -ac_cv_env_CPPFLAGS_value= -ac_cv_env_CPP_set= -ac_cv_env_CPP_value= -ac_cv_env_LDFLAGS_set= -ac_cv_env_LDFLAGS_value= -ac_cv_env_LIBS_set= -ac_cv_env_LIBS_value= -ac_cv_env_build_alias_set= -ac_cv_env_build_alias_value= -ac_cv_env_host_alias_set= -ac_cv_env_host_alias_value= -ac_cv_env_target_alias_set= -ac_cv_env_target_alias_value= -ac_cv_func_EVP_aes_128_cbc=yes -ac_cv_func_EVP_aes_256_cbc=yes -ac_cv_func_EVP_bf_cbc=yes -ac_cv_func_EVP_cast5_cbc=yes -ac_cv_func_EVP_des_cbc=yes -ac_cv_func_EVP_desx_cbc=yes -ac_cv_func_EVP_idea_cbc=yes -ac_cv_func_EVP_rc2_cbc=yes -ac_cv_func_EVP_rc4=yes -ac_cv_func_EVP_rc5_32_12_16_cbc=no -ac_cv_func_OpenSSL_add_all_algorithms=no -ac_cv_header_inttypes_h=yes -ac_cv_header_memory_h=yes -ac_cv_header_stdc=yes -ac_cv_header_stdint_h=yes -ac_cv_header_stdlib_h=yes -ac_cv_header_string_h=yes -ac_cv_header_strings_h=yes -ac_cv_header_sys_sendfile_h=yes -ac_cv_header_sys_soundcard_h=yes -ac_cv_header_sys_stat_h=yes -ac_cv_header_sys_types_h=yes -ac_cv_header_unistd_h=yes -ac_cv_lib_c_ptsname_r=yes -ac_cv_lib_crypto_EVP_CIPHER_CTX_init=yes -ac_cv_lib_ssl_SSL_library_init=yes -ac_cv_objext=o -ac_cv_path_EGREP='/bin/grep -E' -ac_cv_path_GREP=/bin/grep -ac_cv_prog_CPP='gcc -E' -ac_cv_prog_ac_ct_CC=gcc -ac_cv_prog_cc_c89= -ac_cv_prog_cc_g=yes -ac_cv_prog_make_make_set=yes -ac_cv_sys_file_offset_bits=64 -ac_cv_sys_largefile_CC=no - -## ----------------- ## -## Output variables. ## -## ----------------- ## - -CC='gcc' -CFLAGS='-g -O2' -CPP='gcc -E' -CPPFLAGS='' -DEFS='-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBC=1 -DHAVE_PTSNAME_R=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 -DUSE_SENDFILE=1 -DHAVE_LIBSSL=1 -DHAVE_LIBCRYPTO=1 -DHAVE_EVP_BF_CBC=1 -DHAVE_EVP_RC2_CBC=1 -DHAVE_EVP_RC4=1 -DHAVE_EVP_DES_CBC=1 -DHAVE_EVP_DESX_CBC=1 -DHAVE_EVP_CAST5_CBC=1 -DHAVE_EVP_IDEA_CBC=1 -DHAVE_EVP_AES_128_CBC=1 -DHAVE_EVP_AES_256_CBC=1 -DUSE_OPENSSL_ADD_ALL_ALGORITHMS=1 -DHAVE_OSS=1' -ECHO_C='' -ECHO_N='-n' -ECHO_T='' -EGREP='/bin/grep -E' -EXEEXT='' -GREP='/bin/grep' -LDFLAGS='' -LIBOBJS='' -LIBS='-lcrypto -lssl -lc ' -LTLIBOBJS='' -OBJEXT='o' -PACKAGE_BUGREPORT='' -PACKAGE_NAME='' -PACKAGE_STRING='' -PACKAGE_TARNAME='' -PACKAGE_URL='' -PACKAGE_VERSION='' -PATH_SEPARATOR=':' -SET_MAKE='' -SHELL='/bin/sh' -VERSION='0.0.1' -ac_ct_CC='gcc' -bindir='${exec_prefix}/bin' -build_alias='' -datadir='${datarootdir}' -datarootdir='${prefix}/share' -docdir='${datarootdir}/doc/${PACKAGE}' -dvidir='${docdir}' -exec_prefix='${prefix}' -host_alias='' -htmldir='${docdir}' -includedir='${prefix}/include' -infodir='${datarootdir}/info' -libdir='${exec_prefix}/lib' -libexecdir='${exec_prefix}/libexec' -localedir='${datarootdir}/locale' -localstatedir='${prefix}/var' -mandir='${datarootdir}/man' -oldincludedir='/usr/include' -pdfdir='${docdir}' -prefix='/usr/local' -program_transform_name='s,x,x,' -psdir='${docdir}' -sbindir='${exec_prefix}/sbin' -sharedstatedir='${prefix}/com' -sysconfdir='${prefix}/etc' -target_alias='' - -## ----------- ## -## confdefs.h. ## -## ----------- ## - -/* confdefs.h */ -#define PACKAGE_NAME "" -#define PACKAGE_TARNAME "" -#define PACKAGE_VERSION "" -#define PACKAGE_STRING "" -#define PACKAGE_BUGREPORT "" -#define PACKAGE_URL "" -#define STDC_HEADERS 1 -#define _FILE_OFFSET_BITS 64 -#define HAVE_LIBC 1 -#define HAVE_PTSNAME_R 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_UNISTD_H 1 -#define USE_SENDFILE 1 -#define HAVE_LIBSSL 1 -#define HAVE_LIBCRYPTO 1 -#define HAVE_EVP_BF_CBC 1 -#define HAVE_EVP_RC2_CBC 1 -#define HAVE_EVP_RC4 1 -#define HAVE_EVP_DES_CBC 1 -#define HAVE_EVP_DESX_CBC 1 -#define HAVE_EVP_CAST5_CBC 1 -#define HAVE_EVP_IDEA_CBC 1 -#define HAVE_EVP_AES_128_CBC 1 -#define HAVE_EVP_AES_256_CBC 1 -#define USE_OPENSSL_ADD_ALL_ALGORITHMS 1 -#define HAVE_OSS 1 - -configure: exit 0 diff --git a/libUseful-2.6/config.status b/libUseful-2.6/config.status deleted file mode 100755 index c99a527..0000000 --- a/libUseful-2.6/config.status +++ /dev/null @@ -1,894 +0,0 @@ -#! /bin/sh -# Generated by configure. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by $as_me, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -# Files that config.status was made for. -config_files=" Makefile" - -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Report bugs to the package provider." - -ac_cs_config="'--disable-option-checking' '--prefix=/usr/local' '--enable-ssl' '--cache-file=/dev/null' '--srcdir=.'" -ac_cs_version="\ -config.status -configured by ./configure, generated by GNU Autoconf 2.69, - with options \"$ac_cs_config\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='/home/meta/Movgrab/libUseful-2.6' -srcdir='.' -test -n "$AWK" || AWK=awk -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -if $ac_cs_recheck; then - set X /bin/sh './configure' '--disable-option-checking' '--prefix=/usr/local' '--enable-ssl' '--cache-file=/dev/null' '--srcdir=.' $ac_configure_extra_args --no-create --no-recursion - shift - $as_echo "running CONFIG_SHELL=/bin/sh $*" >&6 - CONFIG_SHELL='/bin/sh' - export CONFIG_SHELL - exec "$@" -fi - -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -cat >>"$ac_tmp/subs1.awk" <<\_ACAWK && -S["LTLIBOBJS"]="" -S["LIBOBJS"]="" -S["EGREP"]="/bin/grep -E" -S["GREP"]="/bin/grep" -S["CPP"]="gcc -E" -S["SET_MAKE"]="" -S["OBJEXT"]="o" -S["EXEEXT"]="" -S["ac_ct_CC"]="gcc" -S["CPPFLAGS"]="" -S["LDFLAGS"]="" -S["CFLAGS"]="-g -O2" -S["CC"]="gcc" -S["VERSION"]="0.0.1" -S["target_alias"]="" -S["host_alias"]="" -S["build_alias"]="" -S["LIBS"]="-lcrypto -lssl -lc " -S["ECHO_T"]="" -S["ECHO_N"]="-n" -S["ECHO_C"]="" -S["DEFS"]="-DPACKAGE_NAME=\\\"\\\" -DPACKAGE_TARNAME=\\\"\\\" -DPACKAGE_VERSION=\\\"\\\" -DPACKAGE_STRING=\\\"\\\" -DPACKAGE_BUGREPORT=\\\"\\\" -DPACKAGE_URL=\\\"\\\" -DSTDC_HEADERS=1"\ -" -D_FILE_OFFSET_BITS=64 -DHAVE_LIBC=1 -DHAVE_PTSNAME_R=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 -DUSE_SENDFILE=1 -DHAVE_LIBSSL=1 -DHAVE_LIBCRYPTO=1 -DHAVE_EVP_BF_CBC"\ -"=1 -DHAVE_EVP_RC2_CBC=1 -DHAVE_EVP_RC4=1 -DHAVE_EVP_DES_CBC=1 -DHAVE_EVP_DESX_CBC=1 -DHAVE_EVP_CAST5_CBC=1 -DHAVE_EVP_IDEA_CBC=1 -DHAVE_EVP_AES_128_"\ -"CBC=1 -DHAVE_EVP_AES_256_CBC=1 -DUSE_OPENSSL_ADD_ALL_ALGORITHMS=1 -DHAVE_OSS=1" -S["mandir"]="${datarootdir}/man" -S["localedir"]="${datarootdir}/locale" -S["libdir"]="${exec_prefix}/lib" -S["psdir"]="${docdir}" -S["pdfdir"]="${docdir}" -S["dvidir"]="${docdir}" -S["htmldir"]="${docdir}" -S["infodir"]="${datarootdir}/info" -S["docdir"]="${datarootdir}/doc/${PACKAGE}" -S["oldincludedir"]="/usr/include" -S["includedir"]="${prefix}/include" -S["localstatedir"]="${prefix}/var" -S["sharedstatedir"]="${prefix}/com" -S["sysconfdir"]="${prefix}/etc" -S["datadir"]="${datarootdir}" -S["datarootdir"]="${prefix}/share" -S["libexecdir"]="${exec_prefix}/libexec" -S["sbindir"]="${exec_prefix}/sbin" -S["bindir"]="${exec_prefix}/bin" -S["program_transform_name"]="s,x,x," -S["prefix"]="/usr/local" -S["exec_prefix"]="${prefix}" -S["PACKAGE_URL"]="" -S["PACKAGE_BUGREPORT"]="" -S["PACKAGE_STRING"]="" -S["PACKAGE_VERSION"]="" -S["PACKAGE_TARNAME"]="" -S["PACKAGE_NAME"]="" -S["PATH_SEPARATOR"]=":" -S["SHELL"]="/bin/sh" -_ACAWK -cat >>"$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -fi # test -n "$CONFIG_FILES" - - -eval set X " :F $CONFIG_FILES " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} - ac_datarootdir_hack=' - s&@datadir@&${datarootdir}&g - s&@docdir@&${datarootdir}/doc/${PACKAGE}&g - s&@infodir@&${datarootdir}/info&g - s&@localedir@&${datarootdir}/locale&g - s&@mandir@&${datarootdir}/man&g - s&\${datarootdir}&${prefix}/share&g' ;; -esac -ac_sed_extra="/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -} - -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - - - - esac - -done # for ac_tag - - -as_fn_exit 0 diff --git a/libUseful-2.6/configure b/libUseful-2.6/configure deleted file mode 100755 index 06db83d..0000000 --- a/libUseful-2.6/configure +++ /dev/null @@ -1,5102 +0,0 @@ -#! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69. -# -# -# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -as_fn_exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : - -else - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null; then : - as_have_required=yes -else - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : - -else - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir/$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : - CONFIG_SHELL=$as_shell as_have_required=yes - if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : - break 2 -fi -fi - done;; - esac - as_found=false -done -$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi; } -IFS=$as_save_IFS - - - if test "x$CONFIG_SHELL" != x; then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno; then : - $as_echo "$0: This script requires a shell more modern than all" - $as_echo "$0: the shells that I found on your system." - if test x${ZSH_VERSION+set} = xset ; then - $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" - $as_echo "$0: be upgraded to zsh 4.3.4 or later." - else - $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME= -PACKAGE_TARNAME= -PACKAGE_VERSION= -PACKAGE_STRING= -PACKAGE_BUGREPORT= -PACKAGE_URL= - -ac_unique_file="defines.h" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined STDC_HEADERS && defined HAVE_MEMORY_H -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_subst_vars='LTLIBOBJS -LIBOBJS -EGREP -GREP -CPP -SET_MAKE -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -VERSION -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_largefile -enable_sendfile -enable_ip6 -enable_ssl -enable_zlib -enable_oss -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: $ac_useropt" - ac_useropt_orig=$ac_useropt - ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF -_ACEOF -fi - -if test -n "$ac_init_help"; then - - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-largefile omit support for large files - --enable-sendfile enable sendfile support - --enable-ip6 enable IPv6 support - --enable-ssl use Secure Sockets Layer - --enable-zlib use ZLib Compression - --enable-oss use Open Sound System - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CPP C preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to the package provider. -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for guested configure. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -configure -generated by GNU Autoconf 2.69 - -Copyright (C) 2012 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_c_try_cpp LINENO -# ---------------------- -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if eval \${$3+:} false; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_mongrel - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - -# ac_fn_c_check_func LINENO FUNC VAR -# ---------------------------------- -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_c_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main () -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_func -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by $as_me, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ $0 $@ - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Save into config.log some information that might help in debugging. - { - echo - - $as_echo "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - $as_echo "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - $as_echo "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - $as_echo "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - $as_echo "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - $as_echo "$as_me: caught signal $ac_signal" - $as_echo "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -$as_echo "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_NAME "$PACKAGE_NAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_TARNAME "$PACKAGE_TARNAME" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_VERSION "$PACKAGE_VERSION" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_STRING "$PACKAGE_STRING" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" -_ACEOF - -cat >>confdefs.h <<_ACEOF -#define PACKAGE_URL "$PACKAGE_URL" -_ACEOF - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -ac_site_file1=NONE -ac_site_file2=NONE -if test -n "$CONFIG_SITE"; then - # We do not want a PATH search for config.site. - case $CONFIG_SITE in #(( - -*) ac_site_file1=./$CONFIG_SITE;; - */*) ac_site_file1=$CONFIG_SITE;; - *) ac_site_file1=./$CONFIG_SITE;; - esac -elif test "x$prefix" != xNONE; then - ac_site_file1=$prefix/share/config.site - ac_site_file2=$prefix/etc/config.site -else - ac_site_file1=$ac_default_prefix/share/config.site - ac_site_file2=$ac_default_prefix/etc/config.site -fi -for ac_site_file in "$ac_site_file1" "$ac_site_file2" -do - test "x$ac_site_file" = xNONE && continue - if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -$as_echo "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -$as_echo "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -$as_echo "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -VERSION="0.0.1" - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -$as_echo "$CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -$as_echo "$ac_ct_CC" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi - - -test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else - ac_file='' -fi -if test -z "$ac_file"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -$as_echo_n "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -$as_echo "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -$as_echo_n "checking for suffix of object files... " >&6; } -if ${ac_cv_objext+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -$as_echo "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 -$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if ${ac_cv_c_compiler_gnu+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_compiler_gnu=yes -else - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -$as_echo "$ac_cv_c_compiler_gnu" >&6; } -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+set} -ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -$as_echo_n "checking whether $CC accepts -g... " >&6; } -if ${ac_cv_prog_cc_g+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -else - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - -else - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -$as_echo "$ac_cv_prog_cc_g" >&6; } -if test "$ac_test_CFLAGS" = set; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 -$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if ${ac_cv_prog_cc_c89+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ -struct buf { int x; }; -FILE * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not '\xHH' hex character constants. - These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std is added to get - proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an - array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std. */ -int osf4_cc_array ['\x00' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) 'x' -int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); -int argc; -char **argv; -int -main () -{ -return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; - ; - return 0; -} -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ - -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC - -fi -# AC_CACHE_VAL -case "x$ac_cv_prog_cc_c89" in - x) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -$as_echo "none needed" >&6; } ;; - xno) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -$as_echo "unsupported" >&6; } ;; - *) - CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; -esac -if test "x$ac_cv_prog_cc_c89" != xno; then : - -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } -set x ${MAKE-make} -ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat >conftest.make <<\_ACEOF -SHELL = /bin/sh -all: - @echo '@@@%%%=$(MAKE)=@@@%%%' -_ACEOF -# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. -case `${MAKE-make} -f conftest.make 2>/dev/null` in - *@@@%%%=?*=@@@%%%*) - eval ac_cv_prog_make_${ac_make}_set=yes;; - *) - eval ac_cv_prog_make_${ac_make}_set=no;; -esac -rm -f conftest.make -fi -if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SET_MAKE= -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - SET_MAKE="MAKE=${MAKE-make}" -fi - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# Check whether --enable-largefile was given. -if test "${enable_largefile+set}" = set; then : - enableval=$enable_largefile; -fi - -if test "$enable_largefile" != no; then - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 -$as_echo_n "checking for special C compiler options needed for large files... " >&6; } -if ${ac_cv_sys_largefile_CC+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_sys_largefile_CC=no - if test "$GCC" != yes; then - ac_save_CC=$CC - while :; do - # IRIX 6.2 and later do not support large files by default, - # so use the C compiler's -n32 option if that helps. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF - if ac_fn_c_try_compile "$LINENO"; then : - break -fi -rm -f core conftest.err conftest.$ac_objext - CC="$CC -n32" - if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_sys_largefile_CC=' -n32'; break -fi -rm -f core conftest.err conftest.$ac_objext - break - done - CC=$ac_save_CC - rm -f conftest.$ac_ext - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 -$as_echo "$ac_cv_sys_largefile_CC" >&6; } - if test "$ac_cv_sys_largefile_CC" != no; then - CC=$CC$ac_cv_sys_largefile_CC - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 -$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } -if ${ac_cv_sys_file_offset_bits+:} false; then : - $as_echo_n "(cached) " >&6 -else - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_sys_file_offset_bits=no; break -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define _FILE_OFFSET_BITS 64 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_sys_file_offset_bits=64; break -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cv_sys_file_offset_bits=unknown - break -done -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 -$as_echo "$ac_cv_sys_file_offset_bits" >&6; } -case $ac_cv_sys_file_offset_bits in #( - no | unknown) ;; - *) -cat >>confdefs.h <<_ACEOF -#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits -_ACEOF -;; -esac -rm -rf conftest* - if test $ac_cv_sys_file_offset_bits = unknown; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 -$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } -if ${ac_cv_sys_large_files+:} false; then : - $as_echo_n "(cached) " >&6 -else - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_sys_large_files=no; break -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#define _LARGE_FILES 1 -#include - /* Check that off_t can represent 2**63 - 1 correctly. - We can't simply define LARGE_OFF_T to be 9223372036854775807, - since some C++ compilers masquerading as C compilers - incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) - int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 - && LARGE_OFF_T % 2147483647 == 1) - ? 1 : -1]; -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_sys_large_files=1; break -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ac_cv_sys_large_files=unknown - break -done -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 -$as_echo "$ac_cv_sys_large_files" >&6; } -case $ac_cv_sys_large_files in #( - no | unknown) ;; - *) -cat >>confdefs.h <<_ACEOF -#define _LARGE_FILES $ac_cv_sys_large_files -_ACEOF -;; -esac -rm -rf conftest* - fi - - -fi - - -cf_have_libssl=no -cf_have_libcrypto=no -cf_have_libz=yes -cf_have_oss=no -cf_have_libesd=no -cf_have_sendfile=no -cf_have_ptsname_r=no - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ptsname_r in -lc" >&5 -$as_echo_n "checking for ptsname_r in -lc... " >&6; } -if ${ac_cv_lib_c_ptsname_r+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lc $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char ptsname_r (); -int -main () -{ -return ptsname_r (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_c_ptsname_r=yes -else - ac_cv_lib_c_ptsname_r=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_ptsname_r" >&5 -$as_echo "$ac_cv_lib_c_ptsname_r" >&6; } -if test "x$ac_cv_lib_c_ptsname_r" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBC 1 -_ACEOF - - LIBS="-lc $LIBS" - -fi - -cf_have_ptsname_r=$ac_cv_lib_c_ptsname_r -if test "$cf_have_ptsname_r" -then -$as_echo "#define HAVE_PTSNAME_R 1" >>confdefs.h - -fi - - -# Check whether --enable-sendfile was given. -if test "${enable_sendfile+set}" = set; then : - enableval=$enable_sendfile; cf_use_sendfile=$enableval -fi - - -if test "$cf_use_sendfile" != "no" -then -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -ac_fn_c_check_header_mongrel "$LINENO" "sys/sendfile.h" "ac_cv_header_sys_sendfile_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_sendfile_h" = xyes; then : - cf_have_sendfile=yes -else - cf_have_sendfile=no -fi - - -fi - -if test "$cf_have_sendfile" = "yes" -then -$as_echo "#define USE_SENDFILE 1" >>confdefs.h - -fi - - - -# Check whether --enable-ip6 was given. -if test "${enable_ip6+set}" = set; then : - enableval=$enable_ip6; cf_use_ip6=$enableval -fi - - -if test "$cf_use_ip6" = "yes" -then -$as_echo "#define USE_INET6 1" >>confdefs.h - -fi - - -# Check whether --enable-ssl was given. -if test "${enable_ssl+set}" = set; then : - enableval=$enable_ssl; cf_use_ssl=$enableval -fi - - -if test "$cf_use_ssl" = "yes" -then -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5 -$as_echo_n "checking for SSL_library_init in -lssl... " >&6; } -if ${ac_cv_lib_ssl_SSL_library_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lssl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char SSL_library_init (); -int -main () -{ -return SSL_library_init (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ssl_SSL_library_init=yes -else - ac_cv_lib_ssl_SSL_library_init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_library_init" >&5 -$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; } -if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBSSL 1 -_ACEOF - - LIBS="-lssl $LIBS" - -fi - -cf_have_libssl=$ac_cv_lib_ssl_SSL_library_init - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_CIPHER_CTX_init in -lcrypto" >&5 -$as_echo_n "checking for EVP_CIPHER_CTX_init in -lcrypto... " >&6; } -if ${ac_cv_lib_crypto_EVP_CIPHER_CTX_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lcrypto $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char EVP_CIPHER_CTX_init (); -int -main () -{ -return EVP_CIPHER_CTX_init (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_crypto_EVP_CIPHER_CTX_init=yes -else - ac_cv_lib_crypto_EVP_CIPHER_CTX_init=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_CIPHER_CTX_init" >&5 -$as_echo "$ac_cv_lib_crypto_EVP_CIPHER_CTX_init" >&6; } -if test "x$ac_cv_lib_crypto_EVP_CIPHER_CTX_init" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBCRYPTO 1 -_ACEOF - - LIBS="-lcrypto $LIBS" - -fi - -cf_have_libcrypto=$ac_cv_lib_crypto_EVP_CIPHER_CTX_init - -for ac_func in OpenSSL_add_all_algorithms EVP_bf_cbc EVP_rc2_cbc EVP_rc4 EVP_rc5_32_12_16_cbc EVP_des_cbc EVP_desx_cbc EVP_cast5_cbc EVP_idea_cbc EVP_aes_128_cbc EVP_aes_256_cbc -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -fi -done - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking that OpenSSL Library is at least version 0.9.7" >&5 -$as_echo_n "checking that OpenSSL Library is at least version 0.9.7... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - #if SSLEAY_VERSION_NUMBER >= 0x00907000L - yes - #endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "yes" >/dev/null 2>&1; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -$as_echo "#define USE_OPENSSL_ADD_ALL_ALGORITHMS 1" >>confdefs.h - - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -rm -f conftest* - -fi - -if test "cf_have_libssl" = "yes" -then -cf_use_zlib=yes -fi - - -# Check whether --enable-zlib was given. -if test "${enable_zlib+set}" = set; then : - enableval=$enable_zlib; cf_use_zlib=$enableval -fi - - -if test "$cf_use_zlib" = "yes" -then -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for deflate in -lz" >&5 -$as_echo_n "checking for deflate in -lz... " >&6; } -if ${ac_cv_lib_z_deflate+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char deflate (); -int -main () -{ -return deflate (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_z_deflate=yes -else - ac_cv_lib_z_deflate=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_deflate" >&5 -$as_echo "$ac_cv_lib_z_deflate" >&6; } -if test "x$ac_cv_lib_z_deflate" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBZ 1 -_ACEOF - - LIBS="-lz $LIBS" - -fi - -cf_have_libz=$ac_cv_lib_z_deflate -fi - - -# Check whether --enable-oss was given. -if test "${enable_oss+set}" = set; then : - enableval=$enable_oss; cf_use_oss=$enableval -fi - - -cf_use_oss=yes - -if test "$cf_use_oss" = "yes" -then -ac_fn_c_check_header_mongrel "$LINENO" "sys/soundcard.h" "ac_cv_header_sys_soundcard_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_soundcard_h" = xyes; then : - $as_echo "#define HAVE_OSS 1" >>confdefs.h - -else - cf_have_oss=no -fi - - -fi - - -#AC_ARG_ENABLE(esd, [ --enable-esd use ESound], cf_use_esd=$enableval ) - -if test "$cf_use_esd" = "yes" -then -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for esd_open_sound in -lesd" >&5 -$as_echo_n "checking for esd_open_sound in -lesd... " >&6; } -if ${ac_cv_lib_esd_esd_open_sound+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lesd $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char esd_open_sound (); -int -main () -{ -return esd_open_sound (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_esd_esd_open_sound=yes -else - ac_cv_lib_esd_esd_open_sound=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_esd_esd_open_sound" >&5 -$as_echo "$ac_cv_lib_esd_esd_open_sound" >&6; } -if test "x$ac_cv_lib_esd_esd_open_sound" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBESD 1 -_ACEOF - - LIBS="-lesd $LIBS" - -fi - -cf_have_libesd=$ac_cv_lib_esd_esd_open_sound -fi - -ac_config_files="$ac_config_files Makefile" - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -$as_echo "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`$as_echo "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - -as_nl=' -' -export as_nl -# Printing a long string crashes Solaris 7 /usr/bin/printf. -as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo -as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -# Prefer a ksh shell builtin over an external printf program on Solaris, -# but without wasting forks for bash or zsh. -if test -z "$BASH_VERSION$ZSH_VERSION" \ - && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='print -r --' - as_echo_n='print -rn --' -elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then - as_echo='printf %s\n' - as_echo_n='printf %s' -else - if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then - as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' - as_echo_n='/usr/ucb/echo -n' - else - as_echo_body='eval expr "X$1" : "X\\(.*\\)"' - as_echo_n_body='eval - arg=$1; - case $arg in #( - *"$as_nl"*) - expr "X$arg" : "X\\(.*\\)$as_nl"; - arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; - esac; - expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" - ' - export as_echo_n_body - as_echo_n='sh -c $as_echo_n_body as_echo' - fi - export as_echo_body - as_echo='sh -c $as_echo_body as_echo' -fi - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# IFS -# We need space, tab and new line, in precisely that order. Quoting is -# there to prevent editors from complaining about space-tab. -# (If _AS_PATH_WALK were called with IFS unset, it would disable word -# splitting by setting IFS to empty value.) -IFS=" "" $as_nl" - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - -# Unset variables that we do not need and which cause bugs (e.g. in -# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" -# suppresses any "Segmentation fault" message there. '((' could -# trigger a bug in pdksh 5.2.14. -for as_var in BASH_ENV ENV MAIL MAILPATH -do eval test x\${$as_var+set} = xset \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done -PS1='$ ' -PS2='> ' -PS4='+ ' - -# NLS nuisances. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# CDPATH. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - $as_echo "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by $as_me, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - -Configuration files: -$config_files - -Report bugs to the package provider." - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.69, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2012 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - $as_echo "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - $as_echo "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) - $as_echo "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; - - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; - - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - $as_echo "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - - -eval set X " :F $CONFIG_FILES " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -$as_echo "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`$as_echo "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - - - - esac - -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} -fi - - -echo -echo -echo "############# libUseful Build Config: #############" -if test "$ac_cv_sys_file_offset_bits" = "64" -then -echo "Largefiles ( > 2GB ) enabled" -else -echo "Largefiles ( > 2GB ) NOT enabled" -fi - -if test "$cf_have_sendfile" = "yes" -then -echo "Linux sendfile syscall enabled" -else -echo "Linux sendfile syscall NOT enabled" -fi - -if test "$cf_use_ip6" = "yes" -then -echo "IPv6 enabled" -else -echo "IPv6 NOT enabled" -fi - -if test "$cf_have_libssl" = "yes" -then -echo "SSL/TLS enabled" -else -echo "SSL/TLS NOT enabled" -fi - -if test "$cf_use_zlib" = "yes" -then -echo "zlib support enabled" -else -echo "zlib NOT enabled" -fi - - diff --git a/libUseful-2.6/configure.ac b/libUseful-2.6/configure.ac deleted file mode 100755 index b51a769..0000000 --- a/libUseful-2.6/configure.ac +++ /dev/null @@ -1,152 +0,0 @@ -#AC_INIT(libUseful,colums.projects@googlemail.com,,http://sites.google.com/site/columscode) -AC_INIT(defines.h) - -VERSION="0.0.1" -AC_SUBST(VERSION) - -AC_PROG_CC -AC_LANG_C -AC_PROG_MAKE_SET -AC_HEADER_STDC -AC_SYS_LARGEFILE - -cf_have_libssl=no -cf_have_libcrypto=no -cf_have_libz=yes -cf_have_oss=no -cf_have_libesd=no -cf_have_sendfile=no -cf_have_ptsname_r=no - - -AC_CHECK_LIB(c,ptsname_r,,) -cf_have_ptsname_r=$ac_cv_lib_c_ptsname_r -if test "$cf_have_ptsname_r" -then -AC_DEFINE([HAVE_PTSNAME_R]) -fi - - -AC_ARG_ENABLE(sendfile, [ --enable-sendfile enable sendfile support], cf_use_sendfile=$enableval ) - -if test "$cf_use_sendfile" != "no" -then -AC_CHECK_HEADER(sys/sendfile.h,cf_have_sendfile=yes,cf_have_sendfile=no,) -fi - -if test "$cf_have_sendfile" = "yes" -then -AC_DEFINE([USE_SENDFILE]) -fi - - - -AC_ARG_ENABLE(ip6, [ --enable-ip6 enable IPv6 support], cf_use_ip6=$enableval ) - -if test "$cf_use_ip6" = "yes" -then -AC_DEFINE([USE_INET6],1) -fi - - -AC_ARG_ENABLE(ssl, [ --enable-ssl use Secure Sockets Layer], cf_use_ssl=$enableval ) - -if test "$cf_use_ssl" = "yes" -then -AC_CHECK_LIB(ssl,SSL_library_init,,) -cf_have_libssl=$ac_cv_lib_ssl_SSL_library_init - -AC_CHECK_LIB(crypto,EVP_CIPHER_CTX_init,,) -cf_have_libcrypto=$ac_cv_lib_crypto_EVP_CIPHER_CTX_init - -AC_CHECK_FUNCS(OpenSSL_add_all_algorithms EVP_bf_cbc EVP_rc2_cbc EVP_rc4 EVP_rc5_32_12_16_cbc EVP_des_cbc EVP_desx_cbc EVP_cast5_cbc EVP_idea_cbc EVP_aes_128_cbc EVP_aes_256_cbc) - - AC_MSG_CHECKING([that OpenSSL Library is at least version 0.9.7]) - AC_EGREP_CPP(yes, [ - #include - #if SSLEAY_VERSION_NUMBER >= 0x00907000L - yes - #endif - ], - [ - AC_MSG_RESULT([yes]) - AC_DEFINE(USE_OPENSSL_ADD_ALL_ALGORITHMS, 1, [Use OpenSSL_add_all_algorithms]) - ],[AC_MSG_RESULT([no])]) -fi - -if test "cf_have_libssl" = "yes" -then -cf_use_zlib=yes -fi - - -AC_ARG_ENABLE(zlib, [ --enable-zlib use ZLib Compression], cf_use_zlib=$enableval ) - -if test "$cf_use_zlib" = "yes" -then -AC_CHECK_LIB(z,deflate,,) -cf_have_libz=$ac_cv_lib_z_deflate -fi - - -AC_ARG_ENABLE(oss, [ --enable-oss use Open Sound System], cf_use_oss=$enableval ) - -dnl Always use oss if available -cf_use_oss=yes - -if test "$cf_use_oss" = "yes" -then -AC_CHECK_HEADER(sys/soundcard.h,AC_DEFINE([HAVE_OSS]),cf_have_oss=no,) -fi - - -#AC_ARG_ENABLE(esd, [ --enable-esd use ESound], cf_use_esd=$enableval ) - -if test "$cf_use_esd" = "yes" -then -AC_CHECK_LIB(esd,esd_open_sound,,) -cf_have_libesd=$ac_cv_lib_esd_esd_open_sound -fi - -dnl read Makefile.in and write Makefile -AC_OUTPUT(Makefile) - -echo -echo -echo "############# libUseful Build Config: #############" -if test "$ac_cv_sys_file_offset_bits" = "64" -then -echo "Largefiles ( > 2GB ) enabled" -else -echo "Largefiles ( > 2GB ) NOT enabled" -fi - -if test "$cf_have_sendfile" = "yes" -then -echo "Linux sendfile syscall enabled" -else -echo "Linux sendfile syscall NOT enabled" -fi - -if test "$cf_use_ip6" = "yes" -then -echo "IPv6 enabled" -else -echo "IPv6 NOT enabled" -fi - -if test "$cf_have_libssl" = "yes" -then -echo "SSL/TLS enabled" -else -echo "SSL/TLS NOT enabled" -fi - -if test "$cf_use_zlib" = "yes" -then -echo "zlib support enabled" -else -echo "zlib NOT enabled" -fi - - diff --git a/libUseful-2.6/crc32.c b/libUseful-2.6/crc32.c deleted file mode 100755 index dba57b8..0000000 --- a/libUseful-2.6/crc32.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - --------------------------------------------------------------------------- - Copyright (c) 2003, Dominik Reichl , Germany. - All rights reserved. - - Distributed under the terms of the GNU General Public License v2. - - This software is provided 'as is' with no explicit or implied warranties - in respect of its properties, including, but not limited to, correctness - and/or fitness for purpose. - --------------------------------------------------------------------------- -*/ - -#include "crc32.h" - -// CRC-32 polynominal: -// X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X+1 - -static unsigned long crc32tab[] = { - 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, - 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, - 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, - 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, - 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, - 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, - 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, - 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, - 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, - 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, - 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, - 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, - 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, - 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, - 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, - 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, - 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, - 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, - 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, - 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, - 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, - 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, - 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, - 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, - 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, - 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, - 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, - 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, - 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, - 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, - 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, - 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, - 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, - 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, - 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, - 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, - 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, - 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, - 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, - 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, - 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, - 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, - 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, - 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, - 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, - 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, - 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, - 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, - 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, - 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, - 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, - 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, - 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, - 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, - 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, - 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, - 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, - 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, - 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, - 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, - 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, - 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, - 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, - 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL -}; - -void crc32Init(unsigned long *pCrc32) -{ - *pCrc32 = 0xFFFFFFFF; -} - -void crc32Update(unsigned long *pCrc32, unsigned char *pData, unsigned long uSize) -{ - unsigned long i = 0; - - for(i = 0; i < uSize; i++) - *pCrc32 = ((*pCrc32) >> 8) ^ crc32tab[(pData[i]) ^ ((*pCrc32) & 0x000000FF)]; -} - -// Make the final adjustment -void crc32Finish(unsigned long *pCrc32) -{ - *pCrc32 = ~(*pCrc32); -} diff --git a/libUseful-2.6/crc32.h b/libUseful-2.6/crc32.h deleted file mode 100755 index d947c91..0000000 --- a/libUseful-2.6/crc32.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - --------------------------------------------------------------------------- - Copyright (c) 2003, Dominik Reichl , Germany. - All rights reserved. - - Distributed under the terms of the GNU General Public License v2. - - This software is provided 'as is' with no explicit or implied warranties - in respect of its properties, including, but not limited to, correctness - and/or fitness for purpose. - --------------------------------------------------------------------------- -*/ - -#ifndef ___CRC32_H___ -#define ___CRC32_H___ - - -#ifdef __cplusplus -extern "C" { -#endif - -void crc32Init(unsigned long *pCrc32); -void crc32Update(unsigned long *pCrc32, unsigned char *pData, unsigned long uSize); -void crc32Finish(unsigned long *pCrc32); - -#ifdef __cplusplus -} -#endif - -#endif /* ___CRC32_H___ */ diff --git a/libUseful-2.6/defines.h b/libUseful-2.6/defines.h deleted file mode 100755 index 1d3dd2e..0000000 --- a/libUseful-2.6/defines.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef LIBUSEFUL_DEFINES_H -#define LIBUSEFUL_DEFINES_H - -#define FALSE 0 -#define TRUE 1 - -#define FTIMEOUT -2 - - -#define ENCODE_NONE 0 -#define ENCODE_OCTAL 8 -#define ENCODE_DECIMAL 10 -#define ENCODE_HEX 16 -#define ENCODE_HEXUPPER 17 -#define ENCODE_BASE64 64 -#define ENCODE_IBASE64 65 -#define ENCODE_PBASE64 66 -#define ENCODE_XXENC 67 -#define ENCODE_UUENC 68 -#define ENCODE_CRYPT 69 - -#define ENCODE_ASCII85 85 -#define ENCODE_Z85 86 - -#define SUBS_QUOTE_VARS 1 -#define SUBS_CASE_VARNAMES 2 -#define SUBS_STRIP_VARS_WHITESPACE 4 -#define SUBS_INTERPRET_BACKSLASH 8 -#define SUBS_QUOTES 16 - -#define HEX_CHARS "0123456789ABCDEF" -#define ALPHA_CHARS "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" -#define BASE64_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" -#define IBASE64_CHARS "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789+/" -#define SBASE64_CHARS "0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" -#define CRYPT_CHARS "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" -#define UUENC_CHARS " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" -#define XXENC_CHARS "+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" -#define ASCII85_CHARS "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu" -#define Z85_CHARS "01234567899abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#." - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int (*BASIC_FUNC)(void *Data); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libUseful-2.6/expect.c b/libUseful-2.6/expect.c deleted file mode 100755 index 2c3fcab..0000000 --- a/libUseful-2.6/expect.c +++ /dev/null @@ -1,137 +0,0 @@ -#include "includes.h" -#include "expect.h" - - -//Values for 'flags' that are not visible to the user -//These must not clash with any visible values -#define DIALOG_DONE 67108864 - - -void ExpectDialogAdd(ListNode *ExpectDialogs, char *Expect, char *Reply, int Flags) -{ -TExpectDialog *ExpectDialog; - -ExpectDialog=(TExpectDialog *) calloc(1,sizeof(TExpectDialog)); -ExpectDialog->Expect=CopyStr(ExpectDialog->Expect,Expect); -ExpectDialog->Reply=CopyStr(ExpectDialog->Reply,Reply); -ExpectDialog->Flags=Flags; - -ListAddItem(ExpectDialogs,ExpectDialog); -} - -void ExpectDialogDestroy(void *p_Item) -{ -TExpectDialog *ExpectDialog; - -ExpectDialog=(TExpectDialog *) p_Item; -DestroyString(ExpectDialog->Expect); -DestroyString(ExpectDialog->Reply); -free(ExpectDialog); -} - - - -int STREAMExpectDialog(STREAM *S, ListNode *ExpectDialogs) -{ -int inchar; -ListNode *Curr; -TExpectDialog *ExpectDialog; - -inchar=STREAMReadChar(S); -while (inchar !=EOF) -{ - if (inchar > 0) - { - Curr=ListGetNext(ExpectDialogs); - while (Curr) - { - ExpectDialog=(TExpectDialog *) Curr->Item; - if (! (ExpectDialog->Flags & DIALOG_DONE)) - { - //if the current value does not equal where we are in the string - //we have to consider whether it is the first character in the string - if (ExpectDialog->Expect[ExpectDialog->Match]!=inchar) ExpectDialog->Match=0; - - if (ExpectDialog->Expect[ExpectDialog->Match]==inchar) - { - ExpectDialog->Match++; - if (ExpectDialog->Expect[ExpectDialog->Match]=='\0') - { - ExpectDialog->Match=0; - ExpectDialog->Flags |= DIALOG_DONE; - if (ExpectDialog->Reply) STREAMWriteLine(ExpectDialog->Reply,S); - if (ExpectDialog->Flags & DIALOG_END) return(TRUE); - if (ExpectDialog->Flags & DIALOG_FAIL) return(FALSE); - } - } - - if (! (ExpectDialog->Flags & DIALOG_OPTIONAL)) break; - } - Curr=ListGetNext(Curr); - } - } -inchar=STREAMReadChar(S); -} - -return(FALSE); -} - - -int STREAMExpectAndReply(STREAM *S, char *Expect, char *Reply) -{ -int match=0, len=0, inchar; - -len=StrLen(Expect); -inchar=STREAMReadChar(S); -while (inchar !=EOF) -{ - if (inchar > 0) - { - //if the current value does not equal where we are in the string - //we have to consider whether it is the first character in the string - if (Expect[match]!=inchar) match=0; - - if (Expect[match]==inchar) - { - match++; - if (match==len) - { - if (Reply) - { - STREAMWriteLine(Reply,S); - STREAMFlush(S); - } - return(TRUE); - } - } - - } -inchar=STREAMReadChar(S); -} - -return(FALSE); -} - - -int STREAMExpectSilence(STREAM *S, int wait) -{ -int inchar; -char *Tempstr=NULL; -int len=0, Timeout; - -Timeout=S->Timeout; -S->Timeout=wait; -inchar=STREAMReadChar(S); -while (inchar > 0) -{ - Tempstr=AddCharToBuffer(Tempstr,len,inchar); - len++; - inchar=STREAMReadChar(S); -} - -S->Timeout=Timeout; - -DestroyString(Tempstr); - -return(FALSE); -} diff --git a/libUseful-2.6/expect.h b/libUseful-2.6/expect.h deleted file mode 100755 index d8de924..0000000 --- a/libUseful-2.6/expect.h +++ /dev/null @@ -1,37 +0,0 @@ - -#ifndef LIBUSEFUL_EXPECT_H -#define LIBUSEFUL_EXPECT_H - -#include "file.h" - -#define DIALOG_END 1 -#define DIALOG_FAIL 2 -#define DIALOG_OPTIONAL 4 - -typedef struct -{ -int Flags; -int Match; -char *Expect; -char *Reply; -} TExpectDialog; - - -#ifdef __cplusplus -extern "C" { -#endif - -int STREAMExpectAndReply(STREAM *S, char *Expect, char *Reply); -int STREAMExpectSilence(STREAM *S, int wait); - -void ExpectDialogAdd(ListNode *Dialogs, char *Expect, char *Reply, int Flags); -int STREAMExpectDialog(STREAM *S, ListNode *Dialogs); - -void ExpectDialogDestroy(void *Item); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/file.c b/libUseful-2.6/file.c deleted file mode 100755 index 79b5c8e..0000000 --- a/libUseful-2.6/file.c +++ /dev/null @@ -1,1582 +0,0 @@ -#include "includes.h" -#include "DataProcessing.h" -#include "pty.h" -#include "expect.h" -#include -#include "securemem.h" -#include - -#ifdef HAVE_LIBSSL -#include -#include -#include -#include -#include -#endif - - -//A difficult function to fit in order -int STREAMReadCharsToBuffer(STREAM *S); - - -int FDSelect(int fd, int Flags, struct timeval *tv) -{ -fd_set *readset=NULL, *writeset=NULL; -int result, RetVal=0; - - -if (Flags & SELECT_READ) -{ - readset=(fd_set *) calloc(1,sizeof(fd_set)); - FD_ZERO(readset); - FD_SET(fd, readset); -} - -if (Flags & SELECT_WRITE) -{ - writeset=(fd_set *) calloc(1,sizeof(fd_set)); - FD_ZERO(writeset); - FD_SET(fd, writeset); -} - - -result=select(fd+1,readset,writeset,NULL,tv); -if ((result==-1) && (errno==EBADF)) RetVal=0; -else if (result > 0) -{ - if (readset && FD_ISSET(fd, readset)) RetVal |= SELECT_READ; - if (writeset && FD_ISSET(fd, writeset)) RetVal |= SELECT_WRITE; -} - -if (readset) free(readset); -if (writeset) free(writeset); - -return(RetVal); -} - - -int FDIsWritable(int fd) -{ -struct timeval tv; - -tv.tv_sec=0; -tv.tv_usec=0; -if (FDSelect(fd, SELECT_WRITE, &tv) & SELECT_WRITE) return(TRUE); -return(FALSE); -} - - - -int FDCheckForBytes(int fd) -{ -struct timeval tv; - -tv.tv_sec=0; -tv.tv_usec=0; -if (FDSelect(fd, SELECT_READ, &tv) & SELECT_READ) return(TRUE); -return(FALSE); -} - - - -/*STREAM Functions */ - -void STREAMSetFlags(STREAM *S, int Set, int UnSet) -{ -int val; - - S->Flags &= ~UnSet; - S->Flags |= Set; - - //yes, flags are RETURNED, argument ignored - val=fcntl(S->in_fd,F_GETFL,NULL); - - //Handling nonblock flag involves setting nonblock on or off - //sadly fcntl does not honor O_CLOEXEC flag, so we have to set - //that using F_SETFD below - if (S->Flags & SF_NONBLOCK) val |= O_NONBLOCK; - else val &= (~O_NONBLOCK); - - //these two sets of flags should be the same - fcntl(S->in_fd, F_SETFL, val); - fcntl(S->out_fd, F_SETFL, val); - - - //F_GETFD, NOT F_GETFL as above - val=fcntl(S->in_fd,F_GETFD, NULL); - //Handling close-on-exec flag - if (S->Flags & SF_EXEC_INHERIT) val &= (~FD_CLOEXEC); - else val |= FD_CLOEXEC; - - //NOTE F_SETFD IS NOT SAME AS F_SETFL ABOVE! - //these two sets of flags should be the same - fcntl(S->in_fd, F_SETFD, val); - fcntl(S->out_fd, F_SETFD, val); -} - - -/*Set timeout for select calls within STREAM*/ -void STREAMSetTimeout(STREAM *S, int val) -{ -S->Timeout=val; -} - - -/*Set flush type for STREAM*/ -void STREAMSetFlushType(STREAM *S, int Type, int StartPoint, int BlockSize) -{ -S->Flags &= ~(FLUSH_ALWAYS | FLUSH_LINE | FLUSH_BLOCK | FLUSH_BUFFER); -S->Flags |= Type; -S->StartPoint=StartPoint; -S->BlockSize=BlockSize; -} - -/* This reads chunks from a file and when if finds a newline it resets */ -/* the file pointer to that position */ -void STREAMResizeBuffer(STREAM *S, int size) -{ - if (S->Flags & SF_MMAP) return; - - if (S->Flags & SF_SECURE) - { - if (! (S->Flags & SF_WRONLY)) SecureRealloc(&S->InputBuff, S->BuffSize, size, SMEM_SECURE); - if (! (S->Flags & SF_RDONLY)) SecureRealloc(&S->OutputBuff, S->BuffSize, size, SMEM_SECURE); - } - else - { - if (! (S->Flags & SF_WRONLY)) S->InputBuff =(char *) realloc(S->InputBuff,size); - if (! (S->Flags & SF_RDONLY)) S->OutputBuff=(char *) realloc(S->OutputBuff,size); - } - S->BuffSize=size; - - if (S->InStart > S->BuffSize) S->InStart=0; - if (S->InEnd > S->BuffSize) S->InEnd=0; - if (S->OutEnd > S->BuffSize) S->OutEnd=0; -} - - - - -int STREAMCheckForBytes(STREAM *S) -{ -off_t pos; -struct stat Stat; - - if (! S) return(FALSE); - if (S->State & SS_EMBARGOED) return(FALSE); - if (S->InEnd > S->InStart) return(TRUE); - if (S->in_fd==-1) return(FALSE); - - if (S->Flags & SF_FOLLOW) - { - while (1) - { - pos=STREAMTell(S); - fstat(S->in_fd,&Stat); - if (Stat.st_size > pos) return(TRUE); - } - } - return(FDCheckForBytes(S->in_fd)); -} - - - -int STREAMCountWaitingBytes(STREAM *S) -{ -int read_result=0, result; - - if (! S) return(0); - if (S->State & SS_EMBARGOED) return(0); - - result=FDCheckForBytes(S->in_fd); - if (result > 0) read_result=STREAMReadCharsToBuffer(S); - else if (result < 0) read_result=STREAM_CLOSED; - result=S->InEnd - S->InStart; - - if (result > 0) return(result); - if (read_result==STREAM_CLOSED) return(STREAM_CLOSED); - if (read_result==STREAM_DATA_ERROR) return(STREAM_CLOSED); - return(0); -} - - -STREAM *STREAMSelect(ListNode *Streams, struct timeval *tv) -{ - fd_set SelectSet; - STREAM *S; - ListNode *Curr; - int highfd=0, result; - - FD_ZERO(&SelectSet); - - Curr=ListGetNext(Streams); - while (Curr) - { - S=(STREAM *) Curr->Item; - if (! (S->State & SS_EMBARGOED)) - { - //Pump any data in the stream - STREAMFlush(S); - if (S->InEnd > S->InStart) return(S); - FD_SET(S->in_fd,&SelectSet); - if (S->in_fd > highfd) highfd=S->in_fd; - } - - Curr=ListGetNext(Curr); - } - - result=select(highfd+1,&SelectSet,NULL,NULL,tv); - - if (result > 0) - { - Curr=ListGetNext(Streams); - while (Curr) - { - S=(STREAM *) Curr->Item; - if (FD_ISSET(S->in_fd,&SelectSet)) return(S); - Curr=ListGetNext(Curr); - } - } - - return(NULL); -} - - -int STREAMCheckForWaitingChar(STREAM *S,unsigned char check_char) -{ -int read_result=0, result; -char *found_char; - -if (! S) return(0); -if (S->State & SS_EMBARGOED) return(0); - -result=FDCheckForBytes(S->in_fd); -if (result > 0) read_result=STREAMReadCharsToBuffer(S); -else if (result < 0) read_result=STREAM_CLOSED; - -if (S->InStart < S->InEnd) -{ - found_char=memchr(S->InputBuff + S->InStart,check_char,S->InEnd - S->InStart); - if (found_char > 0) return(TRUE); -} - -if (read_result==STREAM_CLOSED) return(STREAM_CLOSED); -if (read_result==STREAM_DATA_ERROR) return(STREAM_CLOSED); -return(FALSE); -} - - - -int STREAMInternalFinalWriteBytes(STREAM *S, const char *Data, int DataLen) -{ -fd_set selectset; -int result=0, count=0, len; -struct timeval tv; - -if (! S) return(STREAM_CLOSED); -if (S->out_fd==-1) return(STREAM_CLOSED); - - -//if we are flushing blocks, then pad out to the blocksize -if (S->Flags & FLUSH_BLOCK) -{ -DataLen=S->BlockSize; -if (DataLen > S->OutEnd) DataLen=S->OutEnd; - -/* - if (DataLen < S->BlockSize) - { - if (DataLen==0) DataLen=S->BlockSize; - else - { - len=(DataLen / S->BlockSize) * S->BlockSize; - if (S->OutEnd > len) len+=S->BlockSize; - memset(S->OutputBuff+S->OutEnd,0,len - S->OutEnd); - DataLen=len; - } - } -*/ -} - -while (count < DataLen) -{ -if (S->State & SS_SSL) -{ -#ifdef HAVE_LIBSSL -result=SSL_write((SSL *) STREAMGetItem(S,"LIBUSEFUL-SSL-CTX"), Data + count, DataLen - count); -#endif -} -else -{ - if (S->Timeout > 0) - { - FD_ZERO(&selectset); - FD_SET(S->out_fd, &selectset); - result=(S->Timeout % 100); - tv.tv_usec=result * 10000; - tv.tv_sec=S->Timeout / 100; - result=select(S->out_fd+1,NULL,&selectset,NULL,&tv); - - if (result==-1) return(STREAM_CLOSED); - if (result == 0) return(STREAM_TIMEOUT); - } - - if (S->Flags & SF_WRLOCK) flock(S->out_fd,LOCK_EX); - result=DataLen-count; - //if (S->BlockSize && (S->BlockSize < (DataLen-count))) result=S->BlockSize; - result=write(S->out_fd, Data + count, result); - if (S->Flags & SF_WRLOCK) flock(S->out_fd,LOCK_UN); - - //yes, we neglect to do a sync. The idea here is to work opportunisitically, flushing out those pages - //that have been written. We do a sync and another fadvise in STREAMClose - #ifdef POSIX_FADV_DONTNEED - if (S->Flags & SF_NOCACHE) posix_fadvise(S->out_fd, 0,0,POSIX_FADV_DONTNEED); - #endif - -} - - - if (result < 1 && (errno !=EINTR) ) break; - if (result < 0) result=0; - count+=result; - S->BytesWritten+=result; -} - - -//memmove any remaining data so that we add onto the end of it -S->OutEnd -= count; -if (S->OutEnd > 0) memmove(S->OutputBuff,S->OutputBuff+count, S->OutEnd); - - -return(count); -} - - - - -int STREAMFlush(STREAM *S) -{ - return(STREAMInternalFinalWriteBytes(S, S->OutputBuff, S->OutEnd)); -} - -void STREAMClear(STREAM *S) -{ - STREAMFlush(S); - S->InStart=0; -} - - -/*A stream can have a series of 'processor modules' associated with it' */ -/*which do things to the data before it is read/written. This function */ -/*pumps the data through the processor list, and eventually writes it out */ -int STREAMReadThroughProcessors(STREAM *S, char *Bytes, int InLen) -{ -TProcessingModule *Mod; -ListNode *Curr; -char *InBuff=NULL, *OutputBuff=NULL; -int len=0, olen=0, state=STREAM_CLOSED, Flush; - - -len=InLen; - -if (InLen > 0) -{ -InBuff=SetStrLen(InBuff,len+1); -memcpy(InBuff,Bytes ,len); -} - -Curr=ListGetNext(S->ProcessingModules); -while (Curr) -{ - Mod=(TProcessingModule *) Curr->Item; - if (len < BUFSIZ) olen=BUFSIZ; - else olen=len * 8; - - OutputBuff=SetStrLen(OutputBuff,olen); - - if (Mod->Read) - { - if (len < 0) Flush=TRUE; - else Flush=FALSE; - len=Mod->Read(Mod,InBuff,len,&OutputBuff,&olen, Flush); - - if (len != STREAM_CLOSED) state=0; - - if (len > 0) - { - InBuff=SetStrLen(InBuff,len); - memcpy(InBuff,OutputBuff,len); - } - } - - Curr=ListGetNext(Curr); -} - -if ( - (! (S->State & SS_DATA_ERROR)) && - (len > 0) - ) -{ -//Whatever happened above, InBuff should now contain the data to be written! -//note that we resize buff to S->InEnd + len, where len is length of the new -//data. Even if S->InStart > 0 (meaning there are 'sent' bytes in the buffer) -//we consider S->InStart to be 0 as regards sizeing the buffer, because those -//sent bytes are still there. -if ((len + S->InEnd) > S->BuffSize) STREAMResizeBuffer(S, len + S->InEnd); -memcpy(S->InputBuff + S->InEnd, InBuff, len); -S->InEnd+=len; -} - -DestroyString(OutputBuff); -DestroyString(InBuff); - -len=S->InEnd - S->InStart; - -if (len==0) -{ - if (state ==STREAM_CLOSED) return(STREAM_TIMEOUT); - if (S->State & SS_DATA_ERROR) return(STREAM_DATA_ERROR); -} -return(len); -} - - - - -int STREAMLock(STREAM *S, int val) -{ -int result; - -result=flock(S->in_fd,val); - -if (result==0) return(TRUE); -return(FALSE); -} - - -STREAM *STREAMCreate() -{ -STREAM *S; - -S=(STREAM *) calloc(1,sizeof(STREAM)); -STREAMResizeBuffer(S,BUFSIZ); -S->in_fd=-1; -S->out_fd=-1; -S->Timeout=3000; -S->Flags |= FLUSH_ALWAYS; - -return(S); -} - -STREAM *STREAMFromFD(int fd) -{ -STREAM *Stream; - -if (fd==-1) return(NULL); - -Stream=STREAMCreate(); -Stream->in_fd=fd; -Stream->out_fd=fd; -return(Stream); -} - - -STREAM *STREAMFromDualFD(int in_fd, int out_fd) -{ -STREAM *Stream; - -if (in_fd==-1) return(NULL); -if (out_fd==-1) return(NULL); - -Stream=STREAMCreate(); -Stream->in_fd=in_fd; -Stream->out_fd=out_fd; -return(Stream); -} - - - -int STREAMOpenMMap(STREAM *S, int offset, int len, int Flags) -{ -char *ptr; -int MProt=PROT_READ; - -if (S->InputBuff) free(S->InputBuff); -if (Flags & (SF_WRONLY | SF_RDWR)) MProt |= PROT_WRITE; -ptr=(char *) mmap(0, len, MProt, MAP_SHARED, S->in_fd, offset); -if (ptr==MAP_FAILED) return(FALSE); -S->InEnd=len; -S->InStart=0; -S->Flags |= SF_MMAP; -S->InputBuff=ptr; -if (Flags & SF_SECURE) mlock(ptr, len); - -return(TRUE); -} - - -STREAM *STREAMOpenFile(const char *FilePath, int Flags) -{ -int fd, Mode=0; -STREAM *Stream; -struct stat myStat; - -if (Flags & SF_WRONLY) Mode=O_WRONLY; -else if (Flags & SF_RDONLY) Mode=O_RDONLY; -else Mode=O_RDWR; - -if (Flags & SF_CREATE) Mode |= O_CREAT; - -if (strcmp(FilePath,"-")==0) -{ -Stream=STREAMFromDualFD(0,1); -Stream->Path=CopyStr(Stream->Path,FilePath); -Stream->Flags=Flags; -} -else -{ - fd=open(FilePath, Mode, 0600); - if (fd==-1) return(NULL); - - if (Flags & SF_WRLOCK) - { - if (flock(fd,LOCK_EX | LOCK_NB)==-1) - { - close(fd); - return(NULL); - } - } - - if (Flags & SF_RDLOCK) - { - if (flock(fd,LOCK_SH | LOCK_NB)==-1) - { - close(fd); - return(NULL); - } - } - - - // check for symlink naughtyness. Basically a malicious user can - // try to guess the name of the file we are going to open in order - // to get us to write somewhere other than intended. - - - if (! (Flags & SF_SYMLINK_OK)) - { - if (lstat(FilePath, &myStat) !=0) - { - close(fd); - return(NULL); - } - - if (S_ISLNK(myStat.st_mode)) - { - syslog(LOG_USER | LOG_WARNING, "STREAMOpenFile Opened symlink when trying to open %s. Possible DOS attack?",FilePath); - close(fd); - return(NULL); - } - } - else - { - stat(FilePath, &myStat); - } - - //CREATE THE STREAM OBJECT !! - Stream=STREAMFromFD(fd); - STREAMSetTimeout(Stream,0); - - if ( (Flags & (SF_RDONLY | SF_MMAP)) == (SF_RDONLY | SF_MMAP) ) STREAMOpenMMap(Stream, 0, myStat.st_size, Flags); - else - { - if (Flags & SF_TRUNC) ftruncate(fd,0); - if (Flags & SF_APPEND) lseek(fd,0,SEEK_END); - } - -} -Stream->Flags |= Flags; -if (Stream->Flags & SF_SECURE) STREAMResizeBuffer(Stream, Stream->BuffSize); -Stream->Path=CopyStr(Stream->Path,FilePath); -STREAMSetFlushType(Stream,FLUSH_FULL,0,0); - -return(Stream); -} - - -STREAM *STREAMClose(STREAM *S) -{ -ListNode *Curr; -int val; - -if (! S) return(NULL); - -STREAMReadThroughProcessors(S, NULL, 0); -STREAMFlush(S); - -if ( - (StrLen(S->Path)==0) || - (strcmp(S->Path,"-") !=0) - ) -{ - if ((S->out_fd != -1) && (S->out_fd != S->in_fd)) - { - #ifdef POSIX_FADV_DONTNEED - if (S->Flags & SF_NOCACHE) - { - #ifdef linux - fdatasync(S->out_fd); - #endif - posix_fadvise(S->out_fd, 0,0,POSIX_FADV_DONTNEED); - } - #endif - - close(S->out_fd); - } - - if (S->in_fd != -1) - { - #ifdef POSIX_FADV_DONTNEED - if (S->Flags & SF_NOCACHE) posix_fadvise(S->in_fd, 0,0,POSIX_FADV_DONTNEED); - #endif - - close(S->in_fd); - } -} - -Curr=ListGetNext(S->Values); -while (Curr) -{ - if (strncmp(Curr->Tag,"HelperPID",9)==0) - { - val=atoi(Curr->Item); - if (val > 1) kill(val, SIGKILL); - } - Curr=ListGetNext(Curr); -} - -if (S->Flags & SF_SECURE) -{ - SecureDestroy(S->InputBuff,S->BuffSize); - SecureDestroy(S->OutputBuff,S->BuffSize); -} -else -{ - if (! (S->Flags & SF_MMAP)) DestroyString(S->InputBuff); - DestroyString(S->OutputBuff); -} - -ListDestroy(S->Values,(LIST_ITEM_DESTROY_FUNC)DestroyString); -ListDestroy(S->ProcessingModules,DataProcessorDestroy); -DestroyString(S->Path); -free(S); - -return(NULL); -} - - -int STREAMDisassociateFromFD(STREAM *S) -{ -int fd; - -if (! S) return(-1); -fd=S->in_fd; -STREAMFlush(S); -if (! (S->Flags & SF_MMAP)) DestroyString(S->InputBuff); -DestroyString(S->OutputBuff); -DestroyString(S->Path); -free(S); -return(fd); -} - - - - -int STREAMReadCharsToBuffer(STREAM *S) -{ -fd_set selectset; -int result=0, diff, read_result=0, WaitForBytes=TRUE; -struct timeval tv; -char *tmpBuff=NULL; -#ifdef HAVE_LIBSSL -void *SSL_CTX=NULL; -#endif - -if (! S) return(0); - -//we don't read from and embargoed stream. Embargoed is a state that we -//use to indicate a stream must be ignored for a while -if (S->State & SS_EMBARGOED) return(0); - -//we don't read to mmaped streams. We just update pointers to the mmap -if (S->Flags & SF_MMAP) -{ - result=S->InEnd-S->InStart; - if (result < 1) return(STREAM_CLOSED); - return(result); -} - - -if (S->InStart >= S->InEnd) -{ - S->InEnd=0; - S->InStart=0; -} - -diff=S->InEnd-S->InStart; - -if (S->InStart > (S->BuffSize / 2)) -{ - memmove(S->InputBuff,S->InputBuff + S->InStart,diff); - S->InStart=0; - S->InEnd=diff; -} - -//if no room in buffer, we can't read in more bytes -if (S->InEnd >= S->BuffSize) return(1); - - -//This is used in multiple places below, do don't just move it to within the first place -#ifdef HAVE_LIBSSL -SSL_CTX=STREAMGetItem(S,"LIBUSEFUL-SSL-CTX"); -#endif - -//if there are bytes available in the internal OpenSSL buffers, when we don't have to -//wait on a select, we can just go straight through to SSL_read -#ifdef HAVE_LIBSSL -if (S->State & SS_SSL) -{ -if (SSL_pending((SSL *) SSL_CTX) > 0) WaitForBytes=FALSE; -} -#endif - - -//if ((S->Timeout > 0) && (! (S->Flags & SF_NONBLOCK)) && WaitForBytes) -if ((S->Timeout > 0) && WaitForBytes) -{ - FD_ZERO(&selectset); - FD_SET(S->in_fd, &selectset); - result=(S->Timeout % 100); - tv.tv_usec=result * 10000; - tv.tv_sec=S->Timeout / 100; - result=select(S->in_fd+1,&selectset,NULL,NULL,&tv); - - - switch (result) - { - //we are only checking one FD, so should be 1 - case 1: - read_result=0; - break; - - case 0: - errno=ETIMEDOUT; - read_result=STREAM_TIMEOUT; - break; - - default: - if (errno==EINTR) read_result=STREAM_TIMEOUT; - else read_result=STREAM_CLOSED; - break; - - } - -} - -//must do this, as we need it to be 0 if we don't do the reads -result=0; - -if (read_result==0) -{ - tmpBuff=SetStrLen(tmpBuff,S->BuffSize-S->InEnd); - - #ifdef HAVE_LIBSSL - if (S->State & SS_SSL) - { - read_result=SSL_read((SSL *) SSL_CTX, tmpBuff, S->BuffSize-S->InEnd); - } - else - #endif - { - if (S->Flags & SF_RDLOCK) flock(S->in_fd,LOCK_SH); - read_result=read(S->in_fd, tmpBuff, S->BuffSize-S->InEnd); - if (S->Flags & SF_RDLOCK) flock(S->in_fd,LOCK_UN); - } - - if (read_result > 0) - { - result=read_result; - S->BytesRead+=read_result; - } - else - { - if ((read_result == -1) && (errno==EAGAIN)) result=STREAM_NODATA; - else result=STREAM_CLOSED; - } -} - -if (result < 0) read_result=STREAMReadThroughProcessors(S, tmpBuff, 0); -else read_result=STREAMReadThroughProcessors(S, tmpBuff, result); - -if (read_result < 1) -{ - if (result < 0) read_result=result; - else read_result=STREAM_NODATA; -} - - -//We are not returning number of bytes read. We only return something if -//there is a condition (like socket close) where the thing we are waiting for -//may not appear - -DestroyString(tmpBuff); -return(read_result); -} - - -int STREAMTransferBytesOut(STREAM *S, char *Dest, int DestSize) -{ -int bytes; - - bytes=S->InEnd - S->InStart; - - if (bytes > DestSize) bytes=DestSize; - if (bytes < 1) return(0); - - memcpy(Dest,S->InputBuff+S->InStart,bytes); - S->InStart+=bytes; - - return(bytes); -} - - - -int STREAMReadBytes(STREAM *S, char *Buffer, int Buffsize) -{ -int bytes=0, result=0, total=0; - - -if (S->InStart >= S->InEnd) -{ - result=STREAMReadCharsToBuffer(S); - if (S->InStart >= S->InEnd) - { - if (result==STREAM_CLOSED) return(STREAM_CLOSED); - if (result==STREAM_TIMEOUT) return(STREAM_TIMEOUT); - if (result==STREAM_DATA_ERROR) return(STREAM_DATA_ERROR); - } -} - -while (total < Buffsize) -{ - total+=STREAMTransferBytesOut(S, Buffer+total, Buffsize-total); - - bytes=S->InEnd - S->InStart; - - if (bytes < 1) - { - //in testing, the best way to prevent doing constant checking for new bytes, - //and so filling up the buffer, was to only check for new bytes if - //we didn't have enough to satisfy another read like the one we just had - - //We must check for '< 1' rather than '-1' because - if (S->Flags & SF_MMAP) result=-1; - else result=FDCheckForBytes(S->in_fd); - - if (result ==-1) - { - if (total==0) total=STREAM_CLOSED; - break; - } - if (result < 1) break; - - result=STREAMReadCharsToBuffer(S); - if (result < 1) - { - if (total > 0) return(total); - else return(result); - } - } - - -} -return(total); -} - - - -double STREAMTell(STREAM *S) -{ -double pos; - -if (S->Flags & SF_MMAP) return((double) S->InStart); -if (S->OutEnd > 0) STREAMFlush(S); - -#ifdef _LARGEFILE64_SOURCE -pos=(double) lseek64(S->in_fd,0,SEEK_CUR); -#else -pos=(double) lseek(S->in_fd,0,SEEK_CUR); -#endif -pos-=(S->InEnd-S->InStart); - -return(pos); -} - - -double STREAMSeek(STREAM *S, double offset, int whence) -{ -double pos; -int wherefrom; - -if (S->Flags & SF_MMAP) -{ - switch (whence) - { - case SEEK_SET: S->InStart=offset; break; - case SEEK_CUR: S->InStart += offset; break; - case SEEK_END: S->InStart=S->InEnd-offset; break; - } - return((double) S->InStart); -} - -if (S->OutEnd > 0) STREAMFlush(S); - -if (whence==SEEK_CUR) -{ - pos=STREAMTell(S); - pos+=offset; - wherefrom=SEEK_SET; -} -else -{ - pos=offset; - wherefrom=whence; -} -S->InStart=0; -S->InEnd=0; - -#ifdef _LARGEFILE64_SOURCE -pos=(double) lseek64(S->in_fd,(off64_t) pos, wherefrom); -#else -pos=(double) lseek(S->in_fd,(off_t) pos, wherefrom); -#endif - - -return(pos); -} - - - -int STREAMInternalPushProcessingModules(STREAM *S, const char *InData, int InLen, char **OutData, int *OutLen) -{ -TProcessingModule *Mod; -ListNode *Curr, *Next; -int len, AllDataWritten=TRUE; -char *TempBuff=NULL; -const char *ptr; -int Flush=FALSE; - - len=InLen; - ptr=InData; - if (InLen==0) Flush=TRUE; - - //Go through processing modules feeding the data from the previous one into them - Curr=ListGetNext(S->ProcessingModules); - while (Curr) - { - Next=ListGetNext(Curr); - Mod=(TProcessingModule *) Curr->Item; - - if (Mod->Write && ((len > 0) || Flush)) - { - len=Mod->Write(Mod,ptr,len,OutData,OutLen,Flush); - if (Flush && (len !=STREAM_CLOSED)) AllDataWritten=FALSE; - if (Next) - { - TempBuff=SetStrLen(TempBuff, *OutLen); - memcpy(TempBuff,*OutData,*OutLen); - ptr=TempBuff; - len=*OutLen; - } - } - Curr=Next; - } - -DestroyString(TempBuff); -return(AllDataWritten); -} - - -//this function returns the number of bytes *queued*, not number -//written -int STREAMInternalQueueBytes(STREAM *S, const char *Bytes, int Len) -{ -int o_len, queued=0, avail, val=0, result=0; -const char *ptr; - - o_len=Len; - ptr=Bytes; - - do - { - if (o_len > 0) - { - avail=S->BuffSize - S->OutEnd; - if (avail > 0) - { - if (avail > o_len) avail=o_len; - - memcpy(S->OutputBuff+S->OutEnd,ptr,avail); - ptr+=avail; - o_len-=avail; - S->OutEnd+=avail; - - queued+=avail; - } - } - - //Buffer Full, Write some bytes!!! - if ( (S->OutEnd > S->StartPoint) && - ( - (S->OutEnd >= S->BuffSize) || - (S->Flags & FLUSH_ALWAYS) || - ((S->Flags & FLUSH_BLOCK) && (S->OutEnd > S->BlockSize)) - ) - ) - { - //Any decision about how much to write takes place in InternalFinalWrite - result=STREAMInternalFinalWriteBytes(S, S->OutputBuff, S->OutEnd); - if (result < 1) break; - S->StartPoint=0; - } - } while (o_len > 0); - -if ((result < 0) && (result != STREAM_TIMEOUT)) return(result); -return(queued); -} - - - -/*A stream can have a series of 'processor modules' associated with it' */ -/*which do things to the data before it is read/written. This function */ -/*pumps the data through the processor list, and eventually writes it out */ -int STREAMWriteBytes(STREAM *S, const char *Data, int DataLen) -{ -const char *i_data; -char *TempBuff=NULL; -int len, result=0; - - -if (! S) return(STREAM_CLOSED); -if (S->out_fd==-1) return(STREAM_CLOSED); -if (S->State & SS_WRITE_ERROR) return(STREAM_CLOSED); - - -i_data=Data; -len=DataLen; - -if (ListSize(S->ProcessingModules)) -{ - STREAMInternalPushProcessingModules(S, i_data, len, &TempBuff, &len); - i_data=TempBuff; -} - -//This always queues all the data, though it may not flush it all -//thus the calling application always believes all data is written -//Thus we only report errors if len==0; -if (len > 0) result=STREAMInternalQueueBytes(S, i_data, len); -else if (S->OutEnd > S->StartPoint) STREAMInternalFinalWriteBytes(S, S->OutputBuff, S->OutEnd); - -DestroyString(TempBuff); - -return(result); -} - - - - -int STREAMWriteString(const char *Buffer, STREAM *S) -{ -int result; - -if (StrLen(Buffer) < 1) return(FALSE); -result=STREAMWriteBytes(S,Buffer,strlen(Buffer)); -return(result); -} - -int STREAMWriteLine(const char *Buffer, STREAM *S) -{ -int result; - -if (StrLen(Buffer) < 1) return(FALSE); -result=STREAMWriteBytes(S,Buffer,strlen(Buffer)); -if (result < 0) return(result); -if (S->Flags & FLUSH_LINE) result=STREAMFlush(S); -return(result); -} - - -int STREAMReadChar(STREAM *S) -{ -unsigned char inchar; -int result; - -result=STREAMReadBytes(S, &inchar,1); -if (result < 0) return(result); -if (result==0) return(STREAM_NODATA); -return((int) inchar); -} - - - -int STREAMPeekChar(STREAM *S) -{ -int result; - -if (S->InStart >= S->InEnd) -{ - result=STREAMReadCharsToBuffer(S); - if (result < 1) return(result); -} - -return(* (S->InputBuff + S->InStart)); -} - - -int STREAMPeekBytes(STREAM *S, char *Buffer, int Buffsize) -{ -int len=0, result=0; - -if (S->InStart >= S->InEnd) -{ - result=STREAMReadCharsToBuffer(S); - if (S->InStart >= S->InEnd) - { - if (result==STREAM_CLOSED) return(STREAM_CLOSED); - if (result==STREAM_TIMEOUT) return(STREAM_TIMEOUT); - if (result==STREAM_DATA_ERROR) return(STREAM_DATA_ERROR); - } -} - -len=S->InEnd-S->InStart; -if (len > Buffsize) len=Buffsize; - -if (len > 0) memcpy(Buffer,S->InputBuff + S->InStart,len); - -return(len); -} - - - -int STREAMWriteChar(STREAM *S,unsigned char inchar) -{ -char tmpchar; - -tmpchar=(char) inchar; -return(STREAMWriteBytes(S,&tmpchar,1)); -} - - - -int STREAMReadBytesToTerm(STREAM *S, char *Buffer, int BuffSize,unsigned char Term) -{ -int inchar, pos=0; - -inchar=STREAMReadChar(S); -while (inchar != STREAM_CLOSED) -{ -if (inchar > -1) -{ -Buffer[pos]=inchar; -pos++; -if (inchar==Term) break; -if (pos==BuffSize) break; -} -inchar=STREAMReadChar(S); -} - -if ((pos==0) && (inchar==STREAM_CLOSED)) return(STREAM_CLOSED); -return(pos); -} - - -char *STREAMReadToTerminator(char *Buffer, STREAM *S, unsigned char Term) -{ -int result, len=0, bytes_read=0; -char *RetStr=NULL, *ptr; - - -RetStr=CopyStr(Buffer,""); -while (1) -{ - if (S->InEnd > S->InStart) - { - //memchr is wicked fast, so use it - ptr=memchr(S->InputBuff+S->InStart,Term,S->InEnd - S->InStart); - if (ptr) len=(ptr+1)-(S->InputBuff+S->InStart); - else len=S->InEnd-S->InStart; - - RetStr=SetStrLen(RetStr,bytes_read + len); - len=STREAMTransferBytesOut(S, RetStr+bytes_read , len); - bytes_read+=len; - *(RetStr+bytes_read)='\0'; - - //Only return if we found the terminator (using memchr, above) - if (ptr) return(RetStr); - } - - result=STREAMReadCharsToBuffer(S); - if (S->InStart >= S->InEnd) - { - if (result==STREAM_TIMEOUT) return(RetStr); - if (result==STREAM_NODATA) return(RetStr); - - if (bytes_read==0) - { - DestroyString(RetStr); - return(NULL); - } - return(RetStr); - } -} - -//impossible to get here! -return(NULL); -} - - - -char *STREAMReadToMultiTerminator(char *Buffer, STREAM *S, char *Terms) -{ -int inchar, len=0; -char *Tempptr; - -Tempptr=CopyStr(Buffer,""); - -inchar=STREAMReadChar(S); - - -//All error conditions are negative, but '0' can just mean -//no more data to read -while (inchar > -1) -{ - //if ((len % 100)== 0) Tempptr=realloc(Tempptr,(len/100 +1) *100 +2); - //*(Tempptr+len)=inchar; - - if (inchar > 0) - { - Tempptr=AddCharToBuffer(Tempptr,len,(char) inchar); - len++; - - if (strchr(Terms,inchar)) break; - } - inchar=STREAMReadChar(S); -} - - -*(Tempptr+len)='\0'; - -//if ((inchar==STREAM_CLOSED) && (errno==ECONNREFUSED)) return(Tempptr); -if ( - ((inchar==STREAM_CLOSED) || (inchar==STREAM_DATA_ERROR)) - && - (StrLen(Tempptr)==0) - ) -{ - free(Tempptr); - return(NULL); -} - -return(Tempptr); -} - - - - -char *STREAMReadLine(char *Buffer, STREAM *S) -{ -return(STREAMReadToTerminator(Buffer,S,'\n')); -} - - -void STREAMResetInputBuffers(STREAM *S) -{ -double pos; - -pos=STREAMTell(S); -S->InStart=0; -S->InEnd=0; -STREAMSeek(S,pos,SEEK_SET); -} - - - -char *STREAMGetValue(STREAM *S, const char *Name) -{ -ListNode *Curr; - -if (! S->Values) return(NULL); -Curr=ListFindNamedItem(S->Values,Name); -if (Curr) return(Curr->Item); -return(NULL); -} - - -void STREAMSetValue(STREAM *S, const char *Name, const char *Value) -{ - -if (! S->Values) S->Values=ListCreate(); -SetVar(S->Values,Name,Value); -} - -void *STREAMGetItem(STREAM *S, const char *Name) -{ -ListNode *Curr; - -if (! S->Items) return(NULL); -Curr=ListFindNamedItem(S->Items,Name); -if (Curr) return(Curr->Item); -return(NULL); -} - - -void STREAMSetItem(STREAM *S, const char *Name, void *Value) -{ -ListNode *Curr; - -if (! S->Items) S->Items=ListCreate(); -Curr=ListFindNamedItem(S->Items,Name); -if (Curr) Curr->Item=Value; -else ListAddNamedItem(S->Items,Name,Value); -} - - -int STREAMFindCompare(const char *Line, const char *Item, const char *Delimiter, char **RetStr) -{ -char *ptr=NULL; -int result; - - if (StrValid(Delimiter)) ptr=strstr(Line, Delimiter); - - if (ptr) result=strncmp(Item, Line, ptr-Line); - else result=strcmp(Item, Line); - - if (RetStr && (result==0)) *RetStr=CopyStr(*RetStr, Line); - -return(result); -} - - - -int STREAMFindBinarySearch(STREAM *S, const char *Item, const char *Delimiter, char **RetStr) -{ -char *Tempstr=NULL; -struct stat Stat; -double Size, delta, pos; -int result, inchar; - - -if (S->Flags & SF_MMAP) Size=S->InEnd; -else -{ - fstat(S->in_fd, &Stat); - Size=Stat.st_size; -} - -delta=Size / 2; -pos=delta; -while (delta > 100) -{ - STREAMSeek(S, pos, SEEK_SET); - inchar=STREAMReadChar(S); - while ((inchar != '\n') && (inchar != EOF)) inchar=STREAMReadChar(S); - if (inchar==EOF) return(FALSE); - Tempstr=STREAMReadLine(Tempstr, S); - StripTrailingWhitespace(Tempstr); - result=STREAMFindCompare(Tempstr, Item, Delimiter, RetStr); - if (result ==0) break; - - delta /= 2; - if (result > 0) pos+=delta; - else pos-=delta; -} - -//rewind if we need to -while ((result < 0) && (pos > 0)) -{ -pos-=1024; -//if we're near the start of the file, then just seek back to the start -if (pos < 1024) pos=0; -STREAMSeek(S, pos, SEEK_SET); -if (pos > 0) -{ -inchar=STREAMReadChar(S); -while ((inchar != '\n') && (inchar != EOF)) inchar=STREAMReadChar(S); -} - -Tempstr=STREAMReadLine(Tempstr, S); -StripTrailingWhitespace(Tempstr); - -result=STREAMFindCompare(Tempstr, Item, Delimiter, RetStr); -} - -while (Tempstr) -{ - result=STREAMFindCompare(Tempstr, Item, Delimiter, RetStr); - if (result < 1) - { - DestroyString(Tempstr); - if (result==0) return(TRUE); - return(FALSE); - } - Tempstr=STREAMReadLine(Tempstr, S); - StripTrailingWhitespace(Tempstr); -} - -DestroyString(Tempstr); -return(FALSE); -} - - -int STREAMFindItem(STREAM *S, const char *Item, const char *Delimiter, char **RetStr) -{ -char *Tempstr=NULL; - -if (!S) return(FALSE); - -if (S->Flags & SF_SORTED) return(STREAMFindBinarySearch(S, Item, Delimiter, RetStr)); - -Tempstr=STREAMReadLine(Tempstr, S); -while (Tempstr) -{ - StripTrailingWhitespace(Tempstr); - if (STREAMFindCompare(Tempstr, Item, Delimiter, RetStr)==0) - { - DestroyString(Tempstr); - return(TRUE); - } - Tempstr=STREAMReadLine(Tempstr, S); -} - -DestroyString(Tempstr); -return(FALSE); -} - - - - -unsigned long STREAMSendFile(STREAM *In, STREAM *Out, unsigned long Max, int Flags) -{ -unsigned long bytes_transferred=0; -int result; -int UseSendFile=FALSE; - -//val has to be as long as possible, because it will hold the difference -//between two long values. However, use of 'long long' resulted in an -//unsigned value, which caused all manner of problems, so a long is the -//best we can manage -long val, len; - - - -//if we are not using ssl and not using processor modules, we can use -//kernel-level copy! - -if (Max==0) len=BUFSIZ; -else len=(long) (Max-bytes_transferred); - - -#ifdef USE_SENDFILE -#include - -if ( - (Flags & SENDFILE_KERNEL) && - (! (In->State & SS_SSL)) && - (! (Out->State & SS_SSL)) && - (ListSize(In->ProcessingModules)==0) && - (ListSize(Out->ProcessingModules)==0) -) -{ - UseSendFile=TRUE; - STREAMFlush(Out); -} -#endif - - -while (len > 0) -{ -#ifdef USE_SENDFILE - if (UseSendFile) - { - result=sendfile(Out->out_fd, In->in_fd,0,len); - if (result < 1) - { - if (bytes_transferred==0) UseSendFile=FALSE; - result=STREAM_CLOSED; - } - else - { - //if used sendfile we need to do this because we didn't call - //lower level functions like 'STREAMReadCharsToBuffer' that would - //update these - In->BytesRead+=result; - Out->BytesWritten+=result; - } - } -#endif - - if (! UseSendFile) - { - //How much still left to transfer? - - //if outbuff is full do some flushing - val=Out->BuffSize - Out->OutEnd; - if (val < 1) - { - STREAMFlush(Out); - sleep(0); - break; - val=Out->BuffSize - Out->OutEnd; - } - - result=0; - - - val=In->InEnd - In->InStart; - //only read if we don't already have some in inbuff - if (val < 1) - { - result=STREAMReadCharsToBuffer(In); - val=In->InEnd - In->InStart; - } - - if (len > val) len=val; - - //nothing to write! - if (len < 1) - { - //nothing in either buffer! Stream empty. Is it closed? - if ((Out->OutEnd==0) && (result==STREAM_CLOSED)) break; - len=0; - } - - result=STREAMWriteBytes(Out,In->InputBuff+In->InStart,len); - - if (result > 0) - { - In->InStart+=result; - bytes_transferred+=result; - } - - } - - -if (! (Flags & SENDFILE_LOOP)) break; - -if (Max==0) len=BUFSIZ; -else len=(long) (Max-bytes_transferred); -} - -if ((result==STREAM_CLOSED) && (bytes_transferred==0) ) return(STREAM_CLOSED); -return(bytes_transferred); -} - diff --git a/libUseful-2.6/file.h b/libUseful-2.6/file.h deleted file mode 100755 index d721b2c..0000000 --- a/libUseful-2.6/file.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef LIBUSEFUL_FILE_H -#define LIBUSEFUL_FILE_H - -#include -#include //for 'struct timeval' -#include "list.h" - - -#define STREAM_FLUSH -1 - -#define STREAM_CLOSED -1 -#define STREAM_NODATA -2 -#define STREAM_TIMEOUT -3 -#define STREAM_DATA_ERROR -4 - - -/* -#define O_ACCMODE 00000003 -#define O_RDONLY 00000000 -#define O_WRONLY 00000001 -#define O_RDWR 00000002 -#define O_CREAT 00000100 -#define O_EXCL 00000200 -#define O_NOCTTY 00000400 -#define O_TRUNC 00001000 -#define O_APPEND 00002000 -#define O_NONBLOCK 00004000 -#define O_DSYNC 00010000 -#define O_DIRECT 00040000 -#define O_LARGEFILE 00100000 -#define O_DIRECTORY 00200000 -#define O_NOFOLLOW 00400000 -#define O_NOATIME 01000000 -#define O_CLOEXEC 02000000 -*/ - -//Flags that alter stream behavior -#define FLUSH_FULL 0 -#define FLUSH_LINE 1 -#define FLUSH_BLOCK 2 -#define FLUSH_ALWAYS 4 -#define FLUSH_BUFFER 8 - -#define SF_RDWR 0 //is the default -//FLUSH_ flags go in this gap -#define SF_RDONLY 16 -#define SF_WRONLY 32 -#define SF_CREAT 64 -#define SF_CREATE 64 -#define SF_APPEND 128 -#define SF_TRUNC 256 -#define SF_MMAP 512 -#define SF_WRLOCK 1024 -#define SF_RDLOCK 2048 -#define SF_FOLLOW 4096 -#define SF_SECURE 8192 -#define SF_NONBLOCK 16384 -#define SF_EXEC_INHERIT 131072 -#define SF_SYMLINK_OK 262144 -#define SF_NOCACHE 524288 -#define SF_SORTED 1048576 - - -//Stream state values -#define SS_CONNECTING 1 -#define SS_CONNECTED 2 -#define SS_HANDSHAKE_DONE 4 -#define SS_DATA_ERROR 8 -#define SS_WRITE_ERROR 16 -#define SS_EMBARGOED 32 -#define SS_SSL 4096 -#define SS_AUTH 8192 -#define SS_USER1 268435456 -#define SS_USER2 536870912 -#define SS_USER3 1073741824 -#define SS_USER4 2147483648 - -#define STREAM_TYPE_FILE 0 -#define STREAM_TYPE_UNIX 1 -#define STREAM_TYPE_UNIX_DGRAM 2 -#define STREAM_TYPE_TCP 3 -#define STREAM_TYPE_UDP 4 -#define STREAM_TYPE_SSL 5 -#define STREAM_TYPE_HTTP 6 -#define STREAM_TYPE_CHUNKED_HTTP 7 -#define STREAM_TYPE_MESSAGEBUS 8 - -#define O_LOCK O_NOCTTY - - -#define SELECT_READ 1 -#define SELECT_WRITE 2 - - -#define SENDFILE_KERNEL 1 -#define SENDFILE_LOOP 2 - -typedef struct -{ -int Type; -int in_fd, out_fd; -unsigned int Flags; -unsigned int State; -unsigned int Timeout; -unsigned int BlockSize; -unsigned int BuffSize; -unsigned int StartPoint; - -unsigned int InStart, InEnd; -unsigned int OutEnd; -char *InputBuff; -char *OutputBuff; - -unsigned int BytesRead; -unsigned int BytesWritten; -char *Path; -ListNode *ProcessingModules; -ListNode *Values; -ListNode *Items; -} STREAM; - - -#ifdef __cplusplus -extern "C" { -#endif - - -int FDSelect(int fd, int Flags, struct timeval *tv); -int FDIsWritable(int); -int FDCheckForBytes(int); - -void STREAMSetFlags(STREAM *S, int Set, int UnSet); -void STREAMSetTimeout(STREAM *, int); -void STREAMSetFlushType(STREAM *Stream, int Type, int StartPoint, int BlockSize); - - -STREAM *STREAMCreate(); -STREAM *STREAMOpenFile(const char *Path, int Mode); -STREAM *STREAMClose(STREAM *Stream); -int STREAMLock(STREAM *S, int val); -int STREAMFlush(STREAM *Stream); -void STREAMClear(STREAM *Stream); -double STREAMTell(STREAM *Stream); -double STREAMSeek(STREAM *Stream, double, int whence); -void STREAMResizeBuffer(STREAM *, int); -int STREAMReadChar(STREAM *); -int STREAMWriteChar(STREAM *,unsigned char); -char* STREAMReadLine(char *Buffer, STREAM *); -int STREAMReadBytesToTerm(STREAM *S, char *Buffer, int BuffSize,unsigned char Term); -char* STREAMReadToTerminator(char *Buffer, STREAM *,unsigned char Term); -char* STREAMReadToMultiTerminator(char *Buffer, STREAM *, char *Terms); -int STREAMWriteString(const char *Buffer, STREAM *); -int STREAMWriteLine(const char *Buffer, STREAM *); -STREAM *STREAMFromFD(int fd); -STREAM *STREAMFromDualFD(int in_fd, int out_fd); - -int STREAMDisassociateFromFD(STREAM *Stream); -int STREAMPeekChar(STREAM *); -int STREAMPeekBytes(STREAM *S, char *Buffer, int Buffsize); -void STREAMResetInputBuffers(STREAM *S); -int STREAMReadThroughProcessors(STREAM *S, char *Bytes, int InLen); - -int STREAMReadBytes(STREAM *, char *Buffer, int Bytes); -int STREAMWriteBytes(STREAM *, const char *Buffer, int Bytes); -int STREAMCheckForBytes(STREAM *); -int STREAMCheckForWaitingChar(STREAM *S,unsigned char check_char); -int STREAMCountWaitingBytes(STREAM *); -STREAM *STREAMSelect(ListNode *Streams, struct timeval *timeout); - -void STREAMSetValue(STREAM *S, const char *Name, const char *Value); -char *STREAMGetValue(STREAM *S, const char *Name); -void STREAMSetItem(STREAM *S, const char *Name, void *Item); -void *STREAMGetItem(STREAM *S, const char *Name); - -unsigned long STREAMSendFile(STREAM *In, STREAM *Out, unsigned long Max, int Flags); - -#ifdef __cplusplus -} -#endif - - - -#endif diff --git a/libUseful-2.6/http.c b/libUseful-2.6/http.c deleted file mode 100755 index a91c5a7..0000000 --- a/libUseful-2.6/http.c +++ /dev/null @@ -1,1328 +0,0 @@ -#include "http.h" -#include "DataProcessing.h" -#include "ConnectionChain.h" -#include "Hash.h" -#include "ParseURL.h" -#include "Time.h" -#include "base64.h" - -const char *HTTP_AUTH_BY_TOKEN="AuthTokenType"; -ListNode *Cookies=NULL; -ListNode *HTTPVars=NULL; -int g_Flags=0; - - - - -void HTTPInfoDestroy(void *p_Info) -{ -HTTPInfoStruct *Info; - -if (! p_Info) return; -Info=(HTTPInfoStruct *) p_Info; -DestroyString(Info->Protocol); -DestroyString(Info->Method); -DestroyString(Info->Host); -DestroyString(Info->Doc); -DestroyString(Info->Destination); -DestroyString(Info->ResponseCode); -DestroyString(Info->PreviousRedirect); -DestroyString(Info->RedirectPath); -DestroyString(Info->ContentType); -DestroyString(Info->Timestamp); -DestroyString(Info->PostData); -DestroyString(Info->PostContentType); -DestroyString(Info->Proxy); -DestroyString(Info->Authorization); -DestroyString(Info->ProxyAuthorization); - -ListDestroy(Info->ServerHeaders,DestroyString); -ListDestroy(Info->CustomSendHeaders,DestroyString); -free(Info); -} - - - -void HTTPSetVar(const char *Name, const char *Var) -{ - if (! HTTPVars) HTTPVars=ListCreate(); - SetVar(HTTPVars,Name,Var); -} - - - -//These functions relate to adding a 'Data processor' to the stream that -//will decode chunked HTTP transfers - -typedef struct -{ -char *Buffer; -int ChunkSize; -int BuffLen; -} THTTPChunk; - - - -int HTTPChunkedInit(TProcessingModule *Mod, const char *Args) -{ - -Mod->Data=(THTTPChunk *) calloc(1, sizeof(THTTPChunk)); - -return(TRUE); -} - - - -int HTTPChunkedRead(TProcessingModule *Mod, const char *InBuff, int InLen, char **OutBuff, int *OutLen, int Flush) -{ -int len=0, val=0; -THTTPChunk *Chunk; -char *ptr, *vptr; - -Chunk=(THTTPChunk *) Mod->Data; -if (InLen > 0) -{ -len=Chunk->BuffLen+InLen; -Chunk->Buffer=SetStrLen(Chunk->Buffer,len); -memcpy(Chunk->Buffer+Chunk->BuffLen,InBuff,InLen); -Chunk->BuffLen=len; -Chunk->Buffer[len]='\0'; -} -else len=Chunk->BuffLen; -ptr=Chunk->Buffer; - -if (Chunk->ChunkSize==0) -{ - //if chunksize == 0 then read the size of the next chunk - - //if there's nothing in our buffer, and nothing being added, then - //we've already finished! - if ((Chunk->BuffLen==0) && (InLen==0)) return(STREAM_CLOSED); - - vptr=ptr; - //skip past any leading '\r' or '\n' - if (*vptr=='\r') vptr++; - if (*vptr=='\n') vptr++; - - ptr=strchr(vptr,'\n'); - - - //sometimes people seem to miss off the final '\n', so if we get told there's no more data - //we should use a '\r' if we've got one - if ((! ptr) && (InLen==0)) ptr=strchr(vptr,'\r'); - if (ptr) - { - *ptr='\0'; - ptr++; - } - else return(0); - - Chunk->ChunkSize=strtol(vptr,NULL,16); - Chunk->BuffLen=Chunk->Buffer+len-ptr; - - - if (Chunk->BuffLen > 0) memmove(Chunk->Buffer,ptr,Chunk->BuffLen); - //in case it went negative in the above calcuation - else Chunk->BuffLen=0; - - - //if we got chunksize of 0 then we're done, return STREAM_CLOSED - if (Chunk->ChunkSize==0) return(STREAM_CLOSED); -} -else if (len >= Chunk->ChunkSize) -{ - val=Chunk->ChunkSize; - - //We should really grow OutBuff to take all the data - //but for the sake of simplicity we'll just use the space - //supplied - if (val > *OutLen) val=*OutLen; - memcpy(*OutBuff,Chunk->Buffer,val); - - ptr=Chunk->Buffer+val; - Chunk->BuffLen-=val; - Chunk->ChunkSize-=val; - memmove(Chunk->Buffer, ptr, Chunk->BuffLen); -} - -if (Chunk->ChunkSize < 0) Chunk->ChunkSize=0; - -return(val); -} - - - -int HTTPChunkedClose(TProcessingModule *Mod) -{ -THTTPChunk *Chunk; - -Chunk=(THTTPChunk *) Mod->Data; -DestroyString(Chunk->Buffer); -free(Chunk); - -return(TRUE); -} - - -void HTTPAddChunkedProcessor(STREAM *S) -{ -TProcessingModule *Mod=NULL; - - Mod=(TProcessingModule *) calloc(1,sizeof(TProcessingModule)); - Mod->Name=CopyStr(Mod->Name,"HTTP:Chunked"); - Mod->Init=HTTPChunkedInit; - Mod->Read=HTTPChunkedRead; - Mod->Close=HTTPChunkedClose; - - Mod->Init(Mod, ""); - STREAMAddDataProcessor(S,Mod,""); -} - - - -char *HTTPUnQuote(char *RetBuff, const char *Str) -{ -char *RetStr=NULL, *Token=NULL; -const char *ptr; -int olen=0, ilen; - -RetStr=CopyStr(RetStr,""); -ilen=StrLen(Str); - -for (ptr=Str; ptr < (Str+ilen); ptr++) -{ -switch (*ptr) -{ - case '+': - RetStr=AddCharToBuffer(RetStr,olen,' '); - olen++; - break; - - case '%': - ptr++; - Token=CopyStrLen(Token,ptr,2); - ptr++; //not +=2, as we will increment again - RetStr=AddCharToBuffer(RetStr,olen,strtol(Token,NULL,16) & 0xFF); - olen++; - break; - - default: - RetStr=AddCharToBuffer(RetStr,olen,*ptr); - olen++; - break; -} - -} - -DestroyString(Token); -return(RetStr); -} - - -char *HTTPQuoteChars(char *RetBuff, const char *Str, const char *CharList) -{ -char *RetStr=NULL, *Token=NULL; -const char *ptr; -int olen=0, ilen; - -RetStr=CopyStr(RetStr,""); -ilen=StrLen(Str); - -for (ptr=Str; ptr < (Str+ilen); ptr++) -{ -if (strchr(CharList,*ptr)) -{ - Token=FormatStr(Token,"%%%02X",*ptr); - RetStr=CatStr(RetStr,Token); - olen+=StrLen(Token); -} -else -{ - RetStr=AddCharToBuffer(RetStr,olen,*ptr); - olen++; -} -} - - -RetStr[olen]='\0'; -DestroyString(Token); -return(RetStr); -} - - - -char *HTTPQuote(char *RetBuff, const char *Str) -{ -char *RetStr=NULL, *Token=NULL; -const char *ptr; -int olen=0, ilen; - -RetStr=CopyStr(RetStr,""); -ilen=StrLen(Str); - -for (ptr=Str; ptr < (Str+ilen); ptr++) -{ -switch (*ptr) -{ - case ' ': - RetStr=AddCharToStr(RetStr,'+'); - break; - - case '(': - case ')': - case '[': - case ']': - case '{': - case '}': - case '\t': - case '?': - case '&': - case '!': - case ',': - case '+': - case '\'': - case ':': - case ';': - case '/': - case '\r': - case '\n': - Token=FormatStr(Token,"%%%02X",*ptr); - RetStr=CatStr(RetStr,Token); - olen+=StrLen(Token); - break; - - default: - // RetStr=AddCharToBuffer(RetStr,olen,*ptr); - RetStr=AddCharToStr(RetStr,*ptr); - olen++; - break; -} - -} - -DestroyString(Token); -return(RetStr); -} - - -void HTTPInfoSetValues(HTTPInfoStruct *Info, const char *Host, int Port, const char *Logon, const char *Password, const char *Method, const char *Doc, const char *ContentType, int ContentLength) -{ -Info->State=0; -Info->PostData=CopyStr(Info->PostData,""); -Info->Host=CopyStr(Info->Host,Host); -if (Port > 0) Info->Port=Port; -else Info->Port=0; -Info->Method=CopyStr(Info->Method,Method); -Info->Doc=CopyStr(Info->Doc,Doc); -Info->PostContentType=CopyStr(Info->PostContentType,ContentType); -Info->PostContentLength=ContentLength; -Info->UserName=CopyStr(Info->UserName, Logon); - -if (StrLen(Password)) CredsStoreAdd(Host, Logon, Password); -} - - - - -HTTPInfoStruct *HTTPInfoCreate(const char *Protocol, const char *Host, int Port, const char *Logon, const char *Password, const char *Method, const char *Doc, const char *ContentType, int ContentLength) -{ -HTTPInfoStruct *Info; -char *ptr; - -Info=(HTTPInfoStruct *) calloc(1,sizeof(HTTPInfoStruct)); -Info->Protocol=CopyStr(Info->Protocol,Protocol); -HTTPInfoSetValues(Info, Host, Port, Logon, Password, Method, Doc, ContentType, ContentLength); - -Info->ServerHeaders=ListCreate(); -Info->CustomSendHeaders=ListCreate(); -SetVar(Info->CustomSendHeaders,"Accept","*/*"); - -if (g_Flags) Info->Flags=g_Flags; - -ptr=LibUsefulGetValue("HTTP:Proxy"); -if (StrValid(ptr)) -{ - Info->Proxy=CopyStr(Info->Proxy,ptr); - strlwr(Info->Proxy); - if (strncmp(Info->Proxy,"http:",5)==0) Info->Flags |= HTTP_PROXY; - else if (strncmp(Info->Proxy,"https:",6)==0) Info->Flags |= HTTP_PROXY; - else Info->Flags=HTTP_TUNNEL; -} - -return(Info); -} - -char *HTTPInfoToURL(char *RetBuff, HTTPInfoStruct *Info) -{ -char *p_proto; -char *Doc=NULL, *RetStr=NULL; - -if (Info->Flags & HTTP_SSL) p_proto="https"; -else p_proto="http"; - -Doc=HTTPQuoteChars(Doc,Info->Doc," "); -RetStr=FormatStr(RetBuff,"%s://%s:%d%s",p_proto,Info->Host,Info->Port,Info->Doc); - -DestroyString(Doc); -return(RetStr); -} - - -void HTTPInfoSetURL(HTTPInfoStruct *Info, const char *Method, const char *URL) -{ -char *Proto=NULL, *User=NULL, *Pass=NULL, *Token=NULL; - -if (strcasecmp(Method,"POST")==0) ParseURL(URL, &Proto, &Info->Host, &Token, &User, &Pass,&Info->Doc,&Info->PostData); -else ParseURL(URL, &Proto, &Info->Host, &Token, &User, &Pass,&Info->Doc, NULL); -if (StrValid(Token)) Info->Port=atoi(Token); - -if (StrValid(User) || StrValid(Pass)) -{ - Info->UserName=CopyStr(Info->UserName, User); -} - -if (StrValid(Proto) && (strcmp(Proto,"https")==0)) Info->Flags |= HTTP_SSL; - - -//if there were arguments in URL, and HTTP_POSTARGS is set, then post these -//otherwise include them in the URL again -if (StrValid(Info->PostData)) -{ -if (Info->Flags & HTTP_POSTARGS) -{ - Info->PostContentType=CopyStr(Info->PostContentType,"application/x-www-form-urlencoded"); - Info->PostContentLength=StrLen(Info->PostData); -} -else -{ - Info->Doc=MCatStr(Info->Doc,"?",Info->PostData, NULL); - Info->PostData=CopyStr(Info->PostData, ""); -} -} - -DestroyString(User); -DestroyString(Pass); -DestroyString(Token); -DestroyString(Proto); -} - - -HTTPInfoStruct *HTTPInfoFromURL(const char *Method, const char *URL) -{ -HTTPInfoStruct *Info; - -Info=HTTPInfoCreate("HTTP/1.1","", 80, "", "", Method, "", "",0); -HTTPInfoSetURL(Info, Method, URL); - -return(Info); -} - - -void HTTPParseCookie(HTTPInfoStruct *Info, const char *Str) -{ - const char *startptr, *endptr; - char *Tempstr=NULL; - ListNode *Curr; - int len; - - startptr=Str; - while (*startptr==' ') startptr++; - - endptr=strchr(startptr,';'); - if (endptr==NULL) endptr=startptr+strlen(Str); -// if (( *endptr==';') || (*endptr=='\r') ) endptr--; - - Tempstr=CopyStrLen(Tempstr,startptr,endptr-startptr); - - Curr=ListGetNext(Cookies); - endptr=strchr(Tempstr,'='); - len=endptr-Tempstr; - len--; - - while (Curr !=NULL) - { - if (strncmp(Curr->Item,Tempstr,len)==0) - { - Curr->Item=CopyStr(Curr->Item,Tempstr); - DestroyString(Tempstr); - return; - } - Curr=ListGetNext(Curr); - } - - if (! Cookies) Cookies=ListCreate(); - ListAddItem(Cookies,(void *)CopyStr(NULL,Tempstr)); - -DestroyString(Tempstr); -} - - - -char *AppendCookies(char *InStr, ListNode *CookieList) -{ - ListNode *Curr; - char *Tempstr=NULL; - - Tempstr=InStr; - Curr=ListGetNext(CookieList); - - if (Curr) - { - Tempstr=CatStr(Tempstr,"Cookie: "); - while ( Curr ) - { - Tempstr=CatStr(Tempstr,(char *)Curr->Item); - Curr=ListGetNext(Curr); - if (Curr) Tempstr=CatStr(Tempstr, "; "); - } - Tempstr=CatStr(Tempstr,"\r\n"); - } - -return(Tempstr); -} - -void HTTPClearCookies() -{ -ListClear(Cookies, DestroyString); -} - -int HTTPHandleWWWAuthenticate(char *Line, int *Type, char **Config) -{ -char *ptr, *ptr2, *Token=NULL, *Name=NULL, *Value=NULL; -char *Realm=NULL, *QOP=NULL, *Nonce=NULL, *Opaque=NULL, *AuthType=NULL; - -ptr=Line; -while (isspace(*ptr)) ptr++; -ptr=GetToken(ptr," ",&Token,0); -*Type=0; -if (strcasecmp(Token,"basic")==0) *Type |= HTTP_AUTH_BASIC; -if (strcasecmp(Token,"digest")==0) *Type |= HTTP_AUTH_DIGEST; - -QOP=CopyStr(QOP,""); -Realm=CopyStr(Realm,""); -Nonce=CopyStr(Nonce,""); -Opaque=CopyStr(Opaque,""); - -while (ptr) -{ -ptr=GetToken(ptr,",",&Token,GETTOKEN_QUOTES); -StripLeadingWhitespace(Token); -StripTrailingWhitespace(Token); -ptr2=GetToken(Token,"=",&Name,GETTOKEN_QUOTES); -ptr2=GetToken(ptr2,"=",&Value,GETTOKEN_QUOTES); - - -if (strcasecmp(Name,"realm")==0) Realm=CopyStr(Realm,Value); -if (strcasecmp(Name,"qop")==0) QOP=CopyStr(QOP,Value); -if (strcasecmp(Name,"nonce")==0) Nonce=CopyStr(Nonce,Value); -if (strcasecmp(Name,"opaque")==0) Opaque=CopyStr(Opaque,Value); - -} - -if (*Type & HTTP_AUTH_DIGEST) *Config=MCopyStr(*Config, Realm,":", Nonce, ":", QOP, ":", Opaque, ":", NULL); - -DestroyString(Token); -DestroyString(Name); -DestroyString(Value); -DestroyString(Realm); -DestroyString(QOP); -DestroyString(Nonce); -DestroyString(Opaque); -DestroyString(AuthType); - -return(*Type); -} - - - - -void HTTPParseHeader(STREAM *S, HTTPInfoStruct *Info, char *Header) -{ -char *Token=NULL, *Tempstr=NULL; -char *ptr; - -if (Info->Flags & HTTP_DEBUG) fprintf(stderr,"HEADER: %s\n",Header); -ptr=GetToken(Header,":",&Token,0); -while (isspace(*ptr)) ptr++; - -Tempstr=MCopyStr(Tempstr,"HTTP:",Token,NULL); -STREAMSetValue(S,Tempstr,ptr); -ListAddNamedItem(Info->ServerHeaders,Token,CopyStr(NULL,ptr)); - -if (StrValid(Token) && StrValid(ptr)) -{ - switch (*Token) - { - case 'C': - case 'c': - if (strcasecmp(Token,"Content-length")==0) - { - Info->ContentLength=atoi(ptr); - } - else if (strcasecmp(Token,"Content-type")==0) - { - Info->ContentType=CopyStr(Info->ContentType,ptr); - } - else if (strcasecmp(Token,"Connection")==0) - { - if (strcasecmp(ptr,"Close")==0) Info->Flags &= ~HTTP_KEEPALIVE; - } - else if ((strcasecmp(Token,"Content-Encoding")==0) ) - { - if (! (Info->Flags & HTTP_NODECODE)) - { - strlwr(ptr); - - - if ( - (strcmp(ptr,"gzip")==0) || - (strcmp(ptr,"x-gzip")==0) - ) - { - Info->Flags |= HTTP_GZIP; - } - if ( - (strcmp(ptr,"deflate")==0) - ) - { - Info->Flags |= HTTP_DEFLATE; - } - } - - } - break; - - case 'D': - case 'd': - if (strcasecmp(Token,"Date")==0) Info->Timestamp=CopyStr(Info->Timestamp,ptr); - break; - - case 'L': - case 'l': - if (strcasecmp(Token,"Location")==0) - { - if ( - (strncasecmp(ptr,"http:",5)==0) || - (strncasecmp(ptr,"https:",6)==0) - ) - { - Info->RedirectPath=CopyStr(Info->RedirectPath,ptr); - } - else Info->RedirectPath=FormatStr(Info->RedirectPath,"http://%s:%d%s",Info->Host,Info->Port,ptr); - } - break; - - case 'P': - case 'p': - if (strcasecmp(Token,"Proxy-Authenticate")==0) HTTPHandleWWWAuthenticate(ptr, &Info->Flags, &Info->ProxyAuthorization); - break; - - case 'W': - case 'w': - if (strcasecmp(Token,"WWW-Authenticate")==0) HTTPHandleWWWAuthenticate(ptr, &Info->Flags, &Info->Authorization); - break; - - case 'S': - case 's': - if (strcasecmp(Token,"Set-Cookie")==0) HTTPParseCookie(Info,ptr); - else if (strcasecmp(Token,"Status")==0) - { - //'Status' overrides the response - Info->ResponseCode=CopyStrLen(Info->ResponseCode,ptr,3); - STREAMSetValue(S,"HTTP:ResponseCode",Info->ResponseCode); - } - break; - - - case 'T': - case 't': - if ( - (strcasecmp(Token,"Transfer-Encoding")==0) - ) - { - if (! (Info->Flags & HTTP_NODECODE)) - { - strlwr(ptr); - if (strstr(ptr,"chunked")) - { - Info->Flags |= HTTP_CHUNKED; - } - } - } - break; - } -} - -DestroyString(Token); -DestroyString(Tempstr); -} - - -char *HTTPDigest(char *RetStr, const char *Method, const char *Logon, const char *Password, const char *Realm, const char *Doc, const char *Nonce) -{ -char *Tempstr=NULL, *HA1=NULL, *HA2=NULL, *ClientNonce=NULL, *Digest=NULL; -int len1, len2; - - Tempstr=FormatStr(Tempstr,"%s:%s:%s",Logon,Realm,Password); - len1=HashBytes(&HA1,"md5",Tempstr,StrLen(Tempstr),ENCODE_HEX); -printf("HA1: %s\n",Tempstr); - - Tempstr=FormatStr(Tempstr,"%s:%s",Method,Doc); - len2=HashBytes(&HA2,"md5",Tempstr,StrLen(Tempstr),ENCODE_HEX); -printf("HA2: %s\n",Tempstr); - - /* - Tempstr=SetStrLen(len1+len2+StrLen(Nonce)+20); - ptr=Tempstr; - memcpy(ptr,HA1,len1); - ptr+=len1; - *ptr=':'; - ptr++; - - len1=StrLen(Nonce); - memcpy(ptr,Nonce,len1); - ptr+=len1; - *ptr=':'; - ptr++; - - memcpy(ptr,HA2,len2); - ptr+=len2; -*/ - - Tempstr=MCopyStr(Tempstr,HA1,":",Nonce,":",HA2,NULL); - len2=HashBytes(&Digest,"md5",Tempstr,StrLen(Tempstr),ENCODE_HEX); - RetStr=MCopyStr(RetStr, "username=\"",Logon,"\", realm=\"",Realm,"\", nonce=\"",Nonce,"\", response=\"",Digest,"\", ","uri=\"",Doc,"\", algorithm=\"MD5\"", NULL); - - /* AVANCED DIGEST - for (i=0; i < 10; i++) - { - Tempstr=FormatStr(Tempstr,"%x",rand() % 255); - ClientNonce=CatStr(ClientNonce,Tempstr); - } - - Tempstr=FormatStr(Tempstr,"%s:%s:%08d:%s:auth:%s",HA1,Nonce,AuthCounter,ClientNonce,HA2); - HashBytes(&Digest,"md5",Tempstr,StrLen(Tempstr),0); - Tempstr=FormatStr(Tempstr,"%s: Digest username=\"%s\",realm=\"%s\",nonce=\"%s\",uri=\"%s\",qop=auth,nc=%08d,cnonce=\"%s\",response=\"%s\"\r\n",AuthHeader,Logon,Realm,Nonce,Doc,AuthCounter,ClientNonce,Digest); - SendStr=CatStr(SendStr,Tempstr); - */ - -DestroyString(Tempstr); -DestroyString(HA1); -DestroyString(HA2); -DestroyString(Digest); - -return(RetStr); -} - - -char *HTTPHeadersAppendAuth(char *RetStr, char *AuthHeader, HTTPInfoStruct *Info, char *AuthInfo) -{ -char *SendStr=NULL, *Tempstr=NULL, *Realm=NULL, *Nonce=NULL, *ptr; -char *Logon=NULL; -char *p_Password=NULL; - - if (StrEnd(AuthInfo)) return(RetStr); - - SendStr=CatStr(RetStr,""); - - ptr=GetToken(AuthInfo,":",&Realm,0); - ptr=GetToken(ptr,":",&Nonce,0); - - //Authentication by an opaque authentication token that is handled - //elsewhere, and is set as the 'Password' - p_Password=CredsStoreGetSecret(Realm, Info->UserName); - if (! p_Password) p_Password=CredsStoreGetSecret(Info->Host, Info->UserName); - - if (Info->AuthFlags & HTTP_AUTH_TOKEN) SendStr=MCatStr(SendStr,AuthHeader,": ",AuthInfo,"\r\n",NULL); - else if (Info->AuthFlags & HTTP_AUTH_DIGEST) - { - Tempstr=HTTPDigest(Tempstr, Info->Method, Info->UserName, p_Password, Realm, Info->Doc, Nonce); - SendStr=MCatStr(SendStr,AuthHeader,": Digest ", Tempstr, "\r\n",NULL); - } - else - { - Tempstr=MCopyStr(Tempstr,Info->UserName,":",p_Password,NULL); - //We should now have Logon:Password - Nonce=SetStrLen(Nonce,StrLen(Tempstr) *2); - - to64frombits((unsigned char *) Nonce, (unsigned char *) Tempstr,strlen(Tempstr)); - SendStr=MCatStr(SendStr,AuthHeader,": Basic ",Nonce,"\r\n",NULL); - } - - Info->AuthFlags |= HTTP_AUTH_SENT; - //Lock creds again - CredsStoreGetSecret("", ""); - -DestroyString(Tempstr); -DestroyString(Logon); -DestroyString(Realm); -DestroyString(Nonce); - -return(SendStr); -} - - -void HTTPSendHeaders(STREAM *S, HTTPInfoStruct *Info) -{ -char *SendStr=NULL, *Tempstr=NULL, *ptr; -ListNode *Curr; - -STREAMClearDataProcessors(S); -SendStr=CopyStr(SendStr,Info->Method); -SendStr=CatStr(SendStr," "); - -if (Info->Flags & HTTP_PROXY) Tempstr=HTTPInfoToURL(Tempstr, Info); -else Tempstr=HTTPQuoteChars(Tempstr,Info->Doc," "); -SendStr=CatStr(SendStr,Tempstr); - -if (Info->Flags & HTTP_VER1_0) SendStr=CatStr(SendStr," HTTP/1.0\r\n"); -else SendStr=MCatStr(SendStr," ",Info->Protocol,"\r\n","Host: ",Info->Host,"\r\n",NULL); - -if (StrValid(Info->PostContentType)) -{ - Tempstr=FormatStr(Tempstr,"Content-type: %s\r\n",Info->PostContentType); - SendStr=CatStr(SendStr,Tempstr); -} - -if (strcasecmp(Info->Method,"POST")==0) -{ - Tempstr=FormatStr(Tempstr,"Content-Length: %d\r\n",Info->PostContentLength); - SendStr=CatStr(SendStr,Tempstr); -} - -if (StrValid(Info->Destination)) -{ - Tempstr=FormatStr(Tempstr,"Destination: %s\r\n",Info->Destination); - SendStr=CatStr(SendStr,Tempstr); -} - -/* If we have authorisation details then send them */ -if (Info->Authorization) SendStr=HTTPHeadersAppendAuth(SendStr, "Authorization", Info, Info->Authorization); -if (Info->ProxyAuthorization) SendStr=HTTPHeadersAppendAuth(SendStr, "Proxy-Authorization", Info, Info->ProxyAuthorization); - -if (Info->Flags & HTTP_NOCACHE) SendStr=CatStr(SendStr,"Pragma: no-cache\r\nCache-control: no-cache\r\n"); - - -if (Info->Depth > 0) -{ -Tempstr=FormatStr(Tempstr,"Depth: %d\r\n",Info->Depth); -SendStr=CatStr(SendStr,Tempstr); -} - -/* -if ((PathData->Options.Restart) && (PathData->offset >0)) -{ -snprintf(Buffer,sizeof(Buffer),"Range: bytes=%d-\r\n",PathData->offset); -SendStr=CatStr(SendStr,Buffer); - -} -*/ - - if (Info->IfModifiedSince > 0) - { - Tempstr=CopyStr(Tempstr,GetDateStrFromSecs("%a, %d %b %Y %H:%M:%S GMT",Info->IfModifiedSince,NULL)); - SendStr=MCatStr(SendStr,"If-Modified-Since: ",Tempstr, "\r\n",NULL); - } - -if ( - (strcasecmp(Info->Method,"DELETE") !=0) && - (strcasecmp(Info->Method,"HEAD") !=0) && - (strcasecmp(Info->Method,"PUT") !=0) - ) -{ - - Tempstr=CopyStr(Tempstr,""); - - if (! (Info->Flags & HTTP_NOCOMPRESS)) - { - if (DataProcessorAvailable("compress","gzip")) Tempstr=CatStr(Tempstr,"gzip"); - if (DataProcessorAvailable("compress","zlib")) - { - if (StrValid(Tempstr)) Tempstr=CatStr(Tempstr,", deflate"); - else Tempstr=CatStr(Tempstr,"deflate"); - } - } - - if (StrValid(Tempstr)) SendStr=MCatStr(SendStr,"Accept-Encoding: ",Tempstr,"\r\n",NULL); -} - -if (Info->Flags & HTTP_KEEPALIVE) -{ - //if (Info->Flags & HTTP_VER1_0) - SendStr=CatStr(SendStr,"Connection: Keep-Alive\r\n"); - //SendStr=CatStr(SendStr,"Content-Length: 0\r\n"); -} -else -{ - SendStr=CatStr(SendStr,"Connection: close\r\n"); -} - -ptr=LibUsefulGetValue("HTTP:User-Agent"); -if (StrValid(ptr)) SendStr=MCatStr(SendStr,"User-Agent: ",ptr, "\r\n",NULL); - -Curr=ListGetNext(Info->CustomSendHeaders); -while (Curr) -{ -SendStr=MCatStr(SendStr,Curr->Tag, ": ", (char *) Curr->Item, "\r\n",NULL); -Curr=ListGetNext(Curr); -} - -if (! (Info->Flags & HTTP_NOCOOKIES)) -{ -SendStr=AppendCookies(SendStr,Cookies); -} - -SendStr=CatStr(SendStr,"\r\n"); - -Info->State |= HTTP_HEADERS_SENT; -if (Info->Flags & HTTP_DEBUG) fprintf(stderr,"HTTPSEND: ------\n%s------\n\n",SendStr); -STREAMWriteLine(SendStr,S); -STREAMFlush(S); - -DestroyString(Tempstr); -DestroyString(SendStr); -} - - - - -void HTTPReadHeaders(STREAM *S, HTTPInfoStruct *Info) -{ -char *Tempstr=NULL, *Token=NULL, *ptr; - - -ListClear(Info->ServerHeaders,DestroyString); -Info->ContentLength=0; - -//Not needed -//Info->RedirectPath=CopyStr(Info->RedirectPath,""); -Info->Flags &= ~(HTTP_CHUNKED | HTTP_GZIP | HTTP_DEFLATE); -Tempstr=STREAMReadLine(Tempstr,S); -if (Tempstr) -{ - if (Info->Flags & HTTP_DEBUG) fprintf(stderr,"RESPONSE: %s\n",Tempstr); - //Token will be protocol (HTTP/1.0 or ICY or whatever) - ptr=GetToken(Tempstr,"\\S",&Token,0); - Info->ResponseCode=CopyStrLen(Info->ResponseCode,ptr,3); - STREAMSetValue(S,"HTTP:ResponseCode",Info->ResponseCode); -Tempstr=STREAMReadLine(Tempstr,S); -} - -while (Tempstr) -{ -StripTrailingWhitespace(Tempstr); -if (StrEnd(Tempstr)) break; -HTTPParseHeader(S, Info,Tempstr); -Tempstr=STREAMReadLine(Tempstr,S); -} - -//Handle Response Codes -if (StrValid(Info->ResponseCode)) -{ - if (*Info->ResponseCode=='3') - { - //No longer a flag, HTTP Redirect is now just a response code - //Info->Flags |= HTTP_REDIRECT; - } - - if (strcmp(Info->ResponseCode,"401")==0) - { - if (Info->AuthFlags) Info->AuthFlags |= HTTP_AUTH_BASIC; - } - - if (strcmp(Info->ResponseCode,"407")==0) - { - if (Info->AuthFlags) Info->AuthFlags |= HTTP_AUTH_PROXY; - } - -} - -S->BytesRead=0; - -DestroyString(Tempstr); -DestroyString(Token); -} - - - -int HTTPProcessResponse(HTTPInfoStruct *HTTPInfo) -{ -int result=HTTP_ERROR; -char *Proto=NULL, *PortStr=NULL; -int RCode; - -if (HTTPInfo->ResponseCode) -{ -RCode=atoi(HTTPInfo->ResponseCode); -switch (RCode) -{ - case 304: - result=HTTP_NOTMODIFIED; - break; - - case 200: - case 201: - case 202: - case 203: - case 204: - case 205: - case 206: - case 207: - case 400: - result=HTTP_OKAY; - break; - - case 301: - case 302: - case 303: - case 307: - case 308: - if (HTTPInfo->PreviousRedirect && (strcmp(HTTPInfo->RedirectPath,HTTPInfo->PreviousRedirect)==0)) result=HTTP_CIRCULAR_REDIRECTS; - else - { - if (HTTPInfo->Flags & HTTP_DEBUG) fprintf(stderr,"HTTP: Redirected to %s\n",HTTPInfo->RedirectPath); - - //As redirect check has been done, we can copy redirect path to previous - HTTPInfo->PreviousRedirect=CopyStr(HTTPInfo->PreviousRedirect,HTTPInfo->RedirectPath); - ParseURL(HTTPInfo->RedirectPath, &Proto, &HTTPInfo->Host, &PortStr,NULL, NULL,&HTTPInfo->Doc,NULL); - HTTPInfo->Port=atoi(PortStr); - - //if HTTP_SSL_REWRITE is set, then all redirects get forced to https - if (HTTPInfo->Flags & HTTP_SSL_REWRITE) Proto=CopyStr(Proto,"https"); - if (strcmp(Proto,"https")==0) HTTPInfo->Flags |= HTTP_SSL; - else HTTPInfo->Flags &= ~HTTP_SSL; - - //303 Redirects must be get! - if (RCode==303) - { - HTTPInfo->Method=CopyStr(HTTPInfo->Method,"GET"); - HTTPInfo->PostData=CopyStr(HTTPInfo->PostData,""); - HTTPInfo->PostContentType=CopyStr(HTTPInfo->PostContentType,""); - HTTPInfo->PostContentLength=0; - } - - if (! (HTTPInfo->Flags & HTTP_NOREDIRECT)) result=HTTP_REDIRECT; - else result=HTTP_OKAY; - } - break; - - //401 Means authenticate, so it's not a pure error - case 401: - //407 Means authenticate with a proxy - result=HTTP_AUTH_BASIC; - break; - - case 407: - result=HTTP_AUTH_PROXY; - break; - - default: - result=HTTP_NOTFOUND; - break; - -} -} - -DestroyString(Proto); -DestroyString(PortStr); - -return(result); -} - -STREAM *HTTPSetupConnection(HTTPInfoStruct *Info, int ForceHTTPS) -{ -char *Tempstr=NULL, *Host=NULL, *Token=NULL, *ptr; -char *Logon=NULL, *Pass=NULL; -int Port=0, Flags=0; -STREAM *S; - -S=STREAMCreate(); -if (Info->Flags & HTTP_PROXY) -{ - ParseURL(Info->Proxy, &Tempstr, &Host, &Token, &Logon, &Pass, NULL,NULL); - //&Info->ProxyAuthorization->Logon, - Port=atoi(Token); - - - if (ForceHTTPS) Tempstr=CopyStr(Tempstr,"https"); - - if (strcasecmp(Tempstr,"https")==0) Flags |= CONNECT_SSL; -} -else -{ - Host=CopyStr(Host,Info->Host); - Port=Info->Port; - - if (Info->Flags & HTTP_SSL) Flags |= CONNECT_SSL; - if (ForceHTTPS) - { - Flags |= CONNECT_SSL; - } - - if (Port==0) - { - if (Flags & CONNECT_SSL) Port=443; - else Port=80; - } -} - -Tempstr=CopyStr(Tempstr,GetVar(HTTPVars,"Tunnel")); -ptr=GetToken(Tempstr,",",&Token,0); -while (ptr) -{ - STREAMAddConnectionHop(S,Token); - ptr=GetToken(ptr,",",&Token,0); -} - -if (Info->Flags & HTTP_TUNNEL) STREAMAddConnectionHop(S,Info->Proxy); -Tempstr=FormatStr(Tempstr,"tcp:%s:%d",Host,Port); -if (STREAMConnect(S,Tempstr,Flags)) -{ - S->Type=STREAM_TYPE_HTTP; - HTTPSendHeaders(S,Info); -} -else -{ - STREAMClose(S); - S=NULL; -} - -Info->S=S; - -DestroyString(Tempstr); -DestroyString(Token); -DestroyString(Host); - -return(S); -} - - - -STREAM *HTTPConnect(HTTPInfoStruct *Info) -{ -STREAM *S=NULL; - -if ( - (g_Flags & HTTP_REQ_HTTPS) || - (g_Flags & HTTP_TRY_HTTPS) - ) -{ -S=HTTPSetupConnection(Info, TRUE); -if (g_Flags & HTTP_REQ_HTTPS) return(S); -} - -if (!S) S=HTTPSetupConnection(Info, FALSE); - -return(S); -} - - -STREAM *HTTPTransact(HTTPInfoStruct *Info) -{ -int result=HTTP_NOCONNECT; - -while (1) -{ - if (! Info->S) Info->S=HTTPConnect(Info); - else if (! (Info->State & HTTP_HEADERS_SENT)) HTTPSendHeaders(Info->S,Info); - - if (Info->S && STREAMIsConnected(Info->S)) - { - Info->ResponseCode=CopyStr(Info->ResponseCode,""); - - if (! (Info->State & HTTP_CLIENTDATA_SENT)) - { - //Set this even if no client data to send, so we no we've been - //through here once - Info->State |= HTTP_CLIENTDATA_SENT; - - if (StrValid(Info->PostData)) - { - STREAMWriteLine(Info->PostData,Info->S); - if (Info->Flags & HTTP_DEBUG) fprintf(stderr,"\n%s\n",Info->PostData); - } - else - { - if (strcasecmp(Info->Method,"POST")==0) break; - if (strcasecmp(Info->Method,"PUT")==0) break; - } - } - - - //Must clear this once the headers and clientdata sent - Info->State=0; - - HTTPReadHeaders(Info->S,Info); - result=HTTPProcessResponse(Info); - STREAMSetValue(Info->S,"HTTP:URL",Info->Doc); - if (Info->Flags & HTTP_CHUNKED) HTTPAddChunkedProcessor(Info->S); - - if (Info->Flags & HTTP_GZIP) - { - STREAMAddStandardDataProcessor(Info->S,"uncompress","gzip",""); - } - else if (Info->Flags & HTTP_DEFLATE) - { - STREAMAddStandardDataProcessor(Info->S,"uncompress","zlib",""); - } - - if (result == HTTP_OKAY) break; - if (result == HTTP_NOTFOUND) break; - if (result == HTTP_NOTMODIFIED) break; - if (result == HTTP_ERROR) break; - if (result == HTTP_CIRCULAR_REDIRECTS) break; - - - if (result == HTTP_AUTH_BASIC) - { - if ( - (Info->AuthFlags & HTTP_AUTH_SENT) || - (Info->AuthFlags & HTTP_AUTH_RETURN) || - (StrEnd(Info->Authorization)) - ) - { - if (result == HTTP_AUTH_BASIC) break; - if (result == HTTP_AUTH_DIGEST) break; - } - } - - if ( - (result == HTTP_AUTH_PROXY) && - (StrEnd(Info->ProxyAuthorization)) - ) - { - break; - } - - STREAMClose(Info->S); - Info->S=NULL; - } - else break; -} - - -return(Info->S); -} - - - -STREAM *HTTPMethod(const char *Method, const char *URL, const char *Logon, const char *Password, const char *ContentType, const char *ContentData, int ContentLength) -{ -HTTPInfoStruct *Info; -STREAM *S; - - -Info=HTTPInfoFromURL(Method, URL); - -if (StrValid(ContentData)) -{ - if (StrValid(ContentType)) Info->PostContentType=CopyStr(Info->PostContentType,ContentType); - else Info->PostContentType=CopyStr(Info->PostContentType,"application/x-www-form-urlencoded"); - Info->PostData=CopyStr(Info->PostData,ContentData); - Info->PostContentLength=ContentLength; -} - -if (StrValid(Logon) || StrValid(Password)) -{ - Info->UserName=CopyStr(Info->UserName, Logon); -} -S=HTTPTransact(Info); - -HTTPInfoDestroy(Info); -return(S); -} - - -STREAM *HTTPGet(const char *URL, const char *Logon, const char *Password) -{ -return(HTTPMethod("GET", URL, Logon, Password,"","",0)); -} - - -STREAM *HTTPPost(const char *URL, const char *Logon, const char *Password, const char *ContentType, const char *Content) -{ -return(HTTPMethod("POST", URL, Logon, Password, ContentType, Content, StrLen(Content))); -} - - -void HTTPCopyToSTREAM(STREAM *Con, STREAM *S) -{ -char *Tempstr=NULL; -int result; - -Tempstr=SetStrLen(Tempstr,BUFSIZ); -result=STREAMReadBytes(Con, Tempstr,BUFSIZ); -while (result > 0) -{ - STREAMWriteBytes(S,Tempstr,result); - result=STREAMReadBytes(Con, Tempstr,BUFSIZ); -} - -} - - -char *HTTPReadDocument(char *RetStr, STREAM *S) -{ -char *Tempstr=NULL, *ptr; -int result, bytes_read=0, len=0; - -ptr=STREAMGetValue(S, "HTTP:Content-Length"); -if (ptr) len=atoi(ptr); - -printf("HTTPREAD: %d [%s]\n",len, ptr); -if (len > 0) -{ - RetStr=SetStrLen(RetStr,len); - while (bytes_read < len) - { - result=STREAMReadBytes(S, RetStr+bytes_read,len-bytes_read); - if (result > 0) bytes_read+=result; - else break; - } - RetStr[bytes_read]='\0'; -} -else -{ - RetStr=CopyStr(RetStr,""); - Tempstr=STREAMReadLine(Tempstr, S); - while (Tempstr) - { - RetStr=CatStr(RetStr, Tempstr); - Tempstr=STREAMReadLine(Tempstr, S); - } -} - -DestroyString(Tempstr); -return(RetStr); -} - -int HTTPDownload(char *URL,char *Login,char *Password, STREAM *S) -{ -STREAM *Con; -Con=HTTPGet(URL,Login,Password); -if (! Con) return(FALSE); -HTTPCopyToSTREAM(Con, S); -return(TRUE); -} - -void HTTPSetUserAgent(char *AgentName) -{ -LibUsefulSetValue("HTTP:User-Agent",AgentName); -} - -void HTTPSetProxy(char *Proxy) -{ -LibUsefulSetValue("HTTP:Proxy",Proxy); -} - -void HTTPSetFlags(int Flags) -{ -g_Flags=Flags; -} - -int HTTPGetFlags() -{ -return(g_Flags); -} - - diff --git a/libUseful-2.6/http.h b/libUseful-2.6/http.h deleted file mode 100755 index 0efe1b1..0000000 --- a/libUseful-2.6/http.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef LIBUSEFUL_HTTP_H -#define LIBUSEFUL_HTTP_H - -#include "includes.h" -#include "defines.h" -#include "file.h" - -#define HTTP_AUTH_BASIC 1 -#define HTTP_AUTH_DIGEST 2 -#define HTTP_AUTH_TOKEN 4 -#define HTTP_AUTH_OAUTH 8 -#define HTTP_AUTH_PROXY 64 -#define HTTP_AUTH_SENT 128 -#define HTTP_AUTH_RETURN 256 - - -#define HTTP_OKAY 0 -#define HTTP_NOCONNECT 1 -#define HTTP_NOTFOUND 2 -#define HTTP_REDIRECT 3 -#define HTTP_ERROR 4 -#define HTTP_CIRCULAR_REDIRECTS 5 -#define HTTP_NOTMODIFIED 6 - -#define HTTP_VER1_0 1 -#define HTTP_DEBUG 2 -#define HTTP_CHUNKED 4 -#define HTTP_NOCACHE 8 -#define HTTP_NOCOMPRESS 16 -#define HTTP_NOREDIRECT 32 -#define HTTP_TRY_HTTPS 64 -#define HTTP_REQ_HTTPS 128 -#define HTTP_KEEPALIVE 256 -#define HTTP_POSTARGS 512 -#define HTTP_SSL 1024 -#define HTTP_SSL_REWRITE 2048 -#define HTTP_PROXY 4096 -#define HTTP_TUNNEL 8192 -#define HTTP_NODECODE 32768 -#define HTTP_NOCOOKIES 65536 -#define HTTP_GZIP 1048576 -#define HTTP_DEFLATE 2097152 -#define HTTP_BZIP2 4194304 -#define HTTP_XZ 8388608 - - -#define HTTP_HEADERS_SENT 1 -#define HTTP_CLIENTDATA_SENT 2 -#define HTTP_HEADERS_READ 4 - -extern const char *HTTP_AUTH_BY_TOKEN; - - - -typedef struct -{ -char *Protocol; -char *Host; -int Port; -char *Method; -char *Doc; -char *Destination; -char *ResponseCode; -int Flags; -int AuthFlags; -int State; -char *RedirectPath; -char *PreviousRedirect; -char *ContentType; -char *Timestamp; -int ContentLength; -int Depth; -char *PostData; -char *PostContentType; -int PostContentLength; -char *Proxy; -time_t IfModifiedSince; -ListNode *ServerHeaders; -ListNode *CustomSendHeaders; -char *UserName; -char *Authorization; -char *ProxyAuthorization; -STREAM *S; -} HTTPInfoStruct; - -#ifdef __cplusplus -extern "C" { -#endif - -char *HTTPQuote(char *RetBuff, const char *Str); -char *HTTPQuoteChars(char *RetBuff, const char *Str, const char *CharList); -char *HTTPUnQuote(char *RetBuff, const char *Str); - -void HTTPSetVar(const char *Name, const char *Var); - - -void HTTPInfoDestroy(void *p_Info); -void HTTPInfoSetValues(HTTPInfoStruct *Info, const char *Host, int Port, const char *Logon, const char *Password, const char *Method, const char *Doc, const char *ContentType, int ContentLength); -void HTTPInfoSetAuth(HTTPInfoStruct *Auth, const char *Logon, const char *Password, int Type); -char *HTTPDigest(char *RetStr, const char *Method, const char *Logon, const char *Password, const char *Realm, const char *Doc, const char *Nonce); - -HTTPInfoStruct *HTTPInfoCreate(const char *Protocol, const char *Host, int Port, const char *Logon, const char *Password, const char *Method, const char *Doc, const char *ContentType, int ContentLength); - - -STREAM *HTTPConnect(HTTPInfoStruct *Info); -STREAM *HTTPTransact(HTTPInfoStruct *Info); -void HTTPInfoSetURL(HTTPInfoStruct *Info, const char *Method, const char *URL); -HTTPInfoStruct *HTTPInfoFromURL(const char *Method, const char *URL); -STREAM *HTTPMethod(const char *Method, const char *URL, const char *Logon, const char *Password, const char *ContentType, const char *ContentData, int ContentLength); -STREAM *HTTPGet(const char *URL, const char *Logon, const char *Password); -STREAM *HTTPPost(const char *URL, const char *Logon, const char *Password, const char *ContentType, const char *Content); -void HTTPSetUserAgent(char *AgentName); -void HTTPSetProxy(char *Proxy); -void HTTPSetFlags(int Flags); -int HTTPGetFlags(); - -char *HTTPReadDocument(char *RetStr, STREAM *S); -void HTTPCopyToSTREAM(STREAM *Con, STREAM *S); -int HTTPDownload(char *URL, char *Login, char *Password, STREAM *S); - -void HTTPClearCookies(); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/includes.h b/libUseful-2.6/includes.h deleted file mode 100755 index 0c8ab02..0000000 --- a/libUseful-2.6/includes.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef LIBUSEFUL_INCLUDES_H -#define LIBUSEFUL_INCLUDES_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "defines.h" -#include "string.h" -#include "list.h" -#include "file.h" -#include "socket.h" -#include "openssl.h" -#include "Vars.h" -#include "libsettings.h" -#include "GeneralFunctions.h" -#include "Tokenizer.h" - -#endif diff --git a/libUseful-2.6/inet.c b/libUseful-2.6/inet.c deleted file mode 100755 index 01037ef..0000000 --- a/libUseful-2.6/inet.c +++ /dev/null @@ -1,146 +0,0 @@ -#include "inet.h" -#include "http.h" -#include "GeneralFunctions.h" -#include "Markup.h" - -char *ExtractFromWebpage(char *RetStr, char *URL, char *ExtractStr, int MinLength) -{ -STREAM *S; -char *Tempstr=NULL, *ptr; -ListNode *Vars; - -Vars=ListCreate(); - -S=HTTPGet(URL,"",""); -if (S) -{ -Tempstr=STREAMReadLine(Tempstr,S); -while (Tempstr) -{ -StripTrailingWhitespace(Tempstr); -StripLeadingWhitespace(Tempstr); - -if (StrLen(Tempstr) >=MinLength) -{ - if (! StrLen(ExtractStr)) RetStr=CopyStr(RetStr,Tempstr); - else - { - ExtractVarsFromString(Tempstr,ExtractStr,Vars); - ptr=GetVar(Vars,"extract_item"); - if (StrLen(ptr)) RetStr=CopyStr(RetStr,ptr); - } -} -Tempstr=STREAMReadLine(Tempstr,S); -} -STREAMClose(S); -} - -ListDestroy(Vars,(LIST_ITEM_DESTROY_FUNC) DestroyString); -DestroyString(Tempstr); - -StripTrailingWhitespace(RetStr); -StripLeadingWhitespace(RetStr); - -return(RetStr); -} - - -char *GetExternalIP(char *RetStr) -{ -RetStr=CopyStr(RetStr,""); -if (! StrLen(RetStr)) RetStr=ExtractFromWebpage(RetStr,"http://checkip.dyndns.org", "Current IP Address: $(extract_item)",4); -if (! StrLen(RetStr)) RetStr=ExtractFromWebpage(RetStr,"http://ip.appspot.com/", "",4); - -return(RetStr); -} - -#define IPInfo_API_KEY "1261fcbf647ea02c165aa3bfa66810f0be453d8a1c2e7f653c0666d4e7e205f0" - -int IPInfoDBGeoLocate(char *IP, ListNode *Vars) -{ -STREAM *S=NULL; -char *ptr, *TagType=NULL, *TagData=NULL, *Tempstr=NULL, *Token=NULL; -const char *DesiredTags[]={"CountryCode","CountryName","City","RegionName","Latitude","Longitude","TimeZone",NULL}; -int result=FALSE; - -if (! IsIPAddress(IP)) Token=CopyStr(Token,LookupHostIP(IP)); -else Token=CopyStr(Token,IP); - -Tempstr=MCopyStr(Tempstr,"http://api.ipinfodb.com/v2/ip_query.php?key=",IPInfo_API_KEY,"&ip=",Token,"&timezone=true",NULL); - -S=HTTPGet(Tempstr, "", ""); -if (S) -{ - Tempstr=STREAMReadLine(Tempstr,S); - while (Tempstr) - { - ptr=XMLGetTag(Tempstr,NULL,&TagType,&TagData); - while (ptr) - { - if (MatchTokenFromList(TagType,DesiredTags,0) > -1) - { - //we can't re-use 'TagType', we still need it - ptr=XMLGetTag(ptr,NULL,&Token,&TagData); - SetVar(Vars,TagType,TagData); - result=TRUE; - } - ptr=XMLGetTag(ptr,NULL,&TagType,&TagData); - } - Tempstr=STREAMReadLine(Tempstr,S); - } -} - -STREAMClose(S); - -DestroyString(Tempstr); -DestroyString(Token); -DestroyString(TagType); -DestroyString(TagData); - -return(result); -} - - -int IPGeoLocate(const char *IP, ListNode *Vars) -{ -STREAM *S=NULL; -char *ptr, *Tempstr=NULL, *Token=NULL; -const char *DesiredTags[]={"CountryCode","CountryName","City","RegionName","Latitude","Longitude","TimeZone",NULL}; -int result=FALSE; - -printf("GEOZ: %s\n",IP); -if (! StrValid(IP)) return(FALSE); - -if (! IsIPAddress(IP)) Token=CopyStr(Token, LookupHostIP(IP)); -else Token=CopyStr(Token,IP); - -Tempstr=MCopyStr(Tempstr,"http://freegeoip.net/csv/",Token,NULL); - -S=HTTPGet(Tempstr, "", ""); -printf("GEOX: %d %s\n",S, Tempstr); -if (S) -{ - STREAMSetTimeout(S,100); - Tempstr=HTTPReadDocument(Tempstr,S); -printf("GEO2: %s\n",Tempstr); - ptr=GetToken(Tempstr, ",", &Token,0); //IP - ptr=GetToken(ptr, ",", &Token,0); //CountryCode - strlwr(Token); - SetVar(Vars,"CountryCode",Token); - ptr=GetToken(ptr, ",", &Token,0); //Country name - SetVar(Vars,"CountryName",Token); - ptr=GetToken(ptr, ",", &Token,0); //Region Code - ptr=GetToken(ptr, ",", &Token,0); //Region Name - SetVar(Vars,"RegionName",Token); - ptr=GetToken(ptr, ",", &Token,0); //City - SetVar(Vars,"City",Token); - STREAMClose(S); - result=TRUE; -} - - -DestroyString(Tempstr); -DestroyString(Token); - -return(result); -} diff --git a/libUseful-2.6/inet.h b/libUseful-2.6/inet.h deleted file mode 100755 index 472ced3..0000000 --- a/libUseful-2.6/inet.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LIBUSEFUL_INET_H -#define LIBUSEFUL_INET_H - -#include "includes.h" -#include "defines.h" - -#ifdef __cplusplus -extern "C" { -#endif - -char *ExtractFromWebpage(char *RetStr, char *URL, char *ExtractStr, int MinLength); -char *GetExternalIP(char *RetStr); -int IPGeoLocate(const char *IP, ListNode *Vars); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/install-sh b/libUseful-2.6/install-sh deleted file mode 100755 index e9de238..0000000 --- a/libUseful-2.6/install-sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/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=: - chmodcmd="" - 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 diff --git a/libUseful-2.6/jh_ref.c b/libUseful-2.6/jh_ref.c deleted file mode 100755 index bfe21ee..0000000 --- a/libUseful-2.6/jh_ref.c +++ /dev/null @@ -1,321 +0,0 @@ -#include "jh_ref.h" -#include - -/*The constant for the Round 0 of E8*/ -const unsigned char roundconstant_zero[64] = {0x6,0xa,0x0,0x9,0xe,0x6,0x6,0x7,0xf,0x3,0xb,0xc,0xc,0x9,0x0,0x8,0xb,0x2,0xf,0xb,0x1,0x3,0x6,0x6,0xe,0xa,0x9,0x5,0x7,0xd,0x3,0xe,0x3,0xa,0xd,0xe,0xc,0x1,0x7,0x5,0x1,0x2,0x7,0x7,0x5,0x0,0x9,0x9,0xd,0xa,0x2,0xf,0x5,0x9,0x0,0xb,0x0,0x6,0x6,0x7,0x3,0x2,0x2,0xa}; - -/*The two Sboxes S0 and S1*/ -unsigned char S[2][16] = {{9,0,4,11,13,12,3,15,1,10,2,6,7,5,8,14},{3,12,6,13,5,7,1,9,15,2,0,4,11,10,14,8}}; - -/*The linear transformation L, the MDS code*/ -#define L(a, b) { \ - (b) ^= ( ( (a) << 1) ^ ( (a) >> 3) ^ (( (a) >> 2) & 2) ) & 0xf; \ - (a) ^= ( ( (b) << 1) ^ ( (b) >> 3) ^ (( (b) >> 2) & 2) ) & 0xf; \ -} - -void R8(hashState *state); /* The round function of E8 */ -void update_roundconstant(hashState *state); /* Update the round constant of E8 */ -void E8_initialgroup(hashState *state); /* Grouping the state into 4-bit elements at the beginning of E8 */ -void E8_finaldegroup(hashState *state); /* Inverse of the grouping at the end of E8 */ -void E8(hashState *state); /* The bijective function E8 */ -void F8(hashState *state); /* The compression function F8 */ - -/*the round function of E8 */ -void R8(hashState *state) -{ - unsigned int i; - unsigned char tem[256],t; - unsigned char roundconstant_expanded[256]; /*the round constant expanded into 256 1-bit element;*/ - - /*expand the round constant into 256 one-bit element*/ - for (i = 0; i < 256; i++) { - roundconstant_expanded[i] = (state->roundconstant[i >> 2] >> (3 - (i & 3)) ) & 1; - } - - /*S box layer, each constant bit selects one Sbox from S0 and S1*/ - for (i = 0; i < 256; i++) { - tem[i] = S[roundconstant_expanded[i]][state->A[i]]; /*constant bits are used to determine which Sbox to use*/ - } - - /*MDS Layer*/ - for (i = 0; i < 256; i=i+2) L(tem[i], tem[i+1]); - - /*The following is the permuation layer P_8*/ - - /*initial swap Pi_8*/ - for ( i = 0; i < 256; i=i+4) { - t = tem[i+2]; - tem[i+2] = tem[i+3]; - tem[i+3] = t; - } - - /*permutation P'_8*/ - for (i = 0; i < 128; i=i+1) { - state->A[i] = tem[i<<1]; - state->A[i+128] = tem[(i<<1)+1]; - } - - /*final swap Phi_8*/ - for ( i = 128; i < 256; i=i+2) { - t = state->A[i]; - state->A[i] = state->A[i+1]; - state->A[i+1] = t; - } -} - - -/*The following function generates the next round constant from the current - round constant; R6 is used for generating round constants for E8, with - the round constants of R6 being set as 0; -*/ -void update_roundconstant(hashState *state) { - int i; - unsigned char tem[64],t; - - /*Sbox layer*/ - for (i = 0; i < 64; i++) tem[i] = S[0][state->roundconstant[i]]; - - /*MDS layer*/ - for (i = 0; i < 64; i=i+2) L(tem[i], tem[i+1]); - - /*The following is the permutation layer P_6 */ - - /*initial swap Pi_6*/ - for ( i = 0; i < 64; i=i+4) { - t = tem[i+2]; - tem[i+2] = tem[i+3]; - tem[i+3] = t; - } - - /*permutation P'_6*/ - for ( i = 0; i < 32; i=i+1) { - state->roundconstant[i] = tem[i<<1]; - state->roundconstant[i+32] = tem[(i<<1)+1]; - } - - /*final swap Phi_6*/ - for ( i = 32; i < 64; i=i+2 ) { - t = state->roundconstant[i]; - state->roundconstant[i] = state->roundconstant[i+1]; - state->roundconstant[i+1] = t; - } -} - -/*initial group at the begining of E_8: group the bits of H into 4-bit elements of A. - After the grouping, the i-th, (i+256)-th, (i+512)-th, (i+768)-th bits of state->H - become the i-th 4-bit element of state->A -*/ -void E8_initialgroup(hashState *state) { - unsigned int i; - unsigned char t0,t1,t2,t3; - unsigned char tem[256]; - - /*t0 is the i-th bit of H, i = 0, 1, 2, 3, ... , 127*/ - /*t1 is the (i+256)-th bit of H*/ - /*t2 is the (i+512)-th bit of H*/ - /*t3 is the (i+768)-th bit of H*/ - for (i = 0; i < 256; i++) { - t0 = (state->H[i>>3] >> (7 - (i & 7)) ) & 1; - t1 = (state->H[(i+256)>>3] >> (7 - (i & 7)) ) & 1; - t2 = (state->H[(i+ 512 )>>3] >> (7 - (i & 7)) ) & 1; - t3 = (state->H[(i+ 768 )>>3] >> (7 - (i & 7)) ) & 1; - tem[i] = (t0 << 3) | (t1 << 2) | (t2 << 1) | (t3 << 0); - } - /*padding the odd-th elements and even-th elements separately*/ - for (i = 0; i < 128; i++) { - state->A[i << 1] = tem[i]; - state->A[(i << 1)+1] = tem[i+128]; - } -} - -/*de-group at the end of E_8: it is the inverse of E8_initialgroup - The 256 4-bit elements in state->A are degouped into the 1024-bit state->H -*/ -void E8_finaldegroup(hashState *state) { - unsigned int i; - unsigned char t0,t1,t2,t3; - unsigned char tem[256]; - - for (i = 0; i < 128; i++) { - tem[i] = state->A[i << 1]; - tem[i+128] = state->A[(i << 1)+1]; - } - - for (i = 0; i < 128; i++) state->H[i] = 0; - - for (i = 0; i < 256; i++) { - t0 = (tem[i] >> 3) & 1; - t1 = (tem[i] >> 2) & 1; - t2 = (tem[i] >> 1) & 1; - t3 = (tem[i] >> 0) & 1; - - state->H[i>>3] |= t0 << (7 - (i & 7)); - state->H[(i + 256)>>3] |= t1 << (7 - (i & 7)); - state->H[(i + 512)>>3] |= t2 << (7 - (i & 7)); - state->H[(i + 768)>>3] |= t3 << (7 - (i & 7)); - } -} - -/*bijective function E8 */ -void E8(hashState *state) -{ - unsigned int i; - //unsigned char t0,t1,t2,t3; - //unsigned char tem[256]; - - /*initialize the round constant*/ - for (i = 0; i < 64; i++) state->roundconstant[i] = roundconstant_zero[i]; - - /*initial group at the begining of E_8: group the H value into 4-bit elements and store them in A */ - E8_initialgroup(state); - - /* 42 rounds */ - for (i = 0; i < 42; i++) { - R8(state); - update_roundconstant(state); - } - - /*de-group at the end of E_8: decompose the 4-bit elements of A into the 1024-bit H*/ - E8_finaldegroup(state); -} - -/* compression function F8 */ -void F8(hashState *state) -{ - unsigned int i; - - /*xor the message with the first half of H*/ - for (i = 0; i < 64; i++) state->H[i] ^= state->buffer[i]; - - /* Bijective function E8 */ - E8(state); - - /* xor the message with the last half of H */ - for (i = 0; i < 64; i++) state->H[i+64] ^= state->buffer[i]; -} - -/*before hashing a message, initialize the hash state as H0 */ -HashReturn JHInit(hashState *state, int hashbitlen) -{ - unsigned int i; - - state->databitlen = 0; - state->datasize_in_buffer = 0; - - state->hashbitlen = hashbitlen; - - for (i = 0; i < 64; i++) state->buffer[i] = 0; - for (i = 0; i < 128; i++) state->H[i] = 0; - - /*initialize the initial hash value of JH*/ - /*step 1: set H(-1) to the message digest size*/ - state->H[1] = hashbitlen & 0xff; - state->H[0] = (hashbitlen >> 8) & 0xff; - /*step 2: compute H0 from H(-1) with message M(0) being set as 0*/ - F8(state); - - return(SUCCESS); -} - -/*hash each 512-bit message block, except the last partial block*/ -HashReturn JHUpdate(hashState *state, const unsigned char *data, DataLength databitlen) -{ - DataLength index; /*the starting address of the data to be compressed*/ - - state->databitlen += databitlen; - index = 0; - - /*if there is remaining data in the buffer, fill it to a full message block first*/ - /*we assume that the size of the data in the buffer is the multiple of 8 bits if it is not at the end of a message*/ - - /*There is data in the buffer, but the incoming data is insufficient for a full block*/ - if ( (state->datasize_in_buffer > 0 ) && (( state->datasize_in_buffer + databitlen) < 512) ) { - if ( (databitlen & 7) == 0 ) { - memcpy(state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3)) ; - } - else memcpy(state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3)+1) ; - state->datasize_in_buffer += databitlen; - databitlen = 0; - } - - /*There is data in the buffer, and the incoming data is sufficient for a full block*/ - if ( (state->datasize_in_buffer > 0 ) && (( state->datasize_in_buffer + databitlen) >= 512) ) { - memcpy( state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3) ) ; - index = 64-(state->datasize_in_buffer >> 3); - databitlen = databitlen - (512 - state->datasize_in_buffer); - F8(state); - state->datasize_in_buffer = 0; - } - - /*hash the remaining full message blocks*/ - for ( ; databitlen >= 512; index = index+64, databitlen = databitlen - 512) { - memcpy(state->buffer, data+index, 64); - F8(state); - } - - /*store the partial block into buffer, assume that -- if part of the last byte is not part of the message, then that part consists of 0 bits*/ - if ( databitlen > 0) { - if ((databitlen & 7) == 0) - memcpy(state->buffer, data+index, (databitlen & 0x1ff) >> 3); - else - memcpy(state->buffer, data+index, ((databitlen & 0x1ff) >> 3)+1); - state->datasize_in_buffer = databitlen; - } - - return(SUCCESS); -} - - -/*padding the message, truncate the hash value H and obtain the message digest*/ -unsigned int JHFinal(hashState *state, unsigned char *hashval) -{ - unsigned int i, len=0; - - if ( (state->databitlen & 0x1ff) == 0) { - /*pad the message when databitlen is multiple of 512 bits, then process the padded block*/ - for (i = 0; i < 64; i++) state->buffer[i] = 0; - state->buffer[0] = 0x80; - state->buffer[63] = state->databitlen & 0xff; - state->buffer[62] = (state->databitlen >> 8) & 0xff; - state->buffer[61] = (state->databitlen >> 16) & 0xff; - state->buffer[60] = (state->databitlen >> 24) & 0xff; - state->buffer[59] = (state->databitlen >> 32) & 0xff; - state->buffer[58] = (state->databitlen >> 40) & 0xff; - state->buffer[57] = (state->databitlen >> 48) & 0xff; - state->buffer[56] = (state->databitlen >> 56) & 0xff; - F8(state); - } - else { - /*set the rest of the bytes in the buffer to 0*/ - if ( (state->datasize_in_buffer & 7) == 0) - for (i = (state->databitlen & 0x1ff) >> 3; i < 64; i++) state->buffer[i] = 0; - else - for (i = ((state->databitlen & 0x1ff) >> 3)+1; i < 64; i++) state->buffer[i] = 0; - - /*pad and process the partial block when databitlen is not multiple of 512 bits, then hash the padded blocks*/ - state->buffer[((state->databitlen & 0x1ff) >> 3)] |= 1 << (7- (state->databitlen & 7)); - F8(state); - for (i = 0; i < 64; i++) state->buffer[i] = 0; - state->buffer[63] = state->databitlen & 0xff; - state->buffer[62] = (state->databitlen >> 8) & 0xff; - state->buffer[61] = (state->databitlen >> 16) & 0xff; - state->buffer[60] = (state->databitlen >> 24) & 0xff; - state->buffer[59] = (state->databitlen >> 32) & 0xff; - state->buffer[58] = (state->databitlen >> 40) & 0xff; - state->buffer[57] = (state->databitlen >> 48) & 0xff; - state->buffer[56] = (state->databitlen >> 56) & 0xff; - F8(state); - } - - /*truncating the final hash value to generate the message digest*/ - switch (state->hashbitlen) { - case 224: len=28; memcpy(hashval,state->H+100,len); break; - case 256: len=32; memcpy(hashval,state->H+96, len); break; - case 384: len=48; memcpy(hashval,state->H+80, len); break; - case 512: len=64; memcpy(hashval,state->H+64, len); break; - } - - return(len); -} - - diff --git a/libUseful-2.6/jh_ref.h b/libUseful-2.6/jh_ref.h deleted file mode 100755 index 2eaf552..0000000 --- a/libUseful-2.6/jh_ref.h +++ /dev/null @@ -1,39 +0,0 @@ -/* This program gives the reference implementation of JH. - It implements the standard description of JH (not bitslice) - The description given in this program is suitable for hardware implementation - - -------------------------------- - Comparing to the original reference implementation, - two functions are added to make the porgram more readable. - One function is E8_initialgroup() at the beginning of E8; - another function is E8_finaldegroup() at the end of E8. - - -------------------------------- - - Last Modified: January 16, 2011 -*/ - - -#ifndef JH_HASH_H -#define JH_HASH_H - - -typedef unsigned long long DataLength;typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn; - -typedef struct { - int hashbitlen; /*the message digest size*/ - unsigned long long databitlen; /*the message size in bits*/ - unsigned long long datasize_in_buffer; /*the size of the message remained in buffer; assumed to be multiple of 8bits except for the last partial block at the end of the message*/ - unsigned char H[128]; /*the hash value H; 128 bytes;*/ - unsigned char A[256]; /*the temporary round value; 256 4-bit elements*/ - unsigned char roundconstant[64]; /*round constant for one round; 64 4-bit elements*/ - unsigned char buffer[64]; /*the message block to be hashed; 64 bytes*/ -} hashState; - -/*The API functions*/ -HashReturn JHInit(hashState *state, int hashbitlen); -HashReturn JHUpdate(hashState *state, const unsigned char *data, DataLength databitlen); -unsigned int JHFinal(hashState *state, unsigned char *hashval); - - -#endif diff --git a/libUseful-2.6/libUseful.h b/libUseful-2.6/libUseful.h deleted file mode 100755 index 145c45a..0000000 --- a/libUseful-2.6/libUseful.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef LIB_USEFUL_H -#define LIB_USEFUL_H - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#define __LIBUSEFUL_VERSION__ "2.0" -#define __LIBUSEFUL_BUILD_DATE__ __DATE__ -#define __LIBUSEFUL_BUILD_TIME__ __TIME__ - -//__TIME__ - -#include -#include -#include -#include -#include "memory.h" -#include "socket.h" -#include "unix_socket.h" -#include "string.h" -#include "expect.h" -#include "list.h" -#include "file.h" -#include "base64.h" -#include "Tokenizer.h" -#include "FileSystem.h" -#include "GeneralFunctions.h" -#include "DataProcessing.h" -#include "EncryptedFiles.h" -#include "ConnectManager.h" -#include "Hash.h" -#include "Compression.h" -#include "Time.h" -#include "Vars.h" -#include "Markup.h" -#include "MathExpr.h" -#include "PatternMatch.h" -#include "SpawnPrograms.h" -#include "MessageBus.h" -#include "ParseURL.h" -#include "sound.h" -#include "pty.h" -#include "Log.h" -#include "http.h" -#include "oauth.h" -#include "tar.h" -#include "ansi.h" -#include "proctitle.h" -#include "securemem.h" - -#endif diff --git a/libUseful-2.6/libsettings.c b/libUseful-2.6/libsettings.c deleted file mode 100755 index 3fef58f..0000000 --- a/libUseful-2.6/libsettings.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "defines.h" -#include "includes.h" -#include "Vars.h" -#include "libUseful.h" - -/* These functions provide an interface for setting variables that */ -/* are used by libUseful itself */ - -ListNode *LibUsefulSettings=NULL; - -ListNode *LibUsefulValuesGetHead() -{ -return(LibUsefulSettings); -} - -void LibUsefulInitSettings() -{ -char *Tempstr=NULL; - - LibUsefulSettings=ListCreate(); - SetVar(LibUsefulSettings,"LibUsefulVersion",__LIBUSEFUL_VERSION__); - Tempstr=MCopyStr(Tempstr,__LIBUSEFUL_BUILD_DATE__," ",__LIBUSEFUL_BUILD_TIME__,NULL); - SetVar(LibUsefulSettings,"LibUsefulBuildTime",Tempstr); - DestroyString(Tempstr); -} - - -void LibUsefulSetValue(char *Name, char *Value) -{ - if (! LibUsefulSettings) LibUsefulInitSettings(); - SetVar(LibUsefulSettings,Name,Value); -} - -char *LibUsefulGetValue(char *Name) -{ -if (! LibUsefulSettings) LibUsefulInitSettings(); - -if (!StrLen(Name)) return(""); -return(GetVar(LibUsefulSettings,Name)); -} - diff --git a/libUseful-2.6/libsettings.h b/libUseful-2.6/libsettings.h deleted file mode 100755 index 55a4ec0..0000000 --- a/libUseful-2.6/libsettings.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef LIBUSEFUL_SETTINGS -#define LIBUSEFUL_SETTINGS - -#include "Vars.h" - -/* These functions provide an interface for setting variables that */ -/* are used by libUseful itself */ - -#ifdef __cplusplus -extern "C" { -#endif - -ListNode *LibUsefulValuesGetHead(); -void LibUsefulSetValue(char *Name, char *Value); -char *LibUsefulGetValue(char *Name); - -#ifdef __cplusplus -}; -#endif - - -#endif diff --git a/libUseful-2.6/list.c b/libUseful-2.6/list.c deleted file mode 100755 index df13e88..0000000 --- a/libUseful-2.6/list.c +++ /dev/null @@ -1,691 +0,0 @@ -#include "includes.h" -#include "Time.h" - - - -ListNode *ListGetHead(ListNode *Node) -{ -if (! Node) return(NULL); -return(Node->Head); -} - - - -int ListSize(ListNode *List) -{ -ListNode *Head; -int *intptr; - -if (! List) return(0); -Head=ListGetHead(List); -intptr=(int *) Head->Item; - -return(*intptr); - -} - - -void ListSetFlags(ListNode *List, int Flags) -{ -ListNode *Head; - -Head=ListGetHead(List); -Head->Flags=Flags; -} - - -int ListSetNoOfItems(ListNode *LastItem, int val) -{ -ListNode *Head; -int *intptr; - -Head=ListGetHead(LastItem); -if (LastItem->Next==NULL) - Head->Prev=LastItem; /* The head Item has its Prev as being the last item! */ -intptr=(int *) Head->Item; -(*intptr)=val; - -return(*intptr); -} - - - -int ListIncrNoOfItems(ListNode *LastItem) -{ -ListNode *Head; -int *intptr; - -Head=ListGetHead(LastItem); -if (LastItem->Next==NULL) - Head->Prev=LastItem; /* The head Item has its Prev as being the last item! */ -intptr=(int *) Head->Item; -(*intptr)++; - -return(*intptr); -} - -int ListDecrNoOfItems(ListNode *LastItem) -{ -ListNode *Head; -int *intptr; - -Head=ListGetHead(LastItem); -if (LastItem->Next==NULL) Head->Prev=LastItem->Prev; /* The head Item has its Prev as being the last item! */ -intptr=(int *) Head->Item; -(*intptr)--; -return(*intptr); -} - - -ListNode *ListCreate() -{ -ListNode *TempPtr; - -TempPtr=(ListNode *)calloc(1,sizeof(ListNode)); -TempPtr->Head=TempPtr; -TempPtr->Prev=TempPtr; -TempPtr->Next=NULL; -TempPtr->Item=calloc(1,sizeof(int)); - -(*(int *)TempPtr->Item)=0; -return(TempPtr); -} - -void ListClear(ListNode *ListStart, LIST_ITEM_DESTROY_FUNC ItemDestroyer) -{ - ListNode *Curr,*Next; - - if (! ListStart) return; - Curr=ListGetNext(ListStart); - while (Curr !=NULL) - { - Next=Curr->Next; - if (ItemDestroyer && Curr->Item) ItemDestroyer(Curr->Item); - DestroyString(Curr->Tag); - free(Curr); - Curr=Next; - } -ListStart->Next=NULL; -ListStart->Head=ListStart; -ListStart->Prev=ListStart; -ListSetNoOfItems(ListStart,0); -} - -void ListDestroy(ListNode *ListStart, LIST_ITEM_DESTROY_FUNC ItemDestroyer) -{ - if (! ListStart) return; - ListClear(ListStart, ItemDestroyer); - free(ListStart->Item); - free(ListStart); -} - - -void ListAppendItems(ListNode *Dest, ListNode *Src, LIST_ITEM_CLONE_FUNC ItemCloner) -{ - ListNode *Curr; - void *Item; - - Curr=ListGetNext(Src); - while (Curr !=NULL) - { - if (ItemCloner) - { - Item=ItemCloner(Curr->Item); - ListAddNamedItem(Dest,Curr->Tag,Item); - } - else ListAddNamedItem(Dest, Curr->Tag, Curr->Item); - Curr=ListGetNext(Curr); - } -} - - -ListNode *ListClone(ListNode *ListStart, LIST_ITEM_CLONE_FUNC ItemCloner) -{ - ListNode *NewList; - - NewList=ListCreate(); - - ListAppendItems(NewList, ListStart, ItemCloner); - return(NewList); -} - -ListNode *ListAddNamedItemAfter(ListNode *ListStart,const char *Name,void *Item) -{ -ListNode *Curr; - -if (ListStart==NULL) return(NULL); - -Curr=ListStart; -Curr->Next=(ListNode *) calloc(1,sizeof(ListNode)); -Curr->Next->Prev=Curr; -Curr=Curr->Next; -Curr->Item=Item; -Curr->Head=ListGetHead(ListStart); -Curr->Next=NULL; -if (Name) Curr->Tag=CopyStr(NULL,Name); -Curr->Time=GetTime(TIME_CACHED); - -ListIncrNoOfItems(Curr); -return(Curr); -} - - - -ListNode *ListAddNamedItem(ListNode *ListStart,const char *Name,void *Item) -{ -ListNode *Curr; - -Curr=ListGetLast(ListStart); -if (Curr==NULL) return(Curr); -return(ListAddNamedItemAfter(Curr,Name,Item)); -} - - - -ListNode *ListAddItem(ListNode *ListStart,void *Item) -{ -return(ListAddNamedItem(ListStart,NULL,Item)); -} - -void ListUnthreadNode(ListNode *Node) -{ -ListNode *Prev, *Next; - -Prev=Node->Prev; -Next=Node->Next; -if (Prev) Prev->Next=Next; -if (Next) Next->Prev=Prev; -} - -void ListThreadNode(ListNode *Prev, ListNode *Node) -{ -ListNode *Next; - -//Never thread something to itself! -if (Prev==Node) return; - -Next=Prev->Next; -Node->Prev=Prev; -Prev->Next=Node; -Node->Next=Next; -if (Next) Next->Prev=Node; /* Next might be NULL! */ -} - - -ListNode *ListInsertNamedItem(ListNode *InsertNode, const char *Name, void *Item) -{ -ListNode *NewItem, *Next; - -Next=InsertNode->Next; -NewItem=(ListNode *) calloc(1,sizeof(ListNode)); -NewItem->Item=Item; -NewItem->Prev=InsertNode; -NewItem->Next=Next; -NewItem->Head=InsertNode->Head; -InsertNode->Next=NewItem; -if (Next) Next->Prev=NewItem; /* Next might be NULL! */ -ListIncrNoOfItems(NewItem); -if (StrLen(Name)) NewItem->Tag=CopyStr(NewItem->Tag,Name); -NewItem->Time=GetTime(TIME_CACHED); - -return(NewItem); -} - - -void OrderedListAddJump(ListNode *From, ListNode *To) -{ -int result; -static int depth=0; - -if (! From) return; -if (! To) return; - -depth++; -if (depth > 100) -{ - printf("ERROR: OLJ DEEEP\n"); - exit(1); -} - -if (From->Jump) -{ - result=strcmp(From->Jump->Tag, To->Tag); -// if (result > 0) OrderedListAddJump(From->Next,To); -// else - if (result < 0) - { - OrderedListAddJump(From->Next,From->Jump); - From->Jump=To; - } -} -else From->Jump=To; - -depth--; -} - - - -ListNode *ListFindNamedItemInsert(ListNode *Head, const char *Name) -{ -ListNode *Prev, *Curr, *Start=NULL; -int result=0, count=0; -int hops=0, jumps=0, miss=0; - -if (! Head) return(Head); -if (! StrLen(Name)) return(Head); -Curr=ListGetNext(Head); -if (! Curr) return(Head); - -//Check last item in list -Prev=Head->Prev; -if (Prev && (Prev != Head) && Prev->Tag) -{ - if (Head->Flags & LIST_FLAG_CASE) result=strcmp(Prev->Tag,Name); - else result=strcasecmp(Prev->Tag,Name); - - if ((Head->Flags & LIST_FLAG_ORDERED) && (result < 1)) return(Prev); -} - -/* -if ((Head->Flags & LIST_FLAG_CACHE) && (Head->Jump)) -{ - Prev=Head->Jump; - if (Prev->Tag) - { - if (Head->Flags & LIST_FLAG_CASE) result=strcmp(Prev->Tag,Name); - else result=strcasecmp(Prev->Tag,Name); - if (result < 1) Curr=Prev; - } -} -*/ - - -Prev=Head; -while (Curr) -{ - if (Curr->Jump && Curr->Jump->Tag) - { - if (Head->Flags & LIST_FLAG_CASE) result=strcmp(Curr->Jump->Tag,Name); - else result=strcasecmp(Curr->Jump->Tag,Name); - if (result < 1) - { - if ((result < 0) && Curr->Jump->Next) Curr->Jump=Curr->Jump->Next; - Curr=Curr->Jump; - jumps++; - count=0; - } - else miss++; - } else if (! Start) Start=Curr; - - if (Curr->Tag) - { - if (Head->Flags & LIST_FLAG_CASE) result=strcmp(Curr->Tag,Name); - else result=strcasecmp(Curr->Tag,Name); - - if (result==0) - { - if (Head->Flags & LIST_FLAG_SELFORG) ListSwapItems(Curr->Prev, Curr); - if (Head->Flags & LIST_FLAG_CACHE) Head->Jump=Curr; - return(Curr); - } - if ((result > 0) && (Head->Flags & LIST_FLAG_ORDERED)) - { - return(Prev); - } - } - -hops++; -count++; - - - Prev=Curr; - Curr=ListGetNext(Curr); -} - -return(Prev); -} - - - -ListNode *ListFindNamedItem(ListNode *Head, const char *Name) -{ - ListNode *Node; - int result; - - Node=ListFindNamedItemInsert(Head, Name); - if ((! Node) || (Node==Head) || (! Node->Tag)) return(NULL); - if (Head->Flags & LIST_FLAG_CASE) result=strcmp(Node->Tag,Name); - else result=strcasecmp(Node->Tag,Name); - - if (result==0) - { - Node->Hits++; - return(Node); - } - return(NULL); -} - - -ListNode *OrderedListAddNamedItem(ListNode *Head, const char *Name, void *Item) -{ -ListNode *NewItem, *Prev; - -Prev=ListFindNamedItemInsert(Head, Name); -NewItem=(ListNode *) calloc(1,sizeof(ListNode)); -NewItem->Item=Item; -NewItem->Prev=Prev; -NewItem->Next=Prev->Next; -Prev->Next=NewItem; -NewItem->Head=Prev->Head; -if (NewItem->Next) NewItem->Next->Prev=NewItem; /* Next might be NULL! */ -ListIncrNoOfItems(NewItem); -if (StrLen(Name)) NewItem->Tag=CopyStr(NewItem->Tag,Name); -NewItem->Time=GetTime(TIME_CACHED); - -return(NewItem); -} - - - -ListNode *ListInsertItem(ListNode *InsertNode, void *Item) -{ -return(ListInsertNamedItem(InsertNode, NULL, Item)); -} - - -ListNode *InsertItemIntoSortedList(ListNode *List, void *Item, int (*LessThanFunc)(void *, void *, void *)) -{ -ListNode *Curr, *Prev; - -Prev=List; -Curr=ListGetNext(Prev); -while (Curr && (LessThanFunc(NULL, Curr->Item,Item)) ) -{ -Prev=Curr; -Curr=ListGetNext(Prev); -} - -return(ListInsertItem(Prev,Item)); -} - - -ListNode *ListGetNext(ListNode *CurrItem) -{ -if (CurrItem !=NULL) return(CurrItem->Next); -else return(NULL); -} - -ListNode *ListGetPrev(ListNode *CurrItem) -{ -ListNode *Prev; -if (CurrItem !=NULL) -{ -Prev=CurrItem->Prev; -/* Don't return the dummy header! */ -if (Prev && (Prev->Prev !=NULL) && (Prev != Prev->Head)) return(Prev); -else return(NULL); -} -else return(NULL); -} - - -ListNode *ListGetLast(ListNode *CurrItem) -{ -ListNode *Head; - - -Head=ListGetHead(CurrItem); -if (! Head) return(CurrItem); -/* the dummy header has a 'Prev' entry that points to the last item! */ -return(Head->Prev); -} - - - -ListNode *ListGetNth(ListNode *Head, int n) -{ -ListNode *Curr; -int count=0; - -if (! Head) return(NULL); - -Curr=ListGetNext(Head); -while (Curr && (count < n)) -{ - count++; - Curr=ListGetNext(Curr); -} -if (count < n) return(NULL); -return(Curr); -} - - - -void *IndexArrayOnList(ListNode *ListHead) -{ -ListNode *Curr; -int count, list_size; -void **PtrArray; - -Curr=ListGetNext(ListHead); /* Skip past empty list 'header' item */ -list_size=0; -while (Curr !=NULL) -{ -Curr=ListGetNext(Curr); -list_size++; -} -PtrArray=calloc(list_size+1,sizeof(void *)); - -Curr=ListGetNext(ListHead); /* All lists have a dummy header, remember? */ -for (count=0;count < list_size; count++) -{ -PtrArray[count]=Curr->Item; -Curr=ListGetNext(Curr); - -} -PtrArray[count]=NULL; -return(PtrArray); - -} - - -void *AddItemToArray(void *Array,int size, void *Item) -{ -void **PtrArray; - - -/* two more than number of items in array, one is the new item, and*/ -/* one is the terminating null */ -PtrArray=Array; -PtrArray=realloc(PtrArray, (size+2) *sizeof(void *)); - -PtrArray[size]=Item; -PtrArray[size+1]=NULL; -return(PtrArray); -} - -void *DeleteItemFromArray(void *Array,int size, int ItemNo) -{ -int count; -void **PtrArray; - - -/* two more than number of items in array, one is the new item, and*/ -/* one is the terminating null */ -PtrArray=Array; - -/* size is actually number of items in array, hence size+1 is the */ -/* terminating null. So we include that in the copy */ -for (count=ItemNo; count < (size+1); count++) -{ -PtrArray[count]=PtrArray[count+1]; -} - -PtrArray=realloc(PtrArray, (size+1) *sizeof(void *)); -return(PtrArray); -} - - - - -ListNode *ListJoin(ListNode *List1, ListNode *List2) -{ -ListNode *Curr, *StartOfList2; - -Curr=List1; -/*Lists all have a dummy header!*/ -StartOfList2=List2->Next; - -while (Curr->Next !=NULL) Curr=Curr->Next; -Curr->Next=StartOfList2; -StartOfList2->Prev=Curr; - -while (Curr->Next !=NULL) Curr=Curr->Next; -return(Curr); -} - - -//Item1 is before Item2! -void ListSwapItems(ListNode *Item1, ListNode *Item2) -{ -ListNode *Head, *Prev, *Next; - -if (! Item1) return; -if (! Item2) return; -Head=ListGetHead(Item1); -if (Head==Item1) return; -if (Head==Item2) return; - -Prev=Item1->Prev; -Next=Item2->Next; - -if (Head->Next==Item1) Head->Next=Item2; -if (Head->Prev==Item1) Head->Prev=Item2; - -if (Prev) Prev->Next=Item2; -Item1->Prev=Item2; -Item1->Next=Next; - -if (Next) Next->Prev=Item1; -Item2->Prev=Prev; -Item2->Next=Item1; - -} - - -void ListSort(ListNode *List, void *Data, int (*LessThanFunc)(void *, void *, void *)) -{ -ListNode *Curr=NULL, *Prev=NULL; -int sorted=0; - -while (! sorted) -{ - sorted=1; - Prev=NULL; - Curr=ListGetNext(List); - while (Curr) - { - if (Prev !=NULL) - { - if ( (*LessThanFunc)(Data,Curr->Item,Prev->Item) ) - { - sorted=0; - ListSwapItems(Prev,Curr); - } - } - Prev=Curr; - Curr=ListGetNext(Curr); - } -} - -} - -void ListSortNamedItems(ListNode *List) -{ -ListNode *Curr=NULL, *Prev=NULL; -int sorted=0; - -while (! sorted) -{ - sorted=1; - Prev=NULL; - Curr=ListGetNext(List); - while (Curr) - { - if (Prev !=NULL) - { - if (strcmp(Prev->Tag,Curr->Tag) < 0) - { - sorted=0; - ListSwapItems(Prev,Curr); - } - } - - Prev=Curr; - Curr=ListGetNext(Curr); - } -} - -} - - - - - -ListNode *ListFindItem(ListNode *Head, void *Item) -{ -ListNode *Curr; - -if (! Item) return(NULL); -Curr=ListGetNext(Head); -while (Curr) -{ - if (Curr->Item==Item) - { - if (Head->Flags & LIST_FLAG_SELFORG) ListSwapItems(Curr->Prev, Curr); - return(Curr); - } - Curr=ListGetNext(Curr); -} -return(Curr); -} - - -void *ListDeleteNode(ListNode *Node) -{ -ListNode *Head, *Prev, *Next; -void *Contents; - -if (Node==NULL) -{ - return(NULL); -} - -Head=ListGetHead(Node); -Prev=Node->Prev; -Next=Node->Next; -if (Prev !=NULL) Prev->Next=Next; -if (Next !=NULL) Next->Prev=Prev; -if (Head->Next==Node) Head->Next=Next; -if (Head->Prev==Node) Head->Prev=Prev; - -Contents=Node->Item; - -ListDecrNoOfItems(Node); -DestroyString(Node->Tag); -free(Node); -return(Contents); -} - - -void *ListDeleteItem(ListNode *Head, void *Item) -{ -ListNode *Node; - -Node=ListFindItem(Head, Item); -if (Node) ListDeleteNode(Node); - -return(NULL); -} - - diff --git a/libUseful-2.6/list.h b/libUseful-2.6/list.h deleted file mode 100755 index 1db2d1c..0000000 --- a/libUseful-2.6/list.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef LIB_USEFUL_LIST -#define LIB_USEFUL_LIST - -#include - -#define LIST_FLAG_DELETE 1 -#define LIST_FLAG_CASE 2 -#define LIST_FLAG_SELFORG 4 -#define LIST_FLAG_ORDERED 8 -#define LIST_FLAG_CACHE 16 -#define LIST_FLAG_TIMEOUT 32 -#define LIST_FLAG_DEBUG 8192 - -#define LIST_FLAG_USER1 1048576 -#define LIST_FLAG_USER2 2097152 -#define LIST_FLAG_USER3 4194304 -#define LIST_FLAG_USER4 8388608 -#define LIST_FLAG_USER5 16777216 -#define LIST_FLAG_USER6 33554432 -#define LIST_FLAG_USER7 67108864 -#define LIST_FLAG_USER8 134217728 -#define LIST_FLAG_USER0 268435456 -#define LIST_FLAG_USERA 536870912 -#define LIST_FLAG_USERB 1073741824 -#define LIST_FLAG_USERC 2147483648 -#define LIST_FLAG_USERD 4294967296 - - -typedef struct lnode -{ -unsigned int ItemType; -unsigned int Flags; -char *Tag; -void *Item; -struct lnode *Head; -struct lnode *Jump; -struct lnode *Prev; -struct lnode *Next; -unsigned int Hits; -time_t Time; -} ListNode; - - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef void (*LIST_ITEM_DESTROY_FUNC)(void *); -typedef void *(*LIST_ITEM_CLONE_FUNC)(void *); - - -ListNode *ListCreate(); -void ListSetFlags(ListNode *List, int Flags); - -void *IndexArrayOnList(ListNode *); -void *AddItemToArray(void *Array,int size, void *Item); -void *DeleteItemFromArray(void *Array,int size, int ItemNo); -void ListDestroy(ListNode *, LIST_ITEM_DESTROY_FUNC); -void ListClear(ListNode *, LIST_ITEM_DESTROY_FUNC); -ListNode *ListAddItem(ListNode *,void *); -ListNode *ListAddNamedItem(ListNode *, const char *Name, void *); -ListNode *ListInsertItem(ListNode *,void *); -ListNode *ListInsertNamedItem(ListNode *,const char *,void *); -ListNode *OrderedListAddNamedItem(ListNode *Head, const char *Name, void *Item); -ListNode *SortedListInsertItem(ListNode *, void *, int (*LessThanFunc)(void *, void *, void *)); -ListNode *ListAddNamedItemAfter(ListNode *ListStart,const char *Name,void *Item); -ListNode *ListGetNext(ListNode *); -ListNode *ListGetPrev(ListNode *); -ListNode *ListGetHead(ListNode *); -ListNode *ListGetLast(ListNode *); -ListNode *ListGetNth(ListNode *Head, int n); -ListNode *ListFindNamedItemInsert(ListNode *Head, const char *Name); -ListNode *ListFindNamedItem(ListNode *Head, const char *Name); -ListNode *ListFindItem(ListNode *Head, void *Item); -ListNode *ListJoin(ListNode *, ListNode *); -ListNode *ListClone(ListNode *, LIST_ITEM_CLONE_FUNC); -void ListAppendItems(ListNode *Dest, ListNode *Src, LIST_ITEM_CLONE_FUNC ItemCloner); -void ListSort(ListNode *, void *Data, int (*LessThanFunc)(void *, void *, void *)); -void ListSortNamedItems(ListNode *List); - -void *ListDeleteNode(ListNode *); -void *ListDeleteItem(ListNode *Head, void *Item); - -void ListSwapItems(ListNode *, ListNode *); -int ListSize(ListNode *); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/md5-global.h b/libUseful-2.6/md5-global.h deleted file mode 100755 index 22c5684..0000000 --- a/libUseful-2.6/md5-global.h +++ /dev/null @@ -1,32 +0,0 @@ -/* GLOBAL.H - RSAREF types and constants - */ - -/* PROTOTYPES should be set to one if and only if the compiler supports - function argument prototyping. -The following makes PROTOTYPES default to 0 if it has not already - - been defined with C compiler flags. - */ -#ifndef PROTOTYPES -#define PROTOTYPES 0 -#endif - -/* POINTER defines a generic pointer type */ -typedef unsigned char *POINTER; - -/* UINT2 defines a two byte word */ -typedef unsigned short int UINT2; - -/* UINT4 defines a four byte word */ -typedef unsigned long int UINT4; - -/* PROTO_LIST is defined depending on how PROTOTYPES is defined above. -If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it - returns an empty list. - */ -#if PROTOTYPES -#define PROTO_LIST(list) list -#else -#define PROTO_LIST(list) () -#endif - diff --git a/libUseful-2.6/md5.h b/libUseful-2.6/md5.h deleted file mode 100755 index e810f03..0000000 --- a/libUseful-2.6/md5.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MD5_H -#define MD5_H -#ifndef HEADER_MD5_H -/* Try to avoid clashes with OpenSSL */ -#define HEADER_MD5_H -#endif - -#include - -struct MD5Context { - uint32_t buf[4]; - uint32_t bits[2]; - unsigned char in[64]; -}; - -void MD5Init(struct MD5Context *context); -void MD5Update(struct MD5Context *context, unsigned char const *buf, - unsigned len); -void MD5Final(unsigned char digest[16], struct MD5Context *context); -void MD5Transform(uint32_t buf[4], uint32_t const in[16]); - -/* - * This is needed to make RSAREF happy on some MS-DOS compilers. - */ -typedef struct MD5Context MD5_CTX; - -#endif /* !MD5_H */ diff --git a/libUseful-2.6/md5c.c b/libUseful-2.6/md5c.c deleted file mode 100755 index ada7ac5..0000000 --- a/libUseful-2.6/md5c.c +++ /dev/null @@ -1,248 +0,0 @@ -/* This MD5 implmentation is taken from fetchmail, and is declared as - in the public domain in the COPYING file that comes with fetchmail -*/ - - -/* - * This code implements the MD5 message-digest algorithm. - * The algorithm is due to Ron Rivest. This code was - * written by Colin Plumb in 1993, no copyright is claimed. - * This code is in the public domain; do with it what you wish. - * - * Equivalent code is available from RSA Data Security, Inc. - * This code has been tested against that, and is equivalent, - * except that you don't need to include two pages of legalese - * with every copy. - * - * To compute the message digest of a chunk of bytes, declare an - * MD5Context structure, pass it to MD5Init, call MD5Update as - * needed on buffers full of bytes, and then call MD5Final, which - * will fill a supplied 16-byte array with the digest. - */ - -#include "md5.h" -#ifdef HAVE_STRING_H -#include /* memmove */ -#endif - -/* - * Note: this code is harmless on little-endian machines. - */ -static void byteReverse(unsigned char *buf, unsigned longs) -{ - uint32_t t; - do { - t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 | - ((unsigned) buf[1] << 8 | buf[0]); - *(uint32_t *) buf = t; - buf += 4; - } while (--longs); -} - -/* - * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious - * initialization constants. - */ -void MD5Init(struct MD5Context *ctx) -{ - ctx->buf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; - - ctx->bits[0] = 0; - ctx->bits[1] = 0; -} - -/* - * Update context to reflect the concatenation of another buffer full - * of bytes. - */ -void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len) -{ - register uint32_t t; - - /* Update bitcount */ - - t = ctx->bits[0]; - if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t) - ctx->bits[1]++; /* Carry from low to high */ - ctx->bits[1] += len >> 29; - - t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ - - /* Handle any leading odd-sized chunks */ - - if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; - - t = 64 - t; - if (len < t) { - memmove(p, buf, len); - return; - } - memmove(p, buf, t); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - buf += t; - len -= t; - } - /* Process data in 64-byte chunks */ - - while (len >= 64) { - memmove(ctx->in, buf, 64); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - - memmove(ctx->in, buf, len); -} - -/* - * Final wrapup - pad to 64-byte boundary with the bit pattern - * 1 0* (64-bit count of bits processed, MSB-first) - */ -void MD5Final(unsigned char digest[16], struct MD5Context *ctx) -{ - unsigned int count; - unsigned char *p; - - /* Compute number of bytes mod 64 */ - count = (ctx->bits[0] >> 3) & 0x3F; - - /* Set the first char of padding to 0x80. This is safe since there is - always at least one byte free */ - p = ctx->in + count; - *p++ = 0x80; - - /* Bytes of padding needed to make 64 bytes */ - count = 64 - 1 - count; - - /* Pad out to 56 mod 64 */ - if (count < 8) { - /* Two lots of padding: Pad the first block to 64 bytes */ - memset(p, 0, count); - byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - - /* Now fill the next block with 56 bytes */ - memset(ctx->in, 0, 56); - } else { - /* Pad block to 56 bytes */ - memset(p, 0, count - 8); - } - byteReverse(ctx->in, 14); - - /* Append length in bits and transform */ - ((uint32_t *) ctx->in)[14] = ctx->bits[0]; - ((uint32_t *) ctx->in)[15] = ctx->bits[1]; - - MD5Transform(ctx->buf, (uint32_t *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); - memmove(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ -} - -/* The four core functions - F1 is optimized somewhat */ - -/* #define F1(x, y, z) (x & y | ~x & z) */ -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) - -/* - * The core of the MD5 algorithm, this alters an existing MD5 hash to - * reflect the addition of 16 longwords of new data. MD5Update blocks - * the data and converts bytes into longwords for this routine. - */ -void MD5Transform(uint32_t buf[4], uint32_t const in[16]) -{ - register uint32_t a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} diff --git a/libUseful-2.6/mmap.c b/libUseful-2.6/mmap.c deleted file mode 100755 index 18afdb3..0000000 --- a/libUseful-2.6/mmap.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "libUseful.h" - -main() -{ -STREAM *S; -char *Tempstr=NULL; - -S=STREAMOpenFile("/etc/services",SF_RDONLY | SF_MMAP); -Tempstr=STREAMReadLine(Tempstr, S); -while (Tempstr) -{ -printf("%s",Tempstr); -Tempstr=STREAMReadLine(Tempstr, S); -} - -DestroyString(Tempstr); -} diff --git a/libUseful-2.6/mmap.exe b/libUseful-2.6/mmap.exe deleted file mode 100755 index 19ccc34..0000000 Binary files a/libUseful-2.6/mmap.exe and /dev/null differ diff --git a/libUseful-2.6/oauth.c b/libUseful-2.6/oauth.c deleted file mode 100755 index 6d75cb6..0000000 --- a/libUseful-2.6/oauth.c +++ /dev/null @@ -1,262 +0,0 @@ -#include "oauth.h" -#include "http.h" -#include "Markup.h" - -void ParseTagData(char *TagName,char *TagData,char **RType,char **RName,char **RValue) -{ -char *Name=NULL, *Value=NULL, *ptr; - -ptr=GetNameValuePair(TagData," ","=",&Name,&Value); -while (ptr) -{ -if (strcasecmp(Name,"type")==0) *RType=HtmlUnQuote(*RType,Value); -if (strcasecmp(Name,"name")==0) *RName=HtmlUnQuote(*RName,Value); -if (strcasecmp(Name,"value")==0) *RValue=HtmlUnQuote(*RValue,Value); -if (strcasecmp(Name,"method")==0) *RType=HtmlUnQuote(*RType,Value); -if (strcasecmp(Name,"action")==0) *RValue=HtmlUnQuote(*RValue,Value); - -ptr=GetNameValuePair(ptr," ","=",&Name,&Value); -} - -DestroyString(Name); -DestroyString(Value); -} - - -void OAuthParseForm(char *HTML, char *SubmitType, char **SubmitURL, ListNode *HiddenVals, ListNode *QueryVals) -{ -char *TagName=NULL, *TagData=NULL, *Type=NULL, *Name=NULL, *Value=NULL, *ptr; - -ptr=XMLGetTag(HTML,NULL,&TagName,&TagData); -while (ptr) -{ -if (strcmp(TagName,"input")==0) -{ - ParseTagData(TagName,TagData,&Type,&Name,&Value); - - if (strcasecmp(Type,"hidden")==0) SetVar(HiddenVals,Name,Value); - if (strcasecmp(Type,"submit")==0) SetVar(HiddenVals,Name,Value); - if (strcasecmp(Type,"text")==0) SetVar(QueryVals,Name,Value); - if (strcasecmp(Type,"password")==0) SetVar(QueryVals,Name,Value); -} - -if (strcmp(TagName,"form")==0) -{ - ParseTagData(TagName,TagData,&Type,&Name,SubmitURL); -} - - -ptr=XMLGetTag(ptr,NULL,&TagName,&TagData); -} - -DestroyString(TagName); -DestroyString(TagData); -DestroyString(Type); -DestroyString(Name); -DestroyString(Value); -} - - - - -void OAuthParseJSON(char *JSON, ListNode *Vars) -{ -char *ptr, *ptr2, *Token=NULL, *Name=NULL, *Value=NULL; - -StripLeadingWhitespace(JSON); -StripTrailingWhitespace(JSON); -ptr=JSON+StrLen(JSON)-1; -if (*ptr=='}') *ptr='\0'; -ptr=JSON; -if (*ptr=='{') ptr++; -ptr=GetToken(ptr,",",&Token,0); -while (ptr) -{ -printf("TOK: %s\n",Token); -ptr2=GetToken(Token,":",&Name,0); -StripTrailingWhitespace(Name); -StripQuotes(Name); -ptr2=GetToken(ptr2,":",&Value,GETTOKEN_QUOTES); -StripLeadingWhitespace(Value); -StripTrailingWhitespace(Value); -StripQuotes(Value); -printf("JSON: %s=%s\n",Name,Value); -SetVar(Vars,Name,Value); -ptr=GetToken(ptr,",",&Token,0); -} - - -DestroyString(Name); -DestroyString(Value); -DestroyString(Token); -} - - - -void OAuthDeviceLogin(char *LoginURL, char *ClientID, char *Scope, char **DeviceCode, char **UserCode, char **NextURL) -{ -char *Tempstr=NULL, *Encode=NULL; -ListNode *Vars=NULL; -STREAM *S; - -Vars=ListCreate(); - -Encode=HTTPQuote(Encode,ClientID); -Tempstr=MCopyStr(Tempstr,LoginURL,"?client_id=",Encode,NULL); -Encode=HTTPQuote(Encode,Scope); -Tempstr=MCatStr(Tempstr,"&scope=",Encode,NULL); - -S=HTTPMethod("POST",Tempstr,"","","","",0); - -if (S) -{ -Encode=CopyStr(Encode,""); -Tempstr=STREAMReadLine(Tempstr,S); -while (Tempstr) -{ -StripTrailingWhitespace(Tempstr); -Encode=CatStr(Encode,Tempstr); -Tempstr=STREAMReadLine(Tempstr,S); -} - -OAuthParseJSON(Encode, Vars); - -*NextURL=CopyStr(*NextURL,GetVar(Vars,"verification_url")); -*DeviceCode=CopyStr(*DeviceCode,GetVar(Vars,"device_code")); -*UserCode=CopyStr(*UserCode,GetVar(Vars,"user_code")); -} - - -ListDestroy(Vars,DestroyString); -DestroyString(Tempstr); -DestroyString(Encode); -STREAMClose(S); -} - - - -void OAuthDeviceGetAccessToken(char *TokenURL, char *ClientID, char *ClientSecret, char *DeviceCode, char **AccessToken, char **RefreshToken) -{ -char *Tempstr=NULL, *Encode=NULL; -ListNode *Vars=NULL; -STREAM *S; - -Vars=ListCreate(); - -Encode=HTTPQuote(Encode,ClientID); -Tempstr=MCopyStr(Tempstr,TokenURL,"?client_id=",Encode,NULL); -Encode=HTTPQuote(Encode,ClientSecret); -Tempstr=MCatStr(Tempstr,"&client_secret=",Encode,NULL); -Tempstr=MCatStr(Tempstr,"&code=",DeviceCode,NULL); -Tempstr=MCatStr(Tempstr,"&grant_type=","http://oauth.net/grant_type/device/1.0",NULL); - -S=HTTPMethod("POST",Tempstr,"","","","",0); -if (S) -{ -Tempstr=STREAMReadLine(Tempstr,S); -while (Tempstr) -{ -StripTrailingWhitespace(Tempstr); -printf("OA: %s\n",Tempstr); -OAuthParseJSON(Tempstr, Vars); -Tempstr=STREAMReadLine(Tempstr,S); -} -} - -*AccessToken=CopyStr(*AccessToken,GetVar(Vars,"access_token")); -*RefreshToken=CopyStr(*RefreshToken,GetVar(Vars,"refresh_token")); - -ListDestroy(Vars,DestroyString); -DestroyString(Tempstr); -DestroyString(Encode); -} - - - -void OAuthDeviceRefreshToken(char *TokenURL, char *ClientID, char *ClientSecret, char *RequestRefreshToken, char **AccessToken, char **RefreshToken) -{ -char *Tempstr=NULL, *Encode=NULL; -ListNode *Vars=NULL; -STREAM *S; - -Vars=ListCreate(); - -Tempstr=MCopyStr(Tempstr,TokenURL,"?client_id=",ClientID,NULL); -Tempstr=MCatStr(Tempstr,"&client_secret=",ClientSecret,NULL); -Tempstr=MCatStr(Tempstr,"&refresh_token=",RequestRefreshToken,NULL); -Tempstr=MCatStr(Tempstr,"&grant_type=","refresh_token",NULL); - -S=HTTPMethod("POST",Tempstr,"","","","",0); -if (S) -{ -Tempstr=STREAMReadLine(Tempstr,S); -while (Tempstr) -{ -StripTrailingWhitespace(Tempstr); -OAuthParseJSON(Tempstr, Vars); - -Tempstr=STREAMReadLine(Tempstr,S); -} -} - -*AccessToken=CopyStr(*AccessToken,GetVar(Vars,"access_token")); -*RefreshToken=CopyStr(*RefreshToken,GetVar(Vars,"refresh_token")); - -ListDestroy(Vars,DestroyString); -DestroyString(Tempstr); -DestroyString(Encode); -} - - - - -void OAuthInstalledAppURL(char *LoginURL, char *ClientID, char *Scope, char *RedirectURL, char **NextURL) -{ -char *Encode=NULL; - -Encode=HTTPQuote(Encode,ClientID); -*NextURL=MCopyStr(*NextURL,LoginURL,"?response_type=code&redirect_uri=",RedirectURL,"&client_id=",Encode,NULL); -Encode=HTTPQuote(Encode,Scope); -*NextURL=MCatStr(*NextURL,"&scope=",Encode,NULL); - - -DestroyString(Encode); -} - - -void OAuthInstalledAppGetAccessToken(char *TokenURL, char *ClientID, char *ClientSecret, char *AuthCode, char *RedirectURL, char **AccessToken, char **RefreshToken) -{ -char *Tempstr=NULL, *Encode=NULL; -ListNode *Vars=NULL; -STREAM *S; - -Vars=ListCreate(); - -Tempstr=MCopyStr(Tempstr,TokenURL,"?client_id=",ClientID,NULL); -Tempstr=MCatStr(Tempstr,"&client_secret=",ClientSecret,NULL); -Tempstr=MCatStr(Tempstr,"&code=",AuthCode,NULL); -Tempstr=MCatStr(Tempstr,"&redirect_uri=",RedirectURL,NULL); -Tempstr=MCatStr(Tempstr,"&grant_type=","authorization_code",NULL); - -S=HTTPMethod("POST",Tempstr,"","","","",0); -if (S) -{ -Tempstr=STREAMReadLine(Tempstr,S); -while (Tempstr) -{ -StripTrailingWhitespace(Tempstr); -fprintf(stderr,"OA: %s\n",Tempstr); -OAuthParseJSON(Tempstr, Vars); -Tempstr=STREAMReadLine(Tempstr,S); -} -} - -*AccessToken=CopyStr(*AccessToken,GetVar(Vars,"access_token")); -*RefreshToken=CopyStr(*RefreshToken,GetVar(Vars,"refresh_token")); - -ListDestroy(Vars,DestroyString); -DestroyString(Tempstr); -DestroyString(Encode); -} - - diff --git a/libUseful-2.6/oauth.h b/libUseful-2.6/oauth.h deleted file mode 100755 index 58ad8eb..0000000 --- a/libUseful-2.6/oauth.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef LIBUSEFUL_OAUTH_H -#define LIBUSEFUL_OAUTH_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "includes.h" - -void OAuthDeviceLogin(char *LoginURL, char *ClientID, char *Scope, char **DeviceCode, char **UserCode, char **NextURL); -void OAuthDeviceGetAccessToken(char *TokenURL, char *ClientID, char *ClientSecret, char *DeviceCode, char **AccessToken, char **RefreshToken); -void OAuthDeviceRefreshToken(char *TokenURL, char *ClientID, char *ClientSecret, char *RequestRefreshToken, char **AccessToken, char **RefreshToken); -void OAuthInstalledAppURL(char *LoginURL, char *ClientID, char *Scope, char *RedirectURL, char **NextURL); -void OAuthInstalledAppGetAccessToken(char *TokenURL, char *ClientID, char *ClientSecret, char *AuthCode, char *RedirectURL, char **AccessToken, char **RefreshToken); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/libUseful-2.6/openssl.c b/libUseful-2.6/openssl.c deleted file mode 100755 index 87397d3..0000000 --- a/libUseful-2.6/openssl.c +++ /dev/null @@ -1,517 +0,0 @@ -#include "includes.h" -#include "Tokenizer.h" - -#include -#include -#include - -#ifdef HAVE_LIBSSL -#include -#include -#include -#include -#include -#include - -DH *CachedDH=NULL; - - - -void OpenSSLReseedRandom() -{ -int len=32; -char *Tempstr=NULL; - - -len=GenerateRandomBytes(&Tempstr, len, ENCODE_NONE); -RAND_seed(Tempstr,len); -memset(Tempstr,0,len); //extra paranoid step, don't keep those bytes in memory! - -DestroyString(Tempstr); -} - - - -void OpenSSLGenerateDHParams() -{ - CachedDH = DH_new(); - if(CachedDH) - { - OpenSSLReseedRandom(); - DH_generate_parameters_ex(CachedDH, 512, DH_GENERATOR_5, 0); - //DH_check(CachedDH, &codes); - } -} - - - - - - - - -void STREAM_INTERNAL_SSL_ADD_SECURE_KEYS(STREAM *S, SSL_CTX *ctx) -{ -ListNode *Curr; -char *VerifyFile=NULL, *VerifyPath=NULL; - -Curr=ListGetNext(LibUsefulValuesGetHead()); -while (Curr) -{ - if ((StrLen(Curr->Tag)) && (strncasecmp(Curr->Tag,"SSL_CERT_FILE:",14)==0)) - { - SSL_CTX_use_certificate_chain_file(ctx,(char *) Curr->Item); - } - - if ((StrLen(Curr->Tag)) && (strncasecmp(Curr->Tag,"SSL_KEY_FILE:",13)==0)) - { - SSL_CTX_use_PrivateKey_file(ctx,(char *) Curr->Item,SSL_FILETYPE_PEM); - } - - if ((StrLen(Curr->Tag)) && (strncasecmp(Curr->Tag,"SSL_VERIFY_CERTDIR",18)==0)) - { - VerifyPath=CopyStr(VerifyPath,(char *) Curr->Item); - } - - if ((StrLen(Curr->Tag)) && (strncasecmp(Curr->Tag,"SSL_VERIFY_CERTFILE",19)==0)) - { - VerifyFile=CopyStr(VerifyFile,(char *) Curr->Item); - } - - Curr=ListGetNext(Curr); -} - - -Curr=ListGetNext(S->Values); -while (Curr) -{ - if ((StrLen(Curr->Tag)) && (strncasecmp(Curr->Tag,"SSL_CERT_FILE:",14)==0)) - { - SSL_CTX_use_certificate_chain_file(ctx,(char *) Curr->Item); - } - - if ((StrLen(Curr->Tag)) && (strncasecmp(Curr->Tag,"SSL_KEY_FILE:",13)==0)) - { - SSL_CTX_use_PrivateKey_file(ctx,(char *) Curr->Item,SSL_FILETYPE_PEM); - } - - if ((StrLen(Curr->Tag)) && (strncasecmp(Curr->Tag,"SSL_VERIFY_CERTDIR",18)==0)) - { - VerifyPath=CopyStr(VerifyPath,(char *) Curr->Item); - } - - if ((StrLen(Curr->Tag)) && (strncasecmp(Curr->Tag,"SSL_VERIFY_CERTFILE",19)==0)) - { - VerifyFile=CopyStr(VerifyFile,(char *) Curr->Item); - } - - - Curr=ListGetNext(Curr); -} - - -SSL_CTX_load_verify_locations(ctx,VerifyFile,VerifyPath); - -DestroyString(VerifyFile); -DestroyString(VerifyPath); - -} -#endif - - -void HandleSSLError() -{ -#ifdef HAVE_LIBSSL -int val; - - val=ERR_get_error(); - fprintf(stderr,"Failed to create SSL_CTX: %s\n",ERR_error_string(val,NULL)); - fflush(NULL); -#endif -} - - -int INTERNAL_SSL_INIT() -{ -#ifdef HAVE_LIBSSL -char *Tempstr=NULL; -static int InitDone=FALSE; - -//Always reseed RAND on a new connection -//OpenSSLReseedRandom(); - -if (InitDone) return(TRUE); - - SSL_library_init(); -#ifdef USE_OPENSSL_ADD_ALL_ALGORITHMS - OpenSSL_add_all_algorithms(); -#endif - SSL_load_error_strings(); - Tempstr=MCopyStr(Tempstr,SSLeay_version(SSLEAY_VERSION)," : ", SSLeay_version(SSLEAY_BUILT_ON), " : ",SSLeay_version(SSLEAY_CFLAGS),NULL); - LibUsefulSetValue("SSL-Library", Tempstr); - LibUsefulSetValue("SSL-Level", "tls"); - DestroyString(Tempstr); - InitDone=TRUE; - return(TRUE); -#endif - -return(FALSE); -} - - -int SSLAvailable() -{ - return(INTERNAL_SSL_INIT()); -} - -const char *OpenSSLQueryCipher(STREAM *S) -{ -void *ptr; - -if (! S) return(NULL); -ptr=STREAMGetItem(S,"LIBUSEFUL-SSL-CTX"); -if (! ptr) return(NULL); - -#ifdef HAVE_LIBSSL -const SSL_CIPHER *Cipher; -char *Tempstr=NULL; - -Cipher=SSL_get_current_cipher((const SSL *) ptr); - -if (Cipher) -{ -Tempstr=FormatStr(Tempstr,"%d",SSL_CIPHER_get_bits(Cipher,NULL)); -STREAMSetValue(S,"SSL-Bits",Tempstr); -Tempstr=FormatStr(Tempstr,"%s",SSL_CIPHER_get_name(Cipher)); -STREAMSetValue(S,"SSL-Cipher",Tempstr); - -Tempstr=SetStrLen(Tempstr,1024); -Tempstr=SSL_CIPHER_description(Cipher, Tempstr, 1024); - - -STREAMSetValue(S,"SSL-Cipher-Details",Tempstr); -} - -DestroyString(Tempstr); -return(STREAMGetValue(S,"SSL-Cipher")); - -#else -return(NULL); -#endif -} - - -#ifdef HAVE_LIBSSL -int OpenSSLVerifyCallback(int PreverifyStatus, X509_STORE_CTX *X509) -{ -//This does nothing. verification is done in 'OpenSSLVerifyCertificate' instead -return(1); -} -#endif - -int OpenSSLVerifyCertificate(STREAM *S) -{ -int RetVal=FALSE; -#ifdef HAVE_LIBSSL -char *Name=NULL, *Value=NULL, *ptr; -int val; -X509 *cert=NULL; -SSL *ssl; - -ptr=STREAMGetItem(S,"LIBUSEFUL-SSL-CTX"); -if (! ptr) return(FALSE); - -ssl=(SSL *) ptr; - -cert=SSL_get_peer_certificate(ssl); -if (cert) -{ - STREAMSetValue(S,"SSL-Certificate-Issuer",X509_NAME_oneline( X509_get_issuer_name(cert),NULL, 0)); - ptr=X509_NAME_oneline( X509_get_subject_name(cert),NULL, 0); - STREAMSetValue(S,"SSL-Certificate-Subject", ptr); - - ptr=GetNameValuePair(ptr,"/","=",&Name,&Value); - while (ptr) - { - if (StrLen(Name) && (strcmp(Name,"CN")==0)) STREAMSetValue(S,"SSL-Certificate-CommonName",Value); - ptr=GetNameValuePair(ptr,"/","=",&Name,&Value); - } - - val=SSL_get_verify_result(ssl); - - switch(val) - { - case X509_V_OK: STREAMSetValue(S,"SSL-Certificate-Verify","OK"); RetVal=TRUE; break; - case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: STREAMSetValue(S,"SSL-Certificate-Verify","unable to get issuer"); break; - case X509_V_ERR_UNABLE_TO_GET_CRL: STREAMSetValue(S,"SSL-Certificate-Verify","unable to get certificate CRL"); break; - case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: STREAMSetValue(S,"SSL-Certificate-Verify","unable to decrypt certificate's signature"); break; - case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: STREAMSetValue(S,"SSL-Certificate-Verify","unable to decrypt CRL's signature"); break; - case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: STREAMSetValue(S,"SSL-Certificate-Verify","unable to decode issuer public key"); break; - case X509_V_ERR_CERT_SIGNATURE_FAILURE: STREAMSetValue(S,"SSL-Certificate-Verify","certificate signature invalid"); break; - case X509_V_ERR_CRL_SIGNATURE_FAILURE: STREAMSetValue(S,"SSL-Certificate-Verify","CRL signature invalid"); break; - case X509_V_ERR_CERT_NOT_YET_VALID: STREAMSetValue(S,"SSL-Certificate-Verify","certificate is not yet valid"); break; - case X509_V_ERR_CERT_HAS_EXPIRED: STREAMSetValue(S,"SSL-Certificate-Verify","certificate has expired"); break; - case X509_V_ERR_CRL_NOT_YET_VALID: STREAMSetValue(S,"SSL-Certificate-Verify","CRL is not yet valid the CRL is not yet valid."); break; - case X509_V_ERR_CRL_HAS_EXPIRED: STREAMSetValue(S,"SSL-Certificate-Verify","CRL has expired the CRL has expired."); break; - case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: STREAMSetValue(S,"SSL-Certificate-Verify","invalid notBefore value"); break; - case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: STREAMSetValue(S,"SSL-Certificate-Verify","invalid notAfter value"); break; - case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: STREAMSetValue(S,"SSL-Certificate-Verify","invalid CRL lastUpdate value"); break; - case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: STREAMSetValue(S,"SSL-Certificate-Verify","invalid CRL nextUpdate value"); break; - case X509_V_ERR_OUT_OF_MEM: STREAMSetValue(S,"SSL-Certificate-Verify","out of memory"); break; - case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: STREAMSetValue(S,"SSL-Certificate-Verify","self signed certificate"); break; - case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: STREAMSetValue(S,"SSL-Certificate-Verify","self signed certificate in certificate chain"); break; - case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: STREAMSetValue(S,"SSL-Certificate-Verify","cant find root certificate in local database"); break; - case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: STREAMSetValue(S,"SSL-Certificate-Verify","ERROR: unable to verify the first certificate"); break; - case X509_V_ERR_CERT_CHAIN_TOO_LONG: STREAMSetValue(S,"SSL-Certificate-Verify","certificate chain too long"); break; - case X509_V_ERR_CERT_REVOKED: STREAMSetValue(S,"SSL-Certificate-Verify","certificate revoked"); break; - case X509_V_ERR_INVALID_CA: STREAMSetValue(S,"SSL-Certificate-Verify","invalid CA certificate"); break; - case X509_V_ERR_PATH_LENGTH_EXCEEDED: STREAMSetValue(S,"SSL-Certificate-Verify","path length constraint exceeded"); break; - case X509_V_ERR_INVALID_PURPOSE: STREAMSetValue(S,"SSL-Certificate-Verify","unsupported certificate purpose"); break; - case X509_V_ERR_CERT_UNTRUSTED: STREAMSetValue(S,"SSL-Certificate-Verify","certificate not trusted"); break; - case X509_V_ERR_CERT_REJECTED: STREAMSetValue(S,"SSL-Certificate-Verify","certificate rejected"); break; - case X509_V_ERR_SUBJECT_ISSUER_MISMATCH: STREAMSetValue(S,"SSL-Certificate-Verify","subject issuer mismatch"); break; - case X509_V_ERR_AKID_SKID_MISMATCH: STREAMSetValue(S,"SSL-Certificate-Verify","authority and subject key identifier mismatch"); break; - case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: STREAMSetValue(S,"SSL-Certificate-Verify","authority and issuer serial number mismatch"); break; - case X509_V_ERR_KEYUSAGE_NO_CERTSIGN: STREAMSetValue(S,"SSL-Certificate-Verify","key usage does not include certificate signing"); break; - case X509_V_ERR_APPLICATION_VERIFICATION: STREAMSetValue(S,"SSL-Certificate-Verify","application verification failure"); break; - } -} -else -{ - STREAMSetValue(S,"SSL-Certificate-Verify","no certificate"); -} - - -DestroyString(Name); -DestroyString(Value); - -#endif - -return(RetVal); -} - - - - -int DoSSLClientNegotiation(STREAM *S, int Flags) -{ -int result=FALSE, Options=0; -#ifdef HAVE_LIBSSL -const SSL_METHOD *Method; -SSL_CTX *ctx; -SSL *ssl; -//struct x509 *cert=NULL; -char *ptr; - -if (S) -{ - INTERNAL_SSL_INIT(); - // SSL_load_ciphers(); - Method=SSLv23_client_method(); - ctx=SSL_CTX_new(Method); - if (! ctx) HandleSSLError(); - else - { - STREAM_INTERNAL_SSL_ADD_SECURE_KEYS(S,ctx); - SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, OpenSSLVerifyCallback); - ssl=SSL_new(ctx); - SSL_set_fd(ssl,S->in_fd); - STREAMSetItem(S,"LIBUSEFUL-SSL-CTX",ssl); - - Options=SSL_OP_SINGLE_DH_USE | SSL_OP_NO_SSLv2; - ptr=STREAMGetValue(S,"SSL-Level"); - if (! StrLen(ptr)) ptr=LibUsefulGetValue("SSL-Level"); - - if (StrLen(ptr)) - { - if (strncasecmp(ptr,"ssl",3)==0) Options &= ~(SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1); - if (strncasecmp(ptr,"tls",3)==0) Options |=SSL_OP_NO_SSLv3; - if (strcasecmp(ptr,"tls1.1")==0) Options |=SSL_OP_NO_TLSv1; - if (strcasecmp(ptr,"tls1.2")==0) Options |=SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1; - } - - SSL_set_options(ssl, Options); - ptr=LibUsefulGetValue("SSL-Permitted-Ciphers"); - if (ptr) SSL_set_cipher_list(ssl, ptr); - result=SSL_connect(ssl); - while (result==-1) - { - result=SSL_get_error(ssl, result); - if ( (result!=SSL_ERROR_WANT_READ) && (result != SSL_ERROR_WANT_WRITE) ) break; - usleep(300); - result=SSL_connect(ssl); - } - S->State |= SS_SSL; - - OpenSSLQueryCipher(S); - OpenSSLVerifyCertificate(S); - } -} - -#endif -return(result); -} - - -#ifdef HAVE_LIBSSL -void OpenSSLSetupECDH(SSL_CTX *ctx) -{ -EC_KEY* ecdh; - -ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); -//ecdh = EC_KEY_new_by_curve_name( NID_secp384r1); - -{ - SSL_CTX_set_tmp_ecdh(ctx, ecdh); - EC_KEY_free(ecdh); -} - -} - - - -void OpenSSLSetupDH(SSL_CTX *ctx) -{ -char *Tempstr=NULL, *ptr; -DH *dh=NULL; -FILE *paramfile; - -if (CachedDH) dh=CachedDH; -else -{ - ptr=LibUsefulGetValue("SSL-DHParams-File"); - if (StrLen(ptr)) Tempstr=CopyStr(Tempstr,ptr); - - paramfile = fopen(Tempstr, "r"); - if (paramfile) - { - CachedDH = PEM_read_DHparams(paramfile, NULL, NULL, NULL); - dh=CachedDH; - fclose(paramfile); - } - - if (! dh) - { - //OpenSSLGenerateDHParams(); - dh=CachedDH; - } -} - -if (dh) SSL_CTX_set_tmp_dh(ctx, dh); - -//Don't free these parameters, as they are cached -//DH_KEY_free(dh); - -DestroyString(Tempstr); -} -#endif - - - - -int DoSSLServerNegotiation(STREAM *S, int Flags) -{ -int result=FALSE, Options=0; -#ifdef HAVE_LIBSSL -const SSL_METHOD *Method; -SSL_CTX *ctx; -SSL *ssl; -char *ptr; - - -if (S) -{ - INTERNAL_SSL_INIT(); - Method=SSLv23_server_method(); - if (Method) - { - ctx=SSL_CTX_new(Method); - - if (ctx) - { - STREAM_INTERNAL_SSL_ADD_SECURE_KEYS(S,ctx); - if (Flags & LU_SSL_PFS) - { - OpenSSLSetupDH(ctx); - OpenSSLSetupECDH(ctx); - } - if (Flags & LU_SSL_VERIFY_PEER) - { - SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, OpenSSLVerifyCallback); - SSL_CTX_set_verify_depth(ctx,1); - } - SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF); - ssl=SSL_new(ctx); - - Options=SSL_OP_NO_SSLv2|SSL_OP_SINGLE_DH_USE|SSL_OP_CIPHER_SERVER_PREFERENCE; - ptr=STREAMGetValue(S,"SSL-Level"); - if (! StrLen(ptr)) ptr=LibUsefulGetValue("SSL-Level"); - - if (StrLen(ptr)) - { - if (strncasecmp(ptr,"ssl",3)==0) Options &= ~(SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1); - if (strncasecmp(ptr,"tls",3)==0) Options |=SSL_OP_NO_SSLv3; - if (strcasecmp(ptr,"tls1.1")==0) Options |=SSL_OP_NO_TLSv1; - if (strcasecmp(ptr,"tls1.2")==0) Options |=SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1; - } - - SSL_set_options(ssl, Options); - SSL_set_fd(ssl,S->in_fd); - STREAMSetItem(S,"LIBUSEFUL-SSL-CTX",ssl); - ptr=LibUsefulGetValue("SSL-Permitted-Ciphers"); - if (ptr) SSL_set_cipher_list(ssl, ptr); - SSL_set_accept_state(ssl); - - while (1) - { - result=SSL_accept(ssl); - if (result != TRUE) result=SSL_get_error(ssl,result); - switch (result) - { - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_WRITE: - usleep(300); - result=-1; - break; - - case TRUE: - S->State |= SS_SSL; - if (Flags & SSL_VERIFY_PEER) OpenSSLVerifyCertificate(S); - OpenSSLQueryCipher(S); - break; - - default: - result=ERR_get_error(); - STREAMSetValue(S, "SSL-Error", ERR_error_string(result,NULL)); - result=FALSE; - break; - } - if (result !=-1) break; - } - } - } -} - -#endif -return(result); -} - - - -int STREAMIsPeerAuth(STREAM *S) -{ -#ifdef HAVE_LIBSSL -void *ptr; - -ptr=STREAMGetItem(S,"LIBUSEFUL-SSL-CTX"); -if (! ptr) return(FALSE); - -if (SSL_get_verify_result((SSL *) ptr)==X509_V_OK) -{ - if (SSL_get_peer_certificate((SSL *) ptr) !=NULL) return(TRUE); -} -#endif -return(FALSE); -} - - diff --git a/libUseful-2.6/openssl.h b/libUseful-2.6/openssl.h deleted file mode 100755 index d23effd..0000000 --- a/libUseful-2.6/openssl.h +++ /dev/null @@ -1,16 +0,0 @@ - -#ifndef LIBUSEFUL_OPENSSL_H -#define LIBUSEFUL_OPENSSL_H -#include "includes.h" - -#define LU_SSL_PFS 1 -#define LU_SSL_VERIFY_PEER 2 - -void OpenSSLGenerateDHParams(); -void HandleSSLError(); -int SSLAvailable(); -int DoSSLClientNegotiation(STREAM *S, int Flags); -int DoSSLServerNegotiation(STREAM *S, int Flags); -int STREAMIsPeerAuth(STREAM *S); - -#endif diff --git a/libUseful-2.6/proctitle.c b/libUseful-2.6/proctitle.c deleted file mode 100755 index 3b1bca8..0000000 --- a/libUseful-2.6/proctitle.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "proctitle.h" -#define __GNU_SOURCE -#include "errno.h" - -/*This is code to change the command-line of a program as visible in ps */ - -extern char **environ; -char *TitleBuffer=NULL; -int TitleLen=0; - - -void CopyEnv(const char *Env) -{ -char *tmp, *ptr; - - tmp=strdup(Env); - if (tmp) - { - ptr=strchr(tmp,'='); - if (ptr) - { - *ptr='\0'; - ptr++; - } - else ptr=NULL; - setenv(tmp,ptr,1); - free(tmp); - } -} - -//The command-line args that we've been passed (argv) will occupy a block of contiguous memory that -//contains these args and the environment strings. In order to change the command-line args we isolate -//this block of memory by iterating through all the strings in it, and making copies of them. The -//pointers in 'argv' and 'environ' are then redirected to these copies. Now we can overwrite the whole -//block of memory with our new command-line arguments. -void ProcessTitleCaptureBuffer(char **argv) -{ -char **arg, *end=NULL, *tmp; - -#ifdef __GNU_LIBRARY__ -extern char *program_invocation_name; -extern char *program_invocation_short_name; - -program_invocation_name=strdup(program_invocation_name); -program_invocation_short_name=strdup(program_invocation_short_name); -#endif - -TitleBuffer=argv[0]; -arg=argv; -while (*arg) -{ -for (end=*arg; *end != '\0'; end++) ; -*arg=strdup(*arg); -arg++; -} - -arg=environ; -//clearenv(); //clearenv is not portable -environ[0]=NULL; -while (*arg) -{ - for (end=*arg; *end != '\0'; end++); - CopyEnv(*arg); - arg++; -} - -TitleLen=end-TitleBuffer; -} - - -void ProcessSetTitle(char **argv, char *FmtStr, ...) -{ -va_list args; - - if (! TitleBuffer) ProcessTitleCaptureBuffer(argv); - memset(TitleBuffer,0,TitleLen); - - va_start(args,FmtStr); - vsnprintf(TitleBuffer,TitleLen,FmtStr,args); - va_end(args); -} - diff --git a/libUseful-2.6/proctitle.h b/libUseful-2.6/proctitle.h deleted file mode 100755 index dcba88f..0000000 --- a/libUseful-2.6/proctitle.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef LIBUSEFUL_PROCTITLE_H -#define LIBUSEFUL_PROCTITLE_H - -#include "includes.h" - -void ProcessSetTitle(char **argv, char *FmtStr, ...); - -#endif diff --git a/libUseful-2.6/pty.c b/libUseful-2.6/pty.c deleted file mode 100755 index 792e767..0000000 --- a/libUseful-2.6/pty.c +++ /dev/null @@ -1,304 +0,0 @@ -#define _XOPEN_SOURCE -#define _GNU_SOURCE - -#include "includes.h" -#include "file.h" -#include "GeneralFunctions.h" -#include "string.h" -#include "pty.h" - -#include -#include -#include -#include -#include - -ListNode *TTYAttribs=NULL; - -void HangUpLine(int tty) -{ -struct termios tty_data, oldtty_data; - - -tcgetattr(tty,&oldtty_data); -tcgetattr(tty,&tty_data); -cfsetispeed(&tty_data,B0); -cfsetospeed(&tty_data,B0); - -tcsetattr(tty,TCSANOW,&tty_data); -sleep(5); -tcsetattr(tty,TCSANOW,&oldtty_data); -} - -void ResetTTY(int tty) -{ -struct termios *tty_data; -char *Tempstr=NULL; -ListNode *Curr; - -Tempstr=FormatStr(Tempstr,"%d",tty); -Curr=ListFindNamedItem(TTYAttribs,Tempstr); -if (Curr) -{ - tty_data=(struct termios *) Curr->Item; - tcsetattr(tty,TCSANOW,tty_data); - ListDeleteNode(Curr); - free(tty_data); -} - -DestroyString(Tempstr); -} - -void InitTTY(int tty, int LineSpeed, int Flags) -{ -struct termios tty_data, *old_tty_data; -int val; -char *Tempstr=NULL; -ListNode *Curr; - -Tempstr=FormatStr(Tempstr,"%d",tty); -if (! TTYAttribs) TTYAttribs=ListCreate(); -Curr=ListFindNamedItem(TTYAttribs,Tempstr); - -if (! Curr) -{ - old_tty_data=(struct termios *) calloc(1,sizeof(struct termios)); - ListAddNamedItem(TTYAttribs,Tempstr,old_tty_data); -} -else old_tty_data=(struct termios *) Curr->Item; - -tcgetattr(tty,old_tty_data); -//tcgetattr(tty,&tty_data); -memset(&tty_data,0,sizeof(struct termios)); - -//ignore break characters and parity errors -tty_data.c_iflag=IGNBRK | IGNPAR; - - -if (! (Flags & TTYFLAG_CRLF_KEEP)) -{ - //translate carriage-return to newline - - if (Flags & TTYFLAG_CRLF) tty_data.c_iflag |= ICRNL; - else tty_data.c_iflag &= ~ICRNL; - - //translate newline to carriage return - if (Flags & TTYFLAG_LFCR) - { - tty_data.c_iflag |= INLCR; - } - else tty_data.c_iflag &= ~INLCR; - - //postprocess and translate newline to cr-nl - if (Flags & TTYFLAG_LFCR) - { - tty_data.c_oflag |= ONLCR | OPOST; - } -} - -tty_data.c_cflag=CREAD | CS8 | HUPCL | CLOCAL; - - -if (Flags & TTYFLAG_SOFTWARE_FLOW) -{ -tty_data.c_iflag |= IXON | IXOFF; -tty_data.c_cc[VSTART]=old_tty_data->c_cc[VSTART]; -tty_data.c_cc[VSTOP]=old_tty_data->c_cc[VSTOP]; -} - -#ifdef CRTSCTS -if (Flags & TTYFLAG_HARDWARE_FLOW) tty_data.c_cflag |=CRTSCTS; -#endif - -// 'local' input flags -tty_data.c_lflag=0; - -if (! (Flags & TTYFLAG_IGNSIG)) -{ - tty_data.c_lflag=ISIG; - tty_data.c_cc[VQUIT]=old_tty_data->c_cc[VQUIT]; - tty_data.c_cc[VSUSP]=old_tty_data->c_cc[VSUSP]; - tty_data.c_cc[VINTR]=old_tty_data->c_cc[VINTR]; -} -if (Flags & TTYFLAG_ECHO) tty_data.c_lflag |= ECHO; - -if (Flags & TTYFLAG_CANON) -{ - tty_data.c_lflag|= ICANON; - tty_data.c_cc[VEOF]=old_tty_data->c_cc[VEOF]; - tty_data.c_cc[VEOL]=old_tty_data->c_cc[VEOL]; - tty_data.c_cc[VKILL]=old_tty_data->c_cc[VKILL]; - tty_data.c_cc[VERASE]=old_tty_data->c_cc[VERASE]; -} -else -{ - tty_data.c_cc[VMIN]=1; - tty_data.c_cc[VTIME]=0; -} - -//Higher line speeds protected with #ifdef because not all -//operating systems seem to have them -if (LineSpeed > 0) -{ -switch (LineSpeed) -{ -case 2400: val=B2400; break; -case 4800: val=B4800; break; -case 9600: val=B9600; break; -case 19200: val=B19200; break; -case 38400: val=B38400; break; -#ifdef B57600 -case 57600: val=B57600; break; -#endif - -#ifdef B115200 -case 115200: val=B115200; break; -#endif - -#ifdef B230400 -case 230400: val=B230400; break; -#endif - -#ifdef B460800 -case 460800: val=B460800; break; -#endif - -#ifdef B500000 -case 500000: val=B500000; break; -#endif - -#ifdef B1000000 -case 10000000: val=B1000000; break; -#endif - -#ifdef B1152000 -case 1152000: val=B1152000; break; -#endif - -#ifdef B2000000 -case 2000000: val=B2000000; break; -#endif - -#ifdef B4000000 -case 4000000: val=B4000000; break; -#endif - -default: val=B38400; break; -} -cfsetispeed(&tty_data,val); -cfsetospeed(&tty_data,val); -} - -tcflush(tty,TCIFLUSH); -tcsetattr(tty,TCSANOW,&tty_data); - -DestroyString(Tempstr); -} - - - - -int OpenTTY(char *devname, int LineSpeed, int Flags) -{ -int tty, flags=O_RDWR | O_NOCTTY; - - -if (Flags & TTYFLAG_NONBLOCK) -{ - //O_NDELAY should be used only if nothing else available - //as O_NONBLOCK is more 'posixy' - #ifdef O_NDELAY - flags |= O_NDELAY; - #endif - - #ifdef O_NONBLOCK - flags |= O_NONBLOCK; - #endif -} - -tty=open(devname, flags); - -if ( tty <0) return(-1); -InitTTY(tty, LineSpeed, Flags); -return(tty); -} - - - -int GrabPseudoTTY(int *pty, int *tty, int TermFlags) -{ -char c1,c2; -char *Tempstr=NULL; - -#ifdef __GNU_LIBRARY__ -#ifdef HAVE_PTSNAME_R -//first try unix98 style -*pty=open("/dev/ptmx",O_RDWR); -if (*pty > -1) -{ - grantpt(*pty); - unlockpt(*pty); - SetStrLen(Tempstr,100); - if (ptsname_r(*pty,Tempstr,100) != 0) Tempstr=CopyStr(Tempstr,ptsname(*pty)); - if (StrLen(Tempstr)) - { - if ( (*tty=open(Tempstr,O_RDWR)) >-1) - { - InitTTY(*tty,0,TermFlags); - return(1); - } - } - close(*pty); -} -#endif -#endif - -//if unix98 fails, try old BSD style - -for (c1='p'; c1 < 's'; c1++) -{ - for (c2='5'; c2 <='9'; c2++) - { - Tempstr=FormatStr(Tempstr,"/dev/pty%c%c",c1,c2); - if ( (*pty=open(Tempstr,O_RDWR)) >-1) - { - Tempstr=FormatStr(Tempstr,"/dev/tty%c%c",c1,c2); - if ( (*tty=OpenTTY(Tempstr,0,TermFlags)) >-1) - { - DestroyString(Tempstr); - return(1); - } - else close(*pty); - } - - } - -} - -DestroyString(Tempstr); -return(0); -} - - - -char *TTYReadSecret(char *RetStr, STREAM *S, int Flags) -{ -int len=0, inchar; - -//Turn off echo (and other things) -InitTTY(0,0, TTYFLAG_CRLF); -inchar=STREAMReadChar(S); -while (inchar != EOF) -{ - RetStr=AddCharToBuffer(RetStr,len++,inchar); - if (inchar=='\n') break; - if (Flags & TEXT_STARS) write(1,"*",1); - inchar=STREAMReadChar(S); -} -//turn echo back on -ResetTTY(0); -printf("\n"); - -return(RetStr); -} - diff --git a/libUseful-2.6/pty.h b/libUseful-2.6/pty.h deleted file mode 100755 index 198391c..0000000 --- a/libUseful-2.6/pty.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef LIBUSEFUL_PTY_H -#define LIBUSEFUL_PTY_H - -#include "defines.h" - -#define TTYFLAG_CANON 4096 -#define TTYFLAG_HARDWARE_FLOW 8192 -#define TTYFLAG_SOFTWARE_FLOW 16324 -#define TTYFLAG_CRLF_KEEP 32768 -#define TTYFLAG_IGNSIG 65536 -#define TTYFLAG_ECHO 131072 -#define TTYFLAG_CRLF 262144 -#define TTYFLAG_LFCR 524288 -#define TTYFLAG_NONBLOCK 1048576 - -#define TEXT_STARS 1 -#define TEXT_STAR_ONE 2 - -#ifdef __cplusplus -extern "C" { -#endif - -void HangUpLine(int tty); -int OpenTTY(char *devname, int LineSpeed, int Flags); -void InitTTY(int tty, int LineSpeed, int Flags); -void ResetTTY(int tty); -int GrabPseudoTTY(int *pty, int *tty, int Flags); -char *TTYReadSecret(char *RetStr, STREAM *S, int Flags); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/securemem.c b/libUseful-2.6/securemem.c deleted file mode 100755 index f1de681..0000000 --- a/libUseful-2.6/securemem.c +++ /dev/null @@ -1,184 +0,0 @@ -#include "securemem.h" - -#include -#include -#include -#include -#include -#include "string.h" - -char *CredsStore=NULL; -int CredsStoreSize=0; -int CredsStoreUsed=0; - -void SecureClearMem(char *Mem, int Size) -{ -char *ptr; - - if (! Mem) return; - xmemset((volatile char *) Mem,0,Size); - for (ptr=Mem; ptr < (Mem + Size); ptr++) - { - if (*ptr != 0) - { - fprintf(stderr,"LIBUSEFUL ERROR: Failed to clear secure memory"); - exit(3); - } - } -} - - -void SecureDestroy(char *Mem, int Size) -{ - - if (! Mem) return; - SecureClearMem(Mem, Size); - munlock(Mem, Size); - free(Mem); -} - - -int SecureRealloc(char **OldMem, int OldSize, int NewSize, int Flags) -{ -int MemSize; -char *NewMem=NULL; -int val=0, PageSize; - -PageSize=getpagesize(); -MemSize=(NewSize / PageSize + 1) * PageSize; -if (OldMem && (NewSize < OldSize)) return(OldSize); - -if (posix_memalign((void **) &NewMem, PageSize, MemSize)==0) -{ - if (OldMem) - { - //both needed - mprotect(*OldMem, OldSize, PROT_READ|PROT_WRITE); - memcpy(NewMem,*OldMem,OldSize); - SecureDestroy(*OldMem, OldSize); - } - - - #ifdef HAVE_MADVISE - - #ifdef MADV_NOFORK - if (Flags & SMEM_NOFORK) madvise(NewMem,NewSize,MADV_DONTFORK); - #endif - - #ifdef MADV_DONTDUMP - if (Flags & SMEM_NODUMP) madvise(NewMem,NewSize,MADV_DONTDUMP); - #endif - - #endif - - #ifdef HAVE_MLOCK - if (Flags & SMEM_LOCK) mlock(NewMem, NewSize); - #endif - - if (Flags & SMEM_NOACCESS) mprotect(NewMem, NewSize, PROT_NONE); - else if (Flags & SMEM_WRITEONLY) mprotect(NewMem, NewSize, PROT_WRITE); - else if (Flags & SMEM_READONLY) mprotect(NewMem, NewSize, PROT_READ); -} -else -{ - fprintf(stderr,"LIBUSEFUL ERROR: Failed to allocate secure memory"); - exit(3); -} - -*OldMem=NewMem; -return(NewSize); -} - - -char *CredsStoreWrite(char *Dest, const char *String, int len) -{ -uint16_t *plen; -char *ptr; - -ptr=Dest; -plen=(uint16_t *) ptr; -*plen=len; -ptr+=sizeof(uint16_t); -memcpy(ptr, String, len); -ptr+=len; -*ptr='\0'; -ptr++; -return(ptr); -} - - -char *CredsStoreGetSecret(const char *Realm, const char *User) -{ -uint16_t plen, rlen, ulen; -char *ptr, *end, *frealm, *fuser; - -rlen=StrLen(Realm); -ulen=StrLen(User); -ptr=CredsStore; -end=CredsStore + CredsStoreUsed; - -if (rlen && ulen) -{ -mprotect(CredsStore, CredsStoreSize, PROT_READ); -while (ptr < end) -{ - frealm=NULL; - fuser=NULL; - - plen=*(uint16_t *) ptr; - ptr+=sizeof(uint16_t); - if (plen == rlen) frealm=ptr; - ptr+=plen+1; - - plen=*(uint16_t *) ptr; - ptr+=sizeof(uint16_t); - if (plen == ulen) fuser=ptr; - ptr+=plen+1; - - plen=*(uint16_t *) ptr; - ptr+=sizeof(uint16_t); - if ( - (frealm && fuser) && - (strcmp(frealm,Realm)==0) && - (strcmp(fuser,User)==0) - ) - { - printf("FOUND %s\n",ptr); - return(ptr); - } - ptr+=plen+1; -} -} -mprotect(CredsStore, CredsStoreSize, PROT_NONE); - -return(NULL); -} - - -void CredsStoreAdd(const char *Realm, const char *User, const char *Secret) -{ -int len; -char *ptr; - -//Don't add if already exists -ptr=CredsStoreGetSecret(Realm, User); -if (ptr && (strcmp(Secret, ptr)==0)) -{ -mprotect(CredsStore, CredsStoreSize, PROT_NONE); -return; -} - -len=CredsStoreUsed+StrLen(Realm) + StrLen(User) + StrLen(Secret) + 100; -CredsStoreSize=SecureRealloc(&CredsStore, CredsStoreSize, len, SMEM_NOFORK | SMEM_NODUMP | SMEM_LOCK); - -mprotect(CredsStore, CredsStoreSize, PROT_WRITE); -ptr=CredsStoreWrite(CredsStore+CredsStoreUsed, Realm, StrLen(Realm)); -ptr=CredsStoreWrite(ptr, User, StrLen(User)); -ptr=CredsStoreWrite(ptr, Secret, StrLen(Secret)); -mprotect(CredsStore, CredsStoreSize, PROT_NONE); - -CredsStoreUsed=ptr-CredsStore; -} - - - diff --git a/libUseful-2.6/securemem.h b/libUseful-2.6/securemem.h deleted file mode 100755 index a0acc9e..0000000 --- a/libUseful-2.6/securemem.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LIBUSEFUL_SECUREMEM_H -#define LIBUSEFUL_SECUREMEM_H - -#define SMEM_LOCK 1 -#define SMEM_NODUMP 2 -#define SMEM_NOFORK 4 -#define SMEM_READONLY 8 -#define SMEM_WRITEONLY 16 -#define SMEM_NOACCESS 32 -#define SMEM_SECURE (SMEM_LOCK | SMEM_NOFORK | SMEM_NODUMP) -#define SMEM_PARANOID (SMEM_SECURE | SMEM_NOACCESS) - -void SecureClearMem(char *Mem, int Size); -void SecureDestroy(char *Mem, int Size); -int SecureRealloc(char **OldMem, int OldSize, int NewSize, int Flags); - -void CredsStoreAdd(const char *Realm, const char *User, const char *Secret); -char *CredsStoreGetSecret(const char *Realm, const char *User); - -#endif diff --git a/libUseful-2.6/sha1.c b/libUseful-2.6/sha1.c deleted file mode 100755 index b0acc13..0000000 --- a/libUseful-2.6/sha1.c +++ /dev/null @@ -1,331 +0,0 @@ -/* sha1.c - Functions to compute SHA1 message digest of files or - memory blocks according to the NIST specification FIPS-180-1. - - Copyright (C) 2000-2001, 2003-2006, 2008-2011 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* Written by Scott G. Miller - Credits: - Robert Klep -- Expansion function fix -*/ - -//#include - -#include "sha1.h" - -#include -#include -#include - -#ifdef WORDS_BIGENDIAN -# define SWAP(n) (n) -#else -# define SWAP(n) \ - (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) -#endif - -#define BLOCKSIZE 32768 -#if BLOCKSIZE % 64 != 0 -# error "invalid BLOCKSIZE" -#endif - -/* This array contains the bytes used to pad the buffer to the next - 64-byte boundary. (RFC 1321, 3.1: Step 1) */ -static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; - - -/* Take a pointer to a 160 bit block of data (five 32 bit ints) and - initialize it to the start constants of the SHA1 algorithm. This - must be called before using hash in the call to sha1_hash. */ -void -sha1_init_ctx (struct sha1_ctx *ctx) -{ - ctx->A = 0x67452301; - ctx->B = 0xefcdab89; - ctx->C = 0x98badcfe; - ctx->D = 0x10325476; - ctx->E = 0xc3d2e1f0; - - ctx->total[0] = ctx->total[1] = 0; - ctx->buflen = 0; -} - -/* Copy the 4 byte value from v into the memory location pointed to by *cp, - If your architecture allows unaligned access this is equivalent to - * (uint32_t *) cp = v */ -static inline void -set_uint32 (char *cp, uint32_t v) -{ - memcpy (cp, &v, sizeof v); -} - -/* Put result from CTX in first 20 bytes following RESBUF. The result - must be in little endian byte order. */ -void * -sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf) -{ - char *r = resbuf; - set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A)); - set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B)); - set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C)); - set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D)); - set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E)); - - return resbuf; -} - -/* Process the remaining bytes in the internal buffer and the usual - prolog according to the standard and write the result to RESBUF. */ -void * -sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf) -{ - /* Take yet unprocessed bytes into account. */ - uint32_t bytes = ctx->buflen; - size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4; - - /* Now count remaining bytes. */ - ctx->total[0] += bytes; - if (ctx->total[0] < bytes) - ++ctx->total[1]; - - /* Put the 64-bit file length in *bits* at the end of the buffer. */ - ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); - ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3); - - memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes); - - /* Process last bytes. */ - sha1_process_block (ctx->buffer, size * 4, ctx); - - return sha1_read_ctx (ctx, resbuf); -} - -void -sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) -{ - /* When we already have some bits in our internal buffer concatenate - both inputs first. */ - if (ctx->buflen != 0) - { - size_t left_over = ctx->buflen; - size_t add = 128 - left_over > len ? len : 128 - left_over; - - memcpy (&((char *) ctx->buffer)[left_over], buffer, add); - ctx->buflen += add; - - if (ctx->buflen > 64) - { - sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx); - - ctx->buflen &= 63; - /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, - &((char *) ctx->buffer)[(left_over + add) & ~63], - ctx->buflen); - } - - buffer = (const char *) buffer + add; - len -= add; - } - - /* Process available complete blocks. */ - if (len >= 64) - { -#if !_STRING_ARCH_unaligned -# define alignof(type) offsetof (struct { char c; type x; }, x) -# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0) - if (UNALIGNED_P (buffer)) - while (len > 64) - { - sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); - buffer = (const char *) buffer + 64; - len -= 64; - } - else -#endif - { - sha1_process_block (buffer, len & ~63, ctx); - buffer = (const char *) buffer + (len & ~63); - len &= 63; - } - } - - /* Move remaining bytes in internal buffer. */ - if (len > 0) - { - size_t left_over = ctx->buflen; - - memcpy (&((char *) ctx->buffer)[left_over], buffer, len); - left_over += len; - if (left_over >= 64) - { - sha1_process_block (ctx->buffer, 64, ctx); - left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[16], left_over); - } - ctx->buflen = left_over; - } -} - -/* --- Code below is the primary difference between md5.c and sha1.c --- */ - -/* SHA1 round constants */ -#define K1 0x5a827999 -#define K2 0x6ed9eba1 -#define K3 0x8f1bbcdc -#define K4 0xca62c1d6 - -/* Round functions. Note that F2 is the same as F4. */ -#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) ) -#define F2(B,C,D) (B ^ C ^ D) -#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) ) -#define F4(B,C,D) (B ^ C ^ D) - -/* Process LEN bytes of BUFFER, accumulating context into CTX. - It is assumed that LEN % 64 == 0. - Most of this code comes from GnuPG's cipher/sha1.c. */ - -void -sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx) -{ - const uint32_t *words = buffer; - size_t nwords = len / sizeof (uint32_t); - const uint32_t *endp = words + nwords; - uint32_t x[16]; - uint32_t a = ctx->A; - uint32_t b = ctx->B; - uint32_t c = ctx->C; - uint32_t d = ctx->D; - uint32_t e = ctx->E; - - /* First increment the byte count. RFC 1321 specifies the possible - length of the file up to 2^64 bits. Here we only compute the - number of bytes. Do a double word increment. */ - ctx->total[0] += len; - if (ctx->total[0] < len) - ++ctx->total[1]; - -#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n)))) - -#define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \ - ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \ - , (x[I&0x0f] = rol(tm, 1)) ) - -#define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \ - + F( B, C, D ) \ - + K \ - + M; \ - B = rol( B, 30 ); \ - } while(0) - - while (words < endp) - { - uint32_t tm; - int t; - for (t = 0; t < 16; t++) - { - x[t] = SWAP (*words); - words++; - } - - R( a, b, c, d, e, F1, K1, x[ 0] ); - R( e, a, b, c, d, F1, K1, x[ 1] ); - R( d, e, a, b, c, F1, K1, x[ 2] ); - R( c, d, e, a, b, F1, K1, x[ 3] ); - R( b, c, d, e, a, F1, K1, x[ 4] ); - R( a, b, c, d, e, F1, K1, x[ 5] ); - R( e, a, b, c, d, F1, K1, x[ 6] ); - R( d, e, a, b, c, F1, K1, x[ 7] ); - R( c, d, e, a, b, F1, K1, x[ 8] ); - R( b, c, d, e, a, F1, K1, x[ 9] ); - R( a, b, c, d, e, F1, K1, x[10] ); - R( e, a, b, c, d, F1, K1, x[11] ); - R( d, e, a, b, c, F1, K1, x[12] ); - R( c, d, e, a, b, F1, K1, x[13] ); - R( b, c, d, e, a, F1, K1, x[14] ); - R( a, b, c, d, e, F1, K1, x[15] ); - R( e, a, b, c, d, F1, K1, M(16) ); - R( d, e, a, b, c, F1, K1, M(17) ); - R( c, d, e, a, b, F1, K1, M(18) ); - R( b, c, d, e, a, F1, K1, M(19) ); - R( a, b, c, d, e, F2, K2, M(20) ); - R( e, a, b, c, d, F2, K2, M(21) ); - R( d, e, a, b, c, F2, K2, M(22) ); - R( c, d, e, a, b, F2, K2, M(23) ); - R( b, c, d, e, a, F2, K2, M(24) ); - R( a, b, c, d, e, F2, K2, M(25) ); - R( e, a, b, c, d, F2, K2, M(26) ); - R( d, e, a, b, c, F2, K2, M(27) ); - R( c, d, e, a, b, F2, K2, M(28) ); - R( b, c, d, e, a, F2, K2, M(29) ); - R( a, b, c, d, e, F2, K2, M(30) ); - R( e, a, b, c, d, F2, K2, M(31) ); - R( d, e, a, b, c, F2, K2, M(32) ); - R( c, d, e, a, b, F2, K2, M(33) ); - R( b, c, d, e, a, F2, K2, M(34) ); - R( a, b, c, d, e, F2, K2, M(35) ); - R( e, a, b, c, d, F2, K2, M(36) ); - R( d, e, a, b, c, F2, K2, M(37) ); - R( c, d, e, a, b, F2, K2, M(38) ); - R( b, c, d, e, a, F2, K2, M(39) ); - R( a, b, c, d, e, F3, K3, M(40) ); - R( e, a, b, c, d, F3, K3, M(41) ); - R( d, e, a, b, c, F3, K3, M(42) ); - R( c, d, e, a, b, F3, K3, M(43) ); - R( b, c, d, e, a, F3, K3, M(44) ); - R( a, b, c, d, e, F3, K3, M(45) ); - R( e, a, b, c, d, F3, K3, M(46) ); - R( d, e, a, b, c, F3, K3, M(47) ); - R( c, d, e, a, b, F3, K3, M(48) ); - R( b, c, d, e, a, F3, K3, M(49) ); - R( a, b, c, d, e, F3, K3, M(50) ); - R( e, a, b, c, d, F3, K3, M(51) ); - R( d, e, a, b, c, F3, K3, M(52) ); - R( c, d, e, a, b, F3, K3, M(53) ); - R( b, c, d, e, a, F3, K3, M(54) ); - R( a, b, c, d, e, F3, K3, M(55) ); - R( e, a, b, c, d, F3, K3, M(56) ); - R( d, e, a, b, c, F3, K3, M(57) ); - R( c, d, e, a, b, F3, K3, M(58) ); - R( b, c, d, e, a, F3, K3, M(59) ); - R( a, b, c, d, e, F4, K4, M(60) ); - R( e, a, b, c, d, F4, K4, M(61) ); - R( d, e, a, b, c, F4, K4, M(62) ); - R( c, d, e, a, b, F4, K4, M(63) ); - R( b, c, d, e, a, F4, K4, M(64) ); - R( a, b, c, d, e, F4, K4, M(65) ); - R( e, a, b, c, d, F4, K4, M(66) ); - R( d, e, a, b, c, F4, K4, M(67) ); - R( c, d, e, a, b, F4, K4, M(68) ); - R( b, c, d, e, a, F4, K4, M(69) ); - R( a, b, c, d, e, F4, K4, M(70) ); - R( e, a, b, c, d, F4, K4, M(71) ); - R( d, e, a, b, c, F4, K4, M(72) ); - R( c, d, e, a, b, F4, K4, M(73) ); - R( b, c, d, e, a, F4, K4, M(74) ); - R( a, b, c, d, e, F4, K4, M(75) ); - R( e, a, b, c, d, F4, K4, M(76) ); - R( d, e, a, b, c, F4, K4, M(77) ); - R( c, d, e, a, b, F4, K4, M(78) ); - R( b, c, d, e, a, F4, K4, M(79) ); - - a = ctx->A += a; - b = ctx->B += b; - c = ctx->C += c; - d = ctx->D += d; - e = ctx->E += e; - } -} diff --git a/libUseful-2.6/sha1.h b/libUseful-2.6/sha1.h deleted file mode 100755 index 5bea6a5..0000000 --- a/libUseful-2.6/sha1.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Declarations of functions and data types used for SHA1 sum - library functions. - Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2011 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef SHA1_H -# define SHA1_H 1 - -# include -# include - -# ifdef __cplusplus -extern "C" { -# endif - -#define SHA1_DIGEST_SIZE 20 - -/* Structure to save state of computation between the single steps. */ -struct sha1_ctx -{ - uint32_t A; - uint32_t B; - uint32_t C; - uint32_t D; - uint32_t E; - - uint32_t total[2]; - uint32_t buflen; - uint32_t buffer[32]; -}; - - -/* Initialize structure containing state of computation. */ -extern void sha1_init_ctx (struct sha1_ctx *ctx); - -/* Starting with the result of former calls of this function (or the - initialization function update the context for the next LEN bytes - starting at BUFFER. - It is necessary that LEN is a multiple of 64!!! */ -extern void sha1_process_block (const void *buffer, size_t len, - struct sha1_ctx *ctx); - -/* Starting with the result of former calls of this function (or the - initialization function update the context for the next LEN bytes - starting at BUFFER. - It is NOT required that LEN is a multiple of 64. */ -extern void sha1_process_bytes (const void *buffer, size_t len, - struct sha1_ctx *ctx); - -/* Process the remaining bytes in the buffer and put result from CTX - in first 20 bytes following RESBUF. The result is always in little - endian byte order, so that a byte-wise output yields to the wanted - ASCII representation of the message digest. */ -extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); - - -/* Put result from CTX in first 20 bytes following RESBUF. The result is - always in little endian byte order, so that a byte-wise output yields - to the wanted ASCII representation of the message digest. */ -extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf); - - -# ifdef __cplusplus -} -# endif - -#endif diff --git a/libUseful-2.6/sha2.c b/libUseful-2.6/sha2.c deleted file mode 100755 index 005a8d4..0000000 --- a/libUseful-2.6/sha2.c +++ /dev/null @@ -1,1064 +0,0 @@ -/* - * FILE: sha2.c - * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ - * - * Copyright (c) 2000-2001, Aaron D. Gifford - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of the copyright holder nor the names of contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``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 AUTHOR OR CONTRIBUTOR(S) 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. - * - */ - -#include /* memcpy()/memset() or bcopy()/bzero() */ -#include /* assert() */ -#include "sha2.h" - -/* - * ASSERT NOTE: - * Some sanity checking code is included using assert(). On my FreeBSD - * system, this additional code can be removed by compiling with NDEBUG - * defined. Check your own systems manpage on assert() to see how to - * compile WITHOUT the sanity checking code on your system. - * - * UNROLLED TRANSFORM LOOP NOTE: - * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform - * loop version for the hash transform rounds (defined using macros - * later in this file). Either define on the command line, for example: - * - * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c - * - * or define below: - * - * #define SHA2_UNROLL_TRANSFORM - * - */ - - -/*** SHA-256/384/512 Machine Architecture Definitions *****************/ -/* - * BYTE_ORDER NOTE: - * - * Please make sure that your system defines BYTE_ORDER. If your - * architecture is little-endian, make sure it also defines - * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are - * equivilent. - * - * If your system does not define the above, then you can do so by - * hand like this: - * - * #define LITTLE_ENDIAN 1234 - * #define BIG_ENDIAN 4321 - * - * And for little-endian machines, add: - * - * #define BYTE_ORDER LITTLE_ENDIAN - * - * Or for big-endian machines: - * - * #define BYTE_ORDER BIG_ENDIAN - * - * The FreeBSD machine this was written on defines BYTE_ORDER - * appropriately by including (which in turn includes - * where the appropriate definitions are actually - * made). - */ -#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) -#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN -#endif - -/* - * Define the followingsha2_* types to types of the correct length on - * the native archtecture. Most BSD systems and Linux define u_intXX_t - * types. Machines with very recent ANSI C headers, can use the - * uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H - * during compile or in the sha.h header file. - * - * Machines that support neither u_intXX_t nor inttypes.h's uintXX_t - * will need to define these three typedefs below (and the appropriate - * ones in sha.h too) by hand according to their system architecture. - * - * Thank you, Jun-ichiro itojun Hagino, for suggesting using u_intXX_t - * types and pointing out recent ANSI C support for uintXX_t in inttypes.h. - */ -#ifdef SHA2_USE_INTTYPES_H - -typedef uint8_t sha2_byte; /* Exactly 1 byte */ -typedef uint32_t sha2_word32; /* Exactly 4 bytes */ -typedef uint64_t sha2_word64; /* Exactly 8 bytes */ - -#else /* SHA2_USE_INTTYPES_H */ - -typedef u_int8_t sha2_byte; /* Exactly 1 byte */ -typedef u_int32_t sha2_word32; /* Exactly 4 bytes */ -typedef u_int64_t sha2_word64; /* Exactly 8 bytes */ - -#endif /* SHA2_USE_INTTYPES_H */ - - -/*** SHA-256/384/512 Various Length Definitions ***********************/ -/* NOTE: Most of these are in sha2.h */ -#define SHA2_SHA256_SHORT_BLOCK_LENGTH (SHA2_SHA256_BLOCK_LENGTH - 8) -#define SHA2_SHA384_SHORT_BLOCK_LENGTH (SHA2_SHA384_BLOCK_LENGTH - 16) -#define SHA2_SHA512_SHORT_BLOCK_LENGTH (SHA2_SHA512_BLOCK_LENGTH - 16) - - -/*** ENDIAN REVERSAL MACROS *******************************************/ -#if BYTE_ORDER == LITTLE_ENDIAN -#define REVERSE32(w,x) { \ - sha2_word32 tmp = (w); \ - tmp = (tmp >> 16) | (tmp << 16); \ - (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ -} -#define REVERSE64(w,x) { \ - sha2_word64 tmp = (w); \ - tmp = (tmp >> 32) | (tmp << 32); \ - tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ - ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ - (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \ - ((tmp & 0x0000ffff0000ffffULL) << 16); \ -} -#endif /* BYTE_ORDER == LITTLE_ENDIAN */ - -/* - * Macro for incrementally adding the unsigned 64-bit integer n to the - * unsigned 128-bit integer (represented using a two-element array of - * 64-bit words): - */ -#define ADDINC128(w,n) { \ - (w)[0] += (sha2_word64)(n); \ - if ((w)[0] < (n)) { \ - (w)[1]++; \ - } \ -} - -/* - * Macros for copying blocks of memory and for zeroing out ranges - * of memory. Using these macros makes it easy to switch from - * using memset()/memcpy() and using bzero()/bcopy(). - * - * Please define either SHA2_USE_MEMSET_MEMCPY or define - * SHA2_USE_BZERO_BCOPY depending on which function set you - * choose to use: - */ -#if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY) -/* Default to memset()/memcpy() if no option is specified */ -#define SHA2_USE_MEMSET_MEMCPY 1 -#endif -#if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY) -/* Abort with an error if BOTH options are defined */ -#error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both! -#endif - -#ifdef SHA2_USE_MEMSET_MEMCPY -#define MEMSET_BZERO(p,l) memset((p), 0, (l)) -#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l)) -#endif -#ifdef SHA2_USE_BZERO_BCOPY -#define MEMSET_BZERO(p,l) bzero((p), (l)) -#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l)) -#endif - - -/*** THE SIX LOGICAL FUNCTIONS ****************************************/ -/* - * Bit shifting and rotation (used by the six SHA-XYZ logical functions: - * - * NOTE: The naming of R and S appears backwards here (R is a SHIFT and - * S is a ROTATION) because the SHA-256/384/512 description document - * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this - * same "backwards" definition. - */ -/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ -#define R(b,x) ((x) >> (b)) -/* 32-bit Rotate-right (used in SHA-256): */ -#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) -/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ -#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) - -/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */ -#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) -#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) - -/* Four of six logical functions used in SHA-256: */ -#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x))) -#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x))) -#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x))) -#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x))) - -/* Four of six logical functions used in SHA-384 and SHA-512: */ -#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x))) -#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x))) -#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x))) -#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x))) - -/*** INTERNAL FUNCTION PROTOTYPES *************************************/ -/* NOTE: These should not be accessed directly from outside this - * library -- they are intended for private internal visibility/use - * only. - */ -void SHA2_SHA512_Last(SHA2_SHA512_CTX*); -void SHA2_SHA256_Transform(SHA2_SHA256_CTX*, const sha2_word32*); -void SHA2_SHA512_Transform(SHA2_SHA512_CTX*, const sha2_word64*); - - -/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ -/* Hash constant words K for SHA-256: */ -const static sha2_word32 K256[64] = { - 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, - 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, - 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, - 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, - 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, - 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, - 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, - 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, - 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, - 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, - 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, - 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, - 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, - 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, - 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, - 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL -}; - -/* Initial hash value H for SHA-256: */ -const static sha2_word32 sha256_initial_hash_value[8] = { - 0x6a09e667UL, - 0xbb67ae85UL, - 0x3c6ef372UL, - 0xa54ff53aUL, - 0x510e527fUL, - 0x9b05688cUL, - 0x1f83d9abUL, - 0x5be0cd19UL -}; - -/* Hash constant words K for SHA-384 and SHA-512: */ -const static sha2_word64 K512[80] = { - 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, - 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, - 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, - 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, - 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, - 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, - 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, - 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, - 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, - 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, - 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, - 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, - 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, - 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, - 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, - 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, - 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, - 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, - 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, - 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, - 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, - 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, - 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, - 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, - 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, - 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, - 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, - 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, - 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, - 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, - 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, - 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, - 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, - 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, - 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, - 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, - 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, - 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, - 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, - 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL -}; - -/* Initial hash value H for SHA-384 */ -const static sha2_word64 sha384_initial_hash_value[8] = { - 0xcbbb9d5dc1059ed8ULL, - 0x629a292a367cd507ULL, - 0x9159015a3070dd17ULL, - 0x152fecd8f70e5939ULL, - 0x67332667ffc00b31ULL, - 0x8eb44a8768581511ULL, - 0xdb0c2e0d64f98fa7ULL, - 0x47b5481dbefa4fa4ULL -}; - -/* Initial hash value H for SHA-512 */ -const static sha2_word64 sha512_initial_hash_value[8] = { - 0x6a09e667f3bcc908ULL, - 0xbb67ae8584caa73bULL, - 0x3c6ef372fe94f82bULL, - 0xa54ff53a5f1d36f1ULL, - 0x510e527fade682d1ULL, - 0x9b05688c2b3e6c1fULL, - 0x1f83d9abfb41bd6bULL, - 0x5be0cd19137e2179ULL -}; - -/* - * Constant used by SHA256/384/512_End() functions for converting the - * digest to a readable hexadecimal character string: - */ -static const char *sha2_hex_digits = "0123456789abcdef"; - - -/*** SHA-256: *********************************************************/ -void SHA2_SHA256_Init(SHA2_SHA256_CTX* context) { - if (context == (SHA2_SHA256_CTX*)0) { - return; - } - MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA2_SHA256_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA2_SHA256_BLOCK_LENGTH); - context->bitcount = 0; -} - -#ifdef SHA2_UNROLL_TRANSFORM - -/* Unrolled SHA-256 round macros: */ - -#if BYTE_ORDER == LITTLE_ENDIAN - -#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ - REVERSE32(*data++, W256[j]); \ - T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ - K256[j] + W256[j]; \ - (d) += T1; \ - (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ - j++ - - -#else /* BYTE_ORDER == LITTLE_ENDIAN */ - -#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ - T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ - K256[j] + (W256[j] = *data++); \ - (d) += T1; \ - (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ - j++ - -#endif /* BYTE_ORDER == LITTLE_ENDIAN */ - -#define ROUND256(a,b,c,d,e,f,g,h) \ - s0 = W256[(j+1)&0x0f]; \ - s0 = sigma0_256(s0); \ - s1 = W256[(j+14)&0x0f]; \ - s1 = sigma1_256(s1); \ - T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \ - (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ - (d) += T1; \ - (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ - j++ - -void SHA2_SHA256_Transform(SHA2_SHA256_CTX* context, const sha2_word32* data) { - sha2_word32 a, b, c, d, e, f, g, h, s0, s1; - sha2_word32 T1, *W256; - int j; - - W256 = (sha2_word32*)context->buffer; - - /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; - - j = 0; - do { - /* Rounds 0 to 15 (unrolled): */ - ROUND256_0_TO_15(a,b,c,d,e,f,g,h); - ROUND256_0_TO_15(h,a,b,c,d,e,f,g); - ROUND256_0_TO_15(g,h,a,b,c,d,e,f); - ROUND256_0_TO_15(f,g,h,a,b,c,d,e); - ROUND256_0_TO_15(e,f,g,h,a,b,c,d); - ROUND256_0_TO_15(d,e,f,g,h,a,b,c); - ROUND256_0_TO_15(c,d,e,f,g,h,a,b); - ROUND256_0_TO_15(b,c,d,e,f,g,h,a); - } while (j < 16); - - /* Now for the remaining rounds to 64: */ - do { - ROUND256(a,b,c,d,e,f,g,h); - ROUND256(h,a,b,c,d,e,f,g); - ROUND256(g,h,a,b,c,d,e,f); - ROUND256(f,g,h,a,b,c,d,e); - ROUND256(e,f,g,h,a,b,c,d); - ROUND256(d,e,f,g,h,a,b,c); - ROUND256(c,d,e,f,g,h,a,b); - ROUND256(b,c,d,e,f,g,h,a); - } while (j < 64); - - /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = 0; -} - -#else /* SHA2_UNROLL_TRANSFORM */ - -void SHA2_SHA256_Transform(SHA2_SHA256_CTX* context, const sha2_word32* data) { - sha2_word32 a, b, c, d, e, f, g, h, s0, s1; - sha2_word32 T1, T2, *W256; - int j; - - W256 = (sha2_word32*)context->buffer; - - /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; - - j = 0; - do { -#if BYTE_ORDER == LITTLE_ENDIAN - /* Copy data while converting to host byte order */ - REVERSE32(*data++,W256[j]); - /* Apply the SHA-256 compression function to update a..h */ - T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j]; -#else /* BYTE_ORDER == LITTLE_ENDIAN */ - /* Apply the SHA-256 compression function to update a..h with copy */ - T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++); -#endif /* BYTE_ORDER == LITTLE_ENDIAN */ - T2 = Sigma0_256(a) + Maj(a, b, c); - h = g; - g = f; - f = e; - e = d + T1; - d = c; - c = b; - b = a; - a = T1 + T2; - - j++; - } while (j < 16); - - do { - /* Part of the message block expansion: */ - s0 = W256[(j+1)&0x0f]; - s0 = sigma0_256(s0); - s1 = W256[(j+14)&0x0f]; - s1 = sigma1_256(s1); - - /* Apply the SHA-256 compression function to update a..h */ - T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + - (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); - T2 = Sigma0_256(a) + Maj(a, b, c); - h = g; - g = f; - f = e; - e = d + T1; - d = c; - c = b; - b = a; - a = T1 + T2; - - j++; - } while (j < 64); - - /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = T2 = 0; -} - -#endif /* SHA2_UNROLL_TRANSFORM */ - -void SHA2_SHA256_Update(SHA2_SHA256_CTX* context, const sha2_byte *data, size_t len) { - unsigned int freespace, usedspace; - - if (len == 0) { - /* Calling with no data is valid - we do nothing */ - return; - } - - /* Sanity check: */ - assert(context != (SHA2_SHA256_CTX*)0 && data != (sha2_byte*)0); - - usedspace = (context->bitcount >> 3) % SHA2_SHA256_BLOCK_LENGTH; - if (usedspace > 0) { - /* Calculate how much free space is available in the buffer */ - freespace = SHA2_SHA256_BLOCK_LENGTH - usedspace; - - if (len >= freespace) { - /* Fill the buffer completely and process it */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); - context->bitcount += freespace << 3; - len -= freespace; - data += freespace; - SHA2_SHA256_Transform(context, (sha2_word32*)context->buffer); - } else { - /* The buffer is not yet full */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, len); - context->bitcount += len << 3; - /* Clean up: */ - usedspace = freespace = 0; - return; - } - } - while (len >= SHA2_SHA256_BLOCK_LENGTH) { - /* Process as many complete blocks as we can */ - SHA2_SHA256_Transform(context, (sha2_word32*)data); - context->bitcount += SHA2_SHA256_BLOCK_LENGTH << 3; - len -= SHA2_SHA256_BLOCK_LENGTH; - data += SHA2_SHA256_BLOCK_LENGTH; - } - if (len > 0) { - /* There's left-overs, so save 'em */ - MEMCPY_BCOPY(context->buffer, data, len); - context->bitcount += len << 3; - } - /* Clean up: */ - usedspace = freespace = 0; -} - -void SHA2_SHA256_Final(sha2_byte digest[], SHA2_SHA256_CTX* context) { - sha2_word32 *d = (sha2_word32*)digest; - unsigned int usedspace; - - /* Sanity check: */ - assert(context != (SHA2_SHA256_CTX*)0); - - /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - usedspace = (context->bitcount >> 3) % SHA2_SHA256_BLOCK_LENGTH; -#if BYTE_ORDER == LITTLE_ENDIAN - /* Convert FROM host byte order */ - REVERSE64(context->bitcount,context->bitcount); -#endif - if (usedspace > 0) { - /* Begin padding with a 1 bit: */ - context->buffer[usedspace++] = 0x80; - - if (usedspace <= SHA2_SHA256_SHORT_BLOCK_LENGTH) { - /* Set-up for the last transform: */ - MEMSET_BZERO(&context->buffer[usedspace], SHA2_SHA256_SHORT_BLOCK_LENGTH - usedspace); - } else { - if (usedspace < SHA2_SHA256_BLOCK_LENGTH) { - MEMSET_BZERO(&context->buffer[usedspace], SHA2_SHA256_BLOCK_LENGTH - usedspace); - } - /* Do second-to-last transform: */ - SHA2_SHA256_Transform(context, (sha2_word32*)context->buffer); - - /* And set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA2_SHA256_SHORT_BLOCK_LENGTH); - } - } else { - /* Set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA2_SHA256_SHORT_BLOCK_LENGTH); - - /* Begin padding with a 1 bit: */ - *context->buffer = 0x80; - } - /* Set the bit count: */ - *(sha2_word64*)&context->buffer[SHA2_SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; - - /* Final transform: */ - SHA2_SHA256_Transform(context, (sha2_word32*)context->buffer); - -#if BYTE_ORDER == LITTLE_ENDIAN - { - /* Convert TO host byte order */ - int j; - for (j = 0; j < 8; j++) { - REVERSE32(context->state[j],context->state[j]); - *d++ = context->state[j]; - } - } -#else - MEMCPY_BCOPY(d, context->state, SHA2_SHA256_DIGEST_LENGTH); -#endif - } - - /* Clean up state data: */ - MEMSET_BZERO(context, sizeof(SHA2_SHA256_CTX)); - usedspace = 0; -} - -char *SHA2_SHA256_End(SHA2_SHA256_CTX* context, char buffer[]) { - sha2_byte digest[SHA2_SHA256_DIGEST_LENGTH], *d = digest; - int i; - - /* Sanity check: */ - assert(context != (SHA2_SHA256_CTX*)0); - - if (buffer != (char*)0) { - SHA2_SHA256_Final(digest, context); - - for (i = 0; i < SHA2_SHA256_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; - d++; - } - *buffer = (char)0; - } else { - MEMSET_BZERO(context, sizeof(SHA2_SHA256_CTX)); - } - MEMSET_BZERO(digest, SHA2_SHA256_DIGEST_LENGTH); - return buffer; -} - -char* SHA2_SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA2_SHA256_DIGEST_STRING_LENGTH]) { - SHA2_SHA256_CTX context; - - SHA2_SHA256_Init(&context); - SHA2_SHA256_Update(&context, data, len); - return SHA2_SHA256_End(&context, digest); -} - - -/*** SHA-512: *********************************************************/ -void SHA2_SHA512_Init(SHA2_SHA512_CTX* context) { - if (context == (SHA2_SHA512_CTX*)0) { - return; - } - MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA2_SHA512_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA2_SHA512_BLOCK_LENGTH); - context->bitcount[0] = context->bitcount[1] = 0; -} - -#ifdef SHA2_UNROLL_TRANSFORM - -/* Unrolled SHA-512 round macros: */ -#if BYTE_ORDER == LITTLE_ENDIAN - -#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ - REVERSE64(*data++, W512[j]); \ - T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ - K512[j] + W512[j]; \ - (d) += T1, \ - (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \ - j++ - - -#else /* BYTE_ORDER == LITTLE_ENDIAN */ - -#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ - T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ - K512[j] + (W512[j] = *data++); \ - (d) += T1; \ - (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ - j++ - -#endif /* BYTE_ORDER == LITTLE_ENDIAN */ - -#define ROUND512(a,b,c,d,e,f,g,h) \ - s0 = W512[(j+1)&0x0f]; \ - s0 = sigma0_512(s0); \ - s1 = W512[(j+14)&0x0f]; \ - s1 = sigma1_512(s1); \ - T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \ - (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ - (d) += T1; \ - (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ - j++ - -void SHA2_SHA512_Transform(SHA2_SHA512_CTX* context, const sha2_word64* data) { - sha2_word64 a, b, c, d, e, f, g, h, s0, s1; - sha2_word64 T1, *W512 = (sha2_word64*)context->buffer; - int j; - - /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; - - j = 0; - do { - ROUND512_0_TO_15(a,b,c,d,e,f,g,h); - ROUND512_0_TO_15(h,a,b,c,d,e,f,g); - ROUND512_0_TO_15(g,h,a,b,c,d,e,f); - ROUND512_0_TO_15(f,g,h,a,b,c,d,e); - ROUND512_0_TO_15(e,f,g,h,a,b,c,d); - ROUND512_0_TO_15(d,e,f,g,h,a,b,c); - ROUND512_0_TO_15(c,d,e,f,g,h,a,b); - ROUND512_0_TO_15(b,c,d,e,f,g,h,a); - } while (j < 16); - - /* Now for the remaining rounds up to 79: */ - do { - ROUND512(a,b,c,d,e,f,g,h); - ROUND512(h,a,b,c,d,e,f,g); - ROUND512(g,h,a,b,c,d,e,f); - ROUND512(f,g,h,a,b,c,d,e); - ROUND512(e,f,g,h,a,b,c,d); - ROUND512(d,e,f,g,h,a,b,c); - ROUND512(c,d,e,f,g,h,a,b); - ROUND512(b,c,d,e,f,g,h,a); - } while (j < 80); - - /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = 0; -} - -#else /* SHA2_UNROLL_TRANSFORM */ - -void SHA2_SHA512_Transform(SHA2_SHA512_CTX* context, const sha2_word64* data) { - sha2_word64 a, b, c, d, e, f, g, h, s0, s1; - sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer; - int j; - - /* Initialize registers with the prev. intermediate value */ - a = context->state[0]; - b = context->state[1]; - c = context->state[2]; - d = context->state[3]; - e = context->state[4]; - f = context->state[5]; - g = context->state[6]; - h = context->state[7]; - - j = 0; - do { -#if BYTE_ORDER == LITTLE_ENDIAN - /* Convert TO host byte order */ - REVERSE64(*data++, W512[j]); - /* Apply the SHA-512 compression function to update a..h */ - T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j]; -#else /* BYTE_ORDER == LITTLE_ENDIAN */ - /* Apply the SHA-512 compression function to update a..h with copy */ - T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); -#endif /* BYTE_ORDER == LITTLE_ENDIAN */ - T2 = Sigma0_512(a) + Maj(a, b, c); - h = g; - g = f; - f = e; - e = d + T1; - d = c; - c = b; - b = a; - a = T1 + T2; - - j++; - } while (j < 16); - - do { - /* Part of the message block expansion: */ - s0 = W512[(j+1)&0x0f]; - s0 = sigma0_512(s0); - s1 = W512[(j+14)&0x0f]; - s1 = sigma1_512(s1); - - /* Apply the SHA-512 compression function to update a..h */ - T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + - (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); - T2 = Sigma0_512(a) + Maj(a, b, c); - h = g; - g = f; - f = e; - e = d + T1; - d = c; - c = b; - b = a; - a = T1 + T2; - - j++; - } while (j < 80); - - /* Compute the current intermediate hash value */ - context->state[0] += a; - context->state[1] += b; - context->state[2] += c; - context->state[3] += d; - context->state[4] += e; - context->state[5] += f; - context->state[6] += g; - context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = T2 = 0; -} - -#endif /* SHA2_UNROLL_TRANSFORM */ - -void SHA2_SHA512_Update(SHA2_SHA512_CTX* context, const sha2_byte *data, size_t len) { - unsigned int freespace, usedspace; - - if (len == 0) { - /* Calling with no data is valid - we do nothing */ - return; - } - - /* Sanity check: */ - assert(context != (SHA2_SHA512_CTX*)0 && data != (sha2_byte*)0); - - usedspace = (context->bitcount[0] >> 3) % SHA2_SHA512_BLOCK_LENGTH; - if (usedspace > 0) { - /* Calculate how much free space is available in the buffer */ - freespace = SHA2_SHA512_BLOCK_LENGTH - usedspace; - - if (len >= freespace) { - /* Fill the buffer completely and process it */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace); - ADDINC128(context->bitcount, freespace << 3); - len -= freespace; - data += freespace; - SHA2_SHA512_Transform(context, (sha2_word64*)context->buffer); - } else { - /* The buffer is not yet full */ - MEMCPY_BCOPY(&context->buffer[usedspace], data, len); - ADDINC128(context->bitcount, len << 3); - /* Clean up: */ - usedspace = freespace = 0; - return; - } - } - while (len >= SHA2_SHA512_BLOCK_LENGTH) { - /* Process as many complete blocks as we can */ - SHA2_SHA512_Transform(context, (sha2_word64*)data); - ADDINC128(context->bitcount, SHA2_SHA512_BLOCK_LENGTH << 3); - len -= SHA2_SHA512_BLOCK_LENGTH; - data += SHA2_SHA512_BLOCK_LENGTH; - } - if (len > 0) { - /* There's left-overs, so save 'em */ - MEMCPY_BCOPY(context->buffer, data, len); - ADDINC128(context->bitcount, len << 3); - } - /* Clean up: */ - usedspace = freespace = 0; -} - -void SHA2_SHA512_Last(SHA2_SHA512_CTX* context) { - unsigned int usedspace; - - usedspace = (context->bitcount[0] >> 3) % SHA2_SHA512_BLOCK_LENGTH; -#if BYTE_ORDER == LITTLE_ENDIAN - /* Convert FROM host byte order */ - REVERSE64(context->bitcount[0],context->bitcount[0]); - REVERSE64(context->bitcount[1],context->bitcount[1]); -#endif - if (usedspace > 0) { - /* Begin padding with a 1 bit: */ - context->buffer[usedspace++] = 0x80; - - if (usedspace <= SHA2_SHA512_SHORT_BLOCK_LENGTH) { - /* Set-up for the last transform: */ - MEMSET_BZERO(&context->buffer[usedspace], SHA2_SHA512_SHORT_BLOCK_LENGTH - usedspace); - } else { - if (usedspace < SHA2_SHA512_BLOCK_LENGTH) { - MEMSET_BZERO(&context->buffer[usedspace], SHA2_SHA512_BLOCK_LENGTH - usedspace); - } - /* Do second-to-last transform: */ - SHA2_SHA512_Transform(context, (sha2_word64*)context->buffer); - - /* And set-up for the last transform: */ - MEMSET_BZERO(context->buffer, SHA2_SHA512_BLOCK_LENGTH - 2); - } - } else { - /* Prepare for final transform: */ - MEMSET_BZERO(context->buffer, SHA2_SHA512_SHORT_BLOCK_LENGTH); - - /* Begin padding with a 1 bit: */ - *context->buffer = 0x80; - } - /* Store the length of input data (in bits): */ - *(sha2_word64*)&context->buffer[SHA2_SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; - *(sha2_word64*)&context->buffer[SHA2_SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; - - /* Final transform: */ - SHA2_SHA512_Transform(context, (sha2_word64*)context->buffer); -} - -void SHA2_SHA512_Final(sha2_byte digest[], SHA2_SHA512_CTX* context) { - sha2_word64 *d = (sha2_word64*)digest; - - /* Sanity check: */ - assert(context != (SHA2_SHA512_CTX*)0); - - /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - SHA2_SHA512_Last(context); - - /* Save the hash data for output: */ -#if BYTE_ORDER == LITTLE_ENDIAN - { - /* Convert TO host byte order */ - int j; - for (j = 0; j < 8; j++) { - REVERSE64(context->state[j],context->state[j]); - *d++ = context->state[j]; - } - } -#else - MEMCPY_BCOPY(d, context->state, SHA2_SHA512_DIGEST_LENGTH); -#endif - } - - /* Zero out state data */ - MEMSET_BZERO(context, sizeof(SHA2_SHA512_CTX)); -} - -char *SHA2_SHA512_End(SHA2_SHA512_CTX* context, char buffer[]) { - sha2_byte digest[SHA2_SHA512_DIGEST_LENGTH], *d = digest; - int i; - - /* Sanity check: */ - assert(context != (SHA2_SHA512_CTX*)0); - - if (buffer != (char*)0) { - SHA2_SHA512_Final(digest, context); - - for (i = 0; i < SHA2_SHA512_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; - d++; - } - *buffer = (char)0; - } else { - MEMSET_BZERO(context, sizeof(SHA2_SHA512_CTX)); - } - MEMSET_BZERO(digest, SHA2_SHA512_DIGEST_LENGTH); - return buffer; -} - -char* SHA2_SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA2_SHA512_DIGEST_STRING_LENGTH]) { - SHA2_SHA512_CTX context; - - SHA2_SHA512_Init(&context); - SHA2_SHA512_Update(&context, data, len); - return SHA2_SHA512_End(&context, digest); -} - - -/*** SHA-384: *********************************************************/ -void SHA2_SHA384_Init(SHA2_SHA384_CTX* context) { - if (context == (SHA2_SHA384_CTX*)0) { - return; - } - MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA2_SHA512_DIGEST_LENGTH); - MEMSET_BZERO(context->buffer, SHA2_SHA384_BLOCK_LENGTH); - context->bitcount[0] = context->bitcount[1] = 0; -} - -void SHA2_SHA384_Update(SHA2_SHA384_CTX* context, const sha2_byte* data, size_t len) { - SHA2_SHA512_Update((SHA2_SHA512_CTX*)context, data, len); -} - -void SHA2_SHA384_Final(sha2_byte digest[], SHA2_SHA384_CTX* context) { - sha2_word64 *d = (sha2_word64*)digest; - - /* Sanity check: */ - assert(context != (SHA2_SHA384_CTX*)0); - - /* If no digest buffer is passed, we don't bother doing this: */ - if (digest != (sha2_byte*)0) { - SHA2_SHA512_Last((SHA2_SHA512_CTX*)context); - - /* Save the hash data for output: */ -#if BYTE_ORDER == LITTLE_ENDIAN - { - /* Convert TO host byte order */ - int j; - for (j = 0; j < 6; j++) { - REVERSE64(context->state[j],context->state[j]); - *d++ = context->state[j]; - } - } -#else - MEMCPY_BCOPY(d, context->state, SHA2_SHA384_DIGEST_LENGTH); -#endif - } - - /* Zero out state data */ - MEMSET_BZERO(context, sizeof(SHA2_SHA384_CTX)); -} - -char *SHA2_SHA384_End(SHA2_SHA384_CTX* context, char buffer[]) { - sha2_byte digest[SHA2_SHA384_DIGEST_LENGTH], *d = digest; - int i; - - /* Sanity check: */ - assert(context != (SHA2_SHA384_CTX*)0); - - if (buffer != (char*)0) { - SHA2_SHA384_Final(digest, context); - - for (i = 0; i < SHA2_SHA384_DIGEST_LENGTH; i++) { - *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; - *buffer++ = sha2_hex_digits[*d & 0x0f]; - d++; - } - *buffer = (char)0; - } else { - MEMSET_BZERO(context, sizeof(SHA2_SHA384_CTX)); - } - MEMSET_BZERO(digest, SHA2_SHA384_DIGEST_LENGTH); - return buffer; -} - -char* SHA2_SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA2_SHA384_DIGEST_STRING_LENGTH]) { - SHA2_SHA384_CTX context; - - SHA2_SHA384_Init(&context); - SHA2_SHA384_Update(&context, data, len); - return SHA2_SHA384_End(&context, digest); -} - diff --git a/libUseful-2.6/sha2.h b/libUseful-2.6/sha2.h deleted file mode 100755 index b8631ef..0000000 --- a/libUseful-2.6/sha2.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * FILE: sha2.h - * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ - * - * Copyright (c) 2000-2001, Aaron D. Gifford - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of the copyright holder nor the names of contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``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 AUTHOR OR CONTRIBUTOR(S) 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. - * - * $Id: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $ - */ - -#ifndef __SHA2_H__ -#define __SHA2_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * Import u_intXX_t size_t type definitions from system headers. You - * may need to change this, or define these things yourself in this - * file. - */ -#include - -#ifdef SHA2_USE_INTTYPES_H - -#include - -#endif /* SHA2_USE_INTTYPES_H */ - - -/*** SHA-256/384/512 Various Length Definitions ***********************/ -#define SHA2_SHA256_BLOCK_LENGTH 64 -#define SHA2_SHA256_DIGEST_LENGTH 32 -#define SHA2_SHA256_DIGEST_STRING_LENGTH (SHA2_SHA256_DIGEST_LENGTH * 2 + 1) -#define SHA2_SHA384_BLOCK_LENGTH 128 -#define SHA2_SHA384_DIGEST_LENGTH 48 -#define SHA2_SHA384_DIGEST_STRING_LENGTH (SHA2_SHA384_DIGEST_LENGTH * 2 + 1) -#define SHA2_SHA512_BLOCK_LENGTH 128 -#define SHA2_SHA512_DIGEST_LENGTH 64 -#define SHA2_SHA512_DIGEST_STRING_LENGTH (SHA2_SHA512_DIGEST_LENGTH * 2 + 1) - - -/*** SHA-256/384/512 Context Structures *******************************/ -/* NOTE: If your architecture does not define either u_intXX_t types or - * uintXX_t (from inttypes.h), you may need to define things by hand - * for your system: - */ -#if 0 -typedef unsigned char u_int8_t; /* 1-byte (8-bits) */ -typedef unsigned int u_int32_t; /* 4-bytes (32-bits) */ -typedef unsigned long long u_int64_t; /* 8-bytes (64-bits) */ -#endif -/* - * Most BSD systems already define u_intXX_t types, as does Linux. - * Some systems, however, like Compaq's Tru64 Unix instead can use - * uintXX_t types defined by very recent ANSI C standards and included - * in the file: - * - * #include - * - * If you choose to use then please define: - * - * #define SHA2_USE_INTTYPES_H - * - * Or on the command line during compile: - * - * cc -DSHA2_USE_INTTYPES_H ... - */ -#ifdef SHA2_USE_INTTYPES_H - -typedef struct _SHA2_SHA256_CTX { - uint32_t state[8]; - uint64_t bitcount; - uint8_t buffer[SHA2_SHA256_BLOCK_LENGTH]; -} SHA2_SHA256_CTX; -typedef struct _SHA2_SHA512_CTX { - uint64_t state[8]; - uint64_t bitcount[2]; - uint8_t buffer[SHA2_SHA512_BLOCK_LENGTH]; -} SHA2_SHA512_CTX; - -#else /* SHA2_USE_INTTYPES_H */ - -typedef struct _SHA2_SHA256_CTX { - u_int32_t state[8]; - u_int64_t bitcount; - u_int8_t buffer[SHA2_SHA256_BLOCK_LENGTH]; -} SHA2_SHA256_CTX; -typedef struct _SHA2_SHA512_CTX { - u_int64_t state[8]; - u_int64_t bitcount[2]; - u_int8_t buffer[SHA2_SHA512_BLOCK_LENGTH]; -} SHA2_SHA512_CTX; - -#endif /* SHA2_USE_INTTYPES_H */ - -typedef SHA2_SHA512_CTX SHA2_SHA384_CTX; - - -/*** SHA-256/384/512 Function Prototypes ******************************/ -#ifndef NOPROTO -#ifdef SHA2_USE_INTTYPES_H - -void SHA2_SHA256_Init(SHA2_SHA256_CTX *); -void SHA2_SHA256_Update(SHA2_SHA256_CTX*, const uint8_t*, size_t); -void SHA2_SHA256_Final(uint8_t[SHA2_SHA256_DIGEST_LENGTH], SHA2_SHA256_CTX*); -char* SHA2_SHA256_End(SHA2_SHA256_CTX*, char[SHA2_SHA256_DIGEST_STRING_LENGTH]); -char* SHA2_SHA256_Data(const uint8_t*, size_t, char[SHA2_SHA256_DIGEST_STRING_LENGTH]); - -void SHA2_SHA384_Init(SHA2_SHA384_CTX*); -void SHA2_SHA384_Update(SHA2_SHA384_CTX*, const uint8_t*, size_t); -void SHA2_SHA384_Final(uint8_t[SHA2_SHA384_DIGEST_LENGTH], SHA2_SHA384_CTX*); -char* SHA2_SHA384_End(SHA2_SHA384_CTX*, char[SHA2_SHA384_DIGEST_STRING_LENGTH]); -char* SHA2_SHA384_Data(const uint8_t*, size_t, char[SHA2_SHA384_DIGEST_STRING_LENGTH]); - -void SHA2_SHA512_Init(SHA2_SHA512_CTX*); -void SHA2_SHA512_Update(SHA2_SHA512_CTX*, const uint8_t*, size_t); -void SHA2_SHA512_Final(uint8_t[SHA2_SHA512_DIGEST_LENGTH], SHA2_SHA512_CTX*); -char* SHA2_SHA512_End(SHA2_SHA512_CTX*, char[SHA2_SHA512_DIGEST_STRING_LENGTH]); -char* SHA2_SHA512_Data(const uint8_t*, size_t, char[SHA2_SHA512_DIGEST_STRING_LENGTH]); - -#else /* SHA2_USE_INTTYPES_H */ - -void SHA2_SHA256_Init(SHA2_SHA256_CTX *); -void SHA2_SHA256_Update(SHA2_SHA256_CTX*, const u_int8_t*, size_t); -void SHA2_SHA256_Final(u_int8_t[SHA2_SHA256_DIGEST_LENGTH], SHA2_SHA256_CTX*); -char* SHA2_SHA256_End(SHA2_SHA256_CTX*, char[SHA2_SHA256_DIGEST_STRING_LENGTH]); -char* SHA2_SHA256_Data(const u_int8_t*, size_t, char[SHA2_SHA256_DIGEST_STRING_LENGTH]); - -void SHA2_SHA384_Init(SHA2_SHA384_CTX*); -void SHA2_SHA384_Update(SHA2_SHA384_CTX*, const u_int8_t*, size_t); -void SHA2_SHA384_Final(u_int8_t[SHA2_SHA384_DIGEST_LENGTH], SHA2_SHA384_CTX*); -char* SHA2_SHA384_End(SHA2_SHA384_CTX*, char[SHA2_SHA384_DIGEST_STRING_LENGTH]); -char* SHA2_SHA384_Data(const u_int8_t*, size_t, char[SHA2_SHA384_DIGEST_STRING_LENGTH]); - -void SHA2_SHA512_Init(SHA2_SHA512_CTX*); -void SHA2_SHA512_Update(SHA2_SHA512_CTX*, const u_int8_t*, size_t); -void SHA2_SHA512_Final(u_int8_t[SHA2_SHA512_DIGEST_LENGTH], SHA2_SHA512_CTX*); -char* SHA2_SHA512_End(SHA2_SHA512_CTX*, char[SHA2_SHA512_DIGEST_STRING_LENGTH]); -char* SHA2_SHA512_Data(const u_int8_t*, size_t, char[SHA2_SHA512_DIGEST_STRING_LENGTH]); - -#endif /* SHA2_USE_INTTYPES_H */ - -#else /* NOPROTO */ - -void SHA2_SHA256_Init(); -void SHA2_SHA256_Update(); -void SHA2_SHA256_Final(); -char* SHA2_SHA256_End(); -char* SHA2_SHA256_Data(); - -void SHA2_SHA384_Init(); -void SHA2_SHA384_Update(); -void SHA2_SHA384_Final(); -char* SHA2_SHA384_End(); -char* SHA2_SHA384_Data(); - -void SHA512_Init(); -void SHA512_Update(); -void SHA512_Final(); -char* SHA512_End(); -char* SHA512_Data(); - -#endif /* NOPROTO */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __SHA2_H__ */ - diff --git a/libUseful-2.6/socket.c b/libUseful-2.6/socket.c deleted file mode 100755 index 842d8c9..0000000 --- a/libUseful-2.6/socket.c +++ /dev/null @@ -1,1038 +0,0 @@ -#include "socket.h" -#include "ConnectionChain.h" -#include "ParseURL.h" -#include "unix_socket.h" - -#include -#include -#include -#include -#include - - -int IsIP4Address(const char *Str) -{ -const char *ptr; -int dot_count=0; -int AllowDot=FALSE; - -if (! Str) return(FALSE); - -for (ptr=Str; *ptr != '\0'; ptr++) -{ - if (*ptr == '.') - { - if (! AllowDot) return(FALSE); - dot_count++; - AllowDot=FALSE; - } - else - { - if (! isdigit(*ptr)) return(FALSE); - AllowDot=TRUE; - } -} - -if (dot_count != 3) return(FALSE); - -return(TRUE); -} - - -int IsIP6Address(const char *Str) -{ -const char *ptr; -const char *IP6CHARS="0123456789abcdefABCDEF:%"; - -if (!Str) return(FALSE); - -for (ptr=Str; *ptr != '\0'; ptr++) -{ - if (*ptr=='%') break; - if (! strchr(IP6CHARS,*ptr)) return(FALSE); -} - -return(TRUE); -} - - - - -/* This is a simple function to decide if a string is an IP address as */ -/* opposed to a host/domain name. */ - -int IsIPAddress(const char *Str) -{ -int len,count; -len=strlen(Str); -if (len <1) return(FALSE); -for (count=0; count < len; count++) - if ((! isdigit(Str[count])) && (Str[count] !='.')) return(FALSE); - return(TRUE); -} - - - - -int IsSockConnected(int sock) -{ -struct sockaddr_in sa; -socklen_t salen; -int result; - -if (sock==-1) return(FALSE); -salen=sizeof(sa); -result=getpeername(sock,(struct sockaddr *) &sa, &salen); -if (result==0) return(TRUE); -if (errno==ENOTCONN) return(SOCK_CONNECTING); -return(FALSE); -} - - -//Socket options wrapped in ifdef statements to handle systems that lack certain options -int SockSetOptions(int sock, int SetFlags, int UnsetFlags) -{ -int result; - -result=TRUE; -#ifdef SO_BROADCAST -if (SetFlags & SOCK_BROADCAST) result=setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &result,sizeof(int)); -#endif - -#ifdef SO_DONTROUTE -if (SetFlags & SOCK_DONTROUTE) result=setsockopt(sock, SOL_SOCKET, SO_DONTROUTE, &result,sizeof(int)); -#endif - -#ifdef SO_REUSEPORT -if (SetFlags & SOCK_REUSEPORT) result=setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &result,sizeof(int)); -#endif - -#ifdef IP_TRANSPARENT -if (SetFlags & SOCK_TPROXY) result=setsockopt(sock, IPPROTO_IP, IP_TRANSPARENT, &result,sizeof(int)); -#endif - -#ifdef SO_PASSCRED -if (SetFlags & SOCK_PEERCREDS) result=setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &result,sizeof(int)); -#endif - -#ifdef SO_KEEPALIVE -//Default is KEEPALIVE ON -setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &result,sizeof(int)); -#endif - -if (SetFlags & CONNECT_NONBLOCK) fcntl(sock,F_SETFL,O_NONBLOCK); - - -#ifdef SO_BROADCAST -if (UnsetFlags & SOCK_BROADCAST) result=setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &result,sizeof(int)); -#endif - -#ifdef SO_DONTROUTE -if (UnsetFlags & SOCK_DONTROUTE) result=setsockopt(sock, SOL_SOCKET, SO_DONTROUTE, &result,sizeof(int)); -#endif - -#ifdef SO_REUSEPORT -if (UnsetFlags & SOCK_REUSEPORT) result=setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &result,sizeof(int)); -#endif - -#ifdef IP_TRANSPARENT -if (UnsetFlags & SOCK_TPROXY) result=setsockopt(sock, IPPROTO_IP, IP_TRANSPARENT, &result,sizeof(int)); -#endif - -#ifdef SO_PASSCRED -if (UnsetFlags & SOCK_PEERCREDS) result=setsockopt(sock, SOL_SOCKET, SO_PASSCRED, &result,sizeof(int)); -#endif - -result=FALSE; -#ifdef SO_KEEPALIVE -if (SetFlags & SOCK_NOKEEPALIVE) setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &result,sizeof(int)); -#endif -} - - - - - -int SockSetAttribute(int sock, int Attrib, int Value) -{ - - -} - -int SockGetAttribute(int sock, int Attrib, int Value) -{ - - -} - - - -int GetHostARP(const char *IP, char **Device, char **MAC) -{ -char *Tempstr=NULL, *Token=NULL; -int result=FALSE; -const char *ptr; -FILE *F; - -Tempstr=SetStrLen(Tempstr, 255); -F=fopen("/proc/net/arp","r"); -if (F) -{ - *Device=CopyStr(*Device,"remote"); - *MAC=CopyStr(*MAC,"remote"); - //Read Title Line - fgets(Tempstr,255,F); - - while (fgets(Tempstr,255,F)) - { - StripTrailingWhitespace(Tempstr); - ptr=GetToken(Tempstr," ",&Token,0); - if (strcmp(Token,IP)==0) - { - while (isspace(*ptr)) ptr++; - ptr=GetToken(ptr," ",&Token,0); - - while (isspace(*ptr)) ptr++; - ptr=GetToken(ptr," ",&Token,0); - - while (isspace(*ptr)) ptr++; - ptr=GetToken(ptr," ",MAC,0); - strlwr(*MAC); - - while (isspace(*ptr)) ptr++; - ptr=GetToken(ptr," ",&Token,0); - - while (isspace(*ptr)) ptr++; - ptr=GetToken(ptr," ",Device,0); - - result=TRUE; - } - } -fclose(F); -} - -DestroyString(Tempstr); -DestroyString(Token); - -return(result); -} - - - - -const char *GetInterfaceIP(const char *Interface) -{ - int fd, result; - struct ifreq ifr; - - fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd==-1) return(""); - - ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name, Interface, IFNAMSIZ-1); - result=ioctl(fd, SIOCGIFADDR, &ifr); - if (result==-1) return(""); - close(fd); - - return(inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr)); -} - - -#ifdef __GNU_LIBRARY__ - - -#include - -/*--------------------------------------------------------------------*/ -/*--- checksum - standard 1s complement checksum ---*/ -/*--------------------------------------------------------------------*/ -unsigned short checksum(void *b, int len) -{ - unsigned short *buf = b; - unsigned int sum=0; - unsigned short result; - - for ( sum = 0; len > 1; len -= 2 ) - sum += *buf++; - if ( len == 1 ) - sum += *(unsigned char*)buf; - sum = (sum >> 16) + (sum & 0xFFFF); - sum += (sum >> 16); - result = ~sum; - return result; -} - - -int ICMPSend(int sock, const char *Host, int Type, int Code, int TTL, char *Data, int len) -{ -struct icmphdr *ICMPHead; -char *Tempstr=NULL; -int packet_len; -static int seq=0; -struct sockaddr_in sa; -int result; - -result=TTL; -if (setsockopt(sock, SOL_IP, IP_TTL, &result, sizeof(int)) != 0) return(0); - -packet_len=len+sizeof(struct icmphdr); -Tempstr=(char *) calloc(1, packet_len+1); -ICMPHead=(struct icmphdr *) Tempstr; -ICMPHead->type=ICMP_ECHO; -ICMPHead->un.echo.id=getpid(); -ICMPHead->un.echo.sequence=seq++; -if ((len > 0) && Data) memcpy(Tempstr + sizeof(struct icmphdr), Data, len); -ICMPHead->checksum=checksum(Tempstr, packet_len); - -memset(&sa, 0, sizeof(sa)); -sa.sin_family=AF_INET; -sa.sin_port=0; -sa.sin_addr.s_addr=StrtoIP(Host); -result=sendto(sock, Tempstr, packet_len, 0, (struct sockaddr*) &sa, sizeof(struct sockaddr)); - -DestroyString(Tempstr); - -return(result); -} - -#endif - -int SockAddrCreate(struct sockaddr **ret_sa, int Family, const char *Addr, int Port) -{ -struct sockaddr_in *sa4; -struct sockaddr_in6 *sa6; -char *Token=NULL, *ptr; -socklen_t salen; - -if (Family==AF_INET) -{ - sa4=(struct sockaddr_in *) calloc(1,sizeof(struct sockaddr_in)); - if (StrLen(Addr)) sa4->sin_addr.s_addr=StrtoIP(Addr); - else sa4->sin_addr.s_addr=INADDR_ANY; - sa4->sin_port=htons(Port); - sa4->sin_family=AF_INET; - *ret_sa=(struct sockaddr *) sa4; - salen=sizeof(struct sockaddr_in); -} -else -{ - sa6=(struct sockaddr_in6 *) calloc(1,sizeof(struct sockaddr_in6)); - if (StrLen(Addr)) - { - ptr=GetToken(Addr, "%",&Token,0); - if (StrLen(ptr)) sa6->sin6_scope_id=if_nametoindex(ptr); - inet_pton(AF_INET6, Token, &(sa6->sin6_addr)); - } - else sa6->sin6_addr=in6addr_any; - sa6->sin6_port=htons(Port); - sa6->sin6_family=AF_INET6; - - *ret_sa=(struct sockaddr *) sa6; - salen=sizeof(struct sockaddr_in6); -} - -DestroyString(Token); - -return(salen); -} - - -int UDPOpen(const char *Addr, int Port, int Flags) -{ - int result, Family=AF_INET; - struct sockaddr *sa; - socklen_t salen; - int fd; - - if (IsIP6Address(Addr)) Family=AF_INET6; - salen=SockAddrCreate(&sa, Family, Addr, Port); - fd=socket(Family, SOCK_DGRAM,0); - result=bind(fd, sa, salen); - if (result !=0) - { - close(fd); - return(-1); - } - - SockSetOptions(fd, Flags, 0); - return(fd); -} - -int UDPRecv(int sock, char *Buffer, int len, char **Addr, int *Port) -{ - char *Tempstr=NULL; - struct sockaddr_in sa; - socklen_t salen; - int result; - int fd; - - salen=sizeof(sa); -result=recvfrom(sock, Buffer, len,0, &sa, &salen); -if (result > -1) -{ - *Addr=SetStrLen(*Addr,NI_MAXHOST); - Tempstr=SetStrLen(Tempstr,NI_MAXSERV); - getnameinfo((struct sockaddr *) &sa, salen, *Addr, NI_MAXHOST, Tempstr, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV); - - *Port=atoi(Tempstr); -} - -DestroyString(Tempstr); - -return(result); -} - - - -int UDPSend(int sock, const char *Host, int Port, char *Data, int len) -{ -int Family=AF_INET; -struct sockaddr *sa=NULL; -socklen_t salen; -int result; - -if (IsIP6Address(Host)) Family=AF_INET6; - -salen=SockAddrCreate(&sa, Family, Host, Port); - -result=sendto(sock, Data, len, 0, sa , salen); -free(sa); -return(result); -} - - - -int STREAMSendDgram(STREAM *S, const char *Host, int Port, char *Data, int len) -{ -return(UDPSend(S->out_fd, Host, Port, Data, len)); -} - - - - -#ifdef USE_INET6 -int InitServerSock(int Type, const char *Address, int Port) -{ -int sock; -//struct sockaddr_storage sa; -struct sockaddr_in *sa4; -struct sockaddr_in6 *sa6; -struct sockaddr *sa=NULL; -socklen_t salen; -int result, Family=AF_INET6; -const char *p_Addr=NULL, *ptr; - - -if (StrLen(Address)) -{ - if (IsIP4Address(Address)) - { - Family=AF_INET; - p_Addr=Address; - } - else if (IsIP6Address(Address)) - { - Family=AF_INET6; - p_Addr=Address; - } - else - { - Family=AF_INET; - p_Addr=GetInterfaceIP(Address); - } -} - -salen=SockAddrCreate(&sa, Family, p_Addr, Port); - -if (Type==0) Type=SOCK_STREAM; -sock=socket(Family,Type,0); -if (sock <0) return(-1); - -//No reason to pass server/listen sockets across an exec -fcntl(sock, F_SETFD, FD_CLOEXEC); - -result=1; -setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&result,sizeof(result)); - -result=bind(sock, sa, salen); - -if ((result==0) && (Type==SOCK_STREAM)) -{ - result=listen(sock,10); -} - -free(sa); - -if (result==0) return(sock); - -close(sock); -return(-1); -} - -#else - -int InitServerSock(int Type, const char *Address, int Port) -{ -struct sockaddr_in sa; -int result; -const char *ptr; -socklen_t salen; -int sock; - -sa.sin_port=htons(Port); -sa.sin_family=AF_INET; - - -if (StrLen(Address) > 0) -{ - if (IsIP6Address(Address)) return(-1); - - if (IsIP4Address(Address)) ptr=Address; - else ptr=GetInterfaceIP(Address); - sa.sin_addr.s_addr=StrtoIP(ptr); -} -else sa.sin_addr.s_addr=INADDR_ANY; - -if (Type==0) Type=SOCK_STREAM; -sock=socket(AF_INET, Type,0); -if (sock <0) return(-1); - -//No reason to pass server/listen sockets across an exec -fcntl(sock, F_SETFD, FD_CLOEXEC); - -result=1; -salen=sizeof(result); -setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&result,salen); - - -salen=sizeof(struct sockaddr_in); -result=bind(sock,(struct sockaddr *) &sa, salen); - -if ((result==0) && (Type==SOCK_STREAM)) -{ - result=listen(sock,10); -} - -if (result==0) return(sock); -else -{ -close(sock); -return(-1); -} -} -#endif - - -int TCPServerSockAccept(int ServerSock, char **Addr) -{ -struct sockaddr_storage sa; -socklen_t salen; -int sock; - -salen=sizeof(sa); -sock=accept(ServerSock,(struct sockaddr *) &sa, &salen); -if (Addr && (sock > -1)) -{ -*Addr=SetStrLen(*Addr,NI_MAXHOST); -getnameinfo((struct sockaddr *) &sa, salen, *Addr, NI_MAXHOST, NULL, 0, NI_NUMERICHOST); -} -return(sock); -} - - - - - - - - - - -#ifdef USE_INET6 -int GetSockDetails(int sock, char **LocalAddress, int *LocalPort, char **RemoteAddress, int *RemotePort) -{ -socklen_t salen; -int result; -struct sockaddr_storage sa; -char *Tempstr=NULL, *ptr; - -*LocalPort=0; -*RemotePort=0; -*LocalAddress=CopyStr(*LocalAddress,""); -*RemoteAddress=CopyStr(*RemoteAddress,""); - -salen=sizeof(struct sockaddr_storage); -result=getsockname(sock, (struct sockaddr *) &sa, &salen); - -if (result==0) -{ - *LocalAddress=SetStrLen(*LocalAddress,NI_MAXHOST); - Tempstr=SetStrLen(Tempstr,NI_MAXSERV); - getnameinfo((struct sockaddr *) &sa, salen, *LocalAddress, NI_MAXHOST, Tempstr, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV); - *LocalPort=atoi(Tempstr); - - if ((strncmp(*LocalAddress,"::ffff:",7)==0) && strchr(*LocalAddress,'.')) - { - ptr=*LocalAddress; - ptr+=7; - memmove(*LocalAddress,ptr,StrLen(*LocalAddress)-6); - } - - - //Set Address to be the same as control sock, as it might not be INADDR_ANY - result=getpeername(sock, (struct sockaddr *) &sa, &salen); - - if (result==0) - { - *RemoteAddress=SetStrLen(*RemoteAddress,NI_MAXHOST); - Tempstr=SetStrLen(Tempstr,NI_MAXSERV); - getnameinfo((struct sockaddr *) &sa, salen, *RemoteAddress, NI_MAXHOST, Tempstr, NI_MAXSERV, NI_NUMERICHOST|NI_NUMERICSERV); - *RemotePort=atoi(Tempstr); - - if ((strncmp(*RemoteAddress,"::ffff:",7)==0) && strchr(*RemoteAddress,'.')) - { - ptr=*RemoteAddress; - ptr+=7; - memmove(*RemoteAddress,ptr,StrLen(*RemoteAddress)-6); - } - } - - //We've got the local sock, so lets still call it a success - result=0; -} - -DestroyString(Tempstr); - -if (result==0) return(TRUE); -return(FALSE); -} - -#else - -int GetSockDetails(int sock, char **LocalAddress, int *LocalPort, char **RemoteAddress, int *RemotePort) -{ -socklen_t salen; -int result; -struct sockaddr_in sa; - -*LocalPort=0; -*RemotePort=0; -*LocalAddress=CopyStr(*LocalAddress,""); -*RemoteAddress=CopyStr(*RemoteAddress,""); - -salen=sizeof(struct sockaddr_in); -result=getsockname(sock, (struct sockaddr *) &sa, &salen); - -if (result==0) -{ - *LocalAddress=CopyStr(*LocalAddress,IPtoStr(sa.sin_addr.s_addr)); - *LocalPort=ntohs(sa.sin_port); - - //Set Address to be the same as control sock, as it might not be INADDR_ANY - result=getpeername(sock, (struct sockaddr *) &sa, &salen); - - if (result==0) - { - *RemoteAddress=CopyStr(*RemoteAddress,IPtoStr(sa.sin_addr.s_addr)); - *RemotePort=sa.sin_port; - } - - //We've got the local sock, so lets still call it a success - result=0; -} - -if (result==0) return(TRUE); -return(FALSE); -} - -#endif - - - - -/* Users will probably only use this function if they want to reconnect */ -/* a broken connection, or reuse a socket for multiple connections, hence */ -/* the name... */ -int IPReconnect(int sock, const char *Host, int Port, int Flags) -{ -socklen_t salen; -int result; -struct sockaddr_in sa; -struct hostent *hostdata; - -sa.sin_family=AF_INET; -sa.sin_port=htons(Port); - -if (IsIP4Address(Host)) -{ -inet_aton(Host, (struct in_addr *) &sa.sin_addr); -} -else -{ - hostdata=gethostbyname(Host); - if (!hostdata) - { - return(-1); - } -sa.sin_addr=*(struct in_addr *) *hostdata->h_addr_list; -} - -salen=sizeof(sa); -SockSetOptions(sock, Flags, 0); - -result=connect(sock,(struct sockaddr *)&sa, salen); -if (result==0) result=TRUE; - -if ((result==-1) && (Flags & CONNECT_NONBLOCK) && (errno == EINPROGRESS)) result=FALSE; -return(result); -} - - -int TCPConnectWithAttributes(const char *Host, int Port, int Flags, int TTL, int ToS) -{ -int sock, result; - -sock=socket(AF_INET,SOCK_STREAM,0); -if (sock <0) return(-1); - -if (TTL > 0) setsockopt(sock, IPPROTO_IP, IP_TTL, &TTL, sizeof(int)); -if (ToS > 0) setsockopt(sock, IPPROTO_IP, IP_TOS, &ToS, sizeof(int)); - -result=IPReconnect(sock,Host,Port,Flags); -if (result==-1) -{ -close(sock); -return(-1); -} - -return(sock); - -} - - -int TCPConnect(const char *Host, int Port, int Flags) -{ -return(TCPConnectWithAttributes(Host, Port, Flags, 0, 0)); -} - - - -int CheckForTerm(DownloadContext *CTX, char inchar) -{ - - if (inchar == CTX->TermStr[CTX->TermPos]) - { - CTX->TermPos++; - if (CTX->TermPos >=strlen(CTX->TermStr)) - { - CTX->TermPos=0; - return(TRUE); - } - } - else - { - if (CTX->TermPos >0) - { - STREAMWriteBytes(CTX->Output, CTX->TermStr,CTX->TermPos); - CTX->TermPos=0; - return(CheckForTerm(CTX,inchar)); - } - } -return(FALSE); -} - - - -int ProcessIncommingBytes(DownloadContext *CTX) -{ -int inchar, FoundTerm=FALSE; - - inchar=STREAMReadChar(CTX->Input); - - if (inchar==EOF) return(TRUE); - - FoundTerm=CheckForTerm(CTX,(char) inchar); - while ((inchar !=EOF) && (! FoundTerm)) - { - if (CTX->TermPos==0) STREAMWriteChar(CTX->Output, (char) inchar); - inchar=STREAMReadChar(CTX->Input); - FoundTerm=CheckForTerm(CTX, (char) inchar); - } -if (inchar==EOF) return(TRUE); -if (FoundTerm) return(TRUE); -return(FALSE); -} - - -int DownloadToTermStr2(STREAM *Connection, STREAM *SaveFile, char *TermStr) -{ -DownloadContext CTX; - -CTX.TermStr=CopyStr(NULL,TermStr); -CTX.Input=Connection; -CTX.Output=SaveFile; -CTX.TermPos=0; - -while(ProcessIncommingBytes(&CTX) !=TRUE); - -DestroyString(CTX.TermStr); -return(TRUE); -} - -int DownloadToDot(STREAM *Connection, STREAM *SaveFile) -{ -return(DownloadToTermStr2(Connection,SaveFile,"\r\n.\r\n")); -} - - -int DownloadToTermStr(STREAM *Connection, STREAM *SaveFile, char *TermStr) -{ -char *Tempstr=NULL; - -Tempstr=STREAMReadLine(Tempstr,Connection); -while (Tempstr) -{ - if (strcmp(Tempstr,TermStr)==0) -{ - break; -} - STREAMWriteLine(Tempstr,SaveFile); - Tempstr=STREAMReadLine(Tempstr,Connection); -} -return(TRUE); -} - - - -char *LookupHostIP(const char *Host) -{ -struct hostent *hostdata; - - hostdata=gethostbyname(Host); - if (!hostdata) - { - return(NULL); - } - -//inet_ntoa shouldn't need this cast to 'char *', but it emitts a warning -//without it -return((char *) inet_ntoa(*(struct in_addr *) *hostdata->h_addr_list)); -} - - - - -char *GetRemoteIP(int sock) -{ -struct sockaddr_in sa; -socklen_t salen; -int result; - -salen=sizeof(struct sockaddr_in); -result=getpeername(sock,(struct sockaddr *) &sa, &salen); -if (result==-1) -{ -if (errno==ENOTSOCK) return("127.0.0.1"); -else return("0.0.0.0"); -} - -return((char *) inet_ntoa(sa.sin_addr)); -} - - -char *IPStrToHostName(const char *IPAddr) -{ -struct sockaddr_in sa; -struct hostent *hostdata=NULL; - -inet_aton(IPAddr,& sa.sin_addr); -hostdata=gethostbyaddr(&sa.sin_addr.s_addr,sizeof((sa.sin_addr.s_addr)),AF_INET); -if (hostdata) return(hostdata->h_name); -else return(""); -} - - - - -char *IPtoStr(unsigned long Address) -{ -struct sockaddr_in sa; -sa.sin_addr.s_addr=Address; -return((char *) inet_ntoa(sa.sin_addr)); - -} - -unsigned long StrtoIP(const char *Str) -{ -struct sockaddr_in sa; -if (inet_aton(Str,&sa.sin_addr)) return(sa.sin_addr.s_addr); -return(0); -} - - -int STREAMIsConnected(STREAM *S) -{ -int result=FALSE; - -if (! S) return(FALSE); -result=IsSockConnected(S->in_fd); -if (result==TRUE) -{ - if (S->State & SS_CONNECTING) - { - S->State |= SS_CONNECTED; - S->State &= (~SS_CONNECTING); - } -} -if ((result==SOCK_CONNECTING) && (! (S->State & SS_CONNECTING))) result=FALSE; -return(result); -} - - - -int STREAMDoPostConnect(STREAM *S, int Flags) -{ -int result=FALSE; -char *ptr; -struct timeval tv; - -if (! S) return(FALSE); -if ((S->in_fd > -1) && (S->Timeout > 0) ) -{ - tv.tv_sec=S->Timeout; - tv.tv_usec=0; - if (FDSelect(S->in_fd, SELECT_WRITE, &tv) != SELECT_WRITE) - { - close(S->in_fd); - S->in_fd=-1; - S->out_fd=-1; - } -} - -if (S->in_fd > -1) -{ -//We will have been non-blocking during connection, but if we don't -//really want the stream to be non blocking, we unset that here -if (! (Flags & CONNECT_NONBLOCK)) STREAMSetFlags(S, 0, SF_NONBLOCK); - -S->Type=STREAM_TYPE_TCP; -result=TRUE; -STREAMSetFlushType(S,FLUSH_LINE,0,0); -if (Flags & CONNECT_SSL) DoSSLClientNegotiation(S, Flags); - -ptr=GetRemoteIP(S->in_fd); -if (ptr) STREAMSetValue(S,"PeerIP",ptr); -} - -return(result); -} - -extern char *GlobalConnectionChain; - -int STREAMTCPConnect(STREAM *S, const char *Host, int Port, int TTL, int ToS, int Flags) -{ -ListNode *Curr, *LastHop; -char *Token=NULL, *ptr; -int HopNo=0, result=FALSE; - - -if (! STREAMGetValue(S, "ConnectHop:0")) -{ -if (StrValid(GlobalConnectionChain)) STREAMAddConnectionHop(S, GlobalConnectionChain); -} - -//Find the last hop, used to decide what ssh command to use -Curr=ListGetNext(S->Values); -while (Curr) -{ -GetToken(Curr->Tag,":",&Token,0); -if (strcasecmp(Token,"ConnectHop")==0) LastHop=Curr; -if (strcasecmp(Curr->Tag,"TTL")==0) TTL=atoi(Curr->Item); -if (strcasecmp(Curr->Tag,"ToS")==0) ToS=atoi(Curr->Item); -Curr=ListGetNext(Curr); -} - - -Curr=ListGetNext(S->Values); -while (Curr) -{ - GetToken(Curr->Tag,":",&Token,0); - - if (strcasecmp(Token,"ConnectHop")==0) result=STREAMProcessConnectHop(S, (char *) Curr->Item,Curr==LastHop); - - HopNo++; - if (! result) break; - Curr=ListGetNext(Curr); -} - -//If we're not handling the connection through 'Connect hops' then -//just connect to host -if ((HopNo==0) && StrLen(Host)) -{ - if (Flags & CONNECT_NONBLOCK) S->Flags |= SF_NONBLOCK; - - //Flags are handled in this function - S->in_fd=TCPConnectWithAttributes(Host,Port,Flags,TTL,ToS); - - S->out_fd=S->in_fd; - if (S->in_fd > -1) result=TRUE; -} - -if (result==TRUE) -{ - if (Flags & CONNECT_NONBLOCK) - { - S->State |=SS_CONNECTING; - S->Flags |=SF_NONBLOCK; - } - else - { - S->State |=SS_CONNECTED; - result=STREAMDoPostConnect(S, Flags); - } -} - -return(result); -} - - - -int STREAMConnect(STREAM *S, const char *URL, int Flags) -{ -ListNode *Curr; -int result=FALSE, fd; -unsigned int Port=0, TTL=0, ToS=0; -char *Proto=NULL, *Host=NULL, *Token=NULL, *Path=NULL; - - -ParseURL(URL, &Proto, &Host, &Token,NULL, NULL,&Path,NULL); -S->Path=FormatStr(S->Path,URL); -Port=strtoul(Token,0,10); - -STREAMSetFlushType(S,FLUSH_LINE,0,0); -if (strcasecmp(Proto,"unix")==0) result=STREAMConnectUnixSocket(S, Host, SOCK_STREAM); -if (strcasecmp(Proto,"unixdgm")==0) result=STREAMConnectUnixSocket(S, Host, SOCK_DGRAM); -else if ((strcasecmp(Proto,"udp")==0) || (strcasecmp(Proto,"bcast")==0)) -{ - fd=UDPOpen("", 0, Flags); - if (fd > -1) - { - S->in_fd=fd; - S->out_fd=fd; - S->Type=STREAM_TYPE_UDP; - result=IPReconnect(fd,Host,Port,0); - if (strcasecmp(Proto,"bcast")==0) SockSetOptions(fd, SOCK_BROADCAST, 0); - } -} -else if (strcasecmp(Proto,"ssl")==0) result=STREAMTCPConnect(S, Host, Port, TTL, ToS, Flags | CONNECT_SSL); -else result=STREAMTCPConnect(S, Host, Port, TTL, ToS, Flags); - -DestroyString(Token); -DestroyString(Proto); -DestroyString(Host); -DestroyString(Path); - -return(result); -} - - diff --git a/libUseful-2.6/socket.h b/libUseful-2.6/socket.h deleted file mode 100755 index b3a256a..0000000 --- a/libUseful-2.6/socket.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef LIBUSEFUL_SOCK -#define LIBUSEFUL_SOCK - -#include "includes.h" - -#define CONNECT_NONBLOCK 1 -#define CONNECT_SSL 2 -#define CONNECT_HTTP_PROXY 4 -#define CONNECT_SOCKS_PROXY 8 -#define SOCK_NOKEEPALIVE 16 -#define SOCK_BROADCAST 32 -#define SOCK_DONTROUTE 64 -#define SOCK_REUSEPORT 128 -#define SOCK_TPROXY 256 -#define SOCK_PEERCREDS 512 - -#define SOCK_CONNECTED 1 -#define SOCK_CONNECTING -1 - - - -#ifdef __cplusplus -extern "C" { -#endif - -int IsIP4Address(const char *Str); -int IsIP6Address(const char *Str); -int IsIPAddress(const char *); - -const char *GetInterfaceIP(const char *Interface); -int GetHostARP(const char *IP, char **Device, char **MAC); - -int ICMPSend(int sock, const char *Host, int Type, int Code, int TTL, char *Data, int len); -int UDPOpen(const char *Addr, int Port,int NonBlock); -int UDPSend(int sock, const char *Host, int Port, char *Data, int len); -int UDPRecv(int sock, char *Buffer, int len, char **Host, int *Port); - - -/* Server Socket Funcs*/ -int InitServerSock(int Type, const char *Address, int Port); -int InitUnixServerSock(int Type, const char *Path); - -int TCPServerSockAccept(int ServerSock,char **Addr); -int UnixServerSockAccept(int ServerSock); - -int GetSockDetails(int fd, char **LocalAddress, int *LocalPort, char **RemoteAddress, int *RemotePort); - -/* Client Socket Funcs*/ -int IsSockConnected(int sock); -int TCPReconnect(int sock, const char *Host, int Port, int Flags); -int TCPConnect(const char *Host, int Port, int Flags); -/* int CheckForData(int sock); */ -int SendText(int sock, char *Text); -int ReadText(int sock, char *Buffer, int MaxLen); -int ReadToCR(int fd, char *Buffer, int MaxLen); - -int STREAMTCPConnect(STREAM *S, const char *Host, int Port, int TTL, int ToS, int Flags); -int STREAMConnect(STREAM *S, const char *URL, int Flags); -int STREAMIsConnected(STREAM *S); -int DoPostConnect(STREAM *S, int Flags); - -/* Stuff relating to standard inet download procedure (until \r\n.\r\n) */ -typedef struct -{ -STREAM *Input; -STREAM *Output; -char *TermStr; -int TermPos; -} DownloadContext; - -int ProcessIncommingBytes(DownloadContext *); -//int DownloadToDot(int sock, FILE *SaveFile); -int DownloadToDot(STREAM *Connection, STREAM *SaveFile); -int DownloadToTermStr(STREAM *Connection, STREAM *SaveFile, char *TermStr); - - -/* IP Address and host lookup functions */ -char *GetRemoteIP(int sock); -char *LookupHostIP(const char *Host); -char *IPStrToHostName(const char *); -char *IPtoStr(unsigned long); -unsigned long StrtoIP(const char *); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/sound.c b/libUseful-2.6/sound.c deleted file mode 100755 index 13f89a7..0000000 --- a/libUseful-2.6/sound.c +++ /dev/null @@ -1,658 +0,0 @@ -#include -#include -#include "sound.h" -#include "file.h" -#include "string.h" -#include "defines.h" -#include "includes.h" - - -typedef struct -{ -uint32_t DataStart; -uint32_t DataSize; -uint32_t Format; -uint32_t SampleRate; -uint32_t Channels; -} AUHeader; - - - -typedef struct -{ -char RIFF[4]; -uint32_t FileSize; -char Format[4]; -char Block[4]; -uint32_t ChunkSize; -uint16_t AudioFormat; -uint16_t Channels; -uint32_t SampleRate; -uint32_t ByteRate; -uint16_t BlockAlign; -uint16_t BitsPerSample; -char DataHeader[4]; -uint32_t DataSize; -} WAVHeader; - - - -const char *VolTypeStrings[]={"master","pcm","cd","mic","line","video","phonein","phoneout","all",NULL}; -typedef enum {VOL_MASTER,VOL_PCM,VOL_CD,VOL_MIC,VOL_LINE1,VOL_VIDEO,VOL_PHONEIN,VOL_PHONEOUT,VOL_ALL} TVOLUME_CHANNELS; - - - -#define SAMPLE_SIGNED 1 - - - -int SoundReformat(char **Out, char *In, int Len, TAudioInfo *AI) -{ -int len, i; - -len=Len; -//Expand mono to both channels -if (AI->Channels==1) -{ - len=Len*2; - *Out=SetStrLen(*Out, Len*2); - for (i=0; i < Len; i++) - { - (*Out)[i*2]=In[i]; - (*Out)[i*2+1]=In[i]; - } -} - - -return(len); -} - - -TAudioInfo *AudioInfoCreate(unsigned int Format, unsigned int Channels, unsigned int SampleRate, unsigned int SampleSize, unsigned int DataSize) -{ -TAudioInfo *AI; - -AI=(TAudioInfo *) calloc(1,sizeof(TAudioInfo)); - -AI->Format=Format; -AI->Channels=Channels; -AI->SampleRate=SampleRate; -AI->SampleSize=SampleSize; -AI->DataSize=DataSize; - -return(AI); -} - - -/* ------------------------ SOUND FILE FORMATS --------------- */ -TAudioInfo *SoundReadWAV(STREAM *S) -{ -WAVHeader Wav; -TAudioInfo *AudioInfo; - - -AudioInfo=(TAudioInfo *) calloc(1,sizeof(TAudioInfo)); - -STREAMReadBytes(S,(char *) &Wav,sizeof(WAVHeader)); - -AudioInfo->Channels=Wav.Channels; -AudioInfo->SampleRate=Wav.SampleRate; - -AudioInfo->DataSize=Wav.DataSize; - -if (Wav.BitsPerSample==16) -{ - AudioInfo->SampleSize=2; - AudioInfo->Format=AFMT_S16_LE; -} -else -{ - AudioInfo->SampleSize=1; - AudioInfo->Format=AFMT_U8; -} - -return(AudioInfo); -} - - -void SoundWriteWAVHeader(STREAM *S, TAudioInfo *AI) -{ - WAVHeader WavHead; - - memcpy(WavHead.RIFF,"RIFF",4); - memcpy(WavHead.Format,"WAVE",4); - memcpy(WavHead.Block,"fmt ",4); - WavHead.FileSize=AI->DataSize+44; - WavHead.AudioFormat=1; - WavHead.Channels=AI->Channels; - WavHead.SampleRate=AI->SampleRate; - WavHead.BlockAlign=4; - WavHead.ByteRate=WavHead.SampleRate * WavHead.BlockAlign; - WavHead.BitsPerSample=AI->SampleSize * 8; - WavHead.ChunkSize=WavHead.BitsPerSample; - memcpy(WavHead.DataHeader,"data",4); - WavHead.DataSize=AI->DataSize; - - - STREAMWriteBytes(S,(char *) &WavHead,sizeof(WAVHeader)); -} - - - -TAudioInfo *SoundReadAU(STREAM *S) -{ -AUHeader Header; -TAudioInfo *AudioInfo; - -AudioInfo=(TAudioInfo *) calloc(1,sizeof(TAudioInfo)); -STREAMReadBytes(S,(char *) &Header,sizeof(AUHeader)); - -//AU uses big endian -Header.DataSize=htonl(Header.DataSize); -Header.DataStart=htonl(Header.DataStart); -Header.Channels=htonl(Header.Channels); -Header.SampleRate=htonl(Header.SampleRate); -Header.Format=htonl(Header.Format); - - -AudioInfo->Channels=Header.Channels; -AudioInfo->SampleRate=Header.SampleRate; -AudioInfo->DataSize=Header.DataSize; - - -switch(Header.Format) -{ - case 1: - AudioInfo->Format=AFMT_MU_LAW; - break; - - case 2: - AudioInfo->Format=AFMT_S8; - break; - - case 3: - AudioInfo->Format=AFMT_S16_BE; - break; -} - -STREAMSeek(S,(double) Header.DataStart,SEEK_SET); -return(AudioInfo); -} - - - -TAudioInfo *SoundOpenFile(char *FilePath) -{ -TAudioInfo *AudioInfo=NULL; -char *FourCharacter; -STREAM *S; - -S=STREAMOpenFile(FilePath,SF_RDONLY); -if (! S) return(NULL); - -FourCharacter=calloc(4, sizeof(char)); -STREAMReadBytes(S,FourCharacter,4); -STREAMSeek(S,0,SEEK_SET); -if (strcmp(FourCharacter,".snd")==0) AudioInfo=SoundReadAU(S); -else if (strcmp(FourCharacter,"RIFF")==0) AudioInfo=SoundReadWAV(S); - -free(FourCharacter); - -if (! AudioInfo) -{ - STREAMClose(S); - return(NULL); -} -AudioInfo->S=S; - -return(AudioInfo); -} - - - - -#ifdef HAVE_OSS - -#include -/* ------------------------ OSS Functions -------------------- */ -int OpenOSSDevice(char *Dev, int Type, TAudioInfo *Info) -{ - int fd; - int val; - - if (Type==OUTPUT) val=O_WRONLY; - else val=O_RDONLY; - - - if (StrLen(Dev)==0) fd=open("/dev/dsp",val); - else fd=open(Dev,val); - - if (fd==-1) return(-1); - if (fd==-1) return(-1); - - -/* Tell the sound card that the sound about to be played is stereo. 0=mono 1=stereo */ - - val=Info->Channels-1; - if (val < 0) val=0; - if ( ioctl(fd, SNDCTL_DSP_STEREO,&val) == -1 ) - { - perror("ioctl stereo"); - return -1; - } - - /* Inform the sound card of the audio format */ - if ( ioctl(fd, SNDCTL_DSP_SETFMT,&Info->Format) == -1 ) - { - perror("ioctl format"); - return -1; - } - - /* Set the DSP playback rate, sampling rate of the raw PCM audio */ - if (ioctl(fd, SNDCTL_DSP_SPEED,&Info->SampleRate) == -1 ) - { - perror("ioctl sample rate"); - return -1; - } - - /* - if (Flags & O_RDWR) - { - if (ioctl(fd, SNDCTL_DSP_SETDUPLEX,0) == -1 ) - { - perror("ioctl set duplex"); - return -1; - } - } - */ - - return(fd); -} - -int OpenOSSInput(char *Dev, TAudioInfo *Info) -{ -return(OpenOSSDevice(Dev,INPUT,Info)); -} - - -int OpenOSSOutput(char *Dev, TAudioInfo *Info) -{ -return(OpenOSSDevice(Dev,OUTPUT,Info)); -} - - - -int OSSAlterVolumeType(char *device, int Type, int delta) -{ -int left_val=-1, right_val=-1, val, mixfd=0; - -mixfd=open(device, O_RDWR); -if (mixfd > -1) -{ -switch (Type) -{ - case VOL_MASTER: - ioctl(mixfd,MIXER_READ(SOUND_MIXER_VOLUME),&val); - break; - - case VOL_PCM: - ioctl(mixfd,MIXER_READ(SOUND_MIXER_PCM),&val); - break; - - case VOL_CD: - ioctl(mixfd,MIXER_READ(SOUND_MIXER_CD),&val); - break; - - case VOL_MIC: - ioctl(mixfd,MIXER_READ(SOUND_MIXER_MIC),&val); - break; - - case VOL_VIDEO: - ioctl(mixfd,MIXER_READ(SOUND_MIXER_VIDEO),&val); - break; - - case VOL_PHONEIN: - ioctl(mixfd,MIXER_READ(SOUND_MIXER_PHONEIN),&val); - break; - - case VOL_PHONEOUT: - ioctl(mixfd,MIXER_READ(SOUND_MIXER_PHONEOUT),&val); - break; - - case VOL_LINE1: - ioctl(mixfd,MIXER_READ(SOUND_MIXER_LINE1),&val); - break; -} - -left_val=val & 0xFF; -right_val=(val & 0xFF00) >> 8; - -left_val+=delta; -if (left_val < 0) left_val=0; -if (left_val > 255) left_val=255; - -right_val+=delta; -if (right_val < 0) right_val=0; -if (right_val > 255) right_val=255; - -right_val=right_val << 8; -val=right_val + left_val; - -switch (Type) -{ - case VOL_MASTER: - ioctl(mixfd,MIXER_WRITE(SOUND_MIXER_VOLUME),&val); - break; - - case VOL_PCM: - ioctl(mixfd,MIXER_WRITE(SOUND_MIXER_PCM),&val); - break; - - case VOL_CD: - ioctl(mixfd,MIXER_WRITE(SOUND_MIXER_CD),&val); - break; - - case VOL_MIC: - ioctl(mixfd,MIXER_WRITE(SOUND_MIXER_MIC),&val); - break; - - case VOL_VIDEO: - ioctl(mixfd,MIXER_WRITE(SOUND_MIXER_VIDEO),&val); - break; - - case VOL_PHONEIN: - ioctl(mixfd,MIXER_WRITE(SOUND_MIXER_PHONEIN),&val); - break; - - case VOL_PHONEOUT: - ioctl(mixfd,MIXER_WRITE(SOUND_MIXER_PHONEOUT),&val); - break; - - case VOL_LINE1: - ioctl(mixfd,MIXER_WRITE(SOUND_MIXER_LINE1),&val); - break; -} - -close(mixfd); -} - -return(left_val); -} - - -int OSSAlterVolume(char *device, char *type_str, int delta) -{ -int type, result=-1; - -type=MatchTokenFromList(type_str,VolTypeStrings,0); -if ((type==VOL_ALL) || (type==-1)) -{ -result=OSSAlterVolumeType(device, VOL_MASTER, delta); -result=OSSAlterVolumeType(device, VOL_PCM, delta); -} -else result=OSSAlterVolumeType(device, type, delta); - -return(result); -} - - -int OSSPlaySoundFile(char *DevPath, char *FilePath, int Vol) -{ -char *Buffer=NULL, *Tempstr=NULL; -int result, fd=-1, mixfd=-1; -int val, oldvol; -TAudioInfo *AudioInfo=NULL; - -AudioInfo=SoundOpenFile(FilePath); -if (AudioInfo==NULL) return(FALSE); - -//Must do all the above before we do open oss! -fd=OpenOSSOutput(DevPath, AudioInfo); -if (fd==-1) -{ - STREAMClose(AudioInfo->S); - free(AudioInfo); - return(FALSE); -} - -if (Vol != VOLUME_LEAVEALONE) -{ - mixfd=open("/dev/dsp", O_RDWR); - if (mixfd > -1) - { - ioctl(mixfd,SOUND_MIXER_READ_PCM,&oldvol); - if (Vol > 255) result=255; - else result=Vol; - val=(result) | (result <<8); - ioctl(mixfd,SOUND_MIXER_WRITE_PCM,&val); - } -} - -Buffer=SetStrLen(Buffer,1024); -result=STREAMReadBytes(AudioInfo->S,Buffer,1024); - -/* -if (AudioInfo->Channels==1) -{ - Tempstr=SetStrLen(Tempstr,result); - memcpy(Tempstr,Buffer,result); - result=SoundReformat(&Buffer, Tempstr, result, AudioInfo); -} -*/ - -val=0; -while (result > 0) -{ -write(fd,Buffer,result); -val+=result; -if ((AudioInfo->DataSize > 0) && (val >= AudioInfo->DataSize)) break; -result=STREAMReadBytes(AudioInfo->S,Buffer,1024); -} - -close(fd); -if (mixfd > -1) -{ -ioctl(mixfd,SOUND_MIXER_WRITE_PCM,&oldvol); -close(mixfd); -} - -DestroyString(Buffer); -DestroyString(Tempstr); - -STREAMClose(AudioInfo->S); -free(AudioInfo); - -return(TRUE); -} - -#endif - - -/* ------------------------ ESound Functions -------------------- */ - -#ifdef HAVE_LIBESD -#include - -int ESDGetConnection() -{ -static int ConFD=-1; - -if (ConFD==-1) ConFD=esd_open_sound(NULL); -return(ConFD); -} - - -void ESDSendFileData(int ConFD, char *SoundFilePath, int Vol) -{ -char *Tempstr=NULL; -int id; - -Tempstr=CopyStr(Tempstr,"ColLib:"); -Tempstr=CatStr(Tempstr,SoundFilePath); - -id=esd_sample_getid(ConFD,Tempstr); -if (id < 0) -{ - id=esd_file_cache(ConFD,"ColLib",SoundFilePath); -} -if (Vol != VOLUME_LEAVEALONE) esd_set_default_sample_pan(ConFD,id,Vol,Vol); -esd_sample_play(ConFD,id); - -DestroyString(Tempstr); -} - -#endif - - - -int ESDPlaySoundFile(char *SoundFilePath, int Vol) -{ -if (StrLen(SoundFilePath) < 1) return(FALSE); -#ifdef HAVE_LIBESD -int fd; - -fd=ESDGetConnection(); -if (fd > -1) -{ -ESDSendFileData(fd,SoundFilePath,Vol); -return(TRUE); -} - -#endif - -return(FALSE); -} - -/* -//Dont understand ESD volumes yet. - -int ESDAlterVolume(char *Device, int Vol) -{ -int result, fd; - -if (StrLen(Device) < 1) return; -#ifdef HAVE_LIBESD - -fd=ESDGetConnection(); -if (fd > -1) -{ - -return(TRUE); -} - -#endif - -return(FALSE); -} - -*/ - - -//---------------- Wrapper functions -------------// - - -int SoundOpenOutput(char *Dev, TAudioInfo *Info) -{ -int fd=-1; - -#ifdef HAVE_LIBESD -esd_format_t esd_format; - -if ((StrLen(Dev)==0) || (strncmp(Dev,"esd:",4)==0)) -{ -esd_format=ESD_STREAM | ESD_PLAY; - -if (Info->Channels==2) esd_format |= ESD_STEREO; -else esd_format |= ESD_MONO; - -if (Info->SampleSize==2) esd_format |= ESD_BITS16; -else esd_format |= ESD_BITS8; - -if (StrLen(Dev) > 4) setenv("ESPEAKER",Dev+4,TRUE); -else setenv("ESPEAKER","localhost",TRUE); -fd=esd_play_stream(esd_format, Info->SampleRate, NULL, "testing"); -} - -#endif - -#ifdef HAVE_OSS -if (fd < 0) fd=OpenOSSOutput(Dev, Info); -#endif - -return(fd); -} - - -int SoundOpenInput(char *Dev, TAudioInfo *Info) -{ -int fd=-1; - -#ifdef HAVE_LIBESD -esd_format_t esd_format; - -if ((StrLen(Dev)==0) || (strncmp(Dev,"esd:",4)==0)) -{ -esd_format=ESD_STREAM | ESD_RECORD; - -if (Info->Channels==2) esd_format |= ESD_STEREO; -else esd_format |= ESD_MONO; - -if (Info->SampleSize==2) esd_format |= ESD_BITS16; -else esd_format |= ESD_BITS8; - -if (StrLen(Dev) > 4) setenv("ESPEAKER",Dev+4,TRUE); -else setenv("ESPEAKER","localhost",TRUE); -fd=esd_record_stream(esd_format, Info->SampleRate, NULL, "testing"); -} - -#endif - -#ifdef HAVE_OSS -if (fd < 0) fd=OpenOSSInput(Dev, Info); -#endif - -return(fd); -} - - - -int SoundPlayFile(char *Output, char *Path, int Vol, int Flags) -{ -int result=0, pid=0; - - -if (Flags & PLAYSOUND_NONBLOCK) -{ - pid=fork(); - if (pid==0) CloseOpenFiles(); -} -if (pid==0) -{ -result=ESDPlaySoundFile(Path, Vol); - -#ifdef HAVE_OSS -if (! result) result=OSSPlaySoundFile(Output, Path, Vol); -#endif - -if (Flags & PLAYSOUND_NONBLOCK) _exit(0); -} - -return(result); -} - -int SoundAlterVolume(char *ReqDev, char *VolType, int delta) -{ -char *device=NULL; -int val; - -if (StrLen(ReqDev)) device=CopyStr(device,ReqDev); -else device=CopyStr(device,"/dev/mixer"); - -#ifdef HAVE_OSS -val=OSSAlterVolume(device, VolType, delta); -#endif - -DestroyString(device); -return(val); - -} diff --git a/libUseful-2.6/sound.h b/libUseful-2.6/sound.h deleted file mode 100755 index 88a15cd..0000000 --- a/libUseful-2.6/sound.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef LIBUSEFUL_SOUND_H -#define LIBUSEFUL_SOUND_H - -#include "file.h" - -typedef struct -{ -unsigned int Format; -unsigned int Channels; -unsigned int SampleRate; -unsigned int SampleSize; -unsigned int DataSize; -STREAM *S; -}TAudioInfo; - -#define VOLUME_LEAVEALONE -1 -#define PLAYSOUND_NONBLOCK 1 - - -#define OUTPUT 0 -#define INPUT 1 - - -/* For systems that lack 'soundcard.h' but still have some kind of sound */ -/* We define enough audio formats for us to use internally */ -#ifndef AFMT_MU_LAW -# define AFMT_MU_LAW 0x00000001 -#endif - -#ifndef AFMT_A_LAW -# define AFMT_A_LAW 0x00000002 -#endif - -# define AFMT_IMA_ADPCM 0x00000004 - -#ifndef AFMT_U8 -# define AFMT_U8 0x00000008 -#endif - -#ifndef AFMT_S8 -# define AFMT_S8 0x00000040 -#endif - -#ifndef AFMT_S16_LE -# define AFMT_S16_LE 0x00000010 /* Little endian signed 16*/ -#endif - -#ifndef AFMT_S16_BE -# define AFMT_S16_BE 0x00000010 /* Little endian signed 16*/ -#endif - - -#ifndef AFMT_U16_BE -# define AFMT_U16_LE 0x00000080 /* Little endian U16 */ -#endif - -#ifndef AFMT_U16_BE -# define AFMT_U16_BE 0x00000100 /* Big endian U16 */ -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -TAudioInfo *AudioInfoCreate(unsigned int Format, unsigned int Channels, unsigned int SampleRate, unsigned int SampleSize, unsigned int DataSize); -int SoundPlayFile(char *Device, char *Path, int Vol, int Flags); -int SoundAlterVolume(char *Device, char *Channel, int delta); -int SoundOpenOutput(char *Dev, TAudioInfo *Info); -int SoundOpenInput(char *Dev, TAudioInfo *Info); -TAudioInfo *SoundReadWAV(STREAM *S); -TAudioInfo *SoundReadAU(STREAM *S); -void SoundWriteWAVHeader(STREAM *S, TAudioInfo *AI); -TAudioInfo *SoundOpenFile(char *FilePath); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/ssh.c b/libUseful-2.6/ssh.c deleted file mode 100755 index 3dcaf1b..0000000 --- a/libUseful-2.6/ssh.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "expect.h" -#include "ssh.h" -#include "pty.h" -#include "SpawnPrograms.h" - -STREAM *SSHConnect(const char *Host, int Port, const char *User, const char *Pass, const char *Command) -{ -ListNode *Dialog; -char *Tempstr=NULL, *KeyFile=NULL, *Token=NULL; -STREAM *S; -int val, i; - -Tempstr=MCopyStr(Tempstr,"ssh -2 -T ",User,"@",Host, " ", NULL ); - -if (Port > 0) -{ - Token=FormatStr(Token," -p %d ",Port); - Tempstr=CatStr(Tempstr,Token); -} - -if (strncmp(Pass,"keyfile:",8)==0) -{ - KeyFile=CopyStr(KeyFile, Pass+8); - Tempstr=MCatStr(Tempstr,"-i ",KeyFile," ",NULL); -} - -if (StrLen(Command)) -{ - if (strcmp(Command,"none")==0) Tempstr=CatStr(Tempstr, "-N "); - else Tempstr=MCatStr(Tempstr, "\"", Command, "\" ", NULL); -} -Tempstr=CatStr(Tempstr, " 2> /dev/null"); - -//Never use TTYFLAG_CANON here -S=STREAMSpawnCommand(Tempstr,COMMS_BY_PTY|TTYFLAG_CRLF|TTYFLAG_IGNSIG,""); - -printf("SSC: %d [%s]\n",S,Tempstr); - -if (StrLen(KeyFile)==0) -{ - Dialog=ListCreate(); - ExpectDialogAdd(Dialog, "Are you sure you want to continue connecting (yes/no)?", "yes\n", DIALOG_OPTIONAL); - ExpectDialogAdd(Dialog, "Permission denied", "", DIALOG_OPTIONAL | DIALOG_FAIL); - Tempstr=MCopyStr(Tempstr,User,"\n",NULL); - ExpectDialogAdd(Dialog, "ogin:", Tempstr, DIALOG_OPTIONAL); - Tempstr=MCopyStr(Tempstr,Pass,"\n",NULL); - ExpectDialogAdd(Dialog, "assword:", Tempstr, DIALOG_END); - STREAMExpectDialog(S, Dialog); - ListDestroy(Dialog,ExpectDialogDestroy); -} - -/* -STREAMSetTimeout(S,100); - -Tempstr=FormatStr(Tempstr,"okay %d %d\n",getpid(),time(NULL)); -STREAMWriteString("echo ",S); -STREAMWriteLine(Tempstr,S); -STREAMFlush(S); - -StripTrailingWhitespace(Tempstr); -for (i=0; i < 3; i++) -{ -Token=STREAMReadLine(Token,S); -StripTrailingWhitespace(Token); - -printf("SRL: [%s]\n",Token); -if ( StrLen(Token) && (strcmp(Tempstr,Token) ==0) ) break; -} - -if (i==3) -{ - printf("Mismatch! [%s] [%s]\n",Token,Tempstr); - STREAMClose(S); - S=NULL; -} -*/ - -DestroyString(Tempstr); -DestroyString(KeyFile); -DestroyString(Token); - -return(S); -} diff --git a/libUseful-2.6/ssh.h b/libUseful-2.6/ssh.h deleted file mode 100755 index ef656e9..0000000 --- a/libUseful-2.6/ssh.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef LIBUSEFUL_SSH -#define LIBUSEFUL_SSH - -#include "file.h" - -STREAM *SSHConnect(const char *Host, int Port, const char *User, const char *Pass, const char *Command); - -#endif diff --git a/libUseful-2.6/string.c b/libUseful-2.6/string.c deleted file mode 100755 index dd52a01..0000000 --- a/libUseful-2.6/string.c +++ /dev/null @@ -1,667 +0,0 @@ -#include "includes.h" -#include - -#ifndef va_copy -#define va_copy(dest, src) (dest) = (src) -#endif - - -/* -size_t StrLen(const char *Str) -{ -char *ptr, *end; - -if (! Str) return(0); - -ptr=Str; -end=ptr + LibUsefulObjectSize(Str, 0); -while ((ptr < end) && (*ptr != '\0')) ptr++; -return(ptr-Str); -} -*/ - - - - -void DestroyString(void *Obj) -{ -if (Obj) free(Obj); -} - - - -int CompareStr(const char *S1, const char *S2) -{ -if ( - ((!S1) || (*S1=='\0')) && - ((!S2) || (*S2=='\0')) - ) return(0); - -if ((!S1) || (*S1=='\0')) return(-1); -if ((!S2) || (*S2=='\0')) return(1); - -return(strcmp(S1,S2)); -} - - -char *CopyStrLen(char *Dest, const char *Src, size_t len) -{ -const char *src, *end; -char *dst; - -Dest=(char *)realloc(Dest,len+1); -dst=Dest; -src=Src; -if (src) -{ -end=src+len; -while ((src < end) && (*src != '\0')) -{ -*dst=*src; -dst++; -src++; -} -} -*dst='\0'; - -return(Dest); -} - - -char *CatStrLen(char *Dest, const char *Src, size_t len) -{ -const char *src, *end; -char *dst; -int dstlen; - -dstlen=StrLen(Dest); -Dest=(char *)realloc(Dest,dstlen+len+1); -dst=Dest+dstlen; -src=Src; -end=src+len; -while ((src < end) && (*src != '\0')) -{ -*dst=*src; -dst++; -src++; -} -*dst='\0'; - -return(Dest); -} - - - -char *CatStr(char *Dest, const char *Src) -{ -return(CatStrLen(Dest, Src, StrLen(Src))); -} - - -char *CopyStr(char *Dest, const char *Src) -{ -if (Dest) *Dest=0; -return(CatStr(Dest,Src)); -} - - - -char *VCatStr(char *Dest, const char *Str1, va_list args) -{ -//initialize these to keep valgrind happy -size_t len=0, ilen; -char *ptr=NULL; -const char *sptr=NULL; -char *eptr; - - -if (Dest !=NULL) -{ -len=StrLen(Dest); -ptr=Dest; -} -else ptr=(char *) calloc(10,1); - -if (! Str1) return(ptr); - -for (sptr=Str1; sptr !=NULL; sptr=va_arg(args,const char *)) -{ - ilen=StrLen(sptr); - if (ilen > 0) - { - ptr=(char *) realloc(ptr,len+ilen+10); - if (ptr) - { - memcpy(ptr+len, sptr, ilen); - len+=ilen; - } - } -} -ptr[len]='\0'; - -return(ptr); -} - -char *MCatStr(char *Dest, const char *Str1, ...) -{ -char *ptr=NULL; -va_list args; - -va_start(args,Str1); -ptr=VCatStr(Dest,Str1,args); -va_end(args); - -return(ptr); -} - - -char *MCopyStr(char *Dest, const char *Str1, ...) -{ -char *ptr=NULL; -va_list args; - -ptr=Dest; -if (ptr) *ptr='\0'; -va_start(args,Str1); -ptr=VCatStr(ptr,Str1,args); -va_end(args); - -return(ptr); -} - - - - - -char *PadStr(char*Dest, char Pad, int PadLen) -{ -char *NewStr=NULL; -int i, len; - -if (PadLen==0) return(Dest); - -len=StrLen(Dest); -if (PadLen > 0) -{ - NewStr=Dest; - while (len < PadLen) NewStr=AddCharToBuffer(NewStr,len++,Pad); -} -else if (PadLen < 0) -{ - for (i=0; i < (0-PadLen)-len; i++) NewStr=AddCharToBuffer(NewStr,i,Pad); - NewStr=CatStr(NewStr,Dest); - //NewStr really is new, so we destroy Dest - DestroyString(Dest); -} - -return(NewStr); -} - -char *CopyPadStr(char*Dest, char *Src, char Pad, int PadLen) -{ -Dest=CopyStr(Dest,Src); -Dest=PadStr(Dest,Pad,PadLen); -return(Dest); -} - - - -//Clone string is really intended to be passed into the 'ListClone' function -//in the manner of a copy constructor, for most uses it's best to stick to -//CopyStr - -char *CloneStr(const char *Str) -{ -return(CopyStr(NULL,Str)); -} - - -char *VFormatStr(char *InBuff, const char *InputFmtStr, va_list args) -{ -int inc=100, count=1, result=0, FmtLen; -char *Tempstr=NULL, *FmtStr=NULL, *ptr; -va_list argscopy; - -Tempstr=InBuff; - -//Take a copy of the supplied Format string and change it. -//Do not allow '%n', it's useable for exploits - -FmtLen=StrLen(InputFmtStr); -FmtStr=CopyStr(FmtStr,InputFmtStr); - -//Deny %n. Replace it with %x which prints out the value of any supplied argument -ptr=strstr(FmtStr,"%n"); -while (ptr) -{ - memcpy(ptr,"%x",2); - ptr++; - ptr=strstr(ptr,"%n"); -} - - -inc=4 * FmtLen; //this should be a good average -for (count=1; count < 100; count++) -{ - result=inc * count +1; - Tempstr=SetStrLen(Tempstr, result); - - //the vsnprintf function DESTROYS the arg list that is passed to it. - //This is just plain WRONG, it's a long-standing bug. The solution is to - //us va_copy to make a new one every time and pass that in. - va_copy(argscopy,args); - result=vsnprintf(Tempstr,result,FmtStr,argscopy); - va_end(argscopy); - - /* old style returns -1 to say couldn't fit data into buffer.. so we */ - /* have to guess again */ - if (result==-1) continue; - - /* new style returns how long buffer should have been.. so we resize it */ - if (result > (inc * count)) - { - Tempstr=SetStrLen(Tempstr, result+10); - va_copy(argscopy,args); - result=vsnprintf(Tempstr,result+10,FmtStr,argscopy); - va_end(argscopy); - } - - break; -} - -DestroyString(FmtStr); - -return(Tempstr); -} - - - -char *FormatStr(char *InBuff, const char *FmtStr, ...) -{ -char *tempstr=NULL; -va_list args; - -va_start(args,FmtStr); -tempstr=VFormatStr(InBuff,FmtStr,args); -va_end(args); -return(tempstr); -} - - -char *AddCharToStr(char *Dest,char Src) -{ -char temp[2]; -char *ptr=NULL; - -temp[0]=Src; -temp[1]=0; -ptr=CatStr(Dest,temp); -return(ptr); -} - - -inline char *AddCharToBuffer(char *Dest, size_t DestLen, char Char) -{ -char *actb_ptr; - -//if (Dest==NULL || ((DestLen % 100)==0)) -actb_ptr=(char *) realloc((void *) Dest,DestLen +110); -//else actb_ptr=Dest; - -actb_ptr[DestLen]=Char; -actb_ptr[DestLen+1]='\0'; - -return(actb_ptr); -} - - -inline char *AddBytesToBuffer(char *Dest, size_t DestLen, char *Bytes, size_t NoOfBytes) -{ -char *actb_ptr=NULL; - -//if (Dest==NULL || ((DestLen % 100)==0)) -actb_ptr=(char *) realloc((void *) Dest,DestLen + NoOfBytes +10); -//else actb_ptr=Dest; - -memcpy(actb_ptr+DestLen,Bytes,NoOfBytes); - -return(actb_ptr); -} - - - -char *SetStrLen(char *Str,size_t len) -{ -/* Note len+1 to allow for terminating NULL */ -if (Str==NULL) return((char *) calloc(1,len+1)); -else return( (char *) realloc(Str,len+1)); -} - - -char *strlwr(char *str) -{ -char *ptr; - -if (! str) return(NULL); -for (ptr=str; *ptr !='\0'; ptr++) *ptr=tolower(*ptr); -return(str); -} - - -char *strupr(char *str) -{ -char *ptr; -if (! str) return(NULL); -for (ptr=str; *ptr !='\0'; ptr++) *ptr=toupper(*ptr); -return(str); -} - - -char *strrep(char *str, char oldchar, char newchar) -{ -char *ptr; - -if (! str) return(NULL); -for (ptr=str; *ptr !='\0'; ptr++) -{ -if (*ptr==oldchar) *ptr=newchar; -} -return(str); -} - -char *strmrep(char *str, char *oldchars, char newchar) -{ -char *ptr; - -if (! str) return(NULL); -for (ptr=str; *ptr !='\0'; ptr++) -{ -if (strchr(oldchars,*ptr)) *ptr=newchar; -} -return(str); -} - -void StripTrailingWhitespace(char *str) -{ -size_t len; -char *ptr; - -len=StrLen(str); -if (len==0) return; -for(ptr=str+len-1; (ptr >= str) && isspace(*ptr); ptr--) *ptr='\0'; -} - - -void StripLeadingWhitespace(char *str) -{ -char *ptr, *start=NULL; - -if (! str) return; -for(ptr=str; *ptr !='\0'; ptr++) -{ - if ((! start) && (! isspace(*ptr))) start=ptr; -} - -if (!start) start=ptr; - memmove(str,start,ptr+1-start); -} - - - -void StripCRLF(char *Line) -{ -size_t len; -char *ptr; - -len=StrLen(Line); -if (len < 1) return; - -for (ptr=Line+len-1; ptr >= Line; ptr--) -{ - if (strchr("\n\r",*ptr)) *ptr='\0'; - else break; -} - -} - - -void StripQuotes(char *Str) -{ -int len; -char *ptr, StartQuote='\0'; - -ptr=Str; -while (isspace(*ptr)) ptr++; - -if ((*ptr=='"') || (*ptr=='\'')) -{ - StartQuote=*ptr; - len=StrLen(ptr); - if ((len > 0) && (StartQuote != '\0') && (ptr[len-1]==StartQuote)) - { - if (ptr[len-1]==StartQuote) ptr[len-1]='\0'; - memmove(Str,ptr+1,len); - } -} - -} - - -char *EnquoteStr(char *Out, const char *In) -{ -const char *ptr; -char *ReturnStr=NULL; -size_t len=0; - -ptr=In; -ReturnStr=CopyStr(Out,""); - -while (ptr && (*ptr != '\0')) -{ - switch (*ptr) - { - case '\\': - case '"': - case '\'': - ReturnStr=AddCharToBuffer(ReturnStr,len,'\\'); - len++; - ReturnStr=AddCharToBuffer(ReturnStr,len, *ptr); - len++; - break; - - - case '\r': - ReturnStr=AddCharToBuffer(ReturnStr,len,'\\'); - len++; - ReturnStr=AddCharToBuffer(ReturnStr,len, 'r'); - len++; - break; - - - case '\n': - ReturnStr=AddCharToBuffer(ReturnStr,len,'\\'); - len++; - ReturnStr=AddCharToBuffer(ReturnStr,len, 'n'); - len++; - break; - - default: - ReturnStr=AddCharToBuffer(ReturnStr,len, *ptr); - len++; - break; - } - ptr++; -} - -return(ReturnStr); -} - - - -int MatchTokenFromList(const char *Token,const char **List, int Flags) -{ -int count; -size_t tlen, ilen; -char Up1stChar, Lwr1stChar; -const char *Item; - -if ((! Token) || (*Token=='\0')) return(-1); -Up1stChar=toupper(*Token); -Lwr1stChar=tolower(*Token); -tlen=StrLen(Token); -for (count=0; List[count] !=NULL; count++) -{ - Item=List[count]; - if ((*Item==Lwr1stChar) || (*Item==Up1stChar)) - { - ilen=StrLen(Item); - - if (Flags & MATCH_TOKEN_PART) - { - if (tlen > ilen) continue; - if (Flags & MATCH_TOKEN_CASE) - { - if (strncmp(Token,Item,ilen)==0) return(count); - } - else if (strncasecmp(Token,Item,ilen)==0) return(count); - } - else - { - if (tlen != ilen) continue; - if (Flags & MATCH_TOKEN_CASE) - { - if(strcmp(Token,List[count])==0) return(count); - } - else if (strcasecmp(Token,List[count])==0) return(count); - } - } -} -return(-1); -} - - - -int MatchLineStartFromList(const char *Token,char **List) -{ -int count; -size_t len; - -if ((! Token) || (*Token=='\0')) return(-1); -if (! List) return(-1); -for (count=0; List[count] !=NULL; count++) -{ - if (*Token==*List[count]) - { - len=StrLen(List[count]); - - if ( - (len >0) && - (strncasecmp(Token,List[count],len)==0) - ) return(count); - } -} -return(-1); -} - - - - - - -#define ESC 0x1B - -char *UnQuoteStr(char *Buffer, const char *Line) -{ -char *out, *in; -size_t olen=0; -char hex[3]; - -if (Line==NULL) return(NULL); -out=CopyStr(Buffer,""); -in=(char *) Line; - -while(in && (*in != '\0') ) -{ - if (*in=='\\') - { - in++; - switch (*in) - { - case 'e': - out=AddCharToBuffer(out,olen,ESC); - olen++; - break; - - - case 'n': - out=AddCharToBuffer(out,olen,'\n'); - olen++; - break; - - case 'r': - out=AddCharToBuffer(out,olen,'\r'); - olen++; - break; - - case 't': - out=AddCharToBuffer(out,olen,'\t'); - olen++; - break; - - case 'x': - in++; hex[0]=*in; - in++; hex[1]=*in; - hex[2]='\0'; - out=AddCharToBuffer(out,olen,strtol(hex,NULL,16) & 0xFF); - olen++; - break; - - case '\\': - default: - out=AddCharToBuffer(out,olen,*in); - olen++; - break; - - } - } - else - { - out=AddCharToBuffer(out,olen,*in); - olen++; - } - in++; -} - -return(out); -} - - - -char *QuoteCharsInStr(char *Buffer, const char *String, const char *QuoteChars) -{ -char *RetStr=NULL; -const char *sptr, *cptr; -size_t olen=0; - -RetStr=CopyStr(Buffer,""); -if (! String) return(RetStr); - -for (sptr=String; *sptr !='\0'; sptr++) -{ - for (cptr=QuoteChars; *cptr !='\0'; cptr++) - { - if (*sptr==*cptr) - { - RetStr=AddCharToBuffer(RetStr,olen, '\\'); - olen++; - break; - } - } - RetStr=AddCharToBuffer(RetStr,olen,*sptr); - olen++; -} - -return(RetStr); -} - - diff --git a/libUseful-2.6/string.h b/libUseful-2.6/string.h deleted file mode 100755 index ca35f1a..0000000 --- a/libUseful-2.6/string.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef LIBUSEFUL_STRING -#define LIBUSEFUL_STRING - -#include -#include //for strlen, used below in StrLen -#include "defines.h" - -#define MATCH_TOKEN_PART 1 -#define MATCH_TOKEN_CASE 2 - -#ifdef __cplusplus -extern "C" { -#endif - -//A few very simple and frequently used functions can be reduced -//down to macros using weird stuff like the ternary condition -//operator '?' and the dreaded comma operator ',' -#define StrLen(str) ( str ? strlen(str) : 0 ) -#define StrValid(str) ( (str && (*(const char *) str != '\0')) ? TRUE : FALSE ) -//#define StrEnd(str) ( ((! str) || (*str == '\0') || (str > __builtin_frame_address (0)) ? TRUE : FALSE ) -#define StrEnd(str) ( (str && (*(const char *) str != '\0')) ? FALSE : TRUE ) - -//size_t StrLen(const char *Str); -void DestroyString(void *); -int CompareStr(const char *S1, const char *S2); -char *CopyStrLen(char *,const char *,size_t); -char *CopyStr(char *, const char *); -char *MCatStr(char *, const char *, ...); -char *MCopyStr(char *, const char *, ...); -char *CatStr(char *, const char *); -char *CatStrLen(char *,const char *,size_t); -char *PadStr(char*Dest, char Pad, int PadLen); -char *CopyPadStr(char*Dest, char *Src, char Pad, int PadLen); -char *VFormatStr(char *,const char *,va_list); -char *FormatStr(char *,const char *,...); -char *AddCharToStr(char *,char); -char *AddCharToBuffer(char *Buffer, size_t BuffLen, char Char); -char *AddBytesToBuffer(char *Buffer, size_t BuffLen, char *Bytes, size_t Len); -char *SetStrLen(char *,size_t); -char *strupr(char *); -char *strlwr(char *); -char *strrep(char *,char, char); -char *strmrep(char *str, char *oldchars, char newchar); -char *CloneString(const char *); -void StripTrailingWhitespace(char *); -void StripLeadingWhitespace(char *); -void StripCRLF(char *); -void StripQuotes(char *); -char *QuoteCharsInStr(char *Buffer, const char *String,const char *QuoteChars); -char *UnQuoteStr(char *Buffer, const char *Line); -char *EnquoteStr(char *Out, const char *In); -int MatchTokenFromList(const char *Token,const char **List, int Flags); -int MatchLineStartFromList(const char *Token,char **List); - -#ifdef __cplusplus -} -#endif - - - - -#endif - diff --git a/libUseful-2.6/tar.c b/libUseful-2.6/tar.c deleted file mode 100755 index 94177ac..0000000 --- a/libUseful-2.6/tar.c +++ /dev/null @@ -1,285 +0,0 @@ -#include "tar.h" -#include -#include -#include -#include "FileSystem.h" - -#define TAR_RECORDSIZE 512 - -#define FILE_MODE_OFFSET 100 -#define USER_OFFSET 108 -#define GROUP_OFFSET 116 -#define SIZE_OFFSET 124 -#define MTIME_OFFSET 136 -#define CHECKSUM_OFFSET 148 -#define FTYPE_OFFSET 157 - -typedef struct -{ /* byte offset */ - char name[100]; /* 0 */ - char mode[8]; /* 100 */ - char uid[8]; /* 108 */ - char gid[8]; /* 116 */ - char size[12]; /* 124 */ - char mtime[12]; /* 136 */ - char chksum[8]; /* 148 */ - char typeflag; /* 156 */ - char linkname[100]; /* 157 */ - char magic[6]; /* 257 */ - char version[2]; /* 263 */ - char uname[32]; /* 265 */ - char gname[32]; /* 297 */ - char devmajor[8]; /* 329 */ - char devminor[8]; /* 337 */ - char prefix[155]; /* 345 */ - /* 500 */ - char pad[12]; -} TTarHeader; - - -int TarReadHeader(STREAM *S, ListNode *Vars) -{ -char *Tempstr=NULL; -int len, result, RetVal=FALSE; -TTarHeader *Head; - -len=sizeof(TTarHeader); -Head=(TTarHeader *) calloc(1,len); -result=STREAMReadBytes(S,(char *) Head,len); -printf("HEAD: %d %s\n",result,(char *) Head); -if (result == len) -{ -Tempstr=CopyStr(Tempstr,Head->prefix); -Tempstr=CatStr(Tempstr,Head->name); -SetVar(Vars,"Path",Tempstr); - -//Convert 'Size' from octal. Yes, octal. -Tempstr=FormatStr(Tempstr,"%d",strtol(Head->size,NULL,8)); -SetVar(Vars,"Size",Tempstr); - -//mode is in octal too -Tempstr=FormatStr(Tempstr,"%d",strtol(Head->mode,NULL,8)); -SetVar(Vars,"Mode",Tempstr); - -//mtime in, yes, you guessed it, octal -Tempstr=FormatStr(Tempstr,"%d",strtol(Head->mtime,NULL,8)); -SetVar(Vars,"Mtime",Tempstr); - - -SetVar(Vars,"Type","file"); -StripTrailingWhitespace(Head->magic); -if (strcmp(Head->magic,"ustar")==0) -{ -switch (Head->typeflag) -{ - case '1': SetVar(Vars,"Type","hardlink"); break; - case '2': SetVar(Vars,"Type","symlink"); break; - case '3': SetVar(Vars,"Type","chardev"); break; - case '4': SetVar(Vars,"Type","blkdev"); break; - case '5': SetVar(Vars,"Type","directory"); break; -} - -} -RetVal=TRUE; -} - -DestroyString(Tempstr); -free(Head); - -return(RetVal); -} - - -void TarUnpack(STREAM *Tar) -{ -ListNode *Vars; -char *Path=NULL, *Tempstr=NULL, *ptr; -int bytes_read, bytes_total, val, result; -STREAM *S; - -Vars=ListCreate(); -while (TarReadHeader(Tar, Vars)) -{ - Path=CopyStr(Path,GetVar(Vars,"Path")); - if (StrLen(Path)) - { - ptr=GetVar(Vars,"Type"); - if (ptr) - { - if (strcmp(ptr,"directory")==0) - { - mkdir(Path,atoi(GetVar(Vars,"Mode"))); - } - else if (strcmp(ptr,"file")==0) - { - MakeDirPath(Path,0700); - S=STREAMOpenFile(Path,SF_WRONLY|SF_CREAT|SF_TRUNC); - if (S) fchmod(S->out_fd,atoi(GetVar(Vars,"Mode"))); - bytes_read=0; - bytes_total=atoi(GetVar(Vars,"Size")); - Tempstr=SetStrLen(Tempstr,BUFSIZ); - while (bytes_read < bytes_total) - { - val=bytes_total - bytes_read; - if (val > BUFSIZ) val=BUFSIZ; - if ((val % 512)==0) result=val; - else result=((val / 512) + 1) * 512; - result=STREAMReadBytes(Tar,Tempstr,result); - if (result > val) result=val; - if (S) STREAMWriteBytes(S,Tempstr,result); - bytes_read+=result; - } - STREAMClose(S); - } - } - } - ListClear(Vars,DestroyString); -} - -ListDestroy(Vars,DestroyString); -DestroyString(Tempstr); -DestroyString(Path); -} - - - -void TarWriteHeader(STREAM *S, char *Path, struct stat *FStat) -{ -char *Tempstr=NULL, *ptr; -int i, chksum=0; -TTarHeader *Head; -struct passwd *pwd; -struct group *grp; - -Head=(TTarHeader *) calloc(1,sizeof(TTarHeader)); - - ptr=Path; - if (*ptr=='/') ptr++; - memcpy(Head->name,ptr,StrLen(ptr)); - - sprintf(Head->mode,"%07o",FStat->st_mode); - sprintf(Head->uid,"%07o",FStat->st_uid); - sprintf(Head->gid,"%07o",FStat->st_gid); - sprintf(Head->size,"%011lo",(unsigned long) FStat->st_size); - sprintf(Head->mtime,"%011lo",(unsigned long) FStat->st_mtime); - - if (S_ISDIR(FStat->st_mode)) Head->typeflag='5'; - else if (S_ISLNK(FStat->st_mode)) Head->typeflag='2'; - else if (S_ISCHR(FStat->st_mode)) Head->typeflag='3'; - else if (S_ISBLK(FStat->st_mode)) Head->typeflag='4'; - else if (S_ISFIFO(FStat->st_mode)) Head->typeflag='6'; - else Head->typeflag='0'; - - memset(Head->chksum,' ',8); - - memcpy(Head->magic,"ustar\0",6); - memcpy(Head->version,"00",2); - - pwd=getpwuid(FStat->st_uid); - if (pwd) strcpy(Head->uname,pwd->pw_name); - - grp=getgrgid(FStat->st_gid); - if (grp) strcpy(Head->gname,grp->gr_name); - - if ( (Head->typeflag == '3') || (Head->typeflag == '4') ) - { - sprintf(Head->devmajor,"%07o",major(FStat->st_rdev)); - sprintf(Head->devminor,"%07o",minor(FStat->st_rdev)); - } - - ptr=(char *) Head; - for (i=0; i < 512; i++) chksum+=*(ptr+i); - snprintf(Head->chksum,8,"%06o",chksum); - - -STREAMWriteBytes(S,(char *) Head,512); - -DestroyString(Tempstr); -free(Head); -} - - - -void TarWriteFooter(STREAM *Tar) -{ -char *Tempstr=NULL; - -Tempstr=SetStrLen(Tempstr,TAR_RECORDSIZE); -memset(Tempstr,0,TAR_RECORDSIZE); -STREAMWriteBytes(Tar,Tempstr,TAR_RECORDSIZE); -STREAMWriteBytes(Tar,Tempstr,TAR_RECORDSIZE); - -DestroyString(Tempstr); -} - - - - -void TarAddFile(STREAM *Tar, STREAM *File) -{ -char *Buffer=NULL; -int result; - -Buffer=SetStrLen(Buffer,TAR_RECORDSIZE); - -memset(Buffer,0,TAR_RECORDSIZE); -result=STREAMReadBytes(File,Buffer,TAR_RECORDSIZE); -while (result > 0) -{ - STREAMWriteBytes(Tar,Buffer,TAR_RECORDSIZE); - memset(Buffer,0,TAR_RECORDSIZE); - result=STREAMReadBytes(File,Buffer,TAR_RECORDSIZE); -} - -DestroyString(Buffer); -} - - - -void TarInternalProcessFiles(STREAM *Tar, char *FilePattern) -{ -glob_t Glob; -char *Tempstr=NULL, *ptr; -struct stat FStat; -int i; -STREAM *S; - -ptr=GetToken(FilePattern,"\\S",&Tempstr,GETTOKEN_QUOTES); -if (ptr) glob(Tempstr,0,NULL,&Glob); -while (ptr) -{ - ptr=GetToken(ptr,"\\S",&Tempstr,GETTOKEN_QUOTES); - if (ptr) glob(Tempstr,GLOB_APPEND,NULL,&Glob); -} - -for (i=0; i < Glob.gl_pathc; i++) -{ - stat(Glob.gl_pathv[i],&FStat); - if (S_ISDIR(FStat.st_mode)) - { - Tempstr=MCopyStr(Tempstr,Glob.gl_pathv[i],"/*",NULL); - TarInternalProcessFiles(Tar, Tempstr); - } - else - { - S=STREAMOpenFile(Glob.gl_pathv[i],SF_RDONLY); - if (S) - { - TarWriteHeader(Tar, Glob.gl_pathv[i],&FStat); - TarAddFile(Tar, S); - STREAMClose(S); - } - } -} - - -globfree(&Glob); -DestroyString(Tempstr); -} - - -void TarFiles(STREAM *Tar, char *FilePattern) -{ - TarInternalProcessFiles(Tar, FilePattern); - TarWriteFooter(Tar); -} diff --git a/libUseful-2.6/tar.h b/libUseful-2.6/tar.h deleted file mode 100755 index b1c8388..0000000 --- a/libUseful-2.6/tar.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef LIBUSEFUL_TAR_H -#define LIBUSEFUL_TAR_H - -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int TarReadHeader(STREAM *S, ListNode *Vars); -void TarUnpack(STREAM *Tar); -void TarWriteHeader(STREAM *S, char *FileName, struct stat *FStat); -void TarWriteFooter(STREAM *Tar); -void TarAddFile(STREAM *Tar, STREAM *File); -void TarFiles(STREAM *Tar, char *FilePattern); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/test.c b/libUseful-2.6/test.c deleted file mode 100755 index 335710b..0000000 --- a/libUseful-2.6/test.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "libUseful.h" - -/* -main() -{ -char *ptr; - -CredsStoreAdd("test1", "user1", "pass1"); -CredsStoreAdd("test2", "user2", "pass2"); -CredsStoreAdd("test3", "user3", "pass3"); -CredsStoreAdd("test4", "user4", "pass4"); -ptr=CredsStoreGetSecret("test3", "user3"); - -printf("%s\n",ptr); -} -*/ - - -void DumpVars(ListNode *Vars) -{ -ListNode *Curr; - -Curr=ListGetNext(Vars); -while (Curr) -{ -printf("%s = %s\n",Curr->Tag,Curr->Item); -Curr=ListGetNext(Curr); -} -} - - -int Tester(const char *Source, ListNode *Vars) -{ -char *Tempstr=NULL; - -Tempstr=FormatStr(Tempstr,"pid=%d&string=hello_back&val=%s",getpid(),GetVar(Vars,"integer")); -MessageBusWrite("parent", Tempstr); - -DestroyString(Tempstr); -return(TRUE); -} - - -main() -{ -char *Tempstr=NULL; -ListNode *Vars, *Streams; -STREAM *S; -int i; -char *IP[]={"217.33.140.70","8.8.8.8","4.2.2.1","88.198.48.36",NULL}; - -Vars=ListCreate(); -Streams=ListCreate(); -MessageBusRegister("proc:tester.test.func", 4, 10, Tester); -MessageBusRegister("http://freegeoip.net/xml/", 4, 10, NULL); - -printf("PARENT: %d\n",getpid()); -for (i=0; i < 4; i++) -{ -Tempstr=FormatStr(Tempstr,"string=hello&integer=%d",i); -MessageBusWrite("proc:tester.test.func", Tempstr); -MessageBusWrite("http://freegeoip.net/xml/", IP[i]); - -MessageQueueAddToSelect(Streams); -S=STREAMSelect(Streams, NULL); -if (S) -{ - MessageBusRecv(S, &Tempstr, Vars); - DumpVars(Vars); -} -else printf("NO ACTIVITY!\n"); -sleep(1); -} - - -} diff --git a/libUseful-2.6/test.exe b/libUseful-2.6/test.exe deleted file mode 100755 index 7b3339e..0000000 Binary files a/libUseful-2.6/test.exe and /dev/null differ diff --git a/libUseful-2.6/unix_socket.c b/libUseful-2.6/unix_socket.c deleted file mode 100755 index 976e8f1..0000000 --- a/libUseful-2.6/unix_socket.c +++ /dev/null @@ -1,120 +0,0 @@ -#include "unix_socket.h" -#include -#include -#include - -// crazyshit function because different implementations treat -// sun_path differently, so we have to derive a safe length for it! -void sun_set_path(struct sockaddr_un *sa, const char *Path) -{ -int len, val; -char *ptr1, *ptr2; -off_t pos; - -memset(sa,0,sizeof(struct sockaddr_un)); -sa->sun_family=AF_UNIX; -ptr1=sa->sun_path; -ptr2=(char *) sa; //sa is already a pointer, so we don't need & - -len=sizeof(struct sockaddr_un) - (ptr1-ptr2); - -if (len > 0) -{ - len--; //force room for terminating \0 - - //all hail strlcpy, makes life easier - #ifdef strlcpy - strlcpy(sa.sun_path,Path,len); - - //else grrrr - #else - val=strlen(Path); - if (val < len) len=val; - strncpy(sa->sun_path,Path,len); - sa->sun_path[len]='\0'; - #endif -} - -} - - -int OpenUnixSocket(const char *Path, int Type) -{ -int sock; -struct sockaddr_un sa; -int val; - -if (Type==0) Type=SOCK_STREAM; - -sock=socket(AF_UNIX, Type, FALSE); -if (sock==-1) return(-1); - -sun_set_path(&sa, Path); -val=sizeof(sa); -if (connect(sock,(struct sockaddr *) &sa,val)==0) return(sock); - -close(sock); -return(-1); -} - - - -int STREAMConnectUnixSocket(STREAM *S, const char *Path, int ConType) -{ - - S->in_fd=OpenUnixSocket(Path, ConType); - if (S->in_fd==-1) return(FALSE); - S->out_fd=S->in_fd; - S->Type=ConType; - - return(TRUE); -} - - - -int InitUnixServerSock(int Type, const char *Path) -{ -int sock; -struct sockaddr_un sa; -socklen_t salen; -int result; - -if (Type==0) Type=SOCK_STREAM; -sock=socket(AF_UNIX, Type, 0); -if (sock <0) return(-1); - -//No reason to pass server/listen sockets across an exec -fcntl(sock, F_SETFD, FD_CLOEXEC); - -sun_set_path(&sa, Path); -salen=sizeof(struct sockaddr_un); -result=bind(sock,(struct sockaddr *) &sa, salen); - -if ((result==0) && (Type==SOCK_STREAM)) -{ - result=listen(sock,10); -} - -if (result==0) return(sock); -else -{ -close(sock); -return(-1); -} -} - - - -int UnixServerSockAccept(int ServerSock) -{ -struct sockaddr_un sa; -socklen_t salen; -int sock; - -salen=sizeof(sa); -sock=accept(ServerSock,(struct sockaddr *) &sa,&salen); -return(sock); -} - - - diff --git a/libUseful-2.6/unix_socket.h b/libUseful-2.6/unix_socket.h deleted file mode 100755 index 900313f..0000000 --- a/libUseful-2.6/unix_socket.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef LIBUSEFUL_UNIXSOCK_H -#define LIBUSEFUL_UNIXSOCK_H - -#include "file.h" -#include "defines.h" -#include "includes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int OpenUnixSocket(const char *Path, int SockType); -int STREAMConnectUnixSocket(STREAM *S, const char *Path, int SockType); -int InitUnixServerSock(int Type, const char *Path); -int UnixServerSockAccept(int ServerSock); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/libUseful-2.6/whirlpool.c b/libUseful-2.6/whirlpool.c deleted file mode 100755 index 38e24b1..0000000 --- a/libUseful-2.6/whirlpool.c +++ /dev/null @@ -1,1673 +0,0 @@ -/** - * The Whirlpool hashing function. - * - *

- * References - * - *

- * The Whirlpool algorithm was developed by - * Paulo S. L. M. Barreto and - * Vincent Rijmen. - * - * See - * P.S.L.M. Barreto, V. Rijmen, - * ``The Whirlpool hashing function,'' - * WHIRLPOOL submission, 2000 (tweaked version, 2001), - * - * - * @author Paulo S.L.M. Barreto - * @author Vincent Rijmen. - * - * @version 3.0 (2003.03.12) - * - * ============================================================================= - * - * Differences from version 2.1: - * - * - Suboptimal diffusion matrix replaced by cir(1, 1, 4, 1, 8, 5, 2, 9). - * - * ============================================================================= - * - * Differences from version 2.0: - * - * - Generation of ISO/IEC 10118-3 test vectors. - * - Bug fix: nonzero carry was ignored when tallying the data length - * (this bug apparently only manifested itself when feeding data - * in pieces rather than in a single chunk at once). - * - Support for MS Visual C++ 64-bit integer arithmetic. - * - * Differences from version 1.0: - * - * - Original S-box replaced by the tweaked, hardware-efficient version. - * - * ============================================================================= - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''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 AUTHORS 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. - * - */ - -#include -#include -#include -#include -#include - -#include "whirlpool.h" - -#if UINT_MAX >= 4294967295UL - -#define ONE32 0xffffffffU - -#else - -#define ONE32 0xffffffffUL - -#endif - -#define ONE8 0xffU -#define ONE16 0xffffU - -#define T8(x) ((x) & ONE8) -#define T16(x) ((x) & ONE16) -#define T32(x) ((x) & ONE32) - -#define LL(v) (v##ULL) -#define ONE64 LL(0xffffffffffffffff) - - -#define T64(x) ((x) & ONE64) -#define ROTR64(v, n) (((v) >> (n)) | T64((v) << (64 - (n)))) -/* - * Note: the test is used to detect native 64-bit architectures; - * if the unsigned long is strictly greater than 32-bit, it is - * assumed to be at least 64-bit. This will not work correctly - * on (old) 36-bit architectures (PDP-11 for instance). - * - * On non-64-bit architectures, "long long" is used. - */ - -/* - * U8TO32_BIG(c) returns the 32-bit value stored in big-endian convention - * in the unsigned char array pointed to by c. - */ -#define U8TO32_BIG(c) (((uint32_t)T8(*(c)) << 24) | ((uint32_t)T8(*((c) + 1)) << 16) | ((uint32_t)T8(*((c) + 2)) << 8) | ((uint32_t)T8(*((c) + 3)))) - -/* - * U8TO32_LITTLE(c) returns the 32-bit value stored in little-endian convention - * in the unsigned char array pointed to by c. - */ -#define U8TO32_LITTLE(c) (((uint32_t)T8(*(c))) | ((uint32_t)T8(*((c) + 1)) << 8) | (uint32_t)T8(*((c) + 2)) << 16) | ((uint32_t)T8(*((c) + 3)) << 24)) - -/* - * U8TO32_BIG(c, v) stores the 32-bit-value v in big-endian convention - * into the unsigned char array pointed to by c. - */ -#define U32TO8_BIG(c, v) do { uint32_t x = (v); unsigned char *d = (c); d[0] = T8(x >> 24); d[1] = T8(x >> 16); d[2] = T8(x >> 8); d[3] = T8(x); } while (0) - -/* - * U8TO32_LITTLE(c, v) stores the 32-bit-value v in little-endian convention - * into the unsigned char array pointed to by c. - */ -#define U32TO8_LITTLE(c, v) do { uint32_t x = (v); unsigned char *d = (c); d[0] = T8(x); d[1] = T8(x >> 8); d[2] = T8(x >> 16); d[3] = T8(x >> 24); } while (0) - -/* - * ROTL32(v, n) returns the value of the 32-bit unsigned value v after - * a rotation of n bits to the left. It might be replaced by the appropriate - * architecture-specific macro. - * - * It evaluates v and n twice. - * - * The compiler might emit a warning if n is the constant 0. The result - * is undefined if n is greater than 31. - */ -#define ROTL32(v, n) (T32((v) << (n)) | ((v) >> (32 - (n)))) - -/* - * Whirlpool-specific definitions. - */ - - - - -/* #define TRACE_INTERMEDIATE_VALUES */ - -/* - * The number of rounds of the internal dedicated block cipher. - */ -#define R 10 - -/* - * Though Whirlpool is endianness-neutral, the encryption tables are listed - * in BIG-ENDIAN format, which is adopted throughout this implementation - * (but little-endian notation would be equally suitable if consistently - * employed). - */ - -static const uint64_t C0[256] = { - LL(0x18186018c07830d8), LL(0x23238c2305af4626), LL(0xc6c63fc67ef991b8), LL(0xe8e887e8136fcdfb), - LL(0x878726874ca113cb), LL(0xb8b8dab8a9626d11), LL(0x0101040108050209), LL(0x4f4f214f426e9e0d), - LL(0x3636d836adee6c9b), LL(0xa6a6a2a6590451ff), LL(0xd2d26fd2debdb90c), LL(0xf5f5f3f5fb06f70e), - LL(0x7979f979ef80f296), LL(0x6f6fa16f5fcede30), LL(0x91917e91fcef3f6d), LL(0x52525552aa07a4f8), - LL(0x60609d6027fdc047), LL(0xbcbccabc89766535), LL(0x9b9b569baccd2b37), LL(0x8e8e028e048c018a), - LL(0xa3a3b6a371155bd2), LL(0x0c0c300c603c186c), LL(0x7b7bf17bff8af684), LL(0x3535d435b5e16a80), - LL(0x1d1d741de8693af5), LL(0xe0e0a7e05347ddb3), LL(0xd7d77bd7f6acb321), LL(0xc2c22fc25eed999c), - LL(0x2e2eb82e6d965c43), LL(0x4b4b314b627a9629), LL(0xfefedffea321e15d), LL(0x575741578216aed5), - LL(0x15155415a8412abd), LL(0x7777c1779fb6eee8), LL(0x3737dc37a5eb6e92), LL(0xe5e5b3e57b56d79e), - LL(0x9f9f469f8cd92313), LL(0xf0f0e7f0d317fd23), LL(0x4a4a354a6a7f9420), LL(0xdada4fda9e95a944), - LL(0x58587d58fa25b0a2), LL(0xc9c903c906ca8fcf), LL(0x2929a429558d527c), LL(0x0a0a280a5022145a), - LL(0xb1b1feb1e14f7f50), LL(0xa0a0baa0691a5dc9), LL(0x6b6bb16b7fdad614), LL(0x85852e855cab17d9), - LL(0xbdbdcebd8173673c), LL(0x5d5d695dd234ba8f), LL(0x1010401080502090), LL(0xf4f4f7f4f303f507), - LL(0xcbcb0bcb16c08bdd), LL(0x3e3ef83eedc67cd3), LL(0x0505140528110a2d), LL(0x676781671fe6ce78), - LL(0xe4e4b7e47353d597), LL(0x27279c2725bb4e02), LL(0x4141194132588273), LL(0x8b8b168b2c9d0ba7), - LL(0xa7a7a6a7510153f6), LL(0x7d7de97dcf94fab2), LL(0x95956e95dcfb3749), LL(0xd8d847d88e9fad56), - LL(0xfbfbcbfb8b30eb70), LL(0xeeee9fee2371c1cd), LL(0x7c7ced7cc791f8bb), LL(0x6666856617e3cc71), - LL(0xdddd53dda68ea77b), LL(0x17175c17b84b2eaf), LL(0x4747014702468e45), LL(0x9e9e429e84dc211a), - LL(0xcaca0fca1ec589d4), LL(0x2d2db42d75995a58), LL(0xbfbfc6bf9179632e), LL(0x07071c07381b0e3f), - LL(0xadad8ead012347ac), LL(0x5a5a755aea2fb4b0), LL(0x838336836cb51bef), LL(0x3333cc3385ff66b6), - LL(0x636391633ff2c65c), LL(0x02020802100a0412), LL(0xaaaa92aa39384993), LL(0x7171d971afa8e2de), - LL(0xc8c807c80ecf8dc6), LL(0x19196419c87d32d1), LL(0x494939497270923b), LL(0xd9d943d9869aaf5f), - LL(0xf2f2eff2c31df931), LL(0xe3e3abe34b48dba8), LL(0x5b5b715be22ab6b9), LL(0x88881a8834920dbc), - LL(0x9a9a529aa4c8293e), LL(0x262698262dbe4c0b), LL(0x3232c8328dfa64bf), LL(0xb0b0fab0e94a7d59), - LL(0xe9e983e91b6acff2), LL(0x0f0f3c0f78331e77), LL(0xd5d573d5e6a6b733), LL(0x80803a8074ba1df4), - LL(0xbebec2be997c6127), LL(0xcdcd13cd26de87eb), LL(0x3434d034bde46889), LL(0x48483d487a759032), - LL(0xffffdbffab24e354), LL(0x7a7af57af78ff48d), LL(0x90907a90f4ea3d64), LL(0x5f5f615fc23ebe9d), - LL(0x202080201da0403d), LL(0x6868bd6867d5d00f), LL(0x1a1a681ad07234ca), LL(0xaeae82ae192c41b7), - LL(0xb4b4eab4c95e757d), LL(0x54544d549a19a8ce), LL(0x93937693ece53b7f), LL(0x222288220daa442f), - LL(0x64648d6407e9c863), LL(0xf1f1e3f1db12ff2a), LL(0x7373d173bfa2e6cc), LL(0x12124812905a2482), - LL(0x40401d403a5d807a), LL(0x0808200840281048), LL(0xc3c32bc356e89b95), LL(0xecec97ec337bc5df), - LL(0xdbdb4bdb9690ab4d), LL(0xa1a1bea1611f5fc0), LL(0x8d8d0e8d1c830791), LL(0x3d3df43df5c97ac8), - LL(0x97976697ccf1335b), LL(0x0000000000000000), LL(0xcfcf1bcf36d483f9), LL(0x2b2bac2b4587566e), - LL(0x7676c57697b3ece1), LL(0x8282328264b019e6), LL(0xd6d67fd6fea9b128), LL(0x1b1b6c1bd87736c3), - LL(0xb5b5eeb5c15b7774), LL(0xafaf86af112943be), LL(0x6a6ab56a77dfd41d), LL(0x50505d50ba0da0ea), - LL(0x45450945124c8a57), LL(0xf3f3ebf3cb18fb38), LL(0x3030c0309df060ad), LL(0xefef9bef2b74c3c4), - LL(0x3f3ffc3fe5c37eda), LL(0x55554955921caac7), LL(0xa2a2b2a2791059db), LL(0xeaea8fea0365c9e9), - LL(0x656589650fecca6a), LL(0xbabad2bab9686903), LL(0x2f2fbc2f65935e4a), LL(0xc0c027c04ee79d8e), - LL(0xdede5fdebe81a160), LL(0x1c1c701ce06c38fc), LL(0xfdfdd3fdbb2ee746), LL(0x4d4d294d52649a1f), - LL(0x92927292e4e03976), LL(0x7575c9758fbceafa), LL(0x06061806301e0c36), LL(0x8a8a128a249809ae), - LL(0xb2b2f2b2f940794b), LL(0xe6e6bfe66359d185), LL(0x0e0e380e70361c7e), LL(0x1f1f7c1ff8633ee7), - LL(0x6262956237f7c455), LL(0xd4d477d4eea3b53a), LL(0xa8a89aa829324d81), LL(0x96966296c4f43152), - LL(0xf9f9c3f99b3aef62), LL(0xc5c533c566f697a3), LL(0x2525942535b14a10), LL(0x59597959f220b2ab), - LL(0x84842a8454ae15d0), LL(0x7272d572b7a7e4c5), LL(0x3939e439d5dd72ec), LL(0x4c4c2d4c5a619816), - LL(0x5e5e655eca3bbc94), LL(0x7878fd78e785f09f), LL(0x3838e038ddd870e5), LL(0x8c8c0a8c14860598), - LL(0xd1d163d1c6b2bf17), LL(0xa5a5aea5410b57e4), LL(0xe2e2afe2434dd9a1), LL(0x616199612ff8c24e), - LL(0xb3b3f6b3f1457b42), LL(0x2121842115a54234), LL(0x9c9c4a9c94d62508), LL(0x1e1e781ef0663cee), - LL(0x4343114322528661), LL(0xc7c73bc776fc93b1), LL(0xfcfcd7fcb32be54f), LL(0x0404100420140824), - LL(0x51515951b208a2e3), LL(0x99995e99bcc72f25), LL(0x6d6da96d4fc4da22), LL(0x0d0d340d68391a65), - LL(0xfafacffa8335e979), LL(0xdfdf5bdfb684a369), LL(0x7e7ee57ed79bfca9), LL(0x242490243db44819), - LL(0x3b3bec3bc5d776fe), LL(0xabab96ab313d4b9a), LL(0xcece1fce3ed181f0), LL(0x1111441188552299), - LL(0x8f8f068f0c890383), LL(0x4e4e254e4a6b9c04), LL(0xb7b7e6b7d1517366), LL(0xebeb8beb0b60cbe0), - LL(0x3c3cf03cfdcc78c1), LL(0x81813e817cbf1ffd), LL(0x94946a94d4fe3540), LL(0xf7f7fbf7eb0cf31c), - LL(0xb9b9deb9a1676f18), LL(0x13134c13985f268b), LL(0x2c2cb02c7d9c5851), LL(0xd3d36bd3d6b8bb05), - LL(0xe7e7bbe76b5cd38c), LL(0x6e6ea56e57cbdc39), LL(0xc4c437c46ef395aa), LL(0x03030c03180f061b), - LL(0x565645568a13acdc), LL(0x44440d441a49885e), LL(0x7f7fe17fdf9efea0), LL(0xa9a99ea921374f88), - LL(0x2a2aa82a4d825467), LL(0xbbbbd6bbb16d6b0a), LL(0xc1c123c146e29f87), LL(0x53535153a202a6f1), - LL(0xdcdc57dcae8ba572), LL(0x0b0b2c0b58271653), LL(0x9d9d4e9d9cd32701), LL(0x6c6cad6c47c1d82b), - LL(0x3131c43195f562a4), LL(0x7474cd7487b9e8f3), LL(0xf6f6fff6e309f115), LL(0x464605460a438c4c), - LL(0xacac8aac092645a5), LL(0x89891e893c970fb5), LL(0x14145014a04428b4), LL(0xe1e1a3e15b42dfba), - LL(0x16165816b04e2ca6), LL(0x3a3ae83acdd274f7), LL(0x6969b9696fd0d206), LL(0x09092409482d1241), - LL(0x7070dd70a7ade0d7), LL(0xb6b6e2b6d954716f), LL(0xd0d067d0ceb7bd1e), LL(0xeded93ed3b7ec7d6), - LL(0xcccc17cc2edb85e2), LL(0x424215422a578468), LL(0x98985a98b4c22d2c), LL(0xa4a4aaa4490e55ed), - LL(0x2828a0285d885075), LL(0x5c5c6d5cda31b886), LL(0xf8f8c7f8933fed6b), LL(0x8686228644a411c2), -}; - -static const uint64_t C1[256] = { - LL(0xd818186018c07830), LL(0x2623238c2305af46), LL(0xb8c6c63fc67ef991), LL(0xfbe8e887e8136fcd), - LL(0xcb878726874ca113), LL(0x11b8b8dab8a9626d), LL(0x0901010401080502), LL(0x0d4f4f214f426e9e), - LL(0x9b3636d836adee6c), LL(0xffa6a6a2a6590451), LL(0x0cd2d26fd2debdb9), LL(0x0ef5f5f3f5fb06f7), - LL(0x967979f979ef80f2), LL(0x306f6fa16f5fcede), LL(0x6d91917e91fcef3f), LL(0xf852525552aa07a4), - LL(0x4760609d6027fdc0), LL(0x35bcbccabc897665), LL(0x379b9b569baccd2b), LL(0x8a8e8e028e048c01), - LL(0xd2a3a3b6a371155b), LL(0x6c0c0c300c603c18), LL(0x847b7bf17bff8af6), LL(0x803535d435b5e16a), - LL(0xf51d1d741de8693a), LL(0xb3e0e0a7e05347dd), LL(0x21d7d77bd7f6acb3), LL(0x9cc2c22fc25eed99), - LL(0x432e2eb82e6d965c), LL(0x294b4b314b627a96), LL(0x5dfefedffea321e1), LL(0xd5575741578216ae), - LL(0xbd15155415a8412a), LL(0xe87777c1779fb6ee), LL(0x923737dc37a5eb6e), LL(0x9ee5e5b3e57b56d7), - LL(0x139f9f469f8cd923), LL(0x23f0f0e7f0d317fd), LL(0x204a4a354a6a7f94), LL(0x44dada4fda9e95a9), - LL(0xa258587d58fa25b0), LL(0xcfc9c903c906ca8f), LL(0x7c2929a429558d52), LL(0x5a0a0a280a502214), - LL(0x50b1b1feb1e14f7f), LL(0xc9a0a0baa0691a5d), LL(0x146b6bb16b7fdad6), LL(0xd985852e855cab17), - LL(0x3cbdbdcebd817367), LL(0x8f5d5d695dd234ba), LL(0x9010104010805020), LL(0x07f4f4f7f4f303f5), - LL(0xddcbcb0bcb16c08b), LL(0xd33e3ef83eedc67c), LL(0x2d0505140528110a), LL(0x78676781671fe6ce), - LL(0x97e4e4b7e47353d5), LL(0x0227279c2725bb4e), LL(0x7341411941325882), LL(0xa78b8b168b2c9d0b), - LL(0xf6a7a7a6a7510153), LL(0xb27d7de97dcf94fa), LL(0x4995956e95dcfb37), LL(0x56d8d847d88e9fad), - LL(0x70fbfbcbfb8b30eb), LL(0xcdeeee9fee2371c1), LL(0xbb7c7ced7cc791f8), LL(0x716666856617e3cc), - LL(0x7bdddd53dda68ea7), LL(0xaf17175c17b84b2e), LL(0x454747014702468e), LL(0x1a9e9e429e84dc21), - LL(0xd4caca0fca1ec589), LL(0x582d2db42d75995a), LL(0x2ebfbfc6bf917963), LL(0x3f07071c07381b0e), - LL(0xacadad8ead012347), LL(0xb05a5a755aea2fb4), LL(0xef838336836cb51b), LL(0xb63333cc3385ff66), - LL(0x5c636391633ff2c6), LL(0x1202020802100a04), LL(0x93aaaa92aa393849), LL(0xde7171d971afa8e2), - LL(0xc6c8c807c80ecf8d), LL(0xd119196419c87d32), LL(0x3b49493949727092), LL(0x5fd9d943d9869aaf), - LL(0x31f2f2eff2c31df9), LL(0xa8e3e3abe34b48db), LL(0xb95b5b715be22ab6), LL(0xbc88881a8834920d), - LL(0x3e9a9a529aa4c829), LL(0x0b262698262dbe4c), LL(0xbf3232c8328dfa64), LL(0x59b0b0fab0e94a7d), - LL(0xf2e9e983e91b6acf), LL(0x770f0f3c0f78331e), LL(0x33d5d573d5e6a6b7), LL(0xf480803a8074ba1d), - LL(0x27bebec2be997c61), LL(0xebcdcd13cd26de87), LL(0x893434d034bde468), LL(0x3248483d487a7590), - LL(0x54ffffdbffab24e3), LL(0x8d7a7af57af78ff4), LL(0x6490907a90f4ea3d), LL(0x9d5f5f615fc23ebe), - LL(0x3d202080201da040), LL(0x0f6868bd6867d5d0), LL(0xca1a1a681ad07234), LL(0xb7aeae82ae192c41), - LL(0x7db4b4eab4c95e75), LL(0xce54544d549a19a8), LL(0x7f93937693ece53b), LL(0x2f222288220daa44), - LL(0x6364648d6407e9c8), LL(0x2af1f1e3f1db12ff), LL(0xcc7373d173bfa2e6), LL(0x8212124812905a24), - LL(0x7a40401d403a5d80), LL(0x4808082008402810), LL(0x95c3c32bc356e89b), LL(0xdfecec97ec337bc5), - LL(0x4ddbdb4bdb9690ab), LL(0xc0a1a1bea1611f5f), LL(0x918d8d0e8d1c8307), LL(0xc83d3df43df5c97a), - LL(0x5b97976697ccf133), LL(0x0000000000000000), LL(0xf9cfcf1bcf36d483), LL(0x6e2b2bac2b458756), - LL(0xe17676c57697b3ec), LL(0xe68282328264b019), LL(0x28d6d67fd6fea9b1), LL(0xc31b1b6c1bd87736), - LL(0x74b5b5eeb5c15b77), LL(0xbeafaf86af112943), LL(0x1d6a6ab56a77dfd4), LL(0xea50505d50ba0da0), - LL(0x5745450945124c8a), LL(0x38f3f3ebf3cb18fb), LL(0xad3030c0309df060), LL(0xc4efef9bef2b74c3), - LL(0xda3f3ffc3fe5c37e), LL(0xc755554955921caa), LL(0xdba2a2b2a2791059), LL(0xe9eaea8fea0365c9), - LL(0x6a656589650fecca), LL(0x03babad2bab96869), LL(0x4a2f2fbc2f65935e), LL(0x8ec0c027c04ee79d), - LL(0x60dede5fdebe81a1), LL(0xfc1c1c701ce06c38), LL(0x46fdfdd3fdbb2ee7), LL(0x1f4d4d294d52649a), - LL(0x7692927292e4e039), LL(0xfa7575c9758fbcea), LL(0x3606061806301e0c), LL(0xae8a8a128a249809), - LL(0x4bb2b2f2b2f94079), LL(0x85e6e6bfe66359d1), LL(0x7e0e0e380e70361c), LL(0xe71f1f7c1ff8633e), - LL(0x556262956237f7c4), LL(0x3ad4d477d4eea3b5), LL(0x81a8a89aa829324d), LL(0x5296966296c4f431), - LL(0x62f9f9c3f99b3aef), LL(0xa3c5c533c566f697), LL(0x102525942535b14a), LL(0xab59597959f220b2), - LL(0xd084842a8454ae15), LL(0xc57272d572b7a7e4), LL(0xec3939e439d5dd72), LL(0x164c4c2d4c5a6198), - LL(0x945e5e655eca3bbc), LL(0x9f7878fd78e785f0), LL(0xe53838e038ddd870), LL(0x988c8c0a8c148605), - LL(0x17d1d163d1c6b2bf), LL(0xe4a5a5aea5410b57), LL(0xa1e2e2afe2434dd9), LL(0x4e616199612ff8c2), - LL(0x42b3b3f6b3f1457b), LL(0x342121842115a542), LL(0x089c9c4a9c94d625), LL(0xee1e1e781ef0663c), - LL(0x6143431143225286), LL(0xb1c7c73bc776fc93), LL(0x4ffcfcd7fcb32be5), LL(0x2404041004201408), - LL(0xe351515951b208a2), LL(0x2599995e99bcc72f), LL(0x226d6da96d4fc4da), LL(0x650d0d340d68391a), - LL(0x79fafacffa8335e9), LL(0x69dfdf5bdfb684a3), LL(0xa97e7ee57ed79bfc), LL(0x19242490243db448), - LL(0xfe3b3bec3bc5d776), LL(0x9aabab96ab313d4b), LL(0xf0cece1fce3ed181), LL(0x9911114411885522), - LL(0x838f8f068f0c8903), LL(0x044e4e254e4a6b9c), LL(0x66b7b7e6b7d15173), LL(0xe0ebeb8beb0b60cb), - LL(0xc13c3cf03cfdcc78), LL(0xfd81813e817cbf1f), LL(0x4094946a94d4fe35), LL(0x1cf7f7fbf7eb0cf3), - LL(0x18b9b9deb9a1676f), LL(0x8b13134c13985f26), LL(0x512c2cb02c7d9c58), LL(0x05d3d36bd3d6b8bb), - LL(0x8ce7e7bbe76b5cd3), LL(0x396e6ea56e57cbdc), LL(0xaac4c437c46ef395), LL(0x1b03030c03180f06), - LL(0xdc565645568a13ac), LL(0x5e44440d441a4988), LL(0xa07f7fe17fdf9efe), LL(0x88a9a99ea921374f), - LL(0x672a2aa82a4d8254), LL(0x0abbbbd6bbb16d6b), LL(0x87c1c123c146e29f), LL(0xf153535153a202a6), - LL(0x72dcdc57dcae8ba5), LL(0x530b0b2c0b582716), LL(0x019d9d4e9d9cd327), LL(0x2b6c6cad6c47c1d8), - LL(0xa43131c43195f562), LL(0xf37474cd7487b9e8), LL(0x15f6f6fff6e309f1), LL(0x4c464605460a438c), - LL(0xa5acac8aac092645), LL(0xb589891e893c970f), LL(0xb414145014a04428), LL(0xbae1e1a3e15b42df), - LL(0xa616165816b04e2c), LL(0xf73a3ae83acdd274), LL(0x066969b9696fd0d2), LL(0x4109092409482d12), - LL(0xd77070dd70a7ade0), LL(0x6fb6b6e2b6d95471), LL(0x1ed0d067d0ceb7bd), LL(0xd6eded93ed3b7ec7), - LL(0xe2cccc17cc2edb85), LL(0x68424215422a5784), LL(0x2c98985a98b4c22d), LL(0xeda4a4aaa4490e55), - LL(0x752828a0285d8850), LL(0x865c5c6d5cda31b8), LL(0x6bf8f8c7f8933fed), LL(0xc28686228644a411), -}; - -static const uint64_t C2[256] = { - LL(0x30d818186018c078), LL(0x462623238c2305af), LL(0x91b8c6c63fc67ef9), LL(0xcdfbe8e887e8136f), - LL(0x13cb878726874ca1), LL(0x6d11b8b8dab8a962), LL(0x0209010104010805), LL(0x9e0d4f4f214f426e), - LL(0x6c9b3636d836adee), LL(0x51ffa6a6a2a65904), LL(0xb90cd2d26fd2debd), LL(0xf70ef5f5f3f5fb06), - LL(0xf2967979f979ef80), LL(0xde306f6fa16f5fce), LL(0x3f6d91917e91fcef), LL(0xa4f852525552aa07), - LL(0xc04760609d6027fd), LL(0x6535bcbccabc8976), LL(0x2b379b9b569baccd), LL(0x018a8e8e028e048c), - LL(0x5bd2a3a3b6a37115), LL(0x186c0c0c300c603c), LL(0xf6847b7bf17bff8a), LL(0x6a803535d435b5e1), - LL(0x3af51d1d741de869), LL(0xddb3e0e0a7e05347), LL(0xb321d7d77bd7f6ac), LL(0x999cc2c22fc25eed), - LL(0x5c432e2eb82e6d96), LL(0x96294b4b314b627a), LL(0xe15dfefedffea321), LL(0xaed5575741578216), - LL(0x2abd15155415a841), LL(0xeee87777c1779fb6), LL(0x6e923737dc37a5eb), LL(0xd79ee5e5b3e57b56), - LL(0x23139f9f469f8cd9), LL(0xfd23f0f0e7f0d317), LL(0x94204a4a354a6a7f), LL(0xa944dada4fda9e95), - LL(0xb0a258587d58fa25), LL(0x8fcfc9c903c906ca), LL(0x527c2929a429558d), LL(0x145a0a0a280a5022), - LL(0x7f50b1b1feb1e14f), LL(0x5dc9a0a0baa0691a), LL(0xd6146b6bb16b7fda), LL(0x17d985852e855cab), - LL(0x673cbdbdcebd8173), LL(0xba8f5d5d695dd234), LL(0x2090101040108050), LL(0xf507f4f4f7f4f303), - LL(0x8bddcbcb0bcb16c0), LL(0x7cd33e3ef83eedc6), LL(0x0a2d050514052811), LL(0xce78676781671fe6), - LL(0xd597e4e4b7e47353), LL(0x4e0227279c2725bb), LL(0x8273414119413258), LL(0x0ba78b8b168b2c9d), - LL(0x53f6a7a7a6a75101), LL(0xfab27d7de97dcf94), LL(0x374995956e95dcfb), LL(0xad56d8d847d88e9f), - LL(0xeb70fbfbcbfb8b30), LL(0xc1cdeeee9fee2371), LL(0xf8bb7c7ced7cc791), LL(0xcc716666856617e3), - LL(0xa77bdddd53dda68e), LL(0x2eaf17175c17b84b), LL(0x8e45474701470246), LL(0x211a9e9e429e84dc), - LL(0x89d4caca0fca1ec5), LL(0x5a582d2db42d7599), LL(0x632ebfbfc6bf9179), LL(0x0e3f07071c07381b), - LL(0x47acadad8ead0123), LL(0xb4b05a5a755aea2f), LL(0x1bef838336836cb5), LL(0x66b63333cc3385ff), - LL(0xc65c636391633ff2), LL(0x041202020802100a), LL(0x4993aaaa92aa3938), LL(0xe2de7171d971afa8), - LL(0x8dc6c8c807c80ecf), LL(0x32d119196419c87d), LL(0x923b494939497270), LL(0xaf5fd9d943d9869a), - LL(0xf931f2f2eff2c31d), LL(0xdba8e3e3abe34b48), LL(0xb6b95b5b715be22a), LL(0x0dbc88881a883492), - LL(0x293e9a9a529aa4c8), LL(0x4c0b262698262dbe), LL(0x64bf3232c8328dfa), LL(0x7d59b0b0fab0e94a), - LL(0xcff2e9e983e91b6a), LL(0x1e770f0f3c0f7833), LL(0xb733d5d573d5e6a6), LL(0x1df480803a8074ba), - LL(0x6127bebec2be997c), LL(0x87ebcdcd13cd26de), LL(0x68893434d034bde4), LL(0x903248483d487a75), - LL(0xe354ffffdbffab24), LL(0xf48d7a7af57af78f), LL(0x3d6490907a90f4ea), LL(0xbe9d5f5f615fc23e), - LL(0x403d202080201da0), LL(0xd00f6868bd6867d5), LL(0x34ca1a1a681ad072), LL(0x41b7aeae82ae192c), - LL(0x757db4b4eab4c95e), LL(0xa8ce54544d549a19), LL(0x3b7f93937693ece5), LL(0x442f222288220daa), - LL(0xc86364648d6407e9), LL(0xff2af1f1e3f1db12), LL(0xe6cc7373d173bfa2), LL(0x248212124812905a), - LL(0x807a40401d403a5d), LL(0x1048080820084028), LL(0x9b95c3c32bc356e8), LL(0xc5dfecec97ec337b), - LL(0xab4ddbdb4bdb9690), LL(0x5fc0a1a1bea1611f), LL(0x07918d8d0e8d1c83), LL(0x7ac83d3df43df5c9), - LL(0x335b97976697ccf1), LL(0x0000000000000000), LL(0x83f9cfcf1bcf36d4), LL(0x566e2b2bac2b4587), - LL(0xece17676c57697b3), LL(0x19e68282328264b0), LL(0xb128d6d67fd6fea9), LL(0x36c31b1b6c1bd877), - LL(0x7774b5b5eeb5c15b), LL(0x43beafaf86af1129), LL(0xd41d6a6ab56a77df), LL(0xa0ea50505d50ba0d), - LL(0x8a5745450945124c), LL(0xfb38f3f3ebf3cb18), LL(0x60ad3030c0309df0), LL(0xc3c4efef9bef2b74), - LL(0x7eda3f3ffc3fe5c3), LL(0xaac755554955921c), LL(0x59dba2a2b2a27910), LL(0xc9e9eaea8fea0365), - LL(0xca6a656589650fec), LL(0x6903babad2bab968), LL(0x5e4a2f2fbc2f6593), LL(0x9d8ec0c027c04ee7), - LL(0xa160dede5fdebe81), LL(0x38fc1c1c701ce06c), LL(0xe746fdfdd3fdbb2e), LL(0x9a1f4d4d294d5264), - LL(0x397692927292e4e0), LL(0xeafa7575c9758fbc), LL(0x0c3606061806301e), LL(0x09ae8a8a128a2498), - LL(0x794bb2b2f2b2f940), LL(0xd185e6e6bfe66359), LL(0x1c7e0e0e380e7036), LL(0x3ee71f1f7c1ff863), - LL(0xc4556262956237f7), LL(0xb53ad4d477d4eea3), LL(0x4d81a8a89aa82932), LL(0x315296966296c4f4), - LL(0xef62f9f9c3f99b3a), LL(0x97a3c5c533c566f6), LL(0x4a102525942535b1), LL(0xb2ab59597959f220), - LL(0x15d084842a8454ae), LL(0xe4c57272d572b7a7), LL(0x72ec3939e439d5dd), LL(0x98164c4c2d4c5a61), - LL(0xbc945e5e655eca3b), LL(0xf09f7878fd78e785), LL(0x70e53838e038ddd8), LL(0x05988c8c0a8c1486), - LL(0xbf17d1d163d1c6b2), LL(0x57e4a5a5aea5410b), LL(0xd9a1e2e2afe2434d), LL(0xc24e616199612ff8), - LL(0x7b42b3b3f6b3f145), LL(0x42342121842115a5), LL(0x25089c9c4a9c94d6), LL(0x3cee1e1e781ef066), - LL(0x8661434311432252), LL(0x93b1c7c73bc776fc), LL(0xe54ffcfcd7fcb32b), LL(0x0824040410042014), - LL(0xa2e351515951b208), LL(0x2f2599995e99bcc7), LL(0xda226d6da96d4fc4), LL(0x1a650d0d340d6839), - LL(0xe979fafacffa8335), LL(0xa369dfdf5bdfb684), LL(0xfca97e7ee57ed79b), LL(0x4819242490243db4), - LL(0x76fe3b3bec3bc5d7), LL(0x4b9aabab96ab313d), LL(0x81f0cece1fce3ed1), LL(0x2299111144118855), - LL(0x03838f8f068f0c89), LL(0x9c044e4e254e4a6b), LL(0x7366b7b7e6b7d151), LL(0xcbe0ebeb8beb0b60), - LL(0x78c13c3cf03cfdcc), LL(0x1ffd81813e817cbf), LL(0x354094946a94d4fe), LL(0xf31cf7f7fbf7eb0c), - LL(0x6f18b9b9deb9a167), LL(0x268b13134c13985f), LL(0x58512c2cb02c7d9c), LL(0xbb05d3d36bd3d6b8), - LL(0xd38ce7e7bbe76b5c), LL(0xdc396e6ea56e57cb), LL(0x95aac4c437c46ef3), LL(0x061b03030c03180f), - LL(0xacdc565645568a13), LL(0x885e44440d441a49), LL(0xfea07f7fe17fdf9e), LL(0x4f88a9a99ea92137), - LL(0x54672a2aa82a4d82), LL(0x6b0abbbbd6bbb16d), LL(0x9f87c1c123c146e2), LL(0xa6f153535153a202), - LL(0xa572dcdc57dcae8b), LL(0x16530b0b2c0b5827), LL(0x27019d9d4e9d9cd3), LL(0xd82b6c6cad6c47c1), - LL(0x62a43131c43195f5), LL(0xe8f37474cd7487b9), LL(0xf115f6f6fff6e309), LL(0x8c4c464605460a43), - LL(0x45a5acac8aac0926), LL(0x0fb589891e893c97), LL(0x28b414145014a044), LL(0xdfbae1e1a3e15b42), - LL(0x2ca616165816b04e), LL(0x74f73a3ae83acdd2), LL(0xd2066969b9696fd0), LL(0x124109092409482d), - LL(0xe0d77070dd70a7ad), LL(0x716fb6b6e2b6d954), LL(0xbd1ed0d067d0ceb7), LL(0xc7d6eded93ed3b7e), - LL(0x85e2cccc17cc2edb), LL(0x8468424215422a57), LL(0x2d2c98985a98b4c2), LL(0x55eda4a4aaa4490e), - LL(0x50752828a0285d88), LL(0xb8865c5c6d5cda31), LL(0xed6bf8f8c7f8933f), LL(0x11c28686228644a4), -}; - -static const uint64_t C3[256] = { - LL(0x7830d818186018c0), LL(0xaf462623238c2305), LL(0xf991b8c6c63fc67e), LL(0x6fcdfbe8e887e813), - LL(0xa113cb878726874c), LL(0x626d11b8b8dab8a9), LL(0x0502090101040108), LL(0x6e9e0d4f4f214f42), - LL(0xee6c9b3636d836ad), LL(0x0451ffa6a6a2a659), LL(0xbdb90cd2d26fd2de), LL(0x06f70ef5f5f3f5fb), - LL(0x80f2967979f979ef), LL(0xcede306f6fa16f5f), LL(0xef3f6d91917e91fc), LL(0x07a4f852525552aa), - LL(0xfdc04760609d6027), LL(0x766535bcbccabc89), LL(0xcd2b379b9b569bac), LL(0x8c018a8e8e028e04), - LL(0x155bd2a3a3b6a371), LL(0x3c186c0c0c300c60), LL(0x8af6847b7bf17bff), LL(0xe16a803535d435b5), - LL(0x693af51d1d741de8), LL(0x47ddb3e0e0a7e053), LL(0xacb321d7d77bd7f6), LL(0xed999cc2c22fc25e), - LL(0x965c432e2eb82e6d), LL(0x7a96294b4b314b62), LL(0x21e15dfefedffea3), LL(0x16aed55757415782), - LL(0x412abd15155415a8), LL(0xb6eee87777c1779f), LL(0xeb6e923737dc37a5), LL(0x56d79ee5e5b3e57b), - LL(0xd923139f9f469f8c), LL(0x17fd23f0f0e7f0d3), LL(0x7f94204a4a354a6a), LL(0x95a944dada4fda9e), - LL(0x25b0a258587d58fa), LL(0xca8fcfc9c903c906), LL(0x8d527c2929a42955), LL(0x22145a0a0a280a50), - LL(0x4f7f50b1b1feb1e1), LL(0x1a5dc9a0a0baa069), LL(0xdad6146b6bb16b7f), LL(0xab17d985852e855c), - LL(0x73673cbdbdcebd81), LL(0x34ba8f5d5d695dd2), LL(0x5020901010401080), LL(0x03f507f4f4f7f4f3), - LL(0xc08bddcbcb0bcb16), LL(0xc67cd33e3ef83eed), LL(0x110a2d0505140528), LL(0xe6ce78676781671f), - LL(0x53d597e4e4b7e473), LL(0xbb4e0227279c2725), LL(0x5882734141194132), LL(0x9d0ba78b8b168b2c), - LL(0x0153f6a7a7a6a751), LL(0x94fab27d7de97dcf), LL(0xfb374995956e95dc), LL(0x9fad56d8d847d88e), - LL(0x30eb70fbfbcbfb8b), LL(0x71c1cdeeee9fee23), LL(0x91f8bb7c7ced7cc7), LL(0xe3cc716666856617), - LL(0x8ea77bdddd53dda6), LL(0x4b2eaf17175c17b8), LL(0x468e454747014702), LL(0xdc211a9e9e429e84), - LL(0xc589d4caca0fca1e), LL(0x995a582d2db42d75), LL(0x79632ebfbfc6bf91), LL(0x1b0e3f07071c0738), - LL(0x2347acadad8ead01), LL(0x2fb4b05a5a755aea), LL(0xb51bef838336836c), LL(0xff66b63333cc3385), - LL(0xf2c65c636391633f), LL(0x0a04120202080210), LL(0x384993aaaa92aa39), LL(0xa8e2de7171d971af), - LL(0xcf8dc6c8c807c80e), LL(0x7d32d119196419c8), LL(0x70923b4949394972), LL(0x9aaf5fd9d943d986), - LL(0x1df931f2f2eff2c3), LL(0x48dba8e3e3abe34b), LL(0x2ab6b95b5b715be2), LL(0x920dbc88881a8834), - LL(0xc8293e9a9a529aa4), LL(0xbe4c0b262698262d), LL(0xfa64bf3232c8328d), LL(0x4a7d59b0b0fab0e9), - LL(0x6acff2e9e983e91b), LL(0x331e770f0f3c0f78), LL(0xa6b733d5d573d5e6), LL(0xba1df480803a8074), - LL(0x7c6127bebec2be99), LL(0xde87ebcdcd13cd26), LL(0xe468893434d034bd), LL(0x75903248483d487a), - LL(0x24e354ffffdbffab), LL(0x8ff48d7a7af57af7), LL(0xea3d6490907a90f4), LL(0x3ebe9d5f5f615fc2), - LL(0xa0403d202080201d), LL(0xd5d00f6868bd6867), LL(0x7234ca1a1a681ad0), LL(0x2c41b7aeae82ae19), - LL(0x5e757db4b4eab4c9), LL(0x19a8ce54544d549a), LL(0xe53b7f93937693ec), LL(0xaa442f222288220d), - LL(0xe9c86364648d6407), LL(0x12ff2af1f1e3f1db), LL(0xa2e6cc7373d173bf), LL(0x5a24821212481290), - LL(0x5d807a40401d403a), LL(0x2810480808200840), LL(0xe89b95c3c32bc356), LL(0x7bc5dfecec97ec33), - LL(0x90ab4ddbdb4bdb96), LL(0x1f5fc0a1a1bea161), LL(0x8307918d8d0e8d1c), LL(0xc97ac83d3df43df5), - LL(0xf1335b97976697cc), LL(0x0000000000000000), LL(0xd483f9cfcf1bcf36), LL(0x87566e2b2bac2b45), - LL(0xb3ece17676c57697), LL(0xb019e68282328264), LL(0xa9b128d6d67fd6fe), LL(0x7736c31b1b6c1bd8), - LL(0x5b7774b5b5eeb5c1), LL(0x2943beafaf86af11), LL(0xdfd41d6a6ab56a77), LL(0x0da0ea50505d50ba), - LL(0x4c8a574545094512), LL(0x18fb38f3f3ebf3cb), LL(0xf060ad3030c0309d), LL(0x74c3c4efef9bef2b), - LL(0xc37eda3f3ffc3fe5), LL(0x1caac75555495592), LL(0x1059dba2a2b2a279), LL(0x65c9e9eaea8fea03), - LL(0xecca6a656589650f), LL(0x686903babad2bab9), LL(0x935e4a2f2fbc2f65), LL(0xe79d8ec0c027c04e), - LL(0x81a160dede5fdebe), LL(0x6c38fc1c1c701ce0), LL(0x2ee746fdfdd3fdbb), LL(0x649a1f4d4d294d52), - LL(0xe0397692927292e4), LL(0xbceafa7575c9758f), LL(0x1e0c360606180630), LL(0x9809ae8a8a128a24), - LL(0x40794bb2b2f2b2f9), LL(0x59d185e6e6bfe663), LL(0x361c7e0e0e380e70), LL(0x633ee71f1f7c1ff8), - LL(0xf7c4556262956237), LL(0xa3b53ad4d477d4ee), LL(0x324d81a8a89aa829), LL(0xf4315296966296c4), - LL(0x3aef62f9f9c3f99b), LL(0xf697a3c5c533c566), LL(0xb14a102525942535), LL(0x20b2ab59597959f2), - LL(0xae15d084842a8454), LL(0xa7e4c57272d572b7), LL(0xdd72ec3939e439d5), LL(0x6198164c4c2d4c5a), - LL(0x3bbc945e5e655eca), LL(0x85f09f7878fd78e7), LL(0xd870e53838e038dd), LL(0x8605988c8c0a8c14), - LL(0xb2bf17d1d163d1c6), LL(0x0b57e4a5a5aea541), LL(0x4dd9a1e2e2afe243), LL(0xf8c24e616199612f), - LL(0x457b42b3b3f6b3f1), LL(0xa542342121842115), LL(0xd625089c9c4a9c94), LL(0x663cee1e1e781ef0), - LL(0x5286614343114322), LL(0xfc93b1c7c73bc776), LL(0x2be54ffcfcd7fcb3), LL(0x1408240404100420), - LL(0x08a2e351515951b2), LL(0xc72f2599995e99bc), LL(0xc4da226d6da96d4f), LL(0x391a650d0d340d68), - LL(0x35e979fafacffa83), LL(0x84a369dfdf5bdfb6), LL(0x9bfca97e7ee57ed7), LL(0xb44819242490243d), - LL(0xd776fe3b3bec3bc5), LL(0x3d4b9aabab96ab31), LL(0xd181f0cece1fce3e), LL(0x5522991111441188), - LL(0x8903838f8f068f0c), LL(0x6b9c044e4e254e4a), LL(0x517366b7b7e6b7d1), LL(0x60cbe0ebeb8beb0b), - LL(0xcc78c13c3cf03cfd), LL(0xbf1ffd81813e817c), LL(0xfe354094946a94d4), LL(0x0cf31cf7f7fbf7eb), - LL(0x676f18b9b9deb9a1), LL(0x5f268b13134c1398), LL(0x9c58512c2cb02c7d), LL(0xb8bb05d3d36bd3d6), - LL(0x5cd38ce7e7bbe76b), LL(0xcbdc396e6ea56e57), LL(0xf395aac4c437c46e), LL(0x0f061b03030c0318), - LL(0x13acdc565645568a), LL(0x49885e44440d441a), LL(0x9efea07f7fe17fdf), LL(0x374f88a9a99ea921), - LL(0x8254672a2aa82a4d), LL(0x6d6b0abbbbd6bbb1), LL(0xe29f87c1c123c146), LL(0x02a6f153535153a2), - LL(0x8ba572dcdc57dcae), LL(0x2716530b0b2c0b58), LL(0xd327019d9d4e9d9c), LL(0xc1d82b6c6cad6c47), - LL(0xf562a43131c43195), LL(0xb9e8f37474cd7487), LL(0x09f115f6f6fff6e3), LL(0x438c4c464605460a), - LL(0x2645a5acac8aac09), LL(0x970fb589891e893c), LL(0x4428b414145014a0), LL(0x42dfbae1e1a3e15b), - LL(0x4e2ca616165816b0), LL(0xd274f73a3ae83acd), LL(0xd0d2066969b9696f), LL(0x2d12410909240948), - LL(0xade0d77070dd70a7), LL(0x54716fb6b6e2b6d9), LL(0xb7bd1ed0d067d0ce), LL(0x7ec7d6eded93ed3b), - LL(0xdb85e2cccc17cc2e), LL(0x578468424215422a), LL(0xc22d2c98985a98b4), LL(0x0e55eda4a4aaa449), - LL(0x8850752828a0285d), LL(0x31b8865c5c6d5cda), LL(0x3fed6bf8f8c7f893), LL(0xa411c28686228644), -}; - -static const uint64_t C4[256] = { - LL(0xc07830d818186018), LL(0x05af462623238c23), LL(0x7ef991b8c6c63fc6), LL(0x136fcdfbe8e887e8), - LL(0x4ca113cb87872687), LL(0xa9626d11b8b8dab8), LL(0x0805020901010401), LL(0x426e9e0d4f4f214f), - LL(0xadee6c9b3636d836), LL(0x590451ffa6a6a2a6), LL(0xdebdb90cd2d26fd2), LL(0xfb06f70ef5f5f3f5), - LL(0xef80f2967979f979), LL(0x5fcede306f6fa16f), LL(0xfcef3f6d91917e91), LL(0xaa07a4f852525552), - LL(0x27fdc04760609d60), LL(0x89766535bcbccabc), LL(0xaccd2b379b9b569b), LL(0x048c018a8e8e028e), - LL(0x71155bd2a3a3b6a3), LL(0x603c186c0c0c300c), LL(0xff8af6847b7bf17b), LL(0xb5e16a803535d435), - LL(0xe8693af51d1d741d), LL(0x5347ddb3e0e0a7e0), LL(0xf6acb321d7d77bd7), LL(0x5eed999cc2c22fc2), - LL(0x6d965c432e2eb82e), LL(0x627a96294b4b314b), LL(0xa321e15dfefedffe), LL(0x8216aed557574157), - LL(0xa8412abd15155415), LL(0x9fb6eee87777c177), LL(0xa5eb6e923737dc37), LL(0x7b56d79ee5e5b3e5), - LL(0x8cd923139f9f469f), LL(0xd317fd23f0f0e7f0), LL(0x6a7f94204a4a354a), LL(0x9e95a944dada4fda), - LL(0xfa25b0a258587d58), LL(0x06ca8fcfc9c903c9), LL(0x558d527c2929a429), LL(0x5022145a0a0a280a), - LL(0xe14f7f50b1b1feb1), LL(0x691a5dc9a0a0baa0), LL(0x7fdad6146b6bb16b), LL(0x5cab17d985852e85), - LL(0x8173673cbdbdcebd), LL(0xd234ba8f5d5d695d), LL(0x8050209010104010), LL(0xf303f507f4f4f7f4), - LL(0x16c08bddcbcb0bcb), LL(0xedc67cd33e3ef83e), LL(0x28110a2d05051405), LL(0x1fe6ce7867678167), - LL(0x7353d597e4e4b7e4), LL(0x25bb4e0227279c27), LL(0x3258827341411941), LL(0x2c9d0ba78b8b168b), - LL(0x510153f6a7a7a6a7), LL(0xcf94fab27d7de97d), LL(0xdcfb374995956e95), LL(0x8e9fad56d8d847d8), - LL(0x8b30eb70fbfbcbfb), LL(0x2371c1cdeeee9fee), LL(0xc791f8bb7c7ced7c), LL(0x17e3cc7166668566), - LL(0xa68ea77bdddd53dd), LL(0xb84b2eaf17175c17), LL(0x02468e4547470147), LL(0x84dc211a9e9e429e), - LL(0x1ec589d4caca0fca), LL(0x75995a582d2db42d), LL(0x9179632ebfbfc6bf), LL(0x381b0e3f07071c07), - LL(0x012347acadad8ead), LL(0xea2fb4b05a5a755a), LL(0x6cb51bef83833683), LL(0x85ff66b63333cc33), - LL(0x3ff2c65c63639163), LL(0x100a041202020802), LL(0x39384993aaaa92aa), LL(0xafa8e2de7171d971), - LL(0x0ecf8dc6c8c807c8), LL(0xc87d32d119196419), LL(0x7270923b49493949), LL(0x869aaf5fd9d943d9), - LL(0xc31df931f2f2eff2), LL(0x4b48dba8e3e3abe3), LL(0xe22ab6b95b5b715b), LL(0x34920dbc88881a88), - LL(0xa4c8293e9a9a529a), LL(0x2dbe4c0b26269826), LL(0x8dfa64bf3232c832), LL(0xe94a7d59b0b0fab0), - LL(0x1b6acff2e9e983e9), LL(0x78331e770f0f3c0f), LL(0xe6a6b733d5d573d5), LL(0x74ba1df480803a80), - LL(0x997c6127bebec2be), LL(0x26de87ebcdcd13cd), LL(0xbde468893434d034), LL(0x7a75903248483d48), - LL(0xab24e354ffffdbff), LL(0xf78ff48d7a7af57a), LL(0xf4ea3d6490907a90), LL(0xc23ebe9d5f5f615f), - LL(0x1da0403d20208020), LL(0x67d5d00f6868bd68), LL(0xd07234ca1a1a681a), LL(0x192c41b7aeae82ae), - LL(0xc95e757db4b4eab4), LL(0x9a19a8ce54544d54), LL(0xece53b7f93937693), LL(0x0daa442f22228822), - LL(0x07e9c86364648d64), LL(0xdb12ff2af1f1e3f1), LL(0xbfa2e6cc7373d173), LL(0x905a248212124812), - LL(0x3a5d807a40401d40), LL(0x4028104808082008), LL(0x56e89b95c3c32bc3), LL(0x337bc5dfecec97ec), - LL(0x9690ab4ddbdb4bdb), LL(0x611f5fc0a1a1bea1), LL(0x1c8307918d8d0e8d), LL(0xf5c97ac83d3df43d), - LL(0xccf1335b97976697), LL(0x0000000000000000), LL(0x36d483f9cfcf1bcf), LL(0x4587566e2b2bac2b), - LL(0x97b3ece17676c576), LL(0x64b019e682823282), LL(0xfea9b128d6d67fd6), LL(0xd87736c31b1b6c1b), - LL(0xc15b7774b5b5eeb5), LL(0x112943beafaf86af), LL(0x77dfd41d6a6ab56a), LL(0xba0da0ea50505d50), - LL(0x124c8a5745450945), LL(0xcb18fb38f3f3ebf3), LL(0x9df060ad3030c030), LL(0x2b74c3c4efef9bef), - LL(0xe5c37eda3f3ffc3f), LL(0x921caac755554955), LL(0x791059dba2a2b2a2), LL(0x0365c9e9eaea8fea), - LL(0x0fecca6a65658965), LL(0xb9686903babad2ba), LL(0x65935e4a2f2fbc2f), LL(0x4ee79d8ec0c027c0), - LL(0xbe81a160dede5fde), LL(0xe06c38fc1c1c701c), LL(0xbb2ee746fdfdd3fd), LL(0x52649a1f4d4d294d), - LL(0xe4e0397692927292), LL(0x8fbceafa7575c975), LL(0x301e0c3606061806), LL(0x249809ae8a8a128a), - LL(0xf940794bb2b2f2b2), LL(0x6359d185e6e6bfe6), LL(0x70361c7e0e0e380e), LL(0xf8633ee71f1f7c1f), - LL(0x37f7c45562629562), LL(0xeea3b53ad4d477d4), LL(0x29324d81a8a89aa8), LL(0xc4f4315296966296), - LL(0x9b3aef62f9f9c3f9), LL(0x66f697a3c5c533c5), LL(0x35b14a1025259425), LL(0xf220b2ab59597959), - LL(0x54ae15d084842a84), LL(0xb7a7e4c57272d572), LL(0xd5dd72ec3939e439), LL(0x5a6198164c4c2d4c), - LL(0xca3bbc945e5e655e), LL(0xe785f09f7878fd78), LL(0xddd870e53838e038), LL(0x148605988c8c0a8c), - LL(0xc6b2bf17d1d163d1), LL(0x410b57e4a5a5aea5), LL(0x434dd9a1e2e2afe2), LL(0x2ff8c24e61619961), - LL(0xf1457b42b3b3f6b3), LL(0x15a5423421218421), LL(0x94d625089c9c4a9c), LL(0xf0663cee1e1e781e), - LL(0x2252866143431143), LL(0x76fc93b1c7c73bc7), LL(0xb32be54ffcfcd7fc), LL(0x2014082404041004), - LL(0xb208a2e351515951), LL(0xbcc72f2599995e99), LL(0x4fc4da226d6da96d), LL(0x68391a650d0d340d), - LL(0x8335e979fafacffa), LL(0xb684a369dfdf5bdf), LL(0xd79bfca97e7ee57e), LL(0x3db4481924249024), - LL(0xc5d776fe3b3bec3b), LL(0x313d4b9aabab96ab), LL(0x3ed181f0cece1fce), LL(0x8855229911114411), - LL(0x0c8903838f8f068f), LL(0x4a6b9c044e4e254e), LL(0xd1517366b7b7e6b7), LL(0x0b60cbe0ebeb8beb), - LL(0xfdcc78c13c3cf03c), LL(0x7cbf1ffd81813e81), LL(0xd4fe354094946a94), LL(0xeb0cf31cf7f7fbf7), - LL(0xa1676f18b9b9deb9), LL(0x985f268b13134c13), LL(0x7d9c58512c2cb02c), LL(0xd6b8bb05d3d36bd3), - LL(0x6b5cd38ce7e7bbe7), LL(0x57cbdc396e6ea56e), LL(0x6ef395aac4c437c4), LL(0x180f061b03030c03), - LL(0x8a13acdc56564556), LL(0x1a49885e44440d44), LL(0xdf9efea07f7fe17f), LL(0x21374f88a9a99ea9), - LL(0x4d8254672a2aa82a), LL(0xb16d6b0abbbbd6bb), LL(0x46e29f87c1c123c1), LL(0xa202a6f153535153), - LL(0xae8ba572dcdc57dc), LL(0x582716530b0b2c0b), LL(0x9cd327019d9d4e9d), LL(0x47c1d82b6c6cad6c), - LL(0x95f562a43131c431), LL(0x87b9e8f37474cd74), LL(0xe309f115f6f6fff6), LL(0x0a438c4c46460546), - LL(0x092645a5acac8aac), LL(0x3c970fb589891e89), LL(0xa04428b414145014), LL(0x5b42dfbae1e1a3e1), - LL(0xb04e2ca616165816), LL(0xcdd274f73a3ae83a), LL(0x6fd0d2066969b969), LL(0x482d124109092409), - LL(0xa7ade0d77070dd70), LL(0xd954716fb6b6e2b6), LL(0xceb7bd1ed0d067d0), LL(0x3b7ec7d6eded93ed), - LL(0x2edb85e2cccc17cc), LL(0x2a57846842421542), LL(0xb4c22d2c98985a98), LL(0x490e55eda4a4aaa4), - LL(0x5d8850752828a028), LL(0xda31b8865c5c6d5c), LL(0x933fed6bf8f8c7f8), LL(0x44a411c286862286), -}; - -static const uint64_t C5[256] = { - LL(0x18c07830d8181860), LL(0x2305af462623238c), LL(0xc67ef991b8c6c63f), LL(0xe8136fcdfbe8e887), - LL(0x874ca113cb878726), LL(0xb8a9626d11b8b8da), LL(0x0108050209010104), LL(0x4f426e9e0d4f4f21), - LL(0x36adee6c9b3636d8), LL(0xa6590451ffa6a6a2), LL(0xd2debdb90cd2d26f), LL(0xf5fb06f70ef5f5f3), - LL(0x79ef80f2967979f9), LL(0x6f5fcede306f6fa1), LL(0x91fcef3f6d91917e), LL(0x52aa07a4f8525255), - LL(0x6027fdc04760609d), LL(0xbc89766535bcbcca), LL(0x9baccd2b379b9b56), LL(0x8e048c018a8e8e02), - LL(0xa371155bd2a3a3b6), LL(0x0c603c186c0c0c30), LL(0x7bff8af6847b7bf1), LL(0x35b5e16a803535d4), - LL(0x1de8693af51d1d74), LL(0xe05347ddb3e0e0a7), LL(0xd7f6acb321d7d77b), LL(0xc25eed999cc2c22f), - LL(0x2e6d965c432e2eb8), LL(0x4b627a96294b4b31), LL(0xfea321e15dfefedf), LL(0x578216aed5575741), - LL(0x15a8412abd151554), LL(0x779fb6eee87777c1), LL(0x37a5eb6e923737dc), LL(0xe57b56d79ee5e5b3), - LL(0x9f8cd923139f9f46), LL(0xf0d317fd23f0f0e7), LL(0x4a6a7f94204a4a35), LL(0xda9e95a944dada4f), - LL(0x58fa25b0a258587d), LL(0xc906ca8fcfc9c903), LL(0x29558d527c2929a4), LL(0x0a5022145a0a0a28), - LL(0xb1e14f7f50b1b1fe), LL(0xa0691a5dc9a0a0ba), LL(0x6b7fdad6146b6bb1), LL(0x855cab17d985852e), - LL(0xbd8173673cbdbdce), LL(0x5dd234ba8f5d5d69), LL(0x1080502090101040), LL(0xf4f303f507f4f4f7), - LL(0xcb16c08bddcbcb0b), LL(0x3eedc67cd33e3ef8), LL(0x0528110a2d050514), LL(0x671fe6ce78676781), - LL(0xe47353d597e4e4b7), LL(0x2725bb4e0227279c), LL(0x4132588273414119), LL(0x8b2c9d0ba78b8b16), - LL(0xa7510153f6a7a7a6), LL(0x7dcf94fab27d7de9), LL(0x95dcfb374995956e), LL(0xd88e9fad56d8d847), - LL(0xfb8b30eb70fbfbcb), LL(0xee2371c1cdeeee9f), LL(0x7cc791f8bb7c7ced), LL(0x6617e3cc71666685), - LL(0xdda68ea77bdddd53), LL(0x17b84b2eaf17175c), LL(0x4702468e45474701), LL(0x9e84dc211a9e9e42), - LL(0xca1ec589d4caca0f), LL(0x2d75995a582d2db4), LL(0xbf9179632ebfbfc6), LL(0x07381b0e3f07071c), - LL(0xad012347acadad8e), LL(0x5aea2fb4b05a5a75), LL(0x836cb51bef838336), LL(0x3385ff66b63333cc), - LL(0x633ff2c65c636391), LL(0x02100a0412020208), LL(0xaa39384993aaaa92), LL(0x71afa8e2de7171d9), - LL(0xc80ecf8dc6c8c807), LL(0x19c87d32d1191964), LL(0x497270923b494939), LL(0xd9869aaf5fd9d943), - LL(0xf2c31df931f2f2ef), LL(0xe34b48dba8e3e3ab), LL(0x5be22ab6b95b5b71), LL(0x8834920dbc88881a), - LL(0x9aa4c8293e9a9a52), LL(0x262dbe4c0b262698), LL(0x328dfa64bf3232c8), LL(0xb0e94a7d59b0b0fa), - LL(0xe91b6acff2e9e983), LL(0x0f78331e770f0f3c), LL(0xd5e6a6b733d5d573), LL(0x8074ba1df480803a), - LL(0xbe997c6127bebec2), LL(0xcd26de87ebcdcd13), LL(0x34bde468893434d0), LL(0x487a75903248483d), - LL(0xffab24e354ffffdb), LL(0x7af78ff48d7a7af5), LL(0x90f4ea3d6490907a), LL(0x5fc23ebe9d5f5f61), - LL(0x201da0403d202080), LL(0x6867d5d00f6868bd), LL(0x1ad07234ca1a1a68), LL(0xae192c41b7aeae82), - LL(0xb4c95e757db4b4ea), LL(0x549a19a8ce54544d), LL(0x93ece53b7f939376), LL(0x220daa442f222288), - LL(0x6407e9c86364648d), LL(0xf1db12ff2af1f1e3), LL(0x73bfa2e6cc7373d1), LL(0x12905a2482121248), - LL(0x403a5d807a40401d), LL(0x0840281048080820), LL(0xc356e89b95c3c32b), LL(0xec337bc5dfecec97), - LL(0xdb9690ab4ddbdb4b), LL(0xa1611f5fc0a1a1be), LL(0x8d1c8307918d8d0e), LL(0x3df5c97ac83d3df4), - LL(0x97ccf1335b979766), LL(0x0000000000000000), LL(0xcf36d483f9cfcf1b), LL(0x2b4587566e2b2bac), - LL(0x7697b3ece17676c5), LL(0x8264b019e6828232), LL(0xd6fea9b128d6d67f), LL(0x1bd87736c31b1b6c), - LL(0xb5c15b7774b5b5ee), LL(0xaf112943beafaf86), LL(0x6a77dfd41d6a6ab5), LL(0x50ba0da0ea50505d), - LL(0x45124c8a57454509), LL(0xf3cb18fb38f3f3eb), LL(0x309df060ad3030c0), LL(0xef2b74c3c4efef9b), - LL(0x3fe5c37eda3f3ffc), LL(0x55921caac7555549), LL(0xa2791059dba2a2b2), LL(0xea0365c9e9eaea8f), - LL(0x650fecca6a656589), LL(0xbab9686903babad2), LL(0x2f65935e4a2f2fbc), LL(0xc04ee79d8ec0c027), - LL(0xdebe81a160dede5f), LL(0x1ce06c38fc1c1c70), LL(0xfdbb2ee746fdfdd3), LL(0x4d52649a1f4d4d29), - LL(0x92e4e03976929272), LL(0x758fbceafa7575c9), LL(0x06301e0c36060618), LL(0x8a249809ae8a8a12), - LL(0xb2f940794bb2b2f2), LL(0xe66359d185e6e6bf), LL(0x0e70361c7e0e0e38), LL(0x1ff8633ee71f1f7c), - LL(0x6237f7c455626295), LL(0xd4eea3b53ad4d477), LL(0xa829324d81a8a89a), LL(0x96c4f43152969662), - LL(0xf99b3aef62f9f9c3), LL(0xc566f697a3c5c533), LL(0x2535b14a10252594), LL(0x59f220b2ab595979), - LL(0x8454ae15d084842a), LL(0x72b7a7e4c57272d5), LL(0x39d5dd72ec3939e4), LL(0x4c5a6198164c4c2d), - LL(0x5eca3bbc945e5e65), LL(0x78e785f09f7878fd), LL(0x38ddd870e53838e0), LL(0x8c148605988c8c0a), - LL(0xd1c6b2bf17d1d163), LL(0xa5410b57e4a5a5ae), LL(0xe2434dd9a1e2e2af), LL(0x612ff8c24e616199), - LL(0xb3f1457b42b3b3f6), LL(0x2115a54234212184), LL(0x9c94d625089c9c4a), LL(0x1ef0663cee1e1e78), - LL(0x4322528661434311), LL(0xc776fc93b1c7c73b), LL(0xfcb32be54ffcfcd7), LL(0x0420140824040410), - LL(0x51b208a2e3515159), LL(0x99bcc72f2599995e), LL(0x6d4fc4da226d6da9), LL(0x0d68391a650d0d34), - LL(0xfa8335e979fafacf), LL(0xdfb684a369dfdf5b), LL(0x7ed79bfca97e7ee5), LL(0x243db44819242490), - LL(0x3bc5d776fe3b3bec), LL(0xab313d4b9aabab96), LL(0xce3ed181f0cece1f), LL(0x1188552299111144), - LL(0x8f0c8903838f8f06), LL(0x4e4a6b9c044e4e25), LL(0xb7d1517366b7b7e6), LL(0xeb0b60cbe0ebeb8b), - LL(0x3cfdcc78c13c3cf0), LL(0x817cbf1ffd81813e), LL(0x94d4fe354094946a), LL(0xf7eb0cf31cf7f7fb), - LL(0xb9a1676f18b9b9de), LL(0x13985f268b13134c), LL(0x2c7d9c58512c2cb0), LL(0xd3d6b8bb05d3d36b), - LL(0xe76b5cd38ce7e7bb), LL(0x6e57cbdc396e6ea5), LL(0xc46ef395aac4c437), LL(0x03180f061b03030c), - LL(0x568a13acdc565645), LL(0x441a49885e44440d), LL(0x7fdf9efea07f7fe1), LL(0xa921374f88a9a99e), - LL(0x2a4d8254672a2aa8), LL(0xbbb16d6b0abbbbd6), LL(0xc146e29f87c1c123), LL(0x53a202a6f1535351), - LL(0xdcae8ba572dcdc57), LL(0x0b582716530b0b2c), LL(0x9d9cd327019d9d4e), LL(0x6c47c1d82b6c6cad), - LL(0x3195f562a43131c4), LL(0x7487b9e8f37474cd), LL(0xf6e309f115f6f6ff), LL(0x460a438c4c464605), - LL(0xac092645a5acac8a), LL(0x893c970fb589891e), LL(0x14a04428b4141450), LL(0xe15b42dfbae1e1a3), - LL(0x16b04e2ca6161658), LL(0x3acdd274f73a3ae8), LL(0x696fd0d2066969b9), LL(0x09482d1241090924), - LL(0x70a7ade0d77070dd), LL(0xb6d954716fb6b6e2), LL(0xd0ceb7bd1ed0d067), LL(0xed3b7ec7d6eded93), - LL(0xcc2edb85e2cccc17), LL(0x422a578468424215), LL(0x98b4c22d2c98985a), LL(0xa4490e55eda4a4aa), - LL(0x285d8850752828a0), LL(0x5cda31b8865c5c6d), LL(0xf8933fed6bf8f8c7), LL(0x8644a411c2868622), -}; - -static const uint64_t C6[256] = { - LL(0x6018c07830d81818), LL(0x8c2305af46262323), LL(0x3fc67ef991b8c6c6), LL(0x87e8136fcdfbe8e8), - LL(0x26874ca113cb8787), LL(0xdab8a9626d11b8b8), LL(0x0401080502090101), LL(0x214f426e9e0d4f4f), - LL(0xd836adee6c9b3636), LL(0xa2a6590451ffa6a6), LL(0x6fd2debdb90cd2d2), LL(0xf3f5fb06f70ef5f5), - LL(0xf979ef80f2967979), LL(0xa16f5fcede306f6f), LL(0x7e91fcef3f6d9191), LL(0x5552aa07a4f85252), - LL(0x9d6027fdc0476060), LL(0xcabc89766535bcbc), LL(0x569baccd2b379b9b), LL(0x028e048c018a8e8e), - LL(0xb6a371155bd2a3a3), LL(0x300c603c186c0c0c), LL(0xf17bff8af6847b7b), LL(0xd435b5e16a803535), - LL(0x741de8693af51d1d), LL(0xa7e05347ddb3e0e0), LL(0x7bd7f6acb321d7d7), LL(0x2fc25eed999cc2c2), - LL(0xb82e6d965c432e2e), LL(0x314b627a96294b4b), LL(0xdffea321e15dfefe), LL(0x41578216aed55757), - LL(0x5415a8412abd1515), LL(0xc1779fb6eee87777), LL(0xdc37a5eb6e923737), LL(0xb3e57b56d79ee5e5), - LL(0x469f8cd923139f9f), LL(0xe7f0d317fd23f0f0), LL(0x354a6a7f94204a4a), LL(0x4fda9e95a944dada), - LL(0x7d58fa25b0a25858), LL(0x03c906ca8fcfc9c9), LL(0xa429558d527c2929), LL(0x280a5022145a0a0a), - LL(0xfeb1e14f7f50b1b1), LL(0xbaa0691a5dc9a0a0), LL(0xb16b7fdad6146b6b), LL(0x2e855cab17d98585), - LL(0xcebd8173673cbdbd), LL(0x695dd234ba8f5d5d), LL(0x4010805020901010), LL(0xf7f4f303f507f4f4), - LL(0x0bcb16c08bddcbcb), LL(0xf83eedc67cd33e3e), LL(0x140528110a2d0505), LL(0x81671fe6ce786767), - LL(0xb7e47353d597e4e4), LL(0x9c2725bb4e022727), LL(0x1941325882734141), LL(0x168b2c9d0ba78b8b), - LL(0xa6a7510153f6a7a7), LL(0xe97dcf94fab27d7d), LL(0x6e95dcfb37499595), LL(0x47d88e9fad56d8d8), - LL(0xcbfb8b30eb70fbfb), LL(0x9fee2371c1cdeeee), LL(0xed7cc791f8bb7c7c), LL(0x856617e3cc716666), - LL(0x53dda68ea77bdddd), LL(0x5c17b84b2eaf1717), LL(0x014702468e454747), LL(0x429e84dc211a9e9e), - LL(0x0fca1ec589d4caca), LL(0xb42d75995a582d2d), LL(0xc6bf9179632ebfbf), LL(0x1c07381b0e3f0707), - LL(0x8ead012347acadad), LL(0x755aea2fb4b05a5a), LL(0x36836cb51bef8383), LL(0xcc3385ff66b63333), - LL(0x91633ff2c65c6363), LL(0x0802100a04120202), LL(0x92aa39384993aaaa), LL(0xd971afa8e2de7171), - LL(0x07c80ecf8dc6c8c8), LL(0x6419c87d32d11919), LL(0x39497270923b4949), LL(0x43d9869aaf5fd9d9), - LL(0xeff2c31df931f2f2), LL(0xabe34b48dba8e3e3), LL(0x715be22ab6b95b5b), LL(0x1a8834920dbc8888), - LL(0x529aa4c8293e9a9a), LL(0x98262dbe4c0b2626), LL(0xc8328dfa64bf3232), LL(0xfab0e94a7d59b0b0), - LL(0x83e91b6acff2e9e9), LL(0x3c0f78331e770f0f), LL(0x73d5e6a6b733d5d5), LL(0x3a8074ba1df48080), - LL(0xc2be997c6127bebe), LL(0x13cd26de87ebcdcd), LL(0xd034bde468893434), LL(0x3d487a7590324848), - LL(0xdbffab24e354ffff), LL(0xf57af78ff48d7a7a), LL(0x7a90f4ea3d649090), LL(0x615fc23ebe9d5f5f), - LL(0x80201da0403d2020), LL(0xbd6867d5d00f6868), LL(0x681ad07234ca1a1a), LL(0x82ae192c41b7aeae), - LL(0xeab4c95e757db4b4), LL(0x4d549a19a8ce5454), LL(0x7693ece53b7f9393), LL(0x88220daa442f2222), - LL(0x8d6407e9c8636464), LL(0xe3f1db12ff2af1f1), LL(0xd173bfa2e6cc7373), LL(0x4812905a24821212), - LL(0x1d403a5d807a4040), LL(0x2008402810480808), LL(0x2bc356e89b95c3c3), LL(0x97ec337bc5dfecec), - LL(0x4bdb9690ab4ddbdb), LL(0xbea1611f5fc0a1a1), LL(0x0e8d1c8307918d8d), LL(0xf43df5c97ac83d3d), - LL(0x6697ccf1335b9797), LL(0x0000000000000000), LL(0x1bcf36d483f9cfcf), LL(0xac2b4587566e2b2b), - LL(0xc57697b3ece17676), LL(0x328264b019e68282), LL(0x7fd6fea9b128d6d6), LL(0x6c1bd87736c31b1b), - LL(0xeeb5c15b7774b5b5), LL(0x86af112943beafaf), LL(0xb56a77dfd41d6a6a), LL(0x5d50ba0da0ea5050), - LL(0x0945124c8a574545), LL(0xebf3cb18fb38f3f3), LL(0xc0309df060ad3030), LL(0x9bef2b74c3c4efef), - LL(0xfc3fe5c37eda3f3f), LL(0x4955921caac75555), LL(0xb2a2791059dba2a2), LL(0x8fea0365c9e9eaea), - LL(0x89650fecca6a6565), LL(0xd2bab9686903baba), LL(0xbc2f65935e4a2f2f), LL(0x27c04ee79d8ec0c0), - LL(0x5fdebe81a160dede), LL(0x701ce06c38fc1c1c), LL(0xd3fdbb2ee746fdfd), LL(0x294d52649a1f4d4d), - LL(0x7292e4e039769292), LL(0xc9758fbceafa7575), LL(0x1806301e0c360606), LL(0x128a249809ae8a8a), - LL(0xf2b2f940794bb2b2), LL(0xbfe66359d185e6e6), LL(0x380e70361c7e0e0e), LL(0x7c1ff8633ee71f1f), - LL(0x956237f7c4556262), LL(0x77d4eea3b53ad4d4), LL(0x9aa829324d81a8a8), LL(0x6296c4f431529696), - LL(0xc3f99b3aef62f9f9), LL(0x33c566f697a3c5c5), LL(0x942535b14a102525), LL(0x7959f220b2ab5959), - LL(0x2a8454ae15d08484), LL(0xd572b7a7e4c57272), LL(0xe439d5dd72ec3939), LL(0x2d4c5a6198164c4c), - LL(0x655eca3bbc945e5e), LL(0xfd78e785f09f7878), LL(0xe038ddd870e53838), LL(0x0a8c148605988c8c), - LL(0x63d1c6b2bf17d1d1), LL(0xaea5410b57e4a5a5), LL(0xafe2434dd9a1e2e2), LL(0x99612ff8c24e6161), - LL(0xf6b3f1457b42b3b3), LL(0x842115a542342121), LL(0x4a9c94d625089c9c), LL(0x781ef0663cee1e1e), - LL(0x1143225286614343), LL(0x3bc776fc93b1c7c7), LL(0xd7fcb32be54ffcfc), LL(0x1004201408240404), - LL(0x5951b208a2e35151), LL(0x5e99bcc72f259999), LL(0xa96d4fc4da226d6d), LL(0x340d68391a650d0d), - LL(0xcffa8335e979fafa), LL(0x5bdfb684a369dfdf), LL(0xe57ed79bfca97e7e), LL(0x90243db448192424), - LL(0xec3bc5d776fe3b3b), LL(0x96ab313d4b9aabab), LL(0x1fce3ed181f0cece), LL(0x4411885522991111), - LL(0x068f0c8903838f8f), LL(0x254e4a6b9c044e4e), LL(0xe6b7d1517366b7b7), LL(0x8beb0b60cbe0ebeb), - LL(0xf03cfdcc78c13c3c), LL(0x3e817cbf1ffd8181), LL(0x6a94d4fe35409494), LL(0xfbf7eb0cf31cf7f7), - LL(0xdeb9a1676f18b9b9), LL(0x4c13985f268b1313), LL(0xb02c7d9c58512c2c), LL(0x6bd3d6b8bb05d3d3), - LL(0xbbe76b5cd38ce7e7), LL(0xa56e57cbdc396e6e), LL(0x37c46ef395aac4c4), LL(0x0c03180f061b0303), - LL(0x45568a13acdc5656), LL(0x0d441a49885e4444), LL(0xe17fdf9efea07f7f), LL(0x9ea921374f88a9a9), - LL(0xa82a4d8254672a2a), LL(0xd6bbb16d6b0abbbb), LL(0x23c146e29f87c1c1), LL(0x5153a202a6f15353), - LL(0x57dcae8ba572dcdc), LL(0x2c0b582716530b0b), LL(0x4e9d9cd327019d9d), LL(0xad6c47c1d82b6c6c), - LL(0xc43195f562a43131), LL(0xcd7487b9e8f37474), LL(0xfff6e309f115f6f6), LL(0x05460a438c4c4646), - LL(0x8aac092645a5acac), LL(0x1e893c970fb58989), LL(0x5014a04428b41414), LL(0xa3e15b42dfbae1e1), - LL(0x5816b04e2ca61616), LL(0xe83acdd274f73a3a), LL(0xb9696fd0d2066969), LL(0x2409482d12410909), - LL(0xdd70a7ade0d77070), LL(0xe2b6d954716fb6b6), LL(0x67d0ceb7bd1ed0d0), LL(0x93ed3b7ec7d6eded), - LL(0x17cc2edb85e2cccc), LL(0x15422a5784684242), LL(0x5a98b4c22d2c9898), LL(0xaaa4490e55eda4a4), - LL(0xa0285d8850752828), LL(0x6d5cda31b8865c5c), LL(0xc7f8933fed6bf8f8), LL(0x228644a411c28686), -}; - -static const uint64_t C7[256] = { - LL(0x186018c07830d818), LL(0x238c2305af462623), LL(0xc63fc67ef991b8c6), LL(0xe887e8136fcdfbe8), - LL(0x8726874ca113cb87), LL(0xb8dab8a9626d11b8), LL(0x0104010805020901), LL(0x4f214f426e9e0d4f), - LL(0x36d836adee6c9b36), LL(0xa6a2a6590451ffa6), LL(0xd26fd2debdb90cd2), LL(0xf5f3f5fb06f70ef5), - LL(0x79f979ef80f29679), LL(0x6fa16f5fcede306f), LL(0x917e91fcef3f6d91), LL(0x525552aa07a4f852), - LL(0x609d6027fdc04760), LL(0xbccabc89766535bc), LL(0x9b569baccd2b379b), LL(0x8e028e048c018a8e), - LL(0xa3b6a371155bd2a3), LL(0x0c300c603c186c0c), LL(0x7bf17bff8af6847b), LL(0x35d435b5e16a8035), - LL(0x1d741de8693af51d), LL(0xe0a7e05347ddb3e0), LL(0xd77bd7f6acb321d7), LL(0xc22fc25eed999cc2), - LL(0x2eb82e6d965c432e), LL(0x4b314b627a96294b), LL(0xfedffea321e15dfe), LL(0x5741578216aed557), - LL(0x155415a8412abd15), LL(0x77c1779fb6eee877), LL(0x37dc37a5eb6e9237), LL(0xe5b3e57b56d79ee5), - LL(0x9f469f8cd923139f), LL(0xf0e7f0d317fd23f0), LL(0x4a354a6a7f94204a), LL(0xda4fda9e95a944da), - LL(0x587d58fa25b0a258), LL(0xc903c906ca8fcfc9), LL(0x29a429558d527c29), LL(0x0a280a5022145a0a), - LL(0xb1feb1e14f7f50b1), LL(0xa0baa0691a5dc9a0), LL(0x6bb16b7fdad6146b), LL(0x852e855cab17d985), - LL(0xbdcebd8173673cbd), LL(0x5d695dd234ba8f5d), LL(0x1040108050209010), LL(0xf4f7f4f303f507f4), - LL(0xcb0bcb16c08bddcb), LL(0x3ef83eedc67cd33e), LL(0x05140528110a2d05), LL(0x6781671fe6ce7867), - LL(0xe4b7e47353d597e4), LL(0x279c2725bb4e0227), LL(0x4119413258827341), LL(0x8b168b2c9d0ba78b), - LL(0xa7a6a7510153f6a7), LL(0x7de97dcf94fab27d), LL(0x956e95dcfb374995), LL(0xd847d88e9fad56d8), - LL(0xfbcbfb8b30eb70fb), LL(0xee9fee2371c1cdee), LL(0x7ced7cc791f8bb7c), LL(0x66856617e3cc7166), - LL(0xdd53dda68ea77bdd), LL(0x175c17b84b2eaf17), LL(0x47014702468e4547), LL(0x9e429e84dc211a9e), - LL(0xca0fca1ec589d4ca), LL(0x2db42d75995a582d), LL(0xbfc6bf9179632ebf), LL(0x071c07381b0e3f07), - LL(0xad8ead012347acad), LL(0x5a755aea2fb4b05a), LL(0x8336836cb51bef83), LL(0x33cc3385ff66b633), - LL(0x6391633ff2c65c63), LL(0x020802100a041202), LL(0xaa92aa39384993aa), LL(0x71d971afa8e2de71), - LL(0xc807c80ecf8dc6c8), LL(0x196419c87d32d119), LL(0x4939497270923b49), LL(0xd943d9869aaf5fd9), - LL(0xf2eff2c31df931f2), LL(0xe3abe34b48dba8e3), LL(0x5b715be22ab6b95b), LL(0x881a8834920dbc88), - LL(0x9a529aa4c8293e9a), LL(0x2698262dbe4c0b26), LL(0x32c8328dfa64bf32), LL(0xb0fab0e94a7d59b0), - LL(0xe983e91b6acff2e9), LL(0x0f3c0f78331e770f), LL(0xd573d5e6a6b733d5), LL(0x803a8074ba1df480), - LL(0xbec2be997c6127be), LL(0xcd13cd26de87ebcd), LL(0x34d034bde4688934), LL(0x483d487a75903248), - LL(0xffdbffab24e354ff), LL(0x7af57af78ff48d7a), LL(0x907a90f4ea3d6490), LL(0x5f615fc23ebe9d5f), - LL(0x2080201da0403d20), LL(0x68bd6867d5d00f68), LL(0x1a681ad07234ca1a), LL(0xae82ae192c41b7ae), - LL(0xb4eab4c95e757db4), LL(0x544d549a19a8ce54), LL(0x937693ece53b7f93), LL(0x2288220daa442f22), - LL(0x648d6407e9c86364), LL(0xf1e3f1db12ff2af1), LL(0x73d173bfa2e6cc73), LL(0x124812905a248212), - LL(0x401d403a5d807a40), LL(0x0820084028104808), LL(0xc32bc356e89b95c3), LL(0xec97ec337bc5dfec), - LL(0xdb4bdb9690ab4ddb), LL(0xa1bea1611f5fc0a1), LL(0x8d0e8d1c8307918d), LL(0x3df43df5c97ac83d), - LL(0x976697ccf1335b97), LL(0x0000000000000000), LL(0xcf1bcf36d483f9cf), LL(0x2bac2b4587566e2b), - LL(0x76c57697b3ece176), LL(0x82328264b019e682), LL(0xd67fd6fea9b128d6), LL(0x1b6c1bd87736c31b), - LL(0xb5eeb5c15b7774b5), LL(0xaf86af112943beaf), LL(0x6ab56a77dfd41d6a), LL(0x505d50ba0da0ea50), - LL(0x450945124c8a5745), LL(0xf3ebf3cb18fb38f3), LL(0x30c0309df060ad30), LL(0xef9bef2b74c3c4ef), - LL(0x3ffc3fe5c37eda3f), LL(0x554955921caac755), LL(0xa2b2a2791059dba2), LL(0xea8fea0365c9e9ea), - LL(0x6589650fecca6a65), LL(0xbad2bab9686903ba), LL(0x2fbc2f65935e4a2f), LL(0xc027c04ee79d8ec0), - LL(0xde5fdebe81a160de), LL(0x1c701ce06c38fc1c), LL(0xfdd3fdbb2ee746fd), LL(0x4d294d52649a1f4d), - LL(0x927292e4e0397692), LL(0x75c9758fbceafa75), LL(0x061806301e0c3606), LL(0x8a128a249809ae8a), - LL(0xb2f2b2f940794bb2), LL(0xe6bfe66359d185e6), LL(0x0e380e70361c7e0e), LL(0x1f7c1ff8633ee71f), - LL(0x62956237f7c45562), LL(0xd477d4eea3b53ad4), LL(0xa89aa829324d81a8), LL(0x966296c4f4315296), - LL(0xf9c3f99b3aef62f9), LL(0xc533c566f697a3c5), LL(0x25942535b14a1025), LL(0x597959f220b2ab59), - LL(0x842a8454ae15d084), LL(0x72d572b7a7e4c572), LL(0x39e439d5dd72ec39), LL(0x4c2d4c5a6198164c), - LL(0x5e655eca3bbc945e), LL(0x78fd78e785f09f78), LL(0x38e038ddd870e538), LL(0x8c0a8c148605988c), - LL(0xd163d1c6b2bf17d1), LL(0xa5aea5410b57e4a5), LL(0xe2afe2434dd9a1e2), LL(0x6199612ff8c24e61), - LL(0xb3f6b3f1457b42b3), LL(0x21842115a5423421), LL(0x9c4a9c94d625089c), LL(0x1e781ef0663cee1e), - LL(0x4311432252866143), LL(0xc73bc776fc93b1c7), LL(0xfcd7fcb32be54ffc), LL(0x0410042014082404), - LL(0x515951b208a2e351), LL(0x995e99bcc72f2599), LL(0x6da96d4fc4da226d), LL(0x0d340d68391a650d), - LL(0xfacffa8335e979fa), LL(0xdf5bdfb684a369df), LL(0x7ee57ed79bfca97e), LL(0x2490243db4481924), - LL(0x3bec3bc5d776fe3b), LL(0xab96ab313d4b9aab), LL(0xce1fce3ed181f0ce), LL(0x1144118855229911), - LL(0x8f068f0c8903838f), LL(0x4e254e4a6b9c044e), LL(0xb7e6b7d1517366b7), LL(0xeb8beb0b60cbe0eb), - LL(0x3cf03cfdcc78c13c), LL(0x813e817cbf1ffd81), LL(0x946a94d4fe354094), LL(0xf7fbf7eb0cf31cf7), - LL(0xb9deb9a1676f18b9), LL(0x134c13985f268b13), LL(0x2cb02c7d9c58512c), LL(0xd36bd3d6b8bb05d3), - LL(0xe7bbe76b5cd38ce7), LL(0x6ea56e57cbdc396e), LL(0xc437c46ef395aac4), LL(0x030c03180f061b03), - LL(0x5645568a13acdc56), LL(0x440d441a49885e44), LL(0x7fe17fdf9efea07f), LL(0xa99ea921374f88a9), - LL(0x2aa82a4d8254672a), LL(0xbbd6bbb16d6b0abb), LL(0xc123c146e29f87c1), LL(0x535153a202a6f153), - LL(0xdc57dcae8ba572dc), LL(0x0b2c0b582716530b), LL(0x9d4e9d9cd327019d), LL(0x6cad6c47c1d82b6c), - LL(0x31c43195f562a431), LL(0x74cd7487b9e8f374), LL(0xf6fff6e309f115f6), LL(0x4605460a438c4c46), - LL(0xac8aac092645a5ac), LL(0x891e893c970fb589), LL(0x145014a04428b414), LL(0xe1a3e15b42dfbae1), - LL(0x165816b04e2ca616), LL(0x3ae83acdd274f73a), LL(0x69b9696fd0d20669), LL(0x092409482d124109), - LL(0x70dd70a7ade0d770), LL(0xb6e2b6d954716fb6), LL(0xd067d0ceb7bd1ed0), LL(0xed93ed3b7ec7d6ed), - LL(0xcc17cc2edb85e2cc), LL(0x4215422a57846842), LL(0x985a98b4c22d2c98), LL(0xa4aaa4490e55eda4), - LL(0x28a0285d88507528), LL(0x5c6d5cda31b8865c), LL(0xf8c7f8933fed6bf8), LL(0x86228644a411c286), -}; - -#ifdef OBSOLETE -static const uint64_t C0[256] = { - LL(0x1818281878c0d878), LL(0x23236523af0526af), LL(0xc6c657c6f97eb8f9), LL(0xe8e825e86f13fb6f), - LL(0x87879487a14ccba1), LL(0xb8b8d5b862a91162), LL(0x0101030105080905), LL(0x4f4fd14f6e420d6e), - LL(0x36365a36eead9bee), LL(0xa6a6f7a60459ff04), LL(0xd2d26bd2bdde0cbd), LL(0xf5f502f506fb0e06), - LL(0x79798b7980ef9680), LL(0x6f6fb16fce5f30ce), LL(0x9191ae91effc6def), LL(0x5252f65207aaf807), - LL(0x6060a060fd2747fd), LL(0xbcbcd9bc76893576), LL(0x9b9bb09bcdac37cd), LL(0x8e8e8f8e8c048a8c), - LL(0xa3a3f8a31571d215), LL(0x0c0c140c3c606c3c), LL(0x7b7b8d7b8aff848a), LL(0x35355f35e1b580e1), - LL(0x1d1d271d69e8f569), LL(0xe0e03de04753b347), LL(0xd7d764d7acf621ac), LL(0xc2c25bc2ed5e9ced), - LL(0x2e2e722e966d4396), LL(0x4b4bdd4b7a62297a), LL(0xfefe1ffe21a35d21), LL(0x5757f9571682d516), - LL(0x15153f1541a8bd41), LL(0x77779977b69fe8b6), LL(0x37375937eba592eb), LL(0xe5e532e5567b9e56), - LL(0x9f9fbc9fd98c13d9), LL(0xf0f00df017d32317), LL(0x4a4ade4a7f6a207f), LL(0xdada73da959e4495), - LL(0x5858e85825faa225), LL(0xc9c946c9ca06cfca), LL(0x29297b298d557c8d), LL(0x0a0a1e0a22505a22), - LL(0xb1b1ceb14fe1504f), LL(0xa0a0fda01a69c91a), LL(0x6b6bbd6bda7f14da), LL(0x85859285ab5cd9ab), - LL(0xbdbddabd73813c73), LL(0x5d5de75d34d28f34), LL(0x1010301050809050), LL(0xf4f401f403f30703), - LL(0xcbcb40cbc016ddc0), LL(0x3e3e423ec6edd3c6), LL(0x05050f0511282d11), LL(0x6767a967e61f78e6), - LL(0xe4e431e453739753), LL(0x27276927bb2502bb), LL(0x4141c34158327358), LL(0x8b8b808b9d2ca79d), - LL(0xa7a7f4a70151f601), LL(0x7d7d877d94cfb294), LL(0x9595a295fbdc49fb), LL(0xd8d875d89f8e569f), - LL(0xfbfb10fb308b7030), LL(0xeeee2fee7123cd71), LL(0x7c7c847c91c7bb91), LL(0x6666aa66e31771e3), - LL(0xdddd7add8ea67b8e), LL(0x171739174bb8af4b), LL(0x4747c94746024546), LL(0x9e9ebf9edc841adc), - LL(0xcaca43cac51ed4c5), LL(0x2d2d772d99755899), LL(0xbfbfdcbf79912e79), LL(0x070709071b383f1b), - LL(0xadadeaad2301ac23), LL(0x5a5aee5a2feab02f), LL(0x83839883b56cefb5), LL(0x33335533ff85b6ff), - LL(0x6363a563f23f5cf2), LL(0x020206020a10120a), LL(0xaaaae3aa38399338), LL(0x71719371a8afdea8), - LL(0xc8c845c8cf0ec6cf), LL(0x19192b197dc8d17d), LL(0x4949db4970723b70), LL(0xd9d976d99a865f9a), - LL(0xf2f20bf21dc3311d), LL(0xe3e338e3484ba848), LL(0x5b5bed5b2ae2b92a), LL(0x888885889234bc92), - LL(0x9a9ab39ac8a43ec8), LL(0x26266a26be2d0bbe), LL(0x32325632fa8dbffa), LL(0xb0b0cdb04ae9594a), - LL(0xe9e926e96a1bf26a), LL(0x0f0f110f33787733), LL(0xd5d562d5a6e633a6), LL(0x80809d80ba74f4ba), - LL(0xbebedfbe7c99277c), LL(0xcdcd4acdde26ebde), LL(0x34345c34e4bd89e4), LL(0x4848d848757a3275), - LL(0xffff1cff24ab5424), LL(0x7a7a8e7a8ff78d8f), LL(0x9090ad90eaf464ea), LL(0x5f5fe15f3ec29d3e), - LL(0x20206020a01d3da0), LL(0x6868b868d5670fd5), LL(0x1a1a2e1a72d0ca72), LL(0xaeaeefae2c19b72c), - LL(0xb4b4c1b45ec97d5e), LL(0x5454fc54199ace19), LL(0x9393a893e5ec7fe5), LL(0x22226622aa0d2faa), - LL(0x6464ac64e90763e9), LL(0xf1f10ef112db2a12), LL(0x73739573a2bfcca2), LL(0x121236125a90825a), - LL(0x4040c0405d3a7a5d), LL(0x0808180828404828), LL(0xc3c358c3e85695e8), LL(0xecec29ec7b33df7b), - LL(0xdbdb70db90964d90), LL(0xa1a1fea11f61c01f), LL(0x8d8d8a8d831c9183), LL(0x3d3d473dc9f5c8c9), - LL(0x9797a497f1cc5bf1), LL(0x0000000000000000), LL(0xcfcf4ccfd436f9d4), LL(0x2b2b7d2b87456e87), - LL(0x76769a76b397e1b3), LL(0x82829b82b064e6b0), LL(0xd6d667d6a9fe28a9), LL(0x1b1b2d1b77d8c377), - LL(0xb5b5c2b55bc1745b), LL(0xafafecaf2911be29), LL(0x6a6abe6adf771ddf), LL(0x5050f0500dbaea0d), - LL(0x4545cf454c12574c), LL(0xf3f308f318cb3818), LL(0x30305030f09dadf0), LL(0xefef2cef742bc474), - LL(0x3f3f413fc3e5dac3), LL(0x5555ff551c92c71c), LL(0xa2a2fba21079db10), LL(0xeaea23ea6503e965), - LL(0x6565af65ec0f6aec), LL(0xbabad3ba68b90368), LL(0x2f2f712f93654a93), LL(0xc0c05dc0e74e8ee7), - LL(0xdede7fde81be6081), LL(0x1c1c241c6ce0fc6c), LL(0xfdfd1afd2ebb462e), LL(0x4d4dd74d64521f64), - LL(0x9292ab92e0e476e0), LL(0x75759f75bc8ffabc), LL(0x06060a061e30361e), LL(0x8a8a838a9824ae98), - LL(0xb2b2cbb240f94b40), LL(0xe6e637e659638559), LL(0x0e0e120e36707e36), LL(0x1f1f211f63f8e763), - LL(0x6262a662f73755f7), LL(0xd4d461d4a3ee3aa3), LL(0xa8a8e5a832298132), LL(0x9696a796f4c452f4), - LL(0xf9f916f93a9b623a), LL(0xc5c552c5f666a3f6), LL(0x25256f25b13510b1), LL(0x5959eb5920f2ab20), - LL(0x84849184ae54d0ae), LL(0x72729672a7b7c5a7), LL(0x39394b39ddd5ecdd), LL(0x4c4cd44c615a1661), - LL(0x5e5ee25e3bca943b), LL(0x7878887885e79f85), LL(0x38384838d8dde5d8), LL(0x8c8c898c86149886), - LL(0xd1d16ed1b2c617b2), LL(0xa5a5f2a50b41e40b), LL(0xe2e23be24d43a14d), LL(0x6161a361f82f4ef8), - LL(0xb3b3c8b345f14245), LL(0x21216321a51534a5), LL(0x9c9cb99cd69408d6), LL(0x1e1e221e66f0ee66), - LL(0x4343c54352226152), LL(0xc7c754c7fc76b1fc), LL(0xfcfc19fc2bb34f2b), LL(0x04040c0414202414), - LL(0x5151f35108b2e308), LL(0x9999b699c7bc25c7), LL(0x6d6db76dc44f22c4), LL(0x0d0d170d39686539), - LL(0xfafa13fa35837935), LL(0xdfdf7cdf84b66984), LL(0x7e7e827e9bd7a99b), LL(0x24246c24b43d19b4), - LL(0x3b3b4d3bd7c5fed7), LL(0xababe0ab3d319a3d), LL(0xcece4fced13ef0d1), LL(0x1111331155889955), - LL(0x8f8f8c8f890c8389), LL(0x4e4ed24e6b4a046b), LL(0xb7b7c4b751d16651), LL(0xebeb20eb600be060), - LL(0x3c3c443cccfdc1cc), LL(0x81819e81bf7cfdbf), LL(0x9494a194fed440fe), LL(0xf7f704f70ceb1c0c), - LL(0xb9b9d6b967a11867), LL(0x131335135f988b5f), LL(0x2c2c742c9c7d519c), LL(0xd3d368d3b8d605b8), - LL(0xe7e734e75c6b8c5c), LL(0x6e6eb26ecb5739cb), LL(0xc4c451c4f36eaaf3), LL(0x030305030f181b0f), - LL(0x5656fa56138adc13), LL(0x4444cc44491a5e49), LL(0x7f7f817f9edfa09e), LL(0xa9a9e6a937218837), - LL(0x2a2a7e2a824d6782), LL(0xbbbbd0bb6db10a6d), LL(0xc1c15ec1e24687e2), LL(0x5353f55302a2f102), - LL(0xdcdc79dc8bae728b), LL(0x0b0b1d0b27585327), LL(0x9d9dba9dd39c01d3), LL(0x6c6cb46cc1472bc1), - LL(0x31315331f595a4f5), LL(0x74749c74b987f3b9), LL(0xf6f607f609e31509), LL(0x4646ca46430a4c43), - LL(0xacace9ac2609a526), LL(0x89898689973cb597), LL(0x14143c1444a0b444), LL(0xe1e13ee1425bba42), - LL(0x16163a164eb0a64e), LL(0x3a3a4e3ad2cdf7d2), LL(0x6969bb69d06f06d0), LL(0x09091b092d48412d), - LL(0x70709070ada7d7ad), LL(0xb6b6c7b654d96f54), LL(0xd0d06dd0b7ce1eb7), LL(0xeded2aed7e3bd67e), - LL(0xcccc49ccdb2ee2db), LL(0x4242c642572a6857), LL(0x9898b598c2b42cc2), LL(0xa4a4f1a40e49ed0e), - LL(0x28287828885d7588), LL(0x5c5ce45c31da8631), LL(0xf8f815f83f936b3f), LL(0x86869786a444c2a4), -}; - -static const uint64_t C1[256] = { - LL(0x781818281878c0d8), LL(0xaf23236523af0526), LL(0xf9c6c657c6f97eb8), LL(0x6fe8e825e86f13fb), - LL(0xa187879487a14ccb), LL(0x62b8b8d5b862a911), LL(0x0501010301050809), LL(0x6e4f4fd14f6e420d), - LL(0xee36365a36eead9b), LL(0x04a6a6f7a60459ff), LL(0xbdd2d26bd2bdde0c), LL(0x06f5f502f506fb0e), - LL(0x8079798b7980ef96), LL(0xce6f6fb16fce5f30), LL(0xef9191ae91effc6d), LL(0x075252f65207aaf8), - LL(0xfd6060a060fd2747), LL(0x76bcbcd9bc768935), LL(0xcd9b9bb09bcdac37), LL(0x8c8e8e8f8e8c048a), - LL(0x15a3a3f8a31571d2), LL(0x3c0c0c140c3c606c), LL(0x8a7b7b8d7b8aff84), LL(0xe135355f35e1b580), - LL(0x691d1d271d69e8f5), LL(0x47e0e03de04753b3), LL(0xacd7d764d7acf621), LL(0xedc2c25bc2ed5e9c), - LL(0x962e2e722e966d43), LL(0x7a4b4bdd4b7a6229), LL(0x21fefe1ffe21a35d), LL(0x165757f9571682d5), - LL(0x4115153f1541a8bd), LL(0xb677779977b69fe8), LL(0xeb37375937eba592), LL(0x56e5e532e5567b9e), - LL(0xd99f9fbc9fd98c13), LL(0x17f0f00df017d323), LL(0x7f4a4ade4a7f6a20), LL(0x95dada73da959e44), - LL(0x255858e85825faa2), LL(0xcac9c946c9ca06cf), LL(0x8d29297b298d557c), LL(0x220a0a1e0a22505a), - LL(0x4fb1b1ceb14fe150), LL(0x1aa0a0fda01a69c9), LL(0xda6b6bbd6bda7f14), LL(0xab85859285ab5cd9), - LL(0x73bdbddabd73813c), LL(0x345d5de75d34d28f), LL(0x5010103010508090), LL(0x03f4f401f403f307), - LL(0xc0cbcb40cbc016dd), LL(0xc63e3e423ec6edd3), LL(0x1105050f0511282d), LL(0xe66767a967e61f78), - LL(0x53e4e431e4537397), LL(0xbb27276927bb2502), LL(0x584141c341583273), LL(0x9d8b8b808b9d2ca7), - LL(0x01a7a7f4a70151f6), LL(0x947d7d877d94cfb2), LL(0xfb9595a295fbdc49), LL(0x9fd8d875d89f8e56), - LL(0x30fbfb10fb308b70), LL(0x71eeee2fee7123cd), LL(0x917c7c847c91c7bb), LL(0xe36666aa66e31771), - LL(0x8edddd7add8ea67b), LL(0x4b171739174bb8af), LL(0x464747c947460245), LL(0xdc9e9ebf9edc841a), - LL(0xc5caca43cac51ed4), LL(0x992d2d772d997558), LL(0x79bfbfdcbf79912e), LL(0x1b070709071b383f), - LL(0x23adadeaad2301ac), LL(0x2f5a5aee5a2feab0), LL(0xb583839883b56cef), LL(0xff33335533ff85b6), - LL(0xf26363a563f23f5c), LL(0x0a020206020a1012), LL(0x38aaaae3aa383993), LL(0xa871719371a8afde), - LL(0xcfc8c845c8cf0ec6), LL(0x7d19192b197dc8d1), LL(0x704949db4970723b), LL(0x9ad9d976d99a865f), - LL(0x1df2f20bf21dc331), LL(0x48e3e338e3484ba8), LL(0x2a5b5bed5b2ae2b9), LL(0x92888885889234bc), - LL(0xc89a9ab39ac8a43e), LL(0xbe26266a26be2d0b), LL(0xfa32325632fa8dbf), LL(0x4ab0b0cdb04ae959), - LL(0x6ae9e926e96a1bf2), LL(0x330f0f110f337877), LL(0xa6d5d562d5a6e633), LL(0xba80809d80ba74f4), - LL(0x7cbebedfbe7c9927), LL(0xdecdcd4acdde26eb), LL(0xe434345c34e4bd89), LL(0x754848d848757a32), - LL(0x24ffff1cff24ab54), LL(0x8f7a7a8e7a8ff78d), LL(0xea9090ad90eaf464), LL(0x3e5f5fe15f3ec29d), - LL(0xa020206020a01d3d), LL(0xd56868b868d5670f), LL(0x721a1a2e1a72d0ca), LL(0x2caeaeefae2c19b7), - LL(0x5eb4b4c1b45ec97d), LL(0x195454fc54199ace), LL(0xe59393a893e5ec7f), LL(0xaa22226622aa0d2f), - LL(0xe96464ac64e90763), LL(0x12f1f10ef112db2a), LL(0xa273739573a2bfcc), LL(0x5a121236125a9082), - LL(0x5d4040c0405d3a7a), LL(0x2808081808284048), LL(0xe8c3c358c3e85695), LL(0x7becec29ec7b33df), - LL(0x90dbdb70db90964d), LL(0x1fa1a1fea11f61c0), LL(0x838d8d8a8d831c91), LL(0xc93d3d473dc9f5c8), - LL(0xf19797a497f1cc5b), LL(0x0000000000000000), LL(0xd4cfcf4ccfd436f9), LL(0x872b2b7d2b87456e), - LL(0xb376769a76b397e1), LL(0xb082829b82b064e6), LL(0xa9d6d667d6a9fe28), LL(0x771b1b2d1b77d8c3), - LL(0x5bb5b5c2b55bc174), LL(0x29afafecaf2911be), LL(0xdf6a6abe6adf771d), LL(0x0d5050f0500dbaea), - LL(0x4c4545cf454c1257), LL(0x18f3f308f318cb38), LL(0xf030305030f09dad), LL(0x74efef2cef742bc4), - LL(0xc33f3f413fc3e5da), LL(0x1c5555ff551c92c7), LL(0x10a2a2fba21079db), LL(0x65eaea23ea6503e9), - LL(0xec6565af65ec0f6a), LL(0x68babad3ba68b903), LL(0x932f2f712f93654a), LL(0xe7c0c05dc0e74e8e), - LL(0x81dede7fde81be60), LL(0x6c1c1c241c6ce0fc), LL(0x2efdfd1afd2ebb46), LL(0x644d4dd74d64521f), - LL(0xe09292ab92e0e476), LL(0xbc75759f75bc8ffa), LL(0x1e06060a061e3036), LL(0x988a8a838a9824ae), - LL(0x40b2b2cbb240f94b), LL(0x59e6e637e6596385), LL(0x360e0e120e36707e), LL(0x631f1f211f63f8e7), - LL(0xf76262a662f73755), LL(0xa3d4d461d4a3ee3a), LL(0x32a8a8e5a8322981), LL(0xf49696a796f4c452), - LL(0x3af9f916f93a9b62), LL(0xf6c5c552c5f666a3), LL(0xb125256f25b13510), LL(0x205959eb5920f2ab), - LL(0xae84849184ae54d0), LL(0xa772729672a7b7c5), LL(0xdd39394b39ddd5ec), LL(0x614c4cd44c615a16), - LL(0x3b5e5ee25e3bca94), LL(0x857878887885e79f), LL(0xd838384838d8dde5), LL(0x868c8c898c861498), - LL(0xb2d1d16ed1b2c617), LL(0x0ba5a5f2a50b41e4), LL(0x4de2e23be24d43a1), LL(0xf86161a361f82f4e), - LL(0x45b3b3c8b345f142), LL(0xa521216321a51534), LL(0xd69c9cb99cd69408), LL(0x661e1e221e66f0ee), - LL(0x524343c543522261), LL(0xfcc7c754c7fc76b1), LL(0x2bfcfc19fc2bb34f), LL(0x1404040c04142024), - LL(0x085151f35108b2e3), LL(0xc79999b699c7bc25), LL(0xc46d6db76dc44f22), LL(0x390d0d170d396865), - LL(0x35fafa13fa358379), LL(0x84dfdf7cdf84b669), LL(0x9b7e7e827e9bd7a9), LL(0xb424246c24b43d19), - LL(0xd73b3b4d3bd7c5fe), LL(0x3dababe0ab3d319a), LL(0xd1cece4fced13ef0), LL(0x5511113311558899), - LL(0x898f8f8c8f890c83), LL(0x6b4e4ed24e6b4a04), LL(0x51b7b7c4b751d166), LL(0x60ebeb20eb600be0), - LL(0xcc3c3c443cccfdc1), LL(0xbf81819e81bf7cfd), LL(0xfe9494a194fed440), LL(0x0cf7f704f70ceb1c), - LL(0x67b9b9d6b967a118), LL(0x5f131335135f988b), LL(0x9c2c2c742c9c7d51), LL(0xb8d3d368d3b8d605), - LL(0x5ce7e734e75c6b8c), LL(0xcb6e6eb26ecb5739), LL(0xf3c4c451c4f36eaa), LL(0x0f030305030f181b), - LL(0x135656fa56138adc), LL(0x494444cc44491a5e), LL(0x9e7f7f817f9edfa0), LL(0x37a9a9e6a9372188), - LL(0x822a2a7e2a824d67), LL(0x6dbbbbd0bb6db10a), LL(0xe2c1c15ec1e24687), LL(0x025353f55302a2f1), - LL(0x8bdcdc79dc8bae72), LL(0x270b0b1d0b275853), LL(0xd39d9dba9dd39c01), LL(0xc16c6cb46cc1472b), - LL(0xf531315331f595a4), LL(0xb974749c74b987f3), LL(0x09f6f607f609e315), LL(0x434646ca46430a4c), - LL(0x26acace9ac2609a5), LL(0x9789898689973cb5), LL(0x4414143c1444a0b4), LL(0x42e1e13ee1425bba), - LL(0x4e16163a164eb0a6), LL(0xd23a3a4e3ad2cdf7), LL(0xd06969bb69d06f06), LL(0x2d09091b092d4841), - LL(0xad70709070ada7d7), LL(0x54b6b6c7b654d96f), LL(0xb7d0d06dd0b7ce1e), LL(0x7eeded2aed7e3bd6), - LL(0xdbcccc49ccdb2ee2), LL(0x574242c642572a68), LL(0xc29898b598c2b42c), LL(0x0ea4a4f1a40e49ed), - LL(0x8828287828885d75), LL(0x315c5ce45c31da86), LL(0x3ff8f815f83f936b), LL(0xa486869786a444c2), -}; - -static const uint64_t C2[256] = { - LL(0xd8781818281878c0), LL(0x26af23236523af05), LL(0xb8f9c6c657c6f97e), LL(0xfb6fe8e825e86f13), - LL(0xcba187879487a14c), LL(0x1162b8b8d5b862a9), LL(0x0905010103010508), LL(0x0d6e4f4fd14f6e42), - LL(0x9bee36365a36eead), LL(0xff04a6a6f7a60459), LL(0x0cbdd2d26bd2bdde), LL(0x0e06f5f502f506fb), - LL(0x968079798b7980ef), LL(0x30ce6f6fb16fce5f), LL(0x6def9191ae91effc), LL(0xf8075252f65207aa), - LL(0x47fd6060a060fd27), LL(0x3576bcbcd9bc7689), LL(0x37cd9b9bb09bcdac), LL(0x8a8c8e8e8f8e8c04), - LL(0xd215a3a3f8a31571), LL(0x6c3c0c0c140c3c60), LL(0x848a7b7b8d7b8aff), LL(0x80e135355f35e1b5), - LL(0xf5691d1d271d69e8), LL(0xb347e0e03de04753), LL(0x21acd7d764d7acf6), LL(0x9cedc2c25bc2ed5e), - LL(0x43962e2e722e966d), LL(0x297a4b4bdd4b7a62), LL(0x5d21fefe1ffe21a3), LL(0xd5165757f9571682), - LL(0xbd4115153f1541a8), LL(0xe8b677779977b69f), LL(0x92eb37375937eba5), LL(0x9e56e5e532e5567b), - LL(0x13d99f9fbc9fd98c), LL(0x2317f0f00df017d3), LL(0x207f4a4ade4a7f6a), LL(0x4495dada73da959e), - LL(0xa2255858e85825fa), LL(0xcfcac9c946c9ca06), LL(0x7c8d29297b298d55), LL(0x5a220a0a1e0a2250), - LL(0x504fb1b1ceb14fe1), LL(0xc91aa0a0fda01a69), LL(0x14da6b6bbd6bda7f), LL(0xd9ab85859285ab5c), - LL(0x3c73bdbddabd7381), LL(0x8f345d5de75d34d2), LL(0x9050101030105080), LL(0x0703f4f401f403f3), - LL(0xddc0cbcb40cbc016), LL(0xd3c63e3e423ec6ed), LL(0x2d1105050f051128), LL(0x78e66767a967e61f), - LL(0x9753e4e431e45373), LL(0x02bb27276927bb25), LL(0x73584141c3415832), LL(0xa79d8b8b808b9d2c), - LL(0xf601a7a7f4a70151), LL(0xb2947d7d877d94cf), LL(0x49fb9595a295fbdc), LL(0x569fd8d875d89f8e), - LL(0x7030fbfb10fb308b), LL(0xcd71eeee2fee7123), LL(0xbb917c7c847c91c7), LL(0x71e36666aa66e317), - LL(0x7b8edddd7add8ea6), LL(0xaf4b171739174bb8), LL(0x45464747c9474602), LL(0x1adc9e9ebf9edc84), - LL(0xd4c5caca43cac51e), LL(0x58992d2d772d9975), LL(0x2e79bfbfdcbf7991), LL(0x3f1b070709071b38), - LL(0xac23adadeaad2301), LL(0xb02f5a5aee5a2fea), LL(0xefb583839883b56c), LL(0xb6ff33335533ff85), - LL(0x5cf26363a563f23f), LL(0x120a020206020a10), LL(0x9338aaaae3aa3839), LL(0xdea871719371a8af), - LL(0xc6cfc8c845c8cf0e), LL(0xd17d19192b197dc8), LL(0x3b704949db497072), LL(0x5f9ad9d976d99a86), - LL(0x311df2f20bf21dc3), LL(0xa848e3e338e3484b), LL(0xb92a5b5bed5b2ae2), LL(0xbc92888885889234), - LL(0x3ec89a9ab39ac8a4), LL(0x0bbe26266a26be2d), LL(0xbffa32325632fa8d), LL(0x594ab0b0cdb04ae9), - LL(0xf26ae9e926e96a1b), LL(0x77330f0f110f3378), LL(0x33a6d5d562d5a6e6), LL(0xf4ba80809d80ba74), - LL(0x277cbebedfbe7c99), LL(0xebdecdcd4acdde26), LL(0x89e434345c34e4bd), LL(0x32754848d848757a), - LL(0x5424ffff1cff24ab), LL(0x8d8f7a7a8e7a8ff7), LL(0x64ea9090ad90eaf4), LL(0x9d3e5f5fe15f3ec2), - LL(0x3da020206020a01d), LL(0x0fd56868b868d567), LL(0xca721a1a2e1a72d0), LL(0xb72caeaeefae2c19), - LL(0x7d5eb4b4c1b45ec9), LL(0xce195454fc54199a), LL(0x7fe59393a893e5ec), LL(0x2faa22226622aa0d), - LL(0x63e96464ac64e907), LL(0x2a12f1f10ef112db), LL(0xcca273739573a2bf), LL(0x825a121236125a90), - LL(0x7a5d4040c0405d3a), LL(0x4828080818082840), LL(0x95e8c3c358c3e856), LL(0xdf7becec29ec7b33), - LL(0x4d90dbdb70db9096), LL(0xc01fa1a1fea11f61), LL(0x91838d8d8a8d831c), LL(0xc8c93d3d473dc9f5), - LL(0x5bf19797a497f1cc), LL(0x0000000000000000), LL(0xf9d4cfcf4ccfd436), LL(0x6e872b2b7d2b8745), - LL(0xe1b376769a76b397), LL(0xe6b082829b82b064), LL(0x28a9d6d667d6a9fe), LL(0xc3771b1b2d1b77d8), - LL(0x745bb5b5c2b55bc1), LL(0xbe29afafecaf2911), LL(0x1ddf6a6abe6adf77), LL(0xea0d5050f0500dba), - LL(0x574c4545cf454c12), LL(0x3818f3f308f318cb), LL(0xadf030305030f09d), LL(0xc474efef2cef742b), - LL(0xdac33f3f413fc3e5), LL(0xc71c5555ff551c92), LL(0xdb10a2a2fba21079), LL(0xe965eaea23ea6503), - LL(0x6aec6565af65ec0f), LL(0x0368babad3ba68b9), LL(0x4a932f2f712f9365), LL(0x8ee7c0c05dc0e74e), - LL(0x6081dede7fde81be), LL(0xfc6c1c1c241c6ce0), LL(0x462efdfd1afd2ebb), LL(0x1f644d4dd74d6452), - LL(0x76e09292ab92e0e4), LL(0xfabc75759f75bc8f), LL(0x361e06060a061e30), LL(0xae988a8a838a9824), - LL(0x4b40b2b2cbb240f9), LL(0x8559e6e637e65963), LL(0x7e360e0e120e3670), LL(0xe7631f1f211f63f8), - LL(0x55f76262a662f737), LL(0x3aa3d4d461d4a3ee), LL(0x8132a8a8e5a83229), LL(0x52f49696a796f4c4), - LL(0x623af9f916f93a9b), LL(0xa3f6c5c552c5f666), LL(0x10b125256f25b135), LL(0xab205959eb5920f2), - LL(0xd0ae84849184ae54), LL(0xc5a772729672a7b7), LL(0xecdd39394b39ddd5), LL(0x16614c4cd44c615a), - LL(0x943b5e5ee25e3bca), LL(0x9f857878887885e7), LL(0xe5d838384838d8dd), LL(0x98868c8c898c8614), - LL(0x17b2d1d16ed1b2c6), LL(0xe40ba5a5f2a50b41), LL(0xa14de2e23be24d43), LL(0x4ef86161a361f82f), - LL(0x4245b3b3c8b345f1), LL(0x34a521216321a515), LL(0x08d69c9cb99cd694), LL(0xee661e1e221e66f0), - LL(0x61524343c5435222), LL(0xb1fcc7c754c7fc76), LL(0x4f2bfcfc19fc2bb3), LL(0x241404040c041420), - LL(0xe3085151f35108b2), LL(0x25c79999b699c7bc), LL(0x22c46d6db76dc44f), LL(0x65390d0d170d3968), - LL(0x7935fafa13fa3583), LL(0x6984dfdf7cdf84b6), LL(0xa99b7e7e827e9bd7), LL(0x19b424246c24b43d), - LL(0xfed73b3b4d3bd7c5), LL(0x9a3dababe0ab3d31), LL(0xf0d1cece4fced13e), LL(0x9955111133115588), - LL(0x83898f8f8c8f890c), LL(0x046b4e4ed24e6b4a), LL(0x6651b7b7c4b751d1), LL(0xe060ebeb20eb600b), - LL(0xc1cc3c3c443cccfd), LL(0xfdbf81819e81bf7c), LL(0x40fe9494a194fed4), LL(0x1c0cf7f704f70ceb), - LL(0x1867b9b9d6b967a1), LL(0x8b5f131335135f98), LL(0x519c2c2c742c9c7d), LL(0x05b8d3d368d3b8d6), - LL(0x8c5ce7e734e75c6b), LL(0x39cb6e6eb26ecb57), LL(0xaaf3c4c451c4f36e), LL(0x1b0f030305030f18), - LL(0xdc135656fa56138a), LL(0x5e494444cc44491a), LL(0xa09e7f7f817f9edf), LL(0x8837a9a9e6a93721), - LL(0x67822a2a7e2a824d), LL(0x0a6dbbbbd0bb6db1), LL(0x87e2c1c15ec1e246), LL(0xf1025353f55302a2), - LL(0x728bdcdc79dc8bae), LL(0x53270b0b1d0b2758), LL(0x01d39d9dba9dd39c), LL(0x2bc16c6cb46cc147), - LL(0xa4f531315331f595), LL(0xf3b974749c74b987), LL(0x1509f6f607f609e3), LL(0x4c434646ca46430a), - LL(0xa526acace9ac2609), LL(0xb59789898689973c), LL(0xb44414143c1444a0), LL(0xba42e1e13ee1425b), - LL(0xa64e16163a164eb0), LL(0xf7d23a3a4e3ad2cd), LL(0x06d06969bb69d06f), LL(0x412d09091b092d48), - LL(0xd7ad70709070ada7), LL(0x6f54b6b6c7b654d9), LL(0x1eb7d0d06dd0b7ce), LL(0xd67eeded2aed7e3b), - LL(0xe2dbcccc49ccdb2e), LL(0x68574242c642572a), LL(0x2cc29898b598c2b4), LL(0xed0ea4a4f1a40e49), - LL(0x758828287828885d), LL(0x86315c5ce45c31da), LL(0x6b3ff8f815f83f93), LL(0xc2a486869786a444), -}; - -static const uint64_t C3[256] = { - LL(0xc0d8781818281878), LL(0x0526af23236523af), LL(0x7eb8f9c6c657c6f9), LL(0x13fb6fe8e825e86f), - LL(0x4ccba187879487a1), LL(0xa91162b8b8d5b862), LL(0x0809050101030105), LL(0x420d6e4f4fd14f6e), - LL(0xad9bee36365a36ee), LL(0x59ff04a6a6f7a604), LL(0xde0cbdd2d26bd2bd), LL(0xfb0e06f5f502f506), - LL(0xef968079798b7980), LL(0x5f30ce6f6fb16fce), LL(0xfc6def9191ae91ef), LL(0xaaf8075252f65207), - LL(0x2747fd6060a060fd), LL(0x893576bcbcd9bc76), LL(0xac37cd9b9bb09bcd), LL(0x048a8c8e8e8f8e8c), - LL(0x71d215a3a3f8a315), LL(0x606c3c0c0c140c3c), LL(0xff848a7b7b8d7b8a), LL(0xb580e135355f35e1), - LL(0xe8f5691d1d271d69), LL(0x53b347e0e03de047), LL(0xf621acd7d764d7ac), LL(0x5e9cedc2c25bc2ed), - LL(0x6d43962e2e722e96), LL(0x62297a4b4bdd4b7a), LL(0xa35d21fefe1ffe21), LL(0x82d5165757f95716), - LL(0xa8bd4115153f1541), LL(0x9fe8b677779977b6), LL(0xa592eb37375937eb), LL(0x7b9e56e5e532e556), - LL(0x8c13d99f9fbc9fd9), LL(0xd32317f0f00df017), LL(0x6a207f4a4ade4a7f), LL(0x9e4495dada73da95), - LL(0xfaa2255858e85825), LL(0x06cfcac9c946c9ca), LL(0x557c8d29297b298d), LL(0x505a220a0a1e0a22), - LL(0xe1504fb1b1ceb14f), LL(0x69c91aa0a0fda01a), LL(0x7f14da6b6bbd6bda), LL(0x5cd9ab85859285ab), - LL(0x813c73bdbddabd73), LL(0xd28f345d5de75d34), LL(0x8090501010301050), LL(0xf30703f4f401f403), - LL(0x16ddc0cbcb40cbc0), LL(0xedd3c63e3e423ec6), LL(0x282d1105050f0511), LL(0x1f78e66767a967e6), - LL(0x739753e4e431e453), LL(0x2502bb27276927bb), LL(0x3273584141c34158), LL(0x2ca79d8b8b808b9d), - LL(0x51f601a7a7f4a701), LL(0xcfb2947d7d877d94), LL(0xdc49fb9595a295fb), LL(0x8e569fd8d875d89f), - LL(0x8b7030fbfb10fb30), LL(0x23cd71eeee2fee71), LL(0xc7bb917c7c847c91), LL(0x1771e36666aa66e3), - LL(0xa67b8edddd7add8e), LL(0xb8af4b171739174b), LL(0x0245464747c94746), LL(0x841adc9e9ebf9edc), - LL(0x1ed4c5caca43cac5), LL(0x7558992d2d772d99), LL(0x912e79bfbfdcbf79), LL(0x383f1b070709071b), - LL(0x01ac23adadeaad23), LL(0xeab02f5a5aee5a2f), LL(0x6cefb583839883b5), LL(0x85b6ff33335533ff), - LL(0x3f5cf26363a563f2), LL(0x10120a020206020a), LL(0x399338aaaae3aa38), LL(0xafdea871719371a8), - LL(0x0ec6cfc8c845c8cf), LL(0xc8d17d19192b197d), LL(0x723b704949db4970), LL(0x865f9ad9d976d99a), - LL(0xc3311df2f20bf21d), LL(0x4ba848e3e338e348), LL(0xe2b92a5b5bed5b2a), LL(0x34bc928888858892), - LL(0xa43ec89a9ab39ac8), LL(0x2d0bbe26266a26be), LL(0x8dbffa32325632fa), LL(0xe9594ab0b0cdb04a), - LL(0x1bf26ae9e926e96a), LL(0x7877330f0f110f33), LL(0xe633a6d5d562d5a6), LL(0x74f4ba80809d80ba), - LL(0x99277cbebedfbe7c), LL(0x26ebdecdcd4acdde), LL(0xbd89e434345c34e4), LL(0x7a32754848d84875), - LL(0xab5424ffff1cff24), LL(0xf78d8f7a7a8e7a8f), LL(0xf464ea9090ad90ea), LL(0xc29d3e5f5fe15f3e), - LL(0x1d3da020206020a0), LL(0x670fd56868b868d5), LL(0xd0ca721a1a2e1a72), LL(0x19b72caeaeefae2c), - LL(0xc97d5eb4b4c1b45e), LL(0x9ace195454fc5419), LL(0xec7fe59393a893e5), LL(0x0d2faa22226622aa), - LL(0x0763e96464ac64e9), LL(0xdb2a12f1f10ef112), LL(0xbfcca273739573a2), LL(0x90825a121236125a), - LL(0x3a7a5d4040c0405d), LL(0x4048280808180828), LL(0x5695e8c3c358c3e8), LL(0x33df7becec29ec7b), - LL(0x964d90dbdb70db90), LL(0x61c01fa1a1fea11f), LL(0x1c91838d8d8a8d83), LL(0xf5c8c93d3d473dc9), - LL(0xcc5bf19797a497f1), LL(0x0000000000000000), LL(0x36f9d4cfcf4ccfd4), LL(0x456e872b2b7d2b87), - LL(0x97e1b376769a76b3), LL(0x64e6b082829b82b0), LL(0xfe28a9d6d667d6a9), LL(0xd8c3771b1b2d1b77), - LL(0xc1745bb5b5c2b55b), LL(0x11be29afafecaf29), LL(0x771ddf6a6abe6adf), LL(0xbaea0d5050f0500d), - LL(0x12574c4545cf454c), LL(0xcb3818f3f308f318), LL(0x9dadf030305030f0), LL(0x2bc474efef2cef74), - LL(0xe5dac33f3f413fc3), LL(0x92c71c5555ff551c), LL(0x79db10a2a2fba210), LL(0x03e965eaea23ea65), - LL(0x0f6aec6565af65ec), LL(0xb90368babad3ba68), LL(0x654a932f2f712f93), LL(0x4e8ee7c0c05dc0e7), - LL(0xbe6081dede7fde81), LL(0xe0fc6c1c1c241c6c), LL(0xbb462efdfd1afd2e), LL(0x521f644d4dd74d64), - LL(0xe476e09292ab92e0), LL(0x8ffabc75759f75bc), LL(0x30361e06060a061e), LL(0x24ae988a8a838a98), - LL(0xf94b40b2b2cbb240), LL(0x638559e6e637e659), LL(0x707e360e0e120e36), LL(0xf8e7631f1f211f63), - LL(0x3755f76262a662f7), LL(0xee3aa3d4d461d4a3), LL(0x298132a8a8e5a832), LL(0xc452f49696a796f4), - LL(0x9b623af9f916f93a), LL(0x66a3f6c5c552c5f6), LL(0x3510b125256f25b1), LL(0xf2ab205959eb5920), - LL(0x54d0ae84849184ae), LL(0xb7c5a772729672a7), LL(0xd5ecdd39394b39dd), LL(0x5a16614c4cd44c61), - LL(0xca943b5e5ee25e3b), LL(0xe79f857878887885), LL(0xdde5d838384838d8), LL(0x1498868c8c898c86), - LL(0xc617b2d1d16ed1b2), LL(0x41e40ba5a5f2a50b), LL(0x43a14de2e23be24d), LL(0x2f4ef86161a361f8), - LL(0xf14245b3b3c8b345), LL(0x1534a521216321a5), LL(0x9408d69c9cb99cd6), LL(0xf0ee661e1e221e66), - LL(0x2261524343c54352), LL(0x76b1fcc7c754c7fc), LL(0xb34f2bfcfc19fc2b), LL(0x20241404040c0414), - LL(0xb2e3085151f35108), LL(0xbc25c79999b699c7), LL(0x4f22c46d6db76dc4), LL(0x6865390d0d170d39), - LL(0x837935fafa13fa35), LL(0xb66984dfdf7cdf84), LL(0xd7a99b7e7e827e9b), LL(0x3d19b424246c24b4), - LL(0xc5fed73b3b4d3bd7), LL(0x319a3dababe0ab3d), LL(0x3ef0d1cece4fced1), LL(0x8899551111331155), - LL(0x0c83898f8f8c8f89), LL(0x4a046b4e4ed24e6b), LL(0xd16651b7b7c4b751), LL(0x0be060ebeb20eb60), - LL(0xfdc1cc3c3c443ccc), LL(0x7cfdbf81819e81bf), LL(0xd440fe9494a194fe), LL(0xeb1c0cf7f704f70c), - LL(0xa11867b9b9d6b967), LL(0x988b5f131335135f), LL(0x7d519c2c2c742c9c), LL(0xd605b8d3d368d3b8), - LL(0x6b8c5ce7e734e75c), LL(0x5739cb6e6eb26ecb), LL(0x6eaaf3c4c451c4f3), LL(0x181b0f030305030f), - LL(0x8adc135656fa5613), LL(0x1a5e494444cc4449), LL(0xdfa09e7f7f817f9e), LL(0x218837a9a9e6a937), - LL(0x4d67822a2a7e2a82), LL(0xb10a6dbbbbd0bb6d), LL(0x4687e2c1c15ec1e2), LL(0xa2f1025353f55302), - LL(0xae728bdcdc79dc8b), LL(0x5853270b0b1d0b27), LL(0x9c01d39d9dba9dd3), LL(0x472bc16c6cb46cc1), - LL(0x95a4f531315331f5), LL(0x87f3b974749c74b9), LL(0xe31509f6f607f609), LL(0x0a4c434646ca4643), - LL(0x09a526acace9ac26), LL(0x3cb5978989868997), LL(0xa0b44414143c1444), LL(0x5bba42e1e13ee142), - LL(0xb0a64e16163a164e), LL(0xcdf7d23a3a4e3ad2), LL(0x6f06d06969bb69d0), LL(0x48412d09091b092d), - LL(0xa7d7ad70709070ad), LL(0xd96f54b6b6c7b654), LL(0xce1eb7d0d06dd0b7), LL(0x3bd67eeded2aed7e), - LL(0x2ee2dbcccc49ccdb), LL(0x2a68574242c64257), LL(0xb42cc29898b598c2), LL(0x49ed0ea4a4f1a40e), - LL(0x5d75882828782888), LL(0xda86315c5ce45c31), LL(0x936b3ff8f815f83f), LL(0x44c2a486869786a4), -}; - -static const uint64_t C4[256] = { - LL(0x78c0d87818182818), LL(0xaf0526af23236523), LL(0xf97eb8f9c6c657c6), LL(0x6f13fb6fe8e825e8), - LL(0xa14ccba187879487), LL(0x62a91162b8b8d5b8), LL(0x0508090501010301), LL(0x6e420d6e4f4fd14f), - LL(0xeead9bee36365a36), LL(0x0459ff04a6a6f7a6), LL(0xbdde0cbdd2d26bd2), LL(0x06fb0e06f5f502f5), - LL(0x80ef968079798b79), LL(0xce5f30ce6f6fb16f), LL(0xeffc6def9191ae91), LL(0x07aaf8075252f652), - LL(0xfd2747fd6060a060), LL(0x76893576bcbcd9bc), LL(0xcdac37cd9b9bb09b), LL(0x8c048a8c8e8e8f8e), - LL(0x1571d215a3a3f8a3), LL(0x3c606c3c0c0c140c), LL(0x8aff848a7b7b8d7b), LL(0xe1b580e135355f35), - LL(0x69e8f5691d1d271d), LL(0x4753b347e0e03de0), LL(0xacf621acd7d764d7), LL(0xed5e9cedc2c25bc2), - LL(0x966d43962e2e722e), LL(0x7a62297a4b4bdd4b), LL(0x21a35d21fefe1ffe), LL(0x1682d5165757f957), - LL(0x41a8bd4115153f15), LL(0xb69fe8b677779977), LL(0xeba592eb37375937), LL(0x567b9e56e5e532e5), - LL(0xd98c13d99f9fbc9f), LL(0x17d32317f0f00df0), LL(0x7f6a207f4a4ade4a), LL(0x959e4495dada73da), - LL(0x25faa2255858e858), LL(0xca06cfcac9c946c9), LL(0x8d557c8d29297b29), LL(0x22505a220a0a1e0a), - LL(0x4fe1504fb1b1ceb1), LL(0x1a69c91aa0a0fda0), LL(0xda7f14da6b6bbd6b), LL(0xab5cd9ab85859285), - LL(0x73813c73bdbddabd), LL(0x34d28f345d5de75d), LL(0x5080905010103010), LL(0x03f30703f4f401f4), - LL(0xc016ddc0cbcb40cb), LL(0xc6edd3c63e3e423e), LL(0x11282d1105050f05), LL(0xe61f78e66767a967), - LL(0x53739753e4e431e4), LL(0xbb2502bb27276927), LL(0x583273584141c341), LL(0x9d2ca79d8b8b808b), - LL(0x0151f601a7a7f4a7), LL(0x94cfb2947d7d877d), LL(0xfbdc49fb9595a295), LL(0x9f8e569fd8d875d8), - LL(0x308b7030fbfb10fb), LL(0x7123cd71eeee2fee), LL(0x91c7bb917c7c847c), LL(0xe31771e36666aa66), - LL(0x8ea67b8edddd7add), LL(0x4bb8af4b17173917), LL(0x460245464747c947), LL(0xdc841adc9e9ebf9e), - LL(0xc51ed4c5caca43ca), LL(0x997558992d2d772d), LL(0x79912e79bfbfdcbf), LL(0x1b383f1b07070907), - LL(0x2301ac23adadeaad), LL(0x2feab02f5a5aee5a), LL(0xb56cefb583839883), LL(0xff85b6ff33335533), - LL(0xf23f5cf26363a563), LL(0x0a10120a02020602), LL(0x38399338aaaae3aa), LL(0xa8afdea871719371), - LL(0xcf0ec6cfc8c845c8), LL(0x7dc8d17d19192b19), LL(0x70723b704949db49), LL(0x9a865f9ad9d976d9), - LL(0x1dc3311df2f20bf2), LL(0x484ba848e3e338e3), LL(0x2ae2b92a5b5bed5b), LL(0x9234bc9288888588), - LL(0xc8a43ec89a9ab39a), LL(0xbe2d0bbe26266a26), LL(0xfa8dbffa32325632), LL(0x4ae9594ab0b0cdb0), - LL(0x6a1bf26ae9e926e9), LL(0x337877330f0f110f), LL(0xa6e633a6d5d562d5), LL(0xba74f4ba80809d80), - LL(0x7c99277cbebedfbe), LL(0xde26ebdecdcd4acd), LL(0xe4bd89e434345c34), LL(0x757a32754848d848), - LL(0x24ab5424ffff1cff), LL(0x8ff78d8f7a7a8e7a), LL(0xeaf464ea9090ad90), LL(0x3ec29d3e5f5fe15f), - LL(0xa01d3da020206020), LL(0xd5670fd56868b868), LL(0x72d0ca721a1a2e1a), LL(0x2c19b72caeaeefae), - LL(0x5ec97d5eb4b4c1b4), LL(0x199ace195454fc54), LL(0xe5ec7fe59393a893), LL(0xaa0d2faa22226622), - LL(0xe90763e96464ac64), LL(0x12db2a12f1f10ef1), LL(0xa2bfcca273739573), LL(0x5a90825a12123612), - LL(0x5d3a7a5d4040c040), LL(0x2840482808081808), LL(0xe85695e8c3c358c3), LL(0x7b33df7becec29ec), - LL(0x90964d90dbdb70db), LL(0x1f61c01fa1a1fea1), LL(0x831c91838d8d8a8d), LL(0xc9f5c8c93d3d473d), - LL(0xf1cc5bf19797a497), LL(0x0000000000000000), LL(0xd436f9d4cfcf4ccf), LL(0x87456e872b2b7d2b), - LL(0xb397e1b376769a76), LL(0xb064e6b082829b82), LL(0xa9fe28a9d6d667d6), LL(0x77d8c3771b1b2d1b), - LL(0x5bc1745bb5b5c2b5), LL(0x2911be29afafecaf), LL(0xdf771ddf6a6abe6a), LL(0x0dbaea0d5050f050), - LL(0x4c12574c4545cf45), LL(0x18cb3818f3f308f3), LL(0xf09dadf030305030), LL(0x742bc474efef2cef), - LL(0xc3e5dac33f3f413f), LL(0x1c92c71c5555ff55), LL(0x1079db10a2a2fba2), LL(0x6503e965eaea23ea), - LL(0xec0f6aec6565af65), LL(0x68b90368babad3ba), LL(0x93654a932f2f712f), LL(0xe74e8ee7c0c05dc0), - LL(0x81be6081dede7fde), LL(0x6ce0fc6c1c1c241c), LL(0x2ebb462efdfd1afd), LL(0x64521f644d4dd74d), - LL(0xe0e476e09292ab92), LL(0xbc8ffabc75759f75), LL(0x1e30361e06060a06), LL(0x9824ae988a8a838a), - LL(0x40f94b40b2b2cbb2), LL(0x59638559e6e637e6), LL(0x36707e360e0e120e), LL(0x63f8e7631f1f211f), - LL(0xf73755f76262a662), LL(0xa3ee3aa3d4d461d4), LL(0x32298132a8a8e5a8), LL(0xf4c452f49696a796), - LL(0x3a9b623af9f916f9), LL(0xf666a3f6c5c552c5), LL(0xb13510b125256f25), LL(0x20f2ab205959eb59), - LL(0xae54d0ae84849184), LL(0xa7b7c5a772729672), LL(0xddd5ecdd39394b39), LL(0x615a16614c4cd44c), - LL(0x3bca943b5e5ee25e), LL(0x85e79f8578788878), LL(0xd8dde5d838384838), LL(0x861498868c8c898c), - LL(0xb2c617b2d1d16ed1), LL(0x0b41e40ba5a5f2a5), LL(0x4d43a14de2e23be2), LL(0xf82f4ef86161a361), - LL(0x45f14245b3b3c8b3), LL(0xa51534a521216321), LL(0xd69408d69c9cb99c), LL(0x66f0ee661e1e221e), - LL(0x522261524343c543), LL(0xfc76b1fcc7c754c7), LL(0x2bb34f2bfcfc19fc), LL(0x1420241404040c04), - LL(0x08b2e3085151f351), LL(0xc7bc25c79999b699), LL(0xc44f22c46d6db76d), LL(0x396865390d0d170d), - LL(0x35837935fafa13fa), LL(0x84b66984dfdf7cdf), LL(0x9bd7a99b7e7e827e), LL(0xb43d19b424246c24), - LL(0xd7c5fed73b3b4d3b), LL(0x3d319a3dababe0ab), LL(0xd13ef0d1cece4fce), LL(0x5588995511113311), - LL(0x890c83898f8f8c8f), LL(0x6b4a046b4e4ed24e), LL(0x51d16651b7b7c4b7), LL(0x600be060ebeb20eb), - LL(0xccfdc1cc3c3c443c), LL(0xbf7cfdbf81819e81), LL(0xfed440fe9494a194), LL(0x0ceb1c0cf7f704f7), - LL(0x67a11867b9b9d6b9), LL(0x5f988b5f13133513), LL(0x9c7d519c2c2c742c), LL(0xb8d605b8d3d368d3), - LL(0x5c6b8c5ce7e734e7), LL(0xcb5739cb6e6eb26e), LL(0xf36eaaf3c4c451c4), LL(0x0f181b0f03030503), - LL(0x138adc135656fa56), LL(0x491a5e494444cc44), LL(0x9edfa09e7f7f817f), LL(0x37218837a9a9e6a9), - LL(0x824d67822a2a7e2a), LL(0x6db10a6dbbbbd0bb), LL(0xe24687e2c1c15ec1), LL(0x02a2f1025353f553), - LL(0x8bae728bdcdc79dc), LL(0x275853270b0b1d0b), LL(0xd39c01d39d9dba9d), LL(0xc1472bc16c6cb46c), - LL(0xf595a4f531315331), LL(0xb987f3b974749c74), LL(0x09e31509f6f607f6), LL(0x430a4c434646ca46), - LL(0x2609a526acace9ac), LL(0x973cb59789898689), LL(0x44a0b44414143c14), LL(0x425bba42e1e13ee1), - LL(0x4eb0a64e16163a16), LL(0xd2cdf7d23a3a4e3a), LL(0xd06f06d06969bb69), LL(0x2d48412d09091b09), - LL(0xada7d7ad70709070), LL(0x54d96f54b6b6c7b6), LL(0xb7ce1eb7d0d06dd0), LL(0x7e3bd67eeded2aed), - LL(0xdb2ee2dbcccc49cc), LL(0x572a68574242c642), LL(0xc2b42cc29898b598), LL(0x0e49ed0ea4a4f1a4), - LL(0x885d758828287828), LL(0x31da86315c5ce45c), LL(0x3f936b3ff8f815f8), LL(0xa444c2a486869786), -}; - -static const uint64_t C5[256] = { - LL(0x1878c0d878181828), LL(0x23af0526af232365), LL(0xc6f97eb8f9c6c657), LL(0xe86f13fb6fe8e825), - LL(0x87a14ccba1878794), LL(0xb862a91162b8b8d5), LL(0x0105080905010103), LL(0x4f6e420d6e4f4fd1), - LL(0x36eead9bee36365a), LL(0xa60459ff04a6a6f7), LL(0xd2bdde0cbdd2d26b), LL(0xf506fb0e06f5f502), - LL(0x7980ef968079798b), LL(0x6fce5f30ce6f6fb1), LL(0x91effc6def9191ae), LL(0x5207aaf8075252f6), - LL(0x60fd2747fd6060a0), LL(0xbc76893576bcbcd9), LL(0x9bcdac37cd9b9bb0), LL(0x8e8c048a8c8e8e8f), - LL(0xa31571d215a3a3f8), LL(0x0c3c606c3c0c0c14), LL(0x7b8aff848a7b7b8d), LL(0x35e1b580e135355f), - LL(0x1d69e8f5691d1d27), LL(0xe04753b347e0e03d), LL(0xd7acf621acd7d764), LL(0xc2ed5e9cedc2c25b), - LL(0x2e966d43962e2e72), LL(0x4b7a62297a4b4bdd), LL(0xfe21a35d21fefe1f), LL(0x571682d5165757f9), - LL(0x1541a8bd4115153f), LL(0x77b69fe8b6777799), LL(0x37eba592eb373759), LL(0xe5567b9e56e5e532), - LL(0x9fd98c13d99f9fbc), LL(0xf017d32317f0f00d), LL(0x4a7f6a207f4a4ade), LL(0xda959e4495dada73), - LL(0x5825faa2255858e8), LL(0xc9ca06cfcac9c946), LL(0x298d557c8d29297b), LL(0x0a22505a220a0a1e), - LL(0xb14fe1504fb1b1ce), LL(0xa01a69c91aa0a0fd), LL(0x6bda7f14da6b6bbd), LL(0x85ab5cd9ab858592), - LL(0xbd73813c73bdbdda), LL(0x5d34d28f345d5de7), LL(0x1050809050101030), LL(0xf403f30703f4f401), - LL(0xcbc016ddc0cbcb40), LL(0x3ec6edd3c63e3e42), LL(0x0511282d1105050f), LL(0x67e61f78e66767a9), - LL(0xe453739753e4e431), LL(0x27bb2502bb272769), LL(0x41583273584141c3), LL(0x8b9d2ca79d8b8b80), - LL(0xa70151f601a7a7f4), LL(0x7d94cfb2947d7d87), LL(0x95fbdc49fb9595a2), LL(0xd89f8e569fd8d875), - LL(0xfb308b7030fbfb10), LL(0xee7123cd71eeee2f), LL(0x7c91c7bb917c7c84), LL(0x66e31771e36666aa), - LL(0xdd8ea67b8edddd7a), LL(0x174bb8af4b171739), LL(0x47460245464747c9), LL(0x9edc841adc9e9ebf), - LL(0xcac51ed4c5caca43), LL(0x2d997558992d2d77), LL(0xbf79912e79bfbfdc), LL(0x071b383f1b070709), - LL(0xad2301ac23adadea), LL(0x5a2feab02f5a5aee), LL(0x83b56cefb5838398), LL(0x33ff85b6ff333355), - LL(0x63f23f5cf26363a5), LL(0x020a10120a020206), LL(0xaa38399338aaaae3), LL(0x71a8afdea8717193), - LL(0xc8cf0ec6cfc8c845), LL(0x197dc8d17d19192b), LL(0x4970723b704949db), LL(0xd99a865f9ad9d976), - LL(0xf21dc3311df2f20b), LL(0xe3484ba848e3e338), LL(0x5b2ae2b92a5b5bed), LL(0x889234bc92888885), - LL(0x9ac8a43ec89a9ab3), LL(0x26be2d0bbe26266a), LL(0x32fa8dbffa323256), LL(0xb04ae9594ab0b0cd), - LL(0xe96a1bf26ae9e926), LL(0x0f337877330f0f11), LL(0xd5a6e633a6d5d562), LL(0x80ba74f4ba80809d), - LL(0xbe7c99277cbebedf), LL(0xcdde26ebdecdcd4a), LL(0x34e4bd89e434345c), LL(0x48757a32754848d8), - LL(0xff24ab5424ffff1c), LL(0x7a8ff78d8f7a7a8e), LL(0x90eaf464ea9090ad), LL(0x5f3ec29d3e5f5fe1), - LL(0x20a01d3da0202060), LL(0x68d5670fd56868b8), LL(0x1a72d0ca721a1a2e), LL(0xae2c19b72caeaeef), - LL(0xb45ec97d5eb4b4c1), LL(0x54199ace195454fc), LL(0x93e5ec7fe59393a8), LL(0x22aa0d2faa222266), - LL(0x64e90763e96464ac), LL(0xf112db2a12f1f10e), LL(0x73a2bfcca2737395), LL(0x125a90825a121236), - LL(0x405d3a7a5d4040c0), LL(0x0828404828080818), LL(0xc3e85695e8c3c358), LL(0xec7b33df7becec29), - LL(0xdb90964d90dbdb70), LL(0xa11f61c01fa1a1fe), LL(0x8d831c91838d8d8a), LL(0x3dc9f5c8c93d3d47), - LL(0x97f1cc5bf19797a4), LL(0x0000000000000000), LL(0xcfd436f9d4cfcf4c), LL(0x2b87456e872b2b7d), - LL(0x76b397e1b376769a), LL(0x82b064e6b082829b), LL(0xd6a9fe28a9d6d667), LL(0x1b77d8c3771b1b2d), - LL(0xb55bc1745bb5b5c2), LL(0xaf2911be29afafec), LL(0x6adf771ddf6a6abe), LL(0x500dbaea0d5050f0), - LL(0x454c12574c4545cf), LL(0xf318cb3818f3f308), LL(0x30f09dadf0303050), LL(0xef742bc474efef2c), - LL(0x3fc3e5dac33f3f41), LL(0x551c92c71c5555ff), LL(0xa21079db10a2a2fb), LL(0xea6503e965eaea23), - LL(0x65ec0f6aec6565af), LL(0xba68b90368babad3), LL(0x2f93654a932f2f71), LL(0xc0e74e8ee7c0c05d), - LL(0xde81be6081dede7f), LL(0x1c6ce0fc6c1c1c24), LL(0xfd2ebb462efdfd1a), LL(0x4d64521f644d4dd7), - LL(0x92e0e476e09292ab), LL(0x75bc8ffabc75759f), LL(0x061e30361e06060a), LL(0x8a9824ae988a8a83), - LL(0xb240f94b40b2b2cb), LL(0xe659638559e6e637), LL(0x0e36707e360e0e12), LL(0x1f63f8e7631f1f21), - LL(0x62f73755f76262a6), LL(0xd4a3ee3aa3d4d461), LL(0xa832298132a8a8e5), LL(0x96f4c452f49696a7), - LL(0xf93a9b623af9f916), LL(0xc5f666a3f6c5c552), LL(0x25b13510b125256f), LL(0x5920f2ab205959eb), - LL(0x84ae54d0ae848491), LL(0x72a7b7c5a7727296), LL(0x39ddd5ecdd39394b), LL(0x4c615a16614c4cd4), - LL(0x5e3bca943b5e5ee2), LL(0x7885e79f85787888), LL(0x38d8dde5d8383848), LL(0x8c861498868c8c89), - LL(0xd1b2c617b2d1d16e), LL(0xa50b41e40ba5a5f2), LL(0xe24d43a14de2e23b), LL(0x61f82f4ef86161a3), - LL(0xb345f14245b3b3c8), LL(0x21a51534a5212163), LL(0x9cd69408d69c9cb9), LL(0x1e66f0ee661e1e22), - LL(0x43522261524343c5), LL(0xc7fc76b1fcc7c754), LL(0xfc2bb34f2bfcfc19), LL(0x041420241404040c), - LL(0x5108b2e3085151f3), LL(0x99c7bc25c79999b6), LL(0x6dc44f22c46d6db7), LL(0x0d396865390d0d17), - LL(0xfa35837935fafa13), LL(0xdf84b66984dfdf7c), LL(0x7e9bd7a99b7e7e82), LL(0x24b43d19b424246c), - LL(0x3bd7c5fed73b3b4d), LL(0xab3d319a3dababe0), LL(0xced13ef0d1cece4f), LL(0x1155889955111133), - LL(0x8f890c83898f8f8c), LL(0x4e6b4a046b4e4ed2), LL(0xb751d16651b7b7c4), LL(0xeb600be060ebeb20), - LL(0x3cccfdc1cc3c3c44), LL(0x81bf7cfdbf81819e), LL(0x94fed440fe9494a1), LL(0xf70ceb1c0cf7f704), - LL(0xb967a11867b9b9d6), LL(0x135f988b5f131335), LL(0x2c9c7d519c2c2c74), LL(0xd3b8d605b8d3d368), - LL(0xe75c6b8c5ce7e734), LL(0x6ecb5739cb6e6eb2), LL(0xc4f36eaaf3c4c451), LL(0x030f181b0f030305), - LL(0x56138adc135656fa), LL(0x44491a5e494444cc), LL(0x7f9edfa09e7f7f81), LL(0xa937218837a9a9e6), - LL(0x2a824d67822a2a7e), LL(0xbb6db10a6dbbbbd0), LL(0xc1e24687e2c1c15e), LL(0x5302a2f1025353f5), - LL(0xdc8bae728bdcdc79), LL(0x0b275853270b0b1d), LL(0x9dd39c01d39d9dba), LL(0x6cc1472bc16c6cb4), - LL(0x31f595a4f5313153), LL(0x74b987f3b974749c), LL(0xf609e31509f6f607), LL(0x46430a4c434646ca), - LL(0xac2609a526acace9), LL(0x89973cb597898986), LL(0x1444a0b44414143c), LL(0xe1425bba42e1e13e), - LL(0x164eb0a64e16163a), LL(0x3ad2cdf7d23a3a4e), LL(0x69d06f06d06969bb), LL(0x092d48412d09091b), - LL(0x70ada7d7ad707090), LL(0xb654d96f54b6b6c7), LL(0xd0b7ce1eb7d0d06d), LL(0xed7e3bd67eeded2a), - LL(0xccdb2ee2dbcccc49), LL(0x42572a68574242c6), LL(0x98c2b42cc29898b5), LL(0xa40e49ed0ea4a4f1), - LL(0x28885d7588282878), LL(0x5c31da86315c5ce4), LL(0xf83f936b3ff8f815), LL(0x86a444c2a4868697), -}; - -static const uint64_t C6[256] = { - LL(0x281878c0d8781818), LL(0x6523af0526af2323), LL(0x57c6f97eb8f9c6c6), LL(0x25e86f13fb6fe8e8), - LL(0x9487a14ccba18787), LL(0xd5b862a91162b8b8), LL(0x0301050809050101), LL(0xd14f6e420d6e4f4f), - LL(0x5a36eead9bee3636), LL(0xf7a60459ff04a6a6), LL(0x6bd2bdde0cbdd2d2), LL(0x02f506fb0e06f5f5), - LL(0x8b7980ef96807979), LL(0xb16fce5f30ce6f6f), LL(0xae91effc6def9191), LL(0xf65207aaf8075252), - LL(0xa060fd2747fd6060), LL(0xd9bc76893576bcbc), LL(0xb09bcdac37cd9b9b), LL(0x8f8e8c048a8c8e8e), - LL(0xf8a31571d215a3a3), LL(0x140c3c606c3c0c0c), LL(0x8d7b8aff848a7b7b), LL(0x5f35e1b580e13535), - LL(0x271d69e8f5691d1d), LL(0x3de04753b347e0e0), LL(0x64d7acf621acd7d7), LL(0x5bc2ed5e9cedc2c2), - LL(0x722e966d43962e2e), LL(0xdd4b7a62297a4b4b), LL(0x1ffe21a35d21fefe), LL(0xf9571682d5165757), - LL(0x3f1541a8bd411515), LL(0x9977b69fe8b67777), LL(0x5937eba592eb3737), LL(0x32e5567b9e56e5e5), - LL(0xbc9fd98c13d99f9f), LL(0x0df017d32317f0f0), LL(0xde4a7f6a207f4a4a), LL(0x73da959e4495dada), - LL(0xe85825faa2255858), LL(0x46c9ca06cfcac9c9), LL(0x7b298d557c8d2929), LL(0x1e0a22505a220a0a), - LL(0xceb14fe1504fb1b1), LL(0xfda01a69c91aa0a0), LL(0xbd6bda7f14da6b6b), LL(0x9285ab5cd9ab8585), - LL(0xdabd73813c73bdbd), LL(0xe75d34d28f345d5d), LL(0x3010508090501010), LL(0x01f403f30703f4f4), - LL(0x40cbc016ddc0cbcb), LL(0x423ec6edd3c63e3e), LL(0x0f0511282d110505), LL(0xa967e61f78e66767), - LL(0x31e453739753e4e4), LL(0x6927bb2502bb2727), LL(0xc341583273584141), LL(0x808b9d2ca79d8b8b), - LL(0xf4a70151f601a7a7), LL(0x877d94cfb2947d7d), LL(0xa295fbdc49fb9595), LL(0x75d89f8e569fd8d8), - LL(0x10fb308b7030fbfb), LL(0x2fee7123cd71eeee), LL(0x847c91c7bb917c7c), LL(0xaa66e31771e36666), - LL(0x7add8ea67b8edddd), LL(0x39174bb8af4b1717), LL(0xc947460245464747), LL(0xbf9edc841adc9e9e), - LL(0x43cac51ed4c5caca), LL(0x772d997558992d2d), LL(0xdcbf79912e79bfbf), LL(0x09071b383f1b0707), - LL(0xeaad2301ac23adad), LL(0xee5a2feab02f5a5a), LL(0x9883b56cefb58383), LL(0x5533ff85b6ff3333), - LL(0xa563f23f5cf26363), LL(0x06020a10120a0202), LL(0xe3aa38399338aaaa), LL(0x9371a8afdea87171), - LL(0x45c8cf0ec6cfc8c8), LL(0x2b197dc8d17d1919), LL(0xdb4970723b704949), LL(0x76d99a865f9ad9d9), - LL(0x0bf21dc3311df2f2), LL(0x38e3484ba848e3e3), LL(0xed5b2ae2b92a5b5b), LL(0x85889234bc928888), - LL(0xb39ac8a43ec89a9a), LL(0x6a26be2d0bbe2626), LL(0x5632fa8dbffa3232), LL(0xcdb04ae9594ab0b0), - LL(0x26e96a1bf26ae9e9), LL(0x110f337877330f0f), LL(0x62d5a6e633a6d5d5), LL(0x9d80ba74f4ba8080), - LL(0xdfbe7c99277cbebe), LL(0x4acdde26ebdecdcd), LL(0x5c34e4bd89e43434), LL(0xd848757a32754848), - LL(0x1cff24ab5424ffff), LL(0x8e7a8ff78d8f7a7a), LL(0xad90eaf464ea9090), LL(0xe15f3ec29d3e5f5f), - LL(0x6020a01d3da02020), LL(0xb868d5670fd56868), LL(0x2e1a72d0ca721a1a), LL(0xefae2c19b72caeae), - LL(0xc1b45ec97d5eb4b4), LL(0xfc54199ace195454), LL(0xa893e5ec7fe59393), LL(0x6622aa0d2faa2222), - LL(0xac64e90763e96464), LL(0x0ef112db2a12f1f1), LL(0x9573a2bfcca27373), LL(0x36125a90825a1212), - LL(0xc0405d3a7a5d4040), LL(0x1808284048280808), LL(0x58c3e85695e8c3c3), LL(0x29ec7b33df7becec), - LL(0x70db90964d90dbdb), LL(0xfea11f61c01fa1a1), LL(0x8a8d831c91838d8d), LL(0x473dc9f5c8c93d3d), - LL(0xa497f1cc5bf19797), LL(0x0000000000000000), LL(0x4ccfd436f9d4cfcf), LL(0x7d2b87456e872b2b), - LL(0x9a76b397e1b37676), LL(0x9b82b064e6b08282), LL(0x67d6a9fe28a9d6d6), LL(0x2d1b77d8c3771b1b), - LL(0xc2b55bc1745bb5b5), LL(0xecaf2911be29afaf), LL(0xbe6adf771ddf6a6a), LL(0xf0500dbaea0d5050), - LL(0xcf454c12574c4545), LL(0x08f318cb3818f3f3), LL(0x5030f09dadf03030), LL(0x2cef742bc474efef), - LL(0x413fc3e5dac33f3f), LL(0xff551c92c71c5555), LL(0xfba21079db10a2a2), LL(0x23ea6503e965eaea), - LL(0xaf65ec0f6aec6565), LL(0xd3ba68b90368baba), LL(0x712f93654a932f2f), LL(0x5dc0e74e8ee7c0c0), - LL(0x7fde81be6081dede), LL(0x241c6ce0fc6c1c1c), LL(0x1afd2ebb462efdfd), LL(0xd74d64521f644d4d), - LL(0xab92e0e476e09292), LL(0x9f75bc8ffabc7575), LL(0x0a061e30361e0606), LL(0x838a9824ae988a8a), - LL(0xcbb240f94b40b2b2), LL(0x37e659638559e6e6), LL(0x120e36707e360e0e), LL(0x211f63f8e7631f1f), - LL(0xa662f73755f76262), LL(0x61d4a3ee3aa3d4d4), LL(0xe5a832298132a8a8), LL(0xa796f4c452f49696), - LL(0x16f93a9b623af9f9), LL(0x52c5f666a3f6c5c5), LL(0x6f25b13510b12525), LL(0xeb5920f2ab205959), - LL(0x9184ae54d0ae8484), LL(0x9672a7b7c5a77272), LL(0x4b39ddd5ecdd3939), LL(0xd44c615a16614c4c), - LL(0xe25e3bca943b5e5e), LL(0x887885e79f857878), LL(0x4838d8dde5d83838), LL(0x898c861498868c8c), - LL(0x6ed1b2c617b2d1d1), LL(0xf2a50b41e40ba5a5), LL(0x3be24d43a14de2e2), LL(0xa361f82f4ef86161), - LL(0xc8b345f14245b3b3), LL(0x6321a51534a52121), LL(0xb99cd69408d69c9c), LL(0x221e66f0ee661e1e), - LL(0xc543522261524343), LL(0x54c7fc76b1fcc7c7), LL(0x19fc2bb34f2bfcfc), LL(0x0c04142024140404), - LL(0xf35108b2e3085151), LL(0xb699c7bc25c79999), LL(0xb76dc44f22c46d6d), LL(0x170d396865390d0d), - LL(0x13fa35837935fafa), LL(0x7cdf84b66984dfdf), LL(0x827e9bd7a99b7e7e), LL(0x6c24b43d19b42424), - LL(0x4d3bd7c5fed73b3b), LL(0xe0ab3d319a3dabab), LL(0x4fced13ef0d1cece), LL(0x3311558899551111), - LL(0x8c8f890c83898f8f), LL(0xd24e6b4a046b4e4e), LL(0xc4b751d16651b7b7), LL(0x20eb600be060ebeb), - LL(0x443cccfdc1cc3c3c), LL(0x9e81bf7cfdbf8181), LL(0xa194fed440fe9494), LL(0x04f70ceb1c0cf7f7), - LL(0xd6b967a11867b9b9), LL(0x35135f988b5f1313), LL(0x742c9c7d519c2c2c), LL(0x68d3b8d605b8d3d3), - LL(0x34e75c6b8c5ce7e7), LL(0xb26ecb5739cb6e6e), LL(0x51c4f36eaaf3c4c4), LL(0x05030f181b0f0303), - LL(0xfa56138adc135656), LL(0xcc44491a5e494444), LL(0x817f9edfa09e7f7f), LL(0xe6a937218837a9a9), - LL(0x7e2a824d67822a2a), LL(0xd0bb6db10a6dbbbb), LL(0x5ec1e24687e2c1c1), LL(0xf55302a2f1025353), - LL(0x79dc8bae728bdcdc), LL(0x1d0b275853270b0b), LL(0xba9dd39c01d39d9d), LL(0xb46cc1472bc16c6c), - LL(0x5331f595a4f53131), LL(0x9c74b987f3b97474), LL(0x07f609e31509f6f6), LL(0xca46430a4c434646), - LL(0xe9ac2609a526acac), LL(0x8689973cb5978989), LL(0x3c1444a0b4441414), LL(0x3ee1425bba42e1e1), - LL(0x3a164eb0a64e1616), LL(0x4e3ad2cdf7d23a3a), LL(0xbb69d06f06d06969), LL(0x1b092d48412d0909), - LL(0x9070ada7d7ad7070), LL(0xc7b654d96f54b6b6), LL(0x6dd0b7ce1eb7d0d0), LL(0x2aed7e3bd67eeded), - LL(0x49ccdb2ee2dbcccc), LL(0xc642572a68574242), LL(0xb598c2b42cc29898), LL(0xf1a40e49ed0ea4a4), - LL(0x7828885d75882828), LL(0xe45c31da86315c5c), LL(0x15f83f936b3ff8f8), LL(0x9786a444c2a48686), -}; - -static const uint64_t C7[256] = { - LL(0x18281878c0d87818), LL(0x236523af0526af23), LL(0xc657c6f97eb8f9c6), LL(0xe825e86f13fb6fe8), - LL(0x879487a14ccba187), LL(0xb8d5b862a91162b8), LL(0x0103010508090501), LL(0x4fd14f6e420d6e4f), - LL(0x365a36eead9bee36), LL(0xa6f7a60459ff04a6), LL(0xd26bd2bdde0cbdd2), LL(0xf502f506fb0e06f5), - LL(0x798b7980ef968079), LL(0x6fb16fce5f30ce6f), LL(0x91ae91effc6def91), LL(0x52f65207aaf80752), - LL(0x60a060fd2747fd60), LL(0xbcd9bc76893576bc), LL(0x9bb09bcdac37cd9b), LL(0x8e8f8e8c048a8c8e), - LL(0xa3f8a31571d215a3), LL(0x0c140c3c606c3c0c), LL(0x7b8d7b8aff848a7b), LL(0x355f35e1b580e135), - LL(0x1d271d69e8f5691d), LL(0xe03de04753b347e0), LL(0xd764d7acf621acd7), LL(0xc25bc2ed5e9cedc2), - LL(0x2e722e966d43962e), LL(0x4bdd4b7a62297a4b), LL(0xfe1ffe21a35d21fe), LL(0x57f9571682d51657), - LL(0x153f1541a8bd4115), LL(0x779977b69fe8b677), LL(0x375937eba592eb37), LL(0xe532e5567b9e56e5), - LL(0x9fbc9fd98c13d99f), LL(0xf00df017d32317f0), LL(0x4ade4a7f6a207f4a), LL(0xda73da959e4495da), - LL(0x58e85825faa22558), LL(0xc946c9ca06cfcac9), LL(0x297b298d557c8d29), LL(0x0a1e0a22505a220a), - LL(0xb1ceb14fe1504fb1), LL(0xa0fda01a69c91aa0), LL(0x6bbd6bda7f14da6b), LL(0x859285ab5cd9ab85), - LL(0xbddabd73813c73bd), LL(0x5de75d34d28f345d), LL(0x1030105080905010), LL(0xf401f403f30703f4), - LL(0xcb40cbc016ddc0cb), LL(0x3e423ec6edd3c63e), LL(0x050f0511282d1105), LL(0x67a967e61f78e667), - LL(0xe431e453739753e4), LL(0x276927bb2502bb27), LL(0x41c3415832735841), LL(0x8b808b9d2ca79d8b), - LL(0xa7f4a70151f601a7), LL(0x7d877d94cfb2947d), LL(0x95a295fbdc49fb95), LL(0xd875d89f8e569fd8), - LL(0xfb10fb308b7030fb), LL(0xee2fee7123cd71ee), LL(0x7c847c91c7bb917c), LL(0x66aa66e31771e366), - LL(0xdd7add8ea67b8edd), LL(0x1739174bb8af4b17), LL(0x47c9474602454647), LL(0x9ebf9edc841adc9e), - LL(0xca43cac51ed4c5ca), LL(0x2d772d997558992d), LL(0xbfdcbf79912e79bf), LL(0x0709071b383f1b07), - LL(0xadeaad2301ac23ad), LL(0x5aee5a2feab02f5a), LL(0x839883b56cefb583), LL(0x335533ff85b6ff33), - LL(0x63a563f23f5cf263), LL(0x0206020a10120a02), LL(0xaae3aa38399338aa), LL(0x719371a8afdea871), - LL(0xc845c8cf0ec6cfc8), LL(0x192b197dc8d17d19), LL(0x49db4970723b7049), LL(0xd976d99a865f9ad9), - LL(0xf20bf21dc3311df2), LL(0xe338e3484ba848e3), LL(0x5bed5b2ae2b92a5b), LL(0x8885889234bc9288), - LL(0x9ab39ac8a43ec89a), LL(0x266a26be2d0bbe26), LL(0x325632fa8dbffa32), LL(0xb0cdb04ae9594ab0), - LL(0xe926e96a1bf26ae9), LL(0x0f110f337877330f), LL(0xd562d5a6e633a6d5), LL(0x809d80ba74f4ba80), - LL(0xbedfbe7c99277cbe), LL(0xcd4acdde26ebdecd), LL(0x345c34e4bd89e434), LL(0x48d848757a327548), - LL(0xff1cff24ab5424ff), LL(0x7a8e7a8ff78d8f7a), LL(0x90ad90eaf464ea90), LL(0x5fe15f3ec29d3e5f), - LL(0x206020a01d3da020), LL(0x68b868d5670fd568), LL(0x1a2e1a72d0ca721a), LL(0xaeefae2c19b72cae), - LL(0xb4c1b45ec97d5eb4), LL(0x54fc54199ace1954), LL(0x93a893e5ec7fe593), LL(0x226622aa0d2faa22), - LL(0x64ac64e90763e964), LL(0xf10ef112db2a12f1), LL(0x739573a2bfcca273), LL(0x1236125a90825a12), - LL(0x40c0405d3a7a5d40), LL(0x0818082840482808), LL(0xc358c3e85695e8c3), LL(0xec29ec7b33df7bec), - LL(0xdb70db90964d90db), LL(0xa1fea11f61c01fa1), LL(0x8d8a8d831c91838d), LL(0x3d473dc9f5c8c93d), - LL(0x97a497f1cc5bf197), LL(0x0000000000000000), LL(0xcf4ccfd436f9d4cf), LL(0x2b7d2b87456e872b), - LL(0x769a76b397e1b376), LL(0x829b82b064e6b082), LL(0xd667d6a9fe28a9d6), LL(0x1b2d1b77d8c3771b), - LL(0xb5c2b55bc1745bb5), LL(0xafecaf2911be29af), LL(0x6abe6adf771ddf6a), LL(0x50f0500dbaea0d50), - LL(0x45cf454c12574c45), LL(0xf308f318cb3818f3), LL(0x305030f09dadf030), LL(0xef2cef742bc474ef), - LL(0x3f413fc3e5dac33f), LL(0x55ff551c92c71c55), LL(0xa2fba21079db10a2), LL(0xea23ea6503e965ea), - LL(0x65af65ec0f6aec65), LL(0xbad3ba68b90368ba), LL(0x2f712f93654a932f), LL(0xc05dc0e74e8ee7c0), - LL(0xde7fde81be6081de), LL(0x1c241c6ce0fc6c1c), LL(0xfd1afd2ebb462efd), LL(0x4dd74d64521f644d), - LL(0x92ab92e0e476e092), LL(0x759f75bc8ffabc75), LL(0x060a061e30361e06), LL(0x8a838a9824ae988a), - LL(0xb2cbb240f94b40b2), LL(0xe637e659638559e6), LL(0x0e120e36707e360e), LL(0x1f211f63f8e7631f), - LL(0x62a662f73755f762), LL(0xd461d4a3ee3aa3d4), LL(0xa8e5a832298132a8), LL(0x96a796f4c452f496), - LL(0xf916f93a9b623af9), LL(0xc552c5f666a3f6c5), LL(0x256f25b13510b125), LL(0x59eb5920f2ab2059), - LL(0x849184ae54d0ae84), LL(0x729672a7b7c5a772), LL(0x394b39ddd5ecdd39), LL(0x4cd44c615a16614c), - LL(0x5ee25e3bca943b5e), LL(0x78887885e79f8578), LL(0x384838d8dde5d838), LL(0x8c898c861498868c), - LL(0xd16ed1b2c617b2d1), LL(0xa5f2a50b41e40ba5), LL(0xe23be24d43a14de2), LL(0x61a361f82f4ef861), - LL(0xb3c8b345f14245b3), LL(0x216321a51534a521), LL(0x9cb99cd69408d69c), LL(0x1e221e66f0ee661e), - LL(0x43c5435222615243), LL(0xc754c7fc76b1fcc7), LL(0xfc19fc2bb34f2bfc), LL(0x040c041420241404), - LL(0x51f35108b2e30851), LL(0x99b699c7bc25c799), LL(0x6db76dc44f22c46d), LL(0x0d170d396865390d), - LL(0xfa13fa35837935fa), LL(0xdf7cdf84b66984df), LL(0x7e827e9bd7a99b7e), LL(0x246c24b43d19b424), - LL(0x3b4d3bd7c5fed73b), LL(0xabe0ab3d319a3dab), LL(0xce4fced13ef0d1ce), LL(0x1133115588995511), - LL(0x8f8c8f890c83898f), LL(0x4ed24e6b4a046b4e), LL(0xb7c4b751d16651b7), LL(0xeb20eb600be060eb), - LL(0x3c443cccfdc1cc3c), LL(0x819e81bf7cfdbf81), LL(0x94a194fed440fe94), LL(0xf704f70ceb1c0cf7), - LL(0xb9d6b967a11867b9), LL(0x1335135f988b5f13), LL(0x2c742c9c7d519c2c), LL(0xd368d3b8d605b8d3), - LL(0xe734e75c6b8c5ce7), LL(0x6eb26ecb5739cb6e), LL(0xc451c4f36eaaf3c4), LL(0x0305030f181b0f03), - LL(0x56fa56138adc1356), LL(0x44cc44491a5e4944), LL(0x7f817f9edfa09e7f), LL(0xa9e6a937218837a9), - LL(0x2a7e2a824d67822a), LL(0xbbd0bb6db10a6dbb), LL(0xc15ec1e24687e2c1), LL(0x53f55302a2f10253), - LL(0xdc79dc8bae728bdc), LL(0x0b1d0b275853270b), LL(0x9dba9dd39c01d39d), LL(0x6cb46cc1472bc16c), - LL(0x315331f595a4f531), LL(0x749c74b987f3b974), LL(0xf607f609e31509f6), LL(0x46ca46430a4c4346), - LL(0xace9ac2609a526ac), LL(0x898689973cb59789), LL(0x143c1444a0b44414), LL(0xe13ee1425bba42e1), - LL(0x163a164eb0a64e16), LL(0x3a4e3ad2cdf7d23a), LL(0x69bb69d06f06d069), LL(0x091b092d48412d09), - LL(0x709070ada7d7ad70), LL(0xb6c7b654d96f54b6), LL(0xd06dd0b7ce1eb7d0), LL(0xed2aed7e3bd67eed), - LL(0xcc49ccdb2ee2dbcc), LL(0x42c642572a685742), LL(0x98b598c2b42cc298), LL(0xa4f1a40e49ed0ea4), - LL(0x287828885d758828), LL(0x5ce45c31da86315c), LL(0xf815f83f936b3ff8), LL(0x869786a444c2a486), -}; -#endif /* OBSOLETE */ - -static const uint64_t rc[R + 1] = { - LL(0x0000000000000000), - LL(0x1823c6e887b8014f), - LL(0x36a6d2f5796f9152), - LL(0x60bc9b8ea30c7b35), - LL(0x1de0d7c22e4bfe57), - LL(0x157737e59ff04ada), - LL(0x58c9290ab1a06b85), - LL(0xbd5d10f4cb3e0567), - LL(0xe427418ba77d95d8), - LL(0xfbee7c66dd17479e), - LL(0xca2dbf07ad5a8333), -}; - -/** - * The core Whirlpool transform. - */ -static void processBuffer(struct WHIRLPOOLstruct * const structpointer) { - int i, r; - uint64_t K[8]; /* the round key */ - uint64_t block[8]; /* mu(buffer) */ - uint64_t state[8]; /* the cipher state */ - uint64_t L[8]; - unsigned char *buffer = structpointer->buffer; - - /* - * map the buffer to a block: - */ - for (i = 0; i < 8; i++, buffer += 8) { - block[i] = - (((uint64_t)buffer[0] ) << 56) ^ - (((uint64_t)buffer[1] & 0xffL) << 48) ^ - (((uint64_t)buffer[2] & 0xffL) << 40) ^ - (((uint64_t)buffer[3] & 0xffL) << 32) ^ - (((uint64_t)buffer[4] & 0xffL) << 24) ^ - (((uint64_t)buffer[5] & 0xffL) << 16) ^ - (((uint64_t)buffer[6] & 0xffL) << 8) ^ - (((uint64_t)buffer[7] & 0xffL) ); - } - /* - * compute and apply K^0 to the cipher state: - */ - state[0] = block[0] ^ (K[0] = structpointer->hash[0]); - state[1] = block[1] ^ (K[1] = structpointer->hash[1]); - state[2] = block[2] ^ (K[2] = structpointer->hash[2]); - state[3] = block[3] ^ (K[3] = structpointer->hash[3]); - state[4] = block[4] ^ (K[4] = structpointer->hash[4]); - state[5] = block[5] ^ (K[5] = structpointer->hash[5]); - state[6] = block[6] ^ (K[6] = structpointer->hash[6]); - state[7] = block[7] ^ (K[7] = structpointer->hash[7]); - - /* - * iterate over all rounds: - */ - for (r = 1; r <= R; r++) { - /* - * compute K^r from K^{r-1}: - */ - L[0] = - C0[(int)(K[0] >> 56) ] ^ - C1[(int)(K[7] >> 48) & 0xff] ^ - C2[(int)(K[6] >> 40) & 0xff] ^ - C3[(int)(K[5] >> 32) & 0xff] ^ - C4[(int)(K[4] >> 24) & 0xff] ^ - C5[(int)(K[3] >> 16) & 0xff] ^ - C6[(int)(K[2] >> 8) & 0xff] ^ - C7[(int)(K[1] ) & 0xff] ^ - rc[r]; - L[1] = - C0[(int)(K[1] >> 56) ] ^ - C1[(int)(K[0] >> 48) & 0xff] ^ - C2[(int)(K[7] >> 40) & 0xff] ^ - C3[(int)(K[6] >> 32) & 0xff] ^ - C4[(int)(K[5] >> 24) & 0xff] ^ - C5[(int)(K[4] >> 16) & 0xff] ^ - C6[(int)(K[3] >> 8) & 0xff] ^ - C7[(int)(K[2] ) & 0xff]; - L[2] = - C0[(int)(K[2] >> 56) ] ^ - C1[(int)(K[1] >> 48) & 0xff] ^ - C2[(int)(K[0] >> 40) & 0xff] ^ - C3[(int)(K[7] >> 32) & 0xff] ^ - C4[(int)(K[6] >> 24) & 0xff] ^ - C5[(int)(K[5] >> 16) & 0xff] ^ - C6[(int)(K[4] >> 8) & 0xff] ^ - C7[(int)(K[3] ) & 0xff]; - L[3] = - C0[(int)(K[3] >> 56) ] ^ - C1[(int)(K[2] >> 48) & 0xff] ^ - C2[(int)(K[1] >> 40) & 0xff] ^ - C3[(int)(K[0] >> 32) & 0xff] ^ - C4[(int)(K[7] >> 24) & 0xff] ^ - C5[(int)(K[6] >> 16) & 0xff] ^ - C6[(int)(K[5] >> 8) & 0xff] ^ - C7[(int)(K[4] ) & 0xff]; - L[4] = - C0[(int)(K[4] >> 56) ] ^ - C1[(int)(K[3] >> 48) & 0xff] ^ - C2[(int)(K[2] >> 40) & 0xff] ^ - C3[(int)(K[1] >> 32) & 0xff] ^ - C4[(int)(K[0] >> 24) & 0xff] ^ - C5[(int)(K[7] >> 16) & 0xff] ^ - C6[(int)(K[6] >> 8) & 0xff] ^ - C7[(int)(K[5] ) & 0xff]; - L[5] = - C0[(int)(K[5] >> 56) ] ^ - C1[(int)(K[4] >> 48) & 0xff] ^ - C2[(int)(K[3] >> 40) & 0xff] ^ - C3[(int)(K[2] >> 32) & 0xff] ^ - C4[(int)(K[1] >> 24) & 0xff] ^ - C5[(int)(K[0] >> 16) & 0xff] ^ - C6[(int)(K[7] >> 8) & 0xff] ^ - C7[(int)(K[6] ) & 0xff]; - L[6] = - C0[(int)(K[6] >> 56) ] ^ - C1[(int)(K[5] >> 48) & 0xff] ^ - C2[(int)(K[4] >> 40) & 0xff] ^ - C3[(int)(K[3] >> 32) & 0xff] ^ - C4[(int)(K[2] >> 24) & 0xff] ^ - C5[(int)(K[1] >> 16) & 0xff] ^ - C6[(int)(K[0] >> 8) & 0xff] ^ - C7[(int)(K[7] ) & 0xff]; - L[7] = - C0[(int)(K[7] >> 56) ] ^ - C1[(int)(K[6] >> 48) & 0xff] ^ - C2[(int)(K[5] >> 40) & 0xff] ^ - C3[(int)(K[4] >> 32) & 0xff] ^ - C4[(int)(K[3] >> 24) & 0xff] ^ - C5[(int)(K[2] >> 16) & 0xff] ^ - C6[(int)(K[1] >> 8) & 0xff] ^ - C7[(int)(K[0] ) & 0xff]; - K[0] = L[0]; - K[1] = L[1]; - K[2] = L[2]; - K[3] = L[3]; - K[4] = L[4]; - K[5] = L[5]; - K[6] = L[6]; - K[7] = L[7]; - /* - * apply the r-th round transformation: - */ - L[0] = - C0[(int)(state[0] >> 56) ] ^ - C1[(int)(state[7] >> 48) & 0xff] ^ - C2[(int)(state[6] >> 40) & 0xff] ^ - C3[(int)(state[5] >> 32) & 0xff] ^ - C4[(int)(state[4] >> 24) & 0xff] ^ - C5[(int)(state[3] >> 16) & 0xff] ^ - C6[(int)(state[2] >> 8) & 0xff] ^ - C7[(int)(state[1] ) & 0xff] ^ - K[0]; - L[1] = - C0[(int)(state[1] >> 56) ] ^ - C1[(int)(state[0] >> 48) & 0xff] ^ - C2[(int)(state[7] >> 40) & 0xff] ^ - C3[(int)(state[6] >> 32) & 0xff] ^ - C4[(int)(state[5] >> 24) & 0xff] ^ - C5[(int)(state[4] >> 16) & 0xff] ^ - C6[(int)(state[3] >> 8) & 0xff] ^ - C7[(int)(state[2] ) & 0xff] ^ - K[1]; - L[2] = - C0[(int)(state[2] >> 56) ] ^ - C1[(int)(state[1] >> 48) & 0xff] ^ - C2[(int)(state[0] >> 40) & 0xff] ^ - C3[(int)(state[7] >> 32) & 0xff] ^ - C4[(int)(state[6] >> 24) & 0xff] ^ - C5[(int)(state[5] >> 16) & 0xff] ^ - C6[(int)(state[4] >> 8) & 0xff] ^ - C7[(int)(state[3] ) & 0xff] ^ - K[2]; - L[3] = - C0[(int)(state[3] >> 56) ] ^ - C1[(int)(state[2] >> 48) & 0xff] ^ - C2[(int)(state[1] >> 40) & 0xff] ^ - C3[(int)(state[0] >> 32) & 0xff] ^ - C4[(int)(state[7] >> 24) & 0xff] ^ - C5[(int)(state[6] >> 16) & 0xff] ^ - C6[(int)(state[5] >> 8) & 0xff] ^ - C7[(int)(state[4] ) & 0xff] ^ - K[3]; - L[4] = - C0[(int)(state[4] >> 56) ] ^ - C1[(int)(state[3] >> 48) & 0xff] ^ - C2[(int)(state[2] >> 40) & 0xff] ^ - C3[(int)(state[1] >> 32) & 0xff] ^ - C4[(int)(state[0] >> 24) & 0xff] ^ - C5[(int)(state[7] >> 16) & 0xff] ^ - C6[(int)(state[6] >> 8) & 0xff] ^ - C7[(int)(state[5] ) & 0xff] ^ - K[4]; - L[5] = - C0[(int)(state[5] >> 56) ] ^ - C1[(int)(state[4] >> 48) & 0xff] ^ - C2[(int)(state[3] >> 40) & 0xff] ^ - C3[(int)(state[2] >> 32) & 0xff] ^ - C4[(int)(state[1] >> 24) & 0xff] ^ - C5[(int)(state[0] >> 16) & 0xff] ^ - C6[(int)(state[7] >> 8) & 0xff] ^ - C7[(int)(state[6] ) & 0xff] ^ - K[5]; - L[6] = - C0[(int)(state[6] >> 56) ] ^ - C1[(int)(state[5] >> 48) & 0xff] ^ - C2[(int)(state[4] >> 40) & 0xff] ^ - C3[(int)(state[3] >> 32) & 0xff] ^ - C4[(int)(state[2] >> 24) & 0xff] ^ - C5[(int)(state[1] >> 16) & 0xff] ^ - C6[(int)(state[0] >> 8) & 0xff] ^ - C7[(int)(state[7] ) & 0xff] ^ - K[6]; - L[7] = - C0[(int)(state[7] >> 56) ] ^ - C1[(int)(state[6] >> 48) & 0xff] ^ - C2[(int)(state[5] >> 40) & 0xff] ^ - C3[(int)(state[4] >> 32) & 0xff] ^ - C4[(int)(state[3] >> 24) & 0xff] ^ - C5[(int)(state[2] >> 16) & 0xff] ^ - C6[(int)(state[1] >> 8) & 0xff] ^ - C7[(int)(state[0] ) & 0xff] ^ - K[7]; - state[0] = L[0]; - state[1] = L[1]; - state[2] = L[2]; - state[3] = L[3]; - state[4] = L[4]; - state[5] = L[5]; - state[6] = L[6]; - state[7] = L[7]; - } - /* - * apply the Miyaguchi-Preneel compression function: - */ - structpointer->hash[0] ^= state[0] ^ block[0]; - structpointer->hash[1] ^= state[1] ^ block[1]; - structpointer->hash[2] ^= state[2] ^ block[2]; - structpointer->hash[3] ^= state[3] ^ block[3]; - structpointer->hash[4] ^= state[4] ^ block[4]; - structpointer->hash[5] ^= state[5] ^ block[5]; - structpointer->hash[6] ^= state[6] ^ block[6]; - structpointer->hash[7] ^= state[7] ^ block[7]; -} - -/** - * Initialize the hashing state. - */ -void WHIRLPOOLinit(struct WHIRLPOOLstruct * const structpointer) { - int i; - - memset(structpointer->bitLength, 0, 32); - structpointer->bufferBits = structpointer->bufferPos = 0; - structpointer->buffer[0] = 0; /* it's only necessary to cleanup buffer[bufferPos] */ - for (i = 0; i < 8; i++) { - structpointer->hash[i] = 0L; /* initial value */ - } -} - -/** - * Delivers input data to the hashing algorithm. - * - * @param source plaintext data to hash. - * @param sourceBits how many bits of plaintext to process. - * - * This method maintains the invariant: bufferBits < WHIRLPOOL_DIGESTBITS - */ -void WHIRLPOOLadd(const unsigned char * const source, - unsigned long sourceBits, - struct WHIRLPOOLstruct * const structpointer) { - /* - sourcePos - | - +-------+-------+------- - ||||||||||||||||||||| source - +-------+-------+------- - +-------+-------+-------+-------+-------+------- - |||||||||||||||||||||| buffer - +-------+-------+-------+-------+-------+------- - | - bufferPos - */ - int sourcePos = 0; /* index of leftmost source unsigned char containing data (1 to 8 bits). */ - int sourceGap = (8 - ((int)sourceBits & 7)) & 7; /* space on source[sourcePos]. */ - int bufferRem = structpointer->bufferBits & 7; /* occupied bits on buffer[bufferPos]. */ - int i; - uint32_t b, carry; - unsigned char *buffer = structpointer->buffer; - unsigned char *bitLength = structpointer->bitLength; - int bufferBits = structpointer->bufferBits; - int bufferPos = structpointer->bufferPos; - - /* - * tally the length of the added data: - */ - uint64_t value = sourceBits; - for (i = 31, carry = 0; i >= 0 && (carry != 0 || value != LL(0)); i--) { - carry += bitLength[i] + ((uint32_t)value & 0xff); - bitLength[i] = (unsigned char)carry; - carry >>= 8; - value >>= 8; - } - /* - * process data in chunks of 8 bits (a more efficient approach would be to take whole-word chunks): - */ - while (sourceBits > 8) { - /* N.B. at least source[sourcePos] and source[sourcePos+1] contain data. */ - /* - * take a byte from the source: - */ - b = ((source[sourcePos] << sourceGap) & 0xff) | - ((source[sourcePos + 1] & 0xff) >> (8 - sourceGap)); - /* - * process this byte: - */ - buffer[bufferPos++] |= (unsigned char)(b >> bufferRem); - bufferBits += 8 - bufferRem; /* bufferBits = 8*bufferPos; */ - if (bufferBits == WHIRLPOOL_DIGESTBITS) { - /* - * process data block: - */ - processBuffer(structpointer); - /* - * reset buffer: - */ - bufferBits = bufferPos = 0; - } - buffer[bufferPos] = b << (8 - bufferRem); - bufferBits += bufferRem; - /* - * proceed to remaining data: - */ - sourceBits -= 8; - sourcePos++; - } - /* now 0 <= sourceBits <= 8; - * furthermore, all data (if any is left) is in source[sourcePos]. - */ - if (sourceBits > 0) { - b = (source[sourcePos] << sourceGap) & 0xff; /* bits are left-justified on b. */ - /* - * process the remaining bits: - */ - buffer[bufferPos] |= b >> bufferRem; - } else { - b = 0; - } - if (bufferRem + sourceBits < 8) { - /* - * all remaining data fits on buffer[bufferPos], - * and there still remains some space. - */ - bufferBits += sourceBits; - } else { - /* - * buffer[bufferPos] is full: - */ - bufferPos++; - bufferBits += 8 - bufferRem; /* bufferBits = 8*bufferPos; */ - sourceBits -= 8 - bufferRem; - /* now 0 <= sourceBits < 8; - * furthermore, all data (if any is left) is in source[sourcePos]. - */ - if (bufferBits == WHIRLPOOL_DIGESTBITS) { - /* - * process data block: - */ - processBuffer(structpointer); - /* - * reset buffer: - */ - bufferBits = bufferPos = 0; - } - buffer[bufferPos] = b << (8 - bufferRem); - bufferBits += (int)sourceBits; - } - structpointer->bufferBits = bufferBits; - structpointer->bufferPos = bufferPos; -} - -/** - * Get the hash value from the hashing state. - * - * This method uses the invariant: bufferBits < WHIRLPOOL_DIGESTBITS - */ -void WHIRLPOOLfinalize(struct WHIRLPOOLstruct * const structpointer, - unsigned char * const result) { - int i; - unsigned char *buffer = structpointer->buffer; - unsigned char *bitLength = structpointer->bitLength; - int bufferBits = structpointer->bufferBits; - int bufferPos = structpointer->bufferPos; - unsigned char *digest = result; - - /* - * append a '1'-bit: - */ - buffer[bufferPos] |= 0x80U >> (bufferBits & 7); - bufferPos++; /* all remaining bits on the current unsigned char are set to zero. */ - /* - * pad with zero bits to complete (N*WBLOCKBITS - LENGTHBITS) bits: - */ - if (bufferPos > WBLOCKBYTES - LENGTHBYTES) { - if (bufferPos < WBLOCKBYTES) { - memset(&buffer[bufferPos], 0, WBLOCKBYTES - bufferPos); - } - /* - * process data block: - */ - processBuffer(structpointer); - /* - * reset buffer: - */ - bufferPos = 0; - } - if (bufferPos < WBLOCKBYTES - LENGTHBYTES) { - memset(&buffer[bufferPos], 0, (WBLOCKBYTES - LENGTHBYTES) - bufferPos); - } - bufferPos = WBLOCKBYTES - LENGTHBYTES; - /* - * append bit length of hashed data: - */ - memcpy(&buffer[WBLOCKBYTES - LENGTHBYTES], bitLength, LENGTHBYTES); - /* - * process data block: - */ - processBuffer(structpointer); - /* - * return the completed message digest: - */ - for (i = 0; i < WHIRLPOOL_DIGESTBYTES/8; i++) { - digest[0] = (unsigned char)(structpointer->hash[i] >> 56); - digest[1] = (unsigned char)(structpointer->hash[i] >> 48); - digest[2] = (unsigned char)(structpointer->hash[i] >> 40); - digest[3] = (unsigned char)(structpointer->hash[i] >> 32); - digest[4] = (unsigned char)(structpointer->hash[i] >> 24); - digest[5] = (unsigned char)(structpointer->hash[i] >> 16); - digest[6] = (unsigned char)(structpointer->hash[i] >> 8); - digest[7] = (unsigned char)(structpointer->hash[i] ); - digest += 8; - } - structpointer->bufferBits = bufferBits; - structpointer->bufferPos = bufferPos; -} - diff --git a/libUseful-2.6/whirlpool.h b/libUseful-2.6/whirlpool.h deleted file mode 100755 index bfc5c20..0000000 --- a/libUseful-2.6/whirlpool.h +++ /dev/null @@ -1,36 +0,0 @@ - -#ifndef HASH_WHIRLPOOL_H -#define HASH_WHIRLPOOL_H - -#include - -/* - * Whirlpool-specific definitions. - */ - -#define WHIRLPOOL_DIGESTBYTES 64 -#define WHIRLPOOL_DIGESTBITS (8*WHIRLPOOL_DIGESTBYTES) /* 512 */ - -#define WBLOCKBYTES 64 -#define WBLOCKBITS (8*WBLOCKBYTES) /* 512 */ - -#define LENGTHBYTES 32 -#define LENGTHBITS (8*LENGTHBYTES) /* 256 */ - -typedef struct WHIRLPOOLstruct { - unsigned char bitLength[LENGTHBYTES]; /* global number of hashed bits (256-bit counter) */ - unsigned char buffer[WBLOCKBYTES]; /* buffer of data to hash */ - int bufferBits; /* current number of bits on the buffer */ - int bufferPos; /* current (possibly incomplete) byte slot on the buffer */ - uint64_t hash[WHIRLPOOL_DIGESTBYTES/8]; /* the hashing state */ -} WHIRLPOOLstruct; - - -void WHIRLPOOLinit(struct WHIRLPOOLstruct * const structpointer); -void WHIRLPOOLadd(const unsigned char * const source, unsigned long sourceBits, struct WHIRLPOOLstruct * const structpointer); -void WHIRLPOOLfinalize(struct WHIRLPOOLstruct * const structpointer, unsigned char * const result); - - -#endif - - diff --git a/main.c b/main.c index 57e067d..c79ef4a 100755 --- a/main.c +++ b/main.c @@ -43,30 +43,32 @@ int OverrideType=TYPE_NONE; char *Tempstr=NULL; int result; -//HTTPSetFlags(HTTP_NOCOMPRESS); +InitSettings(); +HTTPSetFlags(HTTP_NOCOMPRESS); StdIn=STREAMFromFD(0); STREAMSetTimeout(StdIn,0); -ParseEnvironmentVariables(); -UserAgent=MCopyStr(UserAgent,"Movgrab ",Version,NULL); DownloadQueue=ListCreate(); -FormatPreference=CopyStr(FormatPreference,"mp4,flv,webm,m4v,mov,mpg,mpeg,wmv,avi,3gp,mp3,m4a,wma,m3u8,m3u8-stream,reference"); +Tempstr=MCopyStr(Tempstr,GetCurrUserHomeDir(), ".movgrab.conf", NULL); +if (! ParsePreferencesFile(Tempstr)) ParsePreferencesFile("/etc/movgrab.conf"); +ParseEnvironmentVariables(); + AddOutputFile("", TRUE); ParseCommandLine(argc, argv, DownloadQueue, &OverrideType); CheckSettings(); -if (StrValid(Proxy)) +if (StrValid(Settings.Proxy)) { - if (strncmp(Proxy,"http:",5)==0) HTTPSetProxy(Proxy); - else if (strncmp(Proxy,"https:",6)==0) HTTPSetProxy(Proxy); - else if (! SetGlobalConnectionChain(Proxy)) + if (strncmp(Settings.Proxy,"http:",5)==0) HTTPSetProxy(Settings.Proxy); + else if (strncmp(Settings.Proxy,"https:",6)==0) HTTPSetProxy(Settings.Proxy); + else if (! SetGlobalConnectionChain(Settings.Proxy)) { - printf("ERROR: Failed to set proxy settings to '%s'\n",Proxy); + printf("ERROR: Failed to set proxy settings to '%s'\n",Settings.Proxy); exit(1); } } -HTTPSetUserAgent(UserAgent); +HTTPSetUserAgent(Settings.UserAgent); if (Flags & FLAG_PRINT_USAGE) PrintUsage(); diff --git a/outputfiles.c b/outputfiles.c index c286e6f..39533a4 100755 --- a/outputfiles.c +++ b/outputfiles.c @@ -35,26 +35,28 @@ char *ptr; Extn=CopyStr(Extn,".flv"); -if (StrLen(ID)) +if (StrValid(ID)) { ptr=strchr(ID,'.'); - if (StrLen(ptr)) Extn=CopyStr(Extn,ptr); + if (StrValid(ptr)) Extn=CopyStr(Extn,ptr); } -if (StrLen(Format)) Extn=MCopyStr(Extn,".",Format,NULL); +if (StrValid(Format)) Extn=MCopyStr(Extn,".",Format,NULL); -if (StrLen(ContentType)) +if (StrValid(ContentType)) { ptr=NULL; if (strcasecmp(ContentType,"audio/mp3")==0) ptr=".mp3"; else if (strcasecmp(ContentType,"audio/mpeg")==0) ptr=".mp3"; +else if (strcasecmp(ContentType,"audio/ogg")==0) ptr=".ogg"; +else if (strcasecmp(ContentType,"audio/aac")==0) ptr=".aac"; else if (strcasecmp(ContentType,"video/x-flv")==0) ptr=".flv"; else if (strcasecmp(ContentType,"video/flv")==0) ptr=".flv"; else if (strcasecmp(ContentType,"video/mp4")==0) ptr=".mp4"; else if (strcasecmp(ContentType,"video/3gpp")==0) ptr=".3gp"; else if (strcasecmp(ContentType,"audio/webm")==0) ptr=".webm"; else if (strcasecmp(ContentType,"video/webm")==0) ptr=".webm"; -if (StrLen(ptr)) Extn=CopyStr(Extn,ptr); +if (StrValid(ptr)) Extn=CopyStr(Extn,ptr); } return(Extn); @@ -68,7 +70,7 @@ char *GetSaveFilePath(char *RetStr, const char *Title, const char *URL) char *ptr=NULL; char *Tempstr=NULL, *MD5=NULL; -if (StrLen(Title)) ptr=Title; +if (StrValid(Title)) ptr=Title; else { Tempstr=CopyStr(Tempstr, URL); @@ -123,7 +125,7 @@ if (strcmp(Path,"-")==0) } else { - S=STREAMOpenFile(Path, SF_CREAT | SF_RDWR); + S=STREAMFileOpen(Path, SF_CREAT | SF_RDWR); if (S) { if (! STREAMLock(S,LOCK_EX|LOCK_NB)) @@ -161,7 +163,7 @@ glob(Tempstr,0,0,&Glob); if (Glob.gl_pathc > 0) { -S=STREAMOpenFile(Glob.gl_pathv[0],SF_RDONLY); +S=STREAMFileOpen(Glob.gl_pathv[0],SF_RDONLY); } globfree(&Glob); @@ -187,7 +189,7 @@ if ((Flags & FLAG_RESUME) && (ListSize(OutputFiles)==1)) Resume=TRUE; Curr=ListGetNext(OutputFiles); while (Curr) { - if (StrLen(Curr->Tag)==0) + if (! StrValid(Curr->Tag)) { Tempstr=GetSaveFilePath(Tempstr, Title, URL); S=OpenSaveFile(Tempstr, FileSize, Resume); @@ -247,7 +249,7 @@ while (Curr) if ((Curr->Item) && (strcmp(Curr->Tag,"-") !=0)) { S=(STREAM *) Curr->Item; - if (! StrLen(Curr->Tag)) + if (! StrValid(Curr->Tag)) { Tempstr=MCopyStr(Tempstr,S->Path,Extn,NULL); rename(S->Path,Tempstr); diff --git a/selectformat.c b/selectformat.c index da0c197..77d6241 100644 --- a/selectformat.c +++ b/selectformat.c @@ -1,6 +1,7 @@ #include "selectformat.h" #include "servicetypes.h" #include "display.h" +#include "settings.h" char *GatherMatchingFormats(char *Buffer, char *Type, ListNode *Vars) { @@ -13,7 +14,7 @@ while (Curr) { if (strncmp(Curr->Tag,"item:",5)==0) { -if ((StrLen(Type)==0) || (strncmp(Curr->Tag,Type,StrLen(Type))==0)) Tempstr=MCatStr(Tempstr,Curr->Tag+5," ",NULL); +if ((! StrValid(Type)) || (strncmp(Curr->Tag,Type,StrLen(Type))==0)) Tempstr=MCatStr(Tempstr,Curr->Tag+5," ",NULL); } Curr=ListGetNext(Curr); @@ -24,13 +25,13 @@ return(Tempstr); int FmtIDMatches(const char *FmtID, const char *CurrItem, const char *ItemData) { -int len; -len=StrLen(FmtID); +//item must be... um... an 'item:' +if (! StrValid(CurrItem)) return(FALSE); +if (strncmp(CurrItem,"item:",5) !=0) return(FALSE); -if (len==0) return(TRUE); +if (! StrValid(FmtID)) return(TRUE); if (strcmp(FmtID,"item:*")==0) return(TRUE); -if (strncmp(CurrItem,"item:",5) !=0) return(FALSE); if ((strncmp(CurrItem,FmtID,StrLen(FmtID))==0) && StrValid(ItemData)) return(TRUE); return(FALSE); @@ -40,7 +41,7 @@ return(FALSE); //this function compares the video formats found on the page to the list of //preferences expressed by the user with the '-f' flag, and contained in the -//global variable 'FormatPreference' +//global variable 'Settings.FormatPreference' int SelectDownloadFormat(ListNode *Vars, int WebsiteType, int DisplaySize) { ListNode *Curr; @@ -59,10 +60,10 @@ Tempstr=GatherMatchingFormats(Tempstr,"",Vars); } } - ptr=GetToken(FormatPreference,",",&Fmt,0); + ptr=GetToken(Settings.FormatPreference,",",&Fmt,0); while (ptr) { - if (StrLen(Fmt)) FmtID=MCopyStr(FmtID,"item:",Fmt,NULL); + if (StrValid(Fmt)) FmtID=MCopyStr(FmtID,"item:",Fmt,NULL); else FmtID=CopyStr(FmtID,""); if (Flags & FLAG_DEBUG) fprintf(stderr," %s ",Fmt); @@ -107,14 +108,14 @@ if (StrValid(Selected)) if (! (Flags & FLAG_TEST_SITES)) { - if (RetVal==-1) fprintf(stderr,"No suitable download format found from '%s'\n\n",FormatPreference); + if (RetVal==-1) fprintf(stderr,"No suitable download format found from '%s'\n\n",Settings.FormatPreference); else if (RetVal==TYPE_REFERENCE) fprintf(stderr,"Reference to another site: %s\n",GetVar(Vars,"ID")); else fprintf(stderr,"Selected format %s\n",Selected); } //+5 to get past leading 'item:' in variable name -if (StrLen(Selected)) SetVar(Vars,"DownloadFormat",Selected+5); +if (StrValid(Selected)) SetVar(Vars,"DownloadFormat",Selected+5); DestroyString(Selected); DestroyString(Tempstr); diff --git a/servicetypes.c b/servicetypes.c index 8e26ab7..b42a995 100755 --- a/servicetypes.c +++ b/servicetypes.c @@ -4,6 +4,7 @@ #include "download.h" #include "ign.h" #include "youtube.h" +#include "settings.h" /* This file and it's header (servicetypes.h) holds all the functions and data @@ -330,7 +331,7 @@ case TYPE_YOUTUBE: } //Do we have authentication info? - //if (StrLen(Username) && StrLen(Password)) YoutubeLogin(Username,Password); + //if (StrValid(Username) && StrValid(Password)) YoutubeLogin(Username,Password); break; @@ -436,7 +437,7 @@ startpos=0; endpos=MediaCount; if (MediaCount==1) endpos=1; - else if (StrLen(ItemSelectionArg)==0) + else if (! StrValid(Settings.ItemSelectArg)) { if (! (Flags & FLAG_QUIET)) { @@ -459,21 +460,21 @@ endpos=MediaCount; } endpos=startpos; } - else if (strcmp(ItemSelectionArg,"all")==0) + else if (strcmp(Settings.ItemSelectArg,"all")==0) { //do nothing } - else if (strchr(ItemSelectionArg,'-')) + else if (strchr(Settings.ItemSelectArg,'-')) { - ptr=GetToken(ItemSelectionArg,"-",&Tempstr,0); - if (StrLen(Tempstr)) startpos=atoi(Tempstr); + ptr=GetToken(Settings.ItemSelectArg,"-",&Tempstr,0); + if (StrValid(Tempstr)) startpos=atoi(Tempstr); else startpos=0; - if (StrLen(ptr)) endpos=atoi(ptr); + if (StrValid(ptr)) endpos=atoi(ptr); else endpos=MediaCount; } else { - startpos=atoi(ItemSelectionArg); + startpos=atoi(Settings.ItemSelectArg); endpos=startpos+1; } @@ -794,7 +795,7 @@ case TYPE_YOUTUBE: if (strstr(Tempstr,YOUTUBE_DIV)) { - if (StrLen(GetVar(Vars,"item:flv"))==0) + if (! StrValid(GetVar(Vars,"item:flv"))) { GenericExtractFromLine(Tempstr, "yt:url_fmt",YOUTUBE_DIV, YOUTUBE_END, Vars,EXTRACT_DEQUOTE); Token=CopyStr(Token,GetVar(Vars,"yt:url_fmt")); @@ -1407,7 +1408,7 @@ if (strstr(Tempstr,YOUTUBE_REFERENCE1)) { GenericExtractFromLine(Tempstr, "yt-tmp",YOUTUBE_REFERENCE1,"\"",Vars,EXTRACT_DEQUOTE | EXTRACT_NOSPACES); ptr=GetVar(Vars,"yt-tmp"); - if (StrLen(ptr)) Token=MCopyStr(Token,YOUTUBE_REFERENCE1,ptr,NULL); + if (StrValid(ptr)) Token=MCopyStr(Token,YOUTUBE_REFERENCE1,ptr,NULL); SetVar(Vars,"item:reference",Token); Token=CopyStr(Token,""); //So as later stages of this process don't } @@ -1416,7 +1417,7 @@ if (strstr(Tempstr,YOUTUBE_REFERENCE2)) { GenericExtractFromLine(Tempstr, "yt-tmp",YOUTUBE_REFERENCE2,"\"",Vars,EXTRACT_DEQUOTE | EXTRACT_NOSPACES); ptr=GetVar(Vars,"yt-tmp"); - if (StrLen(ptr)) Token=MCopyStr(Token,YOUTUBE_REFERENCE2,ptr,NULL); + if (StrValid(ptr)) Token=MCopyStr(Token,YOUTUBE_REFERENCE2,ptr,NULL); SetVar(Vars,"item:reference",Token); Token=CopyStr(Token,""); //So as later stages of this process don't //pick up on it @@ -1429,7 +1430,7 @@ if (strstr(Tempstr,ContainerTypes[i])) { GenericExtractFromLine(Tempstr, "tmp","http://",ContainerTypes[i],Vars,EXTRACT_DEQUOTE | EXTRACT_NOSPACES); ptr=GetVar(Vars,"tmp"); - if (StrLen(ptr)) Token=MCopyStr(Token,"http://",ptr,ContainerTypes[i],NULL); + if (StrValid(ptr)) Token=MCopyStr(Token,"http://",ptr,ContainerTypes[i],NULL); SetVar(Vars,"item:reference",Token); } } @@ -1443,19 +1444,19 @@ for (i=0; FileTypes[i] !=NULL; i++) VarName=MCopyStr(VarName,"item:",FileTypes[i]+1,NULL); GenericExtractFromLine(Tempstr, VarName,"http://",FileTypes[i],Vars,EXTRACT_DEQUOTE | EXTRACT_NOSPACES); ptr=GetVar(Vars,VarName); - if (StrLen(ptr)) Token=MCopyStr(Token,"http://",ptr,NULL); + if (StrValid(ptr)) Token=MCopyStr(Token,"http://",ptr,NULL); else { GenericExtractFromLine(Tempstr, VarName,"href=",FileTypes[i],Vars,EXTRACT_DEQUOTE | EXTRACT_NOSPACES); Token=CopyStr(Token,GetVar(Vars,VarName)); - if (StrLen(Token) && (strncasecmp(Token,"http://",7) !=0)) + if (StrValid(Token) && (strncasecmp(Token,"http://",7) !=0)) { Token=MCopyStr(Token,"http://",GetVar(Vars,"Server"),"/",NULL); Token=CatStr(Token,GetVar(Vars,VarName)); } } - if (StrLen(Token)) + if (StrValid(Token)) { Token=CatStr(Token,FileTypes[i]); SetVar(Vars,VarName,Token); @@ -1582,7 +1583,7 @@ char *ptr, *Token=NULL; int Port; int RetVal=FALSE; -if (!StrLen(Path)) return(FALSE); +if (! StrValid(Path)) return(FALSE); Type=MovType; NextPath=CopyStr(NextPath,Path); diff --git a/settings.c b/settings.c index df91132..d63dfb9 100644 --- a/settings.c +++ b/settings.c @@ -3,6 +3,17 @@ #include "display.h" #include "download.h" #include "outputfiles.h" +#include "players.h" + +TSettings Settings; + +void InitSettings() +{ +memset(&Settings,0,sizeof(Settings)); +Settings.PlayerLaunchPercent=25; +Settings.UserAgent=MCopyStr(Settings.UserAgent,"Movgrab ",Version,NULL); +Settings.FormatPreference=CopyStr(Settings.FormatPreference,"mp4,flv,webm,m4v,mov,mpg,mpeg,wmv,avi,3gp,mp3,m4a,wma,m3u8,m3u8-stream,reference"); +} void PrintVersion() { @@ -26,7 +37,7 @@ fprintf(stdout,"'-v -v -v' maximum debugging\n"); fprintf(stdout,"'-version' Program version\n"); fprintf(stdout,"'--version' Program version\n"); fprintf(stdout,"'-T' Test mode, don't do final download\n"); -fprintf(stdout,"'-P ' Player program (e.g. \"mplayer\")\n"); +fprintf(stdout,"'-P ' Player program (e.g. \"mplayer\"). If is 'auto' then select it from players set up in config file.\n"); fprintf(stdout,"'-Pp' Percent download to launch player at (default 25%)\n"); fprintf(stdout,"'-U' User-agent string\n"); fprintf(stdout,"'-a' Authentication info in Username:Password format.\n"); @@ -68,6 +79,20 @@ fprintf(stdout,"\nAvailable proxy types are: 'http', 'https' (which is 'http' st fprintf(stdout,"\nIf a website is not in the list, try 'movgrab -t generic '\n"); fprintf(stdout,"\nMovgrab can also be used to stream from internet radio and pipe it into a player. E.g.'\n movgrab -o - -q -proxy ssltunnel://guest:s3cr3t@sshserver:1022 http://schizoid.in/schizoid-psy.pls | mpg123 -\n"); + +fprintf(stdout,"\nMovgrab honors the following environment variables\n"); +fprintf(stdout,"MOVGRAB_FORMATS list of file formats in preference order\n");; +fprintf(stdout,"PROXY proxy server for network comms (including server type, so e.g. socks4:192.168.5.1:1090)\n");; +fprintf(stdout,"proxy proxy server for network comms (including server type, so e.g. socks4:192.168.5.1:1090)\n");; +fprintf(stdout,"socks4_proxy socks4 proxy server\n");; +fprintf(stdout,"socks5_proxy socks5 proxy server\n");; +fprintf(stdout,"http_proxy http proxy server\n");; + +fprintf(stdout,"\nMovgrab uses a preferences file either set globally in /etc/movgrab.conf or per user in ~/.movgrab.conf. Entries in this file are:\n"); +fprintf(stdout,"mediafmt list of file formats in preference order\n");; +fprintf(stdout,"proxy url of network proxy\n");; +fprintf(stdout,"useragent useragent string for http communications\n");; +fprintf(stdout,"player path to player program for a particular content type. Used in combination with the '-P auto' command-line switch.\n");; fprintf(stdout,"\nFeel free to email me and tell me if you've used this software!\n"); fprintf(stdout,"\nThanks for bug reports go to: Philip Pi, Mark Gamar, Rich Kcsa, 'Rampant Badger', 'nibbles', 'deeice', Omair Eshkenazi, Matthias B, Ashish Disawal, Timo Juhani Lindfors, Abhisek Sanyal and others.\n"); @@ -89,6 +114,39 @@ return(result); } +int ParsePreferencesFile(const char *Path) +{ +STREAM *S; +char *Tempstr=NULL, *Token=NULL, *ptr; + +S=STREAMOpen(Path, "r"); +if (! S) return(FALSE); +Tempstr=STREAMReadLine(Tempstr, S); +while (Tempstr) +{ +StripTrailingWhitespace(Tempstr); +StripLeadingWhitespace(Tempstr); +ptr=GetToken(Tempstr, "\\S", &Token, 0); + +if (strcasecmp(Token, "mediafmt")==0) Settings.FormatPreference=CopyStr(Settings.FormatPreference,ptr); +else if (strcasecmp(Token, "sslciphers")==0) LibUsefulSetValue("SSL-Permitted-Ciphers", ptr); +else if (strcasecmp(Token, "ssllevel")==0) LibUsefulSetValue("SSL-Level", ptr); +else if (strcasecmp(Token, "proxy")==0) Settings.Proxy=CopyStr(Settings.Proxy, ptr); +else if (strcasecmp(Token, "useragent")==0) Settings.UserAgent=CopyStr(Settings.UserAgent, ptr); +else if (strcasecmp(Token, "player")==0) ParsePlayer(ptr); + +Tempstr=STREAMReadLine(Tempstr, S); +} + +STREAMClose(S); + +DestroyString(Tempstr); +DestroyString(Token); + +return(TRUE); +} + + void ParseCommandLine(int argc, char *argv[], ListNode *DL_List, int *OverrideType) { int i,j, DebugLevel=0; @@ -100,8 +158,8 @@ CmdLine=argv[0]; for (i=1; i < argc; i++) { - if (strcmp(argv[i],"-p")==0) Proxy=CopyStr(Proxy,argv[++i]); - else if (strcmp(argv[i],"-proxy")==0) Proxy=CopyStr(Proxy,argv[++i]); + if (strcmp(argv[i],"-p")==0) Settings.Proxy=CopyStr(Settings.Proxy,argv[++i]); + else if (strcmp(argv[i],"-proxy")==0) Settings.Proxy=CopyStr(Settings.Proxy,argv[++i]); else if (strcmp(argv[i],"-a")==0) { ptr=GetToken(argv[++i],":",&Username,0); @@ -125,10 +183,10 @@ for (i=1; i < argc; i++) } else if (strcmp(argv[i],"-n")==0) { - ItemSelectionArg=CopyStr(ItemSelectionArg,argv[++i]); + Settings.ItemSelectArg=CopyStr(Settings.ItemSelectArg,argv[++i]); } else if (strcmp(argv[i],"-t")==0) *OverrideType=ParseType(argv[++i]); - else if (strcmp(argv[i],"-f")==0) FormatPreference=CopyStr(FormatPreference,argv[++i]); + else if (strcmp(argv[i],"-f")==0) Settings.FormatPreference=CopyStr(Settings.FormatPreference,argv[++i]); else if (strcmp(argv[i],"-q")==0) Flags |= FLAG_QUIET; else if (strcmp(argv[i],"-b")==0) Flags |= FLAG_BACKGROUND; else if (strcmp(argv[i],"-r")==0) Flags |= FLAG_RESUME; @@ -136,11 +194,11 @@ for (i=1; i < argc; i++) else if (strcmp(argv[i],"-T")==0) Flags |= FLAG_TEST; else if (strcmp(argv[i],"-w")==0) Flags |= FLAG_STDIN; else if (strcmp(argv[i],"-dt")==0) DisplayTitleWidth=atoi(argv[++i]); - else if (strcmp(argv[i],"-np")==0) NowPlayingFile=CopyStr(NowPlayingFile, argv[++i]); - else if (strcmp(argv[i],"-st")==0) STREAMTimeout=atoi(argv[++i]); - else if (strcmp(argv[i],"-P")==0) Player=CopyStr(Player,argv[++i]); - else if (strcmp(argv[i],"-Pp")==0) PlayerLaunchPercent=atoi(argv[++i]); - else if (strcmp(argv[i],"-U")==0) UserAgent=CopyStr(UserAgent, argv[++i]); + else if (strcmp(argv[i],"-np")==0) Settings.NowPlayingFile=CopyStr(Settings.NowPlayingFile, argv[++i]); + else if (strcmp(argv[i],"-st")==0) Settings.STREAMTimeout=atoi(argv[++i]); + else if (strcmp(argv[i],"-P")==0) SetPlayer(argv[++i]); + else if (strcmp(argv[i],"-Pp")==0) Settings.PlayerLaunchPercent=atoi(argv[++i]); + else if (strcmp(argv[i],"-U")==0) Settings.UserAgent=CopyStr(Settings.UserAgent, argv[++i]); else if (strcmp(argv[i],"-?")==0) Flags |= FLAG_PRINT_USAGE; else if (strcmp(argv[i],"-h")==0) Flags |= FLAG_PRINT_USAGE; else if (strcmp(argv[i],"-help")==0) Flags |= FLAG_PRINT_USAGE; @@ -155,7 +213,7 @@ for (i=1; i < argc; i++) if (StrLen(TestLinks[j])) ListAddNamedItem(DL_List,DownloadTypes[j],CopyStr(NULL,TestLinks[j])); } - ItemSelectionArg=CopyStr(ItemSelectionArg,"0"); + Settings.ItemSelectArg=CopyStr(Settings.ItemSelectArg,"0"); } else { @@ -192,30 +250,69 @@ DestroyString(Token); } -void ParseEnvironmentVariables() + + +void ParseEnvironmentProxy() { -char *Tempstr=NULL; +const char *ptr; -Tempstr=CopyStr(Tempstr,getenv("http_proxy")); -if (StrLen(Tempstr)) +ptr=getenv("proxy"); +if (! StrValid(ptr)) ptr=getenv("PROXY"); +if (StrValid(ptr)) +{ + Settings.Proxy=CopyStr(Settings.Proxy, ptr); + return; +} + + +ptr=getenv("socks4_proxy"); +if (StrValid(ptr)) +{ + Settings.Proxy=MCopyStr(Settings.Proxy, "socks4:", ptr, NULL); + return; +} + +ptr=getenv("socks5_proxy"); +if (StrValid(ptr)) +{ + Settings.Proxy=MCopyStr(Settings.Proxy, "socks5:", ptr, NULL); + return; +} + +ptr=getenv("http_proxy"); +if (StrValid(ptr)) { if ( - (strncasecmp(Tempstr,"http:",5) !=0) && - (strncasecmp(Tempstr,"https:",6) !=0) - ) Proxy=MCopyStr(Proxy,"http:",Tempstr,NULL); - else Proxy=CopyStr(Proxy,Tempstr); + (strncasecmp(ptr,"http:",5) !=0) && + (strncasecmp(ptr,"https:",6) !=0) + ) Settings.Proxy=MCopyStr(Settings.Proxy,"http:",ptr,NULL); + else Settings.Proxy=CopyStr(Settings.Proxy,ptr); + return; } -else + +ptr=getenv("ssh_tunnel"); +if (StrValid(ptr)) { - Tempstr=CopyStr(Tempstr,getenv("ssh_tunnel")); - if (StrLen(Tempstr)) - { - if (strncasecmp(Tempstr,"sshtunnel:",10)==0) Proxy=CopyStr(Proxy,Tempstr); - else if (strncasecmp(Tempstr,"ssh:",4)==0) Proxy=MCopyStr(Proxy,"sshtunnel:",Tempstr+4,NULL); - else Proxy=MCopyStr(Proxy,"sshtunnel:",Tempstr,NULL); - } + if (strncasecmp(ptr,"sshtunnel:",10)==0) Settings.Proxy=CopyStr(Settings.Proxy,ptr); + else if (strncasecmp(ptr,"ssh:",4)==0) Settings.Proxy=MCopyStr(Settings.Proxy,"sshtunnel:",ptr+4,NULL); + else Settings.Proxy=MCopyStr(Settings.Proxy,"sshtunnel:",ptr,NULL); } -DestroyString(Tempstr); +} + +void ParseEnvironmentVariables() +{ +const char *ptr; + +ParseEnvironmentProxy(); + +ptr=getenv("SSL_CIPHERS"); +if (StrValid(ptr)) LibUsefulSetValue("SSL-Permitted-Ciphers", ptr); + +ptr=getenv("SSL_LEVEL"); +if (StrValid(ptr)) LibUsefulSetValue("SSL-Level", ptr); + +ptr=getenv("MOVGRAB_FORMATS"); +if (StrValid(ptr)) Settings.FormatPreference=CopyStr(Settings.FormatPreference,ptr); } diff --git a/settings.h b/settings.h index ab9cd57..5b7d791 100644 --- a/settings.h +++ b/settings.h @@ -3,12 +3,32 @@ #include "common.h" +typedef struct +{ +int Flags; +int DebugLevel; +char *UserAgent; +char *Proxy; +char *Username; +char *Password; +char *FormatPreference; +char *ItemSelectArg; +int DisplayTitleWidth; +char *NowPlayingFile; +int STREAMTimeout; +int PlayerLaunchPercent; +} TSettings; + +extern TSettings Settings; + +void InitSettings(); void PrintVersion(); void PrintUsage(); -int ParseType(char *Type); -void ParseCommandLine(int argc, char *argv[], ListNode *DL_List, int *OverrideType); void CheckSettings(); +int ParseType(char *Type); void ParseEnvironmentVariables(); +int ParsePreferencesFile(const char *Path); +void ParseCommandLine(int argc, char *argv[], ListNode *DL_List, int *OverrideType); #endif diff --git a/youtube.c b/youtube.c index e399d1b..b3f94b1 100755 --- a/youtube.c +++ b/youtube.c @@ -32,7 +32,7 @@ char *Extra=NULL; ptr=GetNameValuePair(Data,"&","=",&Name,&Value); while (ptr) { - if (StrLen(Name)) + if (StrValid(Name)) { if (strcmp(Name,"sig")==0) Extra=MCatStr(Extra,"&signature=", Value, NULL); if (strcmp(Name,"fallback_host")==0) Extra=MCatStr(Extra,"&fallback_host=", Value, NULL); @@ -158,7 +158,7 @@ while (ptr) default: // if (! Flags & FLAG_QUIET) - if (StrLen(ptr)) fprintf(stderr,"Unknown youtube format [%s]\n",Token); + if (StrValid(ptr)) fprintf(stderr,"Unknown youtube format [%s]\n",Token); break; } ptr=GetToken(ptr,",",&Token,0);