Esempio n. 1
0
/* DDS3.2.6: Get Rotation */
void get_rotation(const struct electorate *elec)
{
	struct http_vars *reply;
	unsigned int i;
	char ecodestr[INT_CHARS];
	struct http_vars request[]
		= { { (char*)"ecode", ecodestr }, { NULL, NULL } };

	sprintf(ecodestr, "%u", elec->code);

	reply = http_exchange(SERVER_ADDRESS, SERVER_PORT, ROBSON_CGI,request);
	if (!reply)
		display_error(ERR_SERVER_UNREACHABLE);

	/* Some error occurred? */
	if (http_error(reply))
		display_error(http_error(reply));

	for (i = 0; i < elec->num_seats; i++) {
		char varname[strlen("rotation")
			    + sizeof(STRINGIZE(MAX_ELECTORATE_SEATS))];
		const char *val;

		sprintf(varname, "rotation%u", i);
		val = http_string(reply, varname);
		current_rotation.rotations[i] = atoi(val);
		assert(current_rotation.rotations[i] < elec->num_seats);
	}
	/* DDS3.2.6: Save Rotation */
	current_rotation.size = elec->num_seats;
	http_free(reply);
}
Esempio n. 2
0
int get_initial_cursor(const struct electorate *elec)
{
  struct http_vars *reply;
  int initial_cursor;
  /* SIPL 2011-09-26 Added one to length of array.  There was
     no chance of a buffer overflow, but do this to make it consistent
     with all other uses of INT_CHARS. */
  char ecodestr[INT_CHARS+1];
  struct http_vars request[]
    = { { (char*)"ecode", ecodestr }, { NULL, NULL } };

  sprintf(ecodestr, "%u", elec->code);

  reply = http_exchange(SERVER_ADDRESS, SERVER_PORT, CURSOR_CGI,request);
  if (!reply)
    display_error(ERR_SERVER_UNREACHABLE);

  initial_cursor = atoi(http_string(reply, "cursor"));

  http_free(reply);

  cursor = initial_cursor;

  return initial_cursor;
}