Ejemplo n.º 1
0
unsigned code_do_range(Env& env) {
    
    int n = pop<int>(env);
    int i = pop<int>(env);
    
    Code code = pop<Code>(env);

    int direction = 1;
    if (i > n) direction = -1;

    push(env, i);
    if (i != n) {
    
	i += direction;
	    
	CodeArray vec(5);
	static Code quote   = parse("CODE.QUOTE");
	static Code DoRange = parse("CODE.DO*RANGE");
	
	vec[0] = DoRange;
	vec[1] = code;
	vec[2] = quote;
	vec[3] = Code(new Literal<int>(n));
	vec[4] = Code(new Literal<int>(i));

	env.push_guarded( CodeList::adopt(vec)); //Code(new CodeList(vec)));
	
	
    }
    env.push_guarded(code);
    
    return 1;
}
Ejemplo n.º 2
0
Archivo: zlib.c Proyecto: DQNEO/minigit
int main(int argc, char *argv[]) {
  ParseOptions(argc, argv);
  if (test_mode == HELP_MODE) {
    printf("Usage: %s [OPTION]... [FILE]...\n"
        "Version: zlib-%s\n"
        "Options:\n"
        "  -d, --deflate  圧縮します (default)\n"
        "  -i, --inflate  伸長します\n"
        "  -g, --gzip     gzip 形式で圧縮します\n"
        "  -z, --zlib     zlib 形式で圧縮します (default)\n"
        "  -l, --level=[0-9]    圧縮レベルを指定します (default: 6)\n"
        "  -o, --output=[FILE]  出力ファイルを指定します (default: stdout)\n"
        "  -h, --help     このヘルプを表示します\n",
        argv[0], zlibVersion());
    return 0;
  }

  FILE *output_file = stdout;
  if (output_file_name != NULL) {
    output_file = fopen(output_file_name, "wb");
    if (output_file == NULL) {
      ERROR("%s", output_file_name);
    }
  }

  // 入力ファイルの指定がなければ,標準入力を使います.
  if (optind >= argc) {
    Code(stdin, output_file);
  } else {
    for (int i = optind; i < argc; ++i) {
      const char *input_file_name = argv[i];
      FILE *input_file = fopen(input_file_name, "rb");
      if (input_file == NULL) {
        ERROR("%s", input_file_name);
      }

      Code(input_file, output_file);
      if (fclose(input_file) != 0) {
        ERROR("%s", input_file_name);
      }
    }
  }

  if (output_file != stdout) {
    if (fclose(output_file) != 0) {
      ERROR("%s", output_file_name);
    }
  }

  return 0;
}
Ejemplo n.º 3
0
void Lex::Dump(int pos)
{
#ifdef LOGNEXT
	int code = Code(pos);
	switch(code) {
	case t_string: LOG(AsCString(Text(pos))); break;
	case t_double: LOG(Double(pos)); break;
	case t_integer: LOG(Int(pos)); break;
	case t_character: LOG("char " << AsCString(String(Chr(pos), 1))); break;
	default:
		if(code < 0)
			LOG(decode(Code(),
				t_dblcolon, "::",
				t_mulass, "*=",
				t_divass, "/=",
				t_modass, "%=",
				t_xorass, "^=",
				t_neq, "!=",
				t_dot_asteriks, ".*",
				t_elipsis, "...",
				t_inc, "++",
				t_addass, "+=",
				t_dec, "--",
				t_arrow_asteriks, "->*",
				t_arrow, "->",
				t_subass, "-=",
				t_and, "&&",
				t_andass, "&=",
				t_or, "||",
				t_orass, "|=",
				t_eq, "==",
				t_shl, "<<",
				t_shlass, "<<=",
				t_le, "<=",
				t_shr, ">>",
				t_shrass, ">>=",
				t_ge, ">=",
				te_integeroverflow, "<integer overflow>",
				te_badcharacter, "<bad char>",
				te_badstring, "<bad string>",
				"???"));
		else
		if(code < 256)
			LOG((char)code);
		else
			LOG(id[code - 256]);
	}
#endif
}
Ejemplo n.º 4
0
void Init() {
    AddService(new PTM_Play_Interface);
    AddService(new PTM_Sysm_Interface);
    AddService(new PTM_U_Interface);

    shell_open = true;
    battery_is_charging = true;

    // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't exist
    FileSys::Path archive_path(ptm_shared_extdata_id);
    auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
    // If the archive didn't exist, create the files inside
    if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
        // Format the archive to create the directories
        Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
        // Open it again to get a valid archive now that the folder exists
        archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
        ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");

        FileSys::Path gamecoin_path("gamecoin.dat");
        FileSys::Mode open_mode = {};
        open_mode.write_flag = 1;
        open_mode.create_flag = 1;
        // Open the file and write the default gamecoin information
        auto gamecoin_result = Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
        if (gamecoin_result.Succeeded()) {
            auto gamecoin = gamecoin_result.MoveFrom();
            gamecoin->backend->Write(0, sizeof(GameCoin), 1, reinterpret_cast<const u8*>(&default_game_coin));
            gamecoin->backend->Close();
        }
    }
}
Ejemplo n.º 5
0
TIntegrationEvent::TIntegrationEvent(	char *name,
    char *short_name,
    INT_TIME time,
    long code,
    int priority,
    TIntegrationEventCategory category)
/* --------------------------
     * Author  : Bruno Orsier                : Original Delphi code
             Diego Segura / Gilles Orazi : C++ translation
 * Created : 06/2002
 * Purpose :
 * History :
 * -------------------------- */
{
    assert(strlen(name) < INT_MAX_STRING_LENGTH);
    assert(strlen(short_name) < INT_MAX_SHORT_STRING_LENGTH);
    Name(name);
    Time(time);
    Code(code);
    m_priority = priority;
    ShortName(short_name);
    Category(category);
#ifdef INTEGR_DEBUG
    ++Glob_InEventsCount;
    ++Glob_InEventsTotal;
#endif
}
Ejemplo n.º 6
0
static void WriteGameCoinData(GameCoin gamecoin_data) {
    std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
    FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true);

    FileSys::Path archive_path(ptm_shared_extdata_id);
    auto archive_result = extdata_archive_factory.Open(archive_path);
    std::unique_ptr<FileSys::ArchiveBackend> archive;

    FileSys::Path gamecoin_path("/gamecoin.dat");
    // If the archive didn't exist, create the files inside
    if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
        // Format the archive to create the directories
        extdata_archive_factory.Format(archive_path, FileSys::ArchiveFormatInfo());
        // Open it again to get a valid archive now that the folder exists
        archive = extdata_archive_factory.Open(archive_path).Unwrap();
        // Create the game coin file
        archive->CreateFile(gamecoin_path, sizeof(GameCoin));
    } else {
        ASSERT_MSG(archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");
        archive = std::move(archive_result).Unwrap();
    }

    FileSys::Mode open_mode = {};
    open_mode.write_flag.Assign(1);
    // Open the file and write the default gamecoin information
    auto gamecoin_result = archive->OpenFile(gamecoin_path, open_mode);
    if (gamecoin_result.Succeeded()) {
        auto gamecoin = std::move(gamecoin_result).Unwrap();
        gamecoin->Write(0, sizeof(GameCoin), true, reinterpret_cast<const u8*>(&gamecoin_data));
        gamecoin->Close();
    }
}
Ejemplo n.º 7
0
  bool VariablesFromQueryAffected() 
    {
      IU_COMMAND* vars = Code()->AllVars();
      while (vars)
	{
	  if (vars->Symbol().var()->Binding()) { return true; };
	  vars = vars->NextVar();
	};
      return false;
    };
Ejemplo n.º 8
0
FloatRegisters::Code
FloatRegisters::FromName(const char *name)
{
    for (size_t i = 0; i < Total; i++) {
        if (strcmp(GetName(i), name) == 0)
            return Code(i);
    }

    return Invalid;
}
Ejemplo n.º 9
0
extern  void    BEAbort() {
//=========================

    Action( "BEAbort()%n" );
    CGError( "*****ABORT******%n" );
    Code(   "*****ABORT******%n" );
    Action( "*****ABORT******%n" );
    BEFini();
    exit( 2010 );
}
Ejemplo n.º 10
0
Module::Module() {
    // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't
    // exist
    std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
    FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true);
    FileSys::Path archive_path(ptm_shared_extdata_id);
    auto archive_result = extdata_archive_factory.Open(archive_path);
    // If the archive didn't exist, write the default game coin file
    if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
        WriteGameCoinData(default_game_coin);
    }
}
Ejemplo n.º 11
0
TextureFormat const *
TextureFormat::fromString(std::string const & s)
{
  for (int i = 0; i < Code::NUM; ++i)
  {
    if (s == TextureFormatInternal::nameArray[i])
    {
      return fromCode(Code(i));
    }
  }

  return NULL;
}
Ejemplo n.º 12
0
void QtCUrl::exec(Options& opt)
{
	setOptions(opt);

    if(!FileName.isEmpty())
        File.open(QIODevice::WriteOnly);

    AutoDelete = false;
	_lastCode = Code(curl_easy_perform(_curl));

    if(!FileName.isEmpty())
        File.close();
}
Ejemplo n.º 13
0
unsigned do_times(Env& env) {
    int n = pop<int>(env);
    Code code = pop<Code>(env);

    if (n <= 0) { return 1; }
    
    CodeArray vec(5);
    static Code zero = Code(new Literal<int>(0));
    static Code quote = parse("CODE.QUOTE");
    static Code int_pop = parse("INTEGER.POP");
    static Code DoRange = parse("CODE.DO*RANGE");
    
    vec[0] = DoRange;
    vec[1] = quote;
    vec[2] = cons(int_pop, code);
    vec[3] = Code(new Literal<int>(n-1));
    vec[4] = zero;
    
    env.push_guarded(CodeList::adopt(vec)); //Code(new CodeList(vec)));
    return 1;

}
Ejemplo n.º 14
0
ResultVal<std::shared_ptr<Directory>> ArchiveManager::OpenDirectoryFromArchive(
    ArchiveHandle archive_handle, const FileSys::Path& path) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;

    auto backend = archive->OpenDirectory(path);
    if (backend.Failed())
        return backend.Code();

    auto directory = std::shared_ptr<Directory>(new Directory(std::move(backend).Unwrap(), path));
    return MakeResult<std::shared_ptr<Directory>>(std::move(directory));
}
Ejemplo n.º 15
0
unsigned do_count(Env& env) {
    //if (not has_elements<int>(env,1)) return 1;
    //if (not has_elements<Code>(env,1)) return 1;

    int n = pop<int>(env);
    Code code = pop<Code>(env);

    if (n <= 0) { return 1; }
    
    CodeArray vec(5);
    static Code zero = Code(new Literal<int>(0));
    static Code quote = parse("CODE.QUOTE");
    static Code DoRange = parse("CODE.DO*RANGE");
    
    vec[0] = DoRange;
    vec[1] = quote;
    vec[2] = code;
    vec[3] = Code(new Literal<int>(n-1));
    vec[4] = zero;
    
    env.push_guarded(CodeList::adopt(vec)); //Code(new CodeList(vec)));
    return 1;
}
Ejemplo n.º 16
0
Code Reader::read_code(size_t size_bytes, size_t size_bits) {
    Code res = Code();

    while (bucket.size() < 8 * size_bytes) {
        if (!read_to_bucket())
            break;
    }

    for (int i = 0; i < size_bits; i++) {
        res += bucket.front();
        bucket.pop_front();
    }

    return res;
}
Ejemplo n.º 17
0
void CustomEncoder::Create(const CodePage* target, bool extended) {
    YASSERT(target);

    DefaultChar = (const char*)target->DefaultChar;

    DefaultPlane = new char[256];

    memset(DefaultPlane, 0, 256*sizeof(char));
    for (size_t i = 0; i != 256; ++i)
        Table[i] = DefaultPlane;

    for (size_t i = 0; i != 256; ++i) {
        wchar32 ucode = target->unicode[i];
        if (ucode != BROKEN_RUNE) // always UNASSIGNED
            addToTable(ucode, (unsigned char) i, target);
    }

    if (!extended)
        return;

    for (wchar32 w = 1; w < 65535; w++){
        if (Code(w) == 0){
            wchar32 dw = w;
            while (IsComposed(dw) && Code(dw) == 0){
                const wchar32* decomp_p = NUnicode::Decomposition<true>(dw);
                YASSERT(decomp_p != NULL);

                dw = decomp_p[0];
                if (TCharTraits<wchar32>::GetLength(decomp_p) > 1 && (dw == (wchar32)' ' || dw == (wchar32)'('))
                    dw = decomp_p[1];
            }
            if (Code(dw) != 0 && isGoodDecomp(w, dw))
                addToTable(w, Code(dw), target);
        }
    }
}
Ejemplo n.º 18
0
void XfigPlug::parseColor(QString data)
{
	if (data.isEmpty())
		return;
	int colorNum, dummy;
	QString colorValues;
	ScColor tmp;
	ScTextStream Code(&data, QIODevice::ReadOnly);
	Code >> dummy >> colorNum >> colorValues;
	tmp.setNamedColor(colorValues);
	tmp.setSpotColor(false);
	tmp.setRegistrationColor(false);
	QString namPrefix = "FromXfig%1-"+colorValues;
	CustColors.insert(namPrefix.arg(colorNum), tmp);
	importedColors.insert(colorNum, namPrefix.arg(colorNum));
}
Ejemplo n.º 19
0
std::tuple<ResultVal<std::shared_ptr<File>>, std::chrono::nanoseconds>
ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
                                    const FileSys::Mode mode) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return std::make_tuple(FileSys::ERR_INVALID_ARCHIVE_HANDLE,
                               static_cast<std::chrono::nanoseconds>(0));

    std::chrono::nanoseconds open_timeout_ns{archive->GetOpenDelayNs()};
    auto backend = archive->OpenFile(path, mode);
    if (backend.Failed())
        return std::make_tuple(backend.Code(), open_timeout_ns);

    auto file = std::shared_ptr<File>(new File(system, std::move(backend).Unwrap(), path));
    return std::make_tuple(MakeResult<std::shared_ptr<File>>(std::move(file)), open_timeout_ns);
}
Ejemplo n.º 20
0
TIntegrationEvent::TIntegrationEvent( const TIntegrationEvent &source )
/* --------------------------
     * Author  : Bruno Orsier                : Original Delphi code
             Diego Segura / Gilles Orazi : C++ translation
 * Created : 06/2002
 * Purpose :
 * History :
 * -------------------------- */
{
    Name(source.Name());
    Time(source.Time());
    Code(source.Code());
    m_priority = source.Priority();
    ShortName(source.ShortName());
    Category(source.Category());
#ifdef INTEGR_DEBUG
    ++Glob_InEventsCount;
    ++Glob_InEventsTotal;
#endif
}
Ejemplo n.º 21
0
Registers::Code
Registers::FromName(const char* name)
{
    // Check for some register aliases first.
    if (strcmp(name, "ip") == 0)
        return ip;
    if (strcmp(name, "r13") == 0)
        return r13;
    if (strcmp(name, "lr") == 0)
        return lr;
    if (strcmp(name, "r15") == 0)
        return r15;

    for (size_t i = 0; i < Total; i++) {
        if (strcmp(GetName(i), name) == 0)
            return Code(i);
    }

    return Invalid;
}
Ejemplo n.º 22
0
unsigned _nthcdr(Env& env) {
    //if (not has_elements<Code>(env,1)) return 1;
    //if (not has_elements<int>(env,1)) return 1;

    Code first = pop<Code>(env);
    int val = pop<int>(env);

    if (first->get_stack().size() == 0) { // nil or atom
	push(env, first);
	return 1;
    }
    
    CodeArray stack = first->get_stack();
    val = std::abs(val) % stack.size();

    while(--val >= 0) stack.pop_back();
    
    push(env, Code(new CodeList(stack)));
    
    return first->len();
}
Ejemplo n.º 23
0
TIntegrationEvent& TIntegrationEvent::operator=(const TIntegrationEvent& source)
/* --------------------------
     * Author  : Bruno Orsier                : Original Delphi code
             Diego Segura / Gilles Orazi : C++ translation
 * Created : 06/2002
 * Purpose :
 * History :
 * -------------------------- */
{
    if( this != &source )
    {
        Name(source.Name());
        Time(source.Time());
        Code(source.Code());
        m_priority = source.Priority();
        ShortName(source.ShortName());
        Category(source.Category());
    }

    return *this;
}
Ejemplo n.º 24
0
MyWindow::MyWindow(QWidget * parent, Qt::WFlags flags)
        : QMainWindow(parent, flags)

{
    QWidget * centralWidget = new QWidget(this);
    QGridLayout * mainlayout = new QGridLayout(centralWidget);
    mainlayout->setMargin(1);
    mainlayout->setSpacing(1);

    sa_xy = new QScrollArea(centralWidget);
    xy = new PixLabel();
    xy->setFixedSize(1024, 512);
    sa_xy->setWidget(xy);

    mainlayout->addWidget(sa_xy, 0, 0, 1, 4);

    setCentralWidget(centralWidget);

    buttAdd = new QPushButton(centralWidget);
    buttAdd->setText(tr("Add"));
    mainlayout->addWidget(buttAdd, 1, 0);

    buttCode = new QPushButton(centralWidget);
    buttCode->setText(tr("Code"));
    mainlayout->addWidget(buttCode, 1, 1);

    buttSave = new QPushButton(centralWidget);
    buttSave->setText(tr("Save"));
    mainlayout->addWidget(buttSave, 1, 3);

    buttLoad = new QPushButton(centralWidget);
    buttLoad->setText(tr("Load"));
    mainlayout->addWidget(buttLoad, 1, 2);

    connect(buttAdd, SIGNAL(clicked()), xy, SLOT(AddRect()));
    connect(buttCode, SIGNAL(clicked()), this, SLOT(Code()));
    connect(buttSave, SIGNAL(clicked()), this, SLOT(Save()));
    connect(buttLoad, SIGNAL(clicked()), this, SLOT(Load()));
}
Ejemplo n.º 25
0
TBool HPingHeader::VerifyRecvEcho(TInt aId)
//
// Verifiy header is valid echo reply
//
	{
	
	TBool ret = ETrue;
	TUint typeCheck;
	TUint codeCheck;

	// Fill TInet6HeaderICMP_Echo from packet data
	ret = SetHeader();
	
	// Look at IP version
	if(iIPVersion == KAfInet)
		{
		typeCheck = KIPv4PingTypeEchoReply;
		codeCheck = KIPv4PingCodeEcho;
		}
	else
		{
		typeCheck = KIPv6PingTypeEchoReply;
		codeCheck = KIPv6PingCodeEcho;
		}
		
	// Wrong packet type or code
	if(ret && (Type() != typeCheck || Code() != codeCheck))
		{
		ret = EFalse;
		}

	// Wrong packet identifier
	if(ret && Identifier() != aId)
		{
		ret = EFalse;
		}

	return ret;
	}
Ejemplo n.º 26
0
int main(int argc, char* argv[])
{
     srand(time(NULL));
    #if MODE == MOT
    int i=0;
    while (true)
    {
        printf("%s\t\t\t",GenMot::GenWord(4,9));
        ++i;
        if (i==3)
        {
            sleep(1);
            printf("\n");
            i=0;
        }
    }


    #elif MOD == LECTURE
    LireMot Lecteur(CURRENT,50,25);


   if (argc >1)
        Lecteur.ReadWord(argv[1]);
    else
        Lecteur.ReadWord("Mwaaa je suis sur que tu comprend tellement rie à se que je dis que ça te fait limite peur !!!");

    #else
    if (argc>1)
        wave=atoi(argv[1]);
    LireCode Code(wave,"/home/maxime/Bureau/anka dreles/Informatique/Anka_Dreles/website/views.py");
    Code.ReadCode();
    #endif


    return 0;
}
Ejemplo n.º 27
0
//-------------------------------------------------------
void
PersistenceHandler::OnResponse(const Safir::Dob::ResponseProxy responseProxy)
{
    m_debug << "Got this response to the PersistenceDataReady request:" << std::endl
            << Safir::Dob::Typesystem::Serialization::ToXml(responseProxy.GetBlob()) << std::endl;

    if (responseProxy.IsSuccess())
    {
        return;
    }

    const auto error = boost::dynamic_pointer_cast<Safir::Dob::ErrorResponse>(responseProxy.GetResponse());
    if (error != nullptr && error->Code() == Safir::Dob::ResponseGeneralErrorCodes::SafirNotRegistered())
    {
        //This is probably due to the dose_main having got persistence from somewhere else, and
        //has closed the connection.
        return;
    }

    Safir::Logging::SendSystemLog(Safir::Logging::Error,
                                  L"Did not get a SuccessResponse to the PersistentDataReady request to Dose. Response: "
                                  + Safir::Dob::Typesystem::Serialization::ToXml(responseProxy.GetBlob()));

}
Ejemplo n.º 28
0
status_t
BLanguage::GetIcon(BBitmap* result) const
{
	return BLocaleRoster::Default()->GetFlagIconForCountry(result, Code());
}
Ejemplo n.º 29
0
String Lex::Id(int pos)
{
	if(!IsId(pos))
		ThrowError("expected id");
	return id[Code(pos) - 256];
}
void CCoder2::Execute() { Code(NULL); }