Asterisk - The Open Source Telephony Project  18.5.0
Macros | Functions
rawplayer.c File Reference
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
Include dependency graph for rawplayer.c:

Go to the source code of this file.

Macros

#define BUFLEN   320
 

Functions

static int deliver_file (char *path, int fdout)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ BUFLEN

#define BUFLEN   320

Definition at line 10 of file rawplayer.c.

Referenced by deliver_file().

Function Documentation

◆ deliver_file()

static int deliver_file ( char *  path,
int  fdout 
)
static

Definition at line 17 of file rawplayer.c.

References buf, BUFLEN, and error().

Referenced by main().

17  {
18  int fd = 0, bytes = 0, error = 0;
19  short buf[BUFLEN];
20 
21  if ((fd = open(path,O_RDONLY))) {
22  while ((bytes=read(fd, buf, BUFLEN)) > 0) {
23  if(write(fdout, buf, bytes) < 0){
24  error = -2;
25  break;
26  }
27  }
28  if(fd)
29  close(fd);
30  } else
31  return -1;
32 
33  return error;
34 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define BUFLEN
Definition: rawplayer.c:10
int error(const char *format,...)
Definition: utils/frame.c:999

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 37 of file rawplayer.c.

References deliver_file().

37  {
38  int x = 0, fdout = 0;
39  fdout = fileno(stdout);
40  for (;;)
41  for (x = 1; x < argc ; x++) {
42  if(deliver_file(argv[x], fdout))
43  exit(1);
44  }
45 }
static int deliver_file(char *path, int fdout)
Definition: rawplayer.c:17