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

📄 links.h

📁 this is the file used to browse web
💻 H
📖 第 1 页 / 共 4 页
字号:
#ifndef __EXTENSIONS__#define __EXTENSIONS__#endif#ifndef _LARGEFILE_SOURCE#define _LARGEFILE_SOURCE	1#endif#ifndef _FILE_OFFSET_BITS#define _FILE_OFFSET_BITS	64#endif#ifdef HAVE_CONFIG_H#include "config.h"#endif#ifdef HAVE_CONFIG2_H#include "config2.h"#endif#include "os_dep.h"#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#ifdef HAVE_UNISTD_H#include <unistd.h>#endif#include <string.h>#include <errno.h>#ifdef HAVE_LIMITS_H#include <limits.h>#endif#include <sys/types.h>#ifdef TIME_WITH_SYS_TIME#ifdef HAVE_SYS_TIME_H#include <sys/time.h>#endif#ifdef HAVE_TIME_H#include <time.h>#endif#else#if defined(TM_IN_SYS_TIME) && defined(HAVE_SYS_TIME_H)#include <sys/time.h>#elif defined(HAVE_TIME_H)#include <time.h>#endif#endif#include <sys/stat.h>#ifdef HAVE_FCNTL_H#include <fcntl.h>#endif#ifdef HAVE_DIRENT_H#include <dirent.h>#endif#include <signal.h>/*#ifdef HAVE_SIGACTION_H#include <sigaction.h>#endif*/#ifdef HAVE_SYS_WAIT_H#include <sys/wait.h>#endif#ifdef HAVE_SYS_SELECT_H#include <sys/select.h>#endif#ifdef HAVE_SYS_RESOURCE_H#include <sys/resource.h>#endif#ifdef HAVE_SYS_CYGWIN_H#include <sys/cygwin.h>#endif#ifdef HAVE_IO_H#include <io.h>#endif#ifdef HAVE_SYS_UTSNAME_H#include <sys/utsname.h>#endif/*#ifdef HAVE_WAIT_H#include <wait.h>#endif*/#ifdef HAVE_NETINET_IN_SYSTM_H#include <netinet/in_systm.h>#else#ifdef HAVE_NETINET_IN_SYSTEM_H#include <netinet/in_system.h>#endif#endif#include <netdb.h>#include <sys/socket.h>#include <netinet/in.h>#ifdef HAVE_NETINET_IP_H#include <netinet/ip.h>#endif#include <utime.h>#include <termios.h>#ifdef HAVE_LONG_LONG#define longlong long long#else#define longlong double#endif#ifndef HAVE_SOCKLEN_T#define socklen_t int#endif#ifndef PF_INET#define PF_INET AF_INET#endif#ifndef PF_UNIX#define PF_UNIX AF_UNIX#endif#ifdef HAVE_SSL#include <openssl/ssl.h>#include <openssl/rand.h>#endif#include "os_depx.h"#include "setup.h"#define LINKS_COPYRIGHT "(C) 1999 - 2008 Mikulas Patocka"#define LINKS_COPYRIGHT_8859_1 "(C) 1999 - 2008 Mikul醩 Patocka"#define LINKS_COPYRIGHT_8859_2 "(C) 1999 - 2008 Mikul峁 Pato鑛a"#define DUMMY ((void *)-1L)#define RET_OK		0#define RET_ERROR	1#define RET_SIGNAL	2#define RET_SYNTAX	3#define RET_FATAL	4#ifndef HAVE_MEMMOVEvoid *memmove(void *, const void *, size_t);#endif#ifndef HAVE_RAISEint raise(int);#endif#ifndef HAVE_STRTOULunsigned long strtoul(const char *, char **, int);#endif#ifndef HAVE_STRERRORchar *strerror(int);#endif#ifndef HAVE_GETTIMEOFDAYstruct timeval {	long tv_sec;	long tv_usec;};struct timezone {	int tz_minuteswest;	int tz_dsttime;};int gettimeofday(struct timeval *tv, struct timezone *tz);#endif#ifndef HAVE_STRCSPNsize_t strcspn(const char *s, const char *reject);#endif#ifndef HAVE_STRSTRchar *strstr(const char *haystack, const char *needle);#endif#ifndef HAVE_TEMPNAMchar *tempnam(const char *dir, const char *pfx);#endif#define option option_dirty_workaround_for_name_clash_with_include_on_cygwin#define table table_dirty_workaround_for_name_clash_with_libraries_on_macos#define scroll scroll_dirty_workaround_for_name_clash_with_libraries_on_macos/* error.c */void do_not_optimize_here(void *p);void check_memory_leaks();void error(unsigned char *, ...);void debug_msg(unsigned char *, ...);void int_error(unsigned char *, ...);extern int errline;extern unsigned char *errfile;#define internal while (1) errfile = __FILE__, errline = __LINE__, int_error#define debug errfile = __FILE__, errline = __LINE__, debug_msg#ifdef SPECIAL_MALLOCvoid *sp_malloc(size_t);void sp_free(void *);void *sp_realloc(void *, size_t);#define xmalloc sp_malloc#define xfree sp_free#define xrealloc sp_realloc#else#define xmalloc malloc#define xfree free#define xrealloc realloc#endif/* inline */void fatal_tty_exit(void);#ifdef LEAK_DEBUGextern long mem_amount;extern long last_mem_amount;#ifndef LEAK_DEBUG_LISTstruct alloc_header {	int size;};#elsestruct alloc_header {	struct alloc_header *next;	struct alloc_header *prev;	int size;	int line;	unsigned char *file;	unsigned char *comment;};#endif#define L_D_S ((sizeof(struct alloc_header) + 7) & ~7)#endif#define overalloc()							\do {									\	error("ERROR: attempting to allocate too large block at %s:%d", __FILE__, __LINE__);\	fatal_tty_exit();						\	exit(RET_FATAL);						\} while (1)	/* while (1) is not a type --- it's here to allow the	compiler that doesn't know that exit doesn't return to do better	optimizations */#ifdef LEAK_DEBUGvoid *debug_mem_alloc(unsigned char *, int, size_t);void debug_mem_free(unsigned char *, int, void *);void *debug_mem_realloc(unsigned char *, int, void *, size_t);void set_mem_comment(void *, unsigned char *, int);#define mem_alloc(x) debug_mem_alloc(__FILE__, __LINE__, x)#define mem_free(x) debug_mem_free(__FILE__, __LINE__, x)#define mem_realloc(x, y) debug_mem_realloc(__FILE__, __LINE__, x, y)#elsestatic inline void *mem_alloc(size_t size){	void *p;	if (!size) return DUMMY;	if (size > MAXINT) overalloc();	if (!(p = malloc(size))) {		error("ERROR: out of memory (malloc returned NULL)");		fatal_tty_exit();		exit(RET_FATAL);		return NULL;	}	return p;}static inline void mem_free(void *p){	if (p == DUMMY) return;	if (!p) {		internal("mem_free(NULL)");		return;	}	free(p);}static inline void *mem_realloc(void *p, size_t size){	if (p == DUMMY) return mem_alloc(size);	if (!p) {		internal("mem_realloc(NULL, %d)", size);		return NULL;	}	if (!size) {		mem_free(p);		return DUMMY;	}	if (size > MAXINT) overalloc();	if (!(p = realloc(p, size))) {		error("ERROR: out of memory (realloc returned NULL)");		fatal_tty_exit();		exit(RET_FATAL);		return NULL;	}	return p;}static inline void *debug_mem_alloc(unsigned char *f, int l, size_t s) { return mem_alloc(s); }static inline void debug_mem_free(unsigned char *f, int l, void *p) { mem_free(p); }static inline void *debug_mem_realloc(unsigned char *f, int l, void *p, size_t s) { return mem_realloc(p, s); }static inline void set_mem_comment(void *p, unsigned char *c, int l) {}#endifstatic inline unsigned char upcase(unsigned char a){	if (a>='a' && a<='z') a -= 0x20;	return a;}static inline int xstrcmp(unsigned char *s1, unsigned char *s2){        if (!s1 && !s2) return 0;        if (!s1) return -1;        if (!s2) return 1;        return strcmp(s1, s2);}static inline int cmpbeg(unsigned char *str, unsigned char *b){	while (*str && upcase(*str) == upcase(*b)) str++, b++;	return !!*b;}#if !(defined(LEAK_DEBUG) && defined(LEAK_DEBUG_LIST))static inline unsigned char *memacpy(const unsigned char *src, int len){	unsigned char *m;	m = mem_alloc(len + 1);	memcpy(m, src, len);	m[len] = 0;	return m;}static inline unsigned char *stracpy(const unsigned char *src){	return src ? memacpy(src, src != DUMMY ? strlen(src) : 0) : NULL;}#elsestatic inline unsigned char *debug_memacpy(unsigned char *f, int l, unsigned char *src, int len){	unsigned char *m;	m = debug_mem_alloc(f, l, len + 1);	memcpy(m, src, len);	m[len] = 0;	return m;}#define memacpy(s, l) debug_memacpy(__FILE__, __LINE__, s, l)static inline unsigned char *debug_stracpy(unsigned char *f, int l, unsigned char *src){	return src ? debug_memacpy(f, l, src, src != DUMMY ? strlen(src) : 0) : NULL;}#define stracpy(s) debug_stracpy(__FILE__, __LINE__, s)#endifstatic inline int snprint(unsigned char *s, int n, off_t num){	off_t q = 1;	while (q <= num / 10) q *= 10;	while (n-- > 1 && q) *(s++) = num / q + '0', num %= q, q /= 10;	*s = 0;	return !!q;}static inline int snzprint(unsigned char *s, int n, off_t num){	if (n > 1 && num < 0) *(s++) = '-', num = -num, n--;	return snprint(s, n, num);}static inline void add_to_strn(unsigned char **s, unsigned char *a){	unsigned char *p;	size_t l1 = strlen(*s), l2 = strlen(a);	if (((l1 | l2) | (l1 + l2 + 1)) > MAXINT) overalloc();	p = mem_realloc(*s, l1 + l2 + 1);	strcat(p, a);	*s = p;}#define ALLOC_GR	0x040		/* must be power of 2 */#define init_str() init_str_x(__FILE__, __LINE__)static inline unsigned char *init_str_x(unsigned char *file, int line){	unsigned char *s = debug_mem_alloc(file, line, ALLOC_GR);	*s = 0;	return s;}static inline void add_to_str(unsigned char **s, int *l, unsigned char *a){	unsigned char *p;	size_t ll = strlen(a);	if (ll > MAXINT || *l + ll > MAXINT) overalloc();	p = *s;	if (((size_t)*l & ~(ALLOC_GR - 1)) != ((*l + ll) & ~(ALLOC_GR - 1))) {		p = *s = mem_realloc(*s, (*l + ll + ALLOC_GR) & ~(ALLOC_GR - 1));	}	strcpy(p + *l, a); *l += ll;}static inline void add_bytes_to_str(unsigned char **s, int *l, unsigned char *a, int ll){	unsigned char *p;	if (*l + ll < 0) overalloc();	p = *s;	if ((*l & ~(ALLOC_GR - 1)) != ((*l + ll) & ~(ALLOC_GR - 1))) {		p = *s = mem_realloc(*s, (*l + ll + ALLOC_GR) & ~(ALLOC_GR - 1));	}	memcpy(p + *l, a, ll); p[*l += ll] = 0;}static inline void add_chr_to_str(unsigned char **s, int *l, unsigned char a){	unsigned char *p;	if (*l + 1 < 0) overalloc();	p = *s;	if ((*l & (ALLOC_GR - 1)) == ALLOC_GR - 1) {		p = *s = mem_realloc(*s, (*l + 1 + ALLOC_GR) & ~(ALLOC_GR - 1));	}	*(p + *l) = a; *(p + ++(*l)) = 0;}static inline void add_num_to_str(unsigned char **s, int *l, off_t n){	unsigned char a[64];	/*sprintf(a, "%d", n);*/	snzprint(a, 64, n);	add_to_str(s, l, a);}static inline void add_knum_to_str(unsigned char **s, int *l, int n){	unsigned char a[13];	if (n && n / (1024 * 1024) * (1024 * 1024) == n) snzprint(a, 12, n / (1024 * 1024)), strcat(a, "M");	else if (n && n / 1024 * 1024 == n) snzprint(a, 12, n / 1024), strcat(a, "k");	else snzprint(a, 13, n);	add_to_str(s, l, a);}static inline long strtolx(unsigned char *c, unsigned char **end){	long l;	if (c[0] == '0' && upcase(c[1]) == 'X' && c[2]) l = strtol((char *)c + 2, (char **)end, 16);	else l = strtol((char *)c, (char **)end, 10);	if (!*end) return l;	if (upcase(**end) == 'K') {		(*end)++;		if (l < -MAXINT / 1024) return -MAXINT;		if (l > MAXINT / 1024) return MAXINT;		return l * 1024;	}	if (upcase(**end) == 'M') {		(*end)++;		if (l < -MAXINT / (1024 * 1024)) return -MAXINT;		if (l > MAXINT / (1024 * 1024)) return MAXINT;		return l * (1024 * 1024);	}	return l;}/* Copies at most dst_size chars into dst. Ensures null termination of dst. */static inline unsigned char *safe_strncpy(unsigned char *dst, const unsigned char *src, size_t dst_size) {/*	size_t to_copy;	to_copy = strlen(src);	/ Ensure that the url size is not greater than str_size / 	if (dst_size < to_copy)		to_copy = dst_size - 1;	strncpy(dst, src, to_copy);	/ Ensure null termination /	dst[to_copy] = '\0';		return dst;*/	strncpy(dst, src, dst_size);	if (strlen(src) >= dst_size) dst[dst_size - 1] = 0;	return dst;}struct list_head {	void *next;	void *prev;};struct xlist_head {	struct xlist_head *next;	struct xlist_head *prev;};#define init_list(x) {do_not_optimize_here(&x); (x).next=&(x); (x).prev=&(x); do_not_optimize_here(&x);}#define list_empty(x) ((x).next == &(x))#define del_from_list(x) {do_not_optimize_here(x); ((struct list_head *)(x)->next)->prev=(x)->prev; ((struct list_head *)(x)->prev)->next=(x)->next; do_not_optimize_here(x);}/*#define add_to_list(l,x) {(x)->next=(l).next; (x)->prev=(typeof(x))&(l); (l).next=(x); if ((l).prev==&(l)) (l).prev=(x);}*/#ifdef HAVE_TYPEOF#define add_at_pos(p,x) do {do_not_optimize_here(p); (x)->next=(p)->next; (x)->prev=(p); (p)->next=(x); (x)->next->prev=(x);do_not_optimize_here(p);} while(0)#define add_to_list(l,x) add_at_pos((typeof(x))(void *)&(l),(x))#define foreach(e,l) for ((e)=(l).next; (e)!=(typeof(e))(void *)&(l); (e)=(e)->next)#define foreachback(e,l) for ((e)=(l).prev; (e)!=(typeof(e))(void *)&(l); (e)=(e)->prev)#else#define add_at_pos(p,x) do {do_not_optimize_here(p); (x)->next=(p)->next; (x)->prev=(void *)(p); (p)->next=(x); (x)->next->prev=(x); do_not_optimize_here(p); } while(0)#define add_to_list(l,x) add_at_pos(&(l),(x))#define foreach(e,l) for ((e)=(l).next; (e)!=(void *)&(l); (e)=(e)->next)#define foreachback(e,l) for ((e)=(l).prev; (e)!=(void *)&(l); (e)=(e)->prev)#endif#define free_list(l) {struct xlist_head *a__;do_not_optimize_here(&l);foreach(a__,l) do_not_optimize_here(a__);foreachback(a__,l) do_not_optimize_here(a__); while ((l).next != &(l)) {a__=(l).next; del_from_list(a__); mem_free(a__); } do_not_optimize_here(&l);}#define WHITECHAR(x) ((x) == 9 || (x) == 10 || (x) == 12 || (x) == 13 || (x) == ' ')#define U(x) ((x) == '"' || (x) == '\'')static inline int isA(unsigned char c){	return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') ||	        c == '_' || c == '-';}static inline int casecmp(unsigned char *c1, unsigned char *c2, size_t len){	size_t i;	for (i = 0; i < len; i++) if (upcase(c1[i]) != upcase(c2[i])) return 1;	return 0;}static inline int can_write(int fd){	fd_set fds;	struct timeval tv = {0, 0};	FD_ZERO(&fds);	FD_SET(fd, &fds);	return select(fd + 1, NULL, &fds, NULL, &tv);}static inline int can_read(int fd){	fd_set fds;	struct timeval tv = {0, 0};	FD_ZERO(&fds);	FD_SET(fd, &fds);	return select(fd + 1, &fds, NULL, NULL, &tv);}#define CI_BYTES	1#define CI_FILES	2#define CI_LOCKED	3#define CI_LOADING	4#define CI_TIMERS	5#define CI_TRANSFER	6#define CI_CONNECTING	7#define CI_KEEP		8#define CI_LIST		9/* os_dep.c */struct terminal;struct open_in_new {	unsigned char *text;	unsigned char *hk;	void (*fn)(struct terminal *term, unsigned char *, unsigned char *);

⌨️ 快捷键说明

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