summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-06-19 16:56:04 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2023-06-19 16:56:04 +0800
commit5cfe1b2c239353a72ce7975f2c542924c398c12e (patch)
treed90bdefabf127399e637d53ef5ed46ac18a8ec45
parent01894c3e6e7f3e0fb653bfccf54e511b4473cce1 (diff)
Login POST uncertain data is now checked first
so that we don't get a filled key but with a NULL value, that would terminate the construction loop too early.
-rw-r--r--login.h35
1 files changed, 25 insertions, 10 deletions
diff --git a/login.h b/login.h
index 3faa3e9..c5ca150 100644
--- a/login.h
+++ b/login.h
@@ -9,16 +9,31 @@ static inline void login(const char *username, const char *password,
void (*handler)(interchange_response *),
void (*callback)(void *))
{
- request(handler, callback, (const char *[][2]){
- "mv_username", username,
- "mv_password", password,
- "mv_click", click,
- "mv_nextpage", nextpage,
- "mv_successpage", successpage,
- "mv_failpage", failpage,
- "mv_verify", verify,
- NULL
- }, "%s", "process");
+ const char *body[(verify ? 1 : 0) + (successpage ? 1: 0)
+ + (failpage ? 1 : 0) + 5][2];
+ body[0][0] = "mv_username";
+ body[0][1] = username;
+ body[1][0] = "mv_password";
+ body[1][1] = password;
+ body[2][0] = "mv_click";
+ body[2][1] = click;
+ body[3][0] = "mv_nextpage";
+ body[3][1] = nextpage;
+ size_t i = 4;
+ if (successpage) {
+ body[i][0] = "mv_successpage";
+ body[i++][1] = successpage;
+ }
+ if (failpage) {
+ body[i][0] = "mv_failpage";
+ body[i++][1] = failpage;
+ }
+ if (verify) {
+ body[i][0] = "mv_verify";
+ body[i++][1] = verify;
+ }
+ body[i][0] = NULL;
+ request(handler, callback, body, "%s", "process");
}
#endif