cmd.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. #ifndef CMD_H
  20. #define CMD_H
  21. #include <inttypes.h>
  22. #include "host/ble_uuid.h"
  23. struct kv_pair {
  24. char *key;
  25. int val;
  26. };
  27. const struct kv_pair *parse_kv_find(const struct kv_pair *kvs, char *name);
  28. int parse_arg_find_idx(const char *key);
  29. char *parse_arg_extract(const char *key);
  30. long parse_arg_long_bounds(char *name, long min, long max, int *out_status);
  31. long parse_arg_long_bounds_dflt(char *name, long min, long max,
  32. long dflt, int *out_status);
  33. uint64_t parse_arg_uint64_bounds(char *name, uint64_t min,
  34. uint64_t max, int *out_status);
  35. long parse_arg_long(char *name, int *staus);
  36. uint8_t parse_arg_bool(char *name, int *status);
  37. uint8_t parse_arg_bool_dflt(char *name, uint8_t dflt, int *out_status);
  38. uint8_t parse_arg_uint8(char *name, int *status);
  39. uint8_t parse_arg_uint8_dflt(char *name, uint8_t dflt, int *out_status);
  40. uint16_t parse_arg_uint16(char *name, int *status);
  41. uint16_t parse_arg_uint16_dflt(char *name, uint16_t dflt, int *out_status);
  42. uint32_t parse_arg_uint32(char *name, int *out_status);
  43. uint32_t parse_arg_uint32_dflt(char *name, uint32_t dflt, int *out_status);
  44. uint64_t parse_arg_uint64(char *name, int *out_status);
  45. int parse_arg_kv(char *name, const struct kv_pair *kvs, int *out_status);
  46. int parse_arg_kv_dflt(char *name, const struct kv_pair *kvs, int def_val,
  47. int *out_status);
  48. int parse_arg_byte_stream(char *name, int max_len, uint8_t *dst, int *out_len);
  49. int parse_arg_byte_stream_exact_length(char *name, uint8_t *dst, int len);
  50. int parse_arg_mac(char *name, uint8_t *dst);
  51. int parse_arg_uuid(char *name, ble_uuid_any_t *uuid);
  52. int parse_arg_all(int argc, char **argv);
  53. int parse_eddystone_url(char *full_url, uint8_t *out_scheme, char *out_body,
  54. uint8_t *out_body_len, uint8_t *out_suffix);
  55. int cmd_parse_conn_start_end(uint16_t *out_conn, uint16_t *out_start,
  56. uint16_t *out_end);
  57. void cmd_init(void);
  58. #endif