Ejemplo n.º 1
0
int
main (int argc, char **argv)
{
    FILE *tos_file;


    osip_to_t *to;
    char *a_to;
    char *dest;
    char *res;

    tos_file = fopen (argv[1], "r");
    if (tos_file == NULL)
    {
        fprintf (stdout, "Failed to open %s file.\nUsage: tto tos.txt\n", argv[1]);
        exit (0);
    }

    a_to = (char *) osip_malloc (200);
    res = fgets (a_to, 200, tos_file);    /* lines are under 200 */
    while (res != NULL)
    {

        int errcode;

        /* remove the last '\n' before parsing */
        strncpy (a_to + strlen (a_to) - 1, "\0", 1);

        if (0 != strncmp (a_to, "#", 1))
        {
            /* allocate & init to */
            osip_to_init (&to);
            printf ("=================================================\n");
            printf ("TO TO PARSE: |%s|\n", a_to);
            errcode = osip_to_parse (to, a_to);
            if (errcode != -1)
            {
                if (osip_to_to_str (to, &dest) != -1)
                {
                    printf ("result:      |%s|\n", dest);
                    osip_free (dest);
                }
            } else
                printf ("Bad to format: %s\n", a_to);
            osip_to_free (to);
            printf ("=================================================\n");
        }
        res = fgets (a_to, 200, tos_file);        /* lines are under 200 */
    }
    osip_free (a_to);
    return 0;
}
Ejemplo n.º 2
0
/* this method can't be called unless the previous
   INVITE transaction is over. */
int
eXosip_call_build_initial_invite (osip_message_t ** invite,
                                  const char *to,
                                  const char *from,
                                  const char *route, const char *subject)
{
  int i;
  osip_to_t *_to = NULL;

  *invite = NULL;

  if (to != NULL && *to == '\0')
    return OSIP_BADPARAMETER;
  if (route != NULL && *route == '\0')
    route = NULL;
  if (subject != NULL && *subject == '\0')
    subject = NULL;

  i = osip_to_init (&_to);
  if (i != 0)
    return i;

  i = osip_to_parse (_to, to);
  if (i != 0)
    {
      osip_to_free (_to);
      return i;
    }

  i = generating_request_out_of_dialog (invite, "INVITE", to,
                                        eXosip.transport, from, route);
  osip_to_free (_to);
  if (i != 0)
    return i;
  _eXosip_dialog_add_contact (*invite, NULL);

  if (subject != NULL)
    osip_message_set_subject (*invite, subject);

  /* after this delay, we should send a CANCEL */
  osip_message_set_expires (*invite, "120");
  return OSIP_SUCCESS;
}
Ejemplo n.º 3
0
/* returns -1 on error. */
int osip_message_set_to(osip_message_t * sip, const char *hvalue)
{
	int i;

	if (hvalue == NULL || hvalue[0] == '\0')
		return OSIP_SUCCESS;

	if (sip->to != NULL)
		return OSIP_SYNTAXERROR;
	i = osip_to_init(&(sip->to));
	if (i != 0)
		return i;
	sip->message_property = 2;
	i = osip_to_parse(sip->to, hvalue);
	if (i != 0) {
		osip_to_free(sip->to);
		sip->to = NULL;
		return i;
	}
	return OSIP_SUCCESS;
}
Ejemplo n.º 4
0
int
eXosip_subscribe_build_initial_request (struct eXosip_t *excontext, osip_message_t ** sub, const char *to, const char *from, const char *route, const char *event, int expires)
{
  char tmp[10];
  int i;
  osip_to_t *_to = NULL;

  *sub = NULL;
  if (to == NULL || *to == '\0')
    return OSIP_BADPARAMETER;
  if (from == NULL || *from == '\0')
    return OSIP_BADPARAMETER;
  if (event == NULL || *event == '\0')
    return OSIP_BADPARAMETER;
  if (route == NULL || *route == '\0')
    route = NULL;

  i = osip_to_init (&_to);
  if (i != 0)
    return i;

  i = osip_to_parse (_to, to);
  if (i != 0) {
    osip_to_free (_to);
    return i;
  }

  i = _eXosip_generating_request_out_of_dialog (excontext, sub, "SUBSCRIBE", to, excontext->transport, from, route);
  osip_to_free (_to);
  if (i != 0)
    return i;
  _eXosip_dialog_add_contact (excontext, *sub, NULL);

  snprintf (tmp, 10, "%i", expires);
  osip_message_set_expires (*sub, tmp);

  osip_message_set_header (*sub, "Event", event);

  return OSIP_SUCCESS;
}
Ejemplo n.º 5
0
/* returns -1 on error. */
int
osip_message_set_to (osip_message_t * sip, const char *hvalue)
{
  int i;

  if (hvalue == NULL || hvalue[0] == '\0')
    return 0;

  if (sip->to != NULL)
    return -1;
  i = osip_to_init (&(sip->to));
  if (i != 0)
    return -1;
  sip->message_property = 2;
  i = osip_to_parse (sip->to, hvalue);
  if (i != 0)
    {
      osip_to_free (sip->to);
      sip->to = NULL;
      return -1;
    }
  return 0;
}