Esempio n. 1
0
void
convert(FILE *a, FILE *b, FILE *c, FILE *d)
{
    static char line[MAX_LINE_LEN+1];

    header(b, "gnuplot help");
    fprintf(b, "<h1 align=\"center\">gnuplot %s patchlevel %s</h1>\n", gnuplot_version, gnuplot_patchlevel);

    header(c, "gnuplot help contents");
    fprintf(c, "<ul>\n");

    if (d) {
        header(d, "gnuplot help index");
        fprintf(d, "<ul>\n");
    }

    /* process each line of the file */
    while (get_line(line, sizeof(line), a)) {
	process_line(line, b, c, d);
    }

    footer(b);

    fprintf(c, "</ul>\n");
    footer(c);

    if (d) {
        fprintf(d, "</ul>\n");
        footer(d);
    }

    list_free();
}
Esempio n. 2
0
AutoChamada::AutoChamada(Wt::Dbo::Session& dbSession, std::vector<std::pair<Wt::WCheckBox*, Wt::Dbo::ptr<SiconfModel::Aluno>>> list) :
																								Wt::WDialog(),
																								_dbSession(dbSession),
																								_list(list),
																								index(0){

	Wt::Dbo::Transaction transaction(_dbSession);

	_presente = new Wt::WPushButton("Presente", footer());
	_ausente = new Wt::WPushButton("Ausente", footer());
	_anterior = new Wt::WPushButton("Anterior", footer());
	_cancelar = new Wt::WPushButton("Cancelar", footer());

	new Wt::WText("<h3>Chamada Automatica</h3>", titleBar());
	titleBar()->setContentAlignment(Wt::AlignCenter);
	contents()->setContentAlignment(Wt::AlignCenter);
	footer()->setContentAlignment(Wt::AlignCenter);

	_presente->clicked().connect(this, &AutoChamada::_presenteClicked);
	_ausente->clicked().connect(this, &AutoChamada::_ausenteClicked);
	_anterior->clicked().connect(this, &AutoChamada::_anteriorClicked);
	_cancelar->clicked().connect(this, &AutoChamada::_cancelClicked);

	_presente->setStyleClass("btn-success");
	_ausente->setStyleClass("btn-warning");
	_anterior->setStyleClass("btn-primary");
	_cancelar->setStyleClass("btn-danger");

	rejectWhenEscapePressed();

	auto aluno = _list.begin()->second->usuario();
	_name = new Wt::WText("<h4>" + aluno->nome() + " " + aluno->sobrenome() + "</h4>", contents());
	setWidth(Wt::WLength("30%"));
	show();
}
Esempio n. 3
0
Wizard::Wizard(WObject* parent) :
        WDialog(parent),
        m_currentId(-1),
        m_stack(new WStackedWidget),
        m_title(new WLabel),
        m_subTitle(new WGroupBox),
        m_back(new WPushButton("< Back")),
        m_next(new WPushButton("Next>")),
        m_cancel(new WPushButton("Cancel")),
        m_finish(new WPushButton("Finish"))
{
    setModal(true);
    setResizable(true);

    titleBar()->addWidget(m_title);

    auto contentLayout = new WVBoxLayout;
    contents()->setLayout(contentLayout);
    contentLayout->addWidget(m_subTitle);
    m_subTitle->addWidget(m_stack);
    m_stack->addStyleClass("Wizard-stack");

    footer()->addWidget(m_back);
    footer()->addWidget(m_next);
    footer()->addWidget(m_finish);
    footer()->addWidget(m_cancel);

    m_back->clicked().connect(this, &Wizard::back);
    m_next->clicked().connect(this, &Wizard::next);
    m_cancel->clicked().connect(this, &Wizard::reject);
    m_finish->clicked().connect(this, &Wizard::finish);

    m_finish->setHidden(true);
}
Esempio n. 4
0
/*
 * Print error message & exit
 */
void die(state *st, char *message, char *description)
{
	int en = errno;
	static const char error_gif[] = ERROR_GIF;

	/* Handle NULL description */
	if (description == NULL) description = strerror(en);

	/* Log the error */
	if (st->opt_syslog) {
		syslog(LOG_ERR, "error \"%s\" for request \"%s\" from %s",
			description, st->req_selector, st->req_remote_addr);
	}
	log_combined(st, HTTP_404);

	/* Handle menu errors */
	if (st->req_filetype == TYPE_MENU || st->req_filetype == TYPE_QUERY) {
		printf("3" ERROR_PREFIX "%s\tTITLE\t" DUMMY_HOST CRLF, message);
		footer(st);
	}

	/* Handle image errors */
	else if (st->req_filetype == TYPE_GIF || st->req_filetype == TYPE_IMAGE) {
		fwrite(error_gif, sizeof(error_gif), 1, stdout);
	}

	/* Handle HTML errors */
	else if (st->req_filetype == TYPE_HTML) {
		printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n"
			"<HTML>\n<HEAD>\n"
			"  <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=iso-8859-1\">\n"
			"  <TITLE>" ERROR_PREFIX "%1$s</TITLE>\n"
			"</HEAD>\n<BODY>\n"
			"<STRONG>" ERROR_PREFIX "%1$s</STRONG>\n"
			"<PRE>\n", message);
		footer(st);
		printf("</PRE>\n</BODY>\n</HTML>\n");
	}

	/* Use plain text error for other filetypes */
	else {
		printf(ERROR_PREFIX "%s" CRLF, message);
		footer(st);
	}

	/* Quit */
	exit(EXIT_FAILURE);
}
Esempio n. 5
0
int BF_Translator::translate(std::string in, std::string out) {
	try {
		this->in.open(in.data(), std::ios::in);
		this->out.open(out.data(), std::ios::trunc | std::ios::out);
		if (!this->in.is_open() || !this->out.is_open()) {
			throw std::exception();
		}
		bf_command command;
		header();
		while (!this->in.eof()) {
			char c = this->in.get();
			command = commands[c];
			if (command) {
				(this->*command)();
			}
			else if (!isspace(c) && c != -1) {
				throw std::exception();
			}
		}
		footer();
		this->out.flush();
		this->in.close();
		this->out.close();
	}
	catch (std::exception & e) {
		this->in.close();
		this->out.close();
		return -1;
	}
	return 0;
}
Esempio n. 6
0
static void
test_empty_rope()
{
	header();

	struct rope *rope = test_rope_new();

	fail_unless(rope_size(rope) == 0);

	struct rope_iter *iter = rope_iter_new(rope);

	fail_unless(rope_iter_start(iter) == NULL);
	fail_unless(rope_iter_start(iter) == NULL);

	rope_traverse(rope, str_print);
	rope_check(rope);
	rope_pretty_print(rope, str_print);

	/* rope_erase(), rope_extract() expect a non-empty rope */

	rope_iter_delete(iter);
	rope_delete(rope);

	footer();
}
Esempio n. 7
0
void
test_boundary_args()
{
	header();

	const int max_update_op_cnt = 4000;

	printf("# insert tuple\n");
	struct tnt_tuple *tuple = tnt_tuple(NULL, "%d%d", 0, 1);
	insert_tuple(tuple);
	tnt_tuple_free(tuple);

	printf("# test: try to do update w/o operations\n");
	struct tnt_stream *stream = tnt_buf(NULL);
	update(0, stream);
	tnt_stream_free(stream);

	printf("# test: update w/ maximal allowed opearions count\n");
	stream = tnt_buf(NULL);
	for (int i = 0; i < max_update_op_cnt; ++i)
		tnt_update_arith_i32(stream, 1, TNT_UPDATE_ADD, 1);
	update(0, stream);
	tnt_stream_free(stream);

	printf("# test: update w/ grater than maximal allowed opearions count\n");
	stream = tnt_buf(NULL);
	for (int i = 0; i < max_update_op_cnt + 1; ++i)
		tnt_update_arith_i32(stream, 1, TNT_UPDATE_ADD, 1);
	update(0, stream);
	tnt_stream_free(stream);

	footer();
}
Esempio n. 8
0
void
test_splice()
{
	header();

	printf("# insert tuple\n");
	struct tnt_tuple *tuple = tnt_tuple(NULL, "%d%s%s%s", 1, "first", "hi, this is a test string!", "third");
	insert_tuple(tuple);
	tnt_tuple_free(tuple);

	struct tnt_stream *stream = tnt_buf(NULL);
	printf("# test cut from begin\n");
	update_splice_str(stream, 2, 0, 4, "");
	update(1, stream);
	tnt_stream_free(stream);

	printf("# test cut from middle\n");
	stream = tnt_buf(NULL);
	update_splice_str(stream, 2, 9, -8, "");
	update(1, stream);
	tnt_stream_free(stream);

	printf("# test cut from end\n");
	stream = tnt_buf(NULL);
	update_splice_str(stream, 2, -1, 1, "");
	update(1, stream);
	tnt_stream_free(stream);

	printf("# test insert before begin\n");
	stream = tnt_buf(NULL);
	update_splice_str(stream, 2, 0, 0, "Bonjour, ");
	update(1, stream);
	tnt_stream_free(stream);

	printf("# test insert after end\n");
	stream = tnt_buf(NULL);
	update_splice_str(stream, 2, 10000, 0, " o_O!?");
	update(1, stream);
	tnt_stream_free(stream);

	printf("# test replace in begin\n");
	stream = tnt_buf(NULL);
	update_splice_str(stream, 2, 0, 7, "Hello");
	update(1, stream);
	tnt_stream_free(stream);

	printf("# test replace in middle\n");
	stream = tnt_buf(NULL);
	update_splice_str(stream, 2, 17, -6, "field");
	update(1, stream);
	tnt_stream_free(stream);

	printf("# test replace in end\n");
	stream = tnt_buf(NULL);
	update_splice_str(stream, 2, -6, 4, "! Is this Sparta");
	update(1, stream);
	tnt_stream_free(stream);

	footer();
}
Esempio n. 9
0
void
test_long_set()
{
	header();

	printf("# insert tuple\n");
	struct tnt_tuple *tuple = tnt_tuple(NULL, "%d%s%s%s",
					    1, "first", "", "third");
	insert_tuple(tuple);
	tnt_tuple_free(tuple);

	printf("# test set big value in empty field\n");
	struct tnt_stream *stream = tnt_buf(NULL);
	update_set_str(stream, 2, long_string);
	update(1, stream);
	tnt_stream_free(stream);

	printf("# test replace long value to short\n");
	stream = tnt_buf(NULL);
	update_set_str(stream, 2, "short string");
	update(1, stream);
	tnt_stream_free(stream);

	footer();
}
Esempio n. 10
0
void
test_simple_set()
{
	header();

	/* insert tuple */
	printf("# insert tuple\n");
	struct tnt_tuple *tuple = tnt_tuple(NULL, "%d%d%d%s", 1, 2, 0, "");
	insert_tuple(tuple);
	tnt_tuple_free(tuple);

	printf("# test simple set field\n");
	struct tnt_stream *stream = tnt_buf(NULL);
	update_set_str(stream, 1, "new field value");
	update_set_str(stream, 2, "");
	update_set_str(stream, 3, "fLaC");
	update(1, stream);
	tnt_stream_free(stream);

	printf("# set field\n");
	stream = tnt_buf(NULL);
	update_set_str(stream, 1, "value?");
	update_set_str(stream, 1, "very very very very very long field value?");
	update_set_str(stream, 1, "field's new value");
	update(1, stream);
	tnt_stream_free(stream);

	stream = tnt_buf(NULL);
	printf("# test set primary key\n");
	update_set_i32(stream, 0, 2);
	update(1, stream);
	tnt_stream_free(stream);

	footer();
}
Esempio n. 11
0
int main(void) {
    char command;               // input turtle command
    double d;                   // change in distance
    double a;                   // change in angle

    double r = 0.0;             // red   component of RGB color
    double g = 0.0;             // green component of RGB color
    double b = 0.0;             // blue  component of RGB color

    double x = 0.0;             // x coordinate of turtle
    double y = 0.0;             // y coordinate of turtle
    double alpha = 0.0;         // direction of turtle in degrees

    header();

// read in turtle graphics commands and process
while (scanf(" %c", &command) == 1) {
    // space in " %c" eats up any preceding whitespace
    switch(command) {

        // change color to r, g, b
        case 'C': scanf("%lf %lf %lf", &r, &g, &b);
                  printf("%f %f %f setrgbcolor\n", r, g, b);
                  break;

        // fly to location (x, y)
        case 'F': scanf("%lf %lf", &x, &y);
                  break;

        // draw spot of size d
        case 'S': scanf("%lf", &d);
                  printf("%f %f %f %f rectfill\n", x - d/2, y - d/2, d, d);
                  break; 

        // rotate
        case 'R': scanf("%lf", &a);
                  alpha += a;
                  break;

        // move d units in current direction, pen down
        case 'D': scanf("%lf", &d);
                  printf("%f %f moveto\n", x, y);
                  x += d * cos((PI/180.0) * alpha);
                  y += d * sin((PI/180.0) * alpha);
                  printf("%f %f lineto\n", x, y);
                  printf("stroke\n");
                  break;

        default:  printf("Illegal input format.\n");
                  exit(EXIT_FAILURE);

        }  // end switch 
    }      // end while 



    footer();

    return 0;  
}
Esempio n. 12
0
void show_weather()
{
	int i;
	for(i = 0; i < 8; i++)
	{
		put_line(1);
		put_line(6);
		footer();

		details(DAYS[i].day, DAYS[i].temp, DAYS[i].wind_f, DAYS[i].wind_d, DAYS[i].state, i);

		if(strcmp(DAYS[i].state, "SLONECZNIE"))
			put_image(slo1, slo2);
		else
		if(strcmp(DAYS[i].state, "PRZEWAZNIE SLONECZNIE"))
			put_image(prz_slo1, prz_slo2);
		else
		if(strcmp(DAYS[i].state, "ZMIENNE ZACHMURZENIE"))
			put_image(zach_zm1, zach_zm2);
		else
		if(strcmp(DAYS[i].state, "ZACHMURZENIE PELNE, SLABY DESZCZ"))
			put_image(sd1, sd2);

		ClearScreen();
	}
}
Esempio n. 13
0
static void mhash_int32_collision_test()
{
	header();
	int k;
	struct mh_i32_collision_t *h;
#define init()		({ mh_i32_collision_new();		})
#define clear(x)	({ mh_i32_collision_clear((x));	})
#define destroy(x)	({ mh_i32_collision_delete((x));	})
#define get(x) ({							\
	const struct mh_i32_collision_node_t _node = { .key = (x) };	\
	mh_i32_collision_get(h, &_node, NULL);				\
})
#define put(x) ({							\
	const struct mh_i32_collision_node_t _node = { .key = (x) };	\
	mh_i32_collision_put(h, &_node, NULL, NULL);			\
})
#define key(k) (mh_i32_collision_node(h, k)->key)
#define val(k) (mh_i32_collision_node(h, k)->val)
#define del(k) ({							\
	mh_i32_collision_del(h, k, NULL);				\
})

#include "mhash_body.c"
	footer();
}
Esempio n. 14
0
int main(int argc, char** argv) {
  nsresult res = nullptr;

  nsCOMPtr<nsICharsetConverterManager> gCCM = do_GetService(kCharsetConverterManagerCID, &res);

  if(NS_FAILED(res) && (nullptr != gCCM))
   {
      printf("cannot locate CharsetConverterManager\n");
      return(-1);
   }
   nsAutoString koi8r("KOI8-R");
   res = gCCM->GetUnicodeEncoder(&koi8r,&gKOI8REncoder);
   if(NS_FAILED(res) && (nullptr != gKOI8REncoder))
   {
      printf("cannot locate KOI8-R Encoder\n");
      return(-1);
   }


   npl();
   header();
   
     genCyrillicClass("KOI8", "KOI8-R");
     genCyrillicClass("CP1251", "windows-1251");
     genCyrillicClass("IBM866", "IBM866");
     genCyrillicClass("ISO88595", "ISO-8859-5");
     genCyrillicClass("MacCyrillic", "x-mac-cyrillic");
   footer();
   NS_IF_RELEASE(gKOI8REncoder);
   return(0);
};
Esempio n. 15
0
    void XmlOutput::generate(ostream& os, bool incl_ok_tests, const string& name)
    {
        ostringstream   ss;
        header(os);

        table_header(os, "FailedTests");
        for_each(_suites.begin(), _suites.end(), TestSuiteRowFalse(os));
        table_footer(os, "FailedTests");

        table_header(os, "SuccessfulTests");
        for_each(_suites.begin(), _suites.end(), TestSuiteRowTrue(os));
        table_footer(os, "SuccessfulTests");

        ///> Summary
        table_header(os, "Statistics");
        ss.str(""), ss << _total_tests;
        table_entry(os, ss.str(), "Tests");
        ss.str(""),  ss << _total_errors;
        table_entry(os, ss.str(), "FailuresTotal");
        table_entry(os, "0", "Errors");
        table_entry(os, ss.str(), "Failures");
        table_footer(os, "Statistics");

        footer(os);
    }
Esempio n. 16
0
static int
test_compare_uints(void)
{
	plan(227);
	header();

	test_compare_uint(0, 0);
	test_compare_uint(0, 0);

	uint64_t nums[] = {
		0, 1, 0x7eU, 0x7fU, 0x80U, 0xfeU, 0xffU, 0xfffeU, 0xffffU,
		0x10000U, 0xfffffffeU, 0xffffffffU, 0x100000000ULL,
		0xfffffffffffffffeULL, 0xffffffffffffffffULL
	};

	int count = sizeof(nums) / sizeof(*nums);
	for (int i = 0; i < count; i++) {
		for (int j = 0; j < count; j++) {
			test_compare_uint(nums[i], nums[j]);
		}
	}

	footer();
	return check_plan();
}
Esempio n. 17
0
void
region_test_truncate()
{
	header();

	struct region region;

	region_create(&region, &cache);

	void *ptr = region_alloc(&region, 10);

	fail_unless(ptr);

	size_t used = region_used(&region);

	region_alloc(&region, 10000);
	region_alloc(&region, 10000000);

	region_truncate(&region, used);

	fail_unless(region_used(&region) == used);

	region_free(&region);

	footer();
}
Esempio n. 18
0
static int
test_strls(void)
{
	plan(78);
	header();

	test_strl(0x00U, "\xa0", 1);
	test_strl(0x01U, "\xa1", 1);
	test_strl(0x1eU, "\xbe", 1);
	test_strl(0x1fU, "\xbf", 1);

	test_strl(0x20U, "\xd9\x20", 2);
	test_strl(0xfeU, "\xd9\xfe", 2);
	test_strl(0xffU, "\xd9\xff", 2);

	test_strl(0x0100U, "\xda\x01\x00", 3);
	test_strl(0xfffeU, "\xda\xff\xfe", 3);
	test_strl(0xffffU, "\xda\xff\xff", 3);

	test_strl(0x00010000U, "\xdb\x00\x01\x00\x00", 5);
	test_strl(0xfffffffeU, "\xdb\xff\xff\xff\xfe", 5);
	test_strl(0xffffffffU, "\xdb\xff\xff\xff\xff", 5);

	footer();
	return check_plan();
}
Esempio n. 19
0
static int
test_binls(void)
{
	plan(78);
	header();

	test_binl(0x00U, "\xc4\x00", 2);
	test_binl(0x01U, "\xc4\x01", 2);
	test_binl(0x1eU, "\xc4\x1e", 2);
	test_binl(0x1fU, "\xc4\x1f", 2);

	test_binl(0x20U, "\xc4\x20", 2);
	test_binl(0xfeU, "\xc4\xfe", 2);
	test_binl(0xffU, "\xc4\xff", 2);

	test_binl(0x0100U, "\xc5\x01\x00", 3);
	test_binl(0xfffeU, "\xc5\xff\xfe", 3);
	test_binl(0xffffU, "\xc5\xff\xff", 3);

	test_binl(0x00010000U, "\xc6\x00\x01\x00\x00", 5);
	test_binl(0xfffffffeU, "\xc6\xff\xff\xff\xfe", 5);
	test_binl(0xffffffffU, "\xc6\xff\xff\xff\xff", 5);

	footer();
	return check_plan();
}
Esempio n. 20
0
static int
test_uints(void)
{
	plan(135);
	header();

	test_uint(0U, "\x00", 1);
	test_uint(1U, "\x01", 1);
	test_uint(0x7eU, "\x7e", 1);
	test_uint(0x7fU, "\x7f", 1);

	test_uint(0x80U, "\xcc\x80", 2);
	test_uint(0xfeU, "\xcc\xfe", 2);
	test_uint(0xffU, "\xcc\xff", 2);

	test_uint(0xfffeU, "\xcd\xff\xfe", 3);
	test_uint(0xffffU, "\xcd\xff\xff", 3);

	test_uint(0x10000U, "\xce\x00\x01\x00\x00", 5);
	test_uint(0xfffffffeU, "\xce\xff\xff\xff\xfe", 5);
	test_uint(0xffffffffU, "\xce\xff\xff\xff\xff", 5);

	test_uint(0x100000000ULL,
	     "\xcf\x00\x00\x00\x01\x00\x00\x00\x00", 9);
	test_uint(0xfffffffffffffffeULL,
	     "\xcf\xff\xff\xff\xff\xff\xff\xff\xfe", 9);
	test_uint(0xffffffffffffffffULL,
	     "\xcf\xff\xff\xff\xff\xff\xff\xff\xff", 9);

	footer();
	return check_plan();
}
Esempio n. 21
0
static int
test_ints(void)
{
	plan(153);
	header();

	test_int(-0x01, "\xff", 1);
	test_int(-0x1e, "\xe2", 1);
	test_int(-0x1f, "\xe1", 1);
	test_int(-0x20, "\xe0", 1);
	test_int(-0x21, "\xd0\xdf", 2);

	test_int(-0x7f, "\xd0\x81", 2);
	test_int(-0x80, "\xd0\x80", 2);

	test_int(-0x81, "\xd1\xff\x7f", 3);
	test_int(-0x7fff, "\xd1\x80\x01", 3);
	test_int(-0x8000, "\xd1\x80\x00", 3);

	test_int(-0x8001, "\xd2\xff\xff\x7f\xff", 5);
	test_int(-0x7fffffff, "\xd2\x80\x00\x00\x01", 5);
	test_int(-0x80000000LL, "\xd2\x80\x00\x00\x00", 5);

	test_int(-0x80000001LL,
	     "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", 9);
	test_int(-0x80000001LL,
	     "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", 9);
	test_int(-0x7fffffffffffffffLL,
	     "\xd3\x80\x00\x00\x00\x00\x00\x00\x01", 9);
	test_int((int64_t)-0x8000000000000000LL,
	     "\xd3\x80\x00\x00\x00\x00\x00\x00\x00", 9);

	footer();
	return check_plan();
}
Esempio n. 22
0
int main(void)
{
     //Redirect before initializing headers
     mysqlpp::Connection c(false);
     if (!c.connect("okzoniom", "localhost", "okzoniom", getDBIdent().c_str())) {
          cgi_redirect("./error.okz?state=err_db");
          return 0;
     } else {
          //Set UTF8
          mysqlpp::Query q = c.query("SET NAMES utf8");
          q.exec();
     }

     cgi_init();
     cgi_session_save_path("sessions/");
     cgi_session_start();

     cgi_process_form();
     cgi_init_headers();

     header("sidebar_player_list");
     menu();
     sidebar();
     body(c);
     footer();

     cgi_end();
     return 0;
}
Esempio n. 23
0
QByteArray MediaManager::createMultipartFormData(const QMap< QString, QByteArray >& formdata,
                                                 const QList< QMap< QString, QByteArray > >& mediaFiles)
{
    QByteArray newLine("\r\n");
    QString formHeader( newLine + "Content-Disposition: form-data; name=\"%1\"" );
    QByteArray header(newLine + "--AaB03x");
    QByteArray footer(newLine + "--AaB03x--");
    QString fileHeader(newLine + "Content-Disposition: file; name=\"%1\"; filename=\"%2\"");
    QByteArray data;

    data.append(header);
    
    if ( !mediaFiles.isEmpty() ) {
        QList< QMap< QString, QByteArray > >::const_iterator it1 = mediaFiles.constBegin();
        QList< QMap< QString, QByteArray > >::const_iterator endIt1 = mediaFiles.constEnd();
        for(; it1!=endIt1; ++it1){
            data.append( fileHeader.arg(it1->value("name").data()).arg(it1->value("filename").data()).toUtf8() );
            data.append(newLine + "Content-Type: " + it1->value("mediumType"));
            data.append(newLine);
            data.append(newLine + it1->value("medium"));
        }
    }
    
    QMap< QString, QByteArray >::const_iterator it = formdata.constBegin();
    QMap< QString, QByteArray >::const_iterator endIt = formdata.constEnd();
    for(;it!=endIt; ++it){
        data.append(header);
        data.append(formHeader.arg(it.key()).toLatin1());
        data.append(newLine);
        data.append(newLine + it.value());
    }
    data.append(footer);

    return data;
}
Esempio n. 24
0
void Render::Html::contest(int cid){
    Contest c(cid);
    if(!c) return notFound("Contest");
    header(c.name());
    o << "<h2>" + escape(c.name()) + "</h2>"
         "<div class=\"contest\">";
    std::string descr = c.getDescription();
    if(!descr.empty())
        o << "<div class=\"description\">" << descr << "</div>";
    o << "<h3 id=\"submissions\">" << icon("disc") << " Submissions</h3>";
    std::vector<Track> tracks = c.submissions();
    submissions(c, tracks);
    if(Session::user() && c.state()==Contest::Submissions){
        std::vector<Track> utracks = Session::user().tracks();
        std::vector<Track> toSubmit;
        for(std::vector<Track>::const_iterator i=utracks.begin(); i!=utracks.end(); i++){
            if(std::find(tracks.begin(),tracks.end(),*i)==tracks.end())
                toSubmit.push_back(*i);
        }
        if(!toSubmit.empty()){
            o << "<form action=\"" + c.url() + "/submit\" method=\"post\">"
                 "Submit a track : "
                 "<select name=\"tid\">";
            for(std::vector<Track>::const_iterator i=toSubmit.begin(); i!=toSubmit.end(); i++)
                o << "<option value=\"" << number(i->id()) << "\">" << escape(i->title()) << "</option>";
            o << "</select>"
                 " <input type=\"submit\" value=\"Submit\" />"
                 "</form>";
        }
    }
    o << "</div>";
    footer();
}
Esempio n. 25
0
void cnpy::parse_zip_footer(FILE* fp, unsigned short& nrecs, unsigned int& global_header_size, unsigned int& global_header_offset)
{
    std::vector<char> footer(22);
    fseek(fp,-22,SEEK_END);
    size_t res = fread(&footer[0],sizeof(char),22,fp);
    if(res != 22)
        throw std::runtime_error("parse_zip_footer: failed fread");
#ifdef DEBUG
    unsigned short disk_no, disk_start, nrecs_on_disk, comment_len;
    disk_no = *(unsigned short*) &footer[4];
    disk_start = *(unsigned short*) &footer[6];
    nrecs_on_disk = *(unsigned short*) &footer[8];
    nrecs = *(unsigned short*) &footer[10];
    global_header_size = *(unsigned int*) &footer[12];
    global_header_offset = *(unsigned int*) &footer[16];
    comment_len = *(unsigned short*) &footer[20];

    assert(disk_no == 0);
    assert(disk_start == 0);
    assert(nrecs_on_disk == nrecs);
    assert(comment_len == 0);
#else
    (void)nrecs;
    (void)global_header_size;
    (void)global_header_offset;
#endif
}
Esempio n. 26
0
static void
test_ctz_clz(void)
{
	header();

	for (size_t i = 0; i < sizeof(vals) / sizeof(vals[0]); i++) {
		if (vals[i] == 0)
			continue;

		uint64_t val64 = vals[i];
		uint32_t val32 = (uint32_t) vals[i];

		printf("bit_ctz_u64(%" PRIu64 ") => %d\n", val64,
			bit_ctz_u64(val64));
		printf("bit_clz_u64(%" PRIu64 ") => %d\n", val64,
			bit_clz_u64(val64));

		if (vals[i] > UINT32_MAX)
			continue;

		printf("bit_ctz_u32(%" PRIu32 ") => %d\n", val32,
			bit_ctz_u32(val32));
		printf("bit_clz_u32(%" PRIu32 ") => %d\n", val32,
			bit_clz_u32(val32));
	}

	footer();
}
Esempio n. 27
0
static void
test_index(void)
{
	header();

	int indexes[sizeof(int64_t) * CHAR_BIT];

	for (size_t i = 0; i < sizeof(vals) / sizeof(vals[0]); i++) {
		uint64_t val64 = vals[i];
		uint32_t val32 = (uint32_t) vals[i];

		printf("bit_index_u64(%" PRIu64 ", *, -1) => ", val64);
		test_index_print(indexes, bit_index_u64(val64, indexes, -1));
		printf("\n");

		if (vals[i] > UINT32_MAX)
			continue;

		printf("bit_index_u32(%" PRIu32 ", *, -1) => ", val32);
		test_index_print(indexes, bit_index_u32(val32, indexes, -1));
		printf("\n");
	}

	footer();
}
Esempio n. 28
0
bool ListController::handleEvent(Ion::Events::Event event) {
  if (event == Ion::Events::Up && selectedRow() == -1) {
    footer()->setSelectedButton(-1);
    selectableTableView()->selectCellAtLocation(0, numberOfRows()-1);
    app()->setFirstResponder(selectableTableView());
    return true;
  }
  if (event == Ion::Events::Down) {
    if (selectedRow() == -1) {
      return false;
    }
    selectableTableView()->deselectTable();
    footer()->setSelectedButton(0);
    return true;
  }
  return handleEventOnExpression(event);
}
Esempio n. 29
0
void
test_append()
{
	header();

	/* insert tuple */
	printf("# insert tuple\n");
	struct tnt_tuple *tuple = tnt_tuple(NULL, "%d%s", 1, "first");
	insert_tuple(tuple);
	tnt_tuple_free(tuple);

	/* test append field */
	struct tnt_stream *stream = tnt_buf(NULL);
	printf("# test append field\n");
	update_set_str(stream, 2, "second");
	update(1, stream);
	tnt_stream_free(stream);

	/* test multi append field */
	stream = tnt_buf(NULL);
	printf("# test multi append\n");
	update_set_str(stream, 3, "3");
	update_set_str(stream, 3, "new field value");
	update_set_str(stream, 3, "other new field value");
	update_set_str(stream, 3, "third");
	update(1, stream);
	tnt_stream_free(stream);

	/* test append many field */
	stream = tnt_buf(NULL);
	printf("# test append many fields\n");
	update_set_str(stream, 4, "fourth");
	update_set_str(stream, 5, "fifth");
	update_set_str(stream, 6, "sixth");
	update_set_str(stream, 7, "seventh");
	update_set_str(stream, 8, long_string);
	update(1, stream);
	tnt_stream_free(stream);

	/* test append and change field */
	stream = tnt_buf(NULL);
	printf("# test append and change field\n");
	update_set_str(stream, 9, long_string);
	update_splice_str(stream, 9, 1, 544, "ac");
	tnt_update_arith_i32(stream, 9, TNT_UPDATE_XOR, 0x3ffffff);
	tnt_update_arith_i32(stream, 9, TNT_UPDATE_ADD, 1024);
	update(1, stream);
	tnt_stream_free(stream);

	/* test set to not an exist field */
	stream = tnt_buf(NULL);
	printf("# test set to not an exist field\n");
	update_set_str(stream, 0xDEADBEEF, "invalid!");
	update(1, stream);
	tnt_stream_free(stream);

	footer();
}
int main(int argc, char* argv[]) {
	VirtualCPU cpu0;
	initCPU(&cpu0);

  	//initialise the program
	Settings* set = setup(argc,argv);
	header(set->htmloutput);
	list_Job* list=FileToJobList(set->jobinput); // list would be sorted on arrival time
	list_Job_sort(list, compare_Job_Arrival);

	setSchedulingMode(&cpu0,set->mode);
	setRoundRobinCPUQuanta(&cpu0,set->rr_quanta);
	setMemoryManagement(&cpu0,set->mem_management);

	int clock=cpu0.current_clock;
	int totalclocks=0;
	int startclocks=clock;

	list_iterator_Job* it = malloc(sizeof(*it));
	list_Job_iterator_init(it, list);

	Job* current = list_Job_examine(it);
	while(current!=NULL){
		while(current!=NULL && clock==current->arrival_time){
			if(current->arrival_time < clock){
				//Error when process is behind the clock
				fprintf(stderr,"Process to be scheduled in the past- ERROR\n");
				exit(EXIT_FAILURE);
			}


			if(totalclocks==0)
				startclocks=clock;
			totalclocks+=current->length_time;

			debug_print("%s: %d @ %d \n",current->jobname,current->arrival_time,clock);
			addJobToCPU(&cpu0,current);		
			current= list_Job_next(it);
		}
		clock=incrementClock(&cpu0);
		dumpMemory(clock,set,&cpu0);
		
	}
	free(list);
	while(isCPUIdle(&cpu0)==false){
		debug_print("Incrementing clock %d\n",clock);
		clock=incrementClock(&cpu0);
		dumpMemory(clock,set,&cpu0);
	}
	debug_print_string("Complete!\n");

	list_JobScheduleResult* results = getResults(&cpu0);
	printResultsCompressed(results);

	footer(set->htmloutput);

	return 0;
}