Mercurial > mplayer.hg
comparison libvo/vo_pnm.c @ 14538:00c3c4111017
New suboption type: malloc'ed, zero terminated string
author | reimar |
---|---|
date | Wed, 19 Jan 2005 17:10:20 +0000 |
parents | f5ef32b4bdd3 |
children | 2ef20aa3623b |
comparison
equal
deleted
inserted
replaced
14537:f832c3ec3e4b | 14538:00c3c4111017 |
---|---|
128 | 128 |
129 static uint32_t preinit(const char *arg) | 129 static uint32_t preinit(const char *arg) |
130 { | 130 { |
131 int ppm_type = 0, pgm_type = 0, pgmyuv_type = 0, | 131 int ppm_type = 0, pgm_type = 0, pgmyuv_type = 0, |
132 raw_mode = 0, ascii_mode = 0; | 132 raw_mode = 0, ascii_mode = 0; |
133 strarg_t outdir = {0, NULL}, | |
134 subdirs = {0, NULL}; | |
135 opt_t subopts[] = { | 133 opt_t subopts[] = { |
136 {"ppm", OPT_ARG_BOOL, &ppm_type, NULL}, | 134 {"ppm", OPT_ARG_BOOL, &ppm_type, NULL}, |
137 {"pgm", OPT_ARG_BOOL, &pgm_type, NULL}, | 135 {"pgm", OPT_ARG_BOOL, &pgm_type, NULL}, |
138 {"pgmyuv", OPT_ARG_BOOL, &pgmyuv_type, NULL}, | 136 {"pgmyuv", OPT_ARG_BOOL, &pgmyuv_type, NULL}, |
139 {"raw", OPT_ARG_BOOL, &raw_mode, NULL}, | 137 {"raw", OPT_ARG_BOOL, &raw_mode, NULL}, |
140 {"ascii", OPT_ARG_BOOL, &ascii_mode, NULL}, | 138 {"ascii", OPT_ARG_BOOL, &ascii_mode, NULL}, |
141 {"outdir", OPT_ARG_STR, &outdir, NULL}, | 139 {"outdir", OPT_ARG_MSTRZ, &pnm_outdir, NULL}, |
142 {"subdirs", OPT_ARG_STR, &subdirs, NULL}, | 140 {"subdirs", OPT_ARG_MSTRZ, &pnm_subdirs, NULL}, |
143 {"maxfiles", OPT_ARG_INT, &pnm_maxfiles, (opt_test_f)int_pos}, | 141 {"maxfiles", OPT_ARG_INT, &pnm_maxfiles, (opt_test_f)int_pos}, |
144 {NULL} | 142 {NULL} |
145 }; | 143 }; |
146 const char *info_message = NULL; | 144 const char *info_message = NULL; |
147 | 145 |
148 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, | 146 mp_msg(MSGT_VO, MSGL_INFO, "%s: %s\n", info.short_name, |
149 MSGTR_VO_ParsingSuboptions); | 147 MSGTR_VO_ParsingSuboptions); |
150 | 148 |
151 pnm_maxfiles = 1000; | 149 pnm_maxfiles = 1000; |
150 pnm_outdir = strdup("."); | |
151 pnm_subdirs = NULL; | |
152 | 152 |
153 if (subopt_parse(arg, subopts) != 0) { | 153 if (subopt_parse(arg, subopts) != 0) { |
154 return -1; | 154 return -1; |
155 } | 155 } |
156 | 156 |
160 if (pgmyuv_type) pnm_type = PNM_TYPE_PGMYUV; | 160 if (pgmyuv_type) pnm_type = PNM_TYPE_PGMYUV; |
161 if (pgm_type) pnm_type = PNM_TYPE_PGM; | 161 if (pgm_type) pnm_type = PNM_TYPE_PGM; |
162 if (ppm_type) pnm_type = PNM_TYPE_PPM; | 162 if (ppm_type) pnm_type = PNM_TYPE_PPM; |
163 if (ascii_mode) pnm_mode = PNM_ASCII_MODE; | 163 if (ascii_mode) pnm_mode = PNM_ASCII_MODE; |
164 if (raw_mode) pnm_mode = PNM_RAW_MODE; | 164 if (raw_mode) pnm_mode = PNM_RAW_MODE; |
165 | |
166 if (outdir.len) { | |
167 pnm_outdir = malloc(outdir.len + 1); | |
168 memcpy(pnm_outdir, outdir.str, outdir.len); | |
169 pnm_outdir[outdir.len] = '\0'; | |
170 } else { | |
171 pnm_outdir = strdup("."); | |
172 } | |
173 | |
174 if (subdirs.len) { | |
175 pnm_subdirs = malloc(subdirs.len + 1); | |
176 memcpy(pnm_subdirs, subdirs.str, subdirs.len); | |
177 pnm_subdirs[subdirs.len] = '\0'; | |
178 } | |
179 | 165 |
180 switch (pnm_mode) { | 166 switch (pnm_mode) { |
181 case PNM_ASCII_MODE: | 167 case PNM_ASCII_MODE: |
182 info_message = MSGTR_VO_PNM_ASCIIMode; | 168 info_message = MSGTR_VO_PNM_ASCIIMode; |
183 break; | 169 break; |