1 /* This file is part of GNU Pies
2    Copyright (C) 2015-2020 Sergey Poznyakoff
3 
4    GNU Pies 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 3, or (at your option)
7    any later version.
8 
9    GNU Pies is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with GNU Pies.  If not, see <http://www.gnu.org/licenses/>. */
16 
17 #ifdef HAVE_CONFIG_H
18 # include <config.h>
19 #endif
20 #include <errno.h>
21 #include <grecs.h>
22 #include "libpies.h"
23 #include "grecsasrt.h"
24 
25 int
conf_callback_url(enum grecs_callback_command cmd,grecs_node_t * node,void * varptr,void * cb_data)26 conf_callback_url (enum grecs_callback_command cmd,
27 		   grecs_node_t *node,
28 		   void *varptr, void *cb_data)
29 {
30   grecs_locus_t *locus = &node->locus;
31   grecs_value_t *value = node->v.value;
32   struct pies_url *url;
33 
34   if (grecs_assert_node_value_type (cmd, node, GRECS_TYPE_STRING))
35     return 1;
36   if (pies_url_create (&url, value->v.string))
37     {
38       grecs_error (locus, 0, _("%s: cannot create URL: %s"),
39 		    value->v.string, strerror (errno));
40       return 0;
41     }
42   if (varptr)
43     *(struct pies_url **) varptr = url;
44   else
45     pies_url_destroy (&url);
46   return 0;
47 }
48 
49