Esempio n. 1
0
int main(int argc, char *argv[])
{
    // TODO: This all should be wrapped into common class
    QGuiApplication app(argc, argv);
    ApplicationMain main(&app);

    ConsoleApplication consoleApp;
    if (main.hasApplicationCode())
        consoleApp.setApplicationCode(main.applicationCode());

#ifdef GBERRY_DEBUG_QML_IMPORT_PATH
    consoleApp.setImportPaths(QString(xstr(GBERRY_DEBUG_QML_IMPORT_PATH)));
#endif

#ifdef GBERRY_ASSETS_FIXED_ROOT_PATH
    consoleApp.assets().setRootPath(QString(xstr(GBERRY_ASSETS_FIXED_ROOT_PATH)));
#endif

#ifdef GBERRY_FIXED_ROOT_PATH
    consoleApp.currentApplication().setRootPath(QString(xstr(GBERRY_FIXED_ROOT_PATH)));
#endif

    consoleApp.run("qrc:/main.qml");

    return app.exec();
}
Esempio n. 2
0
/** Parse UID to type and ID strings.
 * Note that the returned values (type and id) must be freed once they are
 * no longer used. Also verifies lengths of the type and id strings.
 * @param uid UID to parse
 * @param type upon return contains the type part of the UID
 * @param id upon return contains the ID part
 */
void
Interface::parse_uid(const char *uid, std::string &type, std::string &id)
{
  regex_t re;
  int ec = 0;
// Requires in parse_uid()
#define str(s) #s
#define xstr(s) str(s)
  if ((ec = regcomp(&re,
		    "^([a-zA-Z0-9]{1," xstr(__INTERFACE_TYPE_SIZE) "})::"
		    "([a-zA-Z0-9 _/\\.-]{1," xstr(__INTERFACE_ID_SIZE) "})$",
		    REG_EXTENDED)) != 0) {
    char errbuf[1024];
    regerror(ec, &re, errbuf, 1024);
    throw Exception("Failed to created regular expression to parse UID (%s)",
		    errbuf);
  }
  regmatch_t matches[3];
  if (regexec(&re, uid, 3, matches, 0) != 0) {
    regfree(&re);
    throw Exception("Failed to match UID %s, format error.", uid);
  }

  type.assign(&(uid[matches[1].rm_so]), matches[1].rm_eo - matches[1].rm_so);
  id.assign(&(uid[matches[2].rm_so]), matches[2].rm_eo - matches[2].rm_so);

  regfree(&re);
}
Esempio n. 3
0
void praat_showLogo (bool autoPopDown) {
	#if gtk
		static const gchar *authors [3] = { "Paul Boersma", "David Weenink", nullptr };

		GuiObject dialog = gtk_about_dialog_new ();
		#define xstr(s) str(s)
		#define str(s) #s
		gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (dialog), xstr (PRAAT_VERSION_STR));
		gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (dialog), "Copyright © 1992–" xstr(PRAAT_YEAR) " by Paul Boersma and David Weenink");
		gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (dialog), "GPL");
		gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (dialog), "http://www.praat.org");
		//gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (dialog), authors);
		g_signal_connect (GTK_DIALOG (dialog), "response", G_CALLBACK (gtk_widget_destroy), nullptr);

		gtk_dialog_run (GTK_DIALOG (dialog));

	#else
		if (theCurrentPraatApplication -> batch || ! theLogo.draw) return;
		if (! theLogo.dia) {
			int width  = theLogo.width_mm  / 25.4 * Gui_getResolution (nullptr);
			int height = theLogo.height_mm / 25.4 * Gui_getResolution (nullptr);
			theLogo.dia = GuiDialog_create (theCurrentPraatApplication -> topShell, 100, 100, width, height,
				U"About", gui_cb_goAway, nullptr, 0);
			theLogo.form = theLogo.dia;
			theLogo.drawingArea = GuiDrawingArea_createShown (theLogo.form, 0, width, 0, height,
				gui_drawingarea_cb_expose, gui_drawingarea_cb_click, nullptr, nullptr, nullptr, 0);
		}
		GuiThing_show (theLogo.form);
		GuiThing_show (theLogo.dia);
		#if motif
			if (autoPopDown)
				GuiAddTimeOut (2000, logo_timeOut, (XtPointer) nullptr);
		#endif
	#endif
}
int main(void)
{
	printf("%" xstr(AA) "d\n", 1);
	printf("%s\n", xstr(AFTERX(BUFSIZE)));
	printf("%s\n", xstr(XAFTERX(BUFSIZE)));

	return 0;
}
Esempio n. 5
0
QString ApplicationInfo::desktopFile()
{
	QString dFile;
	const QString _desktopFile(xstr(APP_PREFIX) "/share/applications/" xstr(APP_BIN_NAME) ".desktop");
	QFile f(_desktopFile);
	if(f.open(QIODevice::ReadOnly)) {
		dFile = QString::fromUtf8(f.readAll());
	}
	return dFile;
}
Esempio n. 6
0
File: sc_can.c Progetto: A-Paul/RIOT
static int _can_usage(void)
{
    puts("usage: can <command> [arguments]");
    puts("commands:");
    puts("\tlist");
    puts("\tsend ifnum id [B1 .. B8]");
    puts("\tdump ifnum nb ms [id1[:mask1][,id2[:mask2], .. id"
         xstr(SC_CAN_MAX_FILTERS) ":[mask" xstr(SC_CAN_MAX_FILTERS) "]]");
    return 0;
}
Esempio n. 7
0
int main(int argc, char **argv)
{
    FILE *config;
    trie_t trie;
    char line[LINE_MAX], app[PATH_MAX], debugger[ARG_MAX], *c;
    unsigned short perc;
    unsigned short fields;

    if (trieinit__pt(&trie) != 0) {
        fprintf(stderr, "error: there was a problem with memory allocation.\n");
        return 1;
    }

    if ((config = fopen(PRETRACECONF, "r"))) {
        while (fgets(line, sizeof(line), config) != NULL) {
            if (*line == '#' || *line == '\n')
                continue;       /* skip comments */

            if ((c = strchr(line, ':')))
                *c = ' ';

            if ((fields = sscanf(line, "%" xstr(PATH_MAX) "s %[^\n]" xstr(ARG_MAX) "s", app, debugger)) < 1)
                continue;

            /* check for percentage */
            if ((c = strchr(app, '%')))
                *(c++) = '\0', perc = atoi(c);
            else
                perc = 100;

            eprintf("debug: adding %s, debugger: %s, percentage: %u\n", app, debugger, perc);

            if (trieadd__pt(app, perc, fields == 2 ? debugger : DEFAULT_DEBUGGER, &trie) != 0) {
                fprintf(stderr, "error: there was a problem constructing the map structure.\n");
                return 1;
            }
        }

        fclose(config);
    } else {
        fprintf(stderr, "error: could not open configuration file %s.\n", PRETRACECONF);
        return 1;
    }

    if (triewrite__pt(PRETRACEMAP, &trie) != 0) {
        fprintf(stderr, "error: failed to create map file %s.\n", PRETRACEMAP);
        return 1;
    }

    fprintf(stdout, "info: %s created successfully.\n", PRETRACEMAP);

    triedestroy__pt(&trie);

    return 0;
}
Esempio n. 8
0
char*
extype(int type)
{
	switch (type)
	{
	case FLOATING:
		return "double";
	case STRING:
		return "char*";
	case UNSIGNED:
		return xstr(uintmax_t);
	}
	return xstr(intmax_t);
}
void praat_reportSystemProperties () {
	#define xstr(s) str(s)
	#define str(s) #s
	MelderInfo_open ();
	MelderInfo_writeLine (U"System properties of this edition of Praat on this computer:\n");
	#ifdef _WIN32
		MelderInfo_writeLine (U"_WIN32 is \"" xstr (_WIN32) "\".");
	#endif
	#ifdef WINVER
		MelderInfo_writeLine (U"WINVER is \"" xstr (WINVER) "\".");
	#endif
	#ifdef _WIN32_WINNT
		MelderInfo_writeLine (U"_WIN32_WINNT is \"" xstr (_WIN32_WINNT) "\".");
	#endif
	#ifdef _WIN32_IE
		MelderInfo_writeLine (U"_WIN32_IE is \"" xstr (_WIN32_IE) "\".");
	#endif
	#ifdef UNICODE
		MelderInfo_writeLine (U"UNICODE is \"" xstr (UNICODE) "\".");
	#endif
	#ifdef _FILE_OFFSET_BITS
		MelderInfo_writeLine (U"_FILE_OFFSET_BITS is \"" xstr (_FILE_OFFSET_BITS) "\".");
	#endif
	#ifdef macintosh
		MelderInfo_writeLine (U"macintosh is \"" xstr (macintosh) "\".");
	#endif
	#ifdef linux
		MelderInfo_writeLine (U"linux is \"" xstr (linux) "\".");
	#endif
	MelderInfo_close ();
}
Esempio n. 10
0
/** More help text for this program, which doubles as the "official"
 *  documentation for the more subtle behaviours of this embedding.
 *
 *  @param	argv_zero	How this program was invoked.
 *
 *  @note	Exits with status 1
 */
static void __attribute__((noreturn)) moreHelp(const char *argv_zero)
{
  char spaces[strlen(argv_zero) + 1];

  memset(spaces, (int)(' '), sizeof(spaces) -1);
  spaces[sizeof(spaces) - 1] = (char)0;

  printf(
                  "\n"
#if defined(__SURELYNX__)
                  "SureLynx "
#endif
                  PRODUCT_SHORTNAME " " PRODUCT_VERSION " - " PRODUCT_SUMMARY " " GPSEE_CURRENT_VERSION_STRING "\n"
                  "Copyright (c) 2007-2010 PageMail, Inc. All Rights Reserved.\n"
                  "\n"
		  "More Help: Additional information beyond basic usage.\n"
		  "\n"
		  "Verbosity\n"
		  "  Verbosity is a measure of how much output GPSEE and " PRODUCT_SHORTNAME " send to stderr.\n"
		  "  To request verbosity N, specify the d flag N times when invoking " PRODUCT_SHORTNAME ".\n"
		  "  Requests in both the shebang (#!) and comment-embedded options is additive.\n"
		  "\n"
		  "  If you invoke " PRODUCT_SHORTNAME " such that stderr is a tty, verbosity will be automatically\n"
		  "  set to " xstr(GSR_MIN_TTY_VERBOSITY) ", unless your -d flags indicate an even higher level.\n"
		  "\n"
		  "  Before your program runs, i.e. you are running script code with -c or a\n"
		  "  preload script, verbosity will be set to " xstr(GSR_PREPROGRAM_TTY_VERBOSITY) " when stderr is a tty,\n"
		  "  and " xstr(GSR_PREPROGRAM_NOTTY_VERBOSITY) " otherwise.\n"
		  "\n"
		  "Uncaught Exceptions\n"
		  "  - Errors are output to stderr when verbosity >= " xstr(GPSEE_ERROR_OUTPUT_VERBOSITY) "\n"
		  "  - Warnings are output to stderr when verbosity >= " xstr(GPSEE_ERROR_OUTPUT_VERBOSITY) "\n"
		  "  - Stack is dumped when error output is enabled and stderr is a tty,\n"
		  "    or verbosity >= " xstr(GSR_FORCE_STACK_DUMP_VERBOSITY) "\n"
		  "  - Syntax errors will have their location within the source shown when stderr\n"
		  "    is a tty, and verbosity >= " xstr(GPSEE_ERROR_POINTER_VERBOSITY) "\n"
		  "\n"
		  "GPSEE-core debugging\n"
		  "  - The module system will generate debug output whe verbosity >= " xstr(GPSEE_MODULE_DEBUG_VERBOSITY) "\n"
		  "  - The script precompilation sub-system will generate debug output\n"
		  "    when verbosity >= " xstr(GPSEE_XDR_DEBUG_VERBOSITY) "\n"
		  "\n"
		  "Miscellaneous\n"
		  "  - Exit codes 0 and 1 are reserved for 'success' and 'error' respectively.\n"
		  "    Application programs can return any exit code they wish, from 0-127,\n"
		  "    with either require('gpsee').exit() or by throwing a number literal.\n"
#if defined(SYSTEM_GSR)
		  "  - Preload scripts will only be processed when " PRODUCT_SHORTNAME " is not invoked\n"
		  "    as " SYSTEM_GSR ".\n"
#endif
		  "\n"
	       );
  exit(1);
};
Esempio n. 11
0
void GetModelParams(int* p_nthreads, int* p_msize, int print)
{
	int nthr = MAXTHREADS;
	int msize = NUM;
	int ncpu = getCPUCount();
	if (ncpu < MAXTHREADS) {
		nthr = ncpu;
	}
	// Making sure the matrix size and the nthreads are aligned
	// If you want more robust threading implementation, take care
	// of the matrix tails
	while ((msize % nthr) != 0 )
		nthr--;
	// If kernel multiply0, set single threaded execution
	if (MULTIPLY == multiply0)
		nthr = 1;

	if(p_nthreads != 0)
		*p_nthreads = nthr;
	if(p_msize != 0)
		*p_msize = msize;

	if(print)
	{
		printf("Threads #: %d %s\n",nthr,
#ifdef WIN32
	 "Win threads"
#else
	  "Pthreads"
#endif
			);	fflush(stdout);
		printf("Matrix size: %d\n",msize); fflush(stdout);
		printf("Using multiply kernel: %s\n", xstr(MULTIPLY)); fflush(stdout);
	}
}
Esempio n. 12
0
int16_t parse_cmd_free(char *cmd, char *output, uint16_t len)
{
	/* Docu March 2009: http://www.nongnu.org/avr-libc/user-manual/malloc.html
	Stack size: RAMEND-SP
	Heap size: __brkval-__heap_start
	Space between stack and heap: SP-__brkval
	Caution: __brkval is 0 when malloc was not called yet (use __heap_start instead)

	Size of network packet frames is stored in NET_MAX_FRAME_LENGTH
	*/

	extern char *__brkval;
	extern unsigned char __heap_start;
	size_t f = (size_t)(__brkval ? (size_t)__brkval : (size_t)&__heap_start);
	size_t allram = RAMEND;

	/* we want an output like this:
	free: 16234/32768
	heap: 10234
	net: 500
	*/
	return ECMD_FINAL(snprintf_P(output, len,
		PSTR("free: %d/%d\nheap: %d\nnet: " xstr(NET_MAX_FRAME_LENGTH)),
		SP-f, allram, f-(size_t)&__heap_start));
}
Esempio n. 13
0
/** 有误 */
void xae::delete_temp_folder(string folder_name)
{
    std::string folder = folder_name;
    SHFILEOPSTRUCT FileOp;
    ZeroMemory((void*)&FileOp,sizeof(SHFILEOPSTRUCT));

    FileOp.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
    FileOp.hNameMappings = NULL;
    FileOp.hwnd = NULL;
    FileOp.lpszProgressTitle = NULL;
    FileOp.pFrom = folder.c_str();
    FileOp.pTo = NULL;
    FileOp.wFunc = FO_DELETE;

    SHFileOperation(&FileOp);

    XStringFunc xstr(folder_name);
    xstr.ToUpper();
    folder_name = xstr.GetString();

    for(vector<string>::iterator it = m_szTmpFolders.begin(); it != m_szTmpFolders.end(); it++)
    {
        if((*it) == folder_name)
        {
            m_szTmpFolders.erase(it);
            return;
        }
    }

    return;
}
Esempio n. 14
0
main( void)
{
    fputs( "started\n", stderr);

/* 24.1:    */
#define str( a)     # a
    assert( strcmp( str( a+b), "a+b") == 0);

/* 24.2:    White spaces between tokens of operand are converted to one space.
 */
    assert( strcmp( str(    ab  /* comment */   +
        cd  ), "ab + cd") == 0);

/* 24.3:    \ is inserted before \ and " in or surrounding literals and no
        other character is inserted to anywhere.    */
    assert( strcmp( str( '"' + "' \""), "'\"' + \"' \\\"\"") == 0);

/* 24.4:    Line splicing by <backslash><newline> is done prior to token
        parsing.   */
    assert( strcmp( str( "ab\
c"), "\"abc\"") == 0);

/* 24.5:    Token separator inserted by macro expansion should be removed.
        (Meanwhile, tokens should not be merged.  See 21.2.)    */
#define xstr( a)    str( a)
#define f(a)        a
    assert( strcmp( xstr( x-f(y)), "x-y") == 0);

    fputs( "success\n", stderr);
    return  0;
}
Esempio n. 15
0
File: sam.c Progetto: Annak17/partis
static int aux_fields1(void)
{
    static const char sam[] = "data:"
"@SQ\tSN:one\tLN:1000\n"
"@SQ\tSN:two\tLN:500\n"
"r1\t0\tone\t500\t20\t8M\t*\t0\t0\tATGCATGC\tqqqqqqqq\tXA:A:k\tXi:i:37\tXf:f:" xstr(PI) "\tXd:d:" xstr(E) "\tXZ:Z:" HELLO "\tXH:H:" BEEF "\tXB:B:c,-2,0,+2\tZZ:i:1000000\n";

    // Canonical form of the alignment record above, as output by sam_format1()
    static const char r1[] = "r1\t0\tone\t500\t20\t8M\t*\t0\t0\tATGCATGC\tqqqqqqqq\tXA:A:k\tXi:i:37\tXf:f:3.14159\tXd:d:2.71828\tXZ:Z:" HELLO "\tXH:H:" BEEF "\tXB:B:c,-2,0,2\tZZ:i:1000000";

    samFile *in = sam_open(sam, "r");
    bam_hdr_t *header = sam_hdr_read(in);
    bam1_t *aln = bam_init1();
    uint8_t *p;
    uint32_t n;
    kstring_t ks = { 0, 0, NULL };

    if (sam_read1(in, header, aln) >= 0) {
        if ((p = check_bam_aux_get(aln, "XA", 'A')) && bam_aux2A(p) != 'k')
            fail("XA field is '%c', expected 'k'", bam_aux2A(p));

        if ((p = check_bam_aux_get(aln, "Xi", 'C')) && bam_aux2i(p) != 37)
            fail("Xi field is %d, expected 37", bam_aux2i(p));

        if ((p = check_bam_aux_get(aln, "Xf", 'f')) && fabs(bam_aux2f(p) - PI) > 1E-6)
            fail("Xf field is %.12f, expected pi", bam_aux2f(p));

        if ((p = check_bam_aux_get(aln, "Xd", 'd')) && fabs(bam_aux2f(p) - E) > 1E-6)
            fail("Xf field is %.12f, expected e", bam_aux2f(p));

        if ((p = check_bam_aux_get(aln, "XZ", 'Z')) && strcmp(bam_aux2Z(p), HELLO) != 0)
            fail("XZ field is \"%s\", expected \"%s\"", bam_aux2Z(p), HELLO);

        if ((p = check_bam_aux_get(aln, "XH", 'H')) && strcmp(bam_aux2Z(p), BEEF) != 0)
            fail("XH field is \"%s\", expected \"%s\"", bam_aux2Z(p), BEEF);

        // TODO Invent and use bam_aux2B()
        if ((p = check_bam_aux_get(aln, "XB", 'B')) && ! (memcmp(p, "Bc", 2) == 0 && (memcpy(&n, p+2, 4), n) == 3 && memcmp(p+6, "\xfe\x00\x02", 3) == 0))
            fail("XB field is %c,..., expected c,-2,0,+2", p[1]);

        if ((p = check_bam_aux_get(aln, "ZZ", 'I')) && bam_aux2i(p) != 1000000)
            fail("ZZ field is %d, expected 1000000", bam_aux2i(p));

        if (sam_format1(header, aln, &ks) < 0)
            fail("can't format record");

        if (strcmp(ks.s, r1) != 0)
            fail("record formatted incorrectly: \"%s\"", ks.s);

        free(ks.s);
    }
    else fail("can't read record");

    bam_destroy1(aln);
    bam_hdr_destroy(header);
    sam_close(in);

    return 1;
}
Esempio n. 16
0
File: fooN.c Progetto: LLNL/pynamic
int N6 ()
{
 volatile int i = 0;
 printf ("In %s\n", xstr(N6) );
 if (i == 0) return 0;
 big_body
 return 0;
}
Esempio n. 17
0
main( void)
{
    fputs( "started\n", stderr);

/* 22.1:    12E+EXP is a preprocessing number, EXP is not expanded. */
    assert( strcmp( xstr( 12E+EXP), "12E+EXP") == 0);

/* 22.2:    .2e-EXP is also a preprocessing number. */
    assert( strcmp( xstr( .2e-EXP), ".2e-EXP") == 0);

/* 22.3:    + or - is allowed only following E or e, 12+EXP is not a
        preprocessing number.   */
    assert( strcmp( xstr( 12+EXP), "12+1") == 0);

    fputs( "success\n", stderr);
    return  0;
}
Esempio n. 18
0
static bool index_check(void)
{
   int result;
   int version = 0;
   bool retval = true;

   result = sqlite3_exec(
     cpd.index,
     "SELECT Version FROM Version",
     index_version_check_callback,
     &version,
     NULL);

   if (result == SQLITE_OK)
   {
      if (version != INDEX_VERSION)
      {
         LOG_FMT(LERR, "Wrong index format version, delete it to continue\n");
         retval = false;
      }
   }
   else
   {
      char *errmsg = NULL;

      result = sqlite3_exec(
         cpd.index,
         "CREATE TABLE Version(Version INTEGER);"
         "INSERT INTO Version VALUES(" xstr(INDEX_VERSION) ");"
         "CREATE TABLE Files(Digest TEXT, Filename TEXT UNIQUE);"
         "CREATE TABLE Refs(Filerow INTEGER, Line INTEGER, ColumnStart INTEGER, Scope TEXT, Type INTEGER, Identifier TEXT);"
         "CREATE TABLE Defs(Filerow INTEGER, Line INTEGER, ColumnStart INTEGER, Scope TEXT, Type INTEGER, Identifier TEXT);"
         "CREATE TABLE Decls(Filerow INTEGER, Line INTEGER, ColumnStart INTEGER, Scope TEXT, Type INTEGER, Identifier TEXT);",
         NULL,
         NULL,
         &errmsg);

      if (result != SQLITE_OK)
      {
         LOG_FMT(LERR, "index_check: access error (%d: %s)\n", result, errmsg != NULL ? errmsg : "");
         retval = false;
      }

      sqlite3_free(errmsg);
   }

   (void) sqlite3_exec(
      cpd.index,
      "PRAGMA journal_mode=OFF;"
      "PRAGMA synchronous=OFF;"
      "PRAGMA case_sensitive_like=ON;",
      NULL,
      NULL,
      NULL);

   return retval;
}
Esempio n. 19
0
int main() {
    printf("all of the following should be 1 except xs[259] = 0");
    a = 3;
    b = 259;
    fptr = (volatile int (*)(unsigned char x))&testUcharX;
    if ((((long)fptr)&((long)1)<<32) == 1) fptr = NULL;
    printf("compiled with: '%s'\nxs[3] = %d\nxs[259] = %d\ntestUcharX(3) = %d\ntestUcharX(%d) = %d\nfptr(3) = %d\nfptr(259) = %d\n",
        xstr(CC), xs[a], xs[b], testUcharX(a), b, testUcharX(b), fptr(a), fptr(b));
}
Esempio n. 20
0
int main (int argc, char *argv[])
{
  /* The space before "bar" here is vital.  */
  char a[] = xstr(glibc_hack(foo, bar));

  if (strcmp (a, "foo@bar"))
    err ("stringification without spaces");

  return 0;
}
Esempio n. 21
0
int main() {
    fprintf(stderr,"all of the following should be 1 except xs[259] = 0\n");
    a = 3;
    b = 259;
    fptr = (volatile int (*)(unsigned char x))&testUcharX;
    if ((((size_t)fptr)&((size_t)1)) == 1) fptr = NULL;
    fprintf(stderr,"compiled with: '%s'\nxs[3] = %d\nxs[259] = %d\ntestUcharX(3) = %d\ntestUcharX(%d) = %d\nfptr(3) = %d\nfptr(259) = %d\n",
           xstr(CC), xs[a], xs[b], testUcharX(a), b, testUcharX((unsigned char)b), fptr(a), fptr(b));
    fprintf(stderr,"misc tests:\n");
    struct1 a = {352.39422e23, 19.287577};
    a = test_1(a);
}
Esempio n. 22
0
int main(int argc, char *argv[]) {
	printf("MagiskBoot v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") (by topjohnwu) - Boot Image Modification Tool\n\n");

	if (argc > 1 && strcmp(argv[1], "--cleanup") == 0) {
		cleanup();
	} else if (argc > 2 && strcmp(argv[1], "--sha1") == 0) {
		char sha1[21], *buf;
		size_t size;
		mmap_ro(argv[2], (unsigned char **) &buf, &size);
		SHA1(sha1, buf, size);
		for (int i = 0; i < 20; ++i)
			printf("%02x", sha1[i]);
		printf("\n");
		munmap(buf, size);
	} else if (argc > 2 && strcmp(argv[1], "--unpack") == 0) {
		unpack(argv[2]);
	} else if (argc > 2 && strcmp(argv[1], "--repack") == 0) {
		repack(argv[2], argc > 3 ? argv[3] : NEW_BOOT);
	} else if (argc > 2 && strcmp(argv[1], "--decompress") == 0) {
		decomp_file(argv[2], argc > 3 ? argv[3] : NULL);
	} else if (argc > 2 && strncmp(argv[1], "--compress", 10) == 0) {
		char *method;
		method = strchr(argv[1], '=');
		if (method == NULL) method = "gzip";
		else method++;
		comp_file(method, argv[2], argc > 3 ? argv[3] : NULL);
	} else if (argc > 4 && strcmp(argv[1], "--hexpatch") == 0) {
		hexpatch(argv[2], argv[3], argv[4]);
	} else if (argc > 2 && strncmp(argv[1], "--cpio", 6) == 0) {
		char *command;
		command = strchr(argv[1] + 2, '-');
		if (command == NULL) usage(argv[0]);
		else ++command;
		if (cpio_commands(command, argc - 2, argv + 2)) usage(argv[0]);
	} else {
		usage(argv[0]);
	}

	return 0;
}
Esempio n. 23
0
rtsFatalInternalErrorFn(const char *s, va_list ap)
{
#if defined(mingw32_HOST_OS)
  /* Ensure we're in text mode so newlines get encoded properly.  */
  int mode = _setmode (_fileno(stderr), _O_TEXT);
  if (isGUIApp())
  {
     char title[BUFSIZE], message[BUFSIZE];

     snprintf(title,   BUFSIZE, "%s: internal error", prog_name);
     vsnprintf(message, BUFSIZE, s, ap);

     MessageBox(NULL /* hWnd */,
                message,
                title,
                MB_OK | MB_ICONERROR | MB_TASKMODAL
               );
  }
  else
#endif
  {
     /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
     if (prog_argv != NULL && prog_name != NULL) {
       fprintf(stderr, "%s: internal error: ", prog_name);
     } else {
       fprintf(stderr, "internal error: ");
     }
     vfprintf(stderr, s, ap);
#if USE_LIBDW
     fprintf(stderr, "\n");
     fprintf(stderr, "Stack trace:\n");
     LibdwSession *session = libdwInit();
     Backtrace *bt = libdwGetBacktrace(session);
     libdwPrintBacktrace(session, stderr, bt);
     libdwFree(session);
#endif
     fprintf(stderr, "\n");
     fprintf(stderr, "    (GHC version %s for %s)\n", ProjectVersion, xstr(HostPlatform_TYPE));
     fprintf(stderr, "    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug\n");
     fflush(stderr);
  }
#if defined(mingw32_HOST_OS)
  _setmode (_fileno(stderr), mode);
#endif

#if defined(TRACING)
  if (RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG) endEventLogging();
#endif

  abort();
  // stg_exit(EXIT_INTERNAL_ERROR);
}
Esempio n. 24
0
int main(int argc, char *argv[])
{
    // TODO: This all should be wrapped into common class
    QGuiApplication app(argc, argv);
    ConsoleApplication consoleApp;

#ifdef GBERRY_DEBUG_QML_IMPORT_PATH
    consoleApp.setImportPaths(QString(xstr(GBERRY_DEBUG_QML_IMPORT_PATH)));
#endif
    consoleApp.run("qrc:/main.qml");

    return app.exec();
}
Esempio n. 25
0
void ParallelMultiply(int msize, TYPE a[][NUM], TYPE b[][NUM], TYPE c[][NUM], TYPE t[][NUM])
{
	int NTHREADS = MAXTHREADS;
	int MSIZE = NUM;

	GetModelParams(&NTHREADS, &MSIZE, 0);
	if(strncmp(xstr(MULTIPLY), "multiply5", 16) != 0)
	{
		printf("===== Error: Change matrix kernel to 'multiply5' for compilation with MKL =====\n"); fflush(stdout);
		return;
	}
	MULTIPLY(MSIZE, NTHREADS, 0, a, b, c, t);
}
Esempio n. 26
0
void InterpretedVM::ImportExt(SExtInstImport import) {
  std::string name(import.Name);
  HINSTANCE extInst = LoadLibrary( ("ext\\" + name + ".dll").c_str());
  
  if (extInst) {
    const char* funcName = xstr(EXT_EXPORT_TABLE_FUNC_NAME);
    GetExtTableFunc* func = (GetExtTableFunc*)GetProcAddress(extInst, TEXT(funcName));
    if (func) {
      auto res = func();
      env.Extensions[import.ResultId] = res;
    }
  }
}
Esempio n. 27
0
void calCRC(char* str, char* augword, char* divisor, char* codeword)
{
     int i,j,k;
     int clen=strlen(str)+strlen(divisor);
     char str1[5],xores[5],remainder[4];
     for(i=0;i<4;i++) str1[i]=augword[i];  //change value '4' according to divisor
     if(str1[0]=='1')                      //first xoring done by checking first bit
      xstr(str1,divisor,xores,strlen(divisor));
      else xstr(str1,"0000",xores,strlen(divisor));       //change no. of zeroes, "0000" according to divisor
      k=0;
      while(augword[k+4]!='\0')                           ////change value '4' according to divisor
      {
      //store xored result in another string, discard first bit and shift in next bit from dataword
      for(i=1;i<4;i++) str1[i-1]=xores[i];  //change value '4' according to divisor
      str1[i-1]=augword[k+4];
      str1[i]='\0';
      //printf("\nstr1=%s\n",str1);
      if(str1[0]=='1'){
                        xstr(str1,divisor,xores,strlen(divisor));
                        k++;
                        }
                  else {
                       xstr(str1,"0000",xores,strlen(divisor));  //change no. of zeroes, "0000" according to divisor
                       k++;
                       }
      }
      //str is the original string, xores contains the final remainder
      for(i=0,j=1;i<clen-1;i++)
      if(i<strlen(str)) codeword[i]=str[i];
      else codeword[i]=xores[j++];
      codeword[i]='\0';
      
      for(i=0,j=1;j<strlen(xores);i++)
      remainder[i]=xores[j++];
      remainder[i]='\0';
      printf("Remainder = %s\n",remainder);
      //printf("\nxores=%s\n",xores);
}
Esempio n. 28
0
static void logo (Graphics g) {
	Graphics_setWindow (g, 0, 1, 0.00, 0.80);
	Graphics_setTextAlignment (g, Graphics_CENTRE, Graphics_HALF);
	Graphics_setFont (g, kGraphics_font_TIMES);
	Graphics_setFontSize (g, 45);
	Graphics_setColour (g, Graphics_MAROON);
	Graphics_text (g, 0.385, 0.66, L"P");
	Graphics_text (g, 0.448, 0.66, L"\\s{R}");
	Graphics_text (g, 0.510, 0.66, L"\\s{A}");
	Graphics_text (g, 0.575, 0.66, L"\\s{A}");
	Graphics_text (g, 0.628, 0.66, L"\\s{T}");
	Graphics_setFontSize (g, 15);
	Graphics_text (g, 0.5, 0.55, L"%%doing phonetics by computer");
	#define xstr(s) str(s)
	#define str(s) #s
	Graphics_text (g, 0.5, 0.45, L"version " xstr(PRAAT_VERSION_STR));
	Graphics_setColour (g, Graphics_BLACK);
	Graphics_setFontSize (g, 14);
	Graphics_text (g, 0.5, 0.33, L"www.praat.org");
	Graphics_setFont (g, kGraphics_font_HELVETICA);
	Graphics_setFontSize (g, 10);
	Graphics_text (g, 0.5, 0.16, L"Copyright \\co 1992-" xstr(PRAAT_YEAR) " by Paul Boersma and David Weenink");
}
Esempio n. 29
0
int16_t
parse_cmd_free(char *cmd, char *output, uint16_t len)
{
  /* trick: use bytes on cmd as "connection specific static variables" */
  if (cmd[0] != ECMD_STATE_MAGIC)
  {                             /* indicator flag: real invocation:  0 */
    cmd[0] = ECMD_STATE_MAGIC;  /*                 continuing call: 23 */
    cmd[1] = 0;                 /* counter for output lines */
  }

  /* Docu March 2009: http://www.nongnu.org/avr-libc/user-manual/malloc.html
   * Stack size: RAMEND-SP
   * Heap size: __brkval-__heap_start
   * Space between stack and heap: SP-__brkval
   * Caution: __brkval is 0 when malloc was not called yet (use __heap_start instead)
   * 
   * Size of network packet frames is stored in NET_MAX_FRAME_LENGTH
   */

  size_t f =
    (size_t) (__brkval ? (size_t) __brkval : (size_t) & __heap_start);

  /* we want an output like this:
   * free: 16234/32768
   * heap: 10234
   * net: 500
   */
  switch (cmd[1]++)
  {
    case 0:
      return ECMD_AGAIN(snprintf_P(output, len,
                                   PSTR("free: %u/%u"),
                                   SP - f, RAM_SIZE));
#ifndef UIP_SUPPORT
    default:
      return ECMD_FINAL(snprintf_P(output, len,
                                   PSTR("heap: %u"),
                                   f - (size_t) & __heap_start));
#else
    case 1:
      return ECMD_AGAIN(snprintf_P(output, len,
                                   PSTR("heap: %u"),
                                   f - (size_t) & __heap_start));
    default:
      return ECMD_FINAL(snprintf_P(output, len,
                                   PSTR("net: " xstr(NET_MAX_FRAME_LENGTH))));
#endif
  }
}
Esempio n. 30
0
int main(int argc, char* argv[])
{
  if(argc != 3)
  {
    printf("usage: " xstr(CMP_FUNC) " <string1> <string2>\n");
    exit(EXIT_FAILURE);
  }

  // Turn off buffering
  setbuf(stdout, NULL);

  printf("%i\n", CMP_FUNC(argv[1], argv[2]));

  return EXIT_SUCCESS;
}