/* * Bookmarks server (chat version). * * NOTE: this code illustrates how to make a dpi-program. * * Copyright 2002-2007 Jorge Arellano Cid * Copyright 2024 Rodrigo Arias Mallo * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * */ /* TODO: this server is not assembling the received packets. * This means it currently expects dillo to send full dpi tags * within the socket; if that fails, everything stops. * This is not hard to fix, mainly is a matter of expecting the * final '>' of a tag. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../dpip/dpip.h" #include "dpiutil.h" /* * Debugging macros */ #define _MSG(...) #define MSG(...) printf("[bookmarks dpi]: " __VA_ARGS__) #define DOCTYPE \ "\n" #define CSS_STYLE \ "\n" /* * Notes on character escaping: * - Basically things are saved unescaped and escaped when in memory. * - &<>"' are escaped in titles and sections and saved unescaped. * - ' is escaped as %27 in URLs and saved escaped. */ typedef struct { int key; int section; char *url; char *title; } BmRec; typedef struct { int section; char *title; int o_sec; /* private, for normalization */ } BmSec; /* * Local data */ 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; /* * Forward declarations */ /* -- HTML templates ------------------------------------------------------- */ static const char *mainpage_header = DOCTYPE "\n" "\n" "Bookmarks\n" CSS_STYLE "\n" "\n" "\n" "

Bookmarks

\n" "
\n" " [Modify]\n" "
\n"; static const char *modifypage_header = DOCTYPE "\n" "\n" "Bookmarks\n" CSS_STYLE "\n" "\n" "

Bookmarks

\n" "\n" "
\n" "
\n" "
\n" " [Dismiss]\n" "
\n" "

Select an operation\n" " \n" " , mark its operands and\n" " \n" "

You can also modify the bookmarks by editting the\n" " ~/.dillo/bm.txt file.\n" "

\n"; static const char *mainpage_sections_header = "\n"; #define modifypage_sections_footer mainpage_sections_footer static const char *mainpage_middle1 = "\n"; static const char *modifypage_middle1 = "\n"; static const char *mainpage_section_card_header = "

%s

\n" "