mirror of
https://github.com/lxsang/ant-http
synced 2025-07-24 17:49:46 +02:00
ninor fix
This commit is contained in:
@ -27,7 +27,23 @@ void execute(int client,const char* method,dictionary rq)
|
||||
|
||||
void get(int client,const char* method,dictionary rq)
|
||||
{
|
||||
|
||||
html(client);
|
||||
if(rq)
|
||||
{
|
||||
dictionary ck = (dictionary)dvalue(rq,"cookie");
|
||||
if(ck)
|
||||
{
|
||||
association as;
|
||||
for_each_assoc(as, ck)
|
||||
{
|
||||
__t(client,"%s -> %s <br/>",as->key, as->value);
|
||||
}
|
||||
}
|
||||
else
|
||||
__t(client,"noo cookie");
|
||||
}
|
||||
else
|
||||
__t(client,"no request");
|
||||
|
||||
}
|
||||
void handler(int client, const char* method, const char* rqpth, dictionary rq)
|
||||
@ -36,6 +52,10 @@ void handler(int client, const char* method, const char* rqpth, dictionary rq)
|
||||
{
|
||||
execute(client,method,rq);
|
||||
}
|
||||
else if(EQU(rqpth,"get"))
|
||||
{
|
||||
get(client,method,rq);
|
||||
}
|
||||
else
|
||||
{
|
||||
unknow(client);
|
||||
|
@ -176,11 +176,13 @@ dbrecord dbselect(sqlite3* db, const char* table,const char* fstring,...)
|
||||
}
|
||||
int hastable(sqlite3* db,const char* table)
|
||||
{
|
||||
char * prefix = "select * from sqlite_master where type='table' and name='%s'";
|
||||
char* sql = __s(prefix,table);
|
||||
int ret = dbquery(db,sql,NULL);
|
||||
free(sql);
|
||||
return ~ret;
|
||||
char * prefix = __s("type='table' and name='%s'",table);
|
||||
dbrecord rc = dbselect(db,"sqlite_master",prefix);
|
||||
free(prefix);
|
||||
if(!rc) return 0;
|
||||
if(!rc->fields) return 0;
|
||||
free(rc);
|
||||
return 1;
|
||||
}
|
||||
int dbupdate(sqlite3* db,const char* table,const dbfield field,const char* fstring,...)
|
||||
{
|
||||
|
Binary file not shown.
@ -14,9 +14,9 @@ void __init_plugin__(const char* pl,const char*ph,const char* htdocs, const char
|
||||
};
|
||||
|
||||
#ifdef USE_DB
|
||||
sqldb getdb()
|
||||
sqldb __getdb(char *name)
|
||||
{
|
||||
int plen = strlen(__plugin__.name)+strlen(__plugin__.dbpath)+4;
|
||||
int plen = strlen(name)+strlen(__plugin__.dbpath)+4;
|
||||
char* path = (char*) malloc(plen*sizeof(char));
|
||||
strcpy(path,__plugin__.dbpath);
|
||||
strcat(path,__plugin__.name);
|
||||
@ -25,6 +25,10 @@ sqldb getdb()
|
||||
free(path);
|
||||
return ret;
|
||||
}
|
||||
sqldb getdb()
|
||||
{
|
||||
return getdb(__plugin__.name);
|
||||
}
|
||||
#endif
|
||||
void header_base(int client)
|
||||
{
|
||||
@ -243,6 +247,16 @@ void set_cookie(int client,dictionary dic)
|
||||
}
|
||||
response(client,"");
|
||||
}
|
||||
void clear_cookie(int client, dictionary dic)
|
||||
{
|
||||
header_base(client);
|
||||
__t(client,"Content-Type: text/html; charset=utf-8");
|
||||
association assoc;
|
||||
for_each_assoc(assoc,dic){
|
||||
__t(client,"Set-Cookie: %s=%s;expires=",assoc->key, (char*)assoc->value, server_time());
|
||||
}
|
||||
response(client,"");
|
||||
}
|
||||
char* config_dir()
|
||||
{
|
||||
struct stat st;
|
||||
|
@ -55,9 +55,10 @@ char* route(const char*);
|
||||
char* htdocs(const char*);
|
||||
#ifdef USE_DB
|
||||
sqldb getdb();
|
||||
sqldb __getdb(char *name);
|
||||
#endif
|
||||
void set_cookie(int,dictionary);
|
||||
|
||||
void clear_cookie(int, dictionary);
|
||||
/*Default function for plugin*/
|
||||
void handler(int, const char*,const char*,dictionary);
|
||||
void unknow(int);
|
||||
|
Binary file not shown.
@ -325,4 +325,9 @@ unsigned hash(const char* key, int hash_size)
|
||||
for (hashval = 0; *key != '\0'; key++)
|
||||
hashval = *key + 31 * hashval;
|
||||
return hashval % hash_size;
|
||||
}
|
||||
int is_file(const char* f)
|
||||
{
|
||||
struct stat st;
|
||||
return !(stat(f, &st) == -1);
|
||||
}
|
@ -80,4 +80,5 @@ char *url_encode(const char *str);
|
||||
char from_hex(char ch);
|
||||
char to_hex(char code);
|
||||
unsigned hash(const char*, int);
|
||||
int is_file(const char* f);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user