Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lopul authored Apr 25, 2021
1 parent 9c55cf3 commit 5889c04
Showing 1 changed file with 20 additions and 39 deletions.
59 changes: 20 additions & 39 deletions memorysurfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@
#include <errno.h>

enum Field { F_UNKNOWN, F_FILENAME, F_FILE_TITLE, F_START_ACTION, F_FILE_ACTION, F_ARRANGE, F_CAT_NAME, F_MOVED_CAT, F_EDIT_ACTION, F_LEARN_ACTION, F_SEARCH_TXT, F_MATCH_CASE, F_IS_HTML, F_SEARCH_ACTION, F_CAT, F_CARD, F_MOV_CARD, F_LVL, F_Q, F_A, F_REVEAL_POS, F_TODO_MAIN, F_TODO_ALT, F_MTIME, F_PASSWORD, F_NEW_PASSWORD, F_TOKEN, F_EVENT, F_PAGE, F_MODE, F_TIMEOUT };
enum Action { A_END, A_NONE, A_FILE, A_WARN_UPLOAD, A_CREATE, A_NEW, A_OPEN_DLG, A_FILELIST, A_OPEN, A_CHANGE_PASSWD, A_WRITE_PASSWD, A_READ_PASSWD, A_CHECK_PASSWORD, A_AUTH_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_LOAD_CARDLIST, A_CHECK_RESUME, A_SLASH, A_VOID, A_FILE_EXTENSION, A_GATHER, A_UPLOAD, A_UPLOAD_REPORT, A_EXPORT, A_ASK_REMOVE, A_REMOVE, A_ASK_ERASE, A_ERASE, A_CLOSE, A_START_DECKS, A_DECKS_CREATE, A_SELECT_CREATE_CAT, A_SELECT_CAT, A_SELECT_DEST_DECK, A_SELECT_SEND_CAT, A_SELECT_ARRANGE, A_CAT_NAME, A_CREATE_CAT, A_RENAME_CAT, A_ASK_DELETE_CAT, A_DELETE_CAT, A_TOGGLE, A_MOVE_CAT, A_SELECT_EDIT_CAT, A_EDIT, A_UPDATE_QA, A_UPDATE_HTML, A_SYNC, A_INSERT, A_APPEND, A_ASK_DELETE_CARD, A_DELETE_CARD, A_PREVIOUS, A_NEXT, A_SCHEDULE, A_SET, A_CARD_ARRANGE, A_MOVE_CARD, A_SEND_CARD, A_SELECT_LEARN_CAT, A_SELECT_SEARCH_CAT, A_PREFERENCES, A_ABOUT, A_APPLY, A_SEARCH, A_PREVIEW, A_QUESTION, A_SHOW, A_REVEAL, A_PROCEED, A_SUSPEND, A_RESUME, A_CHECK_FILE, A_LOGIN, A_HISTOGRAM, A_TABLE, A_RETRIEVE_MTIME, A_MTIME_TEST, A_CARD_TEST, A_TEST_CAT_SELECTED, A_TEST_CAT_VALID, A_TEST_CAT };
enum Action { A_END, A_NONE, A_FILE, A_WARN_UPLOAD, A_CREATE, A_NEW, A_OPEN_DLG, A_FILELIST, A_OPEN, A_CHANGE_PASSWD, A_WRITE_PASSWD, A_READ_PASSWD, A_CHECK_PASSWORD, A_AUTH_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_LOAD_CARDLIST, A_CHECK_RESUME, A_SLASH, A_VOID, A_FILE_EXTENSION, A_GATHER, A_UPLOAD, A_UPLOAD_REPORT, A_EXPORT, A_ASK_REMOVE, A_REMOVE, A_ASK_ERASE, A_ERASE, A_CLOSE, A_START_DECKS, A_DECKS_CREATE, A_SELECT_CAT, A_SELECT_DEST_DECK, A_SELECT_SEND_CAT, A_SELECT_ARRANGE, A_CAT_NAME, A_CREATE_CAT, A_RENAME_CAT, A_ASK_DELETE_CAT, A_DELETE_CAT, A_TOGGLE, A_MOVE_CAT, A_SELECT_EDIT_CAT, A_EDIT, A_UPDATE_QA, A_UPDATE_HTML, A_SYNC, A_INSERT, A_APPEND, A_ASK_DELETE_CARD, A_DELETE_CARD, A_PREVIOUS, A_NEXT, A_SCHEDULE, A_SET, A_CARD_ARRANGE, A_MOVE_CARD, A_SEND_CARD, A_SELECT_LEARN_CAT, A_SELECT_SEARCH_CAT, A_PREFERENCES, A_ABOUT, A_APPLY, A_SEARCH, A_PREVIEW, A_QUESTION, A_SHOW, A_REVEAL, A_PROCEED, A_SUSPEND, A_RESUME, A_CHECK_FILE, A_LOGIN, A_HISTOGRAM, A_TABLE, A_RETRIEVE_MTIME, A_MTIME_TEST, A_CARD_TEST, A_TEST_CAT_SELECTED, A_TEST_CAT_VALID, A_TEST_CAT };
enum Page { P_START, P_FILE, P_PASSWORD, P_NEW, P_OPEN, P_UPLOAD, P_UPLOAD_REPORT, P_EXPORT, P_CAT_NAME, P_SELECT_CAT, P_SELECT_ARRANGE, P_SELECT_DEST_DECK, P_SELECT_DECK, P_EDIT, P_PREVIEW, P_SEARCH, P_PREFERENCES, P_ABOUT, P_LEARN, P_MSG, P_HISTOGRAM, P_TABLE };
enum Block { B_END, B_START_HTML, B_HIDDEN_CAT, B_HIDDEN_ARRANGE, B_HIDDEN_CAT_NAME, B_HIDDEN_SEARCH_TXT, B_HIDDEN_MOV_CARD, B_CLOSE_DIV, B_START, B_FILE, B_PASSWORD, B_NEW, B_OPEN, B_UPLOAD, B_UPLOAD_REPORT, B_EXPORT, B_CAT_NAME, B_SELECT_CAT, B_SELECT_ARRANGE, B_SELECT_DEST_DECK, B_SELECT_DECK, B_EDIT, B_PREVIEW, B_SEARCH, B_PREFERENCES, B_ABOUT, B_LEARN, B_MSG, B_HISTOGRAM, B_TABLE };
enum Mode { M_NONE = -1, M_DEFAULT, M_CHANGE_PASSWD, M_ASK, M_RATE, M_EDIT, M_LEARN, M_SEARCH, M_SEND, M_MOVE, M_CARD, M_DECK, M_START, M_CREATE, M_END };
enum Sequence { S_FILE, S_START_DECKS, S_DECKS_CREATE, S_SELECT_CREATE_CAT, S_SELECT_ARRANGE, S_SELECT_MOVE_ARRANGE, S_CAT_NAME, S_SELECT_EDIT_CAT, S_SELECT_LEARN_CAT, S_SELECT_SEARCH_CAT, S_PREFERENCES, S_ABOUT, S_APPLY, S_NEW, S_FILELIST, S_WARN_UPLOAD, S_UPLOAD, S_LOGIN, S_ENTER, S_CHANGE, S_START, S_UPLOAD_REPORT, S_EXPORT, S_ASK_REMOVE, S_REMOVE, S_ASK_ERASE, S_ERASE, S_CLOSE, S_NONE, S_CREATE, S_GO_LOGIN, S_GO_CHANGE, S_SELECT_RENAME_CAT, S_RENAME_ENTER, S_RENAME_CAT, S_SELECT_MOVE_CAT, S_SELECT_DEST_CAT, S_MOVE_CAT, S_CREATE_CAT, S_SELECT_DELETE_CAT, S_ASK_DELETE_CAT, S_DELETE_CAT, S_SELECT_TOGGLE_CAT, S_TOGGLE, S_EDIT, S_INSERT, S_APPEND, S_ASK_DELETE_CARD, S_DELETE_CARD, S_PREVIOUS, S_NEXT, S_SCHEDULE, S_SET, S_CARD_ARRANGE, S_MOVE_CARD, S_SELECT_SEND_CAT, S_SEND_CARD, S_SEARCH_SYNCED, S_PREVIEW_SYNC, S_QUESTION_SYNCED, S_QUESTION, S_SHOW, S_REVEAL, S_PROCEED, S_SUSPEND, S_RESUME, S_SEARCH, S_HISTOGRAM, S_TABLE, S_END };
enum Mode { M_NONE = -1, M_DEFAULT, M_CHANGE_PASSWD, M_ASK, M_RATE, M_EDIT, M_LEARN, M_SEARCH, M_SEND, M_MOVE, M_CARD, M_DECK, M_START, M_END };
enum Sequence { S_FILE, S_START_DECKS, S_DECKS_CREATE, S_SELECT_ARRANGE, S_SELECT_MOVE_ARRANGE, S_CAT_NAME, S_SELECT_EDIT_CAT, S_SELECT_LEARN_CAT, S_SELECT_SEARCH_CAT, S_PREFERENCES, S_ABOUT, S_APPLY, S_NEW, S_FILELIST, S_WARN_UPLOAD, S_UPLOAD, S_LOGIN, S_ENTER, S_CHANGE, S_START, S_UPLOAD_REPORT, S_EXPORT, S_ASK_REMOVE, S_REMOVE, S_ASK_ERASE, S_ERASE, S_CLOSE, S_NONE, S_CREATE, S_GO_LOGIN, S_GO_CHANGE, S_SELECT_RENAME_CAT, S_RENAME_ENTER, S_RENAME_CAT, S_SELECT_DEST_CAT, S_MOVE_CAT, S_CREATE_CAT, S_SELECT_DELETE_CAT, S_ASK_DELETE_CAT, S_DELETE_CAT, S_SELECT_TOGGLE_CAT, S_TOGGLE, S_EDIT, S_INSERT, S_APPEND, S_ASK_DELETE_CARD, S_DELETE_CARD, S_PREVIOUS, S_NEXT, S_SCHEDULE, S_SET, S_CARD_ARRANGE, S_MOVE_CARD, S_SELECT_SEND_CAT, S_SEND_CARD, S_SEARCH_SYNCED, S_PREVIEW_SYNC, S_QUESTION_SYNCED, S_QUESTION, S_SHOW, S_REVEAL, S_PROCEED, S_SUSPEND, S_RESUME, S_SEARCH, S_HISTOGRAM, S_TABLE, S_END };
enum Stage { T_NULL, T_URLENCODE, T_BOUNDARY_INIT, T_CONTENT, T_NAME, T_BOUNDARY_BEGIN, T_BOUNDARY_CHECK };

static enum Action action_seq[S_END+1][14] = {
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_FILELIST, A_FILE, A_END }, // S_FILE
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_START_DECKS, A_END }, // S_START_DECKS
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_RETRIEVE_MTIME, A_MTIME_TEST, A_TEST_CAT_SELECTED, A_DECKS_CREATE, A_END }, // S_DECKS_CREATE
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_SELECT_CREATE_CAT, A_END }, // S_SELECT_CREATE_CAT
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_RETRIEVE_MTIME, A_MTIME_TEST, A_TEST_CAT, A_DECKS_CREATE, A_END }, // S_DECKS_CREATE
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_TEST_CAT, A_SELECT_ARRANGE, A_END }, // S_SELECT_ARRANGE
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_RETRIEVE_MTIME, A_MTIME_TEST, A_TEST_CAT_SELECTED, A_SELECT_ARRANGE, A_END }, // S_SELECT_MOVE_ARRANGE
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_CAT_NAME, A_END }, // S_CAT_NAME
Expand Down Expand Up @@ -80,7 +79,6 @@ static enum Action action_seq[S_END+1][14] = {
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_SELECT_CAT, A_END }, // S_SELECT_RENAME_CAT
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_RETRIEVE_MTIME, A_MTIME_TEST, A_TEST_CAT_SELECTED, A_CAT_NAME, A_END }, // S_RENAME_ENTER
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_RETRIEVE_MTIME, A_MTIME_TEST, A_RENAME_CAT, A_END }, // S_RENAME_CAT
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_SELECT_CAT, A_END }, // S_SELECT_MOVE_CAT
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_RETRIEVE_MTIME, A_MTIME_TEST, A_TEST_CAT, A_SELECT_DEST_DECK, A_END }, // S_SELECT_DEST_CAT
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_RETRIEVE_MTIME, A_MTIME_TEST, A_MOVE_CAT, A_END }, // S_MOVE_CAT
{ A_GATHER, A_OPEN, A_READ_PASSWD, A_AUTH_TOK, A_GEN_TOK, A_TEST_CAT, A_CREATE_CAT, A_END }, // S_CREATE_CAT
Expand Down Expand Up @@ -2824,15 +2822,9 @@ static int gen_html(struct WebMemorySurfer *wms) {
break;
case B_SELECT_CAT:
assert(wms->file_title_str != NULL && strlen(wms->tok_str) == 40);
if (wms->seq == S_SELECT_CREATE_CAT) {
notice_str[0] = "where to create the new category to";
submit_str = "Select";
} else if (wms->seq == S_SELECT_RENAME_CAT) {
if (wms->seq == S_SELECT_RENAME_CAT) {
notice_str[0] = "to rename";
submit_str = "Rename";
} else if (wms->seq == S_SELECT_MOVE_CAT) {
notice_str[0] = "to move";
submit_str = "Move";
} else if (wms->seq == S_SELECT_DELETE_CAT) {
notice_str[0] = "to delete";
submit_str = "Delete";
Expand Down Expand Up @@ -2903,7 +2895,7 @@ static int gen_html(struct WebMemorySurfer *wms) {
break;
case B_CAT_NAME:
assert(wms->file_title_str != NULL && strlen(wms->tok_str) == 40);
if (wms->seq == S_SELECT_CREATE_CAT || wms->seq == S_CAT_NAME || wms->seq == S_DECKS_CREATE) {
if (wms->seq == S_CAT_NAME || wms->seq == S_DECKS_CREATE) {
header_str = "Enter the name of the deck to create.";
text_str = wms->ms.cat_name != NULL ? wms->ms.cat_name : "new deck name";
submit_str = "Create";
Expand Down Expand Up @@ -3203,7 +3195,7 @@ static int gen_html(struct WebMemorySurfer *wms) {
sw_info_str);
break;
case B_ABOUT:
rv = printf("\t\t\t<h1 class=\"msf\">About MemorySurfer v1.0.1.55</h1>\n"
rv = printf("\t\t\t<h1 class=\"msf\">About MemorySurfer v1.0.1.56</h1>\n"
"\t\t\t<p>Author: Lorenz Pullwitt</p>\n"
"\t\t\t<p>Copyright 2016-2021</p>\n"
"\t\t\t<p>Send bugs and suggestions to\n"
Expand Down Expand Up @@ -4387,6 +4379,8 @@ int main(int argc, char *argv[])
wms->static_header = "Please select a category to learn";
wms->todo_main = S_SELECT_LEARN_CAT;
} else if (wms->from_page == P_SELECT_DECK || wms->from_page == P_SELECT_DEST_DECK) {
if (wms->seq == S_DECKS_CREATE)
wms->static_header = "Please select a category were to arrange the new category to";
wms->todo_main = S_START_DECKS;
}
}
Expand All @@ -4403,29 +4397,24 @@ int main(int argc, char *argv[])
break;
case A_TEST_CAT:
e = wms->ms.cat_i < 0 || wms->ms.cat_i >= wms->ms.cat_a || wms->ms.cat_t[wms->ms.cat_i].cat_used == 0;
if (e != 0 && wms->seq == S_CREATE_CAT)
if (e == 1 && (wms->seq == S_CREATE_CAT || wms->seq == S_DECKS_CREATE))
e = wms->ms.cat_i != -1 || wms->ms.n_first != -1;
if (e != 0) {
wms->static_header = "Warning: Invalid category";
wms->static_btn_main = "OK";
wms->todo_main = S_START_DECKS;
wms->todo_main = S_START;
wms->page = P_MSG;
if (wms->from_page == P_SELECT_CAT && wms->saved_mode == M_CREATE) {
wms->static_header = "Please select a category were to arrange the new category to";
wms->todo_main = S_SELECT_CREATE_CAT;
}
else if (wms->from_page == P_SELECT_CAT) {
if (wms->seq == S_SELECT_DEST_CAT) {
wms->static_header = "Please select a category to move";
wms->todo_main = S_SELECT_MOVE_CAT;
}
else {
assert(wms->seq == S_ASK_DELETE_CAT);
if (wms->from_page == P_SELECT_CAT) {
if (wms->seq == S_ASK_DELETE_CAT) {
wms->static_header = "Please select a category to delete";
wms->todo_main = S_SELECT_DELETE_CAT;
}
} else if (wms->from_page == P_SELECT_DECK)
} else if (wms->from_page == P_SELECT_DECK) {
if (wms->seq == S_SELECT_DEST_CAT) {
wms->static_header = "Please select a category to move";
}
wms->todo_main = S_START_DECKS;
}
}
break;
case A_SLASH:
Expand Down Expand Up @@ -4602,13 +4591,6 @@ int main(int argc, char *argv[])
} else
wms->page = P_CAT_NAME;
break;
case A_SELECT_CREATE_CAT:
if (wms->ms.n_first >= 0) {
wms->page = P_SELECT_CAT;
wms->mode = M_CREATE;
} else
wms->page = P_CAT_NAME;
break;
case A_SELECT_CAT:
wms->page = P_SELECT_CAT;
break;
Expand Down Expand Up @@ -4753,11 +4735,10 @@ int main(int argc, char *argv[])
}
}
}
}
else {
} else {
wms->static_header = "Please enter a name for the new category";
wms->static_btn_main = "OK";
wms->todo_main = S_SELECT_CREATE_CAT;
wms->todo_main = S_START_DECKS;
wms->page = P_MSG;
}
break;
Expand Down

0 comments on commit 5889c04

Please sign in to comment.