| 201 | } |
| 202 | |
| 203 | void NetStringTable::expandString(NetStringHandle &inString, char *buf, U32 bufSize, U32 argc, const char **argv) |
| 204 | { |
| 205 | buf[0] = StringTagPrefixByte; |
| 206 | dSprintf(buf + 1, bufSize - 1, "%d ", inString.getIndex()); |
| 207 | |
| 208 | const char *string = inString.getString(); |
| 209 | if (string != NULL) { |
| 210 | U32 index = dStrlen(buf); |
| 211 | while(index < bufSize) |
| 212 | { |
| 213 | char c = *string++; |
| 214 | if(c == '%') |
| 215 | { |
| 216 | c = *string++; |
| 217 | if(c >= '1' && c <= '9') |
| 218 | { |
| 219 | U32 strIndex = c - '1'; |
| 220 | if(strIndex >= argc) |
| 221 | continue; |
| 222 | // start copying out of arg index |
| 223 | const char *copy = argv[strIndex]; |
| 224 | // skip past any tags: |
| 225 | if(*copy == StringTagPrefixByte) |
| 226 | { |
| 227 | while(*copy && *copy != ' ') |
| 228 | copy++; |
| 229 | if(*copy) |
| 230 | copy++; |
| 231 | } |
| 232 | |
| 233 | while(*copy && index < bufSize) |
| 234 | buf[index++] = *copy++; |
| 235 | continue; |
| 236 | } |
| 237 | } |
| 238 | buf[index++] = c; |
| 239 | if(!c) |
| 240 | break; |
| 241 | } |
| 242 | buf[bufSize - 1] = 0; |
| 243 | } else { |
| 244 | dStrcat(buf, "<NULL>", bufSize); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | #ifdef TORQUE_DEBUG |
| 249 | |