Text::Markdown::Discount
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
891 B

  1. /*
  2. * mkdio -- markdown front end input functions
  3. *
  4. * Copyright (C) 2007 David L Parsons.
  5. * The redistribution terms are provided in the COPYRIGHT file that must
  6. * be distributed with this source code.
  7. */
  8. #include "config.h"
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <ctype.h>
  12. #include "mkdio.h"
  13. #include "cstring.h"
  14. #include "amalloc.h"
  15. static char *
  16. e_basename(const char *string, const int size, void *context)
  17. {
  18. char *ret;
  19. char *base = (char*)context;
  20. if ( base && string && (*string == '/') && (ret=malloc(strlen(base)+size+2)) ) {
  21. strcpy(ret, base);
  22. strncat(ret, string, size);
  23. return ret;
  24. }
  25. return 0;
  26. }
  27. static void
  28. e_free(char *string, void *context)
  29. {
  30. if ( string ) free(string);
  31. }
  32. void
  33. mkd_basename(MMIOT *document, char *base)
  34. {
  35. mkd_e_url(document, e_basename);
  36. mkd_e_data(document, base);
  37. mkd_e_free(document, e_free);
  38. }