Back to index

tetex-bin  3.0
Functions
lib_unget_wch.c File Reference
#include <curses.priv.h>

Go to the source code of this file.

Functions

 unget_wch (const wchar_t wch)

Function Documentation

unget_wch ( const wchar_t  wch)

Definition at line 45 of file lib_unget_wch.c.

{
    int result = OK;
    mbstate_t state;
    size_t length;
    int n;

    T((T_CALLED("unget_wch(%#lx)"), (unsigned long) wch));

    memset(&state, 0, sizeof(state));
    length = wcrtomb(0, wch, &state);

    if (length != (size_t) (-1)
       && length != 0) {
       char *string;

       if ((string = (char *) malloc(length)) != 0) {
           memset(&state, 0, sizeof(state));
           wcrtomb(string, wch, &state);

           for (n = (int) (length - 1); n >= 0; --n) {
              if (ungetch(string[n]) != OK) {
                  result = ERR;
                  break;
              }
           }
           free(string);
       } else {
           result = ERR;
       }
    } else {
       result = ERR;
    }

    returnCode(result);
}

Here is the call graph for this function: