Exemplo n.º 1
0
/* PROTO */
void
imcomm_request_awayprofile(void *handle, char *sn)
{
	pkt_t          *packet;
	struct MultiPacket *mpkt;

	mpkt = MultiPktInit();

	packet = pkt_init(3 + (uint8_t) strlen(sn));

	pkt_add16(packet, 0x0003);
	pkt_add8(packet, (uint8_t) strlen(sn));
	pkt_addraw(packet, (uint8_t *) sn, strlen(sn));

	snac_addToMulti(handle, mpkt, 0x02, 0x05, packet->data, packet->len,
			0);

	pkt_free(packet);

	packet = pkt_init(3 + (uint8_t) strlen(sn));

	pkt_add16(packet, 0x0001);
	pkt_add8(packet, (uint8_t) strlen(sn));
	pkt_addraw(packet, (uint8_t *) sn, strlen(sn));

	snac_addToMulti(handle, mpkt, 0x02, 0x05, packet->data, packet->len,
			0);
	pkt_free(packet);

	flap_sendMulti(handle, mpkt);
	MultiPktFree(mpkt);
}
Exemplo n.º 2
0
/* PROTO */
IMCOMM_RET
snac_send_cli_update(void *handle)
{
	IMCOMM_RET      ret;
	pkt_t          *pkt;

	/*
         * This makes the server send us extended status information
         */
#if 0
	pkt = pkt_init(12);
	pkt_add16(pkt, 0x001d);
	pkt_add16(pkt, 0x0008);
	pkt_add32(pkt, 0x00020404);
	pkt_add32(pkt, 0x00000000);
#endif

	pkt = pkt_init(8);
	pkt_add16(pkt, 0x0006);
	pkt_add16(pkt, 0x0004);
	if (((IMCOMM *) handle)->isinvisible)
		pkt_add32(pkt, 0x00000100);
	else
		pkt_add32(pkt, 0x00000000);

	ret = snac_sendpkt(handle, 0x01, 0x1e, pkt, 0);
	pkt_free(pkt);
	return ret;
}
Exemplo n.º 3
0
/****************************************************************************
 * ow_write_big_block_depot(struct owctx *ow)
 *
 * Write big block depot.
 */
void ow_write_big_block_depot(struct owctx *ow)
{
  int num_blocks = ow->big_blocks;
  int num_lists = ow->list_blocks;
  int total_blocks = num_lists * 128;
  int used_blocks = num_blocks + num_lists + 2;
  struct pkt *pkt;
  int i;

  pkt = pkt_init(0, VARIABLE_PACKET);
  for (i = 1; i <= num_blocks - 1; i++) {
    pkt_add32_le(pkt, i);
  }

  /* End of chain */
  pkt_add32_le(pkt, -2);
  pkt_add32_le(pkt, -2);

  for (i = 1; i <= num_lists; i++) {
    pkt_add32_le(pkt, -3);
  }

  for (i = used_blocks; i <= total_blocks; i++) {
    pkt_add32_le(pkt, -1);
  }

  ow->io_handler.write(ow->io_handle,pkt->data, pkt->len);

  pkt_free(pkt);
}
Exemplo n.º 4
0
/**
 * pkt_recv - receive packet
 * @fd:	file descriptor to read
 *
 * Reads the next packet from @fd. A new lo_packet is created and returned.
 * On error, %NULL is returned, in which case the stream (@fd) will be in
 * an undefined state.
 */
struct lo_packet *pkt_recv(int fd)
{
	struct ccgfs_pkt_header *hdr;
	struct lo_packet *pkt;
	ssize_t ret;
	int err;

	pkt = pkt_init(0, 0);
	hdr = pkt->data;
	ret = reliable_read(fd, hdr, sizeof(*hdr));
	if (ret != sizeof(*hdr)) {
		err = errno;
		pkt_destroy(pkt);
		errno = err;
		return NULL;
	}

	hdr->opcode = le32_to_cpu(hdr->opcode);
	hdr->length = le32_to_cpu(hdr->length);
	hdr         = pkt_resize(pkt, hdr->length);
	pkt->length = hdr->length;

	ret = reliable_read(fd, pkt->data + sizeof(*hdr),
	      pkt->length - sizeof(*hdr));
	if (ret != pkt->length - sizeof(*hdr)) {
		err = errno;
		pkt_destroy(pkt);
		errno = err;
		return NULL;
	}
	return pkt;
}
Exemplo n.º 5
0
usb_dev_handle *usb_open(struct usb_device *dev)
{
   // Get remote fd
   Packet* pkt = pkt_claim();
   int fd = session_get();

   // Send packet
   pkt_init(pkt, UsbOpen);
   pkt_adduint(pkt, dev->bus->location);
   pkt_adduint(pkt, dev->devnum);
   pkt_send(pkt, fd);

   // Get response
   int res = -1, devfd = -1;
   if(pkt_recv(fd, pkt) > 0 && pkt_op(pkt) == UsbOpen) {
      Iterator it;
      pkt_begin(pkt, &it);
      res = iter_getint(&it);
      devfd = iter_getint(&it);
   }

   // Evaluate
   usb_dev_handle* udev = NULL;
   if(res >= 0) {
      udev = malloc(sizeof(usb_dev_handle));
      udev->fd = devfd;
      udev->device = dev;
      udev->bus = dev->bus;
      udev->config = udev->interface = udev->altsetting = -1;
   }

   pkt_release();
   debug_msg("returned %d (fd %d)", res, devfd);
   return udev;
}
Exemplo n.º 6
0
/* PROTO */
void
imcomm_im_send_message(void *handle, const char *whom, const char *msg, int automsg)
{
	pkt_t          *packet;

	packet = pkt_init(28 + strlen(whom) + strlen(msg) + (4 * automsg));

	/*
         * Message cookie?
         *
         * Putting something random seems to work.
         */
	pkt_add32(packet, 0x01020304);
	pkt_add32(packet, 0x05060708);

	pkt_add16(packet, 0x0001);
	pkt_add8(packet, (uint8_t) strlen(whom));
	pkt_addraw(packet, (uint8_t *) whom, strlen(whom));
	pkt_add16(packet, 0x0002);
	pkt_add16(packet, (uint16_t) (uint16_t) (strlen(msg) + 13));
	pkt_add32(packet, 0x05010001);
	pkt_add8(packet, 0x01);
	pkt_add16(packet, 0x0101);
	pkt_add16(packet, (uint16_t) (uint16_t) (strlen(msg) + 4));
	pkt_add32(packet, 0x00000000);
	pkt_addraw(packet, (uint8_t *) msg, strlen(msg));

	if (automsg) {
		pkt_add16(packet, 0x0004);
		pkt_add16(packet, 0x0000);
	}
	snac_sendpkt(handle, 0x04, 0x06, packet, (automsg ? 0 : 1));
	pkt_free(packet);
}
Exemplo n.º 7
0
/* Writes Excel BIFF BOUNDSHEET record */
void wbook_store_boundsheet(struct wbookctx *wbook, char *sname, int offset)
{
  uint16_t name = 0x0085;  /* Record identifier */
  uint16_t length;
  uint16_t grbit = 0x0000;
  int cch;
  struct pkt *pkt;

  length = 0x07 + strlen(sname);  /* Number of bytes to follow */
  cch = strlen(sname);

  pkt = pkt_init(0, VARIABLE_PACKET);

  /* Write header */
  pkt_add16_le(pkt, name);
  pkt_add16_le(pkt, length);

  /* Write data */
  pkt_add32_le(pkt, offset);  /* Location of worksheet BOF */
  pkt_add16_le(pkt, grbit);   /* Sheet identifier */
  pkt_add8(pkt, cch); /* Length of sheet name */
  pkt_addraw(pkt, (unsigned char *)sname, cch);

  bw_append(wbook->biff, pkt->data, pkt->len);
  pkt_free(pkt);

}
Exemplo n.º 8
0
/* PROTO */
IMCOMM_RET
snac_ack_limits(void *handle, unsigned char *data, size_t len)
{
	pkt_t          *pkt;
	uint16_t        x, y, num_classes, *ids;

	num_classes = two_to_16(data);
	ids = malloc(num_classes * 2);	/* it's a 16 bit type, so we need
					 * twice the bytes. Thanks to djgpp
					 * for catching this bug! UNIX/win32
					 * let it go. */


	for (x = 2, y = 0; y < num_classes; y++) {
		ids[y] = two_to_16(data + x);
		x += 35;
	}

	pkt = pkt_init(num_classes * 2);

	for (y = 0; y < num_classes; y++)
		pkt_add16(pkt, ids[y]);

	if (snac_sendpkt(handle, 0x01, 0x08, pkt, 0) != IMCOMM_RET_OK) {
		pkt_free(pkt);
		free(ids);
		return IMCOMM_RET_ERROR;
	}
	pkt_free(pkt);
	free(ids);

	return snac_multireq(handle);
}
Exemplo n.º 9
0
int usb_get_driver_np(usb_dev_handle *dev, int interface, char *name, unsigned int namelen)
{
   // Get remote fd
   Packet* pkt = pkt_claim();
   int fd = session_get();

   // Send packet
   pkt_init(pkt, UsbGetKernelDriver);
   pkt_addint(pkt,  dev->fd);
   pkt_addint(pkt,  interface);
   pkt_adduint(pkt, namelen);
   pkt_send(pkt, fd);

   // Get response
   int res = -1;
   if(pkt_recv(fd, pkt) > 0 && pkt_op(pkt) == UsbGetKernelDriver) {
      Iterator it;
      pkt_begin(pkt, &it);
      res = iter_getint(&it);

      // Error
      if(res) {
         error_msg("%s: could not get bound driver", __func__);
      }

      // Save string
      strncpy(name, iter_getstr(&it), namelen - 1);
      name[namelen - 1] = '\0';
   }

   pkt_release();
   debug_msg("returned %d (%s)", res, name);
   return res;
}
Exemplo n.º 10
0
/****************************************************************************
 * bw_store_bof(struct bwctx *bw, uint16_t type)
 *
 * type = 0x0005, Workbook
 * type = 0x0010, Worksheet
 *
 * Writes Excel BOF (Beginning of File) record to indicate the beginning of
 * a stream or substream in the BIFF file
 */
void bw_store_bof(struct bwctx *bw, uint16_t type)
{
  uint16_t name = 0x0809;   /* Record identifier */
  uint16_t length = 0x0008; /* Number of bytes to follow */

  /* According to the SDK "build" and "year" should be set to zero.
   * However, this throws a warning in Excel 5.  So, use these
   * magic umbers */
  uint16_t build = 0x096C;
  uint16_t year = 0x07C9;

  struct pkt *pkt;

  pkt = pkt_init(12, FIXED_PACKET);

  /* Construct header */
  pkt_add16_le(pkt, name);
  pkt_add16_le(pkt, length);

  /* Construct data */
  pkt_add16_le(pkt, g_BIFF_version);
  pkt_add16_le(pkt, type);
  pkt_add16_le(pkt, build);
  pkt_add16_le(pkt, year);
  bw_prepend(bw, pkt->data, pkt->len);
  pkt_free(pkt);
}
Exemplo n.º 11
0
/* libusb(5):
 * Interrupt transfers.
 */
int usb_interrupt_write(usb_dev_handle *dev, int ep, usb_buf_t bytes, int size, int timeout)
{
   // Get remote fd
   Packet* pkt = pkt_claim();
   int fd = session_get();

   // Prepare packet
   pkt_init(pkt, UsbInterruptWrite);
   pkt_addint(pkt, dev->fd);
   pkt_addint(pkt, ep);
   pkt_addstr(pkt, size, bytes);
   pkt_addint(pkt, timeout);
   pkt_send(pkt, fd);

   // Get response
   int res = -1;
   if(pkt_recv(fd, pkt) > 0 && pkt_op(pkt) == UsbInterruptWrite) {
      Iterator it;
      pkt_begin(pkt, &it);
      res = iter_getint(&it);
   }

   // Return response
   pkt_release();
   debug_msg("returned %d", res);
   return res;
}
Exemplo n.º 12
0
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, int timeout)
{
   // Get remote fd
   Packet* pkt = pkt_claim();
   int fd = session_get();

   // Prepare packet
   pkt_init(pkt, UsbInterruptRead);
   pkt_addint(pkt, dev->fd);
   pkt_addint(pkt, ep);
   pkt_addint(pkt, size);
   pkt_addint(pkt, timeout);
   pkt_send(pkt, fd);

   // Get response
   int res = -1;
   if(pkt_recv(fd, pkt) > 0 && pkt_op(pkt) == UsbInterruptRead) {
      Iterator it;
      pkt_begin(pkt, &it);
      res = iter_getint(&it);

      if(res > 0) {
         int minlen = (res > size) ? size : res;
         memcpy(bytes, it.val, minlen);
      }

   }

   // Return response
   pkt_release();
   debug_msg("returned %d", res);
   return res;
}
Exemplo n.º 13
0
int usb_reset(usb_dev_handle *dev)
{
   // Get remote fd
   Packet* pkt = pkt_claim();
   int fd = session_get();

   // Prepare packet
   pkt_init(pkt, UsbReset);
   pkt_addint(pkt, dev->fd);
   pkt_send(pkt, fd);

   // Get response
   int res = -1;
   if(pkt_recv(fd, pkt) > 0 && pkt_op(pkt) == UsbReset) {
      Iterator it;
      pkt_begin(pkt, &it);

      // Read result
      res = iter_getint(&it);
   }

   // Return response
   pkt_release();
   debug_msg("returned %d", res);
   return res;
}
Exemplo n.º 14
0
int usb_set_altinterface(usb_dev_handle *dev, int alternate)
{
   // Get remote fd
   Packet* pkt = pkt_claim();
   int fd = session_get();

   // Prepare packet
   pkt_init(pkt, UsbSetAltInterface);
   pkt_addint(pkt, dev->fd);
   pkt_addint(pkt, alternate);
   pkt_send(pkt, fd);

   // Get response
   int res = -1;
   if(pkt_recv(fd, pkt) > 0 && pkt_op(pkt) == UsbSetAltInterface) {
      Iterator it;
      pkt_begin(pkt, &it);

      // Read result
      res = iter_getint(&it);

      // Read callback configuration
      alternate = iter_getint(&it);
   }

   // Save configuration
   dev->altsetting = alternate;

   // Return response
   pkt_release();
   debug_msg("returned %d", res);
   return res;
}
Exemplo n.º 15
0
int usb_close(usb_dev_handle *dev)
{
   // Get remote fd
   Packet* pkt = pkt_claim();
   int fd = session_get();

   // Send packet
   pkt_init(pkt, UsbClose);
   pkt_addint(pkt, dev->fd);
   pkt_send(pkt, fd);

   // Free device
   free(dev);

   // Get response
   int res = -1;
   if(pkt_recv(fd, pkt) > 0 && pkt_op(pkt) == UsbClose) {
      Iterator it;
      pkt_begin(pkt, &it);
      res = iter_getint(&it);
   }

   pkt_release();
   debug_msg("returned %d", res);
   return res;
}
Exemplo n.º 16
0
/* PROTO */
IMCOMM_RET
snac_ack_srv_pause(void *handle, uint8_t * data, size_t len)
{
	pkt_t          *ackpkt;
	struct IMComm_Families *tr;
	int             count;

	for (count = 0, tr = ((IMCOMM *) handle)->families; tr; tr = tr->next)
		count++;

	ackpkt = pkt_init(count * 2);	/* each family is 16 bits */

	for (tr = ((IMCOMM *) handle)->families; tr; tr = tr->next) {
		pkt_add16(ackpkt, tr->family);
		printf("adding family %d (total %d).\n", tr->family, count);
	}

	((IMCOMM *) handle)->srv_pause = 1;

	/* return snac_send(handle, 0x01, 0x0c, data, len, 0); */
	snac_sendpkt(handle, 0x01, 0x0c, ackpkt, 0);

	pkt_free(ackpkt);

	return IMCOMM_RET_OK;
}
Exemplo n.º 17
0
/* PROTO */
void
snac_request_new_service(void *handle, uint16_t service)
{
	pkt_t          *pkt;

	pkt = pkt_init(2);
	pkt_add16(pkt, service);
	snac_sendpkt(handle, 0x01, 0x04, pkt, 0);
	pkt_free(pkt);
}
Exemplo n.º 18
0
/* PROTO */
void
imcomm_im_add_buddy(void *handle, char *sn)
{
	IMCOMM_BUDDYLIST *temp, *trav;
	struct MultiPacket *mpkt;
	pkt_t          *packet;
	char           *sname;
	uint16_t        nextid;

	sname = imcomm_simplify_sn(sn);

	for (trav = ((IMCOMM *) handle)->buddylist; trav != NULL;
	     trav = trav->next) {
		if (strcmp(sname, trav->sn) == 0) {
			free(sname);
			return;
		}
	}

	nextid = imcomm_get_next_id(handle);

	temp = malloc(sizeof(IMCOMM_BUDDYLIST));
	temp->sn = sname;
	temp->formattedsn = strdup(sname);
	temp->ssi_id = nextid;
	temp->next = NULL;

	if (((IMCOMM *) handle)->buddylist == NULL)
		((IMCOMM *) handle)->buddylist = temp;
	else {
		for (trav = ((IMCOMM *) handle)->buddylist; trav->next != NULL;
		     trav = trav->next);

		trav->next = temp;
	}

	mpkt = MultiPktInit();

	snac_addToMulti(handle, mpkt, 0x13, 0x11, NULL, 0, 0);
	packet = pkt_init(10 + strlen(sname));
	pkt_add16(packet, (uint16_t) strlen(sname));
	pkt_addraw(packet, (unsigned char *) sname, strlen(sname));
	pkt_add16(packet, 0x0001);
	pkt_add16(packet, nextid);
	pkt_add16(packet, 0x0000);
	pkt_add16(packet, 0x0000);
	snac_addToMulti(handle, mpkt, 0x13, 0x08, packet->data, packet->len,
			0);
	pkt_free(packet);

	snac_addToMulti(handle, mpkt, 0x13, 0x012, NULL, 0, 0);

	flap_sendMulti(handle, mpkt);
	MultiPktFree(mpkt);
}
Exemplo n.º 19
0
/****************************************************************************
 * ow_write_header(struct owctx *ow)
 *
 * Write OLE header block.
 */
void ow_write_header(struct owctx *ow)
{
  int root_start;
  int num_lists;
  struct pkt *pkt;
  int i;

  if (ow->biff_only)
    return;

  ow_calculate_sizes(ow);

  root_start = ow->root_start;
  num_lists = ow->list_blocks;

  pkt = pkt_init(0, VARIABLE_PACKET);
  pkt_add32(pkt, 0xD0CF11E0); /* OLE document file id part 1 */
  pkt_add32(pkt, 0xA1B11AE1); /* OLE document file id part 2 */
  pkt_add32_le(pkt, 0x00); /* UID of this file (can be all 0's) 1/4 */
  pkt_add32_le(pkt, 0x00); /* UID of this file (can be all 0's) 2/4 */
  pkt_add32_le(pkt, 0x00); /* UID of this file (can be all 0's) 3/4 */
  pkt_add32_le(pkt, 0x00); /* UID of this file (can be all 0's) 4/4 */
  pkt_add16_le(pkt, 0x3E); /* Revision number (almost always 0x003E) */
  pkt_add16_le(pkt, 0x03); /* Version number (almost always 0x0003) */
  pkt_add16(pkt, 0xFEFF);  /* Byte order identifier:
                            * (0xFEFF = Little Endian)
                            * (0xFFFE = Big Endian)    */
  pkt_add16_le(pkt, 0x09); /* 2^x  (9 = 512 bytes) */
  pkt_add32_le(pkt, 0x06); /* Unknown 5 */
  pkt_add32_le(pkt, 0x00); /* Unknown 5 */
  pkt_add32_le(pkt, 0x00); /* Unknown 5 */
  pkt_add32_le(pkt, num_lists); /* num_bbd_blocks */
  pkt_add32_le(pkt, root_start); /* root_startblock */
  pkt_add32_le(pkt, 0x00); /* Unknown 6 */
  pkt_add32_le(pkt, 0x1000); /* Unknown 6 */
  pkt_add32_le(pkt, -2);  /* sbd_startblock */
  pkt_add32_le(pkt, 0x00); /* Unknown 7 */
  pkt_add32_le(pkt, -2); /* Unknown 7 */
  pkt_add32_le(pkt, 0x00); /* Unknown 7 */

  for (i = 1; i <= num_lists; i++) {
    root_start++;
    pkt_add32_le(pkt, root_start);

  }

  for (i = num_lists; i <= 108; i++) {
    pkt_add32_le(pkt, -1); /* Unused */
  }

  ow->io_handler.write(ow->io_handle,pkt->data, pkt->len);

  pkt_free(pkt);
}
Exemplo n.º 20
0
static inline struct lo_packet *mpkt_init(unsigned int type,
    unsigned int length)
{
	const struct fuse_context *ctx = fuse_get_context();
	struct lo_packet *pkt;

	pkt = pkt_init(type, length + 2 * PV_32);
	pkt_push_32(pkt, ctx->uid);
	pkt_push_32(pkt, ctx->gid);
	return pkt;
}
Exemplo n.º 21
0
/* PROTO */
ssize_t
send_cmdpkt(void *handle, pkt_t *packet)
{
	pkt_t *n;
	ssize_t ret;

	n = pkt_init(2+packet->len);
	pkt_addraw(n, packet->data, packet->len);
	pkt_addraw(n, (unsigned char *)"\r\n", 2);

	ret = sendPkt(handle, n);
	pkt_free(n);
	return ret;
}
Exemplo n.º 22
0
/* PROTO */
void
imcomm_request_awaymsg(void *handle, char *sn)
{
	pkt_t          *packet;

	packet = pkt_init(3 + (uint8_t) strlen(sn));

	pkt_add16(packet, 0x0003);
	pkt_add8(packet, (uint8_t) strlen(sn));
	pkt_addraw(packet, (uint8_t *) sn, strlen(sn));

	snac_sendpkt(handle, 0x02, 0x05, packet, 0);
	pkt_free(packet);
}
Exemplo n.º 23
0
/** Initialize USB subsystem. */
void usb_init(void)
{
   // Initialize packet & remote fd
   Packet* pkt = pkt_claim();
   int fd = session_get();

   // Create buffer
   pkt_init(pkt, UsbInit);
   pkt_send(pkt, fd);
   pkt_release();

   // Initialize locally
   debug_msg("called");
}
Exemplo n.º 24
0
/****************************************************************************
 * bw_store_eof(struct bwctx *bw)
 *
 * Writes Excel EOF (End of File) record to indicate the end of a BIFF stream.
 */
void bw_store_eof(struct bwctx *bw)
{
  struct pkt *pkt;
  uint16_t name = 0x000A;   /* Record identifier */
  uint16_t length = 0x0000; /* Number of bytes to follow */

  pkt = pkt_init(4, FIXED_PACKET);

  /* Construct header */
  pkt_add16_le(pkt, name);
  pkt_add16_le(pkt, length);

  bw->append(bw, pkt->data, pkt->len);
  pkt_free(pkt);
}
Exemplo n.º 25
0
/*! \brief Allocate new packet using memory context. */
static knot_pkt_t *pkt_new_mm(void *wire, uint16_t len, mm_ctx_t *mm)
{
	assert(mm);

	knot_pkt_t *pkt = mm_alloc(mm, sizeof(knot_pkt_t));
	if (pkt == NULL) {
		return NULL;
	}

	if (pkt_init(pkt, wire, len, mm) != KNOT_EOK) {
		mm_free(mm, pkt);
		return NULL;
	}

	return pkt;
}
Exemplo n.º 26
0
int main(){

	s_pkt_gl *pkt_gl = pkt_init();
	
	if (!pkt_gl ){        
		printf("[INIT ERROR]\n");
		exit(-1);
	}
	
	pkt_proc(pkt_gl); //如果在处理的时候突然崩了的话,pkt_gl没有释放资源,很危险的啊!
	
	clean(pkt_gl);
    
    return 0;
	
}
Exemplo n.º 27
0
/* Write Excel 1904 record to indicate the date system in use. */
static void wbook_store_1904(struct wbookctx *wbook)
{
  struct pkt *pkt;

  pkt = pkt_init(6, FIXED_PACKET);

  /* Write header */
  pkt_add16_le(pkt, 0x0022);  /* Record identifier */
  pkt_add16_le(pkt, 0x0002);

  /* Write data */
  pkt_add16_le(pkt, wbook->epoch1904);  /* Flag for 1904 date system */

  bw_append(wbook->biff, pkt->data, pkt->len);
  pkt_free(pkt);
}
Exemplo n.º 28
0
/* Stores the CODEPAGE biff record */
static void wbook_store_codepage(struct wbookctx *wbook)
{
  struct pkt *pkt;

  pkt = pkt_init(6, FIXED_PACKET);

  /* Write header */
  pkt_add16_le(pkt, 0x0042);  /* Record identifier */
  pkt_add16_le(pkt, 0x0002);

  /* Write data */
  pkt_add16_le(pkt, wbook->codepage);

  bw_append(wbook->biff, pkt->data, pkt->len);
  pkt_free(pkt);
}
Exemplo n.º 29
0
/****************************************************************************
 * ow_write_pps(struct owctx *ow, char *name)
 *
 * Write property sheet in property storage
 */
void ow_write_pps(struct owctx *ow, char *name, int pps_type, int pps_dir, int pps_start, int pps_size)
{
  unsigned char header[64];
  int length;
  struct pkt *pkt;

  memset(header, 0, sizeof(header));
  length = 0;
  if (name != NULL)
  {
    /* Simulate a unicode string */
    char *p = name;
    int i = 0;
    while (*p != '\0') {
      header[i] = *p++;
      i += 2;
    }
    length = (strlen(name) * 2) + 2;
  }

  pkt = pkt_init(0, VARIABLE_PACKET);
  pkt_addraw(pkt, header, sizeof(header));
  pkt_add16_le(pkt, length); /* pps_sizeofname 0x40 */
  pkt_add16_le(pkt, pps_type); /* 0x42 */
  pkt_add32_le(pkt, -1); /* pps_prev  0x44 */
  pkt_add32_le(pkt, -1); /* pps_next  0x48 */
  pkt_add32_le(pkt, pps_dir); /* pps_dir   0x4C */

  pkt_add32_le(pkt, 0);  /* unknown   0x50 */
  pkt_add32_le(pkt, 0);  /* unknown   0x54 */
  pkt_add32_le(pkt, 0);  /* unknown   0x58 */
  pkt_add32_le(pkt, 0);  /* unknown   0x5C */
  pkt_add32_le(pkt, 0);  /* unknown   0x60 */

  pkt_add32_le(pkt, 0);  /* pps_ts1s  0x64 */
  pkt_add32_le(pkt, 0);  /* pps_ts1d  0x68 */
  pkt_add32_le(pkt, 0);  /* pps_ts2s  0x6C */
  pkt_add32_le(pkt, 0);  /* pps_ts2d  0x70 */
  pkt_add32_le(pkt, pps_start); /* pps_start 0x74 */
  pkt_add32_le(pkt, pps_size); /* pps_size 0x78 */
  pkt_add32_le(pkt, 0);  /* unknown  0x7C */

  ow->io_handler.write(ow->io_handle,pkt->data, pkt->len);

  pkt_free(pkt);
}
Exemplo n.º 30
0
/* PROTO */
void
snac_addToMulti(void *handle, struct MultiPacket * mpkt, uint16_t family, uint16_t subtype, unsigned char *data, uint16_t len, int updateidle)
{
	pkt_t          *snac_packet;

	snac_packet = pkt_init(len + 10);
	pkt_add16(snac_packet, family);
	pkt_add16(snac_packet, subtype);
	pkt_add16(snac_packet, 0);
	pkt_add32(snac_packet, ((IMCOMM *) handle)->snacreq);
	pkt_addraw(snac_packet, (uint8_t *) data, len);
	((IMCOMM *) handle)->snacreq++;

	flap_addToMulti(mpkt, 0x02, snac_packet->data, snac_packet->len,
			updateidle);
	pkt_free(snac_packet);
}