This commit is contained in:
dcp1990 2005-06-26 02:56:36 +00:00
parent 6e41a8cc5e
commit 94734280c6
2 changed files with 31 additions and 16 deletions

View File

@ -27,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* $Amigan: phoned/phonectl/phonectl.c,v 1.6 2005/06/25 02:43:54 dcp1990 Exp $ */
/* $Amigan: phoned/phonectl/phonectl.c,v 1.7 2005/06/26 02:56:36 dcp1990 Exp $ */
/* system includes */
#include <stdio.h>
#include <stdlib.h>
@ -40,6 +40,7 @@
#include <sys/types.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <sys/un.h>
@ -53,6 +54,7 @@ int main(argc, argv)
char *nl;
char buff[1024];
struct sockaddr_un it;
fd_set fds;
s = socket(AF_LOCAL, SOCK_STREAM, 0);
strcpy(it.sun_path, DEFSOCK);
it.sun_family = AF_LOCAL;
@ -68,8 +70,18 @@ int main(argc, argv)
}
#endif
if(argc == 1) {
while(!feof(stdin)) {
fputs("phonectl> ", stdout);
for(;;) {
FD_ZERO(&fds);
FD_SET(fileno(stdin), &fds);
FD_SET(s, &fds);
switch(select(s + 1, &fds, NULL, NULL, NULL)) {
case -1:
perror("select");
exit(-1);
break;
default:
{
if(FD_ISSET(fileno(stdin), &fds)) {
fgets(buff, 1024, stdin);
nl = strchr(buff, '\n');
if(nl != NULL) *nl = '\0';
@ -78,10 +90,15 @@ int main(argc, argv)
return 0;
}
send(s, buff, strlen(buff) + 1, 0x0);
}
if(FD_ISSET(s, &fds)) {
recv(s, buff, sizeof(buff), 0x0);
fputs(buff, stdout);
}
}
}
}
}
write(s, argv[1], strlen(argv[1]) + 1);
read(s, buff, sizeof buff);
fputs(buff, stdout);

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* $Amigan: phoned/phoned/remote.c,v 1.13 2005/06/25 02:43:54 dcp1990 Exp $ */
/* $Amigan: phoned/phoned/remote.c,v 1.14 2005/06/26 02:56:37 dcp1990 Exp $ */
/* system includes */
#include <string.h>
#include <stdio.h>
@ -236,7 +236,6 @@ int dialogue_cb(fd, sck)
break;
default:
{
lprintf(debug, "Defaulted!");
if(FD_ISSET(s, &ex) != 0) {
lprintf(debug, "Exceptional.");
return 0;
@ -248,7 +247,6 @@ int dialogue_cb(fd, sck)
return 0;
}
rc = send(s, buffer, 1, 0x0);
lprintf(debug, "rc=%d", rc);
if(rc == -1) {
lprintf(error, "send(): %s", strerror(errno));
return 0;
@ -256,7 +254,6 @@ int dialogue_cb(fd, sck)
}
if(FD_ISSET(s, &fds) != 0) {
rc = recv(s, buffer, 1, 0x0);
lprintf(debug, "rcv=%d", rc);
if(rc == 0) {
lprintf(debug, "Socket closed! Got zero!\n");
return 0;
@ -353,6 +350,7 @@ char *parse_command(cmd, cont, s)
RNF("500 OK: Handler tested.\n");
} else if(CHK("mdlg")) {
int rc;
write(s->fd, "500 OK: Entering dialogue...\n", sizeof("500 OK: Entering dialogue...\n"));
rc = dialogue_with_modem(&dialogue_cb, (void*)s->fpo);
if(!rc) {
return NULL;