OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
sys_pipes_c.c File Reference
#include "hardware.inc"
#include "pipes_c.inc"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/signal.h>
#include <signal.h>
#include <errno.h>
#include <time.h>

Go to the source code of this file.

Macros

#define _FCALL

Functions

void syserr (char *msg)
void syserr_fatal (char *msg)
void fatal (char *msg)
int readr (int pipe, char *buf, int nbytes)
int writer (int pipe, char *buf, int nbytes)

Macro Definition Documentation

◆ _FCALL

#define _FCALL

Definition at line 57 of file sys_pipes_c.c.

Function Documentation

◆ fatal()

void fatal ( char * msg)

Definition at line 76 of file sys_pipes_c.c.

77{
78 fprintf(stderr,"%s\n", msg);
79 exit(1);
80}

◆ readr()

int readr ( int pipe,
char * buf,
int nbytes )

Definition at line 86 of file sys_pipes_c.c.

88{
89int error;
90
91#ifdef _WIN64
92BOOL fSuccess;
93unsigned long ncount,done;
94#else
95int ncount,done;
96#endif
97 ncount = nbytes;
98 while (ncount > 0)
99 {
100#ifdef _WIN64
101 fSuccess = ReadFile(pipe,buf,ncount*sizeof(TCHAR),&done,NULL);
102 if ( ! fSuccess)
103 {error = GetLastError(); done = -1;
104 if ((error == 109)||(error == 232)) printf("\nERROR Broken pipe\n\n");}
105#elif 1
106 done = read(pipe, buf, ncount);
107#endif
108 if (done < 0)
109 fatal("Failed reading fifo");
110 else if (done == 0)
111 break;
112 ncount -= done;
113 buf += done;
114 }
115 return 1;
116}
real(dp), parameter done
void fatal(char *msg)
Definition sys_pipes_c.c:76

◆ syserr()

void syserr ( char * msg)

Definition at line 63 of file sys_pipes_c.c.

64{
65 fprintf(stderr,"SYSTEM ERROR>> ");
66 perror(msg);
67}

◆ syserr_fatal()

void syserr_fatal ( char * msg)

Definition at line 69 of file sys_pipes_c.c.

70{
71 fprintf(stderr,"SYSTEM ERROR>> ");
72 perror(msg);
73 exit(1);
74}

◆ writer()

int writer ( int pipe,
char * buf,
int nbytes )

Definition at line 122 of file sys_pipes_c.c.

124{
125int error;
126#ifdef _WIN64
127BOOL fSuccess;
128unsigned long ncount,done;
129#else
130int ncount,done;
131#endif
132
133 ncount = nbytes;
134 while (ncount > 0)
135 {
136#ifdef _WIN64
137 fSuccess = WriteFile(pipe,buf,ncount*sizeof(TCHAR),&done,NULL);
138 if ( ! fSuccess)
139 {error = GetLastError(); done = -1;
140 if ((error == 109)||(error == 232)) printf("\nERROR Broken pipe\n\n");}
141#elif 1
142 done = write(pipe, buf, ncount);
143#endif
144 if (done < 0)
145 fatal("Failed writing fifo");
146 ncount -= done;
147 buf += done;
148 }
149 return 1;
150}