UNIX高级编程

源代码在线查看: request.c

软件大小: 286 K
上传用户: guigui2008q
关键词: UNIX 高级编程
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include	"opend.h"				#include									void				request(char *buf, int nread, int clifd, uid_t uid)				{					int		newfd;									if (buf[nread-1] != 0) {						sprintf(errmsg,						  "request from uid %d not null terminated: %*.*s\n",						  uid, nread, nread, buf);						send_err(clifd, -1, errmsg);						return;					}					log_msg("request: %s, from uid %d", buf, uid);									/* parse the arguments, set options */					if (buf_args(buf, cli_args) < 0) {						send_err(clifd, -1, errmsg);						log_msg(errmsg);						return;					}									if ((newfd = open(pathname, oflag)) < 0) {						sprintf(errmsg, "can't open %s: %s\n",						  pathname, strerror(errno));						send_err(clifd, -1, errmsg);						log_msg(errmsg);						return;					}									/* send the descriptor */					if (send_fd(clifd, newfd) < 0)						log_sys("send_fd error");					log_msg("sent fd %d over fd %d for %s", newfd, clifd, pathname);					close(newfd);		/* we're done with descriptor */				}							

相关资源