cfad47cfa3/tads2/osrestad.c

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
#ifdef RCSID
2
static char RCSid[] =
3
"$Header: d:/cvsroot/tads/TADS2/OSRESTAD.C,v 1.1 1999/07/11 00:46:30 MJRoberts Exp $";
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
  osrestad.c - Resource String default implementation for TADS 2
15
Function
16
  Implements os_get_str_rsc() using a set of static strings, compiled
17
  in to the application, for English versions of the TADS 2 resources.
18
19
  This file is specific to three things:
20
21
    - TADS 2.  If the OS functions are used by another application,
22
      this implementation must be replaced with one that defines the
23
      strings for that application rather than for TADS 2.  The actual
24
      resource ID's and their meanings are specific to the host
25
      application.
26
27
    - English.  To translate an application built with this
28
      implementation, this file must be replaced with one that defines
29
      translated versions of the strings.
30
31
    - Generic operating system.  The definitions here could be
32
      inappropriate for operating systems where strong local conventions
33
      exist.  In particular, the dialog button labels might not conform
34
      to local conventions.  When porting TADS to an operating system
35
      whose conventions differ from the ones used here, this file must
36
      be replaced.  Note that, whenever possible, an OS-level resource
37
      mechanism should be used instead of this default implementation
38
      to begin with.
39
40
Notes
41
  
42
Modified
43
  06/25/99 MJRoberts  - Creation
44
*/
45
46
#include <string.h>
47
48
#include "os.h"
49
#include "res.h"
50
51
/*
52
 *   The strings, as a static array.
53
 *   
54
 *   To translate a version of TADS built using this file, make a new copy
55
 *   of this file, translate the strings, and modify the makefile to build
56
 *   a new version of the executable with your translated version of this
57
 *   file.  
58
 */
59
static const char *S_res_strings[] =
60
{
61
    /* 
62
     *   OK/Cancel/Yes/No button labels.  We provide a shortcut for every
63
     *   label, to make the buttons work well in character mode. 
64
     */
65
    "&OK",                                              /* RESID_BTN_OK = 1 */
66
    "&Cancel",                                      /* RESID_BTN_CANCEL = 2 */
67
    "&Yes",                                            /* RESID_BTN_YES = 3 */
68
    "&No",                                              /* RESID_BTN_NO = 4 */
69
70
    /* reply strings for yorn() */
71
    "[Yy].*",                                             /* RESID_YORN_YES */
72
    "[Nn].*"                                               /* RESID_YORN_NO */
73
};
74
75
76
/*
77
 *   Load a string resource
78
 */
79
int os_get_str_rsc(int id, char *buf, size_t buflen)
80
{
81
    /* 
82
     *   make sure the index is in range of our array - note that the
83
     *   index values start at 1, but our array starts at 0, so adjust
84
     *   accordingly 
85
     */
86
    if (id < 0 || id >= (int)sizeof(S_res_strings)/sizeof(S_res_strings[0]))
87
        return 1;
88
89
    /* make sure the buffer is large enough */
90
    if (buflen < strlen(S_res_strings[id-1]) + 1)
91
        return 2;
92
93
    /* copy the string */
94
    strcpy(buf, S_res_strings[id-1]);
95
96
    /* return success */
97
    return 0;
98
}
99