1 /* 2 * Copyright 2009-2017 Citrix Ltd and other contributors 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published 6 * by the Free Software Foundation; version 2.1 only. with the special 7 * exception on linking described in file LICENSE. 8 * 9 * This program 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 Lesser General Public License for more details. 13 */ 14 15 #ifndef XL_PARSE_H 16 #define XL_PARSE_H 17 18 #include <libxl.h> 19 20 void parse_config_data(const char *config_source, 21 const char *config_data, 22 int config_len, 23 libxl_domain_config *d_config); 24 int parse_range(const char *str, unsigned long *a, unsigned long *b); 25 int64_t parse_mem_size_kb(const char *mem); 26 void parse_disk_config(XLU_Config **config, const char *spec, 27 libxl_device_disk *disk); 28 29 void parse_disk_config_multistring(XLU_Config **config, 30 int nspecs, const char *const *specs, 31 libxl_device_disk *disk); 32 int parse_usbctrl_config(libxl_device_usbctrl *usbctrl, char *token); 33 int parse_usbdev_config(libxl_device_usbdev *usbdev, char *token); 34 int parse_cpurange(const char *cpu, libxl_bitmap *cpumap); 35 int parse_nic_config(libxl_device_nic *nic, XLU_Config **config, char *token); 36 int parse_vdispl_config(libxl_device_vdispl *vdispl, char *token); 37 38 int match_option_size(const char *prefix, size_t len, 39 char *arg, char **argopt); 40 #define MATCH_OPTION(prefix, arg, oparg) \ 41 match_option_size((prefix "="), sizeof((prefix)), (arg), &(oparg)) 42 43 44 void split_string_into_string_list(const char *str, const char *delim, 45 libxl_string_list *psl); 46 int split_string_into_pair(const char *str, const char *delim, 47 char **a, char **b); 48 void replace_string(char **str, const char *val); 49 50 /* NB: this follows the interface used by <ctype.h>. See 'man 3 ctype' 51 and look for CTYPE in libxl_internal.h */ 52 typedef int (*char_predicate_t)(const int c); 53 void trim(char_predicate_t predicate, const char *input, char **output); 54 55 const char *get_action_on_shutdown_name(libxl_action_on_shutdown a); 56 57 #endif /* XL_PARSE_H */ 58 59 /* 60 * Local variables: 61 * mode: C 62 * c-basic-offset: 4 63 * indent-tabs-mode: nil 64 * End: 65 */ 66