~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

Viewing changes to src/rs232drv/rs232drv.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2006-07-30 19:15:59 UTC
  • mto: (9.1.1 lenny) (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20060730191559-g31ymd2mk102kzff
Tags: upstream-1.19
ImportĀ upstreamĀ versionĀ 1.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include "vice.h"
28
28
 
 
29
#include "archdep.h"
 
30
#include "cmdline.h"
 
31
#include "lib.h"
 
32
#include "resources.h"
29
33
#include "rs232.h"
30
34
#include "rs232drv.h"
 
35
#ifdef HAS_TRANSLATION
 
36
#include "translate.h"
 
37
#endif
31
38
#include "types.h"
 
39
#include "util.h"
32
40
 
33
41
 
34
42
#ifdef HAVE_RS232
35
43
 
 
44
#define NUM_DEVICES 4
 
45
 
 
46
/*static*/ char *devfile[NUM_DEVICES] = { NULL, NULL, NULL, NULL };
 
47
 
 
48
static int set_devfile(resource_value_t v, void *param)
 
49
{
 
50
    util_string_set(&devfile[(int)param], (const char *)v);
 
51
    return 0;
 
52
}
 
53
 
 
54
/* ------------------------------------------------------------------------- */
 
55
 
 
56
static const resource_t resources[] = {
 
57
    { "RsDevice1", RES_STRING, (resource_value_t)ARCHDEP_RS232_DEV1,
 
58
      (void *)&devfile[0], set_devfile, (void *)0 },
 
59
    { "RsDevice2", RES_STRING, (resource_value_t)ARCHDEP_RS232_DEV2,
 
60
      (void *)&devfile[1], set_devfile, (void *)1 },
 
61
    { "RsDevice3", RES_STRING, (resource_value_t)ARCHDEP_RS232_DEV3,
 
62
      (void *)&devfile[2], set_devfile, (void *)2 },
 
63
    { "RsDevice4", RES_STRING, (resource_value_t)ARCHDEP_RS232_DEV4,
 
64
      (void *)&devfile[3], set_devfile, (void *)3 },
 
65
    { NULL }
 
66
};
 
67
 
 
68
int rs232drv_resources_init(void)
 
69
{
 
70
    if (resources_register(resources) < 0)
 
71
        return -1;
 
72
 
 
73
    return rs232_resources_init();
 
74
}
 
75
 
 
76
void rs232drv_resources_shutdown(void)
 
77
{
 
78
    lib_free(devfile[0]);
 
79
    lib_free(devfile[1]);
 
80
    lib_free(devfile[2]);
 
81
    lib_free(devfile[3]);
 
82
 
 
83
    rs232_resources_shutdown();
 
84
}
 
85
 
 
86
#ifdef HAS_TRANSLATION
 
87
static const cmdline_option_t cmdline_options[] = {
 
88
    { "-rsdev1", SET_RESOURCE, 1, NULL, NULL, "RsDevice1", NULL,
 
89
      IDCLS_P_NAME, IDCLS_SPECIFY_RS232_1_NAME },
 
90
    { "-rsdev2", SET_RESOURCE, 1, NULL, NULL, "RsDevice2", NULL,
 
91
      IDCLS_P_NAME, IDCLS_SPECIFY_RS232_2_NAME },
 
92
    { "-rsdev3", SET_RESOURCE, 1, NULL, NULL, "RsDevice3", NULL,
 
93
      IDCLS_P_NAME, IDCLS_SPECIFY_RS232_3_NAME },
 
94
    { "-rsdev4", SET_RESOURCE, 1, NULL, NULL, "RsDevice4", NULL,
 
95
      IDCLS_P_NAME, IDCLS_SPECIFY_RS232_4_NAME },
 
96
    { NULL }
 
97
};
 
98
#else
 
99
static const cmdline_option_t cmdline_options[] = {
 
100
    { "-rsdev1", SET_RESOURCE, 1, NULL, NULL, "RsDevice1", NULL,
 
101
      N_("<name>"), N_("Specify name of first RS232 device") },
 
102
    { "-rsdev2", SET_RESOURCE, 1, NULL, NULL, "RsDevice2", NULL,
 
103
      N_("<name>"), N_("Specify name of second RS232 device") },
 
104
    { "-rsdev3", SET_RESOURCE, 1, NULL, NULL, "RsDevice3", NULL,
 
105
      N_("<name>"), N_("Specify name of third RS232 device") },
 
106
    { "-rsdev4", SET_RESOURCE, 1, NULL, NULL, "RsDevice4", NULL,
 
107
      N_("<name>"), N_("Specify name of fourth RS232 device") },
 
108
    { NULL }
 
109
};
 
110
#endif
 
111
 
 
112
int rs232drv_cmdline_options_init(void)
 
113
{
 
114
    if (cmdline_register_options(cmdline_options) < 0)
 
115
        return -1;
 
116
 
 
117
    return rs232_cmdline_options_init();
 
118
}
 
119
 
36
120
void rs232drv_init(void)
37
121
{
38
122
    rs232_init();
63
147
    return rs232_getc(fd, b);
64
148
}
65
149
 
66
 
int rs232drv_resources_init(void)
67
 
{
68
 
    return rs232_resources_init();
69
 
}
70
 
 
71
 
void rs232drv_resources_shutdown(void)
72
 
{
73
 
    rs232_resources_shutdown();
74
 
}
75
 
 
76
 
int rs232drv_cmdline_options_init(void)
77
 
{
78
 
    return rs232_cmdline_options_init();
79
 
}
80
 
 
81
150
#else
82
151
 
83
152
void rs232drv_init(void)