#include <net_config.h>
U8 ftp_check_account (
U8 code, /* Defines the context for id parameter. */
U8* id ); /* Username or Password entered in the client. */
Description
The ftp_check_account function checks if an user account
for provided credentials exist in the user database. It is called
from the TCPnet FTP server to check if the user with provided
credentials is allowed to access the files on the FTP server or
not.
This function is called twice. On first call the argument
code has a value of 0. The argument id is a pointer to
the username.
In a second call to this function, the argument code is a
nonzero value, representing user identification returned from the
first call to this function. Argument id points to the
password for this user. In both cases argument id points to a
0-terminated string.
The argument code specifies the meaning of the id
argument:
Code
*id
0
Pointer to 0-terminated string representing username.
nonzero
Pointer to 0-terminated string representing a password for
the user identified with code.
The ftp_check_account function is in the FTP_MultiUser.c
module. The prototype is defined in net_config.h.
note
This function is optional. For single user FTP
authentication or when the FTP authentication is disabled from the
configuration, this function is not required.
Return Value
The ftp_check_account function returns the user
identification number. If the user account does not exist, it should
return 0.
/* Local variables. */
static const char *users[] = {
"Dave",
"Michael",
"Guest"};
static const char *passwords[] = {
"test1",
"test2",
""};
U8 ftp_check_account (U8 code, U8 *id) {
/* This function checks externally provided user account. */
int i;
if (code == 0) {
/* Check if the username is valid. */
for (i = 0; i < 3; i++) {
if (strcmp ((char *)id, users[i]) == 0) {
/* Return user index + 1. */
return (i+1);
}
}
}
else {
/* Check the password for user identified with 'code' */
if (strcmp ((char *)id, passwords[code-1]) == 0) {
/* Return user identification if ok. */
return (code);
}
}
/* User account does not exist. */
return (0);
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.