| 1 | /* |
| 2 | * roast_beef.c -- the hero layer. |
| 3 | * |
| 4 | * Thin. Carved. Pink in the middle, because it is a roast, not a brick. |
| 5 | * "carved" here means passed through a deli slicer set to 1.5 mm. |
| 6 | * It comes back folded, Dr. Seuss style, because folded is how hoagies |
| 7 | * are assembled and there is no refactor that fixes physics. |
| 8 | * |
| 9 | * This file is single-threaded. You do not want multi-threaded roast beef. |
| 10 | */ |
| 11 | #include <deli.h> |
| 12 | #include <hunger.h> |
| 13 | |
| 14 | #define SLICE_MM 1.5 /* the legal maximum thinness */ |
| 15 | |
| 16 | /* yield: many slices, all evidence-free */ |
| 17 | static int slice_into(int pounds, double mm) { |
| 18 | return (int)((pounds * 16) / mm); |
| 19 | } |
| 20 | |
| 21 | int layer_roast_beef(struct hoagie *h, double lbs_per_hoagie) { |
| 22 | if (h == NULL || lbs_per_hoagie < 0.25) { |
| 23 | fprintf(stderr, |
| 24 | "error: that is not a meat hoagie, that is a salad\n"); |
| 25 | return -1; |
| 26 | } |
| 27 | for (int i = 0; i < slice_into(lbs_per_hoagie, SLICE_MM); i++) { |
| 28 | h->add_folded_slices(1); /* fold, never curl */ |
| 29 | } |
| 30 | return h->done() ? EXIT_SUCCESS : EBOREDOM; |
| 31 | } |
| 32 | |
| 33 | /* delicate. do not over-browser. do not heat the bottom half. */ |
| 34 | void rest(void) { |
| 35 | while (still_steaming()) { wait(2); } /* the roast decides */ |
| 36 | announce("medium okay by default; --well-done requires a code review"); |
| 37 | } |