1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
/* c_type.c
*
* Copyright (c) 1996-2005 Mike Gleason, NcFTP Software.
* All rights reserved.
*
*/
#include "syshdrs.h"
#ifdef PRAGMA_HDRSTOP
# pragma hdrstop
#endif
int
FTPSetTransferType(const FTPCIPtr cip, int type)
{
int result;
if (cip == NULL)
return (kErrBadParameter);
if (strcmp(cip->magic, kLibraryMagic))
return (kErrBadMagic);
if (cip->curTransferType != type) {
switch (type) {
case kTypeAscii:
case kTypeBinary:
case kTypeEbcdic:
break;
case 'i':
case 'b':
case 'B':
type = kTypeBinary;
break;
case 'e':
type = kTypeEbcdic;
break;
case 'a':
type = kTypeAscii;
break;
default:
/* Yeah, we don't support Tenex. Who cares? */
FTPLogError(cip, kDontPerror, "Bad transfer type [%c].\n", type);
cip->errNo = kErrBadTransferType;
return (kErrBadTransferType);
}
result = FTPCmd(cip, "TYPE %c", type);
if (result != 2) {
result = kErrTYPEFailed;
cip->errNo = kErrTYPEFailed;
return (result);
}
cip->curTransferType = type;
}
return (kNoErr);
} /* FTPSetTransferType */
|