---
name: "globus_ftp_control_server.c"
section: "3"
platform: "linux"
package: "libglobus-ftp-control-doc"
version: "4.4-1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/globus_ftp_control_server.c"
---

# globus\_ftp\_control\_server.c(3)

## NAME

globus\_ftp\_control\_server.c -

## SYNOPSIS

### Functions

globus\_result\_t **globus\_ftp\_control\_server\_handle\_init** (globus\_ftp\_control\_server\_t \*handle)\
 globus\_result\_t **globus\_ftp\_control\_server\_handle\_destroy** (globus\_ftp\_control\_server\_t \*handle)\
 globus\_result\_t **globus\_ftp\_control\_server\_listen** (globus\_ftp\_control\_server\_t \*server\_handle, unsigned short \*port, **globus\_ftp\_control\_server\_callback\_t** callback, void \*callback\_arg)\
 globus\_result\_t **globus\_ftp\_control\_command\_init** (globus\_ftp\_control\_command\_t \*command, char \*raw\_command, **globus\_ftp\_control\_auth\_info\_t** \*auth\_info)\
 globus\_result\_t **globus\_ftp\_control\_command\_destroy** (globus\_ftp\_control\_command\_t \*command)\
 globus\_result\_t **globus\_ftp\_control\_command\_copy** (globus\_ftp\_control\_command\_t \*dest, globus\_ftp\_control\_command\_t \*src)\
 globus\_result\_t **globus\_ftp\_control\_server\_stop** (globus\_ftp\_control\_server\_t \*listener, **globus\_ftp\_control\_server\_callback\_t** callback, void \*callback\_arg)\
 globus\_result\_t **globus\_ftp\_control\_server\_accept** (globus\_ftp\_control\_server\_t \*listener, globus\_ftp\_control\_handle\_t \*handle, **globus\_ftp\_control\_callback\_t** callback, void \*callback\_arg)\
 globus\_result\_t **globus\_ftp\_control\_server\_authenticate** (globus\_ftp\_control\_handle\_t \*handle, **globus\_ftp\_control\_auth\_requirements\_t** auth\_requirements, **globus\_ftp\_control\_auth\_callback\_t** callback, void \*callback\_arg)\
 globus\_result\_t **globus\_ftp\_control\_read\_commands** (globus\_ftp\_control\_handle\_t \*handle, **globus\_ftp\_control\_command\_callback\_t** callback, void \*callback\_arg)\
 globus\_result\_t **globus\_ftp\_control\_send\_response** (globus\_ftp\_control\_handle\_t \*handle, const char \*respspec, **globus\_ftp\_control\_callback\_t** callback, void \*callback\_arg,...)\

## Detailed Description

FTP Server-side Control Connection Management.

## Function Documentation

### globus\_result\_t globus\_ftp\_control\_server\_handle\_init (globus\_ftp\_control\_server\_t \*handle)

Initialize a globus ftp server handle. This function will set up (i.e. intialize all mutexes and variables) a globus ftp server handle. It will also enter the handle in a list used by the module activation/deactivation functions.

**Parameters:**

*handle* The handle to initialize.

**Returns:**

- •

  GLOBUS\_SUCCESS

- •

  invalid handle

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_server\_handle\_destroy (globus\_ftp\_control\_server\_t \*handle)

Destroy a globus ftp server handle. This function will free up all dynamicly allocated memory associated with a given globus ftp server handle. It will also remove the handle from a list used by the module activation/deactivation functions. This function should only be called after a call to globus\_ftp\_control\_server\_stop.

**Parameters:**

*handle* The handle to destory.

**Returns:**

- •

  success

- •

  invalid handle

- •

  handle is still in listening state

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_server\_listen (globus\_ftp\_control\_server\_t \*server\_handle, unsigned short \*port, globus\_ftp\_control\_server\_callback\_tcallback, void \*callback\_arg)

Start listening on a given port for FTP client connections. This function starts the listening on \*port for connections from ftp clients. When a connection request is made callback is called and passed callback\_arg. Upon return from this function the server\_handle structure is initialized.

**Parameters:**

*server\_handle* A pointer to a initialized server handle. \
 *port* A pointer to the port to listen on. If the initial value is zero it will be set to the default value. \
 *callback* The callback function called when connection requests are made. \
 *callback\_arg* The user argument passed to the callback function when connection requests are made.

**Note:**

I'm not providing any mechanism for making sure that this function is only called once. Is this needed?

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_command\_init (globus\_ftp\_control\_command\_t \*command, char \*raw\_command, globus\_ftp\_control\_auth\_info\_t \*auth\_info)

Initialize a command structure. This function initializes a command structure based on a null terminated string representing one line of input from the client. The command structure is used as a convience to determine what command the client issued. This function parses a command string sent by a client and populates the command argument appropriately. In the GSSAPI case it will also decode and unwrap the command before parsing it.

**Parameters:**

*command* A pointer to the command structure to be initialized \
 *raw\_command* A null terminated line of client input. Should contain one command. \
 *auth\_info* Authentication information needed for unwrapping a command

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_command\_destroy (globus\_ftp\_control\_command\_t \*command)

Destroy a command structure. This function frees up the memory allocated to the command argument.

**Parameters:**

*command* The command structure whose associated memory is to be freed

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_command\_copy (globus\_ftp\_control\_command\_t \*dest, globus\_ftp\_control\_command\_t \*src)

Creates a copy of a command structure. This function should be called when the user needs to make a copy of a command structure.

**Parameters:**

*dest* The area of memory that the command structure is copied to. \
 *src* The command structure to be copied.

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_server\_stop (globus\_ftp\_control\_server\_t \*listener, globus\_ftp\_control\_server\_callback\_tcallback, void \*callback\_arg)

Stop the GSIFTP server from listening for client connections. This function stops listening on the given listener object for client connections. All existing client connections are left open.

**Parameters:**

*listener* the globus\_ftp\_control\_server\_t object that should no longer listen for connections. \
 *callback* The user callback that will be called when the server structure is no longer listening. \
 *callback\_arg* The user argument that is passed into callback.

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_server\_accept (globus\_ftp\_control\_server\_t \*listener, globus\_ftp\_control\_handle\_t \*handle, globus\_ftp\_control\_callback\_tcallback, void \*callback\_arg)

Accept a client connection request. This function is called to accept a connection request from a client.

When the listen callback is called (see globus\_ftp\_control\_server\_listen) a client has requested a connection. This function must be called to accept that user connection request. Once the connection is established or if a error occurs, the callback function is called.

**Parameters:**

*listener* The server object that received the connection request. \
 *handle* The control connection object. This structure will be populated and passed to the callback when the client is authorized. This structure represents the control connection between the server and client. It will be used to read commands from the client and send responses to the client.\] \
 *callback* The function called when the client connection has been accepted. \
 *callback\_arg* The user argument passed to the callback.

**Note:**

This functions assumes the the server and control handles have been initialized prior to calling this function.

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_server\_authenticate (globus\_ftp\_control\_handle\_t \*handle, globus\_ftp\_control\_auth\_requirements\_tauth\_requirements, globus\_ftp\_control\_auth\_callback\_tcallback, void \*callback\_arg)

Authenticate a client connection. This function is called to authenticate a connection from a client.

After a client connection has been accepted (using the globus\_ftp\_control\_server\_accept call), this function should be called to authenticate the client. The caller of this function may specify certain authentication requirements using the auth\_requirements parameter.

**Parameters:**

*handle* The control connection object. This structure will be populated and passed to the callback when the client is authorized. This structure represents the control connection between the server and client. It will be used to read commands from the client and send responses to the client.\] \
 *auth\_requirements* This structure represents the authentication requirements that the user has for a given connection. For example GSIFTP user name, password, and account. \
 *callback* The function called when the client authentication has been accepted or rejected. \
 *callback\_arg* The user argument passed to the callback.

**Note:**

It is up to the user of this function to send the reply to the last command of the authentication sequence.

This functions assumes the the server and control handles have been initialized prior to calling this function.

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_read\_commands (globus\_ftp\_control\_handle\_t \*handle, globus\_ftp\_control\_command\_callback\_tcallback, void \*callback\_arg)

Begin reading GSIFTP commands on a given control connection. This function begins reading control commands on a globus\_ftp\_control\_handle\_t. When a command is read the callback function is called.

**Parameters:**

*handle* The control connection handle that commands will be read from. Prior to calling this the function globus\_ftp\_control\_handle\_t must be populated via a call to globus\_ftp\_control\_accept(). \
 *callback* The user callback that will be called when commands are read. \
 *callback\_arg* The user argument passed to the callback.

References GLOBUS\_FTP\_CONTROL\_MODULE.

### globus\_result\_t globus\_ftp\_control\_send\_response (globus\_ftp\_control\_handle\_t \*handle, const char \*respspec, globus\_ftp\_control\_callback\_tcallback, void \*callback\_arg, ...)

Send a response to the GSIFTP client. This function sends a GSIFTP formatted response to the client. When a command callback is received the user calls this function to respond to the clients request.

**Parameters:**

*handle* The control connection to send the response across. \
 *respspec* A formated string representing the users response. \
 *callback* The user callback that will be called when the response has been sent. \
 *callback\_arg* The user argument passed to the callback.

References GLOBUS\_FTP\_CONTROL\_MODULE.

## Author

Generated automatically by Doxygen for globus ftp control from the source code.
