| 82 | |
| 83 | |
| 84 | int parse_destination_list(rt_data_t* rd, char *dstlist, pgw_list_t** pgwl_ret, |
| 85 | unsigned short *len, int no_resize, osips_malloc_f mf) |
| 86 | { |
| 87 | #define PGWL_SIZE 32 |
| 88 | pgw_list_t *pgwl=NULL, *p = NULL; |
| 89 | unsigned int size, pgwl_size; |
| 90 | long int t; |
| 91 | char *tmp, *ep; |
| 92 | str id; |
| 93 | |
| 94 | |
| 95 | /* temporary list of gw while parsing */ |
| 96 | pgwl_size = PGWL_SIZE; |
| 97 | pgwl = (pgw_list_t*)pkg_malloc(pgwl_size*sizeof(pgw_list_t)); |
| 98 | if (pgwl==NULL) { |
| 99 | LM_ERR("no more shm mem\n"); |
| 100 | goto error; |
| 101 | } |
| 102 | memset(pgwl, 0, pgwl_size*sizeof(pgw_list_t)); |
| 103 | |
| 104 | /* parset the destination list */ |
| 105 | tmp = dstlist; |
| 106 | size = 0; |
| 107 | /* parse the dstlst */ |
| 108 | while(tmp && (*tmp!=0)) { |
| 109 | |
| 110 | /* need a larger array ? */ |
| 111 | if(size>=pgwl_size){ |
| 112 | p=(pgw_list_t*)pkg_malloc((pgwl_size*2)*sizeof(pgw_list_t)); |
| 113 | if (p==NULL) { |
| 114 | LM_ERR("not enough shm mem to resize\n"); |
| 115 | goto error; |
| 116 | } |
| 117 | memset( p+pgwl_size, 0, pgwl_size*sizeof(pgw_list_t)); |
| 118 | memcpy( p, pgwl, pgwl_size*sizeof(pgw_list_t)); |
| 119 | pkg_free(pgwl); |
| 120 | pgwl_size*=2; |
| 121 | pgwl=p; |
| 122 | } |
| 123 | |
| 124 | /* go over spaces */ |
| 125 | EAT_SPACE(tmp); |
| 126 | |
| 127 | /* carrier id or GW id ? */ |
| 128 | if (*tmp==CARRIER_MARKER) { |
| 129 | pgwl[size].is_carrier = 1; |
| 130 | tmp++; |
| 131 | } |
| 132 | |
| 133 | /* eat the destination ID (alphanumerical) */ |
| 134 | id.s = tmp; |
| 135 | while( *tmp && is_valid_gw_char(*tmp)) |
| 136 | tmp++; |
| 137 | if (id.s == tmp) { |
| 138 | LM_ERR("bad id '%c' (%d)[%s]\n", |
| 139 | *tmp, (int)(tmp-dstlist), dstlist); |
| 140 | goto error; |
| 141 | } |
no test coverage detected