1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/*
* The Sleuth Kit
*
* Brian Carrier [carrier <at> sleuthkit [dot] org]
* Copyright (c) 2003-2011 Brian Carrier. All rights reserved
*
* This software is distributed under the Common Public License 1.0
*/
/** \file mm_types.c
* Contains the code to parse and print the strings for the supported volume system types.
*/
#include "tsk_vs_i.h"
typedef struct {
char *name;
TSK_VS_TYPE_ENUM code;
char *comment;
} VS_TYPES;
VS_TYPES vs_open_table[] = {
{"dos", TSK_VS_TYPE_DOS,
"DOS Partition Table"},
{"mac", TSK_VS_TYPE_MAC, "MAC Partition Map"},
{"bsd", TSK_VS_TYPE_BSD,
"BSD Disk Label"},
{"sun", TSK_VS_TYPE_SUN,
"Sun Volume Table of Contents (Solaris)"},
{"gpt", TSK_VS_TYPE_GPT, "GUID Partition Table (EFI)"},
{0, 0, ""},
};
/**
* \ingroup vslib
* Parse a string with the volume system type and return its internal ID.
*
* @param str String to parse.
* @returns ID of string (or unsupported if the name is unknown)
*/
TSK_VS_TYPE_ENUM
tsk_vs_type_toid(const TSK_TCHAR * str)
{
char tmp[16];
int i;
// convert to char
for (i = 0; i < 15 && str[i] != '\0'; i++) {
tmp[i] = (char) str[i];
}
tmp[i] = '\0';
return tsk_vs_type_toid_utf8(tmp);
}
/**
* \ingroup vslib
* Parse a string with the volume system type and return its internal ID.
*
* @param str String to parse (always in UTF-8).
* @returns ID of string (or unsupported if the name is unknown)
*/
TSK_VS_TYPE_ENUM
tsk_vs_type_toid_utf8(const char *str)
{
VS_TYPES *types;
for (types = vs_open_table; types->name; types++) {
if (strcmp(str, types->name) == 0) {
return types->code;
}
}
return TSK_VS_TYPE_UNSUPP;
}
/**
* \ingroup vslib
* Print the supported volume system type names to an open handle.
* @param hFile Handle to print to.
*/
void
tsk_vs_type_print(FILE * hFile)
{
VS_TYPES *types;
tsk_fprintf(hFile, "Supported partition types:\n");
for (types = vs_open_table; types->name; types++)
tsk_fprintf(hFile, "\t%s (%s)\n", types->name, types->comment);
}
/**
* \ingroup vslib
* Return the supported volume system types.
* @returns The bit in the return value is 1 if the type is supported.
*/
TSK_VS_TYPE_ENUM
tsk_vs_type_supported()
{
TSK_VS_TYPE_ENUM sup_types = 0;
VS_TYPES *types;
for (types = vs_open_table; types->name; types++) {
sup_types |= types->code;
}
return sup_types;
}
/**
* \ingroup vslib
* Return the string name of a partition type ID.
*
* @param type Volume system type
* @returns name of type or NULL on error
*/
const char *
tsk_vs_type_toname(TSK_VS_TYPE_ENUM type)
{
VS_TYPES *types;
for (types = vs_open_table; types->name; types++) {
if (types->code == type) {
return types->name;
}
}
if (type == TSK_VS_TYPE_DBFILLER) {
return "DB Filler";
}
return NULL;
}
/**
* \ingroup vslib
* Return the string description of a partition type ID.
*
* @param type Volume system type
* @returns description of type or NULL on error
*/
const char *
tsk_vs_type_todesc(TSK_VS_TYPE_ENUM type)
{
VS_TYPES *types;
for (types = vs_open_table; types->name; types++) {
if (types->code == type) {
return types->comment;
}
}
return NULL;
}
|