/[mod_ua_charset]/mod_ua_charset.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /mod_ua_charset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by dpavlin, Tue Apr 18 06:54:05 2000 UTC revision 1.4 by dpavlin, Tue Apr 18 07:36:39 2000 UTC
# Line 57  Line 57 
57    
58  /* charset module  /* charset module
59   *   *
60     * sets `Contnet-type: text/html; charset=foobar' based on user agent string
61     * from client browser
62     *
63     * Dobrica Pavlinusic <dpavlin@rot13.org>
64     * Robert Avilov <ravilov@linux.hr>
65     *
66   */   */
67    
68    
69  #include "httpd.h"  #include "httpd.h"
 #include "http_config.h"  
70  #include "http_core.h"  #include "http_core.h"
71    #include "http_config.h"
72    
73  module MODULE_VAR_EXPORT ua_charset_module;  module MODULE_VAR_EXPORT ua_charset_module;
74    
75  static int add_charset_header(request_rec * r)  static int add_charset_header(request_rec * r)
76  {  {
77          char *ua, *ct;          const char *ua, *ct;
78          if (ua = ap_table_get(r->headers_in, "User-Agent")) {  
79                  ap_table_setn(r->headers_out, "X-User-Agent", ua);          ua = ap_table_get(r->headers_in, "User-Agent");
80          }          if (ua == NULL)
81  #if 1                  ua = "<unknown>";
82          if (ct = ap_table_get(r->headers_in, "Content-type")) {  
83                  ap_table_setn(r->headers_out, "X-Content-type", ct);          ct = r->content_type;
84          }  
85          if (strstr(ct, "text/html")) {          if (ct != NULL) {
86                  return DECLINED;        /* don't mess with other types */  
87          }                  if (strstr(ct, "text/html") == NULL)
88          if (strstr(ua, "Mac")) {                          return DECLINED; /* Don't mess with other types */
89                  if (strstr(ua, "MSIE")) {  
90                          r->content_type = "text/html; charset=x-mac-roman";                  if (strstr(ua, "Mac") != NULL) {
91                  } else {                          if (strstr(ua, "MSIE") != NULL)
92                          r->content_type = "text/html; charset=MacCE";                                  r->content_type = "text/html; charset=x-mac-roman";
93                            else
94                                    r->content_type = "text/html; charset=MacCE";
95                    } else
96                            r->content_type = "text/html; charset=iso-8859-2";
97                  }                  }
         } else {  
                 r->content_type = "text/html; charset=iso-8859-2";  
         }  
98    
99    #ifdef DEBUG
100            ap_table_setn(r->headers_out, "X-Content-Type", ct);
101            ap_table_setn(r->headers_out, "X-User-Agent", ua);
102  #endif  #endif
103          return OK;          return OK;
         return DECLINED;  
104  }  }
105    
106  module MODULE_VAR_EXPORT ua_charset_module = {  module MODULE_VAR_EXPORT ua_charset_module = {
107          STANDARD_MODULE_STUFF, NULL,    /* initializer */          STANDARD_MODULE_STUFF,
108            NULL,                   /* initializer */
109          NULL,                   /* dir config creater */          NULL,                   /* dir config creater */
110          NULL,                   /* dir merger --- default is to override */          NULL,                   /* dir merger --- default is to override */
111          NULL,                   /* server config */          NULL,                   /* server config */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.26