logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

truncation.h (557B)


  1. // Collection of Unix tools, comparable to coreutils
  2. // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: MPL-2.0
  4. #define _POSIX_C_SOURCE 200809L
  5. #include <sys/types.h> // off_t
  6. enum operation_e
  7. {
  8. OP_SET,
  9. OP_INC,
  10. OP_DEC,
  11. OP_CHK_DOWN,
  12. OP_CHK_UP,
  13. };
  14. struct truncation
  15. {
  16. enum operation_e op;
  17. off_t size;
  18. };
  19. int parse_size(const char *arg, struct truncation *buf);
  20. int apply_size_suffix(unsigned long *size, char *endptr);
  21. int apply_truncation(int fd, struct truncation tr, char *arg);