| 1 | /* |
| 2 | * Copyright (c) 2018, 2020 Moritz Grimm <[email protected]> |
| 3 | * |
| 4 | * Permission to use, copy, modify, and distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:412:9`! |
| 18 | # include "config.h"cxx . . $ `<file>/src/config.h`/ |
| 19 | #endif |
| 20 | |
| 21 | #include "compat.h"cxx . . $ `<file>/compat/compat.h`/ |
| 22 | |
| 23 | #if defined(HAVE_LIBGEN_Hcxx . . $ `src/config.h:23:9`!) && !defined(__linux__cxx . . $ `<built-in>:400:9`!) |
| 24 | # include <libgen.h> |
| 25 | #endif /* HAVE_LIBGEN_H && !__linux__ */ |
| 26 | #include <limits.h> |
| 27 | #include <stdio.h> |
| 28 | #include <string.h> |
| 29 | #include <unistd.h> |
| 30 | |
| 31 | #include "cfg.h"cxx . . $ `<file>/src/cfg.h`/ |
| 32 | #include "cfgfile_xml.h"cxx . . $ `<file>/src/cfgfile_xml.h`/ |
| 33 | #include "ezconfig0.h"cxx . . $ `<file>/src/ezconfig0.h`/ |
| 34 | #include "log.h"cxx . . $ `<file>/src/log.h`/ |
| 35 | #include "util.h"cxx . . $ `<file>/src/util.h`/ |
| 36 | #include "xalloc.h"cxx . . $ `<file>/src/xalloc.h`/ |
| 37 | |
| 38 | static char *v0_cfgfilecxx . . $ v0_cfgfile.; |
| 39 | static unsigned int cfg_verbositycxx . . $ cfg_verbosity.; |
| 40 | |
| 41 | #define OPTSTRINGcxx . . $ `src/ezstream-cfgmigrate.c:41:9`! "0:hv" |
| 42 | enum opt_valscxx . . $ opt_vals# { |
| 43 | OPT_V0CONFIGFILEcxx . . $ OPT_V0CONFIGFILE. = '0', |
| 44 | OPT_HELPcxx . . $ OPT_HELP. = 'h', |
| 45 | OPT_VERBOSEcxx . . $ OPT_VERBOSE. = 'v', |
| 46 | OPT_INVALIDcxx . . $ OPT_INVALID. = '?' |
| 47 | }; |
| 48 | |
| 49 | static void _usagecxx . . $ _usage(49f6e7a06ebc5aa8).(void); |
| 50 | static void _usage_helpcxx . . $ _usage_help(49f6e7a06ebc5aa8).(void); |
| 51 | static int _cmdline_parsecxx . . $ _cmdline_parse(e4d6922c49795a40).(int, char *[], int *); |
| 52 | static int _url_parsecxx . . $ _url_parse(faa5c541033cd4e3).(const char *, char **, char **, char **); |
| 53 | static int _parse_ezconfig0cxx . . $ _parse_ezconfig0(99d3d34331ef3c0e).(EZCONFIGcxx . . $ EZCONFIG# *); |
| 54 | |
| 55 | static void |
| 56 | _usagecxx . . $ _usage(49f6e7a06ebc5aa8).(void) |
| 57 | { |
| 58 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "usage: %s [-hv] -0 v0-cfgfile\n", |
| 59 | util_get_prognamecxx . . $ util_get_progname(fb58d2e09a2a1ce6).(NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!)); |
| 60 | } |
| 61 | |
| 62 | static void |
| 63 | _usage_helpcxx . . $ _usage_help(49f6e7a06ebc5aa8).(void) |
| 64 | { |
| 65 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "\n"); |
| 66 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " -0 v0-cfgfile migrate from v0-cfgfile (ezstream version 0.x)\n"); |
| 67 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " -h print this help and exit\n"); |
| 68 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, " -v increase logging verbosity\n"); |
| 69 | } |
| 70 | |
| 71 | static int |
| 72 | _cmdline_parsecxx . . $ _cmdline_parse(e4d6922c49795a40).(int argc, char *argv[], int *ret_p) |
| 73 | { |
| 74 | v0_cfgfilecxx . . $ v0_cfgfile. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 75 | cfg_verbositycxx . . $ cfg_verbosity. = 0; |
| 76 | optindcxx . . $ optind. = 1; |
| 77 | for (;;) { |
| 78 | int ch; |
| 79 | |
| 80 | ch = getoptcxx . . $ getopt(2483c31ff9bab884).(argc, argv, OPTSTRINGcxx . . $ `src/ezstream-cfgmigrate.c:41:9`!); |
| 81 | if (0 > ch) |
| 82 | break; |
| 83 | |
| 84 | switch (ch) { |
| 85 | case OPT_V0CONFIGFILEcxx . . $ OPT_V0CONFIGFILE.: |
| 86 | v0_cfgfilecxx . . $ v0_cfgfile. = optargcxx . . $ optarg.; |
| 87 | break; |
| 88 | case OPT_HELPcxx . . $ OPT_HELP.: |
| 89 | _usagecxx . . $ _usage(49f6e7a06ebc5aa8).(); |
| 90 | _usage_helpcxx . . $ _usage_help(49f6e7a06ebc5aa8).(); |
| 91 | *ret_p = 0; |
| 92 | return (-1); |
| 93 | case OPT_VERBOSEcxx . . $ OPT_VERBOSE.: |
| 94 | cfg_verbositycxx . . $ cfg_verbosity.++; |
| 95 | break; |
| 96 | case OPT_INVALIDcxx . . $ OPT_INVALID.: |
| 97 | default: |
| 98 | _usagecxx . . $ _usage(49f6e7a06ebc5aa8).(); |
| 99 | *ret_p = 2; |
| 100 | return (-1); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | if (!v0_cfgfilecxx . . $ v0_cfgfile.) { |
| 105 | fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "-%c must be provided\n", |
| 106 | OPT_V0CONFIGFILEcxx . . $ OPT_V0CONFIGFILE.); |
| 107 | _usagecxx . . $ _usage(49f6e7a06ebc5aa8).(); |
| 108 | *ret_p = 2; |
| 109 | return (-1); |
| 110 | } |
| 111 | |
| 112 | return (0); |
| 113 | } |
| 114 | |
| 115 | static int |
| 116 | _url_parsecxx . . $ _url_parse(faa5c541033cd4e3).(const char *url, char **hostname, char **port, |
| 117 | char **mountname) |
| 118 | { |
| 119 | const char *p1, *p2, *p3; |
| 120 | size_t hostsiz, portsiz, mountsiz; |
| 121 | |
| 122 | if (strncasecmpcxx . . $ strncasecmp(fd278af2f295fa2e).(url, "http://", strlencxx . . $ strlen(751346f8406fd082).("http://")) != 0) { |
| 123 | log_errorcxx . . $ log_error(581fddd72a8db8fc).("%s: Invalid <url>: Not an HTTP address", |
| 124 | v0_cfgfilecxx . . $ v0_cfgfile.); |
| 125 | return (-1); |
| 126 | } |
| 127 | |
| 128 | p1 = url + strlencxx . . $ strlen(751346f8406fd082).("http://"); |
| 129 | p2 = strchrcxx . . $ `<external>/13506128340496143423/string.h:264:11`!(p1, ':'); |
| 130 | if (p2 == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 131 | log_errorcxx . . $ log_error(581fddd72a8db8fc).("%s: Invalid <url>: Missing port", v0_cfgfilecxx . . $ v0_cfgfile.); |
| 132 | return (-1); |
| 133 | } |
| 134 | hostsiz = (size_t)(p2 - p1) + 1; |
| 135 | *hostname = xmalloccxx . . $ `src/xalloc.h:22:9`!(hostsiz); |
| 136 | strlcpycxx . . $ strlcpy(55abe9014c6d0e39).(*hostname, p1, hostsiz); |
| 137 | |
| 138 | p2++; |
| 139 | p3 = strchrcxx . . $ `<external>/13506128340496143423/string.h:264:11`!(p2, '/'); |
| 140 | if (p3 == NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!) { |
| 141 | log_errorcxx . . $ log_error(581fddd72a8db8fc).("%s: Invalid <url>: Missing mountpoint or too long port number", |
| 142 | v0_cfgfilecxx . . $ v0_cfgfile.); |
| 143 | xfreecxx . . $ `src/xalloc.h:26:9`!(*hostname); |
| 144 | return (-1); |
| 145 | } |
| 146 | |
| 147 | portsiz = (size_t)(p3 - p2) + 1; |
| 148 | *port = xmalloccxx . . $ `src/xalloc.h:22:9`!(portsiz); |
| 149 | strlcpycxx . . $ strlcpy(55abe9014c6d0e39).(*port, p2, portsiz); |
| 150 | |
| 151 | mountsiz = strlencxx . . $ strlen(751346f8406fd082).(p3) + 1; |
| 152 | *mountname = xmalloccxx . . $ `src/xalloc.h:22:9`!(mountsiz); |
| 153 | strlcpycxx . . $ strlcpy(55abe9014c6d0e39).(*mountname, p3, mountsiz); |
| 154 | |
| 155 | return (0); |
| 156 | } |
| 157 | |
| 158 | #define ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(e, el, func, ctx, val) do { \ |
| 159 | const char *err_str2; \ |
| 160 | \ |
| 161 | if (0 > (func)((e), (el), (val), &err_str2)) { \ |
| 162 | log_warning("%s: %s: %s: %s", v0_cfgfile, (ctx), \ |
| 163 | err_str2, (val)); \ |
| 164 | warnings++; \ |
| 165 | } \ |
| 166 | } while (0) |
| 167 | |
| 168 | static int |
| 169 | _parse_ezconfig0cxx . . $ _parse_ezconfig0(99d3d34331ef3c0e).(EZCONFIGcxx . . $ EZCONFIG# *ez) |
| 170 | { |
| 171 | char *hostname, *port, *mountname; |
| 172 | const char *err_str; |
| 173 | int warnings = 0; |
| 174 | cfg_server_list_tcxx . . $ cfg_server_list_t# srv_list = cfg_get_serverscxx . . $ cfg_get_servers(ad3818a383472c4a).(); |
| 175 | cfg_server_tcxx . . $ cfg_server_t# srv = cfg_server_list_getcxx . . $ cfg_server_list_get(a98fd320ccd4534).(srv_list, CFG_DEFAULTcxx . . $ `src/cfg.h:27:9`!); |
| 176 | cfg_stream_list_tcxx . . $ cfg_stream_list_t# str_list = cfg_get_streamscxx . . $ cfg_get_streams(f0c21fd0bbd2a8b).(); |
| 177 | cfg_stream_tcxx . . $ cfg_stream_t# str = cfg_stream_list_getcxx . . $ cfg_stream_list_get(47cc06abd3dd2318).(str_list, CFG_DEFAULTcxx . . $ `src/cfg.h:27:9`!); |
| 178 | cfg_intake_list_tcxx . . $ cfg_intake_list_t# in_list = cfg_get_intakescxx . . $ cfg_get_intakes(6d1209736ac34f33).(); |
| 179 | cfg_intake_tcxx . . $ cfg_intake_t# in = cfg_intake_list_getcxx . . $ cfg_intake_list_get(4b9d0036e0282c96).(in_list, CFG_DEFAULTcxx . . $ `src/cfg.h:27:9`!); |
| 180 | cfg_encoder_list_tcxx . . $ cfg_encoder_list_t# enc_list = cfg_get_encoderscxx . . $ cfg_get_encoders(e957721effb49cb3).(); |
| 181 | cfg_decoder_list_tcxx . . $ cfg_decoder_list_t# dec_list = cfg_get_decoderscxx . . $ cfg_get_decoders(e15359236e44248b).();; |
| 182 | unsigned int i; |
| 183 | char strbuf[BUFSIZcxx . . $ `<external>/232824719582829767/stdio.h:104:9`!]; |
| 184 | |
| 185 | if (NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! == ez->URLcxx . . $ tag_EZCONFIG#URL. || 0 == strlencxx . . $ strlen(751346f8406fd082).(ez->URLcxx . . $ tag_EZCONFIG#URL.)) { |
| 186 | log_errorcxx . . $ log_error(581fddd72a8db8fc).("%s: Missing <url> -- not an ezstream version 0.x configuration?", |
| 187 | v0_cfgfilecxx . . $ v0_cfgfile.); |
| 188 | return (-1); |
| 189 | } |
| 190 | if (0 > _url_parsecxx . . $ _url_parse(faa5c541033cd4e3).(ez->URLcxx . . $ tag_EZCONFIG#URL., &hostname, &port, &mountname)) |
| 191 | return (-1); |
| 192 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(srv, srv_list, cfg_server_set_protocol, "<url>", "HTTP"); |
| 193 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(srv, srv_list, cfg_server_set_hostname, "<url>", hostname); |
| 194 | xfreecxx . . $ `src/xalloc.h:26:9`!(hostname); |
| 195 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(srv, srv_list, cfg_server_set_port, "<url>", port); |
| 196 | xfreecxx . . $ `src/xalloc.h:26:9`!(port); |
| 197 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_mountpoint, "<url>", |
| 198 | mountname); |
| 199 | xfreecxx . . $ `src/xalloc.h:26:9`!(mountname); |
| 200 | |
| 201 | if (ez->usernamecxx . . $ tag_EZCONFIG#username.) |
| 202 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(srv, srv_list, cfg_server_set_user, |
| 203 | "<sourceuser>", ez->username); |
| 204 | if (ez->passwordcxx . . $ tag_EZCONFIG#password.) |
| 205 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(srv, srv_list, cfg_server_set_password, |
| 206 | "<sourcepassword>", ez->password); |
| 207 | if (ez->formatcxx . . $ tag_EZCONFIG#format.) { |
| 208 | if (0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ez->formatcxx . . $ tag_EZCONFIG#format., "vorbis") || |
| 209 | 0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ez->formatcxx . . $ tag_EZCONFIG#format., "theora")) |
| 210 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_format, |
| 211 | "<format>", "Ogg"); |
| 212 | else |
| 213 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_format, |
| 214 | "<format>", ez->format); |
| 215 | } |
| 216 | if (ez->fileNamecxx . . $ tag_EZCONFIG#fileName.) { |
| 217 | if (0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ez->fileNamecxx . . $ tag_EZCONFIG#fileName., "stdin")) |
| 218 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(in, in_list, cfg_intake_set_type, |
| 219 | "<filename>", "stdin"); |
| 220 | else |
| 221 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(in, in_list, cfg_intake_set_filename, |
| 222 | "<filename>", ez->fileName); |
| 223 | } |
| 224 | if (ez->metadataProgramcxx . . $ tag_EZCONFIG#metadataProgram.) { |
| 225 | if (0 > cfg_set_metadata_programcxx . . $ cfg_set_metadata_program(2ef3bc9ee8f8b3e9).(ez->metadataProgramcxx . . $ tag_EZCONFIG#metadataProgram., |
| 226 | &err_str)) { |
| 227 | log_warningcxx . . $ log_warning(581fddd72a8db8fc).("%s: %s: %s: %s", v0_cfgfilecxx . . $ v0_cfgfile., |
| 228 | "<metadata_progname>", err_str, |
| 229 | ez->metadataProgramcxx . . $ tag_EZCONFIG#metadataProgram.); |
| 230 | warnings++; |
| 231 | } |
| 232 | } |
| 233 | if (ez->metadataFormatcxx . . $ tag_EZCONFIG#metadataFormat.) { |
| 234 | if (0 > cfg_set_metadata_format_strcxx . . $ cfg_set_metadata_format_str(2ef3bc9ee8f8b3e9).(ez->metadataFormatcxx . . $ tag_EZCONFIG#metadataFormat., |
| 235 | &err_str)) { |
| 236 | log_warningcxx . . $ log_warning(581fddd72a8db8fc).("%s: %s: %s: %s", v0_cfgfilecxx . . $ v0_cfgfile., |
| 237 | "<metadata_format>", err_str, ez->metadataFormatcxx . . $ tag_EZCONFIG#metadataFormat.); |
| 238 | warnings++; |
| 239 | } |
| 240 | } |
| 241 | if (ez->metadataRefreshIntervalcxx . . $ tag_EZCONFIG#metadataRefreshInterval.) { |
| 242 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(strbuf, sizeof(strbuf), "%d", |
| 243 | ez->metadataRefreshIntervalcxx . . $ tag_EZCONFIG#metadataRefreshInterval.); |
| 244 | if (0 > cfg_set_metadata_refresh_intervalcxx . . $ cfg_set_metadata_refresh_interval(2ef3bc9ee8f8b3e9).(strbuf, &err_str)) { |
| 245 | log_warningcxx . . $ log_warning(581fddd72a8db8fc).("%s: %s: %s: %s", v0_cfgfilecxx . . $ v0_cfgfile., |
| 246 | "<metadata_refreshinterval>", err_str, strbuf); |
| 247 | warnings++; |
| 248 | } |
| 249 | } |
| 250 | if (ez->fileNameIsProgramcxx . . $ tag_EZCONFIG#fileNameIsProgram.) |
| 251 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(in, in_list, cfg_intake_set_type, |
| 252 | "playlist_program", "program"); |
| 253 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(strbuf, sizeof(strbuf), "%d", ez->shufflecxx . . $ tag_EZCONFIG#shuffle.); |
| 254 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(in, in_list, cfg_intake_set_shuffle, |
| 255 | "<shuffle>", strbuf); |
| 256 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(strbuf, sizeof(strbuf), "%d", ez->streamOncecxx . . $ tag_EZCONFIG#streamOnce.); |
| 257 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(in, in_list, cfg_intake_set_stream_once, |
| 258 | "<stream_once>", strbuf); |
| 259 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(strbuf, sizeof(strbuf), "%u", ez->reconnectAttemptscxx . . $ tag_EZCONFIG#reconnectAttempts.); |
| 260 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(srv, srv_list, cfg_server_set_reconnect_attempts, |
| 261 | "<reconnect_tries>", strbuf); |
| 262 | if (ez->serverNamecxx . . $ tag_EZCONFIG#serverName.) |
| 263 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_stream_name, |
| 264 | "<svrinfoname>", ez->serverName); |
| 265 | if (ez->serverURLcxx . . $ tag_EZCONFIG#serverURL.) |
| 266 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_stream_url, |
| 267 | "<svrinfourl>", ez->serverURL); |
| 268 | if (ez->serverGenrecxx . . $ tag_EZCONFIG#serverGenre.) |
| 269 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_stream_genre, |
| 270 | "<svrinfogenre>", ez->serverGenre); |
| 271 | if (ez->serverDescriptioncxx . . $ tag_EZCONFIG#serverDescription.) |
| 272 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_stream_description, |
| 273 | "<svrinfodescription>", ez->serverDescription); |
| 274 | if (ez->serverBitratecxx . . $ tag_EZCONFIG#serverBitrate.) |
| 275 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_stream_bitrate, |
| 276 | "<svrinfobitrate>", ez->serverBitrate); |
| 277 | if (ez->serverChannelscxx . . $ tag_EZCONFIG#serverChannels.) |
| 278 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_stream_channels, |
| 279 | "<svrinfochannels>", ez->serverChannels); |
| 280 | if (ez->serverSampleratecxx . . $ tag_EZCONFIG#serverSamplerate.) |
| 281 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_stream_samplerate, |
| 282 | "<svrinfosamplerate>", ez->serverSamplerate); |
| 283 | if (ez->serverQualitycxx . . $ tag_EZCONFIG#serverQuality.) |
| 284 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_stream_quality, |
| 285 | "<svrinfoquality>", ez->serverQuality); |
| 286 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_public, |
| 287 | "<svrinfopublic>", ez->serverPublic ? "yes" : "no"); |
| 288 | if (ez->reencodecxx . . $ tag_EZCONFIG#reencode.) { |
| 289 | if (0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ez->formatcxx . . $ tag_EZCONFIG#format., "vorbis") || |
| 290 | 0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ez->formatcxx . . $ tag_EZCONFIG#format., "theora")) |
| 291 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_encoder, |
| 292 | "<reencode>", "Ogg"); |
| 293 | else |
| 294 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(str, str_list, cfg_stream_set_encoder, |
| 295 | "<reencode>", ez->format); |
| 296 | } |
| 297 | |
| 298 | for (i = 0; i < MAX_FORMAT_ENCDECcxx . . $ `src/ezconfig0.h:27:9`!; i++) { |
| 299 | FORMAT_ENCDECcxx . . $ FORMAT_ENCDEC# *ed = ez->encoderDecoderscxx . . $ tag_EZCONFIG#encoderDecoders.[i]; |
| 300 | |
| 301 | if (!ed) |
| 302 | continue; |
| 303 | |
| 304 | if (ed->encodercxx . . $ tag_FORMAT_ENCDEC#encoder.) { |
| 305 | cfg_encoder_tcxx . . $ cfg_encoder_t# enc = cfg_encoder_list_getcxx . . $ cfg_encoder_list_get(b613e7b3f606ecd3).(enc_list, |
| 306 | CFG_DEFAULTcxx . . $ `src/cfg.h:27:9`!); |
| 307 | |
| 308 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(enc, enc_list, cfg_encoder_set_program, |
| 309 | "<encode>", ed->encoder); |
| 310 | if (ed->formatcxx . . $ tag_FORMAT_ENCDEC#format.) { |
| 311 | if (0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ed->formatcxx . . $ tag_FORMAT_ENCDEC#format., "vorbis") || |
| 312 | 0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ed->formatcxx . . $ tag_FORMAT_ENCDEC#format., "theora")) { |
| 313 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(enc, enc_list, |
| 314 | cfg_encoder_set_name, |
| 315 | "<format> (encoder)", |
| 316 | "Ogg"); |
| 317 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(enc, enc_list, |
| 318 | cfg_encoder_set_format_str, |
| 319 | "<format> (encoder)", |
| 320 | "Ogg"); |
| 321 | } else { |
| 322 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(enc, enc_list, |
| 323 | cfg_encoder_set_name, |
| 324 | "<format> (encoder)", |
| 325 | ed->format); |
| 326 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(enc, enc_list, |
| 327 | cfg_encoder_set_format_str, |
| 328 | "<format> (encoder)", |
| 329 | ed->format); |
| 330 | } |
| 331 | } |
| 332 | if (0 > cfg_encoder_validatecxx . . $ cfg_encoder_validate(f08003ba3ba72319).(enc, &err_str)) { |
| 333 | log_warningcxx . . $ log_warning(581fddd72a8db8fc).("%s: %s: %s", v0_cfgfilecxx . . $ v0_cfgfile., |
| 334 | "<encdec> (encoder)", err_str); |
| 335 | cfg_encoder_list_removecxx . . $ cfg_encoder_list_remove(70764e441ead9ae8).(enc_list, &enc); |
| 336 | warnings++; |
| 337 | } |
| 338 | } |
| 339 | if (ed->decodercxx . . $ tag_FORMAT_ENCDEC#decoder.) { |
| 340 | cfg_decoder_tcxx . . $ cfg_decoder_t# dec = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 341 | |
| 342 | if (ed->formatcxx . . $ tag_FORMAT_ENCDEC#format.) { |
| 343 | if (0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ed->formatcxx . . $ tag_FORMAT_ENCDEC#format., "vorbis") || |
| 344 | 0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ed->formatcxx . . $ tag_FORMAT_ENCDEC#format., "theora")) |
| 345 | dec = cfg_decoder_list_findcxx . . $ cfg_decoder_list_find(fa3ce1428af83150).(dec_list, |
| 346 | "Ogg"); |
| 347 | else |
| 348 | dec = cfg_decoder_list_findcxx . . $ cfg_decoder_list_find(fa3ce1428af83150).(dec_list, |
| 349 | ed->formatcxx . . $ tag_FORMAT_ENCDEC#format.); |
| 350 | } |
| 351 | if (NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! == dec) |
| 352 | dec = cfg_decoder_list_getcxx . . $ cfg_decoder_list_get(fa3ce1428af83150).(dec_list, CFG_DEFAULTcxx . . $ `src/cfg.h:27:9`!); |
| 353 | |
| 354 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(dec, dec_list, cfg_decoder_set_program, |
| 355 | "<decode>", ed->decoder); |
| 356 | if (ed->formatcxx . . $ tag_FORMAT_ENCDEC#format.) { |
| 357 | if (0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ed->formatcxx . . $ tag_FORMAT_ENCDEC#format., "vorbis") || |
| 358 | 0 == strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ed->formatcxx . . $ tag_FORMAT_ENCDEC#format., "theora")) |
| 359 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(dec, dec_list, |
| 360 | cfg_decoder_set_name, |
| 361 | "<format> (decoder)", |
| 362 | "Ogg"); |
| 363 | else |
| 364 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(dec, dec_list, |
| 365 | cfg_decoder_set_name, |
| 366 | "<format> (decoder)", |
| 367 | ed->format); |
| 368 | } |
| 369 | if (ed->matchcxx . . $ tag_FORMAT_ENCDEC#match.) |
| 370 | ENTITY_SETcxx . . $ `src/ezstream-cfgmigrate.c:158:9`!(dec, dec_list, cfg_decoder_add_match, |
| 371 | "<match>", ed->match); |
| 372 | |
| 373 | if (0 > cfg_decoder_validatecxx . . $ cfg_decoder_validate(11ea17061e373d7c).(dec, &err_str)) { |
| 374 | log_warningcxx . . $ log_warning(581fddd72a8db8fc).("%s: %s: %s", v0_cfgfilecxx . . $ v0_cfgfile., |
| 375 | "<encdec> (decoder)", err_str); |
| 376 | cfg_decoder_list_removecxx . . $ cfg_decoder_list_remove(c04414ed9cb5b8c1).(dec_list, &dec); |
| 377 | warnings++; |
| 378 | } |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | if (warnings) |
| 383 | log_warningcxx . . $ log_warning(581fddd72a8db8fc).("%s: %u warnings", v0_cfgfilecxx . . $ v0_cfgfile., warnings); |
| 384 | |
| 385 | if (cfg_stream_get_encodercxx . . $ cfg_stream_get_encoder(2200fed2ef732c87).(str) && |
| 386 | NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`! == cfg_encoder_list_findcxx . . $ cfg_encoder_list_find(b613e7b3f606ecd3).(enc_list, |
| 387 | cfg_stream_get_encodercxx . . $ cfg_stream_get_encoder(2200fed2ef732c87).(str))) { |
| 388 | log_warningcxx . . $ log_warning(581fddd72a8db8fc).("%s: %s encoder not found; disabling reencoding", |
| 389 | v0_cfgfilecxx . . $ v0_cfgfile., cfg_stream_get_encodercxx . . $ cfg_stream_get_encoder(2200fed2ef732c87).(str)); |
| 390 | cfg_stream_set_encodercxx . . $ cfg_stream_set_encoder(60eb938a45999d0f).(str, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 391 | } |
| 392 | |
| 393 | if (0 > cfg_server_validatecxx . . $ cfg_server_validate(8a603fc9db99667f).(srv, &err_str) || |
| 394 | 0 > cfg_stream_validatecxx . . $ cfg_stream_validate(6db635df7f999560).(str, &err_str) || |
| 395 | 0 > cfg_intake_validatecxx . . $ cfg_intake_validate(4f7d28fe13f0586b).(in, &err_str)) { |
| 396 | log_errorcxx . . $ log_error(581fddd72a8db8fc).("%s: configuration invalid: %s", v0_cfgfilecxx . . $ v0_cfgfile., |
| 397 | err_str); |
| 398 | return (-1); |
| 399 | } |
| 400 | |
| 401 | return (0); |
| 402 | } |
| 403 | |
| 404 | int |
| 405 | maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 406 | { |
| 407 | int ret; |
| 408 | EZCONFIGcxx . . $ EZCONFIG# *ez = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 409 | |
| 410 | ret = 1; |
| 411 | if (0 > cfg_initcxx . . $ cfg_init(b126dc7c1de90089).() || |
| 412 | 0 > log_initcxx . . $ log_init(5c4306d8553b3696).(util_get_prognamecxx . . $ util_get_progname(fb58d2e09a2a1ce6).(argv[0])) || |
| 413 | 0 > _cmdline_parsecxx . . $ _cmdline_parse(e4d6922c49795a40).(argc, argv, &ret)) |
| 414 | return (ret); |
| 415 | (void)cfg_set_program_namecxx . . $ cfg_set_program_name(2ef3bc9ee8f8b3e9).(util_get_prognamecxx . . $ util_get_progname(fb58d2e09a2a1ce6).(argv[0]), NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 416 | |
| 417 | if (0 > parseConfigcxx . . $ parseConfig(5c4306d8553b3696).(v0_cfgfilecxx . . $ v0_cfgfile.)) |
| 418 | goto error; |
| 419 | ez = getEZConfigcxx . . $ getEZConfig(50f9941a0a2c49e7).(); |
| 420 | |
| 421 | if (0 > _parse_ezconfig0cxx . . $ _parse_ezconfig0(99d3d34331ef3c0e).(ez)) |
| 422 | goto error; |
| 423 | |
| 424 | printfcxx . . $ printf(581fddd72a8db8fc).("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n"); |
| 425 | printfcxx . . $ printf(581fddd72a8db8fc).("<!--\n"); |
| 426 | printfcxx . . $ printf(581fddd72a8db8fc).(" This ezstream version 1.x configuration file was generated by\n"); |
| 427 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s.\n\n", util_get_prognamecxx . . $ util_get_progname(fb58d2e09a2a1ce6).(argv[0])); |
| 428 | printfcxx . . $ printf(581fddd72a8db8fc).(" Source (ezstream version 0.x):\n"); |
| 429 | printfcxx . . $ printf(581fddd72a8db8fc).(" %s\n", basenamecxx . . $ basename(a8b8e32347182212).(v0_cfgfilecxx . . $ v0_cfgfile.)); |
| 430 | printfcxx . . $ printf(581fddd72a8db8fc).(" -->\n\n"); |
| 431 | cfgfile_xml_printcxx . . $ cfgfile_xml_print(8d4262d45fc644ab).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!); |
| 432 | |
| 433 | freeConfigcxx . . $ freeConfig(18df6c5910674b29).(ez); |
| 434 | |
| 435 | log_exitcxx . . $ log_exit(49f6e7a06ebc5aa8).(); |
| 436 | cfg_exitcxx . . $ cfg_exit(49f6e7a06ebc5aa8).(); |
| 437 | |
| 438 | return (0); |
| 439 | |
| 440 | error: |
| 441 | if (ez) |
| 442 | freeConfigcxx . . $ freeConfig(18df6c5910674b29).(ez); |
| 443 | |
| 444 | log_exitcxx . . $ log_exit(49f6e7a06ebc5aa8).(); |
| 445 | cfg_exitcxx . . $ cfg_exit(49f6e7a06ebc5aa8).(); |
| 446 | |
| 447 | return (1); |
| 448 | } |