| 445 | |
| 446 | |
| 447 | static SLONG write_bucket(const msgnod* bucket, USHORT length) |
| 448 | { |
| 449 | /************************************** |
| 450 | * |
| 451 | * w r i t e _ b u c k e t |
| 452 | * |
| 453 | ************************************** |
| 454 | * |
| 455 | * Functional description |
| 456 | * Write stuff, return position of stuff written. |
| 457 | * |
| 458 | **************************************/ |
| 459 | const USHORT padded_length = ROUNDUP(length, sizeof(SLONG)); |
| 460 | const SLONG position = global_file_position; |
| 461 | int n = write(global_file, bucket, length); |
| 462 | if (n == -1) |
| 463 | { |
| 464 | fprintf(stderr, "IO error on write()\n"); |
| 465 | exit(FINI_ERROR); |
| 466 | } |
| 467 | |
| 468 | const SLONG zero_bytes = 0; |
| 469 | n = write(global_file, &zero_bytes, padded_length - length); |
| 470 | if (n == -1) |
| 471 | { |
| 472 | fprintf(stderr, "IO error on write()\n"); |
| 473 | exit(FINI_ERROR); |
| 474 | } |
| 475 | global_file_position += padded_length; |
| 476 | |
| 477 | return position; |
| 478 | } |