[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Main functions

These functions are essential to the correct functioning of libgimpprint. All or most other functions in the library depend absolutely upon them. In the case of stp_init, this function must be called before any of the other functions in the library.

Function: int stp_init (void)

This function initialises the libgimpprint library. It must be called before any of the other libgimpprint functions are called. It is responsible for setting up message catalogues (for internationalisation). This function may be called more than once, at any stage during the execution of a program.

It returns zero on success, nonzero on failure.

stp_init might be used as follows:

 
int
main (int argc, char **argv)
{
  stp_init();

  ...

}

Function: const char * stp_set_output_codeset (const char *codeset)

This function sets the encoding of translated strings returned by libgimpprint (if gettext support was enabled). codeset is a valid encoding name which can be used with iconv_open. The default codeset is the current locale's character encoding.

stp_set_output_codeset returns the currently selected codeset on success. This memory may not be modified or freed. On failure, NULL is returned and errno set if this was a memory allocation failure. If gettext support was not enabled, every call will return "US-ASCII".

stp_set_output_codeset will be of use when strings are required to be in a particular encoding. GTK+-2.0 requires that all strings are UTF-8 encoded. An example of possible usage:

 
const char *codeset;
codeset = stp_set_output_codeset("UTF-8");
if (codeset == NULL)
  {
    if (errno == ENOMEM)
      fprintf(stderr, "Memory allocation failure while \
              setting output codeset!\n");
    else
      fprintf(stderr, "Failed to set output codeset!\n");
    exit(EXIT_FAILURE);
  }

Function: void * stp_malloc (size_t size)

Where size is the amount of memory to allocate (in bytes).

This function allocates memory. It will always return a pointer to the allocated memory. It will not return on failure.

It returns a pointer to the allocated memory.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Robert Krawitz on December, 2 2003 using texi2html