Exemple #1
0
hash_manager::content_page::content_page(const char buffer[hash_manager::page_size]) : page(buffer) {
	std::bitset<n_data> data_bitmap(chars_to_int(&buffer[9]));
	int j = 0;
	for (int i=13 ; i<page_size-7 ; i+=8) {
		if (data_bitmap[j++]) add_data(std::make_pair(chars_to_int(&buffer[i]),chars_to_int(&buffer[i+4])));
	}
}
Exemple #2
0
Fichier : cal.c Projet : Jmq14/XV6
char* cal3(char* a1, char* a2, char* s)
{
  char* ret = (char*)malloc(MAXNUM * sizeof(char));
  char* r = (char*)malloc(MAXNUM * sizeof(char));
  int res = 0;
  int i;
  int r1 = chars_to_int(a1);
  int r2 = chars_to_int(a2);
  switch (s[0])
  {
  case '+': res = r1 + r2; break;
  case '-': res = r1 - r2; break;
  case '*': res = r1 * r2; break;
  case '/': res = r1 / r2; break;
  }
  if (res >= 0) 
    ret = int_to_chars(ret, res);
  else
  {
    r = int_to_chars(r, -res);
    ret[0] = '-';
    ret[1] = 0;
    for (i = 0; i < 9; i++)
    {
      ret[i+1] = r[i];
    }
  }
  
  return ret;
}
Exemple #3
0
hash_manager::pointer_page::pointer_page(const char buffer[hash_manager::page_size]) : page(buffer) {
	std::bitset<n_pointers> ptr_bitmap(chars_to_int(&buffer[9]));
	int j = 0;
	for (int i=13 ; i<page_size-3 ; i+=4) {
		if (ptr_bitmap[j++]) add_ptr(chars_to_int(&buffer[i]));
	}
}
int	my_getnbr(char *str)
{
  char	i;
  char	*ptr_int_start;
  char	*ptr_int_end;

  ptr_int_start = 0;
  ptr_int_end = 0;
  i = 0;
  while (str[i] != '\0')
    {
      if (is_digit(str[i]))
	{
	  if (!ptr_int_start)
	    ptr_int_start = &(str[i]);
	  if ((str[i + 1] == '\0' || !is_digit(str[i + 1])) && !ptr_int_end)
	    ptr_int_end = &(str[i]);
	}
      else if (!ptr_int_start && !ptr_int_end)
	{
	  ptr_int_start = 0;
	  ptr_int_end = 0;
	}
      i = i + 1;
    }
  return (chars_to_int(ptr_int_start, ptr_int_end));
}
Exemple #5
0
Fichier : cal.c Projet : Jmq14/XV6
int chars_to_int(char* src)
{
  char* r = (char*)malloc(10 * sizeof(char));
  int ret = 0;
  int j;
  if (src[0] == '-')
  {
    for (j = 0; j < 9; j++)
    {
      r[j] = src[j + 1];
    }
    return -chars_to_int(r);
  }
  for (j = 0; j < strlen(src); j++)
  {
    ret *= 10;
    ret += src[j] - '0';
  }
  return ret;
}
Exemple #6
0
Fichier : cal.c Projet : Jmq14/XV6
int cal(char* src)
{
  char* res = caln(toRPN(split(src)));
  printf(2, "The answer is: %s\n", res);
  return chars_to_int(res);
}
Exemple #7
0
void read_format(char *buffer, midi_format *format) {
	// print_hex_chars(buffer, 6);
	format->format = chars_to_int(buffer);
	format->number_of_tracks = chars_to_int(buffer + 2);
	format->deltatime_ticks = chars_to_int(buffer + 4);
}
Exemple #8
0
hash_manager::page::page(const char buffer[hash_manager::page_size]) : type(buffer[0]) {
	parent_pointer = chars_to_int(&buffer[1]);
	disc_writes = chars_to_int(&buffer[5]);
}
Exemple #9
0
hash_manager::fheader_page::fheader_page(const char buffer[hash_manager::page_size]) : page(buffer) {
	n_buckets = chars_to_int(&buffer[9]);
	n_pages = chars_to_int(&buffer[13]);
	level = chars_to_int(&buffer[17]);
	next = chars_to_int(&buffer[21]);
}