Exemple #1
0
static int c_s_tb(u_sourceinfo *si, u_msg *msg)
{
	char *chan = msg->argv[0];
	int ts;
	u_chan *c;

	msg->propagate = CMD_DO_BROADCAST;

	if (!(c = u_chan_get(chan))) {
		u_log(LG_WARN, "%I sent TB for nonexistent %s", si, chan);
		return 0;
	}

	ts = atoi(msg->argv[1]);
	/* TODO: TS checking */
	c->topic_time = ts;

	if (msg->argc > 3) {
		u_strlcpy(c->topic_setter, msg->argv[2], MAXNICKLEN+1);
	} else {
		snf(FMT_USER, c->topic_setter, MAXNICKLEN+1, "%I", si);
	}

	u_strlcpy(c->topic, msg->argv[msg->argc - 1], MAXTOPICLEN+1);

	u_sendto_chan(c, NULL, ST_USERS, ":%I TOPIC %C :%s", si, c, c->topic);

	return 0;
}
Exemple #2
0
void u_udb_put_i(u_udb *db, long n)
{
	char buf[512];

	snf(FMT_LOG, buf, 512, "%d", n);
	u_udb_put_s(db, buf);
}
Exemple #3
0
void u_udb_row_start(u_udb *db, char *name)
{
	if (db->reading) {
		u_log(LG_ERROR, "Tried to start row while reading database!");
		return;
	}

	db->sz = snf(FMT_LOG, db->line, UDB_LINE_SIZE, "%s", name);
}
Exemple #4
0
void u_udb_put_s(u_udb *db, char *s)
{
	char *p = db->buf;

	while (*s) {
		switch (*s) {
		case ' ':
		case '\\':
			*p++ = '\\';
		default:
			*p++ = *s++;
		}
	}

	db->sz += snf(FMT_LOG, db->line + db->sz,
	              UDB_LINE_SIZE - db->sz, " %s", s);
}
		TEMP_PAR
		void NUM_SYS::compute()
		{
			//Calculate inverse:
			IntSmithNormalForm snf(_base,
					                   true, /* use shape correction */
														 IntSmithNormalForm::LEFT_POSITIVE);
			IntAdjointMatrix adjointForm(_base);
			IMatrix adj = adjointForm["ADJOINT"];
			_G = snf["S"];
			_U = snf["U"];
      BaseProperties props = calculateBaseProperties();
			setBorder();

			createHashTable();

			FMatrix f_adj = I_FConverter::template convertMatrix<Matrix>(adj);
      FMatrix f_G = I_FConverter::template convertMatrix<Matrix>(_G);

      FLOAT_TYPE determinant = FMCalculator::calculateDeterminant(f_G);
			_baseInverse = number_traits_float::multiplicativeUnit/determinant * f_adj;

      if (!(props & EXPANSIVE))
      {
        throw Exceptions::RuntimeException("Number system is not expansive", PROP_EXC_ID);
      }
      else if (!(props & REGULAR))
      {
        throw Exceptions::RuntimeException("Number system is not regular", PROP_EXC_ID);
      }
      else if (!(props & DETERMINANT_NOT_ONE))
      {
        throw Exceptions::RuntimeException("Number system determinant error",
                                           PROP_EXC_ID);
      }
			

      props = calculateBaseProperties();
      if (!(props & CONGRUENT_DIGITSET))
      {
        throw Exceptions::RuntimeException("Number system hasn't got congruent digits",
                                           PROP_EXC_ID);
      }

		}
Exemple #6
0
int u_log(int level, char* fmt, ...)
{
	static bool logging = false;
	struct tm *tm;
	char tmbuf[512];
	char buf[BUFSIZE];
	va_list va;

	if (level > u_log_level)
		return 0;

	if (logging)
		return 0;
	logging = true;

	va_start(va, fmt);
	vsnf(FMT_LOG, buf, BUFSIZE, fmt, va);
	va_end(va);

	tm = localtime(&NOW.tv_sec);
	snf(FMT_LOG, tmbuf, 512, "%04d/%02d/%02d %02d:%02d:%02d",
	    tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
	    tm->tm_hour, tm->tm_min, tm->tm_sec);

	struct hook_log hook;
	hook.level = level;
	hook.time = tmbuf;
	hook.line = buf;
	if (log_hook == NULL)
		log_hook = u_hook_get(HOOK_LOG);
	u_hook_call(log_hook, &hook);

	logging = false;

	return u_log_handler(level, tmbuf, buf);
}