// public API, inits stream instance; a particular namespace is to be
// used with Jabber, see the constant defined in the public header
// 
// note that interestingly, the mainline version allocates both an
// iksparser and stream_data, but returns the parser rather than
// stream_data -- perhaps the idea is to provide the parsing interface
// regardless of what the data source is, just creating a different
// kind of parser
ikss_Stream *
ikss_Stream_new (char *name_space, void *user_data, iksStreamHook *streamHook, ikss_NotifyFunc* notifyFunc)
{
  ikss_Stream *self;
  ikstack *s;

  s = iks_stack_new (DEFAULT_STREAM_CHUNK_SIZE, 0);
  if (NULL == s) return NULL;

  self = iks_stack_alloc (s, sizeof (ikss_Stream));
  if (!self) {
    iks_stack_delete(s);
    return NULL;
  }
  memset (self, 0, sizeof (ikss_Stream));

  self->s = s;

  // This creates the parser, placing the object into "s" memory. Note
  // that self->prs now takes ownership of "s", and iks_parser_delete
  // will delete it.
  self->prs = iks_sax_extend (s, self, (iksTagHook *)tagHook, (iksCDataHook *)cdataHook, (iksDeleteHook *)deleteHook);
  if (!self->prs) {
    iks_stack_delete(s);
    return NULL;
  }

  self->name_space = name_space;
  self->user_data = user_data;
  self->streamHook = streamHook;
  self->notifyFunc = notifyFunc;

  return self;
}
Beispiel #2
0
/**
 * Process <audio>- this is a URL to play
 */
static int process_audio(struct ssml_parser *parsed_data, char **atts)
{
	if (atts) {
		int i = 0;
		while (atts[i]) {
			if (!strcmp("src", atts[i])) {
				char *src = atts[i + 1];
				ikstack *stack = NULL;
				if (!zstr(src) && parsed_data->num_files < parsed_data->max_files) {
					/* get the URI */
					if (strchr(src, '&')) {
						stack = iks_stack_new(256, 0);
						src = iks_unescape(stack, src, strlen(src));
					}
					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding <audio>: \"%s\"\n", src);
					parsed_data->files[parsed_data->num_files].name = switch_core_strdup(parsed_data->pool, src);
					parsed_data->files[parsed_data->num_files++].prefix = NULL;
					if (stack) {
						iks_stack_delete(&stack);
					}
				}
				return IKS_OK;
			}
			i += 2;
		}
	}
	return IKS_OK;
}
Beispiel #3
0
void
iks_parser_delete (iksparser *prs)
{
	if (prs->deleteHook) prs->deleteHook (prs->user_data);
	if (prs->stack) iks_free (prs->stack);
	if (prs->atts) iks_free (prs->atts);
	if (prs->s) iks_stack_delete (prs->s); else iks_free (prs);
}
Beispiel #4
0
iks *
iks_new (const char *name)
{
	ikstack *s;
	iks *x;

	s = iks_stack_new (sizeof (struct iks_tag) * 6, 256);
	if (!s) return NULL;
	x = iks_new_within (name, s);
	if (!x) {
		iks_stack_delete (s);
		return NULL;
	}
	return x;
}
Beispiel #5
0
int main (int argc, char *argv[])
{
	my_stack = iks_stack_new (1024, 1024);

	test_id ("jabber:[email protected]/cabbar", "*****@*****.**", "madcat", "jabber.org", "cabbar");
	test_id ("*****@*****.**", "*****@*****.**", "bob", "silent.org", NULL);

	test_cmp ("[email protected]/hell", "[email protected]/heaven", IKS_ID_PARTIAL, 0);
	test_cmp ("[email protected]/cabbar", "[email protected]/jabberx", IKS_ID_FULL, IKS_ID_RESOURCE);
	test_cmp ("[email protected]/pda", "[email protected]/jabberx", IKS_ID_FULL, IKS_ID_USER | IKS_ID_RESOURCE);
	test_cmp ("[email protected]/gabber", "[email protected]/gsm", IKS_ID_FULL, IKS_ID_FULL);
	test_cmp ("*****@*****.**", "[email protected]/clam", IKS_ID_PARTIAL, 0);

	iks_stack_delete (my_stack);

	return 0;
}
Beispiel #6
0
		Stack::~Stack()
		{
			iks_stack_delete( this->stack );
		}
Beispiel #7
0
void
iks_delete (iks *x)
{
	if (x) iks_stack_delete (x->s);
}