/[jscoverage]/tags/jscoverage-0.4/jscoverage-server.c
ViewVC logotype

Diff of /tags/jscoverage-0.4/jscoverage-server.c

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

revision 146 by siliconforks, Thu Jun 19 19:33:05 2008 UTC revision 174 by siliconforks, Sat Sep 20 23:27:14 2008 UTC
# Line 29  Line 29 
29  #include <pthread.h>  #include <pthread.h>
30  #endif  #endif
31    
32    #include "global.h"
33  #include "http-server.h"  #include "http-server.h"
34  #include "instrument-js.h"  #include "instrument-js.h"
35  #include "resource-manager.h"  #include "resource-manager.h"
36  #include "stream.h"  #include "stream.h"
37  #include "util.h"  #include "util.h"
38    
39    const char * jscoverage_encoding = "ISO-8859-1";
40    
41  typedef struct SourceCache {  typedef struct SourceCache {
42    char * url;    char * url;
43    Stream * source;    Stream * source;
# Line 616  Line 619 
619    }    }
620  }  }
621    
622  static void instrument_js(const char * id, Stream * input_stream, Stream * output_stream) {  static void instrument_js(const char * id, const char * encoding, Stream * input_stream, Stream * output_stream) {
623    LOCK(&javascript_mutex);    LOCK(&javascript_mutex);
624    jscoverage_instrument_js(id, input_stream, output_stream);    jscoverage_instrument_js(id, encoding, input_stream, output_stream);
625    UNLOCK(&javascript_mutex);    UNLOCK(&javascript_mutex);
626    
627    const struct Resource * resource = get_resource("report.js");    const struct Resource * resource = get_resource("report.js");
# Line 741  Line 744 
744    
745      const char * request_uri = HTTPExchange_get_request_uri(client_exchange);      const char * request_uri = HTTPExchange_get_request_uri(client_exchange);
746      Stream * output_stream = Stream_new(0);      Stream * output_stream = Stream_new(0);
747      instrument_js(request_uri, input_stream, output_stream);      instrument_js(request_uri, jscoverage_encoding, input_stream, output_stream);
748    
749      /* send the headers to the client */      /* send the headers to the client */
750      for (const HTTPHeader * h = HTTPExchange_get_response_headers(server_exchange); h != NULL; h = h->next) {      for (const HTTPHeader * h = HTTPExchange_get_response_headers(server_exchange); h != NULL; h = h->next) {
# Line 889  Line 892 
892    
893        Stream_write_file_contents(input_stream, f);        Stream_write_file_contents(input_stream, f);
894    
895        instrument_js(abs_path, input_stream, output_stream);        instrument_js(abs_path, jscoverage_encoding, input_stream, output_stream);
896    
897        if (HTTPExchange_write_response(exchange, output_stream->data, output_stream->length) != 0) {        if (HTTPExchange_write_response(exchange, output_stream->data, output_stream->length) != 0) {
898          HTTPServer_log_err("Warning: error writing to client\n");          HTTPServer_log_err("Warning: error writing to client\n");
# Line 975  Line 978 
978        document_root = argv[i] + 16;        document_root = argv[i] + 16;
979      }      }
980    
981        else if (strcmp(argv[i], "--encoding") == 0) {
982          i++;
983          if (i == argc) {
984            fatal("--encoding: option requires an argument");
985          }
986          jscoverage_encoding = argv[i];
987        }
988        else if (strncmp(argv[i], "--encoding=", 11) == 0) {
989          jscoverage_encoding = argv[i] + 11;
990        }
991    
992      else if (strcmp(argv[i], "--ip-address") == 0) {      else if (strcmp(argv[i], "--ip-address") == 0) {
993        i++;        i++;
994        if (i == argc) {        if (i == argc) {

Legend:
Removed from v.146  
changed lines
  Added in v.174

  ViewVC Help
Powered by ViewVC 1.1.24