#include <string.h>
struct ms_db* mandshurica_db_open(const char* path) {
-
FILE* fp = fopen(path, "r+b");
if(fp != NULL) {
struct ms_db* db = malloc(sizeof(*db));
/* key:value */
char* mandshurica_db_get(struct ms_db* db, const char* key) {
+ flockfile(db->fp);
fseek(db->fp, 0, SEEK_SET);
char cbuf[2];
cbuf[1] = 0;
}
}
free(line);
+ funlockfile(db->fp);
return NULL;
}
return 0;
}
-int mod_auth(const char* username, const char* password) {
+int mod_auth(const char* username, const char* password, void** ptr) {
+ *ptr = NULL;
struct ms_db* db = mandshurica_db_open(config->mandshurica_get_param("CookieDB"));
if(db != NULL) {
char* pwd = mandshurica_db_get(db, username);
const char* httppath = (const char*)dlsym((*config->libs)[j]->lib, "mod_http_path");
if(httppath != NULL) {
if(strcmp(httppath, path) == 0) {
- int (*mod_auth)(const char*, const char*) = (int (*)(const char*, const char*))dlsym((*config->libs)[j]->lib, "mod_auth");
+ int (*mod_auth)(const char*, const char*, void**) = (int (*)(const char*, const char*, void**))dlsym((*config->libs)[j]->lib, "mod_auth");
char* usr = mandshurica_parse_form(postbuf, "username");
char* pwd = mandshurica_parse_form(postbuf, "password");
if(usr != NULL && pwd != NULL) {
- int res = mod_auth(usr, pwd);
+ void* ptr;
+ int res = mod_auth(usr, pwd, &ptr);
if(res == MS_AUTH_OK) {
+ printf("%llx\n", ptr);
char* type;
uint64_t len;
char* data = NULL;