mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-25 03:32:16 +00:00
status handling update
This commit is contained in:
parent
915c5b7924
commit
6dfdb1f077
@ -38,7 +38,7 @@ BOOL SendCommand(char *buf)
|
|||||||
if (connect(fd, (struct sockaddr *)&server,
|
if (connect(fd, (struct sockaddr *)&server,
|
||||||
sizeof(struct sockaddr_in)) < 0) {
|
sizeof(struct sockaddr_in)) < 0) {
|
||||||
fprintf(stderr, "Error : Can't connect to rascsi process\n");
|
fprintf(stderr, "Error : Can't connect to rascsi process\n");
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the command
|
// Send the command
|
||||||
@ -46,8 +46,10 @@ BOOL SendCommand(char *buf)
|
|||||||
setvbuf(fp, NULL, _IONBF, 0);
|
setvbuf(fp, NULL, _IONBF, 0);
|
||||||
fputs(buf, fp);
|
fputs(buf, fp);
|
||||||
|
|
||||||
|
bool status = true;
|
||||||
|
|
||||||
// Receive the message
|
// Receive the message
|
||||||
while (true) {
|
while (status) {
|
||||||
int len;
|
int len;
|
||||||
size_t res = fread(&len, sizeof(int), 1, fp);
|
size_t res = fread(&len, sizeof(int), 1, fp);
|
||||||
if (res != 1) {
|
if (res != 1) {
|
||||||
@ -62,14 +64,10 @@ BOOL SendCommand(char *buf)
|
|||||||
rasctl_interface::CommandResult command_result;
|
rasctl_interface::CommandResult command_result;
|
||||||
command_result.ParseFromString(msg);
|
command_result.ParseFromString(msg);
|
||||||
|
|
||||||
cout << "Command terminated with status " << (command_result.status() ? "true" : "false") << ":" << endl;
|
if (!command_result.status()) {
|
||||||
cout << command_result.msg();
|
cout << command_result.msg();
|
||||||
|
|
||||||
if (command_result.status()) {
|
status = false;
|
||||||
fclose(fp);
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +75,7 @@ BOOL SendCommand(char *buf)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return TRUE;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user