]> andersk Git - test.git/commitdiff
Internet Explorer still doesn't properly support CSS. In particular, it has
authorMarkus Gutschke <markus@shellinabox.com>
Sun, 16 Aug 2009 05:20:09 +0000 (05:20 +0000)
committerMarkus Gutschke <markus@shellinabox.com>
Sun, 16 Aug 2009 05:20:09 +0000 (05:20 +0000)
problems dealing with "inherit" styles. This prevented proper switching
between color and monochrome.

Implemented a work-around.

18 files changed:
Makefile.am
Makefile.in
config.h
configure
configure.ac
demo/styles.css
demo/usercss-2.css
demo/usercss-3.css
demo/vt100.js
libhttp/httpconnection.c
shellinabox/color.css
shellinabox/monochrome.css
shellinabox/shell_in_a_box.js
shellinabox/shellinaboxd.c
shellinabox/styles.css
shellinabox/usercss.c
shellinabox/usercss.h
shellinabox/vt100.js

index 31a9c4395e7e92b9fbc54f06f84636e62107216e..83b1c02321e18ca2c001c86df1674c3969285fda 100644 (file)
@@ -153,7 +153,7 @@ ${top_srcdir}/demo/favicon.ico: ${top_srcdir}/shellinabox/favicon.ico
 
 ${top_srcdir}/demo/styles.css: ${top_srcdir}/shellinabox/styles.css
        @rm -f "$@"
-       ln "$<" "$@"
+       sed -e '/\[if DEFINES_COLORS\]/,/\[endif DEFINES_COLORS\]/d' "$<" >"$@"
 
 ${top_srcdir}/demo/usercss-0.css: ${top_srcdir}/shellinabox/white-on-black.css
        @rm -f "$@"
index 9602b5bbeadf57709a938d1e20c7b0653aa74968..88bff5f6cff09c2e9884d747931c9810764cd74f 100644 (file)
@@ -1086,7 +1086,7 @@ ${top_srcdir}/demo/favicon.ico: ${top_srcdir}/shellinabox/favicon.ico
 
 ${top_srcdir}/demo/styles.css: ${top_srcdir}/shellinabox/styles.css
        @rm -f "$@"
-       ln "$<" "$@"
+       sed -e '/\[if DEFINES_COLORS\]/,/\[endif DEFINES_COLORS\]/d' "$<" >"$@"
 
 ${top_srcdir}/demo/usercss-0.css: ${top_srcdir}/shellinabox/white-on-black.css
        @rm -f "$@"
index ec314355a61d698c58d7a95f96f40e8256b5f58e..895a91802307d64cc0ede5151f02119b2cf86bc1 100644 (file)
--- a/config.h
+++ b/config.h
 #define STDC_HEADERS 1
 
 /* Most recent revision number in the version control system */
-#define VCS_REVISION "171"
+#define VCS_REVISION "172"
 
 /* Version number of package */
 #define VERSION "2.9"
index 932a58b041162b8279a12547f07cef0ee25c760f..b399573ed176a9acda0ed28636709f852adf9874 100755 (executable)
--- a/configure
+++ b/configure
@@ -2317,7 +2317,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-VCS_REVISION=171
+VCS_REVISION=172
 
 
 cat >>confdefs.h <<_ACEOF
index d54462c40485f470611f675be176264bb5799d10..b8031608dfb8836903afa807077defd2f1007ea5 100644 (file)
@@ -2,7 +2,7 @@ AC_PREREQ(2.57)
 
 dnl This is the one location where the authoritative version number is stored
 AC_INIT(shellinabox, 2.9, markus@shellinabox.com)
-VCS_REVISION=171
+VCS_REVISION=172
 AC_SUBST(VCS_REVISION)
 AC_DEFINE_UNQUOTED(VCS_REVISION, "${VCS_REVISION}",
                    [Most recent revision number in the version control system])
index 6e465a12f23e878397afe04cada3ed2434c37dfd..b1b5b6f7c7fdb871474742f3050afbc18d11d98b 100644 (file)
 
 #vt100 #scrollable.inverted { color:            #ffffff;
                               background-color: #000000; }
-#vt100 .ansi0               {                            }
-#vt100 .ansi1               { color:            #cd0000; }
-#vt100 .ansi2               { color:            #00cd00; }
-#vt100 .ansi3               { color:            #cdcd00; }
-#vt100 .ansi4               { color:            #0000ee; }
-#vt100 .ansi5               { color:            #cd00cd; }
-#vt100 .ansi6               { color:            #00cdcd; }
-#vt100 .ansi7               { color:            #e5e5e5; }
-#vt100 .ansi8               { color:            #7f7f7f; }
-#vt100 .ansi9               { color:            #ff0000; }
-#vt100 .ansi10              { color:            #00ff00; }
-#vt100 .ansi11              { color:            #e8e800; }
-#vt100 .ansi12              { color:            #5c5cff; }
-#vt100 .ansi13              { color:            #ff00ff; }
-#vt100 .ansi14              { color:            #00ffff; }
-#vt100 .ansi15              { color:            #ffffff; }
-
-#vt100 .bgAnsi0             { background-color: #000000; }
-#vt100 .bgAnsi1             { background-color: #cd0000; }
-#vt100 .bgAnsi2             { background-color: #00cd00; }
-#vt100 .bgAnsi3             { background-color: #cdcd00; }
-#vt100 .bgAnsi4             { background-color: #0000ee; }
-#vt100 .bgAnsi5             { background-color: #cd00cd; }
-#vt100 .bgAnsi6             { background-color: #00cdcd; }
-#vt100 .bgAnsi7             { background-color: #e5e5e5; }
-#vt100 .bgAnsi8             { background-color: #7f7f7f; }
-#vt100 .bgAnsi9             { background-color: #ff0000; }
-#vt100 .bgAnsi10            { background-color: #00ff00; }
-#vt100 .bgAnsi11            { background-color: #e8e800; }
-#vt100 .bgAnsi12            { background-color: #5c5cff; }
-#vt100 .bgAnsi13            { background-color: #ff00ff; }
-#vt100 .bgAnsi14            { background-color: #00ffff; }
-#vt100 .bgAnsi15            {                            }
 
 @media print {
   #vt100 .scrollback {
index b5c60a543c61812f75e08b7d63ef9695d4bb8268..9863105abb3d8ed7a814bd980287318327ea6cb2 100644 (file)
 #vt100 .ansi13   { color:            inherit; }
 #vt100 .ansi14   { color:            inherit; }
 
-#vt100 .bgAnsi1  { background-color: inherit; }
-#vt100 .bgAnsi2  { background-color: inherit; }
-#vt100 .bgAnsi3  { background-color: inherit; }
-#vt100 .bgAnsi4  { background-color: inherit; }
-#vt100 .bgAnsi5  { background-color: inherit; }
-#vt100 .bgAnsi6  { background-color: inherit; }
-#vt100 .bgAnsi7  { background-color: inherit; }
-#vt100 .bgAnsi8  { background-color: inherit; }
-#vt100 .bgAnsi9  { background-color: inherit; }
-#vt100 .bgAnsi10 { background-color: inherit; }
-#vt100 .bgAnsi11 { background-color: inherit; }
-#vt100 .bgAnsi12 { background-color: inherit; }
-#vt100 .bgAnsi13 { background-color: inherit; }
-#vt100 .bgAnsi14 { background-color: inherit; }
+#vt100 .bgAnsi1  { background-color: transparent; }
+#vt100 .bgAnsi2  { background-color: transparent; }
+#vt100 .bgAnsi3  { background-color: transparent; }
+#vt100 .bgAnsi4  { background-color: transparent; }
+#vt100 .bgAnsi5  { background-color: transparent; }
+#vt100 .bgAnsi6  { background-color: transparent; }
+#vt100 .bgAnsi7  { background-color: transparent; }
+#vt100 .bgAnsi8  { background-color: transparent; }
+#vt100 .bgAnsi9  { background-color: transparent; }
+#vt100 .bgAnsi10 { background-color: transparent; }
+#vt100 .bgAnsi11 { background-color: transparent; }
+#vt100 .bgAnsi12 { background-color: transparent; }
+#vt100 .bgAnsi13 { background-color: transparent; }
+#vt100 .bgAnsi14 { background-color: transparent; }
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..16a1afc2b8ae2dfec863c0bf2353fdd7c8144f0c 100644 (file)
@@ -0,0 +1,34 @@
+/* DEFINES_COLORS */
+#vt100 .ansi0               {                            }
+#vt100 .ansi1               { color:            #cd0000; }
+#vt100 .ansi2               { color:            #00cd00; }
+#vt100 .ansi3               { color:            #cdcd00; }
+#vt100 .ansi4               { color:            #0000ee; }
+#vt100 .ansi5               { color:            #cd00cd; }
+#vt100 .ansi6               { color:            #00cdcd; }
+#vt100 .ansi7               { color:            #e5e5e5; }
+#vt100 .ansi8               { color:            #7f7f7f; }
+#vt100 .ansi9               { color:            #ff0000; }
+#vt100 .ansi10              { color:            #00ff00; }
+#vt100 .ansi11              { color:            #e8e800; }
+#vt100 .ansi12              { color:            #5c5cff; }
+#vt100 .ansi13              { color:            #ff00ff; }
+#vt100 .ansi14              { color:            #00ffff; }
+#vt100 .ansi15              { color:            #ffffff; }
+
+#vt100 .bgAnsi0             { background-color: #000000; }
+#vt100 .bgAnsi1             { background-color: #cd0000; }
+#vt100 .bgAnsi2             { background-color: #00cd00; }
+#vt100 .bgAnsi3             { background-color: #cdcd00; }
+#vt100 .bgAnsi4             { background-color: #0000ee; }
+#vt100 .bgAnsi5             { background-color: #cd00cd; }
+#vt100 .bgAnsi6             { background-color: #00cdcd; }
+#vt100 .bgAnsi7             { background-color: #e5e5e5; }
+#vt100 .bgAnsi8             { background-color: #7f7f7f; }
+#vt100 .bgAnsi9             { background-color: #ff0000; }
+#vt100 .bgAnsi10            { background-color: #00ff00; }
+#vt100 .bgAnsi11            { background-color: #e8e800; }
+#vt100 .bgAnsi12            { background-color: #5c5cff; }
+#vt100 .bgAnsi13            { background-color: #ff00ff; }
+#vt100 .bgAnsi14            { background-color: #00ffff; }
+#vt100 .bgAnsi15            {                            }
index bf064850022be99f7c47f730eb5199bbbbc3d5d9..9f8cc89a77eb9770c56ba7719e25e9d5eb1da997 100644 (file)
@@ -1892,7 +1892,7 @@ VT100.prototype.toggleBell = function() {
 };
 
 VT100.prototype.about = function() {
-  alert("VT100 Terminal Emulator " + "2.9 (revision 171)" +
+  alert("VT100 Terminal Emulator " + "2.9 (revision 172)" +
         "\nCopyright 2008-2009 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com");
 };
index 972a58cc2a323626f30183b7c38a363b0b262994..c8e69f6d39ded29314d2e25d39956a9a6d8b4ee9 100644 (file)
@@ -546,13 +546,12 @@ void httpTransfer(struct HttpConnection *http, char *msg, int len) {
   check(msg);
   check(len >= 0);
 
-  // Internet Explorer prior to version 7 seems to have difficulties with
-  // compressed data. It also has difficulties with SSL connections that
-  // are being proxied.
+  // Internet Explorer seems to have difficulties with compressed data. It
+  // also has difficulties with SSL connections that are being proxied.
   int ieBug                 = 0;
   const char *userAgent     = getFromHashMap(&http->header, "user-agent");
   const char *msie          = userAgent ? strstr(userAgent, "MSIE ") : NULL;
-  if (msie && msie[5] >= '4' && msie[5] <= '6') {
+  if (msie) {
     ieBug++;
   }
 
@@ -637,8 +636,8 @@ void httpTransfer(struct HttpConnection *http, char *msg, int len) {
       z_stream strm         = { .zalloc    = Z_NULL,
                                 .zfree     = Z_NULL,
                                 .opaque    = Z_NULL,
-                                .avail_in  = l - 2,
-                                .next_in   = (unsigned char *)line + 2,
+                                .avail_in  = l,
+                                .next_in   = (unsigned char *)line,
                                 .avail_out = len,
                                 .next_out  = (unsigned char *)compressed
                               };
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..16a1afc2b8ae2dfec863c0bf2353fdd7c8144f0c 100644 (file)
@@ -0,0 +1,34 @@
+/* DEFINES_COLORS */
+#vt100 .ansi0               {                            }
+#vt100 .ansi1               { color:            #cd0000; }
+#vt100 .ansi2               { color:            #00cd00; }
+#vt100 .ansi3               { color:            #cdcd00; }
+#vt100 .ansi4               { color:            #0000ee; }
+#vt100 .ansi5               { color:            #cd00cd; }
+#vt100 .ansi6               { color:            #00cdcd; }
+#vt100 .ansi7               { color:            #e5e5e5; }
+#vt100 .ansi8               { color:            #7f7f7f; }
+#vt100 .ansi9               { color:            #ff0000; }
+#vt100 .ansi10              { color:            #00ff00; }
+#vt100 .ansi11              { color:            #e8e800; }
+#vt100 .ansi12              { color:            #5c5cff; }
+#vt100 .ansi13              { color:            #ff00ff; }
+#vt100 .ansi14              { color:            #00ffff; }
+#vt100 .ansi15              { color:            #ffffff; }
+
+#vt100 .bgAnsi0             { background-color: #000000; }
+#vt100 .bgAnsi1             { background-color: #cd0000; }
+#vt100 .bgAnsi2             { background-color: #00cd00; }
+#vt100 .bgAnsi3             { background-color: #cdcd00; }
+#vt100 .bgAnsi4             { background-color: #0000ee; }
+#vt100 .bgAnsi5             { background-color: #cd00cd; }
+#vt100 .bgAnsi6             { background-color: #00cdcd; }
+#vt100 .bgAnsi7             { background-color: #e5e5e5; }
+#vt100 .bgAnsi8             { background-color: #7f7f7f; }
+#vt100 .bgAnsi9             { background-color: #ff0000; }
+#vt100 .bgAnsi10            { background-color: #00ff00; }
+#vt100 .bgAnsi11            { background-color: #e8e800; }
+#vt100 .bgAnsi12            { background-color: #5c5cff; }
+#vt100 .bgAnsi13            { background-color: #ff00ff; }
+#vt100 .bgAnsi14            { background-color: #00ffff; }
+#vt100 .bgAnsi15            {                            }
index b5c60a543c61812f75e08b7d63ef9695d4bb8268..9863105abb3d8ed7a814bd980287318327ea6cb2 100644 (file)
 #vt100 .ansi13   { color:            inherit; }
 #vt100 .ansi14   { color:            inherit; }
 
-#vt100 .bgAnsi1  { background-color: inherit; }
-#vt100 .bgAnsi2  { background-color: inherit; }
-#vt100 .bgAnsi3  { background-color: inherit; }
-#vt100 .bgAnsi4  { background-color: inherit; }
-#vt100 .bgAnsi5  { background-color: inherit; }
-#vt100 .bgAnsi6  { background-color: inherit; }
-#vt100 .bgAnsi7  { background-color: inherit; }
-#vt100 .bgAnsi8  { background-color: inherit; }
-#vt100 .bgAnsi9  { background-color: inherit; }
-#vt100 .bgAnsi10 { background-color: inherit; }
-#vt100 .bgAnsi11 { background-color: inherit; }
-#vt100 .bgAnsi12 { background-color: inherit; }
-#vt100 .bgAnsi13 { background-color: inherit; }
-#vt100 .bgAnsi14 { background-color: inherit; }
+#vt100 .bgAnsi1  { background-color: transparent; }
+#vt100 .bgAnsi2  { background-color: transparent; }
+#vt100 .bgAnsi3  { background-color: transparent; }
+#vt100 .bgAnsi4  { background-color: transparent; }
+#vt100 .bgAnsi5  { background-color: transparent; }
+#vt100 .bgAnsi6  { background-color: transparent; }
+#vt100 .bgAnsi7  { background-color: transparent; }
+#vt100 .bgAnsi8  { background-color: transparent; }
+#vt100 .bgAnsi9  { background-color: transparent; }
+#vt100 .bgAnsi10 { background-color: transparent; }
+#vt100 .bgAnsi11 { background-color: transparent; }
+#vt100 .bgAnsi12 { background-color: transparent; }
+#vt100 .bgAnsi13 { background-color: transparent; }
+#vt100 .bgAnsi14 { background-color: transparent; }
index 781870329a20a890fede29246045660b58766a68..ab52210f41340a1e8e2a7f17b3d75a9f6cb8a0d4 100644 (file)
@@ -355,7 +355,7 @@ ShellInABox.prototype.extendContextMenu = function(entries, actions) {
 };
 
 ShellInABox.prototype.about = function() {
-  alert("Shell In A Box version " + "2.9 (revision 171)" +
+  alert("Shell In A Box version " + "2.9 (revision 172)" +
         "\nCopyright 2008-2009 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com" +
         (typeof serverSupportsSSL != 'undefined' && serverSupportsSSL ?
index e2d6034ac3be6feacd8950f99961798988b00dd5..caa1e580e735ceea41c8ef33d8cefb8772c01d2a 100644 (file)
@@ -445,18 +445,129 @@ static int dataHandler(HttpConnection *http, struct Service *service,
 
 static void serveStaticFile(HttpConnection *http, const char *contentType,
                             const char *start, const char *end) {
+  char *body                     = (char *)start;
+  char *bodyEnd                  = (char *)end;
+
+  // Unfortunately, there are still some browsers that are so buggy that they
+  // need special conditional code. In anything that has a "text" MIME type,
+  // we allow simple conditionals. Nested conditionals are not supported.
+  if (!memcmp(contentType, "text/", 5)) {
+    char *tag                    = NULL;
+    int condTrue                 = -1;
+    char *ifPtr                  = NULL;
+    char *elsePtr                = NULL;
+    for (char *ptr = body; bodyEnd - ptr >= 6; ) {
+      char *eol                  = ptr;
+      eol                        = memchr(eol, '\n', bodyEnd - eol);
+      if (eol == NULL) {
+        eol                      = bodyEnd;
+      } else {
+        ++eol;
+      }
+      if (!memcmp(ptr, "[if ", 4)) {
+        char *bracket            = memchr(ptr + 4, ']', eol - ptr - 4);
+        if (bracket != NULL && bracket > ptr + 4) {
+          check(tag              = malloc(bracket - ptr - 3));
+          memcpy(tag, ptr + 4, bracket - ptr - 4);
+          tag[bracket - ptr - 4] = '\000';
+          condTrue               = 0;
+          const char *userAgent  = getFromHashMap(httpGetHeaders(http),
+                                                  "user-agent");
+          if (userAgent) {
+            // Allow multiple comma separated conditions
+            for (char *tagPtr = tag; *tagPtr; ) {
+              char *e            = strchr(tagPtr, ',');
+              if (!e) {
+                e                = strchr(tag, '\000');
+              } else {
+                *e++             = '\000';
+              }
+              condTrue           = userCSSGetDefine(tagPtr) ||
+                                   strstr(userAgent, tagPtr) != NULL;
+              if (*e) {
+                e[-1]            = ',';
+              }
+              if (condTrue) {
+                break;
+              }
+              tagPtr             = e;
+            }
+          }
+
+          // If we find any conditionals, then we need to make a copy of
+          // the text document. We do this lazily, as presumably the majority
+          // of text documents won't have conditionals.
+          if (body == start) {
+            check(body           = malloc(end - start));
+            memcpy(body, start, end - start);
+            bodyEnd             += body - start;
+            ptr                 += body - start;
+            eol                 += body - start;
+          }
+
+          // Remember the beginning of the "[if ...]" statement
+          ifPtr                  = ptr;
+        }
+      } else if (ifPtr && !elsePtr && eol - ptr >= strlen(tag) + 7 &&
+                 !memcmp(ptr, "[else ", 6) &&
+                 !memcmp(ptr + 6, tag, strlen(tag)) &&
+                 ptr[6 + strlen(tag)] == ']') {
+        // Found an "[else ...]" statement. Remember where it started.
+        elsePtr                  = ptr;
+      } else if (ifPtr && eol - ptr >= strlen(tag) + 8 &&
+                 !memcmp(ptr, "[endif ", 7) &&
+                 !memcmp(ptr + 7, tag, strlen(tag)) &&
+                 ptr[7 + strlen(tag)] == ']') {
+        // Found the closing "[endif ...]" statement. Now we can remove those
+        // parts of the conditionals that do not apply to this user agent.
+        char *s, *e;
+        if (condTrue) {
+          s                      = strchr(ifPtr, '\n') + 1;
+          e                      = elsePtr ? elsePtr : ptr;
+        } else {
+          if (elsePtr) {
+            s                    = strchr(elsePtr, '\n') + 1;
+            e                    = ptr;
+          } else {
+            s                    = ifPtr;
+            e                    = ifPtr;
+          }
+        }
+        memmove(ifPtr, s, e - s);
+        memmove(ifPtr + (e - s), eol, bodyEnd - eol);
+        bodyEnd                 -= (s - ifPtr) + (eol - e);
+        eol                      = ifPtr + (e - s);
+        ifPtr                    = NULL;
+        elsePtr                  = NULL;
+        free(tag);
+        tag                      = NULL;
+      }
+      ptr                        = eol;
+    }
+    free(tag);
+  }
+
   char *response   = stringPrintf(NULL,
                                   "HTTP/1.1 200 OK\r\n"
                                   "Content-Type: %s\r\n"
                                   "Content-Length: %ld\r\n"
-                                  "\r\n",
-                                  contentType, (long)(end - start));
+                                  "%s\r\n",
+                                  contentType, (long)(bodyEnd - body),
+                                  body == start ? "" :
+                                  "Cache-Control: no-cache\r\n");
   int len          = strlen(response);
   if (strcmp(httpGetMethod(http), "HEAD")) {
-    check(response = realloc(response, len + (end - start)));
-    memcpy(response + len, start, end - start);
-    len           += end - start;
+    check(response = realloc(response, len + (bodyEnd - body)));
+    memcpy(response + len, body, bodyEnd - body);
+    len           += bodyEnd - body;
   }
+
+  // If we expanded conditionals, we had to create a temporary copy. Delete
+  // it now.
+  if (body != start) {
+    free(body);
+  }
+
   httpTransfer(http, response, len);
 }
 
index 6e465a12f23e878397afe04cada3ed2434c37dfd..3c3886f9fb1df3a5737d51af9adc56c3467d4c7b 100644 (file)
 
 #vt100 #scrollable.inverted { color:            #ffffff;
                               background-color: #000000; }
+[if DEFINES_COLORS]
+/* IE cannot properly handle "inherit" properties. So, the monochrome.css
+ * style sheet cannot work, if we define colors by default.
+ */
+[else DEFINES_COLORS]
 #vt100 .ansi0               {                            }
 #vt100 .ansi1               { color:            #cd0000; }
 #vt100 .ansi2               { color:            #00cd00; }
 #vt100 .bgAnsi13            { background-color: #ff00ff; }
 #vt100 .bgAnsi14            { background-color: #00ffff; }
 #vt100 .bgAnsi15            {                            }
+[endif DEFINES_COLORS]
 
 @media print {
   #vt100 .scrollback {
index 5ab733a81486c8251c92f332b2e6b94bf5215bea..e94be7440c593f7cc67b077d50213d9a81b5aa1d 100644 (file)
 
 #include "logging/logging.h"
 #include "shellinabox/usercss.h"
+#include "libhttp/hashmap.h"
 
+static struct HashMap *defines;
 
-static void readStylesheet(const char *filename, char **style, size_t *len) {
-  int fd               = open(filename, O_RDONLY);
+static void definesDestructor(void *arg, char *key, char *value) {
+  free(key);
+}
+
+static void readStylesheet(struct UserCSS *userCSS, const char *filename,
+                           char **style, size_t *len) {
+  int fd                  = open(filename, O_RDONLY);
   struct stat st;
   if (fd < 0 || fstat(fd, &st)) {
     fatal("Cannot access style sheet \"%s\"", filename);
   }
   FILE *fp;
-  check(fp             = fdopen(fd, "r"));
-  check(*style         = malloc(st.st_size + 1));
+  check(fp                = fdopen(fd, "r"));
+  check(*style            = malloc(st.st_size + 1));
   check(fread(*style, 1, st.st_size, fp) == st.st_size);
-  (*style)[st.st_size] = '\000';
-  *len                 = st.st_size;
+  (*style)[st.st_size]    = '\000';
+  *len                    = st.st_size;
   fclose(fp);
+  if (!memcmp(*style, "/* DEFINES_", 11)) {
+    char *e               = strchr(*style + 11, ' ');
+    if (e) {
+      if (!defines) {
+        defines           = newHashMap(definesDestructor, NULL);
+      }
+      char *def;
+      check(def           = malloc(e - *style - 2));
+      memcpy(def, *style + 3, e - *style - 3);
+      def[e - *style - 3] = '\000';
+      addToHashMap(defines, def, (char *)userCSS);
+    }
+  }
 }
 
 void initUserCSS(struct UserCSS *userCSS, const char *arg) {
@@ -130,7 +150,8 @@ void initUserCSS(struct UserCSS *userCSS, const char *arg) {
               "active by default");
     }
 
-    readStylesheet(filename + 1, (char **)&userCSS->style, &userCSS->styleLen);
+    readStylesheet(userCSS, filename + 1, (char **)&userCSS->style,
+                   &userCSS->styleLen);
     free(filename);
 
     arg                                   = colon + 1 + filenameLen;
@@ -208,3 +229,10 @@ char *getUserCSSString(struct UserCSS *userCSS) {
   }
   return stringPrintf(s, " ]");
 }
+
+struct UserCSS *userCSSGetDefine(const char *def) {
+  if (!defines) {
+    return NULL;
+  }
+  return (struct UserCSS *)getFromHashMap(defines, def);
+}
index 5747530e53fed2579dc7c8e82fe3c7c61a170f38..73019ebd1ec212d85714188aa165deef9ce0e59a 100644 (file)
@@ -61,5 +61,6 @@ void parseUserCSS(struct UserCSS **userCSSList, const char *arg);
 void destroyUserCSS(struct UserCSS *userCSS);
 void deleteUserCSS(struct UserCSS *userCSS);
 char *getUserCSSString(struct UserCSS *userCSS);
+struct UserCSS *userCSSGetDefine(const char *def);
 
 #endif
index bf064850022be99f7c47f730eb5199bbbbc3d5d9..9f8cc89a77eb9770c56ba7719e25e9d5eb1da997 100644 (file)
@@ -1892,7 +1892,7 @@ VT100.prototype.toggleBell = function() {
 };
 
 VT100.prototype.about = function() {
-  alert("VT100 Terminal Emulator " + "2.9 (revision 171)" +
+  alert("VT100 Terminal Emulator " + "2.9 (revision 172)" +
         "\nCopyright 2008-2009 by Markus Gutschke\n" +
         "For more information check http://shellinabox.com");
 };
This page took 0.086886 seconds and 5 git commands to generate.