bool CpuProfileInputStream::open(const gtString& path) { if (path.isEmpty()) { return false; } // Check if file is already open if (m_fileStream.isOpened()) { if (path != m_path) { // Close and open a new file close(); } else { return true; } } // Windows Note: // The profile files are opened with UTF-8 encoding. // if (!m_fileStream.open(path.asCharArray(), WINDOWS_SWITCH(FMODE_TEXT("r, ccs=UTF-8"), FMODE_TEXT("rb")))) { return false; } // Set path name m_path = path; #if AMDT_BUILD_TARGET == AMDT_LINUX_OS if (fwide(m_fileStream.getHandler(), 1) <= 0) { close(); return false; } // Note: For Linux // Due to a bug in some version of gcc, // we add this to make sure that we are // starting from the beginning of the file. m_fileStream.seekCurrentPosition(CrtFile::ORIGIN_BEGIN, 0); #endif getCurrentPosition(&m_bof); // Get length of file m_fileStream.seekCurrentPosition(CrtFile::ORIGIN_END, 0); getCurrentPosition(&m_eof); // Back to the beginning of file setCurrentPosition(&m_bof); return true; }
LUSHAPI int main(int argc, char **argv) { /* Skip options and define quiet mode if there are remaining arguments. */ int i = 1; int quiet = FALSE; if (i<argc && argv[i][0]=='@') i++; while (i<argc && argv[i][0]=='-') i++; if (i < argc) quiet = TRUE; lush_argc = argc; lush_argv = argv; /* Setup locale */ #if HAVE_SETLOCALE && defined(LC_ALL) setlocale(LC_ALL,""); setlocale(LC_NUMERIC,"C"); #endif /* Message */ if (! quiet) { FMODE_TEXT(stderr); fprintf(stderr,"LUSH Lisp Universal Shell" #ifdef __DATE__ " (compiled on " __DATE__ ")" #endif "\n"); fprintf(stderr, " Copyright (C) 2002 Leon Bottou, Yann LeCun, AT&T, NECI.\n" " Includes parts of TL3:\n" " Copyright (C) 1987-1999 Leon Bottou and Neuristique.\n" " Includes selected parts of SN3.2:\n" " Copyright (C) 1991-2001 AT&T Corp.\n" "This program is free software distributed under the terms\n" "of the GNU Public Licence (GPL) with ABSOLUTELY NO WARRANTY.\n" "Type `(helptool)' for details.\n"); } /* Start */ FMODE_BINARY(stderr); init_lush(argv[0]); start_lisp(argc, argv, quiet); return 0; }
LUSHAPI int main(int argc, char **argv) { /* Call inits of support code */ api_init_tables(); /* Define quiet mode. */ bool quiet = false; int i = 1; if (i<argc && argv[i][0]=='@') i++; while (i<argc && argv[i][0]=='-') i++; if (i < argc) quiet = true; lush_argc = argc; lush_argv = argv; /* Setup locale */ #if HAVE_SETLOCALE && defined(LC_ALL) setlocale(LC_ALL,""); setlocale(LC_NUMERIC,"C"); #endif /* Message */ if (! quiet) { FMODE_TEXT(stderr); fprintf(stderr, "\n"); fprintf(stderr, " LUSH Lisp Universal Shell " PACKAGE_VERSION #ifdef __DATE__ " (built " __DATE__ ")" #endif "\n" " Copyright (C) 2010 Leon Bottou, Yann LeCun, Ralf Juengling.\n" " Copyright (C) 2002 Leon Bottou, Yann LeCun, AT&T Corp, NECI.\n" " Includes parts of TL3:\n" " Copyright (C) 1987-1999 Leon Bottou and Neuristique.\n" " Includes selected parts of SN3.2:\n" " Copyright (C) 1991-2001 AT&T Corp.\n" "\n" "This program is free software distributed under the terms of\n" "the Lesser GNU Public Licence (LGPL) with ABSOLUTELY NO WARRANTY.\n" "\n" "Type '(helptool)' to get started.\n"); } /* Start */ FMODE_BINARY(stderr); //FILE *mmlog = fopen("lushmm.log", "w"); FILE *mmlog = NULL; MM_INIT((1<<12) * sizeof(struct at), (notify_func_t *)run_notifiers, mmlog); MM_ENTER; init_lush(argv[0]); register_poll_functions(mm_spoll, 0, 0, 0, 0); start_lisp(argc, argv, quiet); MM_EXIT; if (mmlog) fclose(mmlog); return 0; }