/*- * Copyright (c) 2015, 2016 Taylor R. Campbell * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include #include "hdaudio.pb.h" int main(int argc, char **argv) { prop_array_t arr; prop_object_t obj; struct hdaudio_fgrp_pin_config pin_config; char *plist; int error; if (argc != 3 || strcmp(argv[1], "-d") != 0) errx(1, "Usage: %s -d \n", getprogname()); arr = prop_array_internalize_from_file(argv[2]); if (arr == NULL) errx(1, "failed to read prop arr"); pb_init(hdaudio_fgrp_pin_config(&pin_config)); error = pb_prop_decode(hdaudio_fgrp_pin_config(&pin_config), arr); if (error) { errno = error; err(1, "decode prop arr"); } prop_object_release(arr); arr = NULL; error = pb_prop_encode(hdaudio_fgrp_pin_config(&pin_config), &obj); if (error) { errno = error; err(1, "encode prop arr"); } assert(prop_object_type(obj) == PROP_TYPE_ARRAY); arr = obj; plist = prop_array_externalize(arr); if (plist == NULL) errx(1, "failed to encode prop arr"); (void)printf("%s", plist); free(plist); prop_object_release(arr); pb_destroy(hdaudio_fgrp_pin_config(&pin_config)); return 0; }