/[jscoverage]/trunk/jscoverage-server.c
ViewVC logotype

Diff of /trunk/jscoverage-server.c

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

revision 299 by siliconforks, Mon Oct 13 02:39:58 2008 UTC revision 447 by siliconforks, Sun Aug 9 16:21:27 2009 UTC
# Line 1  Line 1 
1  /*  /*
2      jscoverage-server.c - JSCoverage server main routine      jscoverage-server.c - JSCoverage server main routine
3      Copyright (C) 2008 siliconforks.com      Copyright (C) 2008, 2009 siliconforks.com
4    
5      This program is free software; you can redistribute it and/or modify      This program is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published by      it under the terms of the GNU General Public License as published by
# Line 444  Line 444 
444      case '\t':      case '\t':
445        fputs("\\t", f);        fputs("\\t", f);
446        break;        break;
447        /* IE doesn't support this */
448        /*
449      case '\v':      case '\v':
450        fputs("\\v", f);        fputs("\\v", f);
451        break;        break;
452        */
453      case '"':      case '"':
454        fputs("\\\"", f);        fputs("\\\"", f);
455        break;        break;
# Line 513  Line 516 
516      else {      else {
517        /* check that the path begins with / */        /* check that the path begins with / */
518        if (file_coverage->id[0] == '/') {        if (file_coverage->id[0] == '/') {
519          char * source_path = make_path(document_root, file_coverage->id + 1);          char * decoded_path = decode_uri_component(file_coverage->id);
520            if (strstr(decoded_path, "..") != NULL) {
521              free(decoded_path);
522              fputs("[]", f);
523              HTTPServer_log_err("Warning: invalid source path: %s\n", file_coverage->id);
524              goto done;
525            }
526            char * source_path = make_path(document_root, decoded_path + 1);
527            free(decoded_path);
528          FILE * source_file = fopen(source_path, "rb");          FILE * source_file = fopen(source_path, "rb");
529          free(source_path);          free(source_path);
530          if (source_file == NULL) {          if (source_file == NULL) {
# Line 560  Line 571 
571      }      }
572      fputc(']', f);      fputc(']', f);
573    }    }
574    done:
575    fputc('}', f);    fputc('}', f);
576  }  }
577    
# Line 711  Line 723 
723        return;        return;
724      }      }
725      if (strcmp(abs_path, "/jscoverage.js") == 0) {      if (strcmp(abs_path, "/jscoverage.js") == 0) {
726        const char * s = "jscoverage_isServer = true;\n";        const char * s = "jscoverage_isServer = true;\r\n";
727        if (HTTPExchange_write_response(exchange, s, strlen(s)) != 0) {        if (HTTPExchange_write_response(exchange, s, strlen(s)) != 0) {
728          HTTPServer_log_err("Warning: error writing to client\n");          HTTPServer_log_err("Warning: error writing to client\n");
729        }        }
# Line 853  Line 865 
865      free(encoding);      free(encoding);
866      Stream_delete(input_stream);      Stream_delete(input_stream);
867      if (result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED) {      if (result == JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED) {
868        send_response(client_exchange, 502, "Encoding not supported\n");        send_response(client_exchange, 500, "Encoding not supported\n");
869        goto done;        goto done;
870      }      }
871      else if (result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE) {      else if (result == JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE) {
# Line 1111  Line 1123 
1123        exit(EXIT_SUCCESS);        exit(EXIT_SUCCESS);
1124      }      }
1125      else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {      else if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {
1126        printf("jscoverage-server %s\n", VERSION);        version();
       exit(EXIT_SUCCESS);  
1127      }      }
1128      else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {      else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--verbose") == 0) {
1129        verbose = 1;        verbose = 1;
# Line 1164  Line 1175 
1175        ip_address = argv[i] + 13;        ip_address = argv[i] + 13;
1176      }      }
1177    
1178        else if (strcmp(argv[i], "--js-version") == 0) {
1179          i++;
1180          if (i == argc) {
1181            fatal_command_line("--js-version: option requires an argument");
1182          }
1183          jscoverage_set_js_version(argv[i]);
1184        }
1185        else if (strncmp(argv[i], "--js-version=", 13) == 0) {
1186          jscoverage_set_js_version(argv[i] + 13);
1187        }
1188    
1189      else if (strcmp(argv[i], "--no-highlight") == 0) {      else if (strcmp(argv[i], "--no-highlight") == 0) {
1190        jscoverage_highlight = false;        jscoverage_highlight = false;
1191      }      }

Legend:
Removed from v.299  
changed lines
  Added in v.447

  ViewVC Help
Powered by ViewVC 1.1.24