1 /* errno.c 2 * 3 * Copyright (c) 1996-2001 Mike Gleason, NCEMRSoft. 4 * All rights reserved. 5 * 6 */ 7 8 #define _libncftp_errno_c_ 1 9 #include "syshdrs.h" 10 11 static const char *gErrList[kErrLast - kErrFirst + 2] = { 12 "gethostname() failed", /* -100 */ 13 "hostname does not include domain name", /* -101 */ 14 "could not set linger mode", /* -102 */ 15 "could not set type of service", /* -103 */ 16 "could not enable out-of-band data inline", /* -104 */ 17 "unknown host", /* -105 */ 18 "could not get a new stream socket", /* -106 */ 19 "could not duplicate a socket", /* -107 */ 20 "fdopen for reading failed", /* -108 */ 21 "fdopen for writing failed", /* -109 */ 22 "getsockname failed", /* -110 */ 23 "could not bind the data socket", /* -111 */ 24 "could not listen on the data socket", /* -112 */ 25 "passive mode failed", /* -113 */ 26 "server sent bogus port number", /* -114 */ 27 "could not connect data socket", /* -115 */ 28 "could not accept data socket", /* -116 */ 29 "could not set restart point", /* -117 */ 30 "could not connect to remote host", /* -118 */ 31 "could not connect to remote host, but can try again", /* -119 */ 32 "remote host refused connection", /* -120 */ 33 "bad transfer type", /* -121 */ 34 "invalid directory parameter", /* -122 */ 35 "malloc failed", /* -123 */ 36 "PWD failed", /* -124 */ 37 "remote chdir failed", /* -125 */ 38 "remote rmdir failed", /* -126 */ 39 "bad line list", /* -127 */ 40 "unimplemented option", /* -128 */ 41 "unimplemented function", /* -129 */ 42 "remote directory listing failed", /* -130 */ 43 "could not retrieve remote file", /* -131 */ 44 "could not send file to remote host", /* -132 */ 45 "file write error", /* -133 */ 46 "file read error", /* -134 */ 47 "socket write error", /* -135 */ 48 "socket read error", /* -136 */ 49 "could not open file", /* -137 */ 50 "bad magic number in FTP library structure", /* -138 */ 51 "bad parameter given to library", /* -139 */ 52 "remote mkdir failed", /* -140 */ 53 "remote cd .. failed", /* -141 */ 54 "remote chmod failed", /* -142 */ 55 "remote umask failed", /* -143 */ 56 "remote delete failed", /* -144 */ 57 "remote file size inquiry failed", /* -145 */ 58 "remote file timestamp inquiry failed", /* -146 */ 59 "remote transfer type change failed", /* -147 */ 60 "file size inquiries not understood by remote server", /* -148 */ 61 "file timestamp inquiries not understood by remote server", /* -149 */ 62 "could not rename remote file", /* -150 */ 63 "could not do remote wildcard expansion", /* -151 */ 64 "could not set keepalive option", /* -152 */ 65 "remote host disconnected during login", /* -153 */ 66 "username was not accepted for login", /* -154 */ 67 "username and/or password was not accepted for login", /* -155 */ 68 "login failed", /* -156 */ 69 "invalid reply from server", /* -157 */ 70 "remote host closed control connection", /* -158 */ 71 "not connected", /* -159 */ 72 "could not start data transfer", /* -160 */ 73 "data transfer failed", /* -161 */ 74 "PORT failed", /* -162 */ 75 "PASV failed", /* -163 */ 76 "UTIME failed", /* -164 */ 77 "utime requests not understood by remote server", /* -165 */ 78 "HELP failed", /* -166 */ 79 "file deletion on local host failed", /* -167 */ 80 "lseek failed", /* -168 */ 81 "data transfer aborted by local user", /* -169 */ 82 "SYMLINK failed", /* -170 */ 83 "symlink requests not understood by remote server", /* -171 */ 84 "no match", /* -172 */ 85 "server features request failed", /* -173 */ 86 "no valid files were specified", /* -174 */ 87 "file transfer buffer has not been allocated", /* -175 */ 88 "will not overwrite local file with older remote file", /* -176 */ 89 "will not overwrite remote file with older local file", /* -177 */ 90 "local file appears to be the same as the remote file, no transfer necessary", /* -178 */ 91 "could not get extended directory information (MLSD)", /* -179 */ 92 "could not get extended file or directory information (MLST)", /* -180 */ 93 "could not parse extended file or directory information", /* -181 */ 94 "server does not support extended file or directory information", /* -182 */ 95 "server does not support extended directory information", /* -183 */ 96 "could not get information about specified file", /* -184 */ 97 "server does not support file or directory information", /* -185 */ 98 "could not get directory information about specified file", /* -186 */ 99 "server does not support directory information", /* -187 */ 100 "no such file or directory", /* -188 */ 101 "server provides no way to determine file existence", /* -189 */ 102 "item exists, but cannot tell if it is a file or directory", /* -190 */ 103 "not a directory", /* -191 */ 104 "directory recursion limit reached", /* -192 */ 105 "timed out while waiting for server response", /* -193 */ 106 "data transfer timed out", /* -194 */ 107 "canceled by user", /* -195 */ 108 NULL, 109 }; 110 111 int gLibNcFTP_Uses_Me_To_Quiet_Variable_Unused_Warnings = 0; 112 113 const char * 114 FTPStrError(int e) 115 { 116 if (e == kErrGeneric) { 117 return ("miscellaneous error"); 118 } else if (e == kNoErr) { 119 return ("no error"); 120 } else { 121 if (e < 0) 122 e = -e; 123 if ((e >= kErrFirst) && (e <= kErrLast)) { 124 return (gErrList[e - kErrFirst]); 125 } 126 } 127 return ("unrecognized error number"); 128 } /* FTPStrError */ 129 130 131 132 133 void 134 FTPPerror(const FTPCIPtr cip, const int err, const int eerr, const char *const s1, const char *const s2) 135 { 136 if (err != kNoErr) { 137 if (err == eerr) { 138 if ((s2 == NULL) || (s2[0] == '\0')) { 139 if ((s1 == NULL) || (s1[0] == '\0')) { 140 (void) fprintf(stderr, "server said: %s\n", cip->lastFTPCmdResultStr); 141 } else { 142 (void) fprintf(stderr, "%s: server said: %s\n", s1, cip->lastFTPCmdResultStr); 143 } 144 } else if ((s1 == NULL) || (s1[0] == '\0')) { 145 (void) fprintf(stderr, "%s: server said: %s\n", s2, cip->lastFTPCmdResultStr); 146 } else { 147 (void) fprintf(stderr, "%s %s: server said: %s\n", s1, s2, cip->lastFTPCmdResultStr); 148 } 149 } else { 150 if ((s2 == NULL) || (s2[0] == '\0')) { 151 if ((s1 == NULL) || (s1[0] == '\0')) { 152 (void) fprintf(stderr, "%s.\n", FTPStrError(cip->errNo)); 153 } else { 154 (void) fprintf(stderr, "%s: %s.\n", s1, FTPStrError(cip->errNo)); 155 } 156 } else if ((s1 == NULL) || (s1[0] == '\0')) { 157 (void) fprintf(stderr, "%s: %s.\n", s2, FTPStrError(cip->errNo)); 158 } else { 159 (void) fprintf(stderr, "%s %s: %s.\n", s1, s2, FTPStrError(cip->errNo)); 160 } 161 } 162 } 163 } /* FTPPerror */ 164