Dillo v3.1.1-111-gd4f56d0d
|
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <time.h>
#include <netdb.h>
#include <fcntl.h>
#include <signal.h>
#include "../dpip/dpip.h"
#include "dpiutil.h"
Go to the source code of this file.
Macros | |
#define | _MSG(...) |
#define | MSG(...) printf("[bookmarks dpi]: " __VA_ARGS__) |
#define | DOCTYPE "<!DOCTYPE html>\n" |
#define | CSS_STYLE |
#define | modifypage_sections_header mainpage_sections_header |
#define | modifypage_sections_footer mainpage_sections_footer |
#define | modifypage_section_card_footer mainpage_section_card_footer |
Functions | |
static char * | make_one_line_str (char *str) |
static void | Unencode_str (char *e_str) |
static int | Bmsrv_dpi_send_status_msg (Dsh *sh, char *str) |
static int | Bms_node_by_key_cmp (const void *node, const void *key) |
static int | Bms_node_by_section_cmp (const void *node, const void *key) |
static int | Bms_sec_by_number_cmp (const void *node, const void *key) |
static BmRec * | Bms_get (int key) |
static BmSec * | Bms_get_sec (int key) |
static void | Bms_add (int section, char *url, char *title) |
static void | Bms_sec_add (char *title) |
static void | Bms_del (int key) |
static void | Bms_sec_del (int section) |
static void | Bms_move (int key, int target_section) |
static void | Bms_update_title (int key, char *n_title) |
static void | Bms_update_sec_title (int key, char *n_title) |
static void | Bms_free (void) |
static void | Bms_normalize (void) |
static void | Bms_check_import (void) |
static int | Bms_load (void) |
static int | Bms_cond_load (void) |
static int | Bms_save (void) |
static int | Bmsrv_add_bm (Dsh *sh, char *url, char *title) |
static void | Bmsrv_count_urls_and_sections (char *url, int *n_sec, int *n_url) |
static int | Bmsrv_send_reload_request (Dsh *sh, char *url) |
static int | Bmsrv_send_modify_page (Dsh *sh) |
static int | Bmsrv_send_modify_page_add_section (Dsh *sh) |
static int | Bmsrv_send_modify_page_add_url (Dsh *sh) |
static int | Bmsrv_send_modify_update (Dsh *sh, char *url) |
static int | Bmsrv_send_modify_answer (Dsh *sh, char *url) |
static int | Bmsrv_modify_delete (char *url) |
static int | Bmsrv_modify_move (char *url) |
static int | Bmsrv_modify_update (char *url) |
static int | Bmsrv_modify_add_section (char *url) |
static int | Bmsrv_modify_add_url (Dsh *sh, char *s_url) |
static int | Bmsrv_check_modify_request (Dsh *sh, char *url) |
static int | Bmsrv_process_modify_request (Dsh *sh, char *url) |
static int | send_bm_page (Dsh *sh) |
static int | Bmsrv_parse_token (Dsh *sh, char *Buf) |
static void | cleanup (void) |
static void | termination_handler (int signum) |
int | main (void) |
Variables | |
static char * | Header = "Content-type: text/html\n\n" |
static char * | BmFile = NULL |
static time_t | BmFileTimeStamp = 0 |
static Dlist * | B_bms = NULL |
static int | bm_key = 0 |
static Dlist * | B_secs = NULL |
static int | sec_key = 0 |
static int | MODIFY_PAGE_NUM = 1 |
static const char * | mainpage_header |
static const char * | modifypage_header |
static const char * | mainpage_sections_header |
static const char * | mainpage_sections_item |
static const char * | sections_sep |
static const char * | modifypage_sections_item |
static const char * | mainpage_sections_footer |
static const char * | mainpage_middle1 = "\n" |
static const char * | modifypage_middle1 = "\n" |
static const char * | mainpage_section_card_header |
static const char * | modifypage_section_card_header |
static const char * | mainpage_section_card_item |
static const char * | modifypage_section_card_item |
static const char * | mainpage_section_card_footer |
static const char * | mainpage_footer |
static const char * | modifypage_footer |
static const char * | modifypage_add_section_page |
static const char * | modifypage_update_header |
static const char * | modifypage_update_title |
static const char * | modifypage_update_item_header |
static const char * | modifypage_update_item |
static const char * | modifypage_update_item2 |
static const char * | modifypage_update_item_footer |
static const char * | modifypage_update_footer |
static const char * | modifypage_add_url |
#define _MSG | ( | ... | ) |
Definition at line 45 of file bookmarks.c.
#define CSS_STYLE |
Definition at line 51 of file bookmarks.c.
#define DOCTYPE "<!DOCTYPE html>\n" |
Definition at line 48 of file bookmarks.c.
#define modifypage_section_card_footer mainpage_section_card_footer |
Definition at line 196 of file bookmarks.c.
#define modifypage_sections_footer mainpage_sections_footer |
Definition at line 168 of file bookmarks.c.
#define modifypage_sections_header mainpage_sections_header |
Definition at line 153 of file bookmarks.c.
#define MSG | ( | ... | ) | printf("[bookmarks dpi]: " __VA_ARGS__) |
Definition at line 46 of file bookmarks.c.
|
static |
Definition at line 410 of file bookmarks.c.
References B_bms, bm_key, dList_append(), dNew, Escape_html_str(), and Escape_uri_str().
Referenced by Bms_load(), Bmsrv_add_bm(), and Bmsrv_modify_add_url().
|
static |
Definition at line 573 of file bookmarks.c.
References BmFile, dFree(), dGethomedir(), dStr_free(), dStr_new(), dStr_sprintf(), dStrconcat(), dStrerror, MSG, Dstr::str, and TRUE.
Referenced by Bms_cond_load().
|
static |
Definition at line 688 of file bookmarks.c.
References B_bms, B_secs, BmFile, BmFileTimeStamp, Bms_check_import(), Bms_load(), and dList_length().
Referenced by Bmsrv_parse_token().
|
static |
Definition at line 438 of file bookmarks.c.
References B_bms, bm_key, Bms_node_by_key_cmp(), dFree(), dList_find_custom(), dList_length(), dList_remove(), and INT2VOIDP.
Referenced by Bms_free(), Bms_sec_del(), and Bmsrv_modify_delete().
|
static |
Definition at line 522 of file bookmarks.c.
References B_bms, B_secs, Bms_del(), Bms_sec_del(), and dList_nth_data().
Referenced by Bms_load().
|
static |
Definition at line 394 of file bookmarks.c.
References B_bms, Bms_node_by_key_cmp(), dList_find_custom(), and INT2VOIDP.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 402 of file bookmarks.c.
References B_secs, Bms_sec_by_number_cmp(), dList_find_custom(), and INT2VOIDP.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 614 of file bookmarks.c.
References BmFile, BmFileTimeStamp, Bms_add(), Bms_free(), Bms_sec_add(), dFree(), dGetline(), error(), MSG, and Unescape_html_str().
Referenced by Bms_cond_load().
|
static |
Definition at line 481 of file bookmarks.c.
References B_bms, Bms_node_by_key_cmp(), dList_find_custom(), and INT2VOIDP.
Referenced by Bmsrv_modify_move().
|
static |
Definition at line 370 of file bookmarks.c.
References VOIDP2INT.
Referenced by Bms_del(), Bms_get(), Bms_move(), and Bms_update_title().
|
static |
|
static |
Definition at line 540 of file bookmarks.c.
References B_bms, B_secs, Bms_sec_add(), dList_length(), and dList_nth_data().
Referenced by Bms_save().
|
static |
Definition at line 714 of file bookmarks.c.
References B_bms, B_secs, BmFile, BmFileTimeStamp, Bms_normalize(), dFree(), dList_nth_data(), dStr_free(), dStr_new(), dStr_sprintf(), dStrconcat(), Dstr::len, Dstr::str, TRUE, and Unescape_html_str().
Referenced by Bmsrv_add_bm(), Bmsrv_modify_add_section(), Bmsrv_modify_add_url(), Bmsrv_modify_delete(), Bmsrv_modify_move(), and Bmsrv_modify_update().
|
static |
Definition at line 425 of file bookmarks.c.
References B_secs, dList_append(), dNew, Escape_html_str(), and sec_key.
Referenced by Bms_load(), Bms_normalize(), and Bmsrv_modify_add_section().
|
static |
Definition at line 386 of file bookmarks.c.
References VOIDP2INT.
Referenced by Bms_get_sec(), Bms_sec_del(), and Bms_update_sec_title().
|
static |
Definition at line 456 of file bookmarks.c.
References B_bms, B_secs, Bms_del(), Bms_node_by_section_cmp(), Bms_sec_by_number_cmp(), dFree(), dList_find_custom(), dList_length(), dList_remove(), INT2VOIDP, and sec_key.
Referenced by Bms_free(), and Bmsrv_modify_delete().
|
static |
Definition at line 508 of file bookmarks.c.
References B_secs, Bms_sec_by_number_cmp(), dFree(), dList_find_custom(), Escape_html_str(), and INT2VOIDP.
Referenced by Bmsrv_modify_update().
|
static |
Definition at line 494 of file bookmarks.c.
References B_bms, Bms_node_by_key_cmp(), dFree(), dList_find_custom(), Escape_html_str(), and INT2VOIDP.
Referenced by Bmsrv_modify_update().
|
static |
Definition at line 776 of file bookmarks.c.
References Bms_add(), Bms_save(), Bmsrv_dpi_send_status_msg(), dFree(), sh, and Unescape_html_str().
Referenced by Bmsrv_parse_token().
|
static |
Definition at line 1274 of file bookmarks.c.
References Bmsrv_count_urls_and_sections(), Bmsrv_dpi_send_status_msg(), and sh.
Referenced by Bmsrv_process_modify_request().
|
static |
Definition at line 801 of file bookmarks.c.
Referenced by Bmsrv_check_modify_request(), and Bmsrv_send_modify_update().
|
static |
Definition at line 355 of file bookmarks.c.
References a_Dpip_build_cmd(), a_Dpip_dsh_write_str(), dFree(), and sh.
Referenced by Bmsrv_add_bm(), and Bmsrv_check_modify_request().
|
static |
Definition at line 1193 of file bookmarks.c.
References Bms_save(), Bms_sec_add(), dFree(), dStrdup(), and Unencode_str().
Referenced by Bmsrv_process_modify_request().
|
static |
Definition at line 1221 of file bookmarks.c.
References Bms_add(), Bms_save(), dFree(), dStrdup(), sh, Unencode_str(), and Unescape_html_str().
Referenced by Bmsrv_process_modify_request().
|
static |
Definition at line 1053 of file bookmarks.c.
References Bms_del(), Bms_save(), and Bms_sec_del().
Referenced by Bmsrv_process_modify_request().
|
static |
Definition at line 1099 of file bookmarks.c.
References Bms_move(), and Bms_save().
Referenced by Bmsrv_process_modify_request().
|
static |
Definition at line 1138 of file bookmarks.c.
References Bms_save(), Bms_update_sec_title(), Bms_update_title(), dFree(), dStrdup(), dStrndup(), and Unencode_str().
Referenced by Bmsrv_process_modify_request().
|
static |
Definition at line 1482 of file bookmarks.c.
References a_Dpip_build_cmd(), a_Dpip_dsh_write_str(), a_Dpip_get_attr_l(), Bms_cond_load(), Bmsrv_add_bm(), Bmsrv_process_modify_request(), Bmsrv_send_modify_answer(), dFree(), DOCTYPE, DPIP_RAW, dStrdup(), dStrnAsciiCasecmp(), Header, Dsh::mode, MSG, send_bm_page(), and sh.
Referenced by main().
|
static |
Definition at line 1339 of file bookmarks.c.
References Bmsrv_check_modify_request(), Bmsrv_modify_add_section(), Bmsrv_modify_add_url(), Bmsrv_modify_delete(), Bmsrv_modify_move(), Bmsrv_modify_update(), Bmsrv_send_modify_update(), Bmsrv_send_reload_request(), MODIFY_PAGE_NUM, and sh.
Referenced by Bmsrv_parse_token().
|
static |
Definition at line 1016 of file bookmarks.c.
References a_Dpip_build_cmd(), a_Dpip_dsh_write_str(), Bmsrv_send_modify_page(), Bmsrv_send_modify_page_add_section(), Bmsrv_send_modify_page_add_url(), Bmsrv_send_modify_update(), dFree(), Header, MODIFY_PAGE_NUM, and sh.
Referenced by Bmsrv_parse_token().
|
static |
Definition at line 839 of file bookmarks.c.
References a_Dpip_dsh_write_str(), B_bms, B_secs, dFree(), dList_nth_data(), dStr_new(), dStr_sprintf(), make_one_line_str(), modifypage_footer, modifypage_header, modifypage_middle1, modifypage_section_card_footer, modifypage_section_card_header, modifypage_section_card_item, modifypage_sections_footer, modifypage_sections_header, modifypage_sections_item, sections_sep, sh, and Dstr::str.
Referenced by Bmsrv_send_modify_answer().
|
static |
Definition at line 913 of file bookmarks.c.
References a_Dpip_dsh_write_str(), modifypage_add_section_page, and sh.
Referenced by Bmsrv_send_modify_answer().
|
static |
Definition at line 926 of file bookmarks.c.
References a_Dpip_dsh_write_str(), modifypage_add_url, and sh.
Referenced by Bmsrv_send_modify_answer().
|
static |
Definition at line 940 of file bookmarks.c.
References a_Dpip_dsh_write_str(), Bms_get(), Bms_get_sec(), Bmsrv_count_urls_and_sections(), dFree(), dStr_new(), dStr_sprintf(), dStrdup(), modifypage_update_footer, modifypage_update_header, modifypage_update_item, modifypage_update_item2, modifypage_update_item_footer, modifypage_update_item_header, modifypage_update_title, sh, and Dstr::str.
Referenced by Bmsrv_process_modify_request(), and Bmsrv_send_modify_answer().
|
static |
Definition at line 824 of file bookmarks.c.
References a_Dpip_build_cmd(), a_Dpip_dsh_write_str(), dFree(), and sh.
Referenced by Bmsrv_process_modify_request().
|
static |
Definition at line 1596 of file bookmarks.c.
Referenced by main().
int main | ( | void | ) |
Definition at line 1613 of file bookmarks.c.
References a_Dpip_check_auth(), a_Dpip_dsh_close(), a_Dpip_dsh_free(), a_Dpip_dsh_new(), a_Dpip_dsh_read_token(), B_bms, B_secs, BmFile, Bmsrv_parse_token(), cleanup(), dFree(), dGethomedir(), dList_new(), dStrconcat(), dStrerror, MSG, sh, and termination_handler().
|
static |
Definition at line 301 of file bookmarks.c.
References dNew.
Referenced by Bmsrv_send_modify_page(), and send_bm_page().
|
static |
Definition at line 1405 of file bookmarks.c.
References a_Dpip_dsh_write_str(), B_bms, B_secs, dFree(), dList_nth_data(), dStr_new(), dStr_sprintf(), mainpage_footer, mainpage_header, mainpage_middle1, mainpage_section_card_footer, mainpage_section_card_header, mainpage_section_card_item, mainpage_sections_footer, mainpage_sections_header, mainpage_sections_item, make_one_line_str(), sections_sep, sh, and Dstr::str.
Referenced by Bmsrv_parse_token().
|
static |
Definition at line 1604 of file bookmarks.c.
Referenced by main().
|
static |
Definition at line 329 of file bookmarks.c.
References dStrnAsciiCasecmp().
Referenced by Bmsrv_modify_add_section(), Bmsrv_modify_add_url(), and Bmsrv_modify_update().
|
static |
Definition at line 89 of file bookmarks.c.
Referenced by Bms_add(), Bms_cond_load(), Bms_del(), Bms_free(), Bms_get(), Bms_move(), Bms_normalize(), Bms_save(), Bms_sec_del(), Bms_update_title(), Bmsrv_send_modify_page(), main(), and send_bm_page().
|
static |
Definition at line 92 of file bookmarks.c.
Referenced by Bms_cond_load(), Bms_free(), Bms_get_sec(), Bms_normalize(), Bms_save(), Bms_sec_add(), Bms_sec_del(), Bms_update_sec_title(), Bmsrv_send_modify_page(), main(), and send_bm_page().
|
static |
Definition at line 90 of file bookmarks.c.
|
static |
Definition at line 87 of file bookmarks.c.
Referenced by Bms_check_import(), Bms_cond_load(), Bms_load(), Bms_save(), and main().
|
static |
Definition at line 88 of file bookmarks.c.
Referenced by Bms_cond_load(), Bms_load(), and Bms_save().
|
static |
Definition at line 86 of file bookmarks.c.
Referenced by Bmsrv_parse_token(), and Bmsrv_send_modify_answer().
|
static |
Definition at line 198 of file bookmarks.c.
Referenced by send_bm_page().
|
static |
Definition at line 105 of file bookmarks.c.
Referenced by send_bm_page().
|
static |
Definition at line 170 of file bookmarks.c.
Referenced by send_bm_page().
|
static |
|
static |
Definition at line 174 of file bookmarks.c.
Referenced by send_bm_page().
|
static |
Definition at line 182 of file bookmarks.c.
Referenced by send_bm_page().
|
static |
Definition at line 164 of file bookmarks.c.
Referenced by send_bm_page().
|
static |
Definition at line 149 of file bookmarks.c.
Referenced by send_bm_page().
|
static |
Definition at line 155 of file bookmarks.c.
Referenced by send_bm_page().
|
static |
Definition at line 95 of file bookmarks.c.
Referenced by Bmsrv_process_modify_request(), and Bmsrv_send_modify_answer().
|
static |
Definition at line 208 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page_add_section().
|
static |
Definition at line 270 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page_add_url().
|
static |
Definition at line 202 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page().
|
static |
Definition at line 119 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page().
|
static |
Definition at line 172 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page().
|
static |
Definition at line 178 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page().
|
static |
Definition at line 187 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page().
|
static |
Definition at line 161 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page().
|
static |
Definition at line 263 of file bookmarks.c.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 231 of file bookmarks.c.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 249 of file bookmarks.c.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 255 of file bookmarks.c.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 260 of file bookmarks.c.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 246 of file bookmarks.c.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 243 of file bookmarks.c.
Referenced by Bmsrv_send_modify_update().
|
static |
Definition at line 93 of file bookmarks.c.
Referenced by Bms_sec_add(), and Bms_sec_del().
|
static |
Definition at line 158 of file bookmarks.c.
Referenced by Bmsrv_send_modify_page(), and send_bm_page().