Exemplo n.º 1
0
		inline void check(in_t::ptr_t const &) const {
			for(typeof(list._ptr()) lptr = list; lptr; ++lptr) {
				name_t const &name = lptr.val();

				// #dir "/mod_" #name ".so\0"

				if(module_info_t::lookup(name)) return;

				string_t fname_z = string_t::ctor_t(dir.size() + 5 + name.size() + 4)
					(dir)(CSTR("/mod_"))(name)(CSTR(".so\0"))
				;

				try {
					module_load(fname_z.ptr());
				}
				catch(string_t const &ex) {
					config::error(name.ptr, ex.ptr());
				}

				module_info_t *module_info = module_info_t::lookup(name);
				if(!module_info)
					config::error(name.ptr, "not a phantom module loaded");

				if(!*module_info)
					config::error(name.ptr, "illegal module version");
			}
		}
Exemplo n.º 2
0
SpaceShip::SpaceShip( Scene2::Texture &tex, Scene2::Texture &wp, Scene2::Texture &lazr  ) :LazorTex(lazr) {
	Mvmnt.Key[0] = 'A';
	Mvmnt.Key[1] = 'D';
	Mvmnt.Key[2] = 'W';
	Mvmnt.Key[3] = 'S';
		
	Mvmnt.activate();


	Spr.Pos = 320.0f;
	Spr.Size = 100.0f;
	Spr.Tex = &tex;

	Weapon.Tex = ℘

	Ship = this;

	Fire = 0;

	LaserSfx = Audio::load(CSTR("Media//Audio//pew.wav"),false,0.3f);
	DeathSfx = Audio::load(CSTR("Media//Audio//explosion.wav"));
		//DeathSfx;

	DeathTimer = -1;
}
Exemplo n.º 3
0
obj_t *
symbol_table_unlink (struct symtab *symtab, 
		     enum toplevel_type wanttp, str_ptr wantnm)
{
  obj_t *result;
  struct assign *p, *top = NULL;

  for (p = symtab->assign_start; p; top = p, p = p->next)
    {
      if (p->value->type == wanttp)
	{
	  if (strcmp (CSTR(p->name), CSTR(wantnm)) == 0)
	    break;
	}
    }

  if (p == NULL)
    return NULL;

  if (top == NULL)
    symtab->assign_start = p->next;
  else
    top->next = p->next;

  result = p->value;

  str_free (p->name);
  free (p);

  return result;
}
Exemplo n.º 4
0
	Game() : 
		CntrTex( CSTR("Media//ui//counter.png") ),
		StdShdr( CSTR("Media//shaders//textureVS.glsl"), CSTR("Media//shaders//textureFS.glsl") ),
		PlanetShdr( CSTR("Media//shaders//planetVS.glsl"), CSTR("Media//shaders//planetFS.glsl")  ),
		Tex1( CSTR("Media//armoredrecon_diff.png") ),
		Tex2( CSTR("Media//Tank1DF.png") ),
		NoiseTex( CSTR("Media//checker.png") ),
		Mesh1( CSTR("Media//armoredrecon.fbx") ),
		Mesh2( CSTR("Media//Tank1.FBX") ),
		CarMat( Tex1, StdShdr),
		TankMat(Tex2, StdShdr),
		Car(Mesh1, CarMat),
		Tank(Mesh2, TankMat),
		Cntr(CntrTex, vec2f(900, 50), 0.4f, 0)
	{

		Mvmnt.Key[0] = 'A';
		Mvmnt.Key[1] = 'D';
		Mvmnt.Key[2] = 'S';
		Mvmnt.Key[3] = 'W';
		MoveObj = 0;

		Gm = this;
		for( int i = 12; i--; ) {
			DebugToggles[i].Key = 0x70+i;
			DebugToggles[i].activate();
		}
	}
Exemplo n.º 5
0
smcp_t
smcp_init(
	smcp_t self, uint16_t port
) {
	SMCP_EMBEDDED_SELF_HOOK;

	require(self != NULL, bail);

	if(port == 0)
		port = COAP_DEFAULT_PORT;

#if SMCP_USE_BSD_SOCKETS
	struct sockaddr_in6 saddr = {
#if SOCKADDR_HAS_LENGTH_FIELD
		.sin6_len		= sizeof(struct sockaddr_in6),
#endif
		.sin6_family	= AF_INET6,
		.sin6_port		= htons(port),
	};
#endif

	// Clear the entire structure.
	memset(self, 0, sizeof(*self));

	// Set up the UDP port for listening.
#if SMCP_USE_BSD_SOCKETS
	uint16_t attempts = 0x7FFF;

	self->mcfd = -1;
	self->fd = -1;
	errno = 0;

	self->fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
	int prev_errno = errno;

	require_action_string(
		self->fd >= 0,
		bail, (
			smcp_release(self),
			self = NULL
		),
		strerror(prev_errno)
	);

	// Keep attempting to bind until we find a port that works.
	while(bind(self->fd, (struct sockaddr*)&saddr, sizeof(saddr)) != 0) {
		// We should only continue trying if errno == EADDRINUSE.
		require_action_string(errno == EADDRINUSE, bail,
			{ DEBUG_PRINTF(CSTR("errno=%d"), errno); smcp_release(
				    self); self = NULL; }, "Failed to bind socket");
		port++;

		// Make sure we aren't in an infinite loop.
		require_action_string(--attempts, bail,
			{ DEBUG_PRINTF(CSTR("errno=%d"), errno); smcp_release(
				    self); self = NULL; }, "Failed to bind socket (ran out of ports)");
Exemplo n.º 6
0
void
str_dirname (str_t to, const str_t from, int dirsep)
{
  const char * ptr = strrchr (CSTR(from), dirsep);

  if (ptr == NULL)
    str_copy_c (to, CSTR(from));
  else
    str_copy_c_substr (to, CSTR(from), ptr - CSTR(from));
}
Exemplo n.º 7
0
void
str_get_basename (str_t to, const str_t from, int dirsep)
{
  const char * ptr = strrchr (CSTR(from), dirsep);

  if (ptr == NULL)
    str_copy_c (to, CSTR(from));
  else
    str_copy_c (to, ptr + 1);
}
Exemplo n.º 8
0
struct assign *
symbol_table_cell_find (struct symtab *symtab, str_ptr name)
{
  struct assign *cell = symtab->assign_start;
  while (cell)
    {
      if (strcmp (CSTR(cell->name), CSTR(name)) == 0)
	break;
      cell = cell->next;
    }
  return cell;
}
Exemplo n.º 9
0
Arquivo: obj.C Projeto: Civil/phantom
void helper_t<obj_t *>::print(out_t &out, int, obj_t *const &val) {
	if(val) {
		out(val->name);
	}
	else
		out(CSTR("NULL"));
}
Exemplo n.º 10
0
Arquivo: main.c Projeto: wuwx/simba
int main()
{
    sys_start();

    uart_soft_init(&uart,
                   &pin_d4_dev,
                   &pin_d3_dev,
                   &exti_d3_dev,
                   9600,
                   qinbuf,
                   sizeof(qinbuf));

    fs_command_init(&cmd_at,
                    CSTR("/at"),
                    cmd_at_cb,
                    NULL);
    fs_command_register(&cmd_at);

    std_printf(FSTR("Welcome to HC-0X configuration tool!\r\n"
                    "\r\n"
                    "SETUP: Connect pin34 to VCC so the device enters AT mode.\r\n"
                    "\r\n"
                    "Type 'at' to start communicating with the device.\r\n"));

    shell_init(&shell,
               sys_get_stdin(),
               sys_get_stdout(),
               NULL,
               NULL,
               NULL,
               NULL);
    shell_main(&shell);

    return (0);
}
Exemplo n.º 11
0
Arquivo: rom.c Projeto: k5g/emulika
static int fzip2file(struct zip *fzip, int index, const string filename)
{
    FILE *f = NULL;
    byte *buffer = NULL;
    size_t buflen;

    if((buflen=fzip2buffer(fzip, index, &buffer))<0)
        goto error;

    // Write unzipped file
    if((f = fopen(CSTR(filename), "wb"))==NULL)
        goto error;
    fwrite(buffer, buflen, 1, f);
    fclose(f); f = NULL;

    free(buffer);
    return 1;

error:
    free(buffer);
    if(f)
        fclose(f);

    return 0;
}
Exemplo n.º 12
0
void Palette::PresetApply(PalettePreset &preset)
{
static const U16 b_arr[] = { 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3, 0, 0, 1, 3 };
static const U16 r_arr[] = { 0, 0, 0, 1, 3, 1, 3, 0, 0, 0, 0, 1, 3, 1, 3 };
static const U16 g_arr[] = { 0, 0, 0, 0, 0, 0, 0, 1, 3, 1, 3, 1, 3, 1, 3 };
const auto &coeffs = preset.CoeffsGet();
const U16 brights[] = { coeffs.zz, coeffs.zn, coeffs.nn, coeffs.zb, coeffs.nb, 0 /*dummy*/, coeffs.bb };
U16 r, g, b;
U16 tr, tg, tb;

    D_LOG(D_DEBUG, D_LOG_MSG("Apply palette preset: %s", CSTR(preset.NameGet())));
    clear();
    for (auto row = 0; row < PALETTE_ROWS; ++row) {
        for (auto col = row; col < PALETTE_COLUMS; ++col) {
            b = brights[b_arr[row] + b_arr[col]];
            r = brights[r_arr[row] + r_arr[col]];
            g = brights[g_arr[row] + g_arr[col]];

            tr = ((r * coeffs.r11) + (g * coeffs.g12) + (b * coeffs.b13)) / (U16)0x100;
            tg = ((r * coeffs.r21) + (g * coeffs.g22) + (b * coeffs.b23)) / (U16)0x100;
            tb = ((r * coeffs.r31) + (g * coeffs.g32) + (b * coeffs.b33)) / (U16)0x100;
            const PaletteItem item(tr, tg, tb);
            if (TRUE != IsDuplicate(item)) { // Filter duplicate colors.
                append(item);
                //D_LOG(D_DEBUG, D_LOG_MSG("row=%i,\tcol=%i,\tr=%i,\tg=%i,\tb=%i", row, col, tr, tg, tb));
            }
        }
    }
}
Exemplo n.º 13
0
int
parse_strategy (struct symtab *symtab, const char *text)
{
  str_t workdir;
  int status;

  str_init (workdir, 64);
  str_getcwd (workdir);

  clean_error_msgs ();

  lexer_init (text);

  symbol_table_clean (symtab);

  config_set_default (symtab->config_table);

  status = yyparse (symtab);

  chdir (CSTR(workdir));
  str_free (workdir);

  if (status != 0)
    symbol_table_clean (symtab);

  return status;
}
Exemplo n.º 14
0
int
write_mat_file (const char *filename, const disp_t *d, 
		double lmin, double lmax, double lstep)
{
  FILE *f;
  int jinf, jsup, step;
  int j;

  f = fopen(filename, "w");

  if (f == NULL)
    return 1;

  fprintf (f, "%s\n", CSTR(d->name));
  fprintf (f, "nm\n");
  fprintf (f, "NK\n");

  jinf = rint (lmin * 100.0);
  jsup = rint (lmax * 100.0);
  step = rint (lstep * 100.0);

  for (j = jinf; j <= jsup; j += step)
    {
      double lambda = j / 100.0;
      cmpl n = n_value (d, lambda);

      fprintf (f, "%7.2f\t%.7f\t%.7f\n", lambda, creal(n), - cimag(n));
    }

  fclose (f);

  return 0;
}
Exemplo n.º 15
0
void initmodules(const string basedir)
{
	log4me_init(LOG_EMU_NONE);
#ifdef WIN32
	string redirect = pathcombc(strdups(basedir), "output.txt");
	log4me_redirectoutput(CSTR(redirect));
	strfree(redirect);
#endif

    LIBXML_TEST_VERSION;

    clock_init();

    // initialize SDL video
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK)<0) {
        log4me_error(LOG_EMU_SDL, "Unable to init SDL: %s\n", SDL_GetError());
        exit(EXIT_FAILURE);
    }
    // make sure SDL cleans up before exit
    pushexit(SDL_Quit);

    video_init();
    input_init();

    seticon(getcurrentwindow());
}
Exemplo n.º 16
0
void out_t::helper_t<sizeval_t>::print(
	out_t &out, sizeval_t const &s, char const *fmt
) {
	unsigned short int prec = 63;

	if(fmt) {
		if(*fmt == '.') {
			prec = 0;
			++fmt;
			while(*fmt >= '0' && *fmt <= '9') (prec *= 10) += (*(fmt++) - '0');
		}
		if(!prec) prec = 63;
	}
	else {
		out.print((uint64_t)s);
		return;
	}

	if(s == sizeval::unlimited) {
		out(CSTR("unlimited"));
	} else if(s) {
		if(((s - (s % sizeval::exa)) >> prec) >= (s % sizeval::exa)) {
			out.print((uint64_t)(s / sizeval::exa))('E');
		}
		else if(((s - (s % sizeval::peta)) >> prec) >= (s % sizeval::peta)) {
			out.print((uint64_t)(s / sizeval::peta))('P');
		}
		else if(((s - (s % sizeval::tera)) >> prec) >= (s % sizeval::tera)) {
Exemplo n.º 17
0
bool ChromeClient::runJavaScriptPrompt(WebCore::Frame*, const WTF::String& msg, const WTF::String& defaultValue, WTF::String& result)
{
    outputMsg(L"JavaScript Prompt %s %s\n", CSTR(msg), CSTR(defaultValue));

    wke::CWebViewHandler& handler = m_webView->m_handler;
    if (!handler.promptBoxCallback)
        return false;

    wke::CString wkeMsg(msg);
    wke::CString wkeDefaultResult(defaultValue);
    wke::CString wkeResult("");
    if (!handler.promptBoxCallback(m_webView, handler.promptBoxCallbackParam, &wkeMsg, &wkeDefaultResult, &wkeResult))
        return false;

    result = wkeResult.original();
    return true;
}
Exemplo n.º 18
0
void out_t::helper_t<netaddr_ipv4_t>::print(
	out_t &out, netaddr_ipv4_t const &netaddr, char const *
) {
	if(netaddr)
		out.print(netaddr.address())(':').print(netaddr.port());
	else
		out(CSTR("<unset>"));
}
Exemplo n.º 19
0
  const char *assign_iter() {
    while (m_iter = symbol_table_next (m_symtab, m_iter))
      {
	if (m_iter->value->type == TL_TYPE_DISP)
	  break;
      }
    return (m_iter ? CSTR(m_iter->name) : 0);
  }
Exemplo n.º 20
0
void scheduler_t::stat_print() const {
	{
		stat::ctx_t ctx(CSTR("bqs"), 1);
		for(size_t i = 0; i < threads; ++i)
			bq_thrs[i].stat_print();
	}

	stat_print_ext();
}
Exemplo n.º 21
0
  const char *library_iter() {
    const char* name;
    if (dispers_library_get(m_lib_iter ++, &name))
      {
	str_printf (m_name_buffer, "lib:%s", name);
	return CSTR(m_name_buffer);
      }
    return NULL;
  }
Exemplo n.º 22
0
char LTable_Reverse(LTable* lt, const char* hash, char* dst)
{
	s32 res = binaryFind(lt, hash);
	if (res < 0)
		return 0;

	memcpy(dst, CSTR(res), lt->l_string);
	return 1;
}
Exemplo n.º 23
0
QString getImageFile(const QString& name){
	if (QFile::exists(DataDir+"/icons/"+name))
		return DataDir+"/icons/"+name;
	else{
		QString errMsg = QApplication::translate("Main","File '%1' could not be found.").arg(name);
		showErrMsg(errMsg);
		qFatal("Error: '%s'", CSTR(errMsg));
		return QString();
	}
}
Exemplo n.º 24
0
void LTable_Print(LTable* lt)
{
	for (u32 i = 0; i < lt->n_rows; i++)
	{
		printHash(CHASH(i), lt->l_hash);
		printf(" ");
		printString(CSTR(i), lt->l_string);
		printf("\n");
	}
}
Exemplo n.º 25
0
int
disp_sample_table_write(writer_t *w, const disp_t *_d)
{
    const struct disp_sample_table *d = &_d->disp.sample_table;
    writer_printf(w, "table \"%s\" %d", CSTR(_d->name), d->len);
    writer_newline_enter(w);
    rc_matrix_write(w, d->table, RC_MATRIX_TRANSPOSED);
    writer_newline_exit(w);
    return 0;
}
Exemplo n.º 26
0
void ChromeClient::addMessageToConsole(WebCore::MessageSource source, WebCore::MessageType type, WebCore::MessageLevel level, const WTF::String& message, unsigned int lineNumber, const WTF::String& url)
{
    outputMsg(L"console message %s %d %s\n", CSTR(message), lineNumber, CSTR(url));

    wke::CWebViewHandler& handler = m_webView->m_handler;
    if (!handler.consoleMessageCallback)
        return;

    wkeConsoleMessage msgStruct;
    msgStruct.source = (wkeMessageSource)source;
    msgStruct.type = (wkeMessageType)type;
    msgStruct.level = (wkeMessageLevel)level;
    msgStruct.lineNumber = lineNumber;

    wke::CString csMessage = message;
    wke::CString csUrl = url;
    msgStruct.message = &csMessage;
    msgStruct.url = &csUrl;
    handler.consoleMessageCallback(m_webView, handler.consoleMessageCallbackParam, &msgStruct);
}
Exemplo n.º 27
0
void ChromeClient::runJavaScriptAlert(WebCore::Frame*, const WTF::String& msg)
{
    outputMsg(L"JavaScript Alert %s\n", CSTR(msg));

    wke::CWebViewHandler& handler = m_webView->m_handler;
    if (!handler.alertBoxCallback)
        return;

    wke::CString wkeMsg(msg);
    handler.alertBoxCallback(m_webView, handler.alertBoxCallbackParam, &wkeMsg);
}
Exemplo n.º 28
0
bool ChromeClient::runJavaScriptConfirm(WebCore::Frame*, const WTF::String& msg)
{
    outputMsg(L"JavaScript Confirm %s\n", CSTR(msg));

    wke::CWebViewHandler& handler = m_webView->m_handler;
    if (!handler.confirmBoxCallback)
        return false;

    wke::CString wkeMsg(msg);
    return handler.confirmBoxCallback(m_webView, handler.confirmBoxCallbackParam, &wkeMsg);
}
Exemplo n.º 29
0
void savetiles(mastersystem *sms, const string debugdir)
{
    string filename = gettimedfilename(CSTR(sms->romname), "bmp");

    string tilesfilename = strdups(debugdir);
    pathcombs(tilesfilename, filename);

    tms9918a_save_tiles(&sms->vdp, tilesfilename);
    strfree(filename);
    strfree(tilesfilename);
}
Exemplo n.º 30
0
/**
 * Initialize the plugger.
 */
void ProcessorPlugin::init(void) {
	initialized_paths = true;
	plugger.resetPaths();
	elm::system::Path path = elm::system::Path::current().append(".otawa/proc");
	plugger.addPath(path);
	path = elm::system::Path::home().append(".otawa/proc");
	plugger.addPath(path);
	path = MANAGER.prefixPath() / "lib/otawa/proc";
	plugger.addPath(path);
	path = Path(CSTR(PROC_PATHS));
	plugger.addPath(path);
}