1 /*****************************************************************************
2 * winvlc.c: the Windows VLC player
3 *****************************************************************************
4 * Copyright (C) 1998-2008 the VideoLAN team
6 * Authors: Vincent Seguin <seguin@via.ecp.fr>
7 * Samuel Hocevar <sam@zoy.org>
8 * Gildas Bazin <gbazin@videolan.org>
9 * Derk-Jan Hartman <hartman at videolan dot org>
10 * Lots of other people, see the libvlc AUTHORS file
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
38 static int parse_cmdline (char *line
, char ***argvp
)
40 char **argv
= malloc (sizeof (char *));
47 /* Skips white spaces */
48 while (strchr ("\t ", *line
))
53 /* Starts a new parameter */
54 argv
= realloc (argv
, (argc
+ 2) * sizeof (char *));
63 while (*line
&& !strchr ("\t ", *line
))
66 if (line
> argv
[argc
- 1] && line
[-1] == quote
)
67 /* End of quoted parameter */
72 /* Space within a quote */
77 /* End of unquoted parameter */
87 # define wWinMain WinMain
90 /*****************************************************************************
91 * wWinMain: parse command line, start interface and spawn threads.
92 *****************************************************************************/
93 int WINAPI
wWinMain( HINSTANCE hInstance
, HINSTANCE hPrevInstance
,
94 LPWSTR lpCmdLine
, int nCmdShow
)
96 char **argv
, psz_cmdline
[wcslen(lpCmdLine
) * 4 + 1];
99 (void)hInstance
; (void)hPrevInstance
; (void)nCmdShow
;
101 WideCharToMultiByte( CP_UTF8
, 0, lpCmdLine
, -1,
102 psz_cmdline
, sizeof (psz_cmdline
), NULL
, NULL
);
104 argc
= parse_cmdline (psz_cmdline
, &argv
);
106 libvlc_exception_t ex
, dummy
;
107 libvlc_exception_init (&ex
);
108 libvlc_exception_init (&dummy
);
110 /* Initialize libvlc */
111 libvlc_instance_t
*vlc
= libvlc_new (argc
, (const char **)argv
, &ex
);
114 libvlc_add_intf (vlc
, NULL
, &ex
);
115 libvlc_playlist_play (vlc
, -1, 0, NULL
, &dummy
);
117 libvlc_release (vlc
);
121 ret
= libvlc_exception_raised (&ex
);
122 libvlc_exception_clear (&ex
);
123 libvlc_exception_clear (&dummy
);
127 #ifndef IF_MINGW_SUPPORTED_UNICODE
128 int WINAPI
WinMain (HINSTANCE hInstance
, HINSTANCE hPrevInstance
,
129 LPSTR args
, int nCmdShow
)
131 /* This makes little sense, but at least it links properly */
132 wchar_t lpCmdLine
[(strlen (args
) + 1) * 3];
133 MultiByteToWideChar (CP_ACP
, 0, args
, -1, lpCmdLine
, sizeof (lpCmdLine
));
134 return wWinMain (hInstance
, hPrevInstance
, lpCmdLine
, nCmdShow
);