From bbf6fe2fd069ef89f73ecc3fe3ec2000833f05f4 Mon Sep 17 00:00:00 2001 From: sijanec Date: Sat, 3 Apr 2021 23:15:48 +0200 Subject: initial release --- src/main.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index c42d5c0..3e8c544 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include #include #include @@ -16,11 +17,25 @@ #include #include #include +#include #include #include unsigned char sc_hp[] = { /* html page null terminated format string, from file src/hp.html */ #include }; +char sc_osdd[] = { /* xml document for opensearch */ +#include +}; +char sc_robotstxt[] = "User-Agent: *\nDisallow: /\n"; +char sc_securitytxt[] = "# This content information is provided by the developer of this opensource application.\n" + "# The developer is not responsible for the actions of his software\n" + "# This website IS NOT operated by the developer. Do not use the contact information below in hopes of contacting the webmaster\n" + "# The following contact information is provided for reporting security bugs regarding the software, not for legal issues\n" + "Contact: https://www.sijanec.eu/o.html#kontakt\n" + "Acknowledgments: https://git.sijanec.eu/sijanec/sear.c\n" + "Encryption: https://www.sijanec.eu/pgp-key.txt\n" + "Expires: Thu, 31 Dec 2021 18:37:07 -0800\n" + "Preferred-Languages: sl, en, de, hr\n"; #define SC_HTTP_PORT 7327 /* SEAR on mobile keyboard */ #define SC_HTTP_RBUFSIZE 4096 /* initial size of http read buffer, increasning by K */ #define SC_HTTP_USER_AGENT "Nokia WAP Gateway 4.1 CD1/ECD13_D/4.1.04)" /* so google and others sends a minimal response */ @@ -28,16 +43,25 @@ unsigned char sc_hp[] = { /* html page null terminated format string, from file #include #include #include +#include /* this is new in my programs. I am now using _sizeof for the actual alloced size of the array and _length for the count of elements in array. this is done to decrease number of calls to realloc&amis */ int main (int argc, char ** argv) { int rs = 0; struct sc_cache * c = sc_cache_init(); + struct MHD_Daemon * d; if (!c) { rs = 1; goto rc; } - sc_query_google("slovenia", c); + d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, SC_HTTP_PORT, NULL, NULL, &sc_httpd, c, MHD_OPTION_END); + if (!d) { + rs = 2; + goto rc; + } + /* sc_query_google(argv[1], c); */ + getc(stdin); rc: sc_cache_free(c); + MHD_stop_daemon(d); return rs; } -- cgit v1.2.3