MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / split_commandline

Function split_commandline

fftools/cmdutils.c:790–911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

788}
789
790int split_commandline(OptionParseContext *octx, int argc, char *argv[],
791 const OptionDef *options,
792 const OptionGroupDef *groups, int nb_groups)
793{
794 int ret;
795 int optindex = 1;
796 int dashdash = -2;
797
798 /* perform system-dependent conversions for arguments list */
799 prepare_app_arguments(&argc, &argv);
800
801 ret = init_parse_context(octx, groups, nb_groups);
802 if (ret < 0)
803 return ret;
804
805 av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n");
806
807 while (optindex < argc) {
808 const char *opt = argv[optindex++], *arg;
809 const OptionDef *po;
810 int group_idx;
811
812 av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt);
813
814 if (opt[0] == '-' && opt[1] == '-' && !opt[2]) {
815 dashdash = optindex;
816 continue;
817 }
818 /* unnamed group separators, e.g. output filename */
819 if (opt[0] != '-' || !opt[1] || dashdash+1 == optindex) {
820 ret = finish_group(octx, 0, opt);
821 if (ret < 0)
822 return ret;
823
824 av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name);
825 continue;
826 }
827 opt++;
828
829#define GET_ARG(arg) \
830do { \
831 arg = argv[optindex++]; \
832 if (!arg) { \
833 av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\
834 return AVERROR(EINVAL); \
835 } \
836} while (0)
837
838 /* named group separators, e.g. -i */
839 group_idx = match_group_separator(groups, nb_groups, opt);
840 if (group_idx >= 0) {
841 GET_ARG(arg);
842 ret = finish_group(octx, group_idx, arg);
843 if (ret < 0)
844 return ret;
845
846 av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n",
847 groups[group_idx].name, arg);

Callers 1

ffmpeg_parse_optionsFunction · 0.85

Calls 9

prepare_app_argumentsFunction · 0.85
init_parse_contextFunction · 0.85
av_logFunction · 0.85
finish_groupFunction · 0.85
match_group_separatorFunction · 0.85
find_optionFunction · 0.85
opt_has_argFunction · 0.85
add_optFunction · 0.85
opt_defaultFunction · 0.85

Tested by

no test coverage detected