add ppr_process_readable
This commit is contained in:
parent
f921861976
commit
1baa36725d
3 changed files with 48 additions and 0 deletions
24
.clang-format
Normal file
24
.clang-format
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
UseTab: Always
|
||||
TabWidth: 8
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: true
|
||||
AccessModifierOffset: -4
|
||||
NamespaceIndentation: All
|
||||
IndentWidth: 8
|
||||
PointerAlignment: Left
|
||||
ColumnLimit: 0
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
SpaceBeforeParens: Never
|
||||
AlignEscapedNewlines: DontAlign
|
||||
SortIncludes: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
#IndentPPDirectives: AfterHash
|
||||
|
|
@ -210,6 +210,7 @@ void* ppr_process_create(const char* exec, char** env);
|
|||
void ppr_process_close(void* handle);
|
||||
int ppr_process_write(void* handle, const void* data, int len);
|
||||
int ppr_process_read(void* handle, void* data, int len);
|
||||
int ppr_process_readable(void* handle);
|
||||
void ppr_process_destroy(void* handle);
|
||||
|
||||
/* dirent.c */
|
||||
|
|
|
|||
|
|
@ -245,6 +245,29 @@ int ppr_process_read(void* handle, void* data, int len) {
|
|||
#endif
|
||||
}
|
||||
|
||||
int ppr_process_readable(void* handle) {
|
||||
process_t* proc = handle;
|
||||
#if defined(PPR_IS_WIN32)
|
||||
DWORD avail;
|
||||
|
||||
if(!PeekNamedPipe(proc->h_stdout, NULL, 0, NULL, &avail, NULL)) return 0;
|
||||
|
||||
return (avail > 0) ? 1 : 0;
|
||||
#elif defined(FPR_IS_UNIX)
|
||||
struct ppr_pollfd pfd;
|
||||
int n;
|
||||
|
||||
pfd.fd = proc->fd_stdout;
|
||||
pfd.events = FPR_POLLIN | FPR_POLLPRI;
|
||||
|
||||
if((n = ppr_poll(&pfd, 1, 0)) < 0) return 0;
|
||||
|
||||
return (n > 0) ? 1 : 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ppr_process_destroy(void* handle) {
|
||||
process_t* proc = handle;
|
||||
#if defined(PPR_IS_WIN32)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue