mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
Origin commit data
------------------
Branch: master
Commit: c3278d9c3e
Author: martii <m4rtii@gmx.de>
Date: 2014-03-21 (Fri, 21 Mar 2014)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
84 lines
1.6 KiB
C
84 lines
1.6 KiB
C
#ifndef misc_123
|
|
#define misc_123
|
|
|
|
#include <dirent.h>
|
|
|
|
/* some useful things needed by many files ... */
|
|
|
|
/* ***************************** */
|
|
/* Types */
|
|
/* ***************************** */
|
|
|
|
typedef struct BitPacker_s {
|
|
unsigned char *Ptr; /* write pointer */
|
|
unsigned int BitBuffer; /* bitreader shifter */
|
|
int Remaining; /* number of remaining in the shifter */
|
|
} BitPacker_t;
|
|
|
|
/* ***************************** */
|
|
/* Makros/Constants */
|
|
/* ***************************** */
|
|
|
|
#define INVALID_PTS_VALUE 0x200000000ull
|
|
|
|
/* ***************************** */
|
|
/* Prototypes */
|
|
/* ***************************** */
|
|
|
|
void PutBits(BitPacker_t * ld, unsigned int code, unsigned int length);
|
|
void FlushBits(BitPacker_t * ld);
|
|
|
|
/* ***************************** */
|
|
/* MISC Functions */
|
|
/* ***************************** */
|
|
|
|
static inline char *getExtension(char *name)
|
|
{
|
|
if (name) {
|
|
char *ext = strrchr(name, '.');
|
|
if (ext)
|
|
return ext + 1;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/* the function returns the base name */
|
|
static inline char *basename(char *name)
|
|
{
|
|
int i = 0;
|
|
int pos = 0;
|
|
|
|
while (name[i] != 0) {
|
|
if (name[i] == '/')
|
|
pos = i;
|
|
i++;
|
|
}
|
|
|
|
if (name[pos] == '/')
|
|
pos++;
|
|
|
|
return name + pos;
|
|
}
|
|
|
|
/* the function returns the directry name */
|
|
static inline char *dirname(char *name)
|
|
{
|
|
static char path[100];
|
|
unsigned int i = 0;
|
|
int pos = 0;
|
|
|
|
while ((name[i] != 0) && (i < sizeof(path))) {
|
|
if (name[i] == '/')
|
|
pos = i;
|
|
path[i] = name[i];
|
|
i++;
|
|
}
|
|
|
|
path[i] = 0;
|
|
path[pos] = 0;
|
|
|
|
return path;
|
|
}
|
|
|
|
#endif
|