PageRenderTime 398ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/generate-resources.c

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
C | 58 lines | 36 code | 4 blank | 18 comment | 8 complexity | b8a5ca96b30e44592fc9ba1b692510ec MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /*
  2. generate-resources.c - code generator for embedded resources
  3. Copyright (C) 2007, 2008 siliconforks.com
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #include <ctype.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <sys/stat.h>
  21. int main(int argc, char ** argv) {
  22. for (int i = 1; i < argc; i++) {
  23. printf("const unsigned char RESOURCE%d_[] = {\n", i);
  24. FILE * f = fopen(argv[i], "rb");
  25. if (f == NULL) {
  26. fprintf(stderr, "cannot open file %s\n", argv[i]);
  27. exit(EXIT_FAILURE);
  28. }
  29. int c;
  30. int j = 0;
  31. while ((c = fgetc(f)) != EOF) {
  32. if (j % 16 == 0) {
  33. printf("\n ");
  34. }
  35. printf("0x%02x,", c);
  36. j++;
  37. }
  38. fclose(f);
  39. printf("\n};\n");
  40. }
  41. printf("const struct Resource RESOURCES[] = {\n");
  42. for (int i = 1; i < argc; i++) {
  43. printf(" {\n");
  44. printf(" \"%s\",\n", argv[i]);
  45. printf(" RESOURCE%d_,\n", i);
  46. printf(" sizeof(RESOURCE%d_)\n", i);
  47. printf(" },\n");
  48. }
  49. printf("};\n");
  50. exit(EXIT_SUCCESS);
  51. }