video_filter: erase: use C99 loop declarations
[vlc.git] / modules / services_discovery / windrive.c
blobbed020e59f837da8f438c721771cf6faab61a616
1 /**
2 * @file win_disc.c
3 * @brief List of disc drives for VLC media player for Windows
4 */
5 /*****************************************************************************
6 * Copyright © 2010 Rémi Denis-Courmont
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
27 #include <vlc_common.h>
28 #include <vlc_services_discovery.h>
29 #include <vlc_plugin.h>
31 static int Open (vlc_object_t *);
33 VLC_SD_PROBE_HELPER("disc", "Discs", SD_CAT_DEVICES)
36 * Module descriptor
38 vlc_module_begin ()
39 add_submodule ()
40 set_shortname (N_("Discs"))
41 set_description (N_("Discs"))
42 set_category (CAT_PLAYLIST)
43 set_subcategory (SUBCAT_PLAYLIST_SD)
44 set_capability ("services_discovery", 0)
45 set_callbacks (Open, NULL)
46 add_shortcut ("disc")
48 VLC_SD_PROBE_SUBMODULE
50 vlc_module_end ()
52 /**
53 * Probes and initializes.
55 static int Open (vlc_object_t *obj)
57 services_discovery_t *sd = (services_discovery_t *)obj;
59 LONG drives = GetLogicalDrives ();
60 char mrl[12] = "file:///A:/", name[3] = "A:";
61 TCHAR path[4] = TEXT("A:\\");
63 for (char d = 0; d < 26; d++)
65 input_item_t *item;
66 char letter = 'A' + d;
68 /* Does this drive actually exist? */
69 if (!(drives & (1 << d)))
70 continue;
71 /* Is it a disc drive? */
72 path[0] = letter;
73 if (GetDriveType (path) != DRIVE_CDROM)
74 continue;
76 mrl[8] = name[0] = letter;
77 item = input_item_NewWithType (mrl, name,
78 0, NULL, 0, -1, ITEM_TYPE_DISC);
79 msg_Dbg (sd, "adding %s (%s)", mrl, name);
80 if (item == NULL)
81 break;
83 services_discovery_AddItem (sd, item, _("Local drives"));
85 return VLC_SUCCESS;