Merge pull request #19 from nspaseski/master
[deliverable/titan.core.git] / hello / PCOType.cc
CommitLineData
970ed795 1///////////////////////////////////////////////////////////////////////////////
3abe9331 2// Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
3// All rights reserved. This program and the accompanying materials
4// are made available under the terms of the Eclipse Public License v1.0
5// which accompanies this distribution, and is available at
6// http://www.eclipse.org/legal/epl-v10.html
7///////////////////////////////////////////////////////////////////////////////
8// This Test Port skeleton source file was generated by the
9// TTCN-3 Compiler of the TTCN-3 Test Executor version CRL 113 200/4 R2A
10// for Arpad Lovassy (earplov@esekilxxen1841) on Tue Jul 22 16:49:55 2014
11// You may modify this file. Complete the body of empty functions and
12// add your member functions here.
13
14#include "PCOType.hh"
15#include "memory.h"
16
17#include <stdio.h>
18
19namespace MyExample {
20
21PCOType::PCOType(const char *par_port_name)
22 : PCOType_BASE(par_port_name)
23{
24
25}
26
27PCOType::~PCOType()
28{
29
30}
31
32void PCOType::set_parameter(const char * /*parameter_name*/,
33 const char * /*parameter_value*/)
34{
35
36}
37
38void PCOType::Event_Handler(const fd_set *read_fds,
39 const fd_set *write_fds, const fd_set *error_fds,
40 double time_since_last_call)
41{
42 size_t buf_len = 0, buf_size = 32;
43 char *buf = (char*)Malloc(buf_size);
44 for ( ; ; ) {
45 int c = getc(stdin);
46 if (c == EOF) {
47 if (buf_len > 0) incoming_message(CHARSTRING(buf_len, buf));
48 Uninstall_Handler();
49 break;
50 } else if (c == '\n') {
51 incoming_message(CHARSTRING(buf_len, buf));
52 break;
53 } else {
54 if (buf_len >= buf_size) {
55 buf_size *= 2;
56 buf = (char*)Realloc(buf, buf_size);
57 }
58 buf[buf_len++] = c;
59 }
60 }
61 Free(buf);
62}
63
64/*void PCOType::Handle_Fd_Event(int fd, boolean is_readable,
65 boolean is_writable, boolean is_error) {}*/
66
67void PCOType::Handle_Fd_Event_Error(int /*fd*/)
68{
69
70}
71
72void PCOType::Handle_Fd_Event_Writable(int /*fd*/)
73{
74
75}
76
77void PCOType::Handle_Fd_Event_Readable(int /*fd*/)
78{
79
80}
81
82/*void PCOType::Handle_Timeout(double time_since_last_call) {}*/
83
84void PCOType::user_map(const char *system_port)
85{
86 fd_set readfds;
87 FD_ZERO(&readfds);
88 FD_SET(fileno(stdin), &readfds);
89 Install_Handler(&readfds, NULL, NULL, 0.0);
90}
91
92void PCOType::user_unmap(const char *system_port)
93{
94 Uninstall_Handler();
95}
96
97void PCOType::user_start()
98{
99
100}
101
102void PCOType::user_stop()
103{
104
105}
106
107void PCOType::outgoing_send(const CHARSTRING& send_par)
108{
109 puts((const char*)send_par);
110 fflush(stdout);
111}
112
113} /* end of namespace */
114
This page took 0.027025 seconds and 5 git commands to generate.