xorp

cplfile.h

00001 #ifndef cplfile_h
00002 #define cplfile_h
00003 
00004 /*
00005  * Copyright (c) 2000, 2001 by Martin C. Shepherd.
00006  * 
00007  * All rights reserved.
00008  * 
00009  * Permission is hereby granted, free of charge, to any person obtaining a
00010  * copy of this software and associated documentation files (the
00011  * "Software"), to deal in the Software without restriction, including
00012  * without limitation the rights to use, copy, modify, merge, publish,
00013  * distribute, and/or sell copies of the Software, and to permit persons
00014  * to whom the Software is furnished to do so, provided that the above
00015  * copyright notice(s) and this permission notice appear in all copies of
00016  * the Software and that both the above copyright notice(s) and this
00017  * permission notice appear in supporting documentation.
00018  * 
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00020  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
00022  * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
00023  * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
00024  * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
00025  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
00026  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
00027  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00028  * 
00029  * Except as contained in this notice, the name of a copyright holder
00030  * shall not be used in advertising or otherwise to promote the sale, use
00031  * or other dealings in this Software without prior written authorization
00032  * of the copyright holder.
00033  */
00034 
00035 typedef struct CompleteFile CompleteFile;
00036 
00037 /*
00038  * Create a file-completion resource object.
00039  */
00040 CompleteFile *_new_CompleteFile(void);
00041 /*
00042  * Delete a file-completion resource object.
00043  */
00044 CompleteFile *_del_CompleteFile(CompleteFile *cf);
00045 
00046 /*.......................................................................
00047  * Complete the string between path[0] and path[len-1] as a pathname,
00048  * leaving the last component uncompleted if it is potentially ambiguous,
00049  * and returning an array of possible completions. Note that the returned
00050  * container belongs to the 'cf' object and its contents will change on
00051  * subsequent calls to this function.
00052  *
00053  * Input:
00054  *  cpl   WordCompletion *  The object in which to record the completions.
00055  *  cf      CompleteFile *  The filename-completion resource object.
00056  *  line      const char *  The string containing the incomplete filename.
00057  *  word_start       int    The index of the first character in line[]
00058  *                          of the incomplete filename.
00059  *  word_end         int    The index of the character in line[] that
00060  *                          follows the last character of the incomplete
00061  *                          filename.
00062  *  escaped          int    If true, backslashes in path[] are
00063  *                          interpreted as escaping the characters
00064  *                          that follow them, and any spaces, tabs,
00065  *                          backslashes, or wildcard characters in the
00066  *                          returned suffixes will be similarly be escaped.
00067  *                          If false, backslashes will be interpreted as
00068  *                          literal parts of the file name, and no
00069  *                          backslashes will be added to the returned
00070  *                          suffixes.
00071  *  check_fn  CplCheckFn *  If not zero, this argument specifies a
00072  *                          function to call to ask whether a given
00073  *                          file should be included in the list
00074  *                          of completions.
00075  *  check_data      void *  Anonymous data to be passed to check_fn().
00076  * Output:
00077  *  return           int    0 - OK.
00078  *                          1 - Error. A description of the error can be
00079  *                                     acquired by calling cf_last_error(cf).
00080  */
00081 int _cf_complete_file(WordCompletion *cpl, CompleteFile *cf,
00082              const char *line, int word_start, int word_end,
00083              int escaped, CplCheckFn *check_fn, void *check_data);
00084 
00085 /*.......................................................................
00086  * Return a description of the error that occurred on the last call to
00087  * cf_complete_file().
00088  *
00089  * Input:
00090  *  cf    CompleteFile *  The path-completion resource object.
00091  * Output:
00092  *  return        char *  The description of the last error.
00093  */
00094 const char *_cf_last_error(CompleteFile *cf);
00095 
00096 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations