Lines Matching +defs:val +defs:sp
136 static int fdclose(Service_t *sp, register int fd)
140 if(sp->fd==fd)
141 sp->fd = -1;
147 if(sp->actionf)
148 (*sp->actionf)(sp, fd, 1);
157 Service_t *sp;
174 else if(sp = service_list[fd1])
176 fdclose(sp,fd1);
177 if(--sp->refcount==0)
178 nv_unset(sp->node);
186 Service_t * sp = service_list[fd];
187 if(fd==sp->fd) /* connection socket */
192 service_list[fd] = sp;
193 sp->refcount++;
197 if(sp->acceptf)
198 r = (*sp->acceptf)(sp,fd);
201 else if(sp->actionf)
204 r = (*sp->actionf)(sp, fd, 0);
205 service_list[fd] = sp;
273 void service_add(Service_t *sp)
278 service_list[sp->fd] = sp;
279 file_list[npoll++] = sp->fd;
282 static int Accept(register Service_t *sp, int accept_fd)
284 register Namval_t* nq = sp->disc[ACCEPT];
299 if (sh_fun(nq, sp->node, av))
310 static int Action(Service_t *sp, int fd, int close)
316 nq = sp->disc[CLOSE];
318 nq = sp->disc[ACTION];
327 r=sh_fun(nq, sp->node, av);
333 static int Error(Service_t *sp, int level, const char* arg, ...)
338 if(sp->node)
339 nv_unset(sp->node);
340 free((void*)sp);
348 register Service_t* sp = (Service_t*)fp;
359 action = sp->disc[i];
362 if (nq = sp->disc[i])
365 sp->disc[i] = action;
367 sp->disc[i] = 0;
375 static void putval(Namval_t* np, const char* val, int flag, Namfun_t* fp)
377 register Service_t* sp = (Service_t*)fp;
378 if (!val)
380 nv_putv(np, val, flag, fp);
381 if (!val)
386 if(service_list[i]==sp)
389 if(--sp->refcount<=0)
412 register Service_t* sp;
435 if (!(sp = newof(0, Service_t, 1, 0)))
437 sp->acceptf = Accept;
438 sp->actionf = Action;
439 sp->errorf = Error;
440 sp->refcount = 1;
441 sp->context = extra;
442 sp->node = 0;
443 sp->fun.disc = &servdisc;
446 free((void*)sp);
449 if((sp->fd = fcntl(fd, F_DUPFD, 10))>=10)
452 sp->fd = fd;
454 sp->node = np;
456 nv_stack(np, (Namfun_t*)sp);
457 service_add(sp);