if (fputs("Content-Type: text/plain\n\n",stdout)==EOF || fflush(stdout))
syserror("write stdout");
if (dup2(1,2)<0) { perror("dup stdout to stderr"); exit(-1); }
if (fputs("Content-Type: text/plain\n\n",stdout)==EOF || fflush(stdout))
syserror("write stdout");
if (dup2(1,2)<0) { perror("dup stdout to stderr"); exit(-1); }
}
if (argc > MAX_ARGS) error("too many arguments");
pathi= getenv("PATH_INFO");
if (!pathi) error("PATH_INFO not found");
}
if (argc > MAX_ARGS) error("too many arguments");
pathi= getenv("PATH_INFO");
if (!pathi) error("PATH_INFO not found");
if (pathi[0] != '/' || pathi[1] != '~') error("PATH_INFO must start with /~");
slash2= strchr(pathi+2,'/'); if (!slash2) error("PATH_INFO must have more than one /");
usernamelen= slash2-(pathi+2);
if (usernamelen > MAX_USERNAME_LEN) error("PATH_INFO username too long");
username= xmalloc(usernamelen+1);
memcpy(username,pathi+2,usernamelen); username[usernamelen]= 0;
if (pathi[0] != '/' || pathi[1] != '~') error("PATH_INFO must start with /~");
slash2= strchr(pathi+2,'/'); if (!slash2) error("PATH_INFO must have more than one /");
usernamelen= slash2-(pathi+2);
if (usernamelen > MAX_USERNAME_LEN) error("PATH_INFO username too long");
username= xmalloc(usernamelen+1);
memcpy(username,pathi+2,usernamelen); username[usernamelen]= 0;
if (!isalpha(username[0])) error("username 1st character is not alphabetic");
xsetenv("PATH_INFO",slash2,1);
if (!isalpha(username[0])) error("username 1st character is not alphabetic");
xsetenv("PATH_INFO",slash2,1);
child= fork(); if (child==-1) syserror("fork");
if (child) {
rchild= waitpid(child,&status,0);
child= fork(); if (child==-1) syserror("fork");
if (child) {
rchild= waitpid(child,&status,0);