mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Re-name error macros and eliminate need for specifying empty parameters.
This commit is contained in:
parent
64dd6a5f3f
commit
63ad1a66d7
4
common.c
4
common.c
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: common.c,v 1.6 2007/10/20 23:16:28 ajhseppa Exp $
|
* $Id: common.c,v 1.7 2007/10/20 23:25:14 ajhseppa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vdr/i18n.h>
|
#include <vdr/i18n.h>
|
||||||
@ -55,7 +55,7 @@ int select_single_desc(int descriptor, const int usecs, const bool selectWrite)
|
|||||||
else
|
else
|
||||||
retval = select(descriptor + 1, &fds, NULL, NULL, &tv);
|
retval = select(descriptor + 1, &fds, NULL, NULL, &tv);
|
||||||
// Check if error
|
// Check if error
|
||||||
ERROR_IF(retval < 0, "select()", return retval);
|
ERROR_IF_RET(retval < 0, "select()", return retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
common.h
7
common.h
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: common.h,v 1.12 2007/10/20 23:16:28 ajhseppa Exp $
|
* $Id: common.h,v 1.13 2007/10/20 23:25:14 ajhseppa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __IPTV_COMMON_H
|
#ifndef __IPTV_COMMON_H
|
||||||
@ -39,7 +39,10 @@
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define ERROR_IF(exp, errstr, ret) ERROR_IF_FUNC(exp, errstr, ,ret);
|
|
||||||
|
#define ERROR_IF_RET(exp, errstr, ret) ERROR_IF_FUNC(exp, errstr, ,ret);
|
||||||
|
|
||||||
|
#define ERROR_IF(exp, errstr) ERROR_IF_FUNC(exp, errstr, , );
|
||||||
|
|
||||||
uint16_t ts_pid(const uint8_t *buf);
|
uint16_t ts_pid(const uint8_t *buf);
|
||||||
uint8_t payload(const uint8_t *tsp);
|
uint8_t payload(const uint8_t *tsp);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: protocolext.c,v 1.15 2007/10/20 23:16:28 ajhseppa Exp $
|
* $Id: protocolext.c,v 1.16 2007/10/20 23:25:14 ajhseppa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
@ -55,7 +55,7 @@ bool cIptvProtocolExt::OpenSocket(void)
|
|||||||
int yes = 1;
|
int yes = 1;
|
||||||
// Create socket
|
// Create socket
|
||||||
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
|
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
|
||||||
ERROR_IF(socketDesc < 0, "socket()", return false);
|
ERROR_IF_RET(socketDesc < 0, "socket()", return false);
|
||||||
// Make it use non-blocking I/O to avoid stuck read calls
|
// Make it use non-blocking I/O to avoid stuck read calls
|
||||||
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()", CloseSocket(), return false);
|
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()", CloseSocket(), return false);
|
||||||
// Allow multiple sockets to use the same PORT number
|
// Allow multiple sockets to use the same PORT number
|
||||||
@ -91,7 +91,7 @@ void cIptvProtocolExt::ExecuteCommand(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Let's fork
|
// Let's fork
|
||||||
ERROR_IF((pid = fork()) == -1, "fork()", return);
|
ERROR_IF_RET((pid = fork()) == -1, "fork()", return);
|
||||||
// Check if child process
|
// Check if child process
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
// Close all dup'ed filedescriptors
|
// Close all dup'ed filedescriptors
|
||||||
@ -125,7 +125,7 @@ void cIptvProtocolExt::TerminateCommand(void)
|
|||||||
bool waitOver = false;
|
bool waitOver = false;
|
||||||
// signal and wait for termination
|
// signal and wait for termination
|
||||||
int retval = kill(pid, SIGINT);
|
int retval = kill(pid, SIGINT);
|
||||||
ERROR_IF(retval < 0, "kill()", waitOver = true);
|
ERROR_IF_RET(retval < 0, "kill()", waitOver = true);
|
||||||
while (!waitOver) {
|
while (!waitOver) {
|
||||||
retval = 0;
|
retval = 0;
|
||||||
waitms += timeoutms;
|
waitms += timeoutms;
|
||||||
@ -137,7 +137,7 @@ void cIptvProtocolExt::TerminateCommand(void)
|
|||||||
memset(&waitStatus, '\0', sizeof(waitStatus));
|
memset(&waitStatus, '\0', sizeof(waitStatus));
|
||||||
// Wait for child termination
|
// Wait for child termination
|
||||||
retval = waitid(P_PID, pid, &waitStatus, (WNOHANG | WEXITED));
|
retval = waitid(P_PID, pid, &waitStatus, (WNOHANG | WEXITED));
|
||||||
ERROR_IF(retval < 0, "waitid()", waitOver = true);
|
ERROR_IF_RET(retval < 0, "waitid()", waitOver = true);
|
||||||
// These are the acceptable conditions under which child exit is
|
// These are the acceptable conditions under which child exit is
|
||||||
// regarded as successful
|
// regarded as successful
|
||||||
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pid) &&
|
if (!retval && waitStatus.si_pid && (waitStatus.si_pid == pid) &&
|
||||||
@ -176,7 +176,7 @@ int cIptvProtocolExt::Read(unsigned char* *BufferAddr)
|
|||||||
if (isActive)
|
if (isActive)
|
||||||
len = recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
|
len = recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
|
||||||
(struct sockaddr *)&sockAddr, &addrlen);
|
(struct sockaddr *)&sockAddr, &addrlen);
|
||||||
ERROR_IF(len < 0, "recvfrom()", return len);
|
ERROR_IF_RET(len < 0, "recvfrom()", return len);
|
||||||
if ((len > 0) && (readBuffer[0] == 0x47)) {
|
if ((len > 0) && (readBuffer[0] == 0x47)) {
|
||||||
// Set argument point to read buffer
|
// Set argument point to read buffer
|
||||||
*BufferAddr = &readBuffer[0];
|
*BufferAddr = &readBuffer[0];
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: protocolfile.c,v 1.13 2007/10/20 23:16:28 ajhseppa Exp $
|
* $Id: protocolfile.c,v 1.14 2007/10/20 23:25:14 ajhseppa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -44,7 +44,7 @@ bool cIptvProtocolFile::OpenFile(void)
|
|||||||
// Check that stream address is valid
|
// Check that stream address is valid
|
||||||
if (!isActive && !isempty(fileLocation)) {
|
if (!isActive && !isempty(fileLocation)) {
|
||||||
fileStream = fopen(fileLocation, "rb");
|
fileStream = fopen(fileLocation, "rb");
|
||||||
ERROR_IF(!fileStream || ferror(fileStream), "fopen()", return false);
|
ERROR_IF_RET(!fileStream || ferror(fileStream), "fopen()", return false);
|
||||||
// Update active flag
|
// Update active flag
|
||||||
isActive = true;
|
isActive = true;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: protocolhttp.c,v 1.16 2007/10/20 23:16:28 ajhseppa Exp $
|
* $Id: protocolhttp.c,v 1.17 2007/10/20 23:25:14 ajhseppa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -59,7 +59,7 @@ bool cIptvProtocolHttp::OpenSocket(const int Port)
|
|||||||
int yes = 1;
|
int yes = 1;
|
||||||
// Create socket
|
// Create socket
|
||||||
socketDesc = socket(PF_INET, SOCK_STREAM, 0);
|
socketDesc = socket(PF_INET, SOCK_STREAM, 0);
|
||||||
ERROR_IF(socketDesc < 0, "socket()", return false);
|
ERROR_IF_RET(socketDesc < 0, "socket()", return false);
|
||||||
// Make it use non-blocking I/O to avoid stuck read calls
|
// Make it use non-blocking I/O to avoid stuck read calls
|
||||||
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()", CloseSocket(), return false);
|
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()", CloseSocket(), return false);
|
||||||
// Allow multiple sockets to use the same PORT number
|
// Allow multiple sockets to use the same PORT number
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: protocoludp.c,v 1.17 2007/10/20 23:16:28 ajhseppa Exp $
|
* $Id: protocoludp.c,v 1.18 2007/10/20 23:25:14 ajhseppa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -56,7 +56,7 @@ bool cIptvProtocolUdp::OpenSocket(const int Port)
|
|||||||
int yes = 1;
|
int yes = 1;
|
||||||
// Create socket
|
// Create socket
|
||||||
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
|
socketDesc = socket(PF_INET, SOCK_DGRAM, 0);
|
||||||
ERROR_IF(socketDesc < 0, "socket()", return false);
|
ERROR_IF_RET(socketDesc < 0, "socket()", return false);
|
||||||
// Make it use non-blocking I/O to avoid stuck read calls
|
// Make it use non-blocking I/O to avoid stuck read calls
|
||||||
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()", CloseSocket(), return false);
|
ERROR_IF_FUNC(fcntl(socketDesc, F_SETFL, O_NONBLOCK), "fcntl()", CloseSocket(), return false);
|
||||||
// Allow multiple sockets to use the same PORT number
|
// Allow multiple sockets to use the same PORT number
|
||||||
@ -98,7 +98,7 @@ bool cIptvProtocolUdp::JoinMulticast(void)
|
|||||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||||
int err = setsockopt(socketDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
|
int err = setsockopt(socketDesc, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
|
||||||
sizeof(mreq));
|
sizeof(mreq));
|
||||||
ERROR_IF(err < 0, "setsockopt()", return false);
|
ERROR_IF_RET(err < 0, "setsockopt()", return false);
|
||||||
// Update multicasting flag
|
// Update multicasting flag
|
||||||
isActive = true;
|
isActive = true;
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ bool cIptvProtocolUdp::DropMulticast(void)
|
|||||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||||
int err = setsockopt(socketDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq,
|
int err = setsockopt(socketDesc, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq,
|
||||||
sizeof(mreq));
|
sizeof(mreq));
|
||||||
ERROR_IF(err < 0, "setsockopt()", return false);
|
ERROR_IF_RET(err < 0, "setsockopt()", return false);
|
||||||
// Update multicasting flag
|
// Update multicasting flag
|
||||||
isActive = false;
|
isActive = false;
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ int cIptvProtocolUdp::Read(unsigned char* *BufferAddr)
|
|||||||
if (isActive)
|
if (isActive)
|
||||||
len = recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
|
len = recvfrom(socketDesc, readBuffer, readBufferLen, MSG_DONTWAIT,
|
||||||
(struct sockaddr *)&sockAddr, &addrlen);
|
(struct sockaddr *)&sockAddr, &addrlen);
|
||||||
ERROR_IF(len < 0, "recvfrom()", return len);
|
ERROR_IF_RET(len < 0, "recvfrom()", return len);
|
||||||
if ((len > 0) && (readBuffer[0] == 0x47)) {
|
if ((len > 0) && (readBuffer[0] == 0x47)) {
|
||||||
// Set argument point to read buffer
|
// Set argument point to read buffer
|
||||||
*BufferAddr = &readBuffer[0];
|
*BufferAddr = &readBuffer[0];
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* See the README file for copyright information and how to reach the author.
|
* See the README file for copyright information and how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: sectionfilter.c,v 1.14 2007/10/20 23:16:28 ajhseppa Exp $
|
* $Id: sectionfilter.c,v 1.15 2007/10/20 23:25:14 ajhseppa Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sectionfilter.h"
|
#include "sectionfilter.h"
|
||||||
@ -56,7 +56,7 @@ cIptvSectionFilter::cIptvSectionFilter(int Index, int devInd,
|
|||||||
if (S_ISFIFO(sb.st_mode))
|
if (S_ISFIFO(sb.st_mode))
|
||||||
unlink(pipeName);
|
unlink(pipeName);
|
||||||
int err = mknod(pipeName, 0644 | S_IFIFO, 0);
|
int err = mknod(pipeName, 0644 | S_IFIFO, 0);
|
||||||
ERROR_IF(err < 0, "mknod()", return);
|
ERROR_IF_RET(err < 0, "mknod()", return);
|
||||||
|
|
||||||
// Create descriptors
|
// Create descriptors
|
||||||
fifoDescriptor = open(pipeName, O_RDWR | O_NONBLOCK);
|
fifoDescriptor = open(pipeName, O_RDWR | O_NONBLOCK);
|
||||||
@ -104,7 +104,7 @@ int cIptvSectionFilter::dmxdev_section_callback(const uint8_t *buffer1, size_t b
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
retval = write(fifoDescriptor, buffer1, buffer1_len);
|
retval = write(fifoDescriptor, buffer1, buffer1_len);
|
||||||
ERROR_IF(retval < 0, "write()", );
|
ERROR_IF(retval < 0, "write()");
|
||||||
// Update statistics
|
// Update statistics
|
||||||
AddStatistic(retval, 1);
|
AddStatistic(retval, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user