17c478bd9Sstevel@tonic-gate #ifndef cplfile_h 27c478bd9Sstevel@tonic-gate #define cplfile_h 37c478bd9Sstevel@tonic-gate 47c478bd9Sstevel@tonic-gate /* 57c478bd9Sstevel@tonic-gate * Copyright (c) 2000, 2001, 2002, 2003, 2004 by Martin C. Shepherd. 6*1da57d55SToomas Soome * 77c478bd9Sstevel@tonic-gate * All rights reserved. 8*1da57d55SToomas Soome * 97c478bd9Sstevel@tonic-gate * Permission is hereby granted, free of charge, to any person obtaining a 107c478bd9Sstevel@tonic-gate * copy of this software and associated documentation files (the 117c478bd9Sstevel@tonic-gate * "Software"), to deal in the Software without restriction, including 127c478bd9Sstevel@tonic-gate * without limitation the rights to use, copy, modify, merge, publish, 137c478bd9Sstevel@tonic-gate * distribute, and/or sell copies of the Software, and to permit persons 147c478bd9Sstevel@tonic-gate * to whom the Software is furnished to do so, provided that the above 157c478bd9Sstevel@tonic-gate * copyright notice(s) and this permission notice appear in all copies of 167c478bd9Sstevel@tonic-gate * the Software and that both the above copyright notice(s) and this 177c478bd9Sstevel@tonic-gate * permission notice appear in supporting documentation. 18*1da57d55SToomas Soome * 197c478bd9Sstevel@tonic-gate * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 207c478bd9Sstevel@tonic-gate * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 217c478bd9Sstevel@tonic-gate * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 227c478bd9Sstevel@tonic-gate * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 237c478bd9Sstevel@tonic-gate * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 247c478bd9Sstevel@tonic-gate * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 257c478bd9Sstevel@tonic-gate * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 267c478bd9Sstevel@tonic-gate * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 277c478bd9Sstevel@tonic-gate * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 28*1da57d55SToomas Soome * 297c478bd9Sstevel@tonic-gate * Except as contained in this notice, the name of a copyright holder 307c478bd9Sstevel@tonic-gate * shall not be used in advertising or otherwise to promote the sale, use 317c478bd9Sstevel@tonic-gate * or other dealings in this Software without prior written authorization 327c478bd9Sstevel@tonic-gate * of the copyright holder. 337c478bd9Sstevel@tonic-gate */ 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate typedef struct CompleteFile CompleteFile; 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * Create a file-completion resource object. 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate CompleteFile *_new_CompleteFile(void); 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * Delete a file-completion resource object. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate CompleteFile *_del_CompleteFile(CompleteFile *cf); 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /*....................................................................... 477c478bd9Sstevel@tonic-gate * Complete the string between path[0] and path[len-1] as a pathname, 487c478bd9Sstevel@tonic-gate * leaving the last component uncompleted if it is potentially ambiguous, 497c478bd9Sstevel@tonic-gate * and returning an array of possible completions. Note that the returned 507c478bd9Sstevel@tonic-gate * container belongs to the 'cf' object and its contents will change on 517c478bd9Sstevel@tonic-gate * subsequent calls to this function. 527c478bd9Sstevel@tonic-gate * 537c478bd9Sstevel@tonic-gate * Input: 547c478bd9Sstevel@tonic-gate * cpl WordCompletion * The object in which to record the completions. 557c478bd9Sstevel@tonic-gate * cf CompleteFile * The filename-completion resource object. 567c478bd9Sstevel@tonic-gate * line const char * The string containing the incomplete filename. 577c478bd9Sstevel@tonic-gate * word_start int The index of the first character in line[] 587c478bd9Sstevel@tonic-gate * of the incomplete filename. 597c478bd9Sstevel@tonic-gate * word_end int The index of the character in line[] that 607c478bd9Sstevel@tonic-gate * follows the last character of the incomplete 617c478bd9Sstevel@tonic-gate * filename. 627c478bd9Sstevel@tonic-gate * escaped int If true, backslashes in path[] are 637c478bd9Sstevel@tonic-gate * interpreted as escaping the characters 647c478bd9Sstevel@tonic-gate * that follow them, and any spaces, tabs, 657c478bd9Sstevel@tonic-gate * backslashes, or wildcard characters in the 667c478bd9Sstevel@tonic-gate * returned suffixes will be similarly be escaped. 677c478bd9Sstevel@tonic-gate * If false, backslashes will be interpreted as 687c478bd9Sstevel@tonic-gate * literal parts of the file name, and no 697c478bd9Sstevel@tonic-gate * backslashes will be added to the returned 707c478bd9Sstevel@tonic-gate * suffixes. 717c478bd9Sstevel@tonic-gate * check_fn CplCheckFn * If not zero, this argument specifies a 727c478bd9Sstevel@tonic-gate * function to call to ask whether a given 737c478bd9Sstevel@tonic-gate * file should be included in the list 747c478bd9Sstevel@tonic-gate * of completions. 757c478bd9Sstevel@tonic-gate * check_data void * Anonymous data to be passed to check_fn(). 767c478bd9Sstevel@tonic-gate * Output: 777c478bd9Sstevel@tonic-gate * return int 0 - OK. 787c478bd9Sstevel@tonic-gate * 1 - Error. A description of the error can be 797c478bd9Sstevel@tonic-gate * acquired by calling cf_last_error(cf). 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate int _cf_complete_file(WordCompletion *cpl, CompleteFile *cf, 827c478bd9Sstevel@tonic-gate const char *line, int word_start, int word_end, 837c478bd9Sstevel@tonic-gate int escaped, CplCheckFn *check_fn, void *check_data); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /*....................................................................... 867c478bd9Sstevel@tonic-gate * Return a description of the error that occurred on the last call to 877c478bd9Sstevel@tonic-gate * cf_complete_file(). 887c478bd9Sstevel@tonic-gate * 897c478bd9Sstevel@tonic-gate * Input: 907c478bd9Sstevel@tonic-gate * cf CompleteFile * The path-completion resource object. 917c478bd9Sstevel@tonic-gate * Output: 927c478bd9Sstevel@tonic-gate * return char * The description of the last error. 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate const char *_cf_last_error(CompleteFile *cf); 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #endif 97