Beispiel #1
0
static void append_header(Buffer *canon_s, const struct curl_slist *headers, const char * header) {
  int header_key_length = strlen(header);
  char *found_header = get_header(headers, header, header_key_length);
  
  if (found_header) {
    char *header_value = &found_header[header_key_length + 1];
    buffer_in(canon_s, header_value, strlen(header_value));
  }
  buffer_in(canon_s, "\n", 1);
}
Beispiel #2
0
static char * build_auth_header(char * access_id, char * signature) {
  Buffer *auth_header = new_buffer(64);
  buffer_in(auth_header, "Authorization: AuthHMAC ", strlen("Authorization: AuthHMAC "));
  buffer_in(auth_header, access_id, strlen(access_id));
  buffer_in(auth_header, ":", 1);
  buffer_in(auth_header, signature, strlen(signature));
  buffer_in(auth_header, "\0", 1);
  
  char * return_header = auth_header->buf;
  free(auth_header);
  
  return return_header;
}
Beispiel #3
0
/**@brief Handler for SPI0 master events.
 *
 * @param[in] event SPI master event.
 */
void spi_master_0_event_handler(nrf_drv_spi_evt_type_t* event)
{
//    uint32_t err_code = NRF_SUCCESS;
//	  uint32_t c_buff;   // Temporarily store the buffer index of the buffer ready to be compressed

    switch (*event)
    {
			  // Transfer complete; store in buffer.
        case NRF_DRV_SPI_EVENT_DONE:
            
            nrf_drv_spi_uninit(&m_spi_master_0);
            if (buffer_in(&db, &m_rx_data_spi[0]) == BUFFER_FULL) {
              if (buffer_compress(db.buffer, db.item_cnt, transmission_buffer) != BUFFER_SUCCESS) {
							//		buffer_reset(&db);  
									printf("Error compressing data!\n");
              }
              intan_convert_channel++;
              intan_convert_channel = intan_convert_channel % 32;
						}

            m_transfer_completed = true;
            break;

        default:
            // No implementation needed.
            break;
    }
}
Beispiel #4
0
char * canonical_string(const char * method, const char * path, const struct curl_slist *headers) {
  // TOOD handle this
  Buffer *canon_s = new_buffer(256);
  buffer_in(canon_s, method, strlen(method));
  buffer_in(canon_s, "\n", 1);
  
  append_header(canon_s, headers, "Content-Type:");
  append_header(canon_s, headers, "Content-MD5:");
  append_header(canon_s, headers, "Date:");
  
  buffer_in(canon_s, path, strlen(path));
  
  buffer_in(canon_s, "\0", 1);
  char * return_string = canon_s->buf;
  free(canon_s);
  return return_string;
}
Beispiel #5
0
static void processNode(xmlTextReaderPtr reader, Buffer * buf) {
	int type = xmlTextReaderNodeType(reader);

	if (type == XML_TEXT_NODE) {
		unsigned char *s = xmlTextReaderReadString(reader);
		int slen = strlen(s);
		char enc[512];
		int enclen = 512;
		if (!htmlEncodeEntities(enc, &enclen, s, &slen, 0)) {
			buffer_in(buf, enc, enclen);

			if (enc[enclen-1] != ' ') {
				buffer_in(buf, " ", 1);
			}
		}

		free(s);
	}
}
Beispiel #6
0
static Buffer *extractText(htmlDocPtr doc) {
		char * term = "\0";
    Buffer *buf = new_buffer(256);
    xmlTextReaderPtr reader = xmlReaderWalker(doc);
    while(xmlTextReaderRead(reader)){
        processNode(reader, buf);
    }
    xmlFreeTextReader(reader);

    buffer_in(buf, term, 1);
    return buf;
}
Beispiel #7
0
   mlpipebuf::int_type
   mlpipebuf::underflow()
   {
#ifdef DEBUG
      char *fname = "mlpipebuf::underflow()";
      Tracebuf T(fname);
#endif

      if(gptr() < egptr())
         return (int)(unsigned char)(*gptr());

      if(buffer_in() < 0)
         return (int)EOF;

      else
         return (int)(unsigned char)(*gptr());
   }