[vlc-devel] commit: WinCE: reintroduce parse_cmdline (Geoffroy Couprie )
git version control
git at videolan.org
Tue Oct 7 19:43:22 CEST 2008
vlc | branch: master | Geoffroy Couprie <geo.couprie at gmail.com> | Tue Oct 7 19:41:55 2008 +0200| [ff026ff6e3090456adad19b4a6c1be63dd83f7b0] | committer: Geoffroy Couprie
WinCE: reintroduce parse_cmdline
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ff026ff6e3090456adad19b4a6c1be63dd83f7b0
---
bin/winvlc.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/bin/winvlc.c b/bin/winvlc.c
index ef31d98..f8268df 100644
--- a/bin/winvlc.c
+++ b/bin/winvlc.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <windows.h>
+#ifndef UNDER_CE
static char *FromWide (const wchar_t *wide)
{
size_t len;
@@ -45,7 +46,55 @@ static char *FromWide (const wchar_t *wide)
WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
return out;
}
+#else
+static int parse_cmdline (char *line, char ***argvp)
+{
+ char **argv = malloc (sizeof (char *));
+ int argc = 0;
+
+ while (*line != '\0')
+ {
+ char quote = 0;
+ /* Skips white spaces */
+ while (strchr ("\t ", *line))
+ line++;
+ if (!*line)
+ break;
+
+ /* Starts a new parameter */
+ argv = realloc (argv, (argc + 2) * sizeof (char *));
+ if (*line == '"')
+ {
+ quote = '"';
+ line++;
+ }
+ argv[argc++] = line;
+
+ more:
+ while (*line && !strchr ("\t ", *line))
+ line++;
+
+ if (line > argv[argc - 1] && line[-1] == quote)
+ /* End of quoted parameter */
+ line[-1] = 0;
+ else
+ if (*line && quote)
+ {
+ /* Space within a quote */
+ line++;
+ goto more;
+ }
+ else
+ /* End of unquoted parameter */
+ if (*line)
+ *line++ = 0;
+ }
+ argv[argc] = NULL;
+ *argvp = argv;
+ return argc;
+}
+#endif
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
#ifndef UNDER_CE
@@ -56,6 +105,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
int nCmdShow )
{
int argc, ret;
+#ifndef UNDER_CE
wchar_t **wargv = CommandLineToArgvW (GetCommandLine (), &argc);
if (wargv == NULL)
return 1;
@@ -65,6 +115,14 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
argv[i] = FromWide (wargv[i]);
argv[argc] = NULL;
LocalFree (wargv);
+#else
+ char **argv, psz_cmdline[wcslen(lpCmdLine) * 4];
+
+ WideCharToMultiByte( CP_UTF8, 0, lpCmdLine, -1,
+ psz_cmdline, sizeof (psz_cmdline), NULL, NULL );
+
+ argc = parse_cmdline (psz_cmdline, &argv);
+#endif
libvlc_exception_t ex, dummy;
libvlc_exception_init (&ex);
More information about the vlc-devel
mailing list