- Main Page
- Data Structures
- Files

- File List
- Globals

# jasperserver/attachment.h File Reference

`#include <stdsoap2.h>`

Go to the source code of this file.

## Data Structures
struct | jasperserver_attachment
## Typedefs
typedef jasperserver_attachment | jasperserver_attachment_t
## Functions
int | jasperserver_attach_file (struct soap *soapPtr, const char *fileName)
| Attach a file to a soap struct previously created and initiated.
void * | jasperserver_dime_read_open (struct soap *soap, void *handle, const char *id, const char *type, const char *options)
| Callback function to open a file to read.
void | jasperserver_dime_read_close (struct soap *soap, void *handle)
| Callback function to close the attached file.
size_t | jasperserver_dime_read (struct soap *soap, void *handle, char *buf, size_t len)
| Callback function to read bytes from a file.
int | jasperserver_read_file (const char *fileName, char **dataPtr, size_t *sizePtr)
| Allocate a buffer and put into that the content of a file.

## Typedef Documentation

typedef struct jasperserver_attachment jasperserver_attachment_t

## Function Documentation

int jasperserver_attach_file | ( | struct soap * | soapPtr,
|  | const char * | fileName |
| ) |  |  |

Attach a file to a soap struct previously created and initiated.

This function provides an easy way to add an attachment to a SOAP request. The file is streamed using the mechanism provided by gSOAP. A struct jasperserver_attachment is created to keep track of the FILE* opened. That structure will be passed to the callback functions to open, read and close the file.

Parameters:

  | soapPtr | A pointer to the struct soap
  | fileName | The file name to attach

Returns:
  The function return 0 if no errors occur, otherwise a positive integer representing the error.

Possible errors:

- 1 File to attach not specified!
- 2 Soap struct NULL!
- 3 File not found!!
- 4 Unable to find the size of the file
- 5 Error setting up DIME attachment

Definition at line 25 of file attachment.c.

size_t jasperserver_dime_read | ( | struct soap * | soap,
|  | void * | handle,
|  | char * | buf,
|  | size_t | len |
| ) |  |  |

Callback function to read bytes from a file.

This function is used as callback for the gSoap file streaming mechanism. This funcion is used by jasperserver_attach_file and it should not be called directly by the user.

Parameters:

  | soap | A pointer to the struct soap
  | handle | It is a ready FILE pointer
  | buf | Buffer to store the read bytes
  | len | Number of bytes to read

Returns:
  The number of read bytes

See also:
  jasperserver_attach_file

Definition at line 90 of file attachment.c.

void jasperserver_dime_read_close | ( | struct soap * | soap,
|  | void * | handle |
| ) |  |  |

Callback function to close the attached file.

This function is used as callback for the gSoap file streaming mechanism. This funcion is used by jasperserver_attach_file and it should not be called directly by the user.

Parameters:

  | soap | A pointer to the struct soap
  | handle | It is a FILE pointer
  | id | Not used
  | type | Not used
  | options | Not used

See also:
  jasperserver_attach_file

Definition at line 83 of file attachment.c.

void* jasperserver_dime_read_open | ( | struct soap * | soap,
|  | void * | handle,
|  | const char * | id,
|  | const char * | type,
|  | const char * | options |
| ) |  |  |

Callback function to open a file to read.

This function is used as callback for the gSoap file streaming mechanism. This funcion is used by jasperserver_attach_file and it should not be called directly by the user.

Parameters:

  | soap | A pointer to the struct soap
  | handle | It is a ready FILE pointer
  | id | Not used
  | type | Not used
  | options | Not used

Returns:
  The handle input parameter.

See also:
  jasperserver_attach_file

Definition at line 76 of file attachment.c.

int jasperserver_read_file | ( | const char * | fileName,
|  | char ** | dataPtr,
|  | size_t * | sizePtr |
| ) |  |  |

Allocate a buffer and put into that the content of a file.

This function is currently not used. The user is responsible to free the data allocated to read the file with free(*dataPtr)

Parameters:

  | fileName | A file to read
  | dataPtr | A pointer to a data pointer (char **).
  | sizePtr | Pointer to a size_t to save the size of the allocated buffer

Returns:
  0 if no error occurs, a different value otherwise.

Possible errors:

- 1 File to attach not specified!
- 3 File not found!!

See also:
  jasperserver_attach_file

Definition at line 99 of file attachment.c.