2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of quvi <http://quvi.sourceforge.net/>.
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this program. If not, see
18 * <http://www.gnu.org/licenses/>.
29 /* Validate string value to possible values. */
30 gint
lopts_chk_str(const gchar
*opt_val
, const gchar
**ok_strv
, gchar
**dst
)
37 return (EXIT_SUCCESS
);
39 for (i
=0, r
=EXIT_FAILURE
; ok_strv
[i
] != NULL
; ++i
)
41 if (g_strcmp0(ok_strv
[i
], opt_val
) == 0)
48 if (r
== EXIT_FAILURE
)
49 *dst
= (gchar
*) opt_val
;
54 /* Validate string array of values to possible values. */
55 gint
lopts_chk_strv(const gchar
**opt_val
, const gchar
**ok_strv
, gchar
**dst
)
62 return (EXIT_SUCCESS
);
64 for (i
=0, r
=EXIT_SUCCESS
; opt_val
[i
] != NULL
&& r
== EXIT_SUCCESS
; ++i
)
65 r
= lopts_chk_str(opt_val
[i
], ok_strv
, dst
);
70 /* Validate regex patterns. */
71 gint
lopts_chk_re(const gchar
**opt_val
, gchar
**dst
)
79 return (EXIT_SUCCESS
);
81 for (i
=0, r
=EXIT_SUCCESS
; opt_val
[i
] != NULL
&& r
== EXIT_SUCCESS
; ++i
)
83 lutil_regex_op_new(opt_val
[i
], &is_valid
);
84 if (is_valid
== FALSE
)
86 *dst
= (gchar
*) opt_val
[i
];
93 /* vim: set ts=2 sw=2 tw=72 expandtab: */