| 147 | |
| 148 | |
| 149 | ipc_handler_type ipc_register_handler( ipc_handler_f *hdl, char *name) |
| 150 | { |
| 151 | ipc_handler *new; |
| 152 | |
| 153 | /* allocate an n+1 new buffer to accomodate the new handler */ |
| 154 | new = (ipc_handler*) |
| 155 | pkg_malloc( (ipc_handlers_no+1)*sizeof(ipc_handler) ); |
| 156 | if (new==NULL) { |
| 157 | LM_ERR("failed to alloctes IPC handler array for size %d\n", |
| 158 | ipc_handlers_no+1); |
| 159 | return -1; |
| 160 | } |
| 161 | |
| 162 | /* copy previous records, if any */ |
| 163 | if (ipc_handlers) { |
| 164 | memcpy( new, ipc_handlers, ipc_handlers_no*sizeof(ipc_handler) ); |
| 165 | pkg_free( ipc_handlers ); |
| 166 | } |
| 167 | |
| 168 | /* copy handler function */ |
| 169 | new[ipc_handlers_no].func = hdl; |
| 170 | |
| 171 | /* copy the name, trunkate it needed, but keep it null terminated */ |
| 172 | strncpy( new[ipc_handlers_no].name , name, IPC_HANDLER_NAME_MAX); |
| 173 | new[ipc_handlers_no].name[IPC_HANDLER_NAME_MAX] = 0; |
| 174 | |
| 175 | ipc_handlers = new; |
| 176 | |
| 177 | LM_DBG("IPC type %d [%s] registered with handler %p\n", |
| 178 | ipc_handlers_no, ipc_handlers[ipc_handlers_no].name, hdl ); |
| 179 | |
| 180 | return ipc_handlers_no++; |
| 181 | } |
| 182 | |
| 183 | |
| 184 | static inline int __ipc_send_job(int fd, int dst_proc, ipc_handler_type type, |
no outgoing calls
no test coverage detected