Core library operations

Core library operations — Methods and types to initialize and teardown the library.

Functions

const char * mccr_status_to_string ()
mccr_status_t mccr_init ()
void mccr_exit ()

Types and Values

Description

This section defines the core types and methods exposed by the MCCR library.

Example 1. Initializing and tearing down the library

1
2
3
4
5
6
7
8
9
10
mccr_status_t  st;

if ((st = mccr_init ()) != MCCR_STATUS_OK) {
  fprintf (stderr, "error: couldn't initialize MCCR library: %s\n", mccr_status_to_string (st));
  return EXIT_FAILURE;
}

// Use the library here

mccr_exit ();

Functions

mccr_status_to_string ()

const char *
mccr_status_to_string (mccr_status_t st);

Gets a description for the given mccr_status_t.

Parameters

st

a mccr_status_t.

 

Returns

a constant string.


mccr_init ()

mccr_status_t
mccr_init (void);

Initialize the library.

This operation must be run once at program startup, or after mccr_exit() has been run and the library needs to be reinitialized.

If mccr_init() fails, no further library operations may be executed, it is a fatal error.

Returns

a mccr_status_t.


mccr_exit ()

void
mccr_exit (void);

Teardown the library.

If a clean output report is required, the user may teardown the library using this method. It isn't strictly required to do this unless mccr_init() is going to be called again.

Types and Values

enum mccr_status_t

Status of an operation performed with the MCCR library.

Members

MCCR_STATUS_OK

Operation successful.

 

MCCR_STATUS_FAILED

Operation failed.

 

MCCR_STATUS_NOT_FOUND

Item not found.

 

MCCR_STATUS_INTERNAL

Internal error.

 

MCCR_STATUS_NOT_OPEN

Device not open.

 

MCCR_STATUS_WRITE_FAILED

Writing to the device failed.

 

MCCR_STATUS_READ_FAILED

Reading from the device failed.

 

MCCR_STATUS_REPORT_FAILED

Report failed.

 

MCCR_STATUS_DELAYED

Operation delayed.

 

MCCR_STATUS_INVALID_OPERATION

Invalid operation.

 

MCCR_STATUS_INVALID_INPUT

Invalid input.

 

MCCR_STATUS_UNEXPECTED_FORMAT

Unexpected format.

 

MCCR_STATUS_TIMED_OUT

Operation timed out.