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