Monkey: Update for new HTTP auth API.

This commit is contained in:
Michael Drake 2018-08-13 17:52:44 +01:00 committed by Michael Drake
parent e41e558c5f
commit 97810d0c1a
2 changed files with 16 additions and 7 deletions

View File

@ -27,20 +27,23 @@ typedef struct monkey401 {
struct monkey401 *r_next, *r_prev; struct monkey401 *r_next, *r_prev;
uint32_t num; uint32_t num;
lwc_string *host; /* Ignore */ lwc_string *host; /* Ignore */
nserror (*cb)(bool,void*); nserror (*cb)(const char *, const char *, void *);
void *pw; void *pw;
} monkey401_t; } monkey401_t;
static monkey401_t *m4_ring = NULL; static monkey401_t *m4_ring = NULL;
static uint32_t m4_ctr = 0; static uint32_t m4_ctr = 0;
void gui_401login_open(nsurl *url, const char *realm, nserror gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw) const char *username, const char *password,
nserror (*cb)(const char *username,
const char *password,
void *pw),
void *cbpw)
{ {
monkey401_t *m4t = calloc(sizeof(*m4t), 1); monkey401_t *m4t = calloc(sizeof(*m4t), 1);
if (m4t == NULL) { if (m4t == NULL) {
cb(false, cbpw); return NSERROR_NOMEM;
return;
} }
m4t->cb = cb; m4t->cb = cb;
m4t->pw = cbpw; m4t->pw = cbpw;
@ -50,6 +53,8 @@ void gui_401login_open(nsurl *url, const char *realm,
fprintf(stdout, "401LOGIN OPEN M4 %u URL %s REALM %s\n", fprintf(stdout, "401LOGIN OPEN M4 %u URL %s REALM %s\n",
m4t->num, nsurl_access(url), realm); m4t->num, nsurl_access(url), realm);
return NSERROR_OK;
} }

View File

@ -5,5 +5,9 @@
#include "utils/errors.h" #include "utils/errors.h"
void gui_401login_open(nsurl *url, const char *realm, nserror gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw); const char *username, const char *password,
nserror (*cb)(const char *username,
const char *password,
void *pw),
void *cbpw);