Frees allocated memory and sets pointers to NULL before calling readline * and then parses the input into space separated tokens. */
| 279 | * and then parses the input into space separated tokens. |
| 280 | */ |
| 281 | static void rp_getline(const char *s) |
| 282 | { |
| 283 | int i; |
| 284 | |
| 285 | /* free allocated memory and set pointers to NULL */ |
| 286 | if (input_line) |
| 287 | { |
| 288 | free(input_line); |
| 289 | input_line = (char *)NULL; |
| 290 | } |
| 291 | |
| 292 | if (result) |
| 293 | { |
| 294 | result = (char *)NULL; |
| 295 | } |
| 296 | |
| 297 | /* cmd, arg1, arg2, arg3, arg4, arg5, arg6 |
| 298 | * arg5 and arg 6 are currently unused. |
| 299 | */ |
| 300 | for (i = 0; i < 7; i++) |
| 301 | { |
| 302 | parsed_input[i] = NULL; |
| 303 | } |
| 304 | |
| 305 | /* Action! Returns typed line with newline stripped. */ |
| 306 | input_line = readline(s); |
| 307 | } |
| 308 | #endif |
| 309 | |
| 310 | /* |