1 /* This file is part of Pazpar2.
2 Copyright (C) 2006-2011 Index Data
4 Pazpar2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 /** \file facet_limit.c
21 \brief Parse facet limit
31 #include <yaz/yaz-version.h>
34 #include "facet_limit.h"
42 facet_limits_t facet_limits_create(const char *param)
45 NMEM nmem = nmem_create();
46 facet_limits_t fl = nmem_malloc(nmem, sizeof(*fl));
51 nmem_strsplit_escape2(fl->nmem, ",", param, &fl->darray,
52 &fl->num, 1, '\\', 0);
53 /* replace = with \0 .. for each item */
54 for (i = 0; i < fl->num; i++)
56 char *cp = strchr(fl->darray[i], '=');
59 facet_limits_destroy(fl);
67 int facet_limits_num(facet_limits_t fl)
72 const char *facet_limits_get(facet_limits_t fl, int idx, const char **value)
74 if (idx >= fl->num || idx < 0)
76 *value = fl->darray[idx] + strlen(fl->darray[idx]) + 1;
77 return fl->darray[idx];
80 void facet_limits_destroy(facet_limits_t fl)
83 nmem_destroy(fl->nmem);
89 * c-file-style: "Stroustrup"
90 * indent-tabs-mode: nil
92 * vim: shiftwidth=4 tabstop=8 expandtab