Debian Codegraph @

ext/basename.c

raw symbols SCIP
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
13 #include "mkdio.h"
14 #include "cstring.h"
15 #include "amalloc.h"
16
17 static char *
18 e_basename(const char *string, const int size, void *context)
19 {
20 char *ret;
21 char *base = (char*)context;
22
23 if ( base && string && (*string == '/') && (ret=malloc(strlen(base)+size+2)) ) {
24 strcpy(ret, base);
25 strncat(ret, string, size);
26 return ret;
27 }
28 return 0;
29 }
30
31 static void
32 e_free(char *string, void *context)
33 {
34 if ( string ) free(string);
35 }
36
37 void
38 mkd_basename(MMIOT *document, char *base)
39 {
40 mkd_e_url(document, e_basename);
41 mkd_e_data(document, base);
42 mkd_e_free(document, e_free);
43 }