Skip to content

Instantly share code, notes, and snippets.

@tloriato
Created June 28, 2018 02:38
Show Gist options
  • Save tloriato/65f0024710947553ae16b63ae7699968 to your computer and use it in GitHub Desktop.
Save tloriato/65f0024710947553ae16b63ae7699968 to your computer and use it in GitHub Desktop.
if (WIFEXITED(status) != 0) {
int stat = WEXITSTATUS(status);
if(stat !=0)
{
memset(response,0,BUFSIZ);
if (buf[0] == 'D' && (buf[1] == 'C' || buf[1] == 'R')) {
int secondComma = 0;
for (int i = 0, j = 0; i < BUFSIZE || j < 2; i++) {
if (buf[i] == ',') {
j++;
if (j == 2) {
secondComma = i;
break;
}
}
}
memcpy(response, buf, secondComma + 2);
buf[secondComma+2] = '0';
buf[secondComma+3] = '\0';
}
else {
strcat(response, buf);
char nmbr[12];
sprintf(nmbr, "%d", stat);
response[5] = 'P';
strcat(response, " : error ");
strcat(response, nmbr);
response[strlen(response)] = '\0';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment