mirror of
https://github.com/akuker/RASCSI.git
synced 2025-01-21 13:33:20 +00:00
Remove no-longer-used os.cpp
This commit is contained in:
parent
2579437b57
commit
da8880576a
@ -75,7 +75,6 @@ SRC_RASCSI = \
|
||||
gpiobus.cpp \
|
||||
filepath.cpp \
|
||||
fileio.cpp\
|
||||
os.cpp\
|
||||
rascsi_version.cpp
|
||||
# os.cpp
|
||||
# rasctl_command.cpp
|
||||
|
@ -1,63 +0,0 @@
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// SCSI Target Emulator RaSCSI (*^..^*)
|
||||
// for Raspberry Pi
|
||||
//
|
||||
// Powered by XM6 TypeG Technology.
|
||||
// Copyright (C) 2016-2020 GIMONS
|
||||
// Copyright (C) 2020-2021 akuker
|
||||
//
|
||||
// [ OS related definitions ]
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#include "os.h"
|
||||
#include "log.h"
|
||||
#include <sys/wait.h>
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Run system command and wait for it to finish
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
int run_system_cmd(const char* command)
|
||||
{
|
||||
pid_t pid;
|
||||
int result;
|
||||
int status = 0;
|
||||
pid=fork();
|
||||
if(pid == 0){
|
||||
result = system(command);
|
||||
exit(result);
|
||||
}
|
||||
waitpid(pid, &status, 0);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Run system command and save the output to a string
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
int run_system_cmd_with_output(const char* command, char* output_str, size_t max_size)
|
||||
{
|
||||
FILE *fp;
|
||||
char str_buff[1024];
|
||||
|
||||
fp = popen(command,"r");
|
||||
if(fp == NULL)
|
||||
{
|
||||
LOGWARN("%s Unable to run command %s", __PRETTY_FUNCTION__, command);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while((fgets(str_buff, sizeof(str_buff), fp) != NULL) && (strlen(output_str) < max_size))
|
||||
{
|
||||
strncat(output_str, str_buff, max_size);
|
||||
}
|
||||
|
||||
pclose(fp);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -155,11 +155,4 @@ typedef const char *LPCSTR;
|
||||
#define xstrcasecmp strcasecmp
|
||||
#define xstrncasecmp strncasecmp
|
||||
|
||||
// Run system command and wait for it to finish
|
||||
extern int run_system_cmd(const char* command);
|
||||
|
||||
// Run system command and wait for it to finish and keep the output
|
||||
extern int run_system_cmd_with_output(const char* command, char* output_str, size_t max_size);
|
||||
|
||||
|
||||
#endif // os_h
|
||||
|
Loading…
x
Reference in New Issue
Block a user