"Fossies" - the Fresh Open Source Software Archive

Member "libcdio-2.1.0/example/C++/OO/drives.cpp" (12 Aug 2018, 2498 Bytes) of package /linux/privat/libcdio-2.1.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2   Copyright (C) 2003, 2004, 2006, 2008, 2009 Rocky Bernstein <rocky@gnu.org>
    3   
    4   This program is free software: you can redistribute it and/or modify
    5   it under the terms of the GNU General Public License as published by
    6   the Free Software Foundation, either version 3 of the License, or
    7   (at your option) any later version.
    8 
    9   This program is distributed in the hope that it will be useful,
   10   but WITHOUT ANY WARRANTY; without even the implied warranty of
   11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12   GNU General Public License for more details.
   13 
   14   You should have received a copy of the GNU General Public License
   15   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   16 */
   17 
   18 /* Simple program to show drivers installed and what the default 
   19    CD-ROM drive is and what CD drives are available. */
   20 #ifdef HAVE_CONFIG_H
   21 #include "config.h"
   22 #define __CDIO_CONFIG_H__ 1
   23 #endif
   24 
   25 #ifdef HAVE_STDIO_H
   26 #include <stdio.h>
   27 #endif
   28 #ifdef HAVE_STDLIB_H
   29 #include <stdlib.h>
   30 #endif
   31 #ifdef HAVE_SYS_TYPES_H
   32 #include <sys/types.h>
   33 #endif
   34 
   35 #include <cdio++/cdio.hpp>
   36 #include <cdio/cd_types.h>
   37 #include <cdio/logging.h>
   38 
   39 static void 
   40 log_handler (cdio_log_level_t level, const char message[])
   41 {
   42   switch(level) {
   43   case CDIO_LOG_DEBUG:
   44   case CDIO_LOG_INFO:
   45     return;
   46   default:
   47     printf("cdio %d message: %s\n", level, message);
   48   }
   49 }
   50 
   51 static void 
   52 print_drive_class(const char *psz_msg, cdio_fs_anal_t bitmask, 
   53           bool b_any=false) {
   54   char **ppsz_cd_drives=NULL, **c;
   55 
   56   printf("%s...\n", psz_msg);
   57   ppsz_cd_drives = getDevices(NULL,  bitmask, b_any);
   58   if (NULL != ppsz_cd_drives) 
   59     for( c = ppsz_cd_drives; *c != NULL; c++ ) {
   60       printf("Drive %s\n", *c);
   61     }
   62 
   63   freeDeviceList(ppsz_cd_drives);
   64   printf("-----\n");
   65 }
   66 
   67 int
   68 main(int argc, const char *argv[])
   69 {
   70   char **ppsz_cd_drives=NULL, **c;
   71   
   72   cdio_log_set_handler (log_handler);
   73 
   74   /* Print out a list of CD-drives */
   75   printf("All CD-ROM/DVD drives...\n");
   76   ppsz_cd_drives = getDevices();
   77   if (NULL != ppsz_cd_drives) 
   78     for( c = ppsz_cd_drives; *c != NULL; c++ ) {
   79       printf("Drive %s\n", *c);
   80     }
   81 
   82   freeDeviceList(ppsz_cd_drives);
   83 
   84   print_drive_class("All CD-ROM drives (again)", CDIO_FS_MATCH_ALL);
   85   print_drive_class("CD-ROM drives with a CD-DA loaded...", CDIO_FS_AUDIO);
   86   print_drive_class("CD-ROM drives with some sort of ISO 9660 filesystem...", 
   87             CDIO_FS_ANAL_ISO9660_ANY, true);
   88   print_drive_class("(S)VCD drives...", CDIO_FS_ANAL_VCD_ANY, true);
   89   return 0;
   90   
   91 }