Doors....

This commit is contained in:
Andrew Pamment 2017-04-23 13:07:30 +10:00
parent 0e16613143
commit 5a507cc0e3

13
doors.c
View File

@ -186,6 +186,7 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
int g; int g;
char *ptr1; char *ptr1;
char *ptr2; char *ptr2;
char *ptr2p;
size_t ouc; size_t ouc;
size_t inc; size_t inc;
@ -319,15 +320,15 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
} }
ptr1 = outbuf; ptr1 = outbuf;
ptr2 = (char *)malloc((g + 1) * 2); ptr2 = (char *)malloc((g + 1) * 2);
ptr2p = ptr2;
memset(ptr2, 0, (g + 1) * 2); memset(ptr2, 0, (g + 1) * 2);
inc = g; inc = g;
ouc = g * 2; ouc = g * 2;
iconv(ic, &ptr1, &inc, &ptr2, &ouc); iconv(ic, &ptr1, &inc, &ptr2, &ouc);
ptr2 = ptr2 - (g * 2 - ouc); write(master, ptr2p, ptr2p - ptr2);
write(master, ptr2, strlen(ptr2));
free(ptr2); free(ptr2p);
iconv_close(ic); iconv_close(ic);
} }
} else if (FD_ISSET(master, &fdset)) { } else if (FD_ISSET(master, &fdset)) {
@ -354,15 +355,15 @@ void runexternal(struct user_record *user, char *cmd, int stdio, char *argv[], c
} }
ptr1 = outbuf; ptr1 = outbuf;
ptr2 = (char *)malloc((g + 1) * 2); ptr2 = (char *)malloc((g + 1) * 2);
ptr2p = ptr2;
memset(ptr2, 0, (g + 1) * 2); memset(ptr2, 0, (g + 1) * 2);
inc = g; inc = g;
ouc = g * 2; ouc = g * 2;
iconv(ic, &ptr1, &inc, &ptr2, &ouc); iconv(ic, &ptr1, &inc, &ptr2, &ouc);
ptr2 = ptr2 - (g * 2 - ouc); write(door_out, ptr2p, ptr2p - ptr2);
write(door_out, ptr2, strlen(ptr2));
free(ptr2); free(ptr2p);
iconv_close(ic); iconv_close(ic);
} }
} }