Qshell Interpreter (qsh) - FTP Directory Listing - IBM
Qshell Interpreter (qsh) - FTP Directory Listing - IBM
Qshell Interpreter (qsh) - FTP Directory Listing - IBM
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
124 <strong>Qshell</strong> <strong>Interpreter</strong> (<strong>qsh</strong>)<br />
#pragma disable_handler /* Exception handler */<br />
#pragma disable_handler /* Cancel handler */<br />
exit(0);<br />
return 0;<br />
/* Exception handler */<br />
Cleanup:<br />
LogError(“Unexpected exception %7.7s\n”, ca.Msg_Id);<br />
close(sfd);<br />
exit(1);<br />
} /* End of main() */<br />
/*<br />
* Convert a string to upper case.<br />
*/<br />
int<br />
strtoupper(char *string)<br />
{<br />
for ( ; *string != '\0'; ++string)<br />
*string = toupper(*string);<br />
return 0;<br />
} /* End of strtoupper() */<br />
/*<br />
* Read a string from a socket.<br />
*/<br />
int<br />
GetString(int fd, char *buffer, size_t nbytes)<br />
{<br />
char c;<br />
do {<br />
if (read(fd, &c, 1) != 1) {<br />
return -1;<br />
}<br />
*buffer++ = c;<br />
if (—nbytes == 0) {<br />
return 0;<br />
}<br />
} while (c != '\0');<br />
return 0;<br />
} /* End of GetString() */<br />
/*<br />
* Write an error message to the log file.<br />
*/<br />
void LogError(char *format, ...)<br />
{<br />
va_list ap;<br />
time_t now; /* Time stamp */<br />
/* If needed, open the log file. */<br />
if (log_fp == NULL) {<br />
log_fp = fopen(log_file, “w”);<br />
if (log_fp == NULL) {<br />
return;<br />
}<br />
}<br />
/* Write timestamp to the log file. */<br />
now=time(NULL);<br />
fprintf(log_fp, “\n%s”, ctime(&now));<br />
/* Write the formatted string to the log file. */<br />
va_start(ap, format);<br />
vfprintf(log_fp, format, ap);<br />
va_end(ap);<br />
/* Flush output to log file. */<br />
fflush(log_fp);<br />
return;<br />
} /* End of LogError() */<br />
/*<br />
* Send an error message to the client.<br />
*/<br />
void SendError(int fd, char *format, ...)