Register that shiat

This commit is contained in:
dcp1990 2005-06-26 16:22:54 +00:00
parent 3f7ad3efca
commit 300397b61e
3 changed files with 24 additions and 15 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/lib/sockstuff.c,v 1.4 2005/06/26 16:06:49 dcp1990 Exp $ */ /* $Amigan: phoned/lib/sockstuff.c,v 1.5 2005/06/26 16:22:54 dcp1990 Exp $ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -148,7 +148,8 @@ Tcl_ChannelType Udom_ChanType = {
Tcl_Channel Udom_CreateChannel(sockfile, mask) Tcl_Channel Udom_CreateChannel(interp, sockfile, mask)
Tcl_Interp *interp;
CONST char *sockfile; CONST char *sockfile;
int mask; int mask;
{ {
@ -162,6 +163,7 @@ Tcl_Channel Udom_CreateChannel(sockfile, mask)
them.sun_family = AF_LOCAL; them.sun_family = AF_LOCAL;
if(connect(s, (struct sockaddr *)&them, 1 + strlen(them.sun_path) + sizeof(them.sun_family)) == -1) { if(connect(s, (struct sockaddr *)&them, 1 + strlen(them.sun_path) + sizeof(them.sun_family)) == -1) {
ckfree((char*)cdt); ckfree((char*)cdt);
Tcl_SetResult(interp, strerror(errno), TCL_STATIC);
return NULL; return NULL;
} }
cdt->fd = s; cdt->fd = s;
@ -189,19 +191,20 @@ int Udom_Cmd (cdata, interp, argc, argv)
arg = Tcl_GetString(argv[a]); arg = Tcl_GetString(argv[a]);
if(*arg != '-') break; if(*arg != '-') break;
if(Tcl_GetIndexFromObj(interp, argv[a], udomopt, "option", TCL_EXACT, &optind) if(Tcl_GetIndexFromObj(interp, argv[a], udomopt, "option", TCL_EXACT, &optind)
!= TCL_OK) return TCL_ERROR; != TCL_OK) return mseterr("Getindex");
switch((enum udomopt)optind) { switch((enum udomopt)optind) {
case UDOM_FILE: case UDOM_FILE:
if(a >= argc) return mseterr("needs file!"); if(a >= argc) return mseterr("needs file!");
sfl = Tcl_GetString(argv[a]); sfl = Tcl_GetString(argv[a + 1]);
break; break;
default: default:
Tcl_Panic("udom: bad optind to opts"); Tcl_Panic("udom: bad optind to opts");
} }
} }
if(sfl == NULL) return mseterr("file argument REQUIRED."); if(sfl == NULL) return mseterr("file argument REQUIRED.");
res = Udom_CreateChannel(sfl, TCL_READABLE | TCL_WRITABLE); res = Udom_CreateChannel(interp, sfl, TCL_READABLE | TCL_WRITABLE);
if(res == NULL) return TCL_ERROR; if(res == NULL) return TCL_ERROR;
Tcl_RegisterChannel(interp, res);
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
Tcl_AppendResult(interp, Tcl_GetChannelName(res), (char*)NULL); Tcl_AppendResult(interp, Tcl_GetChannelName(res), (char*)NULL);
return TCL_OK; return TCL_OK;

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/lib/tcl/sockstuff.c,v 1.4 2005/06/26 16:06:49 dcp1990 Exp $ */ /* $Amigan: phoned/lib/tcl/sockstuff.c,v 1.5 2005/06/26 16:22:54 dcp1990 Exp $ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -148,7 +148,8 @@ Tcl_ChannelType Udom_ChanType = {
Tcl_Channel Udom_CreateChannel(sockfile, mask) Tcl_Channel Udom_CreateChannel(interp, sockfile, mask)
Tcl_Interp *interp;
CONST char *sockfile; CONST char *sockfile;
int mask; int mask;
{ {
@ -162,6 +163,7 @@ Tcl_Channel Udom_CreateChannel(sockfile, mask)
them.sun_family = AF_LOCAL; them.sun_family = AF_LOCAL;
if(connect(s, (struct sockaddr *)&them, 1 + strlen(them.sun_path) + sizeof(them.sun_family)) == -1) { if(connect(s, (struct sockaddr *)&them, 1 + strlen(them.sun_path) + sizeof(them.sun_family)) == -1) {
ckfree((char*)cdt); ckfree((char*)cdt);
Tcl_SetResult(interp, strerror(errno), TCL_STATIC);
return NULL; return NULL;
} }
cdt->fd = s; cdt->fd = s;
@ -189,19 +191,20 @@ int Udom_Cmd (cdata, interp, argc, argv)
arg = Tcl_GetString(argv[a]); arg = Tcl_GetString(argv[a]);
if(*arg != '-') break; if(*arg != '-') break;
if(Tcl_GetIndexFromObj(interp, argv[a], udomopt, "option", TCL_EXACT, &optind) if(Tcl_GetIndexFromObj(interp, argv[a], udomopt, "option", TCL_EXACT, &optind)
!= TCL_OK) return TCL_ERROR; != TCL_OK) return mseterr("Getindex");
switch((enum udomopt)optind) { switch((enum udomopt)optind) {
case UDOM_FILE: case UDOM_FILE:
if(a >= argc) return mseterr("needs file!"); if(a >= argc) return mseterr("needs file!");
sfl = Tcl_GetString(argv[a]); sfl = Tcl_GetString(argv[a + 1]);
break; break;
default: default:
Tcl_Panic("udom: bad optind to opts"); Tcl_Panic("udom: bad optind to opts");
} }
} }
if(sfl == NULL) return mseterr("file argument REQUIRED."); if(sfl == NULL) return mseterr("file argument REQUIRED.");
res = Udom_CreateChannel(sfl, TCL_READABLE | TCL_WRITABLE); res = Udom_CreateChannel(interp, sfl, TCL_READABLE | TCL_WRITABLE);
if(res == NULL) return TCL_ERROR; if(res == NULL) return TCL_ERROR;
Tcl_RegisterChannel(interp, res);
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
Tcl_AppendResult(interp, Tcl_GetChannelName(res), (char*)NULL); Tcl_AppendResult(interp, Tcl_GetChannelName(res), (char*)NULL);
return TCL_OK; return TCL_OK;

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/xfone/sockstuff.c,v 1.4 2005/06/26 16:06:49 dcp1990 Exp $ */ /* $Amigan: phoned/xfone/sockstuff.c,v 1.5 2005/06/26 16:22:54 dcp1990 Exp $ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
@ -148,7 +148,8 @@ Tcl_ChannelType Udom_ChanType = {
Tcl_Channel Udom_CreateChannel(sockfile, mask) Tcl_Channel Udom_CreateChannel(interp, sockfile, mask)
Tcl_Interp *interp;
CONST char *sockfile; CONST char *sockfile;
int mask; int mask;
{ {
@ -162,6 +163,7 @@ Tcl_Channel Udom_CreateChannel(sockfile, mask)
them.sun_family = AF_LOCAL; them.sun_family = AF_LOCAL;
if(connect(s, (struct sockaddr *)&them, 1 + strlen(them.sun_path) + sizeof(them.sun_family)) == -1) { if(connect(s, (struct sockaddr *)&them, 1 + strlen(them.sun_path) + sizeof(them.sun_family)) == -1) {
ckfree((char*)cdt); ckfree((char*)cdt);
Tcl_SetResult(interp, strerror(errno), TCL_STATIC);
return NULL; return NULL;
} }
cdt->fd = s; cdt->fd = s;
@ -189,19 +191,20 @@ int Udom_Cmd (cdata, interp, argc, argv)
arg = Tcl_GetString(argv[a]); arg = Tcl_GetString(argv[a]);
if(*arg != '-') break; if(*arg != '-') break;
if(Tcl_GetIndexFromObj(interp, argv[a], udomopt, "option", TCL_EXACT, &optind) if(Tcl_GetIndexFromObj(interp, argv[a], udomopt, "option", TCL_EXACT, &optind)
!= TCL_OK) return TCL_ERROR; != TCL_OK) return mseterr("Getindex");
switch((enum udomopt)optind) { switch((enum udomopt)optind) {
case UDOM_FILE: case UDOM_FILE:
if(a >= argc) return mseterr("needs file!"); if(a >= argc) return mseterr("needs file!");
sfl = Tcl_GetString(argv[a]); sfl = Tcl_GetString(argv[a + 1]);
break; break;
default: default:
Tcl_Panic("udom: bad optind to opts"); Tcl_Panic("udom: bad optind to opts");
} }
} }
if(sfl == NULL) return mseterr("file argument REQUIRED."); if(sfl == NULL) return mseterr("file argument REQUIRED.");
res = Udom_CreateChannel(sfl, TCL_READABLE | TCL_WRITABLE); res = Udom_CreateChannel(interp, sfl, TCL_READABLE | TCL_WRITABLE);
if(res == NULL) return TCL_ERROR; if(res == NULL) return TCL_ERROR;
Tcl_RegisterChannel(interp, res);
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
Tcl_AppendResult(interp, Tcl_GetChannelName(res), (char*)NULL); Tcl_AppendResult(interp, Tcl_GetChannelName(res), (char*)NULL);
return TCL_OK; return TCL_OK;