* returns history ``num''th event * * returned pointer points to static variable */
| 1382 | * returned pointer points to static variable |
| 1383 | */ |
| 1384 | HIST_ENTRY * |
| 1385 | history_get(int num) |
| 1386 | { |
| 1387 | static HIST_ENTRY she; |
| 1388 | HistEvent ev; |
| 1389 | int curr_num; |
| 1390 | |
| 1391 | if (h == NULL || e == NULL) |
| 1392 | rl_initialize(); |
| 1393 | |
| 1394 | /* save current position */ |
| 1395 | if (history(h, &ev, H_CURR) != 0) |
| 1396 | return NULL; |
| 1397 | curr_num = ev.num; |
| 1398 | |
| 1399 | /* start from the oldest */ |
| 1400 | if (history(h, &ev, H_LAST) != 0) |
| 1401 | return NULL; /* error */ |
| 1402 | |
| 1403 | /* look forwards for event matching specified offset */ |
| 1404 | if (history(h, &ev, H_NEXT_EVDATA, num, &she.data)) |
| 1405 | return NULL; |
| 1406 | |
| 1407 | she.line = ev.str; |
| 1408 | |
| 1409 | /* restore pointer to where it was */ |
| 1410 | (void)history(h, &ev, H_SET, curr_num); |
| 1411 | |
| 1412 | return &she; |
| 1413 | } |
| 1414 | |
| 1415 | |
| 1416 | /* |
no test coverage detected