const char * dbio_read_string(void) { static Stream *str = 0; static char buffer[1024]; int len, used_stream = 0; if (str == 0) str = new_stream(1024); try_again: fgets(buffer, sizeof(buffer), input); len = strlen(buffer); if (len == sizeof(buffer) - 1 && buffer[len - 1] != '\n') { stream_add_string(str, buffer); used_stream = 1; goto try_again; } if (buffer[len - 1] == '\n') buffer[len - 1] = '\0'; if (used_stream) { stream_add_string(str, buffer); return reset_stream(str); } else return buffer; }
enum proto_accept_error proto_accept_connection(int listener_fd, int *read_fd, int *write_fd, const char **name) { int timeout = server_int_option("name_lookup_timeout", 5); int fd; struct sockaddr_in address; size_t addr_length = sizeof(address); static Stream *s = 0; if (!s) s = new_stream(100); fd = accept(listener_fd, (struct sockaddr *) &address, &addr_length); if (fd < 0) { if (errno == EMFILE) return PA_FULL; else { log_perror("Accepting new network connection"); return PA_OTHER; } } *read_fd = *write_fd = fd; stream_printf(s, "%s, port %d", lookup_name_from_addr(&address, timeout), (int) ntohs(address.sin_port)); *name = reset_stream(s); return PA_OKAY; }
/* Append type information. */ static const char * append_type(const char *str, var_type type) { static Stream *stream = NULL; if (NULL == stream) stream = new_stream(20); stream_add_string(stream, str); switch (type) { case TYPE_OBJ: stream_add_string(stream, "|obj"); break; case TYPE_INT: stream_add_string(stream, "|int"); break; case TYPE_FLOAT: stream_add_string(stream, "|float"); break; case TYPE_ERR: stream_add_string(stream, "|err"); break; case TYPE_STR: stream_add_string(stream, "|str"); break; default: panic("Unsupported type in append_type()"); } return reset_stream(stream); }
static void create_video_stream(struct ffmpeg_mux *ffm) { AVCodecContext *context; void *extradata = NULL; if (!new_stream(ffm, &ffm->video_stream, ffm->params.vcodec, &ffm->output->oformat->video_codec)) return; if (ffm->video_header.size) { extradata = av_memdup(ffm->video_header.data, ffm->video_header.size); } context = ffm->video_stream->codec; context->bit_rate = ffm->params.vbitrate * 1000; context->width = ffm->params.width; context->height = ffm->params.height; context->coded_width = ffm->params.width; context->coded_height = ffm->params.height; context->extradata = extradata; context->extradata_size = ffm->video_header.size; context->time_base = (AVRational){ffm->params.fps_den, ffm->params.fps_num}; ffm->video_stream->time_base = context->time_base; if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER) context->flags |= CODEC_FLAG_GLOBAL_HEADER; }
static stream_t *open_stream_plugin(const stream_info_t *sinfo, const char *filename, int mode, struct MPOpts *options, int *file_format, int *ret, char **redirected_url) { void* arg = NULL; stream_t* s; m_struct_t* desc = (m_struct_t*)sinfo->opts; // Parse options if(desc) { arg = m_struct_alloc(desc); if(sinfo->opts_url) { m_option_t url_opt = { "stream url", arg , CONF_TYPE_CUSTOM_URL, 0, 0 ,0, (void *)sinfo->opts }; if (m_option_parse(&url_opt, bstr("stream url"), bstr(filename), false, arg) < 0) { mp_tmsg(MSGT_OPEN,MSGL_ERR, "URL parsing failed on url %s\n",filename); m_struct_free(desc,arg); return NULL; } } } s = new_stream(-2,-2); s->opts = options; s->url=strdup(filename); s->flags |= mode; *ret = sinfo->open(s,mode,arg,file_format); if((*ret) != STREAM_OK) { #ifdef CONFIG_NETWORKING if (*ret == STREAM_REDIRECTED && redirected_url) { if (s->streaming_ctrl && s->streaming_ctrl->url && s->streaming_ctrl->url->url) *redirected_url = strdup(s->streaming_ctrl->url->url); else *redirected_url = NULL; } streaming_ctrl_free(s->streaming_ctrl); #endif free(s->url); free(s); return NULL; } if(s->type <= -2) mp_msg(MSGT_OPEN,MSGL_WARN, "Warning streams need a type !!!!\n"); if(s->flags & MP_STREAM_SEEK && !s->seek) s->flags &= ~MP_STREAM_SEEK; if(s->seek && !(s->flags & MP_STREAM_SEEK)) s->flags |= MP_STREAM_SEEK; s->mode = mode; mp_msg(MSGT_OPEN,MSGL_V, "STREAM: [%s] %s\n",sinfo->name,filename); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Description: %s\n",sinfo->info); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Author: %s\n", sinfo->author); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Comment: %s\n", sinfo->comment); return s; }
static const char * value_to_literal(Var v) { static Stream *s = NULL; if (!s) s = new_stream(100); unparse_value(s, v); return reset_stream(s); }
static nhandle * new_nhandle(int rfd, int wfd, const char *local_name, const char *remote_name, int outbound) { nhandle *h; static Stream *s = 0; if (s == 0) s = new_stream(100); if (!network_set_nonblocking(rfd) || (rfd != wfd && !network_set_nonblocking(wfd))) log_perror("Setting connection non-blocking"); h = (nhandle *)mymalloc(sizeof(nhandle), M_NETWORK); if (all_nhandles) all_nhandles->prev = &(h->next); h->next = all_nhandles; h->prev = &all_nhandles; all_nhandles = h; h->rfd = rfd; h->wfd = wfd; h->input = new_stream(100); h->last_input_was_CR = 0; h->input_suspended = 0; h->output_head = 0; h->output_tail = &(h->output_head); h->output_length = 0; h->output_lines_flushed = 0; h->outbound = outbound; h->binary = 0; h->excess_utf_count = 0; #if NETWORK_PROTOCOL == NP_TCP h->client_echo = 1; #endif stream_printf(s, "%s %s %s", local_name, outbound ? "to" : "from", remote_name); h->name = str_dup(reset_stream(s)); return h; }
enum error proto_make_listener(Var desc, int *fd, Var * canon, const char **name) { struct sockaddr_in address; int s, port, option = 1; static Stream *st = 0; if (!st) st = new_stream(20); if (desc.type != TYPE_INT) return E_TYPE; port = desc.v.num; s = socket(AF_INET, SOCK_STREAM, 0); if (s < 0) { log_perror("Creating listening socket"); return E_QUOTA; } if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &option, sizeof(option)) < 0) { log_perror("Setting listening socket options"); close(s); return E_QUOTA; } address.sin_family = AF_INET; address.sin_addr.s_addr = bind_local_ip; address.sin_port = htons(port); if (bind(s, (struct sockaddr *) &address, sizeof(address)) < 0) { enum error e = E_QUOTA; log_perror("Binding listening socket"); if (errno == EACCES) e = E_PERM; close(s); return e; } if (port == 0) { size_t length = sizeof(address); if (getsockname(s, (struct sockaddr *) &address, &length) < 0) { log_perror("Discovering local port number"); close(s); return E_QUOTA; } canon->type = TYPE_INT; canon->v.num = ntohs(address.sin_port); } else *canon = var_ref(desc); stream_printf(st, "port %d", canon->v.num); *name = reset_stream(st); *fd = s; return E_NONE; }
void add_a_stream (FILE *the_stream, int (*closing_action) (FILE *)) { stream_list old = the_streams; the_streams = new_stream (); the_streams->handle = the_stream; the_streams->action = closing_action; the_streams->rest_streams = old; return; }
stream_t* open_stream_plugin(stream_info_t* sinfo,char* filename,int mode, char** options, int* file_format, int* ret) { void* arg = NULL; stream_t* s; m_struct_t* desc = (m_struct_t*)sinfo->opts; // Parse options if(desc) { arg = m_struct_alloc(desc); if(sinfo->opts_url) { m_option_t url_opt = { "stream url", arg , CONF_TYPE_CUSTOM_URL, 0, 0 ,0, sinfo->opts }; if(m_option_parse(&url_opt,"stream url",filename,arg,M_CONFIG_FILE) < 0) { mp_msg(MSGT_OPEN,MSGL_ERR, "URL parsing failed on url %s\n",filename); m_struct_free(desc,arg); return NULL; } } if(options) { int i; for(i = 0 ; options[i] != NULL ; i += 2) { mp_msg(MSGT_OPEN,MSGL_DBG2, "Set stream arg %s=%s\n", options[i],options[i+1]); if(!m_struct_set(desc,arg,options[i],options[i+1])) mp_msg(MSGT_OPEN,MSGL_WARN, "Failed to set stream option %s=%s\n", options[i],options[i+1]); } } } s = new_stream(-2,-2); s->url=strdup(filename); s->flags |= mode; *ret = sinfo->open(s,mode,arg,file_format); if((*ret) != STREAM_OK) { free(s->url); free(s); return NULL; } if(s->type <= -2) mp_msg(MSGT_OPEN,MSGL_WARN, "Warning streams need a type !!!!\n"); if(s->flags & STREAM_SEEK && !s->seek) s->flags &= ~STREAM_SEEK; if(s->seek && !(s->flags & STREAM_SEEK)) s->flags |= STREAM_SEEK; s->mode = mode; mp_msg(MSGT_OPEN,MSGL_V, "STREAM: [%s] %s\n",sinfo->name,filename); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Description: %s\n",sinfo->info); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Author: %s\n", sinfo->author); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Comment: %s\n", sinfo->comment); return s; }
static stream_t *stream_hash_insert_conv( const struct conversation *conv, int p2p_dir ) { stream_key_t *key; key = g_mem_chunk_alloc(stream_keys); key->is_circuit = FALSE; key->circ.conv = conv; key->p2p_dir = p2p_dir; return new_stream(key); }
static stream_t *stream_hash_insert_conv( const struct conversation *conv, int p2p_dir ) { stream_key_t *key; key = wmem_new(wmem_file_scope(), stream_key_t); key->is_circuit = FALSE; key->circ.conv = conv; key->p2p_dir = p2p_dir; return new_stream(key); }
/* insert function */ static stream_t *stream_hash_insert_circ( const struct circuit *circuit, int p2p_dir ) { stream_key_t *key; key = g_mem_chunk_alloc(stream_keys); key->is_circuit = TRUE; key->circ.circuit = circuit; key->p2p_dir = p2p_dir; return new_stream(key); }
/* insert function */ static stream_t *stream_hash_insert_circ( const struct circuit *circuit, int p2p_dir ) { stream_key_t *key; key = wmem_new(wmem_file_scope(), stream_key_t); key->is_circuit = TRUE; key->circ.circuit = circuit; key->p2p_dir = p2p_dir; return new_stream(key); }
static const char * fmt_verb_name(void *data) { db_verb_handle *h = data; static Stream *s = 0; if (!s) s = new_stream(40); stream_printf(s, "#%d:%s", db_verb_definer(*h), db_verb_names(*h)); return reset_stream(s); }
global Cell * read_stream(Cell *cell) { long c; c = cell->c_file == stdin ? get_one_char() : GetChar(cell->c_file); if (c == EOF) { end_stream(cell->c_file); return new_cnst(nil); } return new_cons(cons, new_pair(new_char((Char)c), new_stream(cell->c_file))); }
static void xml_characterDataHandler(void *userData, const XML_Char *s, int len) { XMLdata **data = (XMLdata**)userData; XMLdata *node = *data; Stream *sp = node->body; if(sp == NULL) { node->body = new_stream(len); sp = node->body; } stream_add_string(sp, raw_bytes_to_binary(s, len)); }
static int set_output( int num_tokens, struct token *tokens, void *d ) { struct mpeg4_decoder *en = (struct mpeg4_decoder *)d; en->output = new_stream( tokens[1].v.str, FORMAT_RAW_UYVY, en ); if( ! en->output ) { spook_log( SL_ERR, "mpeg4: unable to create stream \"%s\"", tokens[1].v.str ); return -1; } en->output->get_framerate = get_framerate; en->output->set_running = set_running; return 0; }
static int set_output( int num_tokens, struct token *tokens, void *d ) { struct oss_input *conf = (struct oss_input *)d; conf->output = new_stream( tokens[1].v.str, FORMAT_PCM, conf ); if( ! conf->output ) { spook_log( SL_ERR, "oss: unable to create stream \"%s\"", tokens[1].v.str ); return -1; } conf->output->get_framerate = get_framerate; conf->output->set_running = set_running; return 0; }
enum proto_accept_error proto_accept_connection(int listener_fd, int *read_fd, int *write_fd, const char **name) { int timeout = server_int_option("name_lookup_timeout", 5); int fd; struct sockaddr_in *addr = (struct sockaddr_in *) call->addr.buf; static Stream *s = 0; if (!s) s = new_stream(100); fd = t_open((void *) "/dev/tcp", O_RDWR, 0); if (fd < 0) { if (t_errno == TSYSERR && errno == EMFILE) return PA_FULL; else { log_ti_error("Opening endpoint for new connection"); return PA_OTHER; } } if (t_bind(fd, 0, 0) < 0) { log_ti_error("Binding endpoint for new connection"); t_close(fd); return PA_OTHER; } if (t_listen(listener_fd, call) < 0) { log_ti_error("Accepting new network connection"); t_close(fd); return PA_OTHER; } if (t_accept(listener_fd, fd, call) < 0) { log_ti_error("Accepting new network connection"); t_close(fd); return PA_OTHER; } if (!set_rw_able(fd)) { t_close(fd); return PA_OTHER; } *read_fd = *write_fd = fd; stream_printf(s, "%s, port %d", lookup_name_from_addr(addr, timeout), (int) ntohs(addr->sin_port)); *name = reset_stream(s); return PA_OKAY; }
static int set_output( int num_tokens, struct token *tokens, void *d ) { struct dc1394_input *conf = (struct dc1394_input *)d; conf->cam[conf->cam_count].output = new_stream( tokens[1].v.str, FORMAT_RAW_UYVY, &conf->cam[conf->cam_count] ); if( ! conf->cam[conf->cam_count].output ) { spook_log( SL_ERR, "dc1394: unable to create stream \"%s\"", tokens[1].v.str ); return -1; } conf->cam[conf->cam_count].output->get_framerate = get_framerate; conf->cam[conf->cam_count].output->set_running = set_running; ++conf->cam_count; return 0; }
static int set_output(int num_tokens, struct token *tokens, void *d) { struct h264_encoder *en = (struct h264_encoder *)d; en->output = new_stream(tokens[1].v.str, FORMAT_H264, en); if (! en->output) { spook_log(SL_ERR, "h264: unable to create stream \"%s\"", tokens[1].v.str); return -1; } en->output->get_framerate = get_framerate; en->output->set_running = set_running; en->output->new_listener_notify = new_listener_coming; en->output->get_enc_pipe_num = get_h264_enc_pipe_num; return 0; }
void do_templates () { int i; GLOBAL = new_stream (); tpls = (Template**) alloca (c_nsym * sizeof (Template*)); for (i = 0; i < c_nsym; i++) tpls [i] = 0; pass (); for (i = 0; i < c_nsym; i++) if (tpls [i]) { free (tpls [i]->BODY); free (tpls [i]); } free (CODE); CODE = combine_output (GLOBAL); }
global Cell * open_stream(Cell *arg) { char shOut[20], *po; char filename[MAX_FILENAME]; FILE **fp; #if 0 if (restricted) error(EXECERR, "read function disabled"); #endif hope2c((Byte *)filename, MAX_FILENAME, arg); /* find a free slot in the stream table */ for (fp = str_table; *fp != NULL; fp++) { if (fp == &str_table[MAX_STREAMS]) error(EXECERR, "stream table full"); } if(!restricted && *filename=='!') { /* this filename is command to run */ strcpy(shOut,"/tmp/hopeXXXXXX"); mktemp(shOut); /* check for new line character */ po = strchr(filename,'\n'); if(po!=NULL) *po = 0; po = strchr(filename,'\r'); if(po!=NULL) *po = 0; /* send output to temporary file */ strcat(filename," >"); strcat(filename,shOut); system(&filename[1]); strcpy(filename,shOut); } /* try to open the file */ if ((*fp = fopen(filename, "r")) == NULL) error(EXECERR, "'%s': can't read file", filename); return new_stream(*fp); }
static int set_output( int num_tokens, struct token *tokens, void *d ) { struct framedropper *drop = (struct framedropper *)d; if( ! drop->input ) { spook_log( SL_ERR, "framedrop: input must be specified before output" ); return -1; } drop->output = new_stream( tokens[1].v.str, drop->input->stream->format, drop ); if( ! drop->output ) { spook_log( SL_ERR, "framedrop: unable to create stream \"%s\"", tokens[1].v.str ); return -1; } drop->output->get_framerate = get_framerate; drop->output->set_running = set_running; return 0; }
static void create_audio_stream(struct ffmpeg_mux *ffm, int idx) { AVCodecContext *context; AVStream *stream; void *extradata = NULL; if (!new_stream(ffm, &stream, ffm->params.acodec, &ffm->output->oformat->audio_codec)) return; ffm->audio_streams[idx] = stream; av_dict_set(&stream->metadata, "title", ffm->audio[idx].name, 0); stream->time_base = (AVRational){1, ffm->audio[idx].sample_rate}; if (ffm->audio_header[idx].size) { extradata = av_memdup(ffm->audio_header[idx].data, ffm->audio_header[idx].size); } context = stream->codec; context->bit_rate = ffm->audio[idx].abitrate * 1000; context->channels = ffm->audio[idx].channels; context->sample_rate = ffm->audio[idx].sample_rate; context->sample_fmt = AV_SAMPLE_FMT_S16; context->time_base = stream->time_base; context->extradata = extradata; context->extradata_size = ffm->audio_header[idx].size; context->channel_layout = av_get_default_channel_layout(context->channels); if (ffm->output->oformat->flags & AVFMT_GLOBALHEADER) context->flags |= CODEC_FLAG_GLOBAL_HEADER; ffm->num_audio_streams++; }
enum error proto_open_connection(Var arglist, int *read_fd, int *write_fd, const char **local_name, const char **remote_name) { /* These are `static' rather than `volatile' because I can't cope with * getting all those nasty little parameter-passing rules right. This * function isn't recursive anyway, so it doesn't matter. */ struct sockaddr_in rec_addr; struct t_bind received; static const char *host_name; static int port; static Timer_ID id; int fd, result; int timeout = server_int_option("name_lookup_timeout", 5); static struct sockaddr_in addr; static Stream *st1 = 0, *st2 = 0; if (!st1) { st1 = new_stream(20); st2 = new_stream(50); } if (arglist.v.list[0].v.num != 2) return E_ARGS; else if (arglist.v.list[1].type != TYPE_STR || arglist.v.list[2].type != TYPE_INT) return E_TYPE; host_name = arglist.v.list[1].v.str; port = arglist.v.list[2].v.num; addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = lookup_addr_from_name(host_name, timeout); if (addr.sin_addr.s_addr == 0) return E_INVARG; /* Cast to (void *) here to workaround const-less decls on some systems. */ fd = t_open((void *) "/dev/tcp", O_RDWR, 0); if (fd < 0) { if (t_errno != TSYSERR || errno != EMFILE) log_ti_error("Making endpoint in proto_open_connection"); return E_QUOTA; } received.addr.maxlen = sizeof(rec_addr); received.addr.len = sizeof(rec_addr); received.addr.buf = (void *) &rec_addr; if (t_bind(fd, 0, &received) < 0) { log_ti_error("Binding outbound endpoint"); t_close(fd); return E_QUOTA; } call->addr.maxlen = sizeof(addr); call->addr.len = sizeof(addr); call->addr.buf = (void *) &addr; TRY id = set_timer(server_int_option("outbound_connect_timeout", 5), timeout_proc, 0); result = t_connect(fd, call, 0); cancel_timer(id); EXCEPT(timeout_exception) result = -1; errno = ETIMEDOUT; t_errno = TSYSERR; reenable_timers(); ENDTRY if (result < 0) { t_close(fd); log_ti_error("Connecting in proto_open_connection"); return E_QUOTA; } if (!set_rw_able(fd)) { t_close(fd); return E_QUOTA; } *read_fd = *write_fd = fd; stream_printf(st1, "port %d", (int) ntohs(rec_addr.sin_port)); *local_name = reset_stream(st1); stream_printf(st2, "%s, port %d", host_name, port); *remote_name = reset_stream(st2); return E_NONE; }
static stream_t* open_stream_plugin(const stream_info_t* sinfo, const char* filename, int mode, char** options, int* file_format, int* ret, char** redirected_url) { void* arg = NULL; stream_t* s; m_struct_t* desc = (m_struct_t*)sinfo->opts; // Parse options if(desc) { arg = m_struct_alloc(desc); if(sinfo->opts_url) { m_option_t url_opt = { "stream url", arg , CONF_TYPE_CUSTOM_URL, 0, 0 ,0, sinfo->opts }; if(m_option_parse(&url_opt,"stream url",filename,arg,M_CONFIG_FILE) < 0) { mp_msg(MSGT_OPEN,MSGL_ERR, MSGTR_URLParsingFailed,filename); m_struct_free(desc,arg); return NULL; } } if(options) { int i; for(i = 0 ; options[i] != NULL ; i += 2) { mp_msg(MSGT_OPEN,MSGL_DBG2, "Set stream arg %s=%s\n", options[i],options[i+1]); if(!m_struct_set(desc,arg,options[i],options[i+1])) mp_msg(MSGT_OPEN,MSGL_WARN, MSGTR_FailedSetStreamOption, options[i],options[i+1]); } } } s = new_stream(-2,-2); s->capture_file = NULL; s->url=strdup(filename); s->flags |= mode; *ret = sinfo->open(s,mode,arg,file_format); if((*ret) != STREAM_OK) { #ifdef CONFIG_NETWORKING if (*ret == STREAM_REDIRECTED && redirected_url) { if (s->streaming_ctrl && s->streaming_ctrl->url && s->streaming_ctrl->url->url) *redirected_url = strdup(s->streaming_ctrl->url->url); else *redirected_url = NULL; } streaming_ctrl_free(s->streaming_ctrl); #endif free(s->url); free(s); return NULL; } if(s->type <= -2) mp_msg(MSGT_OPEN,MSGL_WARN, MSGTR_StreamNeedType); if(s->flags & MP_STREAM_SEEK && !s->seek) s->flags &= ~MP_STREAM_SEEK; if(s->seek && !(s->flags & MP_STREAM_SEEK)) s->flags |= MP_STREAM_SEEK; s->mode = mode; mp_msg(MSGT_OPEN,MSGL_V, "STREAM: [%s] %s\n",sinfo->name,filename); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Description: %s\n",sinfo->info); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Author: %s\n", sinfo->author); mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Comment: %s\n", sinfo->comment); return s; }
stream_t* new_ds_stream(demux_stream_t *ds) { stream_t* s = new_stream(-1,STREAMTYPE_DS); s->priv = ds; return s; }
enum error proto_make_listener(Var desc, int *fd, Var * canon, const char **name) { struct sockaddr_in req_addr, rec_addr; struct t_bind requested, received; int s, port; static Stream *st = 0; if (!st) st = new_stream(20); if (desc.type != TYPE_INT) return E_TYPE; port = desc.v.num; s = t_open((void *) "/dev/tcp", O_RDWR, 0); if (s < 0) { log_ti_error("Creating listening endpoint"); return E_QUOTA; } req_addr.sin_family = AF_INET; req_addr.sin_addr.s_addr = htonl(INADDR_ANY); req_addr.sin_port = htons(port); requested.addr.maxlen = sizeof(req_addr); requested.addr.len = sizeof(req_addr); requested.addr.buf = (void *) &req_addr; requested.qlen = 5; received.addr.maxlen = sizeof(rec_addr); received.addr.len = sizeof(rec_addr); received.addr.buf = (void *) &rec_addr; if (t_bind(s, &requested, &received) < 0) { enum error e = E_QUOTA; log_ti_error("Binding to listening address"); t_close(s); if (t_errno == TACCES || (t_errno == TSYSERR && errno == EACCES)) e = E_PERM; return e; } else if (port != 0 && rec_addr.sin_port != port) { errlog("Can't bind to requested port!\n"); t_close(s); return E_QUOTA; } if (!call) call = (struct t_call *) t_alloc(s, T_CALL, T_ADDR); if (!call) { log_ti_error("Allocating T_CALL structure"); t_close(s); return E_QUOTA; } canon->type = TYPE_INT; canon->v.num = ntohs(rec_addr.sin_port); stream_printf(st, "port %d", canon->v.num); *name = reset_stream(st); *fd = s; return E_NONE; }