]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/tools/scsilist.cpp
Restore win32 dir from Branch-5.2 and update it
[bacula/bacula] / bacula / src / win32 / tools / scsilist.cpp
1 /*
2  * scsilist.cpp - Outputs the contents of a ScsiDeviceList.
3  *
4  * Author: Robert Nelson, August, 2006 <robertn@the-nelsons.org>
5  *
6  * Version $Id$
7  *
8  * This file was contributed to the Bacula project by Robert Nelson.
9  *
10  * Robert Nelson has been granted a perpetual, worldwide,
11  * non-exclusive, no-charge, royalty-free, irrevocable copyright
12  * license to reproduce, prepare derivative works of, publicly
13  * display, publicly perform, sublicense, and distribute the original
14  * work contributed by Robert Nelson to the Bacula project in source 
15  * or object form.
16  *
17  * If you wish to license contributions from Robert Nelson
18  * under an alternate open source license please contact
19  * Robert Nelson <robertn@the-nelsons.org>.
20  */
21 /*
22    Bacula® - The Network Backup Solution
23
24    Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
25
26    The main author of Bacula is Kern Sibbald, with contributions from
27    many others, a complete list can be found in the file AUTHORS.
28    This program is Free Software; you can redistribute it and/or
29    modify it under the terms of version three of the GNU Affero General Public
30    License as published by the Free Software Foundation and included
31    in the file LICENSE.
32
33    This program is distributed in the hope that it will be useful, but
34    WITHOUT ANY WARRANTY; without even the implied warranty of
35    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36    General Public License for more details.
37
38    You should have received a copy of the GNU Affero General Public License
39    along with this program; if not, write to the Free Software
40    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
41    02110-1301, USA.
42
43    Bacula® is a registered trademark of Kern Sibbald.
44    The licensor of Bacula is the Free Software Foundation Europe
45    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
46    Switzerland, email:ftf@fsfeurope.org.
47 */
48
49 #if defined(_MSC_VER) && defined(_DEBUG)
50 #include <afx.h>
51 #else
52 #include <windows.h>
53 #endif
54
55 #include <stdio.h>
56 #include <tchar.h>
57 #include <conio.h>
58
59 #include "ScsiDeviceList.h"
60
61 #if defined(_MSC_VER) && defined(_DEBUG)
62 #define  new   DEBUG_NEW
63 #endif
64
65 int _tmain(int argc, _TCHAR* argv[])
66 {
67 #if defined(_MSC_VER) && defined(_DEBUG)
68    CMemoryState InitialMemState, FinalMemState, DiffMemState;
69
70    InitialMemState.Checkpoint();
71
72    {
73 #endif
74
75    CScsiDeviceList   DeviceList;
76
77    if (!DeviceList.Populate())
78    {
79       DeviceList.PrintLastError();
80       return 1;
81    }
82
83 #define  HEADING \
84    _T("Device                        Type     Physical     Name\n") \
85    _T("======                        ====     ========     ====\n")
86
87    _fputts(HEADING, stdout);
88
89    for (DWORD index = 0; index < DeviceList.size(); index++) {
90
91       CScsiDeviceListEntry &entry = DeviceList[index];
92
93       if (entry.GetType() != CScsiDeviceListEntry::Disk) {
94
95          _tprintf(_T("%-28s  %-7s  %-11s  %-27s\n"), 
96                   entry.GetIdentifier(),
97                   entry.GetTypeName(),
98                   entry.GetDevicePath(),
99                   entry.GetDeviceName());
100       }
101    }
102
103 #if defined(_MSC_VER) && defined(_DEBUG)
104    }
105
106    InitialMemState.DumpAllObjectsSince();
107
108    FinalMemState.Checkpoint();
109    DiffMemState.Difference(InitialMemState, FinalMemState);
110    DiffMemState.DumpStatistics();
111 #endif
112
113    if (argc > 1 && _tcsnicmp(argv[1], _T("/pause"), sizeof(_T("/pause")) - sizeof(TCHAR)) == 0) {
114       _fputts(_T("\nPress any key to continue\n"), stderr);
115       _getch();
116    }
117
118    return 0;
119 }