mirror of
https://github.com/lxsang/ant-http
synced 2025-07-15 05:19:55 +02:00
bug every where
This commit is contained in:
@ -8,7 +8,7 @@ void init()
|
||||
printf("Finish init\n");
|
||||
}
|
||||
|
||||
void execute(int client,const char* method,dictionary rq)
|
||||
void execute(void* client,const char* method,dictionary rq)
|
||||
{
|
||||
|
||||
/**
|
||||
@ -25,7 +25,7 @@ void execute(int client,const char* method,dictionary rq)
|
||||
freedict(d);
|
||||
}
|
||||
|
||||
void get(int client,const char* method,dictionary rq)
|
||||
void get(void* client,const char* method,dictionary rq)
|
||||
{
|
||||
html(client);
|
||||
if(rq)
|
||||
@ -46,7 +46,7 @@ void get(int client,const char* method,dictionary rq)
|
||||
__t(client,"no request");
|
||||
|
||||
}
|
||||
void handler(int client, const char* method, const char* rqpth, dictionary rq)
|
||||
void handler(void* client, const char* method, const char* rqpth, dictionary rq)
|
||||
{
|
||||
if(EQU(rqpth,"default"))
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ void pexit()
|
||||
{
|
||||
LOG("%s\n","Plugin DUMMY is exited");
|
||||
}
|
||||
void execute(int client,const char* method,dictionary rq)
|
||||
void execute(void* client,const char* method,dictionary rq)
|
||||
{
|
||||
|
||||
char * question;
|
||||
@ -56,7 +56,7 @@ void execute(int client,const char* method,dictionary rq)
|
||||
}
|
||||
|
||||
// delete record
|
||||
void delete(int client,const char* method,dictionary rq)
|
||||
void delete(void* client,const char* method,dictionary rq)
|
||||
{
|
||||
char* id = dvalue(rq,"id");
|
||||
html(client);
|
||||
@ -76,7 +76,7 @@ void delete(int client,const char* method,dictionary rq)
|
||||
}
|
||||
|
||||
}
|
||||
void update(int client,const char* method,dictionary rq)
|
||||
void update(void* client,const char* method,dictionary rq)
|
||||
{
|
||||
char * id;
|
||||
html(client);
|
||||
@ -121,14 +121,14 @@ void update(int client,const char* method,dictionary rq)
|
||||
}
|
||||
|
||||
|
||||
void jsonex(int client,const char* method,dictionary rq)
|
||||
void jsonex(void* client,const char* method,dictionary rq)
|
||||
{
|
||||
//json(client);
|
||||
//__t(client,"{name:\"%s\", age:%d}","Sang",30);
|
||||
jpeg(client);
|
||||
__f(client,htdocs("images/ex.jpg"));
|
||||
}
|
||||
void handler(int client, const char* method, const char* rqpth, dictionary rq)
|
||||
void handler(void* client, const char* method, const char* rqpth, dictionary rq)
|
||||
{
|
||||
if(EQU(rqpth,"default"))
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ char* folder_list_from(const char* aPath)
|
||||
return flist;
|
||||
}
|
||||
|
||||
void execute(int client,const char* method,dictionary rq)
|
||||
void execute(void* client,const char* method,dictionary rq)
|
||||
{
|
||||
DIR *d;
|
||||
struct dirent *dir;
|
||||
@ -96,7 +96,7 @@ void execute(int client,const char* method,dictionary rq)
|
||||
|
||||
}
|
||||
|
||||
void add(int c, const char* m, dictionary rq)
|
||||
void add(void* c, const char* m, dictionary rq)
|
||||
{
|
||||
json(c);
|
||||
if(IS_GET(m))
|
||||
@ -133,7 +133,7 @@ void add(int c, const char* m, dictionary rq)
|
||||
return;
|
||||
}
|
||||
|
||||
void mkfolder(int c, const char* m, dictionary rq)
|
||||
void mkfolder(void* c, const char* m, dictionary rq)
|
||||
{
|
||||
json(c);
|
||||
if(IS_GET(m))
|
||||
@ -161,7 +161,7 @@ void mkfolder(int c, const char* m, dictionary rq)
|
||||
__t(c,__RESULT__,1,"OK");
|
||||
}
|
||||
|
||||
void rmfolder(int c, const char* m, dictionary rq)
|
||||
void rmfolder(void* c, const char* m, dictionary rq)
|
||||
{
|
||||
json(c);
|
||||
if(IS_GET(m))
|
||||
@ -190,7 +190,7 @@ void pexit()
|
||||
{
|
||||
LOG("Exit file manager,plugins\n");
|
||||
}
|
||||
void handler(int client, const char* method, const char* rqpth, dictionary rq)
|
||||
void handler(void* client, const char* method, const char* rqpth, dictionary rq)
|
||||
{
|
||||
if(EQU(rqpth,"default"))
|
||||
{
|
||||
|
127
libs/handle.c
127
libs/handle.c
@ -1,33 +1,39 @@
|
||||
#include "handle.h"
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
int usessl()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void set_status(int client,int code,const char* msg)
|
||||
void set_status(void* client,int code,const char* msg)
|
||||
{
|
||||
response(client, __s("HTTP/1.1 %d %s", code, msg));
|
||||
response(client, __s("Server: %s ", SERVER_NAME));
|
||||
}
|
||||
void redirect(int client,const char*path)
|
||||
void redirect(void* client,const char*path)
|
||||
{
|
||||
__t(client,"<html><head><meta http-equiv=\"refresh\" content=\"0; url=%s\"></head><body></body></html>",path);
|
||||
}
|
||||
|
||||
void html(int client)
|
||||
void html(void* client)
|
||||
{
|
||||
ctype(client,"text/html; charset=utf-8");
|
||||
}
|
||||
void text(int client)
|
||||
void text(void* client)
|
||||
{
|
||||
ctype(client,"text/plain; charset=utf-8");
|
||||
}
|
||||
void json(int client)
|
||||
void json(void* client)
|
||||
{
|
||||
ctype(client,"application/json");
|
||||
}
|
||||
void textstream(int client)
|
||||
void textstream(void* client)
|
||||
{
|
||||
ctype(client, "text/event-stream");
|
||||
}
|
||||
void octstream(int client, char* name)
|
||||
void octstream(void* client, char* name)
|
||||
{
|
||||
set_status(client,200,"OK");
|
||||
__t(client,"Content-Type: application/octet-stream");
|
||||
@ -35,18 +41,18 @@ void octstream(int client, char* name)
|
||||
response(client,"");
|
||||
//Content-Disposition: attachment; filename="fname.ext"
|
||||
}
|
||||
void jpeg(int client)
|
||||
void jpeg(void* client)
|
||||
{
|
||||
ctype(client,"image/jpeg");
|
||||
}
|
||||
void ctype(int client, const char* type)
|
||||
void ctype(void* client, const char* type)
|
||||
{
|
||||
set_status(client,200,"OK");
|
||||
__t(client,"Content-Type: %s",type);
|
||||
response(client,"");
|
||||
}
|
||||
|
||||
int response(int client, const char* data)
|
||||
int response(void* client, const char* data)
|
||||
{
|
||||
char buf[BUFFLEN+3];
|
||||
strcpy(buf, data);
|
||||
@ -54,18 +60,66 @@ int response(int client, const char* data)
|
||||
int size = strlen(data);
|
||||
buf[size] = '\r';
|
||||
buf[size+1] = '\n';
|
||||
buf[size+2] = '\0';
|
||||
nbytes = send(client, buf, strlen(buf), 0);
|
||||
buf[size+2] = '\0';
|
||||
int _ssl = 0;
|
||||
#ifdef USE_OPENSSL
|
||||
_ssl = usessl();
|
||||
#endif
|
||||
nbytes = antd_send(client, buf, strlen(buf), _ssl);
|
||||
return (nbytes ==-1?0:1);
|
||||
}
|
||||
int __ti(int client,int data)
|
||||
int antd_send(const void *src, const void* data, int len, int _ssl)
|
||||
{
|
||||
antd_client_t * source = (antd_client_t *) src;
|
||||
#ifdef USE_OPENSSL
|
||||
if(_ssl)
|
||||
{
|
||||
return SSL_write((SSL*) source->ssl, data, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
return send(source->sock, data, len, 0);
|
||||
#ifdef USE_OPENSSL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
int antd_recv(const void *src, void* data, int len, int _ssl)
|
||||
{
|
||||
antd_client_t * source = (antd_client_t *) src;
|
||||
#ifdef USE_OPENSSL
|
||||
if(_ssl)
|
||||
{
|
||||
return SSL_read((SSL*) source->ssl, data, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
return recv(((int) source->sock), data, len, 0);
|
||||
#ifdef USE_OPENSSL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
int antd_close(void* src)
|
||||
{
|
||||
antd_client_t * source = (antd_client_t *) src;
|
||||
#ifdef USE_OPENSSL
|
||||
if(source->ssl && usessl()){
|
||||
SSL_free((SSL*) source->ssl);
|
||||
LOG("Freeing SSL\n");
|
||||
}
|
||||
#endif
|
||||
printf("Close sock %d\n", source->sock);
|
||||
close(source->sock);
|
||||
}
|
||||
int __ti(void* client,int data)
|
||||
{
|
||||
char str[15];
|
||||
sprintf(str, "%d", data);
|
||||
return response(client,str);
|
||||
}
|
||||
|
||||
int __t(int client, const char* fstring,...)
|
||||
int __t(void* client, const char* fstring,...)
|
||||
{
|
||||
int nbytes;
|
||||
int dlen;
|
||||
@ -77,6 +131,10 @@ int __t(int client, const char* fstring,...)
|
||||
va_start( arguments, fstring);
|
||||
dlen = vsnprintf(0,0,fstring,arguments) + 1;
|
||||
va_end(arguments);
|
||||
int _ssl = 0;
|
||||
#ifdef USE_OPENSSL
|
||||
_ssl = usessl();
|
||||
#endif
|
||||
if ((data = (char*)malloc(dlen*sizeof(char))) != 0)
|
||||
{
|
||||
va_start(arguments, fstring);
|
||||
@ -99,27 +157,31 @@ int __t(int client, const char* fstring,...)
|
||||
//chunk[buflen-1] = '\0';
|
||||
//response(client,chunk);
|
||||
sent += buflen;
|
||||
nbytes = send(client, chunk, buflen, 0);
|
||||
nbytes = antd_send(client, chunk, buflen, _ssl);
|
||||
free(chunk);
|
||||
if(nbytes == -1) return 0;
|
||||
}
|
||||
chunk = "\r\n";
|
||||
send(client, chunk, strlen(chunk), 0);
|
||||
antd_send(client, chunk, strlen(chunk), _ssl);
|
||||
}
|
||||
free(data);
|
||||
}
|
||||
return 1;
|
||||
//
|
||||
}
|
||||
int __b(int client, const unsigned char* data, int size)
|
||||
int __b(void* client, const unsigned char* data, int size)
|
||||
{
|
||||
char buf[BUFFLEN];
|
||||
int sent = 0;
|
||||
int buflen = 0;
|
||||
int nbytes;
|
||||
int _ssl = 0;
|
||||
#ifdef USE_OPENSSL
|
||||
_ssl = usessl();
|
||||
#endif
|
||||
if(size <= BUFFLEN)
|
||||
{
|
||||
nbytes = send(client,data,size,0);
|
||||
nbytes = antd_send(client,data,size,_ssl);
|
||||
return (nbytes==-1?0:1);
|
||||
}
|
||||
else
|
||||
@ -131,14 +193,14 @@ int __b(int client, const unsigned char* data, int size)
|
||||
else
|
||||
buflen = size - sent;
|
||||
memcpy(buf,data+sent,buflen);
|
||||
nbytes = send(client,buf,buflen,0);
|
||||
nbytes = antd_send(client,buf,buflen,_ssl);
|
||||
sent += buflen;
|
||||
if(nbytes == -1) return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int __fb(int client, const char* file)
|
||||
int __fb(void* client, const char* file)
|
||||
{
|
||||
printf("Open file %s\n",file );
|
||||
unsigned char buffer[BUFFLEN];
|
||||
@ -158,7 +220,7 @@ int __fb(int client, const char* file)
|
||||
fclose(ptr);
|
||||
return 1;
|
||||
}
|
||||
int __f(int client, const char* file)
|
||||
int __f(void* client, const char* file)
|
||||
{
|
||||
unsigned char buf[BUFFLEN];
|
||||
FILE *ptr;
|
||||
@ -169,10 +231,13 @@ int __f(int client, const char* file)
|
||||
LOG("Cannot read : %s\n", file);
|
||||
return 0;
|
||||
}
|
||||
;
|
||||
int _ssl = 0;
|
||||
#ifdef USE_OPENSSL
|
||||
_ssl = usessl();
|
||||
#endif
|
||||
while(fgets(buf, sizeof(buf), ptr) != NULL)
|
||||
{
|
||||
nbytes = send(client, buf, strlen(buf), 0);
|
||||
nbytes = antd_send(client, buf, strlen(buf), _ssl);
|
||||
if(nbytes == -1) return 0;
|
||||
//LOG("READ : %s\n", buf);
|
||||
//fgets(buf, sizeof(buf), ptr);
|
||||
@ -186,7 +251,7 @@ int upload(const char* tmp, const char* path)
|
||||
return !rename(tmp, path);
|
||||
}
|
||||
// __plugin__.name
|
||||
void set_cookie(int client,const char* type, dictionary dic, const char* name)
|
||||
void set_cookie(void* client,const char* type, dictionary dic, const char* name)
|
||||
{
|
||||
set_status(client,200,"OK");
|
||||
__t(client,"Content-Type: %s",type);
|
||||
@ -196,7 +261,7 @@ void set_cookie(int client,const char* type, dictionary dic, const char* name)
|
||||
}
|
||||
response(client,"");
|
||||
}
|
||||
void clear_cookie(int client, dictionary dic)
|
||||
void clear_cookie(void* client, dictionary dic)
|
||||
{
|
||||
set_status(client,200,"OK");
|
||||
__t(client,"Content-Type: text/html; charset=utf-8");
|
||||
@ -206,7 +271,7 @@ void clear_cookie(int client, dictionary dic)
|
||||
}
|
||||
response(client,"");
|
||||
}
|
||||
void unknow(int client)
|
||||
void unknow(void* client)
|
||||
{
|
||||
html(client);
|
||||
__t(client,"404 API not found");
|
||||
@ -220,7 +285,7 @@ int ws_enable(dictionary dic)
|
||||
* @param sock socket
|
||||
* @return a request string
|
||||
*/
|
||||
char* read_line(int sock)
|
||||
char* read_line(void* sock)
|
||||
{
|
||||
char buf[BUFFLEN];
|
||||
read_buf(sock,buf,sizeof(buf));
|
||||
@ -235,14 +300,18 @@ char* read_line(int sock)
|
||||
* @param size size of buffer
|
||||
* @return number of bytes read
|
||||
*/
|
||||
int read_buf(int sock, char*buf,int size)
|
||||
int read_buf(void* sock, char*buf,int size)
|
||||
{
|
||||
int i = 0;
|
||||
char c = '\0';
|
||||
int n;
|
||||
int _ssl = 0;
|
||||
#ifdef USE_OPENSSL
|
||||
_ssl = usessl();
|
||||
#endif
|
||||
while ((i < size - 1) && (c != '\n'))
|
||||
{
|
||||
n = recv(sock, &c, 1, 0);
|
||||
n = antd_recv(sock, &c, 1, _ssl);
|
||||
if (n > 0)
|
||||
{
|
||||
buf[i] = c;
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
//open ssl
|
||||
#ifdef USE_OPENSSL
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#endif
|
||||
#ifdef USE_DB
|
||||
#include "dbhelper.h"
|
||||
#endif
|
||||
@ -20,30 +25,56 @@
|
||||
#define __RESULT__ "{\"result\":%d,\"msg\":\"%s\"}"
|
||||
|
||||
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
int __attribute__((weak)) usessl();
|
||||
#endif
|
||||
|
||||
int response(int, const char*);
|
||||
void ctype(int,const char*);
|
||||
void redirect(int,const char*);
|
||||
void html(int);
|
||||
void text(int);
|
||||
void json(int);
|
||||
void jpeg(int);
|
||||
void octstream(int, char*);
|
||||
void textstream(int);
|
||||
int __ti(int,int);
|
||||
int __t(int, const char*,...);
|
||||
int __b(int, const unsigned char*, int);
|
||||
int __f(int, const char*);
|
||||
int __fb(int, const char*);
|
||||
typedef struct {
|
||||
int port;
|
||||
char *plugins_dir;
|
||||
char *plugins_ext;
|
||||
char *db_path;
|
||||
char* htdocs;
|
||||
char* tmpdir;
|
||||
dictionary rules;
|
||||
int backlog;
|
||||
#ifdef USE_OPENSSL
|
||||
int usessl;
|
||||
char* sslcert;
|
||||
char* sslkey;
|
||||
#endif
|
||||
}config_t;
|
||||
|
||||
typedef struct{
|
||||
int sock;
|
||||
void* ssl;
|
||||
} antd_client_t;
|
||||
|
||||
int response(void*, const char*);
|
||||
void ctype(void*,const char*);
|
||||
void redirect(void*,const char*);
|
||||
void html(void*);
|
||||
void text(void*);
|
||||
void json(void*);
|
||||
void jpeg(void*);
|
||||
void octstream(void*, char*);
|
||||
void textstream(void*);
|
||||
int __ti(void*,int);
|
||||
int __t(void*, const char*,...);
|
||||
int __b(void*, const unsigned char*, int);
|
||||
int __f(void*, const char*);
|
||||
int __fb(void*, const char*);
|
||||
int upload(const char*, const char*);
|
||||
|
||||
void set_cookie(int, const char*,dictionary,const char*);
|
||||
void set_status(int,int,const char*);
|
||||
void clear_cookie(int, dictionary);
|
||||
void set_cookie(void*, const char*,dictionary,const char*);
|
||||
void set_status(void*,int,const char*);
|
||||
void clear_cookie(void*, dictionary);
|
||||
/*Default function for plugin*/
|
||||
void unknow(int);
|
||||
void unknow(void*);
|
||||
int ws_enable(dictionary);
|
||||
char* read_line(int sock);
|
||||
int read_buf(int sock,char* buf,int i);
|
||||
char* read_line(void* sock);
|
||||
int read_buf(void* sock,char* buf,int i);
|
||||
int antd_send(const void *source, const void* data, int len, int usessl);
|
||||
int antd_recv(const void *source, void* data, int len, int usessl);
|
||||
int antd_close(void* source);
|
||||
#endif
|
||||
|
@ -101,7 +101,7 @@ void pexit()
|
||||
{
|
||||
LOG("%s","EXIT daemon");
|
||||
}
|
||||
void handler(int c, const char* m, const char* rqp, dictionary d)
|
||||
void handler(void* c, const char* m, const char* rqp, dictionary d)
|
||||
{
|
||||
text(c);
|
||||
__t(c,"This is a system plugin. It cant be acessed from the web");
|
||||
|
@ -3,13 +3,15 @@
|
||||
plugin_header __plugin__;
|
||||
// private function
|
||||
call __init__;
|
||||
|
||||
void __init_plugin__(const char* pl,const char*ph,const char* htdocs, const char* pdir,int port){
|
||||
void __init_plugin__(const char* pl,config_t* conf){
|
||||
__plugin__.name = strdup(pl);
|
||||
__plugin__.dbpath= strdup(ph);
|
||||
__plugin__.htdocs = strdup(htdocs);
|
||||
__plugin__.pdir = strdup(pdir);
|
||||
__plugin__.sport = port;
|
||||
__plugin__.dbpath= strdup(conf->db_path);
|
||||
__plugin__.htdocs = strdup(conf->htdocs);
|
||||
__plugin__.pdir = strdup(conf->plugins_dir);
|
||||
__plugin__.sport = conf->port;
|
||||
#ifdef USE_OPENSSL
|
||||
__plugin__.usessl = conf->usessl;
|
||||
#endif
|
||||
if(__init__ != NULL) __init__();
|
||||
};
|
||||
|
||||
@ -32,6 +34,13 @@ sqldb getdb()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
int usessl()
|
||||
{
|
||||
return __plugin__.usessl;
|
||||
}
|
||||
#endif
|
||||
|
||||
char* route(const char* repath)
|
||||
{
|
||||
int len = strlen(__plugin__.name) + 2;
|
||||
|
@ -12,6 +12,9 @@ typedef struct {
|
||||
char * htdocs;
|
||||
char*pdir;
|
||||
int sport;
|
||||
#ifdef USE_OPENSSL
|
||||
int usessl;
|
||||
#endif
|
||||
} plugin_header;
|
||||
|
||||
|
||||
@ -33,6 +36,6 @@ char* route(const char*);
|
||||
char* htdocs(const char*);
|
||||
char* config_dir();
|
||||
/*Default function for plugin*/
|
||||
void handler(int, const char*,const char*,dictionary);
|
||||
void handler(void*, const char*,const char*,dictionary);
|
||||
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define PEXT "dylib"
|
||||
#define MAXSIZE 500000
|
||||
|
||||
void execute(int client,const char* method,dictionary rq)
|
||||
void execute(void* client,const char* method,dictionary rq)
|
||||
{
|
||||
//all plugin file
|
||||
DIR *d;
|
||||
@ -36,7 +36,7 @@ void execute(int client,const char* method,dictionary rq)
|
||||
|
||||
}
|
||||
|
||||
void install(int c, const char* m, dictionary rq)
|
||||
void install(void* c, const char* m, dictionary rq)
|
||||
{
|
||||
char * result = "{\"result\":%d,\"msg\":\"%s\"}";
|
||||
json(c);
|
||||
@ -74,7 +74,7 @@ void install(int c, const char* m, dictionary rq)
|
||||
|
||||
__t(c,result,0,"This is not a plugin file");
|
||||
}
|
||||
void handler(int client, const char* method, const char* rqpth, dictionary rq)
|
||||
void handler(void* client, const char* method, const char* rqpth, dictionary rq)
|
||||
{
|
||||
if(EQU(rqpth,"default"))
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ void pexit()
|
||||
{
|
||||
|
||||
}
|
||||
void handler(int cl, const char* m, const char* rqp, dictionary rq)
|
||||
void handler(void* cl, const char* m, const char* rqp, dictionary rq)
|
||||
{
|
||||
//html(cl);
|
||||
ws_msg_header_t* h = NULL;
|
||||
|
@ -218,7 +218,7 @@ void SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len)
|
||||
|
||||
|
||||
/* Add padding and return the message digest. */
|
||||
void SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE])
|
||||
void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX* context)
|
||||
{
|
||||
uint32_t i;
|
||||
uint8_t finalcount[8];
|
||||
|
@ -18,6 +18,6 @@ typedef struct {
|
||||
|
||||
void SHA1_Init(SHA1_CTX* context);
|
||||
void SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len);
|
||||
void SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]);
|
||||
void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX* context);
|
||||
void digest_to_hex(const uint8_t digest[SHA1_DIGEST_SIZE], char *output);
|
||||
#endif /* __SHA1_H */
|
14
libs/utils.c
14
libs/utils.c
@ -444,9 +444,13 @@ void md5(uint8_t *initial_msg, size_t initial_len, char* buff) {
|
||||
void sha1(const char* text, char* out)
|
||||
{
|
||||
uint8_t d [20];
|
||||
SHA1_CTX context;
|
||||
SHA1_Init(&context);
|
||||
SHA1_Update(&context, text, strlen(text));
|
||||
SHA1_Final(&context, d);
|
||||
digest_to_hex(d,out);
|
||||
#ifdef USE_OPENSSL
|
||||
SHA_CTX context;
|
||||
#else
|
||||
SHA1_CTX context;
|
||||
#endif
|
||||
SHA1_Init(&context);
|
||||
SHA1_Update(&context, text, strlen(text));
|
||||
SHA1_Final(d, &context);
|
||||
digest_to_hex(d,out);
|
||||
}
|
@ -36,7 +36,11 @@ THE SOFTWARE.
|
||||
#include <regex.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#ifdef USE_OPENSSL
|
||||
#include <openssl/sha.h>
|
||||
#else
|
||||
#include "sha1.h"
|
||||
#endif
|
||||
#include "base64.h"
|
||||
|
||||
#define LEFTROTATE(x, c) (((x) << (c)) | ((x) >> (32 - (c))))
|
||||
|
@ -6,7 +6,7 @@ void pexit()
|
||||
{
|
||||
|
||||
}
|
||||
void handler(int cl, const char* m, const char* rqp, dictionary rq)
|
||||
void handler(void* cl, const char* m, const char* rqp, dictionary rq)
|
||||
{
|
||||
char* path = NULL;
|
||||
int nimg = 19;
|
||||
|
@ -13,7 +13,7 @@ void pexit()
|
||||
{
|
||||
|
||||
}
|
||||
void handler(int cl, const char* m, const char* rqp, dictionary rq)
|
||||
void handler(void* cl, const char* m, const char* rqp, dictionary rq)
|
||||
{
|
||||
ws_msg_header_t* h = NULL;
|
||||
if(ws_enable(rq))
|
||||
|
Reference in New Issue
Block a user