MyWebUniversity.com Home Page
 



Darwin Mac OS X man pages main menu
ui(3)                               OpenSL                              ui(3)



NAME
       UInew, UInewmethod, UIfree, UIaddinputstring,
       UIdupinputstring, UIaddverifystring, UIdupverifystring,
       UIaddinputboolean, UIdupinputboolean, UIaddinfostring,
       UIdupinfostring, UIadderrorstring, UIduperrorstring, UIcon-
       structprompt, UIadduserdata, UIget0userdata, UIget0result,
       UIprocess, UIctrl, UIsetdefaultmethod, UIgetdefaultmethod,
       UIgetmethod, UIsetmethod, UIOpenSL, ERloadUIstrings - New
       User Interface

SYNOPSIS
        #include 

        typedef struct uist UI;
        typedef struct uimethodst UIMETHOD;

        UI *UInew(void);
        UI *UInewmethod(const UIMETHOD *method);
        void UIfree(UI *ui);

        int UIaddinputstring(UI *ui, const char *prompt, int flags,
               char *resultbuf, int minsize, int maxsize);
        int UIdupinputstring(UI *ui, const char *prompt, int flags,
               char *resultbuf, int minsize, int maxsize);
        int UIaddverifystring(UI *ui, const char *prompt, int flags,
               char *resultbuf, int minsize, int maxsize, const char *testbuf);
        int UIdupverifystring(UI *ui, const char *prompt, int flags,
               char *resultbuf, int minsize, int maxsize, const char *testbuf);
        int UIaddinputboolean(UI *ui, const char *prompt, const char *actiondesc,
               const char *okchars, const char *cancelchars,
               int flags, char *resultbuf);
        int UIdupinputboolean(UI *ui, const char *prompt, const char *actiondesc,
               const char *okchars, const char *cancelchars,
               int flags, char *resultbuf);
        int UIaddinfostring(UI *ui, const char *text);
        int UIdupinfostring(UI *ui, const char *text);
        int UIadderrorstring(UI *ui, const char *text);
        int UIduperrorstring(UI *ui, const char *text);

        /* These are the possible flags.  They can be or'ed together. */
        #define UINPUTFLAGECHO             0x01
        #define UINPUTFLAGDEFAULTPWD      0x02

        char *UIconstructprompt(UI *uimethod,
               const char *objectdesc, const char *objectname);

        void *UIadduserdata(UI *ui, void *userdata);
        void *UIget0userdata(UI *ui);

        const char *UIget0result(UI *ui, int i);

        int UIprocess(UI *ui);

        int UIctrl(UI *ui, int cmd, long i, void *p, void (*f)());
        #define UICTRLPRINTERORS           1
        #define UICTRLISREDOABLE            2

        void UIsetdefaultmethod(const UIMETHOD *meth);
        const UIMETHOD *UIgetdefaultmethod(void);
        const UIMETHOD *UIgetmethod(UI *ui);
        const UIMETHOD *UIsetmethod(UI *ui, const UIMETHOD *meth);

        UIMETHOD *UIOpenSL(void);

DESCRIPTION
       UI stands for User Interface, and is general purpose set of routines to
       prompt the user for text-based information.  Through user-written meth-
       ods (see uicreate(3)), prompting can be done in any way imaginable, be
       it plain text prompting, through dialog boxes or from a cell phone.

       All the functions work through a context of the type UI.  This context
       contains all the information needed to prompt correctly as well as a
       reference to a UIMETHOD, which is an ordered vector of functions that
       carry out the actual prompting.

       The first thing to do is to create a UI with UInew() or
       UInewmethod(), then add information to it with the UIadd or UIdup
       functions.  Also, user-defined random data can be passed down to the
       underlying method through calls to UIadduserdata.  The default UI
       method doesn't care about these data, but other methods might.
       Finally, use UIprocess() to actually perform the prompting and
       UIget0result() to find the result to the prompt.

       A UI can contain more than one prompt, which are performed in the given
       sequence.  Each prompt gets an index number which is returned by the
       UIadd and UIdup functions, and has to be used to get the correspond-
       ing result with UIget0result().

       The functions are as follows:

       UInew() creates a new UI using the default UI method.  When done with
       this UI, it should be freed using UIfree().

       UInewmethod() creates a new UI using the given UI method.  When done
       with this UI, it should be freed using UIfree().

       UIOpenSL() returns the built-in UI method (note: not the default one,
       since the default can be changed.  See further on).  This method is the
       most machine/OS dependent part of OpenSL and normally generates the
       most problems when porting.

       UIfree() removes a UI from memory, along with all other pieces of mem-
       ory that's connected to it, like duplicated input strings, results and
       others.

       UIaddinputstring() and UIaddverifystring() add a prompt to the
       UI, as well as flags and a result buffer and the desired minimum and
       maximum sizes of the result.  The given information is used to prompt
       for information, for example a password, and to verify a password (i.e.
       having the user enter it twice and check that the same string was
       entered twice).  UIaddverifystring() takes and extra argument that
       should be a pointer to the result buffer of the input string that it's
       supposed to verify, or verification will fail.

       UIaddinputboolean() adds a prompt to the UI that's supposed to be
       answered in a boolean way, with a single character for yes and a dif-
       ferent character for no.  A set of characters that can be used to can-
       cel the prompt is given as well.  The prompt itself is really divided
       in two, one part being the descriptive text (given through the prompt
       argument) and one describing the possible answers (given through the
       actiondesc argument).

       UIaddinfostring() and UIadderrorstring() add strings that are
       shown at the same time as the prompt for extra information or to show
       an error string.  The difference between the two is only conceptual.
       With the builtin method, there's no technical difference between them.
       Other methods may make a difference between them, however.

       The flags currently supported are UINPUTFLAGECHO, which is relevant
       for UIaddinputstring() and will have the users response be echoed
       (when prompting for a password, this flag should obviously not be used,
       and UINPUTFLAGDEFAULTPWD, which means that a default password of
       some sort will be used (completely depending on the application and the
       UI method).

       UIdupinputstring(), UIdupverifystring(), UIdupinputboolean(),
       UIdupinfostring() and UIduperrorstring() are basically the same
       as their UIadd counterparts, except that they make their own copies of
       all strings.

       UIconstructprompt() is a helper function that can be used to create a
       prompt from two pieces of information: an description and a name.  The
       default constructor (if there is none provided by the method used) cre-
       ates a string "Enter description for name:".  With the description
       "pass phrase" and the file name "foo.key", that becomes "Enter pass
       phrase for foo.key:".  Other methods may create whatever string and may
       include encodings that will be processed by the other method functions.

       UIadduserdata() adds a piece of memory for the method to use at any
       time.  The builtin UI method doesn't care about this info.  Note that
       several calls to this function doesn't add data, it replaces the previ-
       ous blob with the one given as argument.

       UIget0userdata() retrieves the data that has last been given to the
       UI with UIadduserdata().

       UIget0result() returns a pointer to the result buffer associated with
       the information indexed by i.

       UIprocess() goes through the information given so far, does all the
       printing and prompting and returns.

       UIctrl() adds extra control for the application author.  For now, it
       understands two commands: UICTRLPRINTERORS, which makes
       UIprocess() print the OpenSL error stack as part of processing the
       UI, and UICTRLISREDOABLE, which returns a flag saying if the used UI
       can be used again or not.

       UIsetdefaultmethod() changes the default UI method to the one given.

       UIgetdefaultmethod() returns a pointer to the current default UI
       method.

       UIgetmethod() returns the UI method associated with a given UI.

       UIsetmethod() changes the UI method associated with a given UI.

SEE ALSO
       uicreate(3), uicompat(3)

HISTORY
       The UI section was first introduced in OpenSL 0.9.7.

AUTHOR
       Richard Levitte (richard@levitte.org) for the OpenSL project
       (http:/www.openssl.org).



0.9.7l                            2003-09-30                             ui(3)
Darwin Mac OS X man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™