| | 1 | #ifdef RCSID |
| | 2 | static char RCSid[] = |
| | 3 | "$Header$"; |
| | 4 | #endif |
| | 5 | |
| | 6 | /* |
| | 7 | * Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved. |
| | 8 | * |
| | 9 | * Please see the accompanying license file, LICENSE.TXT, for information |
| | 10 | * on using and copying this software. |
| | 11 | */ |
| | 12 | /* |
| | 13 | Name |
| | 14 | askf_tx.c - formatted text-mode implementation of tio_askfile |
| | 15 | Function |
| | 16 | Implements tio_askfile() using text prompts. |
| | 17 | Notes |
| | 18 | Only one of askf_tx.c or askf_os.c should be included in a given |
| | 19 | executable. For a text-only version, include askf_tx. For a version |
| | 20 | where os_askfile() provides a file dialog, use askf_os instead. |
| | 21 | |
| | 22 | We provide a choice of tio_askfile() implementations in the portable |
| | 23 | code (rather than only through the OS code) so that we can call |
| | 24 | the formatted text output routines in this version. An OS-layer |
| | 25 | implementation could not call the formatted output routines (it would |
| | 26 | have to call os_printf directly), which would result in poor prompt |
| | 27 | formatting any time a prompt exceeded a single line of text. |
| | 28 | Modified |
| | 29 | 09/27/99 MJRoberts - Creation |
| | 30 | */ |
| | 31 | |
| | 32 | #include "os.h" |
| | 33 | #include "std.h" |
| | 34 | #include "tio.h" |
| | 35 | |
| | 36 | /* |
| | 37 | * formatted text-only file prompt |
| | 38 | */ |
| | 39 | int tio_askfile(const char *prompt, char *reply, int replen, |
| | 40 | int prompt_type, os_filetype_t file_type) |
| | 41 | { |
| | 42 | /* show the prompt */ |
| | 43 | outformat((char *)prompt); |
| | 44 | |
| | 45 | /* ask for the filename */ |
| | 46 | if (getstring(" >", reply, replen)) |
| | 47 | return OS_AFE_FAILURE; |
| | 48 | |
| | 49 | /* |
| | 50 | * if they entered an empty line, return "cancel"; otherwise, return |
| | 51 | * success |
| | 52 | */ |
| | 53 | return (reply[0] == '\0' ? OS_AFE_CANCEL : OS_AFE_SUCCESS); |
| | 54 | } |
| | 55 | |