/*-----------------------------------------------------------------------+*/ static SbInputId SPC_RemoveInput(int source, SPC_Callback_Condition condition) /*-----------------------------------------------------------------------+*/ { SPC_Callback_Struct *structptr = NULL; _DtSvcProcessLock(); if (SPC_Fd_Mapping == NULL) { SPC_Fd_Mapping = (SPC_Callback_Struct **) XeMalloc (FD_SETSIZE * sizeof (SPC_Callback_Struct *)); memset(SPC_Fd_Mapping, 0, FD_SETSIZE * sizeof(SPC_Callback_Struct *)); } structptr=SPC_LOOKUP_FD_MAPPING(source); _DtSvcProcessUnlock(); switch(condition) { case SPC_Input: case SPC_Terminator: case SPC_Client: return structptr->read_id; case SPC_Exception: return structptr->except_id; } return 0; }
/*----------------------------------------------------------------------+*/ object *alloc_channel_object(object_clasp c) /*----------------------------------------------------------------------+*/ { object *p=(object *) XeMalloc((unsigned) c->object_size); memset(p, 0, (int) c->object_size); return(p); }
/*----------------------------------------------------------------------+*/ Wire *get_new_wire(void) /*----------------------------------------------------------------------+*/ { Wire *tmp_wire; tmp_wire=(Wire *)XeMalloc(sizeof(Wire)); memset(tmp_wire, NULL, sizeof(Wire)); tmp_wire->master_name=(XeString)XeMalloc(PTY_NAMLEN); memset(tmp_wire->master_name, NULL, PTY_NAMLEN); tmp_wire->slave_name =(XeString)XeMalloc(PTY_NAMLEN); memset(tmp_wire->slave_name, NULL, PTY_NAMLEN); tmp_wire->fd[0] = tmp_wire->fd[1] = (-1); tmp_wire->read_toolkit_id = (-1); tmp_wire->except_toolkit_id = (-1); return(tmp_wire); }
/*----------------------------------------------------------------------+*/ buffered_data_ptr SPC_New_Buffered_Data_Ptr(void) /*----------------------------------------------------------------------+*/ { buffered_data_ptr bdata; bdata=(buffered_data_ptr)XeMalloc(sizeof(buffered_data)); bdata->len = bdata->offset = 0; return(bdata); }
XeString *Alloc_Argv(int n) { /* Allocate an array to hold argv list */ XeString *av; av = (XeString *)XeMalloc((n + 1) * sizeof(XeString)); /* Zero the space so we don't have to worry about trailing NULL */ memset((XeString) av, NULL, (n + 1) * sizeof(XeString)); return(av); }
/*-----------------------------------------------------------------------+*/ static int SPC_AddInput(int source, SPC_Callback_Condition condition, SbInputId id) /*-----------------------------------------------------------------------+*/ { SPC_Callback_Struct *structptr = NULL; _DtSvcProcessLock(); if (SPC_Fd_Mapping == NULL) { SPC_Fd_Mapping = (SPC_Callback_Struct **) XeMalloc (FD_SETSIZE * sizeof (SPC_Callback_Struct *)); memset(SPC_Fd_Mapping, 0, FD_SETSIZE * sizeof(SPC_Callback_Struct *)); } structptr=SPC_LOOKUP_FD_MAPPING(source); if(!structptr) { structptr=(SPC_Callback_Struct *) XeMalloc(sizeof(SPC_Callback_Struct)); SPC_LOOKUP_FD_MAPPING(source)=structptr; } _DtSvcProcessUnlock(); switch (condition) { case SPC_Input: case SPC_Terminator: case SPC_Client: structptr->read_id = id; break; case SPC_Exception: structptr->except_id = id; break; default: break; } return(source); }
/*----------------------------------------------------------------------+*/ SPC_Connection_Ptr SPC_Alloc_Connection(void) /*----------------------------------------------------------------------+*/ { SPC_Connection_Ptr conn; _DtSvcProcessLock(); conn=(SPC_Connection_Ptr) XeMalloc(sizeof(SPC_Connection)); /* Zero the connection */ memset(conn, 0, sizeof(SPC_Connection)); conn->queued_remote_data = Xe_make_queue(FALSE); conn->termination_id = (-1); /* Init the socket id to "-1" because "0" is a valid file descriptor. */ conn->sid = (-1); _DtSvcProcessUnlock(); return(conn); }
/*----------------------------------------------------------------------+*/ protocol_request_ptr SPC_New_Protocol_Ptr (SPC_Channel_Ptr channel, XeChar req, int len) /*----------------------------------------------------------------------+*/ { protocol_request_ptr prot; _DtSvcProcessLock(); if(free_protocol_requests) { prot = free_protocol_requests; free_protocol_requests = free_protocol_requests->next; } else { prot = (protocol_request_ptr)XeMalloc(sizeof(protocol_request)); prot->dataptr = SPC_New_Buffered_Data_Ptr(); } SPC_Reset_Protocol_Ptr(prot, channel, req, len); _DtSvcProcessUnlock(); return(prot); }
/*----------------------------------------------------------------------+*/ int SPC_Initialize(void) /*----------------------------------------------------------------------+*/ { XeString home; _DtSvcProcessLock(); if(SPC_Initialized) { _DtSvcProcessUnlock(); return(TRUE); } spc_init_fds(); if (!SPC_ResetTerminator()) { _DtSvcProcessUnlock(); return(SPC_ERROR); } if(!SPC_Init_Local_Host_Info()) { _DtSvcProcessUnlock(); return(SPC_ERROR); } if(SPC_Setup_Synchronous_Terminator()==SPC_ERROR) { _DtSvcProcessUnlock(); return(SPC_ERROR); } if(home=getenv("HOME")) { spc_user_environment_file=(XeString) XeMalloc(strlen(home)+ strlen(SPCD_ENV_HOME_DIRECTORY)+strlen(SPCD_ENV_FILE)+3); sprintf(spc_user_environment_file, "%s/%s/%s", home, SPCD_ENV_HOME_DIRECTORY, SPCD_ENV_FILE); } SPC_Initialized=TRUE; _DtSvcProcessUnlock(); return(TRUE); }