Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
result.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
8 * You may select, at your option, one of the above-listed licenses.
9 */
10
11#ifndef RESULT_H
12#define RESULT_H
13
14#include <stddef.h>
15
27
31typedef struct {
32 size_t total_size;
34
39typedef struct {
40 result_error_t internal_error;
41 result_data_t internal_data;
42} result_t;
43
47static result_t result_error(result_error_t error);
51static result_t result_data(result_data_t data);
52
56static int result_is_error(result_t result);
60static int result_is_skip(result_t result);
64static result_error_t result_get_error(result_t result);
68static result_data_t result_get_data(result_t result);
69
70static result_t result_error(result_error_t error) {
71 result_t result = {
72 .internal_error = error,
73 };
74 return result;
75}
76
77static result_t result_data(result_data_t data) {
78 result_t result = {
79 .internal_error = result_error_ok,
80 .internal_data = data,
81 };
82 return result;
83}
84
85static int result_is_error(result_t result) {
86 return result_get_error(result) != result_error_ok;
87}
88
89static int result_is_skip(result_t result) {
90 return result_get_error(result) == result_error_skip;
91}
92
93static result_error_t result_get_error(result_t result) {
94 return result.internal_error;
95}
96
97char const* result_get_error_string(result_t result);
98
99static result_data_t result_get_data(result_t result) {
100 return result.internal_data;
101}
102
103#endif
static const void * data
Definition XzCrc64.c:50
Definition poolTests.c:28
Definition result.h:31
Definition result.h:39
result_data_t internal_data
Definition result.h:41
result_error_t internal_error
Definition result.h:40
char const * result_get_error_string(result_t result)
Definition result.c:13
result_error_t
Definition result.h:19
@ result_error_system_error
Definition result.h:22
@ result_error_decompression_error
Definition result.h:24
@ result_error_skip
Definition result.h:21
@ result_error_ok
Definition result.h:20
@ result_error_round_trip_error
Definition result.h:25
@ result_error_compression_error
Definition result.h:23
void error(char *msg) const
Definition minigzip.c:356