Exemplo n.º 1
0
int main()
{
    // Structures may be initialized at declaration time by putting
    // the list of elements in curly braces.
    struct complex_number c1 = {1.0, 1.0};
    struct complex_number c2;
    c2.re = 2.0;
    c2.im = 4.0;

    printf("c1 = (%f,%f)\n", c1.re, c1.im);
    printf("c2 = (%f,%f)\n", c2.re, c2.im);

    struct complex_number result = complex_add(c1,c2);
    printf("c1 + c2 = (%f,%f)\n", result.re, result.im);

    struct complex_number *c_ptr;
    c_ptr = (struct complex_number*)malloc(sizeof(struct complex_number)); 
    c_ptr->re = 7.0;
    c_ptr->im = -13.0;
    printf("*c_ptr = (%f,%f)\n", c_ptr->re, c_ptr->im);    
    free(c_ptr);
    
    struct time t = {12,15,3};
    time_dump(&t);
    time_init(&t);
    time_dump(&t);

	return 0;
}
Exemplo n.º 2
0
void session_dump_one (session_desc_t *sptr)
{
  int ix;
  media_desc_t *media;
  string_list_t *strptr;
  
  printf("Session name: %s\n", sptr->session_name);
  if (sptr->session_desc != NULL) {
    printf("Description: %s\n", sptr->session_desc);
  }
  if (sptr->uri != NULL) {
    printf("URI: %s\n", sptr->uri);
  }
  if (sptr->orig_username) {
    printf("Origin username: %s\n", sptr->orig_username);
  }
  printf("Session id: "D64"\nSession version: "D64"\n",
	 sptr->session_id,
	 sptr->session_version);
  if (sptr->create_addr)
    printf("Session created by: %s", sptr->create_addr);
  if (sptr->create_addr_type &&
      strcasecmp(sptr->create_addr_type, "IP4") != 0) {
    printf("address type %s", sptr->create_addr_type);
  }
  printf("\n");
  if (sptr->conf_type != CONFERENCE_TYPE_NONE) {
    printf("Conference type: %s\n",
	   sptr->conf_type < CONFERENCE_TYPE_OTHER ?
	   type_values[sptr->conf_type - 1] : sptr->conf_type_user);
  }
    
  if (sptr->keywds) printf("Keywords: %s\n", sptr->keywds);
  if (sptr->tool) printf("Tool: %s\n", sptr->tool);
  category_dump(sptr->category_list);

  strptr = sptr->admin_email;
  while (strptr != NULL) {
    printf("Admin email: %s\n", strptr->string_val);
    strptr = strptr->next;
  }
  strptr = sptr->admin_phone;
  while (strptr != NULL) {
    printf("Admin phone: %s\n", strptr->string_val);
    strptr = strptr->next;
  }
  key_dump(&sptr->key);
  time_dump(sptr->time_desc);
  time_adj_dump(sptr->time_adj_desc);
  if (sptr->session_connect.used) {
    printf("Session Address: %s", sptr->session_connect.conn_addr);
    if (strcasecmp(sptr->session_connect.conn_type, "IP4") != 0) {
      printf("(address type %s)", sptr->session_connect.conn_type);
    }
    if (sptr->session_connect.num_addr > 0) {
      printf("(%u addresses)", sptr->session_connect.num_addr);
    }
    printf("\ntSession TTL: %u\n", sptr->session_connect.ttl);
  }
  range_dump(&sptr->session_range, "");
  bandwidth_dump(sptr->session_bandwidth, "Session");
  if (sptr->control_string) {
    printf("Control: %s\n", sptr->control_string);
  }
  unparsed_dump(sptr->unparsed_a_lines, "");
  ix = 0;
  media = sptr->media;
  while (media != NULL) {

    printf("Media description %d:\n", ix + 1);
    media_dump(media);
    media = media->next;
    ix++;
  }
  if (ix == 0) {
    printf("No media descriptions for session\n");
  }
}