void SipInviteBuilding(char* SendMsg,struct connect_info *ihostinfo) { int j,bp; j=sprintf(SendMsg,"%s sip:%s %s\r\n","INVITE",ihostinfo->targetip,ihostinfo->sipversion); j+=sprintf(SendMsg+j,"%s: %s/%s %s:%s\r\n","Via",ihostinfo->sipversion,ihostinfo->baseproto,ihostinfo->hostip,ihostinfo->hostport); j+=sprintf(SendMsg+j,"%s: %s\r\n","Max-Forwards",ihostinfo->maxforwards); j+=sprintf(SendMsg+j,"%s: \"%s\" <sip:%s>;tag=%s\r\n","From",ihostinfo->username,ihostinfo->hostname,ihostinfo->tag); j+=sprintf(SendMsg+j,"%s: <sip:%s>\r\n","To",ihostinfo->targetip); j+=sprintf(SendMsg+j,"%s: %s@%s\r\n","Call-ID",ihostinfo->callid,ihostinfo->hostip); j+=sprintf(SendMsg+j,"%s: 1 %s\r\n","CSeq","INVITE"); j+=sprintf(SendMsg+j,"%s: <sip:%s:%s>\r\n","Contact",ihostinfo->hostip,ihostinfo->hostport); j+=sprintf(SendMsg+j,"%s: %s\r\n","User-Agent",ihostinfo->agent); j+=sprintf(SendMsg+j,"%s: %s\r\n","Content-Type",ihostinfo->proto); j+=sprintf(SendMsg+j,"%s: %s\r\n\r\n","Content-Length"," "); bp=j; j=SdpInviteBuilding(SendMsg,ihostinfo,j); Int2String(SendMsg+bp-7,j-bp); }
std::string& HttpHeader::Encode(std::string& strData) { if (m_bRequest) { strData = m_strMethod + " " + (m_strUrl.empty()? "/" : m_strUrl) + " HTTP/" + m_strVersion + "\r\n"; } else { strData = std::string("HTTP/") + m_strVersion + " " + Int2String(m_nRespCode) + " " + GetRespCodeString(m_nRespCode) + "\r\n"; } for (int i = 0; i < m_nItemArray.size(); ++i) { const HttpHeaderItem& n = m_nItemArray[i]; strData += n.m_strName + ": " + n.m_strValue + "\r\n"; } strData += "\r\n"; return strData; }
void SipOKBuilding(char* SendMsg,struct connect_info *ihostinfo,struct sip_packet *packeta,struct sdp_packet *packetb) { int j,bp; j=sprintf(SendMsg,"%s %d %s\r\n",ihostinfo->sipversion,OK,"OK"); j+=sprintf(SendMsg+j,"%s: %s %s:%s\r\n","Via",packeta->via.protocol,packeta->via.hostaddr,packeta->via.hostport); j+=sprintf(SendMsg+j,"%s: \"%s\" <%s>;tag=%s\r\n","From",packeta->from.display_name,packeta->from.URI,packeta->from.tag); j+=sprintf(SendMsg+j,"%s: \"%s\" <sip:%s>;tag=%s\r\n","To",ihostinfo->username,ihostinfo->hostip,ihostinfo->tag); j+=sprintf(SendMsg+j,"%s: %s@%s\r\n","Call-ID",packeta->call_id.id,packeta->call_id.URI); j+=sprintf(SendMsg+j,"%s: %s %s\r\n","CSeq",packeta->cseq.value,packeta->cseq.method); if(!strcmp(packeta->cseq.method,"INVITE")) { j+=sprintf(SendMsg+j,"%s: <sip:%s:%s>\r\n","Contact",ihostinfo->hostip,ihostinfo->hostport); j+=sprintf(SendMsg+j,"%s: %s\r\n","User-Agent",ihostinfo->agent); j+=sprintf(SendMsg+j,"%s: %s\r\n","Content-Type",ihostinfo->proto); j+=sprintf(SendMsg+j,"%s: %s\r\n\r\n","Content-Length"," "); bp=j; j=SdpOKBuilding(SendMsg,ihostinfo,packeta,packetb,j); Int2String(SendMsg+bp-7,j-bp); } if(!strcmp(packeta->cseq.method,"BYE")) { j+=sprintf(SendMsg+j,"%s: %s\r\n","User-Agent",ihostinfo->agent); j+=sprintf(SendMsg+j,"%s: %s\r\n\r\n","Content-Length","0"); } }
flag Xer_EncodeInteger(ByteStream* pByteStrm, const char* elementTag, asn1SccSint value, int *pErrCode, int level) { return Xer_EncodePrimitiveElement(pByteStrm, elementTag, Int2String(value), pErrCode, level); }
bool FM_GetNameForNewFile(char name[255]) { char buffer[20]; static int number = 0; strcpy(name, currentDir); strcat(name, "\\"); int size = strlen(set.memory.fileName); if (size == 0) { return false; } if (set.memory.fileNamingMode == FileNamingMode_Manually) { LIMITATION(size, size, 1, 95); strcat(name, set.memory.fileName); strcat(name, "."); strcat(name, set.memory.modeSaveSignal == ModeSaveSignal_BMP ? "bmp" : "txt"); return true; } else { PackedTime time = RTC_GetPackedTime(); // 1 2 3 4 5 6 int values[] = {0, time.year, time.month, time.day, time.hours, time.minutes, time.seconds}; char *ch = set.memory.fileNameMask; char *wr = name; while (*wr != '\0') { wr++; } while (*ch) { if (*ch >= 0x30) { *wr = *ch; wr++; } else { if (*ch == 0x07) { number++; strcpy(wr, Int2String(number, false, *(ch + 1), buffer)); wr += strlen(buffer); ch++; } else { if (*ch >= 0x01 && *ch <= 0x06) { strcpy(wr, Int2String(values[*ch], false, 2, buffer)); wr += strlen(buffer); } } } ch++; } *wr = '.'; *(wr + 1) = '\0'; strcat(name, set.memory.modeSaveSignal == ModeSaveSignal_BMP ? "bmp" : "txt"); return true; } }