MythTV  master
Classes | Macros | Enumerations | Functions
lirc_client.c File Reference
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <limits.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "lirc_client.h"
Include dependency graph for lirc_client.c:

Go to the source code of this file.

Classes

struct  filestack_t
 

Macros

#define MAX_INCLUDES   10
 
#define LIRC_READ   255
 
#define LIRC_PACKET_SIZE   255
 
#define LIRC_TIMEOUT   3
 
#define PACKET_SIZE   100
 

Enumerations

enum  packet_state {
  P_BEGIN, P_MESSAGE, P_STATUS, P_DATA,
  P_N, P_DATA_N, P_END
}
 

Functions

static void lirc_printf (const struct lirc_state *, const char *format_str,...)
 
static void lirc_perror (const struct lirc_state *, const char *s)
 
static int lirc_readline (const struct lirc_state *state, char **line, FILE *f)
 
static char * lirc_trim (char *s)
 
static char lirc_parse_escape (const struct lirc_state *state, char **s, const char *name, int line)
 
static void lirc_parse_string (const struct lirc_state *state, char *s, const char *name, int line)
 
static void lirc_parse_include (char *s, const char *name, int line)
 
static int lirc_mode (const struct lirc_state *state, const char *token, const char *token2, char **mode, struct lirc_config_entry **new_config, struct lirc_config_entry **first_config, struct lirc_config_entry **last_config, int(check)(char *s), const char *name, int line)
 
static unsigned int lirc_flags (const struct lirc_state *state, char *string)
 
static char * lirc_getfilename (const struct lirc_state *state, const char *file, const char *current_file)
 
static FILE * lirc_open (const struct lirc_state *state, const char *file, const char *current_file, char **full_name)
 
static struct filestack_tstack_push (const struct lirc_state *state, struct filestack_t *parent)
 
static struct filestack_tstack_pop (struct filestack_t *entry)
 
static void stack_free (struct filestack_t *entry)
 
static int lirc_readconfig_only_internal (const struct lirc_state *state, const char *file, struct lirc_config **config, int(check)(char *s), char **full_name, char **sha_bang)
 
static char * lirc_startupmode (const struct lirc_state *state, struct lirc_config_entry *first)
 
static void lirc_freeconfigentries (struct lirc_config_entry *first)
 
static void lirc_clearmode (struct lirc_config *config)
 
static char * lirc_execute (const struct lirc_state *state, struct lirc_config *config, struct lirc_config_entry *scan)
 
static int lirc_iscode (struct lirc_config_entry *scan, char *remote, char *button, unsigned int rep)
 
static int lirc_code2char_internal (const struct lirc_state *state, struct lirc_config *config, char *code, char **string, char **prog)
 
static const char * lirc_read_string (const struct lirc_state *state, int fd)
 
static int lirc_identify (const struct lirc_state *state, int sockfd)
 
static int lirc_send_command (const struct lirc_state *state, int sockfd, const char *command, char *buf, size_t *buf_len, int *ret_status)
 
struct lirc_statelirc_init (const char *lircrc_root_file, const char *lircrc_user_file, const char *prog, const char *lircd, int verbose)
 
int lirc_deinit (struct lirc_state *state)
 
int lirc_readconfig (const struct lirc_state *state, const char *file, struct lirc_config **config, int(check)(char *s))
 
int lirc_readconfig_only (const struct lirc_state *state, const char *file, struct lirc_config **config, int(check)(char *s))
 
void lirc_freeconfig (struct lirc_config *config)
 
int lirc_code2char (const struct lirc_state *state, struct lirc_config *config, char *code, char **string)
 
int lirc_code2charprog (struct lirc_state *state, struct lirc_config *config, char *code, char **string, char **prog)
 
int lirc_nextcode (struct lirc_state *state, char **code)
 
size_t lirc_getsocketname (const char *filename, char *buf, size_t size)
 
const char * lirc_getmode (const struct lirc_state *state, struct lirc_config *config)
 
const char * lirc_setmode (const struct lirc_state *state, struct lirc_config *config, const char *mode)
 

Macro Definition Documentation

◆ MAX_INCLUDES

#define MAX_INCLUDES   10

Definition at line 37 of file lirc_client.c.

◆ LIRC_READ

#define LIRC_READ   255

Definition at line 38 of file lirc_client.c.

◆ LIRC_PACKET_SIZE

#define LIRC_PACKET_SIZE   255

Definition at line 39 of file lirc_client.c.

◆ LIRC_TIMEOUT

#define LIRC_TIMEOUT   3

Definition at line 41 of file lirc_client.c.

◆ PACKET_SIZE

#define PACKET_SIZE   100

Definition at line 1754 of file lirc_client.c.

Enumeration Type Documentation

◆ packet_state

Enumerator
P_BEGIN 
P_MESSAGE 
P_STATUS 
P_DATA 
P_N 
P_DATA_N 
P_END 

Definition at line 51 of file lirc_client.c.

Function Documentation

◆ lirc_printf()

static void lirc_printf ( const struct lirc_state state,
const char *  format_str,
  ... 
)
static

◆ lirc_perror()

static void lirc_perror ( const struct lirc_state state,
const char *  s 
)
static

◆ lirc_readline()

static int lirc_readline ( const struct lirc_state state,
char **  line,
FILE *  f 
)
static

Definition at line 239 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ lirc_trim()

static char * lirc_trim ( char *  s)
static

Definition at line 283 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ lirc_parse_escape()

static char lirc_parse_escape ( const struct lirc_state state,
char **  s,
const char *  name,
int  line 
)
static

Definition at line 298 of file lirc_client.c.

Referenced by lirc_parse_string().

◆ lirc_parse_string()

static void lirc_parse_string ( const struct lirc_state state,
char *  s,
const char *  name,
int  line 
)
static

Definition at line 408 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ lirc_parse_include()

static void lirc_parse_include ( char *  s,
const char *  name,
int  line 
)
static

Definition at line 429 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ lirc_mode()

int lirc_mode ( const struct lirc_state state,
const char *  token,
const char *  token2,
char **  mode,
struct lirc_config_entry **  new_config,
struct lirc_config_entry **  first_config,
struct lirc_config_entry **  last_config,
int(check)(char *s)  ,
const char *  name,
int  line 
)
static

Definition at line 455 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ lirc_flags()

unsigned int lirc_flags ( const struct lirc_state state,
char *  string 
)
static

Definition at line 636 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ lirc_getfilename()

static char * lirc_getfilename ( const struct lirc_state state,
const char *  file,
const char *  current_file 
)
static

Definition at line 672 of file lirc_client.c.

Referenced by lirc_open().

◆ lirc_open()

static FILE * lirc_open ( const struct lirc_state state,
const char *  file,
const char *  current_file,
char **  full_name 
)
static

Definition at line 744 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ stack_push()

static struct filestack_t * stack_push ( const struct lirc_state state,
struct filestack_t parent 
)
static

Definition at line 800 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ stack_pop()

static struct filestack_t * stack_pop ( struct filestack_t entry)
static

Definition at line 815 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal(), and stack_free().

◆ stack_free()

static void stack_free ( struct filestack_t entry)
static

Definition at line 828 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ lirc_readconfig_only_internal()

static int lirc_readconfig_only_internal ( const struct lirc_state state,
const char *  file,
struct lirc_config **  config,
int(check)(char *s)  ,
char **  full_name,
char **  sha_bang 
)
static

Definition at line 951 of file lirc_client.c.

Referenced by lirc_readconfig(), and lirc_readconfig_only().

◆ lirc_startupmode()

static char * lirc_startupmode ( const struct lirc_state state,
struct lirc_config_entry first 
)
static

Definition at line 1353 of file lirc_client.c.

Referenced by lirc_readconfig_only_internal().

◆ lirc_freeconfigentries()

static void lirc_freeconfigentries ( struct lirc_config_entry first)
static

Definition at line 1417 of file lirc_client.c.

Referenced by lirc_freeconfig(), lirc_mode(), and lirc_readconfig_only_internal().

◆ lirc_clearmode()

static void lirc_clearmode ( struct lirc_config config)
static

Definition at line 1452 of file lirc_client.c.

Referenced by lirc_execute().

◆ lirc_execute()

static char * lirc_execute ( const struct lirc_state state,
struct lirc_config config,
struct lirc_config_entry scan 
)
static

Definition at line 1474 of file lirc_client.c.

Referenced by lirc_code2char_internal().

◆ lirc_iscode()

static int lirc_iscode ( struct lirc_config_entry scan,
char *  remote,
char *  button,
unsigned int  rep 
)
static

Definition at line 1514 of file lirc_client.c.

Referenced by lirc_code2char_internal().

◆ lirc_code2char_internal()

static int lirc_code2char_internal ( const struct lirc_state state,
struct lirc_config config,
char *  code,
char **  string,
char **  prog 
)
static

Definition at line 1678 of file lirc_client.c.

Referenced by lirc_code2char(), and lirc_code2charprog().

◆ lirc_read_string()

static const char * lirc_read_string ( const struct lirc_state state,
int  fd 
)
static

Definition at line 1904 of file lirc_client.c.

Referenced by lirc_send_command().

◆ lirc_identify()

int lirc_identify ( const struct lirc_state state,
int  sockfd 
)
static

Definition at line 2121 of file lirc_client.c.

Referenced by lirc_readconfig().

◆ lirc_send_command()

int lirc_send_command ( const struct lirc_state state,
int  sockfd,
const char *  command,
char *  buf,
size_t *  buf_len,
int *  ret_status 
)
static

Definition at line 1982 of file lirc_client.c.

Referenced by lirc_code2char(), lirc_getmode(), lirc_identify(), and lirc_setmode().

◆ lirc_init()

struct lirc_state* lirc_init ( const char *  lircrc_root_file,
const char *  lircrc_user_file,
const char *  prog,
const char *  lircd,
int  verbose 
)

Definition at line 134 of file lirc_client.c.

Referenced by LIRC::Init().

◆ lirc_deinit()

int lirc_deinit ( struct lirc_state state)

Definition at line 208 of file lirc_client.c.

Referenced by LIRC::Init(), lirc_init(), LIRC::run(), and LIRCPriv::~LIRCPriv().

◆ lirc_readconfig()

int lirc_readconfig ( const struct lirc_state state,
const char *  file,
struct lirc_config **  config,
int(check)(char *s)   
)

Definition at line 836 of file lirc_client.c.

Referenced by LIRC::Init().

◆ lirc_readconfig_only()

int lirc_readconfig_only ( const struct lirc_state state,
const char *  file,
struct lirc_config **  config,
int(check)(char *s)   
)

Definition at line 943 of file lirc_client.c.

◆ lirc_freeconfig()

void lirc_freeconfig ( struct lirc_config config)

Definition at line 1402 of file lirc_client.c.

Referenced by lirc_readconfig(), and LIRCPriv::~LIRCPriv().

◆ lirc_code2char()

int lirc_code2char ( const struct lirc_state state,
struct lirc_config config,
char *  code,
char **  string 
)

Definition at line 1632 of file lirc_client.c.

Referenced by LIRC::Process().

◆ lirc_code2charprog()

int lirc_code2charprog ( struct lirc_state state,
struct lirc_config config,
char *  code,
char **  string,
char **  prog 
)

Definition at line 1666 of file lirc_client.c.

◆ lirc_nextcode()

int lirc_nextcode ( struct lirc_state state,
char **  code 
)

Definition at line 1775 of file lirc_client.c.

◆ lirc_getsocketname()

size_t lirc_getsocketname ( const char *  filename,
char *  buf,
size_t  size 
)

Definition at line 1837 of file lirc_client.c.

Referenced by lirc_readconfig().

◆ lirc_getmode()

const char* lirc_getmode ( const struct lirc_state state,
struct lirc_config config 
)

Definition at line 1847 of file lirc_client.c.

◆ lirc_setmode()

const char* lirc_setmode ( const struct lirc_state state,
struct lirc_config config,
const char *  mode 
)

Definition at line 1870 of file lirc_client.c.