Markus Armbruster | f5bebbb | 2014-09-30 13:59:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Dealing with identifiers |
| 3 | * |
| 4 | * Copyright (C) 2014 Red Hat, Inc. |
| 5 | * |
| 6 | * Authors: |
| 7 | * Markus Armbruster <armbru@redhat.com>, |
| 8 | * |
| 9 | * This work is licensed under the terms of the GNU LGPL, version 2.1 |
| 10 | * or later. See the COPYING.LIB file in the top-level directory. |
| 11 | */ |
| 12 | |
| 13 | #include "qemu-common.h" |
| 14 | |
| 15 | bool id_wellformed(const char *id) |
| 16 | { |
| 17 | int i; |
| 18 | |
| 19 | if (!qemu_isalpha(id[0])) { |
| 20 | return false; |
| 21 | } |
| 22 | for (i = 1; id[i]; i++) { |
| 23 | if (!qemu_isalnum(id[i]) && !strchr("-._", id[i])) { |
| 24 | return false; |
| 25 | } |
| 26 | } |
| 27 | return true; |
| 28 | } |