The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
listener.c
Go to the documentation of this file.
1 
22 #include <projectcommon.h>
23 #include <memory.h>
24 #include <glib.h>
25 #include <frame.h>
26 #include <frameset.h>
27 #include <listener.h>
30 void _listener_finalize(AssimObj * self);
32 FSTATIC void _listener_associate(Listener* self, NetGSource* source);
34 
39 #define ONESEC 1000000
40 
42 FSTATIC gboolean
44 {
45  (void)self;
46  UNREF(fs);
47  (void)addr;
48  return TRUE;
49 }
50 
52 void
54 {
55  Listener* self = CASTTOCLASS(Listener, aself);
56  UNREF(self->config);
57  self->dissociate(self);
58  memset(self, 0x00, sizeof(*self));
59  FREECLASSOBJ(self);
60 }
61 
63 FSTATIC void
65 {
66  // We kinda have to just hope that 'source' lives as long as we do...
67  self->transport = source;
68 }
69 
71 FSTATIC void
73 {
74  self->transport = NULL;
75 }
76 
77 
78 
81 Listener*
83  gsize objsize)
84 {
85  Listener * newlistener;
86  if (objsize < sizeof(Listener)) {
87  objsize = sizeof(Listener);
88  }
89  newlistener = NEWSUBCLASS(Listener, assimobj_new(objsize));
90  if (newlistener != NULL) {
91  newlistener->baseclass._finalize = _listener_finalize;
92  newlistener->got_frameset = _listener_got_frameset;
93  newlistener->associate = _listener_associate;
94  newlistener->dissociate = _listener_dissociate;
95  newlistener->config = config;
96  REF(config);
97  }
98  return newlistener;
99 }