void tcpmsg_add_field(char **buf, string name, const char* value) { int field_len = strlen(name) + strlen(value) + 1; /* Count the = sign as well */ memcpy(*buf,(char*)&field_len, 4); SPRINT(*buf + 4,"%s=%s", name, value); *buf += field_len + 4; }
static CXXRCONST char* name_value_search(const char *name, const name_value table[], const int table_count) { int min, mid, max; #if defined(DEBUG_TEST) static last; DPRINT(last); last = 0; #endif min = 0; max = table_count - 1; if ( 0 > strcmp(name,table[min].name) || 0 < strcmp(name,table[max].name) ) { #if defined(DEBUG_TEST) && DEBUG_TEST > 1 DPRINT(strcmp(name, table[min].name)); DPRINT(strcmp(name, table[max].name)); #endif return (nullptr); } while (max >= min) { #if defined(DEBUG_TEST) last++; #endif mid = (min + max) / 2; #if defined(DEBUG_TEST) && DEBUG_TEST > 1 SPRINT(table[mid].name); #endif if (0 < strcmp(name,table[mid].name)) { #if defined(DEBUG_TEST) && DEBUG_TEST > 1 DPRINT(strcmp(name, table[mid].name)); #endif min = mid + 1; } else if (0 > strcmp(name, table[mid].name)) { #if defined(DEBUG_TEST) && DEBUG_TEST > 1 DPRINT(strcmp(name, table[mid].name)); #endif max = mid - 1; } else { #if defined(DEBUG_TEST) && DEBUG_TEST > 1 DPRINT(strcmp(name, table[mid].name)); #endif return(table[mid].value); } } return (nullptr); }
void xmlmsg_init(string msg) { SPRINT(msg, "<?xml version=\"1.0\"?>\n"); }
void xmlmsg_close_tag(string msg, string tag) { SPRINT(msg + strlen(msg), "</%s>\n", tag); }
void xmlmsg_add_tag_with_uint(string msg, string tag, unsigned int value) { SPRINT(msg + strlen(msg), "<%s>%u</%s>\n", tag, value, tag); }
void xmlmsg_add_tag_with_string(string msg, string tag, string value) { SPRINT(msg + strlen(msg), "<%s>%s</%s>\n", tag, value, tag); }
void xmlmsg_open_tag(string msg, string tag) { SPRINT(msg + strlen(msg), "<%s>\n", tag); }
static ssize_t mdss_mdp_show_capabilities(struct device *dev, struct device_attribute *attr, char *buf) { struct mdss_data_type *mdata = dev_get_drvdata(dev); size_t len = PAGE_SIZE; int cnt = 0; #define SPRINT(fmt, ...) \ (cnt += scnprintf(buf + cnt, len - cnt, fmt, ##__VA_ARGS__)) SPRINT("mdp_version=5 hw_rev=%d\n", mdata->mdp_rev); SPRINT("rgb_pipes=%d\n", mdata->nrgb_pipes); SPRINT("vig_pipes=%d\n", mdata->nvig_pipes); SPRINT("dma_pipes=%d\n", mdata->ndma_pipes); SPRINT("smp_count=%d\n", mdata->smp_mb_cnt); SPRINT("smp_size=%d\n", mdata->smp_mb_size); SPRINT("max downscale ratio=%d\n", MAX_DOWNSCALE_RATIO); SPRINT("max upscale ratio=%d\n", MAX_UPSCALE_RATIO); SPRINT("features:"); if (mdata->has_bwc) SPRINT(" bwc"); if (mdata->has_decimation) SPRINT(" decimation"); SPRINT("\n"); return cnt; }
main() { int i; i=0; setlocale(LC_CTYPE,""); DPRINT(guess_count); #ifndef Win32 SPRINT(locale2charset(NULL)); SPRINT(locale2charset("ja")); SPRINT(locale2charset("ja_JP")); SPRINT(locale2charset("ja_JP.eucJP")); SPRINT(locale2charset("ja_JP.ujis")); SPRINT(locale2charset("ja_JP.IBM-eucJP")); SPRINT(locale2charset("ja_JP.sjis")); SPRINT(locale2charset("ja_JP.IBM-932")); /* cannot encoding only zh */ SPRINT(locale2charset("zh""\0""BIG5")); SPRINT(locale2charset("zh_CN")); SPRINT(locale2charset("zh_CN.BIG5")); SPRINT(locale2charset("zh_TW")); SPRINT(locale2charset("zh_TW.eucTW")); SPRINT(locale2charset("zh_TW.big5")); SPRINT(locale2charset("zh_SG")); SPRINT(locale2charset("zh_HK")); SPRINT(locale2charset("ko")); SPRINT(locale2charset("en")); SPRINT(locale2charset("en_IE@euro")); SPRINT(locale2charset("en_IN")); SPRINT(locale2charset("C")); SPRINT(locale2charset("fran""\xe7""ais")); for(i=0;i<guess_count;i++){ locale2charset(guess[i].name); } #else SPRINT(locale2charset("japanese_JAPAN.932")); SPRINT(locale2charset("japanese_JAPAN.932")); #endif }
/* epoint sends a message to a join * */ void JoinPBX::message_epoint(unsigned int epoint_id, int message_type, union parameter *param) { class Join *cl; struct join_relation *relation, *reltemp; int num; int new_state; struct lcr_msg *message; // int size, writesize, oldpointer; char *number, *numbers; if (!epoint_id) { PERROR("software error, epoint == NULL\n"); return; } // if (options.deb & DEBUG_JOIN) { // PDEBUG(DEBUG_JOIN, "message %d received from ep%d.\n", message, epoint->ep_serial); // joinpbx_debug(join,"Join::message_epoint"); // } if (options.deb & DEBUG_JOIN) { if (message_type) { cl = join_first; while(cl) { if (cl->j_type == JOIN_TYPE_PBX) joinpbx_debug((class JoinPBX *)cl, "Join::message_epoint{all joins before processing}"); cl = cl->next; } } } /* check relation */ relation = j_relation; while(relation) { if (relation->epoint_id == epoint_id) break; relation = relation->next; } if (!relation) { PDEBUG(DEBUG_JOIN, "no relation back to the endpoint found, ignoring (join=%d, endpoint=%d)\n", j_serial, epoint_id); return; } /* count relations */ num=joinpbx_countrelations(j_serial); /* process party line */ if (message_type == MESSAGE_SETUP) if (param->setup.partyline && !j_partyline) { j_partyline = param->setup.partyline; j_partyline_jingle = param->setup.partyline_jingle; } if (j_partyline) { switch(message_type) { case MESSAGE_SETUP: PDEBUG(DEBUG_JOIN, "respsone with connect in partyline mode.\n"); relation->type = RELATION_TYPE_CONNECT; message = message_create(j_serial, epoint_id, JOIN_TO_EPOINT, MESSAGE_CONNECT); SPRINT(message->param.connectinfo.id, "%d", j_partyline); message->param.connectinfo.ntype = INFO_NTYPE_UNKNOWN; message_put(message); trigger_work(&j_updatebridge); if (j_partyline_jingle) play_jingle(1); break; case MESSAGE_AUDIOPATH: PDEBUG(DEBUG_JOIN, "join received channel message: %d.\n", param->audiopath); if (relation->channel_state != param->audiopath) { relation->channel_state = param->audiopath; trigger_work(&j_updatebridge); if (options.deb & DEBUG_JOIN) joinpbx_debug(this, "Join::message_epoint{after setting new channel state}"); } break; /* track notify */ case MESSAGE_NOTIFY: switch(param->notifyinfo.notify) { case INFO_NOTIFY_USER_SUSPENDED: case INFO_NOTIFY_USER_RESUMED: case INFO_NOTIFY_REMOTE_HOLD: case INFO_NOTIFY_REMOTE_RETRIEVAL: case INFO_NOTIFY_CONFERENCE_ESTABLISHED: case INFO_NOTIFY_CONFERENCE_DISCONNECTED: new_state = track_notify(relation->rx_state, param->notifyinfo.notify); if (new_state != relation->rx_state) { relation->rx_state = new_state; trigger_work(&j_updatebridge); if (options.deb & DEBUG_JOIN) joinpbx_debug(this, "Join::message_epoint{after setting new rx state}"); } break; } break; case MESSAGE_DISCONNECT: PDEBUG(DEBUG_JOIN, "releasing after receiving disconnect, because join in partyline mode.\n"); message = message_create(j_serial, epoint_id, JOIN_TO_EPOINT, MESSAGE_RELEASE); message->param.disconnectinfo.cause = CAUSE_NORMAL; message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL; message_put(message); // fall through case MESSAGE_RELEASE: PDEBUG(DEBUG_JOIN, "releasing from join\n"); release(relation, 0, 0); if (j_partyline_jingle) play_jingle(0); break; default: PDEBUG(DEBUG_JOIN, "ignoring message, because join in partyline mode.\n"); } return; } /* process messages */ switch(message_type) { /* process audio path message */ case MESSAGE_AUDIOPATH: PDEBUG(DEBUG_JOIN, "join received channel message: audiopath=%d, current relation's channel_state=%d\n", param->audiopath, relation->channel_state); if (relation->channel_state != param->audiopath) { relation->channel_state = param->audiopath; trigger_work(&j_updatebridge); if (options.deb & DEBUG_JOIN) joinpbx_debug(this, "Join::message_epoint{after setting new channel state}"); } return; /* track notify */ case MESSAGE_NOTIFY: switch(param->notifyinfo.notify) { case INFO_NOTIFY_USER_SUSPENDED: case INFO_NOTIFY_USER_RESUMED: case INFO_NOTIFY_REMOTE_HOLD: case INFO_NOTIFY_REMOTE_RETRIEVAL: case INFO_NOTIFY_CONFERENCE_ESTABLISHED: case INFO_NOTIFY_CONFERENCE_DISCONNECTED: new_state = track_notify(relation->rx_state, param->notifyinfo.notify); if (new_state != relation->rx_state) { relation->rx_state = new_state; trigger_work(&j_updatebridge); if (options.deb & DEBUG_JOIN) joinpbx_debug(this, "Join::message_epoint{after setting new rx state}"); } break; default: /* send notification to all other endpoints */ reltemp = j_relation; while(reltemp) { if (reltemp->epoint_id!=epoint_id && reltemp->epoint_id) { message = message_create(j_serial, reltemp->epoint_id, JOIN_TO_EPOINT, MESSAGE_NOTIFY); memcpy(&message->param, param, sizeof(union parameter)); message_put(message); } reltemp = reltemp->next; } } return; /* relations sends a connect */ case MESSAGE_CONNECT: /* outgoing setup type becomes connected */ if (relation->type == RELATION_TYPE_SETUP) relation->type = RELATION_TYPE_CONNECT; /* release other relations in setup state */ release_again: reltemp = j_relation; while(reltemp) { //printf("connect, checking relation %d\n", reltemp->epoint_id); if (reltemp->type == RELATION_TYPE_SETUP) { //printf("relation %d is of type setup, releasing\n", reltemp->epoint_id); /* send release to endpoint */ message = message_create(j_serial, reltemp->epoint_id, JOIN_TO_EPOINT, MESSAGE_RELEASE); message->param.disconnectinfo.cause = CAUSE_NONSELECTED; message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL; message_put(message); if (release(reltemp, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL)) // dummy cause, should not be used, since calling and connected endpoint still exist afterwards. return; // must return, because join IS destroyed goto release_again; } if (reltemp->type == RELATION_TYPE_CALLING) reltemp->type = RELATION_TYPE_CONNECT; reltemp = reltemp->next; } break; // continue with our message /* release is sent by endpoint */ case MESSAGE_RELEASE: switch(relation->type) { case RELATION_TYPE_SETUP: /* by called */ /* collect cause and send collected cause */ collect_cause(&j_multicause, &j_multilocation, param->disconnectinfo.cause, param->disconnectinfo.location); if (j_multicause) release(relation, j_multilocation, j_multicause); else release(relation, LOCATION_PRIVATE_LOCAL, CAUSE_UNSPECIFIED); break; case RELATION_TYPE_CALLING: /* by calling */ /* remove us, if we don't have a called releation yet */ if (!j_relation->next) { release(j_relation, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); return; // must return, because join IS destroyed } /* in a conf, we don't kill the other members */ if (num > 2 && !joinpbx_onecalling_othersetup(j_relation)) { release(relation, 0, 0); return; } /* remove all relations that are of called type */ release_again2: reltemp = j_relation; while(reltemp) { if (reltemp->type == RELATION_TYPE_SETUP) { /* send release to endpoint */ message = message_create(j_serial, reltemp->epoint_id, JOIN_TO_EPOINT, message_type); memcpy(&message->param, param, sizeof(union parameter)); message_put(message); if (release(reltemp, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL)) return; // must return, because join IS destroyed goto release_again2; } reltemp = reltemp->next; } PERROR("we are still here, this should not happen\n"); break; default: /* by connected */ /* send current cause */ release(relation, param->disconnectinfo.location, param->disconnectinfo.cause); } return; // must return, because join may be destroyed } /* check number of relations */ if (num > 2 && !joinpbx_onecalling_othersetup(j_relation) && message_type != MESSAGE_CONNECT) { PDEBUG(DEBUG_JOIN, "we are in a conference, so we ignore the messages, except MESSAGE_CONNECT.\n"); return; } /* if join has no other relation, we process the setup message */ if (num == 1) { switch(message_type) { case MESSAGE_SETUP: if (param->setup.dialinginfo.itype == INFO_ITYPE_ISDN_EXTENSION) { /* in case of keypad */ numbers = param->setup.dialinginfo.keypad; if (numbers[0]) { while((number = strsep(&numbers, ","))) { if (out_setup(epoint_id, message_type, param, NULL, number)) return; // join destroyed } /* after keypad finish dialing */ break; } /* dialed number */ numbers = param->setup.dialinginfo.id; while((number = strsep(&numbers, ","))) { if (out_setup(epoint_id, message_type, param, number, NULL)) return; // join destroyed } break; } if (out_setup(epoint_id, message_type, param, param->setup.dialinginfo.id, param->setup.dialinginfo.keypad)) return; // join destroyed break; default: PDEBUG(DEBUG_JOIN, "no need to send a message because there is no other endpoint than the calling one.\n"); } } else { /* sending message to other relation(s) */ relation = j_relation; while(relation) { if (relation->epoint_id != epoint_id) { PDEBUG(DEBUG_JOIN, "sending message ep%ld -> ep%ld.\n", epoint_id, relation->epoint_id); message = message_create(j_serial, relation->epoint_id, JOIN_TO_EPOINT, message_type); memcpy(&message->param, param, sizeof(union parameter)); message_put(message); PDEBUG(DEBUG_JOIN, "message sent.\n"); } relation = relation->next; } } }
string uri_get_rosrpc_string(uri_t* uri) { string res = (char*)calloc(sizeof(char), MAX_URI_STRING_LEN); SPRINT(res, "rosrpc://%s:%u/", uri->ip, uri->port); return res; }