output_modules.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * ZMap Copyright 2013 Regents of the University of Michigan
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy
  6. * of the License at http://www.apache.org/licenses/LICENSE-2.0
  7. */
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include "output_modules.h"
  11. extern output_module_t module_csv_file;
  12. #ifdef REDIS
  13. extern output_module_t module_redis;
  14. extern output_module_t module_redis_csv;
  15. extern output_module_t module_csv_redis;
  16. #endif
  17. #ifdef JSON
  18. extern output_module_t module_json_file;
  19. #endif
  20. #ifdef MONGODB
  21. extern output_module_t module_mongodb;
  22. #endif
  23. output_module_t* output_modules[] = {
  24. &module_csv_file,
  25. #ifdef REDIS
  26. &module_redis,
  27. &module_redis_csv,
  28. #endif
  29. #ifdef JSON
  30. &module_json_file,
  31. #endif
  32. #ifdef MONGODB
  33. &module_mongodb,
  34. #endif
  35. // ADD YOUR MODULE HERE
  36. };
  37. output_module_t* get_output_module_by_name(const char* name)
  38. {
  39. int num_modules = (int) (sizeof(output_modules)/sizeof(output_modules[0]));
  40. for (int i=0; i < num_modules; i++) {
  41. if (!strcmp(output_modules[i]->name, name)) {
  42. return output_modules[i];
  43. }
  44. }
  45. return NULL;
  46. }
  47. void print_output_modules(void)
  48. {
  49. int num_modules = (int) (sizeof(output_modules)/sizeof(output_modules[0]));
  50. for (int i=0; i < num_modules; i++) {
  51. printf("%s\n", output_modules[i]->name);
  52. }
  53. }