srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 1 | // support.cc |
| 2 | // Non-class support functions for gdisk program. |
| 3 | // Primarily by Rod Smith, February 2009, but with a few functions |
| 4 | // copied from other sources (see attributions below). |
| 5 | |
srs5694 | 221e087 | 2009-08-29 15:00:31 -0400 | [diff] [blame] | 6 | /* This program is copyright (c) 2009 by Roderick W. Smith. It is distributed |
| 7 | under the terms of the GNU GPL version 2, as detailed in the COPYING file. */ |
| 8 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 9 | #define __STDC_LIMIT_MACROS |
| 10 | #define __STDC_CONSTANT_MACROS |
| 11 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 12 | #include <stdio.h> |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 13 | #include <stdint.h> |
| 14 | #include <errno.h> |
srs5694 | e4ac11e | 2009-08-31 10:13:04 -0400 | [diff] [blame] | 15 | #include <fcntl.h> |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 16 | #include <string.h> |
srs5694 | e35eb1b | 2009-09-14 00:29:34 -0400 | [diff] [blame] | 17 | #include <sys/stat.h> |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 18 | #include <string> |
| 19 | #include <iostream> |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 20 | #include <sstream> |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 21 | #include "support.h" |
| 22 | |
| 23 | #include <sys/types.h> |
| 24 | |
srs5694 | 5d58fe0 | 2010-01-03 20:57:08 -0500 | [diff] [blame] | 25 | // As of 1/2010, BLKPBSZGET is very new, so I'm explicitly defining it if |
| 26 | // it's not already defined. This should become unnecessary in the future. |
| 27 | // Note that this is a Linux-only ioctl.... |
| 28 | #ifndef BLKPBSZGET |
| 29 | #define BLKPBSZGET _IO(0x12,123) |
| 30 | #endif |
| 31 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 32 | using namespace std; |
| 33 | |
| 34 | // Get a numeric value from the user, between low and high (inclusive). |
| 35 | // Keeps looping until the user enters a value within that range. |
| 36 | // If user provides no input, def (default value) is returned. |
| 37 | // (If def is outside of the low-high range, an explicit response |
| 38 | // is required.) |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 39 | int GetNumber(int low, int high, int def, const string & prompt) { |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 40 | int response, num; |
| 41 | char line[255]; |
| 42 | |
| 43 | if (low != high) { // bother only if low and high differ... |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 44 | do { |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 45 | cout << prompt; |
| 46 | cin.getline(line, 255); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 47 | num = sscanf(line, "%d", &response); |
| 48 | if (num == 1) { // user provided a response |
| 49 | if ((response < low) || (response > high)) |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 50 | cout << "Value out of range\n"; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 51 | } else { // user hit enter; return default |
| 52 | response = def; |
| 53 | } // if/else |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 54 | } while ((response < low) || (response > high)); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 55 | } else { // low == high, so return this value |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 56 | cout << "Using " << low << "\n"; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 57 | response = low; |
| 58 | } // else |
| 59 | return (response); |
| 60 | } // GetNumber() |
| 61 | |
| 62 | // Gets a Y/N response (and converts lowercase to uppercase) |
| 63 | char GetYN(void) { |
| 64 | char line[255]; |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 65 | char response; |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 66 | char *junk; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 67 | |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 68 | do { |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 69 | cout << "(Y/N): "; |
srs5694 | 5d58fe0 | 2010-01-03 20:57:08 -0500 | [diff] [blame] | 70 | junk = fgets(line, 255, stdin); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 71 | sscanf(line, "%c", &response); |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 72 | if (response == 'y') |
| 73 | response = 'Y'; |
| 74 | if (response == 'n') |
| 75 | response = 'N'; |
| 76 | } while ((response != 'Y') && (response != 'N')); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 77 | return response; |
| 78 | } // GetYN(void) |
| 79 | |
srs5694 | e4ac11e | 2009-08-31 10:13:04 -0400 | [diff] [blame] | 80 | // Obtains a sector number, between low and high, from the |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 81 | // user, accepting values prefixed by "+" to add sectors to low, |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 82 | // or the same with "K", "M", "G", "T", or "P" as suffixes to add |
| 83 | // kilobytes, megabytes, gigabytes, terabytes, or petabytes, |
| 84 | // respectively. If a "-" prefix is used, use the high value minus |
| 85 | // the user-specified number of sectors (or KiB, MiB, etc.). Use the |
| 86 | // def value as the default if the user just hits Enter. The sSize is |
| 87 | // the sector size of the device. |
| 88 | uint64_t GetSectorNum(uint64_t low, uint64_t high, uint64_t def, uint64_t sSize, const string & prompt) { |
| 89 | uint64_t response, mult = 1, divide = 1; |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 90 | int plusFlag = 0; |
| 91 | char suffix, line[255]; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 92 | |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 93 | if (sSize == 0) { |
| 94 | sSize = SECTOR_SIZE; |
| 95 | cerr << "Bug: Sector size invalid in GetSectorNum()!\n"; |
| 96 | } // if |
| 97 | |
| 98 | do { |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 99 | cout << prompt; |
| 100 | cin.getline(line, 255); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 101 | |
| 102 | // Remove leading spaces, if present |
| 103 | while (line[0] == ' ') |
| 104 | strcpy(line, &line[1]); |
| 105 | |
| 106 | // If present, flag and remove leading plus sign |
| 107 | if (line[0] == '+') { |
| 108 | plusFlag = 1; |
| 109 | strcpy(line, &line[1]); |
| 110 | } // if |
| 111 | |
srs5694 | e4ac11e | 2009-08-31 10:13:04 -0400 | [diff] [blame] | 112 | // If present, flag and remove leading minus sign |
| 113 | if (line[0] == '-') { |
| 114 | plusFlag = -1; |
| 115 | strcpy(line, &line[1]); |
| 116 | } // if |
| 117 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 118 | // Extract numeric response and, if present, suffix |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 119 | istringstream inString(line); |
| 120 | inString >> response >> suffix; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 121 | |
srs5694 | e4ac11e | 2009-08-31 10:13:04 -0400 | [diff] [blame] | 122 | // If no response, use default (def) |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 123 | if (strlen(line) == 0) { |
| 124 | response = def; |
| 125 | suffix = ' '; |
srs5694 | e19ba09 | 2009-08-24 14:10:35 -0400 | [diff] [blame] | 126 | plusFlag = 0; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 127 | } // if |
| 128 | |
| 129 | // Set multiplier based on suffix |
| 130 | switch (suffix) { |
| 131 | case 'K': |
| 132 | case 'k': |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 133 | mult = UINT64_C(1024) / sSize; |
| 134 | divide = sSize / UINT64_C(1024); |
| 135 | break; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 136 | break; |
| 137 | case 'M': |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 138 | case 'm': |
| 139 | mult = UINT64_C(1048576) / sSize; |
| 140 | divide = sSize / UINT64_C(1048576); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 141 | break; |
| 142 | case 'G': |
| 143 | case 'g': |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 144 | mult = UINT64_C(1073741824) / sSize; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 145 | break; |
| 146 | case 'T': |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 147 | case 't': |
| 148 | mult = UINT64_C(1099511627776) / sSize; |
| 149 | break; |
| 150 | case 'P': |
| 151 | case 'p': |
| 152 | mult = UINT64_C(1125899906842624) / sSize; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 153 | break; |
| 154 | default: |
| 155 | mult = 1; |
| 156 | } // switch |
| 157 | |
| 158 | // Adjust response based on multiplier and plus flag, if present |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 159 | if (mult > 1) |
| 160 | response *= mult; |
| 161 | else if (divide > 1) |
| 162 | response /= divide; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 163 | if (plusFlag == 1) { |
srs5694 | ba00fed | 2010-01-12 18:18:36 -0500 | [diff] [blame] | 164 | // Recompute response based on low part of range (if default = high |
| 165 | // value, which should be the case when prompting for the end of a |
| 166 | // range) or the defaut value (if default != high, which should be |
| 167 | // the case for the first sector of a partition). |
| 168 | if (def == high) |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 169 | response = response + low - UINT64_C(1); |
srs5694 | ba00fed | 2010-01-12 18:18:36 -0500 | [diff] [blame] | 170 | else |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 171 | response = response + def - UINT64_C(1); |
srs5694 | e4ac11e | 2009-08-31 10:13:04 -0400 | [diff] [blame] | 172 | } // if |
| 173 | if (plusFlag == -1) { |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 174 | response = high - response; |
srs5694 | e19ba09 | 2009-08-24 14:10:35 -0400 | [diff] [blame] | 175 | } // if |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 176 | } while ((response < low) || (response > high)); |
srs5694 | 55d9261 | 2010-03-07 22:16:07 -0500 | [diff] [blame] | 177 | return response; |
srs5694 | e4ac11e | 2009-08-31 10:13:04 -0400 | [diff] [blame] | 178 | } // GetSectorNum() |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 179 | |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 180 | // Takes a size and converts this to a size in SI units (KiB, MiB, GiB, |
| 181 | // TiB, or PiB), returned in C++ string form. The size is either in units |
| 182 | // of the sector size or, if that parameter is omitted, in bytes. |
| 183 | // (sectorSize defaults to 1). |
| 184 | string BytesToSI(uint64_t size, uint32_t sectorSize) { |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 185 | string units; |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 186 | ostringstream theValue; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 187 | float sizeInSI; |
| 188 | |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 189 | sizeInSI = (float) size * (float) sectorSize; |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 190 | units = " bytes"; |
| 191 | if (sizeInSI > 1024.0) { |
| 192 | sizeInSI /= 1024.0; |
| 193 | units = " KiB"; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 194 | } // if |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 195 | if (sizeInSI > 1024.0) { |
| 196 | sizeInSI /= 1024.0; |
| 197 | units = " MiB"; |
| 198 | } // if |
| 199 | if (sizeInSI > 1024.0) { |
| 200 | sizeInSI /= 1024.0; |
| 201 | units = " GiB"; |
| 202 | } // if |
| 203 | if (sizeInSI > 1024.0) { |
| 204 | sizeInSI /= 1024.0; |
| 205 | units = " TiB"; |
| 206 | } // if |
| 207 | if (sizeInSI > 1024.0) { |
| 208 | sizeInSI /= 1024.0; |
| 209 | units = " PiB"; |
| 210 | } // if |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 211 | theValue.setf(ios::fixed); |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 212 | if (units == " bytes") { // in bytes, so no decimal point |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 213 | theValue.precision(0); |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 214 | } else { |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 215 | theValue.precision(1); |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 216 | } // if/else |
srs5694 | 08bb0da | 2010-02-19 17:19:55 -0500 | [diff] [blame] | 217 | theValue << sizeInSI << units; |
| 218 | return theValue.str(); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 219 | } // BlocksToSI() |
| 220 | |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 221 | // Converts two consecutive characters in the input string into a |
| 222 | // number, interpreting the string as a hexadecimal number, starting |
| 223 | // at the specified position. |
| 224 | unsigned char StrToHex(const string & input, unsigned int position) { |
| 225 | unsigned char retval = 0x00; |
| 226 | unsigned int temp; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 227 | |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 228 | if (input.length() >= (position + 2)) { |
| 229 | sscanf(input.substr(position, 2).c_str(), "%x", &temp); |
| 230 | retval = (unsigned char) temp; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 231 | } // if |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 232 | return retval; |
| 233 | } // StrToHex() |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 234 | |
srs5694 | 0873e9d | 2010-10-07 13:00:45 -0400 | [diff] [blame^] | 235 | // Returns 1 if input can be interpreted as a hexadecimal number -- |
| 236 | // all characters must be spaces, digits, or letters A-F (upper- or |
| 237 | // lower-case), with at least one valid hexadecimal digit; otherwise |
| 238 | // returns 0. |
| 239 | int IsHex(const string & input) { |
| 240 | int isHex = 1, foundHex = 0, i; |
| 241 | |
| 242 | for (i = 0; i < (int) input.length(); i++) { |
| 243 | if ((input[i] < '0') || (input[i] > '9')) { |
| 244 | if ((input[i] < 'A') || (input[i] > 'F')) { |
| 245 | if ((input[i] < 'a') || (input[i] > 'f')) { |
| 246 | if ((input[i] != ' ') && (input[i] != '\n')) { |
| 247 | isHex = 0; |
| 248 | } |
| 249 | } else foundHex = 1; |
| 250 | } else foundHex = 1; |
| 251 | } else foundHex = 1; |
| 252 | } // for |
| 253 | if (!foundHex) |
| 254 | isHex = 0; |
| 255 | return isHex; |
| 256 | } // IsHex() |
| 257 | |
srs5694 | 2a9f5da | 2009-08-26 00:48:01 -0400 | [diff] [blame] | 258 | // Return 1 if the CPU architecture is little endian, 0 if it's big endian.... |
| 259 | int IsLittleEndian(void) { |
| 260 | int littleE = 1; // assume little-endian (Intel-style) |
| 261 | union { |
| 262 | uint32_t num; |
| 263 | unsigned char uc[sizeof(uint32_t)]; |
| 264 | } endian; |
| 265 | |
| 266 | endian.num = 1; |
| 267 | if (endian.uc[0] != (unsigned char) 1) { |
| 268 | littleE = 0; |
| 269 | } // if |
| 270 | return (littleE); |
| 271 | } // IsLittleEndian() |
| 272 | |
| 273 | // Reverse the byte order of theValue; numBytes is number of bytes |
srs5694 | 221e087 | 2009-08-29 15:00:31 -0400 | [diff] [blame] | 274 | void ReverseBytes(void* theValue, int numBytes) { |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 275 | char* tempValue = NULL; |
srs5694 | 2a9f5da | 2009-08-26 00:48:01 -0400 | [diff] [blame] | 276 | int i; |
| 277 | |
srs5694 | cb76c67 | 2010-02-11 22:22:22 -0500 | [diff] [blame] | 278 | tempValue = new char [numBytes]; |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 279 | if (tempValue != NULL) { |
| 280 | memcpy(tempValue, theValue, numBytes); |
| 281 | for (i = 0; i < numBytes; i++) |
| 282 | ((char*) theValue)[i] = tempValue[numBytes - i - 1]; |
srs5694 | cb76c67 | 2010-02-11 22:22:22 -0500 | [diff] [blame] | 283 | delete[] tempValue; |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 284 | } // if |
srs5694 | 2a9f5da | 2009-08-26 00:48:01 -0400 | [diff] [blame] | 285 | } // ReverseBytes() |
| 286 | |
srs5694 | 9ddc14b | 2010-08-22 22:44:42 -0400 | [diff] [blame] | 287 | // Extract integer data from argument string, which should be colon-delimited |
| 288 | uint64_t GetInt(const string & argument, int itemNum) { |
| 289 | int startPos = -1, endPos = -1; |
| 290 | uint64_t retval = 0; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 291 | |
srs5694 | 9ddc14b | 2010-08-22 22:44:42 -0400 | [diff] [blame] | 292 | while (itemNum-- > 0) { |
| 293 | startPos = endPos + 1; |
srs5694 | ab4b043 | 2010-09-25 20:39:52 -0400 | [diff] [blame] | 294 | endPos = (int) argument.find(':', startPos); |
srs5694 | 9ddc14b | 2010-08-22 22:44:42 -0400 | [diff] [blame] | 295 | } |
| 296 | if (endPos == (int) string::npos) |
srs5694 | ab4b043 | 2010-09-25 20:39:52 -0400 | [diff] [blame] | 297 | endPos = (int) argument.length(); |
srs5694 | 9ddc14b | 2010-08-22 22:44:42 -0400 | [diff] [blame] | 298 | endPos--; |
| 299 | |
| 300 | istringstream inString(argument.substr(startPos, endPos - startPos + 1)); |
| 301 | inString >> retval; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 302 | return retval; |
srs5694 | 9ddc14b | 2010-08-22 22:44:42 -0400 | [diff] [blame] | 303 | } // GetInt() |
| 304 | |
| 305 | // Extract string data from argument string, which should be colon-delimited |
| 306 | string GetString(const string & argument, int itemNum) { |
| 307 | int startPos = -1, endPos = -1; |
| 308 | |
| 309 | while (itemNum-- > 0) { |
| 310 | startPos = endPos + 1; |
srs5694 | ab4b043 | 2010-09-25 20:39:52 -0400 | [diff] [blame] | 311 | endPos = (int) argument.find(':', startPos); |
srs5694 | 9ddc14b | 2010-08-22 22:44:42 -0400 | [diff] [blame] | 312 | } |
| 313 | if (endPos == (int) string::npos) |
srs5694 | ab4b043 | 2010-09-25 20:39:52 -0400 | [diff] [blame] | 314 | endPos = (int) argument.length(); |
srs5694 | 9ddc14b | 2010-08-22 22:44:42 -0400 | [diff] [blame] | 315 | endPos--; |
| 316 | |
| 317 | return argument.substr(startPos, endPos - startPos + 1); |
| 318 | } // GetString() |