GRU - Generic Reusable Utilities
Data Structures | Macros | Typedefs | Enumerations | Functions
gru_status.h File Reference
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common/gru_portable.h"

Go to the source code of this file.

Data Structures

struct  gru_status_t_
 Status type. More...
 

Macros

#define GRU_MAX_ERROR_MESSAGE   1024
 Copyright 2016 Otavio Rodolfo Piske. More...
 

Typedefs

typedef enum gru_status_code_t_ gru_status_code_t
 
typedef struct gru_status_t_ gru_status_t
 Status type. More...
 

Enumerations

enum  gru_status_code_t_ { GRU_SUCCESS , GRU_FAILURE }
 

Functions

gru_export gru_status_t gru_status_new ()
 Create a new status object. More...
 
gru_export void gru_status_set (gru_status_t *status, gru_status_code_t code, const char *message,...)
 Sets the status. More...
 
gru_export void gru_status_strerror (gru_status_t *status, gru_status_code_t code, int errnum)
 Sets the status from the errno. More...
 
gru_export void gru_status_reset (gru_status_t *status)
 Resets the status. More...
 
gru_export void gru_status_set_success (gru_status_t *status)
 Sets the status to success. More...
 
gru_export bool gru_status_error (const gru_status_t *status)
 Checks for error status. More...
 
gru_export bool gru_status_success (const gru_status_t *status)
 Checks for success status. More...
 

Macro Definition Documentation

◆ GRU_MAX_ERROR_MESSAGE

#define GRU_MAX_ERROR_MESSAGE   1024

Copyright 2016 Otavio Rodolfo Piske.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Typedef Documentation

◆ gru_status_code_t

◆ gru_status_t

typedef struct gru_status_t_ gru_status_t

Status type.

Enumeration Type Documentation

◆ gru_status_code_t_

Enumerator
GRU_SUCCESS 
GRU_FAILURE 

Function Documentation

◆ gru_status_error()

gru_export bool gru_status_error ( const gru_status_t status)
inline

Checks for error status.

Parameters
statusthe status object to check
Returns
true if an error or false otherwise

◆ gru_status_new()

gru_export gru_status_t gru_status_new ( )
inline

Create a new status object.

Returns
a new status object

Create a new status object.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

◆ gru_status_reset()

gru_export void gru_status_reset ( gru_status_t status)

Resets the status.

Parameters
statusan instance of the status object to set

◆ gru_status_set()

gru_export void gru_status_set ( gru_status_t status,
gru_status_code_t  code,
const char *  message,
  ... 
)

Sets the status.

Parameters
statusan instance of the status object to set
codethe code to set the object to
messagethe status message followed by any other parameter as accepted by vasprintf

◆ gru_status_set_success()

gru_export void gru_status_set_success ( gru_status_t status)

Sets the status to success.

Parameters
statusan instance of the status object to set

◆ gru_status_strerror()

gru_export void gru_status_strerror ( gru_status_t status,
gru_status_code_t  code,
int  errnum 
)

Sets the status from the errno.

Parameters
statusan instance of the status object to set
codethe code to set the object to
errnumthe error number (as in errno)

◆ gru_status_success()

gru_export bool gru_status_success ( const gru_status_t status)
inline

Checks for success status.

Parameters
statusthe status object to check
Returns
true if success or false otherwise