📄 support.c
字号:
{EDEADLOCK, "file locking deadlock error"},#endif /* EDEADLOCK */#ifdef EBFONT {EBFONT, "bad font file fmt"},#endif /* EBFONT */#ifdef ENOSTR {ENOSTR, "Device not a stream"},#endif /* ENOSTR */#ifdef ENODATA {ENODATA, "no data (for no delay io)"},#endif /* ENODATA */#ifdef ETIME {ETIME, "timer expired"},#endif /* ETIME */#ifdef ENOSR {ENOSR, "out of streams resources"},#endif /* ENOSR */#ifdef ENONET {ENONET, "Machine is not on the network"},#endif /* ENONET */#ifdef ENOPKG {ENOPKG, "Package not installed"},#endif /* ENOPKG */#ifdef EREMOTE {EREMOTE, "The object is remote"},#endif /* EREMOTE */#ifdef ENOLINK {ENOLINK, "the link has been severed"},#endif /* ENOLINK */#ifdef EADV {EADV, "advertise error"},#endif /* EADV */#ifdef ESRMNT {ESRMNT, "srmount error"},#endif /* ESRMNT */#ifdef ECOMM {ECOMM, "Communication error on send"},#endif /* ECOMM */#ifdef EPROTO {EPROTO, "Protocol error"},#endif /* EPROTO */#ifdef EMULTIHOP {EMULTIHOP, "multihop attempted"},#endif /* EMULTIHOP */#ifdef EBADMSG {EBADMSG, "trying to read unreadable message"},#endif /* EBADMSG */#ifdef ENAMETOOLONG {ENAMETOOLONG, "path name is too long"},#endif /* ENAMETOOLONG */#ifdef EOVERFLOW {EOVERFLOW, "value too large to be stored in data type"},#endif /* EOVERFLOW */#ifdef ENOTUNIQ {ENOTUNIQ, "given log. name not unique"},#endif /* ENOTUNIQ */#ifdef EBADFD {EBADFD, "f.d. invalid for this operation"},#endif /* EBADFD */#ifdef EREMCHG {EREMCHG, "Remote address changed"},#endif /* EREMCHG */#ifdef ELIBACC {ELIBACC, "Can't access a needed shared lib."},#endif /* ELIBACC */#ifdef ELIBBAD {ELIBBAD, "Accessing a corrupted shared lib."},#endif /* ELIBBAD */#ifdef ELIBSCN {ELIBSCN, ".lib section in a.out corrupted."},#endif /* ELIBSCN */#ifdef ELIBMAX {ELIBMAX, "Attempting to link in too many libs."},#endif /* ELIBMAX */#ifdef ELIBEXEC {ELIBEXEC, "Attempting to exec a shared library."},#endif /* ELIBEXEC */#ifdef EILSEQ {EILSEQ, "Illegal byte sequence."},#endif /* EILSEQ */#ifdef ENOSYS {ENOSYS, "Unsupported file system operation"},#endif /* ENOSYS */#ifdef ELOOP {ELOOP, "Symbolic link loop"},#endif /* ELOOP */#ifdef ERESTART {ERESTART, "Restartable system call"},#endif /* ERESTART */#ifdef ESTRPIPE {ESTRPIPE, "if pipe/FIFO, don't sleep in stream head"},#endif /* ESTRPIPE */#ifdef ENOTEMPTY {ENOTEMPTY, "directory not empty"},#endif /* ENOTEMPTY */#ifdef EUSERS {EUSERS, "Too many users (for UFS)"},#endif /* EUSERS */#ifdef ENOTSOCK {ENOTSOCK, "Socket operation on non-socket"},#endif /* ENOTSOCK */#ifdef EDESTADDRREQ {EDESTADDRREQ, "Destination address required"},#endif /* EDESTADDRREQ */#ifdef EMSGSIZE {EMSGSIZE, "Message too long"},#endif /* EMSGSIZE */#ifdef EPROTOTYPE {EPROTOTYPE, "Protocol wrong type for socket"},#endif /* EPROTOTYPE */#ifdef ENOPROTOOPT {ENOPROTOOPT, "Protocol not available"},#endif /* ENOPROTOOPT */#ifdef EPROTONOSUPPORT {EPROTONOSUPPORT, "Protocol not supported"},#endif /* EPROTONOSUPPORT */#ifdef ESOCKTNOSUPPORT {ESOCKTNOSUPPORT, "Socket type not supported"},#endif /* ESOCKTNOSUPPORT */#ifdef EOPNOTSUPP {EOPNOTSUPP, "Operation not supported on socket"},#endif /* EOPNOTSUPP */#ifdef EPFNOSUPPORT {EPFNOSUPPORT, "Protocol family not supported"},#endif /* EPFNOSUPPORT */#ifdef EAFNOSUPPORT {EAFNOSUPPORT, "Address family not supported by"},#endif /* EAFNOSUPPORT */#ifdef EADDRINUSE {EADDRINUSE, "Address already in use"},#endif /* EADDRINUSE */#ifdef EADDRNOTAVAIL {EADDRNOTAVAIL, "Can't assign requested address"},#endif /* EADDRNOTAVAIL */#ifdef ENETDOWN {ENETDOWN, "Network is down"},#endif /* ENETDOWN */#ifdef ENETUNREACH {ENETUNREACH, "Network is unreachable"},#endif /* ENETUNREACH */#ifdef ENETRESET {ENETRESET, "Network dropped connection because"},#endif /* ENETRESET */#ifdef ECONNABORTED {ECONNABORTED, "Software caused connection abort"},#endif /* ECONNABORTED */#ifdef ECONNRESET {ECONNRESET, "Connection reset by peer"},#endif /* ECONNRESET */#ifdef ENOBUFS {ENOBUFS, "No buffer space available"},#endif /* ENOBUFS */#ifdef EISCONN {EISCONN, "Socket is already connected"},#endif /* EISCONN */#ifdef ENOTCONN {ENOTCONN, "Socket is not connected"},#endif /* ENOTCONN */#ifdef ESHUTDOWN {ESHUTDOWN, "Can't send after socket shutdown"},#endif /* ESHUTDOWN */#ifdef ETOOMANYREFS {ETOOMANYREFS, "Too many references: can't splice"},#endif /* ETOOMANYREFS */#ifdef ETIMEDOUT {ETIMEDOUT, "Connection timed out"},#endif /* ETIMEDOUT */#ifdef ECONNREFUSED {ECONNREFUSED, "Connection refused"},#endif /* ECONNREFUSED */#ifdef EHOSTDOWN {EHOSTDOWN, "Host is down"},#endif /* EHOSTDOWN */#ifdef EHOSTUNREACH {EHOSTUNREACH, "No route to host"},#endif /* EHOSTUNREACH */#ifdef EALREADY {EALREADY, "operation already in progress"},#endif /* EALREADY */#ifdef EINPROGRESS {EINPROGRESS, "operation now in progress"},#endif /* EINPROGRESS */#ifdef ESTALE {ESTALE, "Stale NFS file handle"},#endif /* ESTALE */ {0, NULL}}; for(i = 0; error_list[i].str != NULL; i++) if(error_list[i].id == errnum) return error_list[i].str; sprintf(s, "ERROR %d", errnum); return s;}#endif /* HAVE_ERRNO_H */#endif /* HAVE_STRERROR */#ifndef HAVE_USLEEP#ifdef __W32__int usleep(unsigned int usec){ Sleep(usec / 1000); return 0;}#elif __MACOS__int usleep(unsigned int /*usec*/){ YieldToAnyThread(); return 0;}#elseint usleep(unsigned int usec){ struct timeval tv; tv.tv_sec = usec / 1000000; tv.tv_usec = usec % 1000000; select(0, NULL, NULL, NULL, &tv); return 0;}#endif /* __W32__ */#endif /* HAVE_USLEEP */#ifndef HAVE_STRDUPchar *strdup(const char *s){ size_t len; char *p; len = strlen(s); if((p = (char *)safe_malloc(len + 1)) == NULL) return NULL; return strcpy(p, s);}#endif /* HAVE_STRDUP */#ifndef HAVE_GETCWD#ifndef MAXPATHLEN#define MAXPATHLEN 1024 /* It must be defined in <sys/param.h> */#endif /* MAXPATHLEN */char *getcwd(char *buf, size_t size){ char path[MAXPATHLEN+1]; if(getwd(path) == NULL) strcpy(path, "."); if(buf != NULL) return strncpy(buf, path, size); return safe_strdup(path);}#endif /* HAVE_GETCWD */#ifndef HAVE_STRNCASECMPint strncasecmp(char *s1, char *s2, unsigned int len) { int dif; while (len-- > 0) { if ((dif = (unsigned char)tolower(*s1) - (unsigned char)tolower(*s2++)) != 0) return(dif); if (*s1++ == '\0') break; } return (0);}#endif /* HAVE_STRNCASECMP */#ifndef HAVE_SYS_STAT_H#ifdef __MACOS__int stat(const char *filename, struct stat *st){ Str255 pfilename; CInfoPBRec pb; FSSpec fss; c2pstrcpy(pfilename, filename); if (FSMakeFSSpec(0, 0, pfilename, &fss) == noErr) { pb.hFileInfo.ioNamePtr = fss.name; pb.hFileInfo.ioVRefNum = fss.vRefNum; pb.hFileInfo.ioFDirIndex = 0; pb.hFileInfo.ioDirID = fss.parID; if (PBGetCatInfoSync(&pb) == noErr) { st->st_mode = (pb.hFileInfo.ioFlAttrib & kioFlAttribDirMask) ? S_IFDIR : 0; st->st_dev = pb.hFileInfo.ioVRefNum; st->st_ino = pb.hFileInfo.ioDirID; st->st_size = pb.hFileInfo.ioFlLgLen; st->st_mtime = pb.hFileInfo.ioFlMdDat; st->st_ctime = pb.hFileInfo.ioFlCrDat; st->st_btime = pb.hFileInfo.ioFlBkDat; return 0; } } st->st_mode = 0; st->st_dev = 0; st->st_ino = 0; st->st_size = 0; st->st_mtime = st->st_ctime = st->st_btime = 0; errno = EIO; return -1;}#endif /* __MACOS__ */#endif /* HAVE_SYS_STAT_H */#ifndef HAVE_STRLCPY/* * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */#include <sys/types.h>#include <string.h>/* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */size_tstrlcpy(char *dst, const char *src, size_t siz){ register char *d = dst; register const char *s = src; register size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { do { if ((*d++ = *s++) == 0) break; } while (--n != 0); } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return(s - src - 1); /* count does not include NUL */}#endif /* strlcpy() */#ifndef HAVE_STRLCAT/* * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */#include <sys/types.h>#include <string.h>/* * Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters * will be copied. Always NUL terminates (unless siz <= strlen(dst)). * Returns strlen(src) + MIN(siz, strlen(initial dst)). * If retval >= siz, truncation occurred. */size_tstrlcat(char *dst, const char *src, size_t siz){ register char *d = dst; register const char *s = src; register size_t n = siz; size_t dlen; /* Find the end of dst and adjust bytes left but don't go past end */ while (n-- != 0 && *d != '\0') d++; dlen = d - dst; n = siz - dlen; if (n == 0) return(dlen + strlen(s)); while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; } *d = '\0'; return(dlen + (s - src)); /* count does not include NUL */}#endif /* strlcat() */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -