AT Translated Set 2 keyboard
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Â524_‘I|¥‰ÓMdœv ©ƒ†ü+=ÂÁ     ‹      Õ•ßoÚ0ÇßûWÜü°7¸„¦QÇSG�†FQ¦iš¦É‰±šÄÈ1Pö×Ï!a°ªl�¶iÝ“Ï—ïýø\›>Ç½Ù‡IÞÌ®‡0y÷z8èi ¾?ï!†³°zpÑô|Äþˆ I¬]v7›MssÞÔf�³)&6K/°°FÅ¶)¬ ìŒ–>v4‘\¸¨U6•l�yz¨W¶PBº¸m�B®U,‹Ò¶2ÃLfÚlë¥ÝÆ\éÕÛŽ‹XE•�b•ÕÕÁº�´Ø–õý?^Ë¥Ü�ðhW²4£6�5OÕ"ˆÕKÂ¨ÊP˜8 ¨b�¥<¿m.Ôœ Om@>zãON‡6)£å�9È«^0º!a#žIŠüaÍµÓ\6ä……L5WRœßTâõåtÂ°Ò„²ˆ�ZZ¥óƒâ1j¬ÓbÉkÛ$æXUIÄÏ¦Áãï†1¹šöG³p0­F"Ê‡î~çÍ6áFæBedl�³Æªj<Ï£by¹ßBÝ´Q‹ÄÐ€•¿@:×©�æ˜õåž‹°½uÜé½ÖZ^«Óðý†ÿü]¯ð4ŒZK³c¨­§Â°Êos½É�!Üý#ˆÏ|åRÉo4×#°Z>x�nË;‰åÔ·ÿ ëÒÿŠ³’k÷[V­à‘ÇÖÅÝD±º¿5 �9e       ˆÀ¿Ã579¾ÂÁ C    ‹      Õ–QoÚ0Çßû)<?ì(ES›dêÒÐ( Ê4MÓ„LlˆEbGöÆ>ýœ„	Ú�¶Ië¤¼ÄçË?¾û��ä¼Wá¤?ÿ<�÷ó‡™~|7ö	m |ºî„ó°ºÑm¶Ú ƒ1%4FÌnv»]swÝÔfóÄ˜&]°hd„MŽœW^á®ˆÆÝH<”˜ˆ`¨¸øFôŠ€ÎÑJ.º�ÆÆ	V$+0Z#Ø½.¶2¶°Q¤ 4å¥©HµÙw{�é�0T‹»ppˆç-5ßi´_*¤[¹ÄbË2rašÀÃ˜lY"×Ê§¨3x2]k"Ÿ‚Œ´²°L˜Ú4×rE	KÐ§_†ýÉW§séO#.¯•OßöýñÝÄi0f©ð€�×<8Í=FÌ"I5—+)øEñc%~”ß//VšPØÈÈ¥VG)8ÄSÔH'6cŽõÆÄæTUIøïªÁ¢'Å˜ÞÏãy8œU%áÅÇìþÑÒ`ÊŒPHBiD„Îy ¬Â½VK›Ýýœ’CþF®c¤!rVùÐ¹Ú(½S§Ü®¦g‰™Ý«ˆåpšä³¬:­N¯Ñn7:mÒzs{Ó#ä‚Ð½Éþgú9j›ÛL(¾à"aûEjÍoáœ�Nhp0jˆ`r…2¡ÜŠÅFr·=gœõG+ì_Ð
»ÆhBÿ~Ä:8jŒd‘a~r«y��ªïœàÏNàS�sËÖ'\åôåqþ°�CwæAÙzPu¥? '*Éø
    @   ˆl–äY>”Êa,je@Šã,Üd
bÑ¿�þB7È³r´)]z9[ÀþÅƒqà‹Ä_ˆI|¥�+ÄÃ œ    /**
 *
 * Static file server Ulfius callback
 *
 * Copyright 2017-2020 Nicolas Mora <mail@babelouest.org>
 *
 * Version 202020616
 * 
 * The MIT License (MIT)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * struct static_file_config must be initialized with proper values
 * files_path: path (relative or absolute) to the DocumentRoot folder
 * url_prefix: prefix used to access the callback function
 * mime_types: a struct _u_map filled with all the mime-types needed for a static file server
 * redirect_on_404: redirct uri on error 404, if NULL, send 404
 * 
 * example of mime-types used in Hutch:
 * {
 *   key = ".html"
 *   value = "text/html"
 * },
 * {
 *   key = ".css"
 *   value = "text/css"
 * },
 * {
 *   key = ".js"
 *   value = "application/javascript"
 * },
 * {
 *   key = ".png"
 *   value = "image/png"
 * },
 * {
 *   key = ".jpg"
 *   value = "image/jpeg"
 * },
 * {
 *   key = ".jpeg"
 *   value = "image/jpeg"
 * },
 * {
 *   key = ".ttf"
 *   value = "font/ttf"
 * },
 * {
 *   key = ".woff"
 *   value = "font/woff"
 * },
 * {
 *   key = ".woff2"
 *   value = "font/woff2"
 * },
 * {
 *   key = ".map"
 *   value = "application/octet-stream"
 * },
 * {
 *   key = "*"
 *   value = "application/octet-stream"
 * }
 * 
 */

#include <orcania.h>
#include <string.h>
#include <ulfius.h>
#include <yder.h>

#include "static_file_callback.h"

/**
 * Return the filename extension
 */
const char * get_filename_ext(const char *path) {
    const char *dot = strrchr(path, '.');
    if(!dot || dot == path) return "*";
    if (strchr(dot, '?') != NULL) {
      *strchr(dot, '?') = '\0';
    }
    return dot;
}

/**
 * Streaming callback function to ease sending large files
 */
static ssize_t callback_static_file_stream(void * cl