ReactOS 0.4.16-dev-297-gc569aee
free.c
Go to the documentation of this file.
1/*
2 * FREE.C - internal command.
3 *
4 *
5 * History:
6 *
7 * 01-Sep-1999 (Eric Kohl)
8 * Started.
9 *
10 * 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
11 * Remove all hardcoded strings in En.rc
12 */
13
14#include "precomp.h"
15
16#ifdef INCLUDE_CMD_FREE
17
18static VOID
20{
22 TCHAR szRootPath[4] = _T("A:\\");
23 TCHAR szDrive[2] = _T("A");
24 TCHAR szVolume[64];
25 TCHAR szSerial[10];
26 TCHAR szTotal[40];
27 TCHAR szUsed[40];
28 TCHAR szFree[40];
29 DWORD dwSerial;
30 ULONGLONG uliSize;
31 DWORD dwSecPerCl;
32 DWORD dwBytPerSec;
33 DWORD dwFreeCl;
34 DWORD dwTotCl;
35
36 if (_tcslen (szDisk) < 2 || szDisk[1] != _T(':'))
37 {
39 return;
40 }
41
42 szRootPath[0] = szDisk[0];
43 szDrive[0] = _totupper (szRootPath[0]);
44
45 if (!GetVolumeInformation (szRootPath, szVolume, 64, &dwSerial,
46 NULL, NULL, NULL, 0))
47 {
49 ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive);
50 return;
51 }
52
53 if (szVolume[0] == _T('\0'))
54 {
55
57 _tcscpy (szVolume, szMsg);
58 }
59
60 _stprintf (szSerial,
61 _T("%04X-%04X"),
62 HIWORD(dwSerial),
63 LOWORD(dwSerial));
64
65 if (!GetDiskFreeSpace (szRootPath, &dwSecPerCl,
66 &dwBytPerSec, &dwFreeCl, &dwTotCl))
67 {
69 ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive);
70 return;
71 }
72
73 uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwTotCl;
74 ConvertULargeInteger(uliSize, szTotal, 40, TRUE);
75
76 uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)(dwTotCl - dwFreeCl);
77 ConvertULargeInteger(uliSize, szUsed, 40, TRUE);
78
79 uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwFreeCl;
80 ConvertULargeInteger(uliSize, szFree, 40, TRUE);
81
82 ConOutResPrintf(STRING_FREE_HELP1, szDrive, szVolume, szSerial, szTotal, szUsed, szFree);
83}
84
85
87{
88 LPTSTR szParam;
89 TCHAR szDefPath[MAX_PATH];
90 INT argc, i;
91 LPTSTR *arg;
92
93 if (!_tcsncmp (param, _T("/?"), 2))
94 {
96 return 0;
97 }
98
99 if (!param || *param == _T('\0'))
100 {
101 GetCurrentDirectory (MAX_PATH, szDefPath);
102 szDefPath[2] = _T('\0');
103 szParam = szDefPath;
104 }
105 else
106 szParam = param;
107
108 arg = split (szParam, &argc, FALSE, FALSE);
109
110 for (i = 0; i < argc; i++)
112
113 freep (arg);
114
115 return 0;
116}
117
118#endif /* INCLUDE_CMD_FREE */
119
120/* EOF */
static int argc
Definition: ServiceArgs.c:12
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
HANDLE CMD_ModuleHandle
Definition: cmd.c:165
INT ConvertULargeInteger(ULONGLONG num, LPTSTR des, UINT len, BOOL bPutSeparator)
Definition: cmd.c:189
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:178
#define ConErrPrintf(szStr,...)
Definition: console.h:44
#define ConErrResPrintf(uID,...)
Definition: console.h:50
#define STRING_FREE_ERROR2
Definition: resource.h:57
#define STRING_FREE_HELP1
Definition: resource.h:131
#define STRING_FREE_HELP2
Definition: resource.h:132
#define STRING_FREE_ERROR1
Definition: resource.h:56
static VOID freep(LPSTR *p)
Definition: cmdcons.c:98
static LPSTR * split(LPSTR s, LPINT args)
Definition: cmdcons.c:163
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static VOID PrintDiskInfo(LPTSTR szDisk)
Definition: free.c:19
INT CommandFree(LPTSTR param)
Definition: free.c:86
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _tcscpy
Definition: tchar.h:623
#define _tcsncmp
Definition: tchar.h:1428
#define _totupper
Definition: tchar.h:1509
#define _stprintf
Definition: utility.h:124
#define LOWORD(l)
Definition: pedump.c:82
#define ConOutResPrintf(uID,...)
Definition: replace.h:31
int32_t INT
Definition: typedefs.h:58
uint64_t ULONGLONG
Definition: typedefs.h:67
#define HIWORD(l)
Definition: typedefs.h:247
#define _T(x)
Definition: vfdio.h:22
#define GetVolumeInformation
Definition: winbase.h:3878
#define GetDiskFreeSpace
Definition: winbase.h:3832
#define GetCurrentDirectory
Definition: winbase.h:3830
void * arg
Definition: msvc.h:10
#define LoadString
Definition: winuser.h:5831
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcslen
Definition: xmlstorage.h:198