Audiovox P965 Scheda Tecnica Pagina 223

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 280
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 222
API in C
220
* Encode message length and write it out to the socket
********************************************************************/
void writeLen(int fdSock, int iLen)
{
char *cEncodedLength; // encoded length to send to the api socket
char *cLength; // exactly what is in memory at &iLen integer
cLength = calloc(sizeof(int), 1);
cEncodedLength = calloc(sizeof(int), 1);
// set cLength address to be same as iLen
cLength = (char *)&iLen;
DEBUG ? printf("length of word is %d\n", iLen) : 0;
// write 1 byte
if (iLen < 0x80)
{
cEncodedLength[0] = (char)iLen;
write (fdSock, cEncodedLength, 1);
}
// write 2 bytes
else if (iLen < 0x4000)
{
DEBUG ? printf("iLen < 0x4000.\n") : 0;
if (iLittleEndian)
{
cEncodedLength[0] = cLength[1] | 0x80;
cEncodedLength[1] = cLength[0];
}
else
{
cEncodedLength[0] = cLength[2] | 0x80;
cEncodedLength[1] = cLength[3];
}
write (fdSock, cEncodedLength, 2);
}
// write 3 bytes
else if (iLen < 0x200000)
{
DEBUG ? printf("iLen < 0x200000.\n") : 0;
if (iLittleEndian)
Vedere la pagina 222
1 2 ... 218 219 220 221 222 223 224 225 226 227 228 ... 279 280

Commenti su questo manuale

Nessun commento