⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 support.c

📁 socket5 代理服务代码 socket5 代理服务代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    return((n < 1 || n > 12) ? name[0] : name[n]);}/*                                                                           *//*  * sindex - Find first instance of string 2 in string 1                   *//*  *                                                                        *//*  * SINDEX scans string 1 for the first instance of string                 *//*  * 2.  If found, SINDEX returns a pointer to the first                    *//*  * character of that instance.  If no instance is found,                  *//*  * SINDEX returns NULL (0).                                               *//*  *                                                                        *//*  * ARGS: s1 - string to be searched                                       *//*  * s2 - string to be found                                                *//*  * RETURNS: First instance of s2 in s1, or NULL (0) if not found          */char *sindex(s1,s2)    char	*s1;		/* String to be searched                     */    char	*s2;		/* String to be found                        */    {	register int s2len = strlen(s2);	char	*s = s1;	/* Temp pointer to string                    */	/* Check for first character of s2                                   */	while((s = (char *) index(s,*s2)) != NULL) {	    if(strncmp(s,s2,s2len) == 0)		return(s);	    s++;	}	/* We didn't find it                                                 */	return(NULL);    }intscan_error(erst)    char	*erst;    {	*p_err_string = '\0';	if(strncmp(erst,"NOT-A-DIRECTORY",15) == 0) 	    return(DIRSRV_NOT_DIRECTORY);	if(strncmp(erst,"UNIMPLEMENTED",13) == 0) {	    perrno = DIRSRV_UNIMPLEMENTED;	    sscanf(erst+13,"%*[^\n \t\r]%*[ \t]%[^\n]",p_err_string);	    return(perrno);	}	if(strncmp(erst,"WARNING ",8) == 0) {	    erst += 8;	    *p_warn_string = '\0';	    sscanf(erst,"%*[^\n \t\r]%*[ \t]%[^\n]",p_warn_string);	    /* Return values for warnings are negative */	    if(strncmp(erst,"OUT-OF-DATE",11) == 0) {		pwarn = PWARN_OUT_OF_DATE;		return(PSUCCESS);	    }	    if(strncmp(erst,"MESSAGE",7) == 0) {		pwarn = PWARN_MSG_FROM_SERVER;		return(PSUCCESS);	    }	    pwarn = PWARNING;	    sscanf(erst,"%[^\n]",p_warn_string);	    return(PSUCCESS);	}	else if(strncmp(erst,"ERROR",5) == 0) {	    if(*(erst+5)) sscanf(erst+6,"%[^\n]",p_err_string);	    perrno = DIRSRV_ERROR;	    return(perrno);	}	/* The rest start with "FAILURE" */	else if(strncmp(erst,"FAILURE",7) != 0) {	    /* Unrecognized - Give warning, but return PSUCCESS */	    if(pwarn == 0) {		*p_warn_string = '\0';		pwarn = PWARN_UNRECOGNIZED_RESP;		sscanf(erst,"%[^\n]",p_warn_string);	    }	    return(PSUCCESS);	}	if(strncmp(erst,"FAILURE ",8) != 0) {	    perrno = PFAILURE;	    return(perrno);	}		erst += 8;		sscanf(erst,"%*[^\n \t\r]%*[ \t]%[^\n]",p_err_string);	/* Still to add               */	/* DIRSRV_AUTHENT_REQ     242 */	/* DIRSRV_BAD_VERS        245 */	if(strncmp(erst,"NOT-FOUND",9) == 0) 	    perrno = DIRSRV_NOT_FOUND;	else if(strncmp(erst,"NOT-AUTHORIZED",13) == 0) 	    perrno = DIRSRV_NOT_AUTHORIZED;	else if(strncmp(erst,"ALREADY-EXISTS",14) == 0) 	    perrno = DIRSRV_ALREADY_EXISTS;	else if(strncmp(erst,"NAME-CONFLICT",13) == 0) 	    perrno = DIRSRV_NAME_CONFLICT;	else if(strncmp(erst,"SERVER-FAILED",13) == 0) 	    perrno = DIRSRV_SERVER_FAILED; 	/* Use it whether it starts with FAILURE or not */	else if(strncmp(erst,"NOT-A-DIRECTORY",15) == 0) 	    perrno = DIRSRV_NOT_DIRECTORY;	else perrno = PFAILURE;	return(perrno);    }PATTRIB parse_attribute(line)    char	*line;    {	char	l_precedence[MAX_DIR_LINESIZE];	char	l_name[MAX_DIR_LINESIZE];	char	l_type[MAX_DIR_LINESIZE];	char	l_value[MAX_DIR_LINESIZE];	PATTRIB	at;	int	tmp;	tmp = sscanf(line,"OBJECT-INFO %s %s %[^\n]", l_name, l_type, l_value);		if(tmp < 3) {	    tmp = sscanf(line,"LINK-INFO %s %s %s %[^\n]", l_precedence,			 l_name, l_type, l_value);	    if(tmp < 4) {		perrno = DIRSRV_BAD_FORMAT;		return(NULL);	    }	}	at = atalloc();	if(tmp == 4) {	    if(strcmp(l_precedence,"CACHED") == 0) 		at->precedence = ATR_PREC_CACHED;	    else if(strcmp(l_precedence,"LINK") == 0) 		at->precedence = ATR_PREC_LINK;	    else if(strcmp(l_precedence,"REPLACEMENT") == 0) 		at->precedence = ATR_PREC_REPLACE;	    else if(strcmp(l_precedence,"ADDITIONAL") == 0) 		at->precedence = ATR_PREC_ADD;	}	at->aname = stcopy(l_name);	at->avtype = stcopy(l_type);	if(strcmp(l_type,"ASCII") == 0) 	    at->value.ascii = stcopy(l_value);	else if(strcmp(l_type,"LINK") == 0) {	    char		ftype[MAX_DIR_LINESIZE];	    char		lname[MAX_DIR_LINESIZE];	    char		htype[MAX_DIR_LINESIZE];	    char		host[MAX_DIR_LINESIZE];	    char		ntype[MAX_DIR_LINESIZE];	    char		fname[MAX_DIR_LINESIZE];	    VLINK		al;	    al = vlalloc();	    at->value.link = al;	    tmp = sscanf(l_value,"%c %s %s %s %s %s %s %ld %ld",			 &(al->linktype),			 ftype,lname,htype,host,ntype,fname,			 &(al->version),			 &(al->f_magic_no));	    if(tmp == 9) {		al->type = stcopyr(ftype,al->type);		al->name = stcopyr(unquote(lname),al->name);		al->hosttype = stcopyr(htype,al->hosttype);		al->host = stcopyr(host,al->host);		al->nametype = stcopyr(ntype,al->nametype);		al->filename = stcopyr(fname,al->filename);	    }	    else {		perrno = DIRSRV_BAD_FORMAT;		return(NULL);	    }	    	}	return(at);    }/*                                                                           *//*  * nxtline - Find the next line in the string                             *//*  *                                                                        *//*  * NXTLINE takes a string and returns a pointer to                        *//*  * the character immediately following the next newline.                  *//*  *                                                                        *//*  * ARGS: s - string to be searched                                        *//*  *                                                                        *//*  * RETURNS: Next line or NULL (0) on failure                              */char *nxtline(s)    char	*s;		/* String to be searched */ {	s = (char *) index(s,'\n');	if(s) return(++s);	else return(NULL);    }/*                                                                           *//*  * unquote - unquote string if necessary                                  *//*  *                                                                        *//*  * UNQUOTE takes a string and unquotes it if it has been quoted.          *//*  *                                                                        *//*  * ARGS: s - string to be unquoted                                        *//*  *                                                                        *//*  * RETURNS: The original string.  If the string has been quoted, then the *//*  * result appears in static storage, and must be copied if                *//*  * it is to last beyond the next call to quote.                           *//*  *                                                                        */char *unquote(s)    char	*s;		/* String to be quoted */    {	static char	unquoted[200];	char		*c = unquoted;	if(*s != '\'') return(s);	s++;	/* This should really treat a quote followed by other */	/* than a quote or a null as an error                 */	while(*s) {	    if(*s == '\'') s++;	    if(*s) *c++ = *s++;	}	*c++ = '\0';	return(unquoted);    }#if defined(DEBUG) && !defined(HAVE_STRSPN)/* needed for -D option parsing                                              *//*                                                                           *//*  * strspn - Count initial characters from chrs in s                       *//*  *                                                                        *//*  * STRSPN counts the occurances of chacters from chrs                     *//*  * in the string s preceeding the first occurance of                      *//*  * a character not in s.                                                  *//*  *                                                                        *//*  * ARGS: s - string to be checked                                         *//*  * chrs - string of characters we are looking for                         *//*  *                                                                        *//*  * RETURNS: Count of initial characters from chrs in s                    */strspn(s,chrs)    char	*s;    /* String to search                         */    char	*chrs; /* String of characters we are looking for  */    {	char	*cp;   /* Pointer to the current character in chrs */	int	count; /* Count of characters seen so far          */		count = 0;	while(*s) {	    for(cp = chrs;*cp;cp++)		if(*cp == *s) {		    s++;		    count++;		    goto done;		}	    return(count);	done:	    ;	}	return(count);    }#endif#ifndef HAVE_GETENV/*                                                                           *//*  * Copyright (c) 1987 Regents of the University of California.            *//*  * All rights reserved.                                                   *//*  *                                                                        *//*  * Redistribution and use in source and binary forms are permitted        *//*  * provided that: (1) source distributions retain this entire copyright   *//*  * notice and comment, and (2) distributions including binaries display   *//*  * the following acknowledgement: ``This product includes software        *//*  * developed by the University of California, Berkeley and its            *//* contributors''                                                            *//*  * in the documentation or other materials provided with the distribution *//*  * and in all advertising materials mentioning features or use of this    *//*  * software. Neither the name of the University nor the names of its      *//*  * contributors may be used to endorse or promote products derived        *//*  * from this software without specific prior written permission.          *//*  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR         *//*  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED         *//*  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.    */#if defined(LIBC_SCCS) && !defined(lint)static char sccsid[] = "@(#)getenv.c	5.7 (Berkeley) 6/1/90";#endif /* LIBC_SCCS and not lint */#include <stdlib.h>#include <stddef.h>/*                                                                           *//*  * getenv --                                                              *//*  * Returns ptr to value associated with name, if any, else NULL.          */char *getenv(name)	const char *name;{	int offset;	char *_findenv();	return(_findenv(name, &offset));}/*                                                                           *//*  * _findenv --                                                            *//*  * Returns pointer to value associated with name, if any, else NULL.      *//*  * Sets offset to be the offset of the name/value combination in the      *//*  * environmental array, for use by setenv(3) and unsetenv(3).             *//*  * Explicitly removes '=' in argument name.                               *//*  *                                                                        *//*  * This routine *should* be a static; don't use it.                       */char *_findenv(name, offset)	register const char *name;	int *offset;{	extern char **environ;	register int len;	register const char *C;	register char **P;	for (C = name, len = 0; *C && *C != '='; ++C, ++len);	for (P = environ; *P; ++P)		if (!strncmp(*P, name, len))			if (*(C = *P + len) == '=') {				*offset = P - environ;				return(++C);			}	return(NULL);}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -