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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 */ /* system includes */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -40,6 +40,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <signal.h> #include <signal.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/select.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/un.h> #include <sys/un.h>
@ -53,6 +54,7 @@ int main(argc, argv)
char *nl; char *nl;
char buff[1024]; char buff[1024];
struct sockaddr_un it; struct sockaddr_un it;
fd_set fds;
s = socket(AF_LOCAL, SOCK_STREAM, 0); s = socket(AF_LOCAL, SOCK_STREAM, 0);
strcpy(it.sun_path, DEFSOCK); strcpy(it.sun_path, DEFSOCK);
it.sun_family = AF_LOCAL; it.sun_family = AF_LOCAL;
@ -68,18 +70,33 @@ int main(argc, argv)
} }
#endif #endif
if(argc == 1) { if(argc == 1) {
while(!feof(stdin)) { for(;;) {
fputs("phonectl> ", stdout); FD_ZERO(&fds);
fgets(buff, 1024, stdin); FD_SET(fileno(stdin), &fds);
nl = strchr(buff, '\n'); FD_SET(s, &fds);
if(nl != NULL) *nl = '\0'; switch(select(s + 1, &fds, NULL, NULL, NULL)) {
if(strcmp(buff, "#quit#") == 0) { case -1:
close(s); perror("select");
return 0; exit(-1);
break;
default:
{
if(FD_ISSET(fileno(stdin), &fds)) {
fgets(buff, 1024, stdin);
nl = strchr(buff, '\n');
if(nl != NULL) *nl = '\0';
if(strcmp(buff, "#quit#") == 0) {
close(s);
return 0;
}
send(s, buff, strlen(buff) + 1, 0x0);
}
if(FD_ISSET(s, &fds)) {
recv(s, buff, sizeof(buff), 0x0);
fputs(buff, stdout);
}
}
} }
send(s, buff, strlen(buff) + 1, 0x0);
recv(s, buff, sizeof(buff), 0x0);
fputs(buff, stdout);
} }
} }
write(s, argv[1], strlen(argv[1]) + 1); write(s, argv[1], strlen(argv[1]) + 1);

View File

@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 */ /* system includes */
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -236,7 +236,6 @@ int dialogue_cb(fd, sck)
break; break;
default: default:
{ {
lprintf(debug, "Defaulted!");
if(FD_ISSET(s, &ex) != 0) { if(FD_ISSET(s, &ex) != 0) {
lprintf(debug, "Exceptional."); lprintf(debug, "Exceptional.");
return 0; return 0;
@ -248,7 +247,6 @@ int dialogue_cb(fd, sck)
return 0; return 0;
} }
rc = send(s, buffer, 1, 0x0); rc = send(s, buffer, 1, 0x0);
lprintf(debug, "rc=%d", rc);
if(rc == -1) { if(rc == -1) {
lprintf(error, "send(): %s", strerror(errno)); lprintf(error, "send(): %s", strerror(errno));
return 0; return 0;
@ -256,7 +254,6 @@ int dialogue_cb(fd, sck)
} }
if(FD_ISSET(s, &fds) != 0) { if(FD_ISSET(s, &fds) != 0) {
rc = recv(s, buffer, 1, 0x0); rc = recv(s, buffer, 1, 0x0);
lprintf(debug, "rcv=%d", rc);
if(rc == 0) { if(rc == 0) {
lprintf(debug, "Socket closed! Got zero!\n"); lprintf(debug, "Socket closed! Got zero!\n");
return 0; return 0;
@ -353,6 +350,7 @@ char *parse_command(cmd, cont, s)
RNF("500 OK: Handler tested.\n"); RNF("500 OK: Handler tested.\n");
} else if(CHK("mdlg")) { } else if(CHK("mdlg")) {
int rc; 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); rc = dialogue_with_modem(&dialogue_cb, (void*)s->fpo);
if(!rc) { if(!rc) {
return NULL; return NULL;