testmod.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "../list.h"
  4. #include "../mapcalc.h"
  5. #include "../map.h"
  6. /*
  7. * Required function:
  8. * Return the name of the main function which is useable in v.mapcalc.
  9. */
  10. char *fname(void)
  11. {
  12. return "dltest";
  13. }
  14. /*
  15. * Required function:
  16. * Return the prototype of the main function. Generally, it's the initial
  17. * letter of the C-type, plus "m" for (MAP *) and "p" for (POINT *).
  18. * Indirection doesn't fully work, but to return a pointer to one of the
  19. * above types, the letter "a" is used ("ai" means an integer pointer).
  20. *
  21. * Each prototype needs to be represented by one of the typedef and switch
  22. * cases in func.c of mapcalc.
  23. */
  24. char *proto(void)
  25. {
  26. return "m=mm";
  27. }
  28. /*
  29. * This is the main function which needs to have the name and prototype
  30. * as returned above.
  31. */
  32. MAP *dltest(MAP * m, MAP * n)
  33. {
  34. char namebuf[128];
  35. printf("Performing 2 arg dynamically loaded map function on maps "
  36. "%s and %s\n", m->name, n->name);
  37. sprintf(namebuf, "%s.%s", m->name, n->name);
  38. m = (MAP *) listitem(sizeof(MAP));
  39. m->name = strdup(namebuf);
  40. return m;
  41. }