Appends price-quote information to the given buffer, updating the given end of string position. *eos mut be buf + strlen(buf). If the update would make bug longer than BUFSZ, instead does nothing. */
| 451 | given end of string position. *eos mut be buf + strlen(buf). If the |
| 452 | update would make bug longer than BUFSZ, instead does nothing. */ |
| 453 | void |
| 454 | append_price_quote(char *buf, char **eos, int otyp) { |
| 455 | char buf2[BUFSZ]; |
| 456 | char *eos2 = buf2; |
| 457 | const char *sep = ""; |
| 458 | size_t len = *eos - buf; |
| 459 | size_t len2; |
| 460 | |
| 461 | if (objects[otyp].oc_sell_minseen > objects[otyp].oc_sell_maxseen && |
| 462 | objects[otyp].oc_buy_minseen > objects[otyp].oc_buy_maxseen) |
| 463 | return; |
| 464 | |
| 465 | eos2 += sprintf(eos2, " {"); |
| 466 | |
| 467 | if (objects[otyp].oc_buy_minseen < objects[otyp].oc_buy_maxseen) { |
| 468 | eos2 += sprintf(eos2, "buy %lu-%lu", |
| 469 | objects[otyp].oc_buy_minseen, |
| 470 | objects[otyp].oc_buy_maxseen); |
| 471 | sep = " "; |
| 472 | } else if (objects[otyp].oc_buy_minseen == objects[otyp].oc_buy_maxseen) { |
| 473 | eos2 += sprintf(eos2, "buy %lu", |
| 474 | objects[otyp].oc_buy_minseen); |
| 475 | sep = " "; |
| 476 | } |
| 477 | |
| 478 | if (objects[otyp].oc_sell_minseen < objects[otyp].oc_sell_maxseen) { |
| 479 | eos2 += sprintf(eos2, "%ssell %lu-%lu", sep, |
| 480 | objects[otyp].oc_sell_minseen, |
| 481 | objects[otyp].oc_sell_maxseen); |
| 482 | } else if (objects[otyp].oc_sell_minseen == objects[otyp].oc_sell_maxseen) { |
| 483 | eos2 += sprintf(eos2, "%ssell %lu", sep, |
| 484 | objects[otyp].oc_sell_minseen); |
| 485 | } |
| 486 | |
| 487 | eos2 += sprintf(eos2, "}"); |
| 488 | len2 = eos2 - buf2; |
| 489 | if (len2 < BUFSZ - len - 1) { |
| 490 | Strcpy(*eos, buf2); |
| 491 | *eos += len2; |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | staticfn long |
| 496 | addupbill(struct monst *shkp) |
no outgoing calls
no test coverage detected