Pulsar  3d3a057
Macros | Typedefs | Enumerations
types.h File Reference

Base types. More...

#include <switch.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <unistd.h>

Go to the source code of this file.

Macros

#define PLSR_RC_MAKE_RESULT_TYPE(RESULT_TYPE)   (PLSR_ResultType_ ## RESULT_TYPE)
 Shortcut to get a result type enum from its name.
 
#define PLSR_RC_MAKE_CATEGORY_TYPE(ARCHIVE_TYPE, CATEGORY_TYPE)   (PLSR_ ## ARCHIVE_TYPE ## CategoryType_ ## CATEGORY_TYPE)
 Shortcut to get a category enum from its name.
 
#define PLSR_RC_MAKE_ARCHIVE_TYPE(ARCHIVE_TYPE)   (PLSR_ArchiveType_ ## ARCHIVE_TYPE)
 Shortcut to get an archive enum from its name.
 
#define PLSR_RC_MAKE_RAW(ARCHIVE, CATEGORY, RESULT)   (RESULT + (CATEGORY << 8) + (ARCHIVE << 16))
 Make a result code from raw integers.
 
#define PLSR_RC_MAKE(ARCHIVE_TYPE, CATEGORY_TYPE, RESULT_TYPE)
 Make a result code from archive, category and result type names. More...
 
#define PLSR_RC_OK   0
 Result code returned on success.
 
#define PLSR_RC_FAILED(RESULT)   (RESULT != PLSR_RC_OK)
 Test that the result code means failure.
 
#define PLSR_RC_SUCCEEDED(RESULT)   (RESULT == PLSR_RC_OK)
 Test that the result code means success.
 
#define PLSR_RC_ARCHIVE(RESULT)   ((RESULT >> 16) & 0xFF)
 Extract the archive part of a result code.
 
#define PLSR_RC_CATEGORY(RESULT)   ((RESULT >> 8) & 0xFF)
 Extract the category part of a result code.
 
#define PLSR_RC_RESULT(RESULT)   (RESULT & 0xFF)
 Extract the result type part of a result code.
 
#define PLSR_RC_CONVERT(RESULT, NEW_ARCHIVE_TYPE, NEW_CATEGORY_TYPE)
 Convert a result code to another archive and category, keeping the result type. More...
 
#define PLSR_RC_TRY(X)
 Return result code if failed. More...
 
#define PLSR_RC_LTRY(ARCHIVE_TYPE, CATEGORY_TYPE, X)
 Return result code if failed, also converts result to a new archive and category. More...
 
#define PLSR_RC_NX_LTRY(ARCHIVE_TYPE, CATEGORY_TYPE, NX_RESULT)
 Return a System type result code if the libnx result failed. More...
 

Typedefs

typedef u32 PLSR_RC
 Result code returned by Pulsar functions.
 

Enumerations

enum  PLSR_ResultType {
  PLSR_ResultType_OK = 0,
  PLSR_ResultType_FileRead,
  PLSR_ResultType_BadMagic,
  PLSR_ResultType_BadEndianness,
  PLSR_ResultType_BadInput,
  PLSR_ResultType_NotFound,
  PLSR_ResultType_NotReady,
  PLSR_ResultType_Unsupported,
  PLSR_ResultType_Memory,
  PLSR_ResultType_System = 0xFF
}
 Result code types. More...
 
enum  PLSR_ArchiveType {
  PLSR_ArchiveType_Unknown = 0,
  PLSR_ArchiveType_BFSAR,
  PLSR_ArchiveType_BFGRP,
  PLSR_ArchiveType_BFWSD,
  PLSR_ArchiveType_BFWAR,
  PLSR_ArchiveType_BFWAV,
  PLSR_ArchiveType_BFSTM,
  PLSR_ArchiveType_Player = 0xFF
}
 Supported archive types. More...
 

Detailed Description

Base types.

Macro Definition Documentation

◆ PLSR_RC_CONVERT

#define PLSR_RC_CONVERT (   RESULT,
  NEW_ARCHIVE_TYPE,
  NEW_CATEGORY_TYPE 
)
Value:
PLSR_RC_MAKE_ARCHIVE_TYPE(NEW_ARCHIVE_TYPE), \
PLSR_RC_MAKE_CATEGORY_TYPE(NEW_ARCHIVE_TYPE, NEW_CATEGORY_TYPE), \
PLSR_RC_RESULT(RESULT) \
)
#define PLSR_RC_MAKE_ARCHIVE_TYPE(ARCHIVE_TYPE)
Shortcut to get an archive enum from its name.
Definition: types.h:19
#define PLSR_RC_MAKE_RAW(ARCHIVE, CATEGORY, RESULT)
Make a result code from raw integers.
Definition: types.h:22
#define PLSR_RC_MAKE_CATEGORY_TYPE(ARCHIVE_TYPE, CATEGORY_TYPE)
Shortcut to get a category enum from its name.
Definition: types.h:17
#define PLSR_RC_RESULT(RESULT)
Extract the result type part of a result code.
Definition: types.h:43

Convert a result code to another archive and category, keeping the result type.

Note
This is mainly meant to convert errors from generic archive read calls into the callee archive and category type

◆ PLSR_RC_LTRY

#define PLSR_RC_LTRY (   ARCHIVE_TYPE,
  CATEGORY_TYPE,
 
)
Value:
do { \
const PLSR_RC _rc = (X); \
if(PLSR_RC_FAILED(_rc)) { return PLSR_RC_CONVERT(_rc, ARCHIVE_TYPE, CATEGORY_TYPE); } \
} while(false)
#define PLSR_RC_CONVERT(RESULT, NEW_ARCHIVE_TYPE, NEW_CATEGORY_TYPE)
Convert a result code to another archive and category, keeping the result type.
Definition: types.h:47
#define PLSR_RC_FAILED(RESULT)
Test that the result code means failure.
Definition: types.h:34
u32 PLSR_RC
Result code returned by Pulsar functions.
Definition: types.h:73

Return result code if failed, also converts result to a new archive and category.

Note
This is mainly meant to convert errors from generic archive read calls into the callee archive and category type

◆ PLSR_RC_MAKE

#define PLSR_RC_MAKE (   ARCHIVE_TYPE,
  CATEGORY_TYPE,
  RESULT_TYPE 
)
Value:
PLSR_RC_MAKE_ARCHIVE_TYPE(ARCHIVE_TYPE), \
PLSR_RC_MAKE_CATEGORY_TYPE(ARCHIVE_TYPE, CATEGORY_TYPE), \
PLSR_RC_MAKE_RESULT_TYPE(RESULT_TYPE) \
)
#define PLSR_RC_MAKE_ARCHIVE_TYPE(ARCHIVE_TYPE)
Shortcut to get an archive enum from its name.
Definition: types.h:19
#define PLSR_RC_MAKE_RAW(ARCHIVE, CATEGORY, RESULT)
Make a result code from raw integers.
Definition: types.h:22
#define PLSR_RC_MAKE_CATEGORY_TYPE(ARCHIVE_TYPE, CATEGORY_TYPE)
Shortcut to get a category enum from its name.
Definition: types.h:17
#define PLSR_RC_MAKE_RESULT_TYPE(RESULT_TYPE)
Shortcut to get a result type enum from its name.
Definition: types.h:15

Make a result code from archive, category and result type names.

◆ PLSR_RC_NX_LTRY

#define PLSR_RC_NX_LTRY (   ARCHIVE_TYPE,
  CATEGORY_TYPE,
  NX_RESULT 
)
Value:
do { \
if(R_FAILED(NX_RESULT)) { return PLSR_RC_MAKE(ARCHIVE_TYPE, CATEGORY_TYPE, System); } \
} while(false)
#define PLSR_RC_MAKE(ARCHIVE_TYPE, CATEGORY_TYPE, RESULT_TYPE)
Make a result code from archive, category and result type names.
Definition: types.h:25

Return a System type result code if the libnx result failed.

Note
This is mainly used in the player when calling the audio renderer

◆ PLSR_RC_TRY

#define PLSR_RC_TRY (   X)
Value:
do { \
const PLSR_RC _rc = (X); \
if(PLSR_RC_FAILED(_rc)) { return _rc; } \
} while(false)
#define PLSR_RC_FAILED(RESULT)
Test that the result code means failure.
Definition: types.h:34
u32 PLSR_RC
Result code returned by Pulsar functions.
Definition: types.h:73

Return result code if failed.

Examples:
example01-simple.c, and example02-browse.c.

Enumeration Type Documentation

◆ PLSR_ArchiveType

Supported archive types.

Enumerator
PLSR_ArchiveType_BFSAR 

Sound archive.

PLSR_ArchiveType_BFGRP 

Sound group.

PLSR_ArchiveType_BFWSD 

Wave sound data.

PLSR_ArchiveType_BFWAR 

Wave archive.

PLSR_ArchiveType_BFWAV 

Wave file.

PLSR_ArchiveType_BFSTM 

Stream file.

PLSR_ArchiveType_Player 

Not an archive, type used by Player functions.

◆ PLSR_ResultType

Result code types.

Enumerator
PLSR_ResultType_FileRead 

File could not be opened or read.

PLSR_ResultType_BadMagic 

Magic mismatch.

PLSR_ResultType_BadEndianness 

Archive endianness did not match host endianness.

PLSR_ResultType_BadInput 

Function was called with improper arguments.

PLSR_ResultType_NotFound 

Requested data could not be retrieved.

PLSR_ResultType_NotReady 

Function was called before required initialization.

PLSR_ResultType_Unsupported 

Execution encountered an unexpected case.

PLSR_ResultType_Memory 

Memory allocation failed.

PLSR_ResultType_System 

Can indicate an underlying libnx fn call failure.