diff --git a/ase/awk/Awk.cpp b/ase/awk/Awk.cpp index a9a59780..7f0746d7 100644 --- a/ase/awk/Awk.cpp +++ b/ase/awk/Awk.cpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.cpp,v 1.29 2007/05/16 06:43:32 bacon Exp $ + * $Id: Awk.cpp,v 1.30 2007/05/16 07:13:32 bacon Exp $ */ #include @@ -7,9 +7,6 @@ #include #include -#include -#include - namespace ASE { @@ -158,7 +155,7 @@ namespace ASE } } - void* Awk::Argument::operator new (size_t n, awk_t* awk) + void* Awk::Argument::operator new (size_t n, awk_t* awk) throw () { void* ptr = ase_awk_malloc (awk, ASE_SIZEOF(awk) + n); if (ptr == ASE_NULL) return ASE_NULL; @@ -167,7 +164,7 @@ namespace ASE return (char*)ptr+ASE_SIZEOF(awk); } - void* Awk::Argument::operator new[] (size_t n, awk_t* awk) + void* Awk::Argument::operator new[] (size_t n, awk_t* awk) throw () { void* ptr = ase_awk_malloc (awk, ASE_SIZEOF(awk) + n); if (ptr == ASE_NULL) return ASE_NULL; diff --git a/ase/awk/Awk.hpp b/ase/awk/Awk.hpp index b285548c..8c3e75fe 100644 --- a/ase/awk/Awk.hpp +++ b/ase/awk/Awk.hpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.hpp,v 1.27 2007/05/16 06:43:32 bacon Exp $ + * $Id: Awk.hpp,v 1.28 2007/05/16 07:13:32 bacon Exp $ */ #ifndef _ASE_AWK_AWK_HPP_ @@ -136,8 +136,8 @@ namespace ASE ~Argument (); // initialization - void* operator new (size_t n, awk_t* awk); - void* operator new[] (size_t n, awk_t* awk); + void* operator new (size_t n, awk_t* awk) throw (); + void* operator new[] (size_t n, awk_t* awk) throw (); // deletion when initialization fails void operator delete (void* p, awk_t* awk); diff --git a/ase/awk/StdAwk.cpp b/ase/awk/StdAwk.cpp index 0c905b90..281ee32f 100644 --- a/ase/awk/StdAwk.cpp +++ b/ase/awk/StdAwk.cpp @@ -1,8 +1,11 @@ /* - * $Id: StdAwk.cpp,v 1.12 2007/05/13 10:49:32 bacon Exp $ + * $Id: StdAwk.cpp,v 1.14 2007/05/16 14:44:13 bacon Exp $ */ #include +#include +#include +#include #include #include @@ -195,4 +198,270 @@ namespace ASE return n; #endif } + + int StdAwk::openPipe (Pipe& io) + { + Awk::Pipe::Mode mode = io.getMode(); + FILE* fp = NULL; + + switch (mode) + { + case Awk::Pipe::READ: + fp = ase_popen (io.getName(), ASE_T("r")); + break; + case Awk::Pipe::WRITE: + fp = ase_popen (io.getName(), ASE_T("w")); + break; + } + + if (fp == NULL) return -1; + + io.setHandle (fp); + return 1; + } + + int StdAwk::closePipe (Pipe& io) + { + fclose ((FILE*)io.getHandle()); + return 0; + } + + StdAwk::ssize_t StdAwk::readPipe (Pipe& io, char_t* buf, size_t len) + { + // TODO: change this implementation... + FILE* fp = (FILE*)io.getHandle(); + if (ase_fgets (buf, len, fp) == ASE_NULL) + { + if (ferror(fp)) return -1; + return 0; + } + + return ase_strlen(buf); + } + + + StdAwk::ssize_t StdAwk::writePipe (Pipe& io, char_t* buf, size_t len) + { + FILE* fp = (FILE*)io.getHandle(); + size_t left = len; + + while (left > 0) + { + if (*buf == ASE_T('\0')) + { + #if defined(ASE_CHAR_IS_WCHAR) && defined(__linux) + if (fputc ('\0', fp) == EOF) + #else + if (ase_fputc (*buf, fp) == ASE_CHAR_EOF) + #endif + { + return -1; + } + left -= 1; buf += 1; + } + else + { + #if defined(ASE_CHAR_IS_WCHAR) && defined(__linux) + // fwprintf seems to return an error with the file + // pointer opened by popen, as of this writing. + // anyway, hopefully the following replacement + // will work all the way. + int n = fprintf (fp, "%.*ls", left, buf); + if (n >= 0) + { + size_t x; + for (x = 0; x < left; x++) + { + if (buf[x] == ASE_T('\0')) break; + } + n = x; + } + #else + int n = ase_fprintf (fp, ASE_T("%.*s"), left, buf); + #endif + + if (n < 0 || n > left) return -1; + left -= n; buf += n; + } + } + + return len; + } + + int StdAwk::flushPipe (Pipe& io) + { + return ::fflush ((FILE*)io.getHandle()); + } + + // file io handlers + int StdAwk::openFile (File& io) + { + Awk::File::Mode mode = io.getMode(); + FILE* fp = NULL; + + switch (mode) + { + case Awk::File::READ: + fp = ase_fopen (io.getName(), ASE_T("r")); + break; + case Awk::File::WRITE: + fp = ase_fopen (io.getName(), ASE_T("w")); + break; + case Awk::File::APPEND: + fp = ase_fopen (io.getName(), ASE_T("a")); + break; + } + + if (fp == NULL) return -1; + + io.setHandle (fp); + return 1; + } + + int StdAwk::closeFile (File& io) + { + fclose ((FILE*)io.getHandle()); + return 0; + } + + StdAwk::ssize_t StdAwk::readFile (File& io, char_t* buf, size_t len) + { + // TODO: replace ase_fgets by something else + FILE* fp = (FILE*)io.getHandle(); + if (ase_fgets (buf, len, fp) == ASE_NULL) + { + if (ferror(fp)) return -1; + return 0; + } + + return ase_strlen(buf); + } + + StdAwk::ssize_t StdAwk::writeFile (File& io, char_t* buf, size_t len) + { + FILE* fp = (FILE*)io.getHandle(); + size_t left = len; + + while (left > 0) + { + if (*buf == ASE_T('\0')) + { + if (ase_fputc (*buf, fp) == ASE_CHAR_EOF) return -1; + left -= 1; buf += 1; + } + else + { + int n = ase_fprintf (fp, ASE_T("%.*s"), left, buf); + if (n < 0 || n > left) return -1; + left -= n; buf += n; + } + } + + return len; + } + + int StdAwk::flushFile (File& io) + { + return ::fflush ((FILE*)io.getHandle()); + } + + // memory allocation primitives + void* StdAwk::allocMem (size_t n) + { + return ::malloc (n); + } + + void* StdAwk::reallocMem (void* ptr, size_t n) + { + return ::realloc (ptr, n); + } + + void StdAwk::freeMem (void* ptr) + { + ::free (ptr); + } + + // character class primitives + StdAwk::bool_t StdAwk::isUpper (cint_t c) + { + return ase_isupper (c); + } + + StdAwk::bool_t StdAwk::isLower (cint_t c) + { + return ase_islower (c); + } + + StdAwk::bool_t StdAwk::isAlpha (cint_t c) + { + return ase_isalpha (c); + } + + StdAwk::bool_t StdAwk::isDigit (cint_t c) + { + return ase_isdigit (c); + } + + StdAwk::bool_t StdAwk::isXdigit (cint_t c) + { + return ase_isxdigit (c); + } + + StdAwk::bool_t StdAwk::isAlnum (cint_t c) + { + return ase_isalnum (c); + } + + StdAwk::bool_t StdAwk::isSpace (cint_t c) + { + return ase_isspace (c); + } + + StdAwk::bool_t StdAwk::isPrint (cint_t c) + { + return ase_isprint (c); + } + + StdAwk::bool_t StdAwk::isGraph (cint_t c) + { + return ase_isgraph (c); + } + + StdAwk::bool_t StdAwk::isCntrl (cint_t c) + { + return ase_iscntrl (c); + } + + StdAwk::bool_t StdAwk::isPunct (cint_t c) + { + return ase_ispunct (c); + } + + StdAwk::cint_t StdAwk::toUpper (cint_t c) + { + return ase_toupper (c); + } + + StdAwk::cint_t StdAwk::toLower (cint_t c) + { + return ase_tolower (c); + } + + // miscellaneous primitive + StdAwk::real_t StdAwk::pow (real_t x, real_t y) + { + return ::pow (x, y); + } + + int StdAwk::vsprintf ( + char_t* buf, size_t size, const char_t* fmt, va_list arg) + { + return ase_vsprintf (buf, size, fmt, arg); + } + + void StdAwk::vdprintf (const char_t* fmt, va_list arg) + { + ase_vfprintf (stderr, fmt, arg); + } + } diff --git a/ase/awk/StdAwk.hpp b/ase/awk/StdAwk.hpp index 65a25900..28e609fb 100644 --- a/ase/awk/StdAwk.hpp +++ b/ase/awk/StdAwk.hpp @@ -1,5 +1,5 @@ /* - * $Id: StdAwk.hpp,v 1.7 2007/05/11 16:25:38 bacon Exp $ + * $Id: StdAwk.hpp,v 1.9 2007/05/16 14:44:13 bacon Exp $ */ #ifndef _ASE_AWK_STDAWK_HPP_ @@ -7,7 +7,6 @@ #include - namespace ASE { class StdAwk: public Awk @@ -18,6 +17,8 @@ namespace ASE int open (); protected: + + // builtin functions int sin (Return* ret, const Argument* args, size_t nargs); int cos (Return* ret, const Argument* args, size_t nargs); int tan (Return* ret, const Argument* args, size_t nargs); @@ -33,6 +34,45 @@ namespace ASE int strfgmtime (Return* ret, const Argument* args, size_t nargs); int system (Return* ret, const Argument* args, size_t nargs); + + // pipe io handlers + int openPipe (Pipe& io); + int closePipe (Pipe& io); + ssize_t readPipe (Pipe& io, char_t* buf, size_t len); + ssize_t writePipe (Pipe& io, char_t* buf, size_t len); + int flushPipe (Pipe& io); + + // file io handlers + int openFile (File& io); + int closeFile (File& io); + ssize_t readFile (File& io, char_t* buf, size_t len); + ssize_t writeFile (File& io, char_t* buf, size_t len); + int flushFile (File& io); + + // primitive handlers + void* allocMem (size_t n); + void* reallocMem (void* ptr, size_t n); + void freeMem (void* ptr); + + bool_t isUpper (cint_t c); + bool_t isLower (cint_t c); + bool_t isAlpha (cint_t c); + bool_t isDigit (cint_t c); + bool_t isXdigit (cint_t c); + bool_t isAlnum (cint_t c); + bool_t isSpace (cint_t c); + bool_t isPrint (cint_t c); + bool_t isGraph (cint_t c); + bool_t isCntrl (cint_t c); + bool_t isPunct (cint_t c); + cint_t toUpper (cint_t c); + cint_t toLower (cint_t c); + + real_t pow (real_t x, real_t y); + int vsprintf (char_t* buf, size_t size, + const char_t* fmt, va_list arg); + void vdprintf (const char_t* fmt, va_list arg); + protected: unsigned int seed; }; diff --git a/ase/change.log b/ase/change.log index e6ee034b..282733c2 100644 --- a/ase/change.log +++ b/ase/change.log @@ -8,6 +8,8 @@ * added awk c++ classes (awk/Awk.hpp awk/Awk.cpp awk/StdAwk.hpp awk/StdAwk.cpp) * added c++ test program (test/awk/Awk.cpp) +* changed the way to invoke the main function (utl/main.h utl/main.c) + [0.1.0] * initial release diff --git a/ase/test/awk/Awk.cpp b/ase/test/awk/Awk.cpp index edcb6fcf..3429c173 100644 --- a/ase/test/awk/Awk.cpp +++ b/ase/test/awk/Awk.cpp @@ -1,11 +1,9 @@ /* - * $Id: Awk.cpp,v 1.12 2007/05/14 08:40:13 bacon Exp $ + * $Id: Awk.cpp,v 1.15 2007/05/16 14:44:13 bacon Exp $ */ #include #include - -#include #include #include @@ -22,6 +20,9 @@ public: TestAwk (): srcInName(ASE_NULL), srcOutName(ASE_NULL), numConInFiles(0), numConOutFiles(0) { + #ifdef _WIN32 + heap = ASE_NULL; + #endif } ~TestAwk () @@ -29,6 +30,30 @@ public: close (); } + int open () + { + #ifdef _WIN32 + ASE_ASSERT (heap == ASE_NULL); + heap = HeapCreate (0, 1000000, 1000000); + if (heap == ASE_NULL) return -1; + #endif + + return StdAwk::open (); + } + + void close () + { + StdAwk::close (); + + numConInFiles = 0; + numConOutFiles = 0; + + #ifdef _WIN32 + HeapDestroy (heap); + heap = ASE_NULL; + #endif + } + int addConsoleInput (const char_t* file) { if (numConInFiles < ASE_COUNTOF(conInFile)) @@ -114,13 +139,19 @@ protected: ssize_t readSource (Source& io, char_t* buf, size_t len) { - if (len <= 0) return -1; + FILE* fp = (FILE*)io.getHandle(); + ssize_t n = 0; - // TOOD: read more characters... - cint_t c = ase_fgetc ((FILE*)io.getHandle()); - if (c == ASE_CHAR_EOF) return 0; - buf[0] = (ase_char_t)c; - return 1; + while (n < len) + { + ase_cint_t c = ase_fgetc (fp); + if (c == ASE_CHAR_EOF) break; + + buf[n++] = c; + if (c == ASE_T('\n')) break; + } + + return n; } ssize_t writeSource (Source& io, char_t* buf, size_t len) @@ -146,164 +177,6 @@ protected: return len; } - // pipe io handlers - int openPipe (Pipe& io) - { - Awk::Pipe::Mode mode = io.getMode(); - FILE* fp = NULL; - - switch (mode) - { - case Awk::Pipe::READ: - fp = ase_popen (io.getName(), ASE_T("r")); - break; - case Awk::Pipe::WRITE: - fp = ase_popen (io.getName(), ASE_T("w")); - break; - } - - if (fp == NULL) return -1; - - io.setHandle (fp); - return 1; - } - - int closePipe (Pipe& io) - { - fclose ((FILE*)io.getHandle()); - return 0; - } - - ssize_t readPipe (Pipe& io, char_t* buf, size_t len) - { - FILE* fp = (FILE*)io.getHandle(); - if (ase_fgets (buf, len, fp) == ASE_NULL) - { - if (ferror(fp)) return -1; - return 0; - } - - return ase_strlen(buf); - } - - ssize_t writePipe (Pipe& io, char_t* buf, size_t len) - { - FILE* fp = (FILE*)io.getHandle(); - size_t left = len; - - while (left > 0) - { - if (*buf == ASE_T('\0')) - { - #if defined(ASE_CHAR_IS_WCHAR) && defined(__linux) - if (fputc ('\0', fp) == EOF) - #else - if (ase_fputc (*buf, fp) == ASE_CHAR_EOF) - #endif - { - return -1; - } - left -= 1; buf += 1; - } - else - { - #if defined(ASE_CHAR_IS_WCHAR) && defined(__linux) - /* fwprintf seems to return an error with the file - * pointer opened by popen, as of this writing. - * anyway, hopefully the following replacement - * will work all the way. */ - int n = fprintf (fp, "%.*ls", left, buf); - if (n >= 0) - { - size_t x; - for (x = 0; x < left; x++) - { - if (buf[x] == ASE_T('\0')) break; - } - n = x; - } - #else - int n = ase_fprintf (fp, ASE_T("%.*s"), left, buf); - #endif - - if (n < 0 || n > left) return -1; - left -= n; buf += n; - } - } - - return len; - } - - int flushPipe (Pipe& io) { return ::fflush ((FILE*)io.getHandle()); } - - // file io handlers - int openFile (File& io) - { - Awk::File::Mode mode = io.getMode(); - FILE* fp = NULL; - - switch (mode) - { - case Awk::File::READ: - fp = ase_fopen (io.getName(), ASE_T("r")); - break; - case Awk::File::WRITE: - fp = ase_fopen (io.getName(), ASE_T("w")); - break; - case Awk::File::APPEND: - fp = ase_fopen (io.getName(), ASE_T("a")); - break; - } - - if (fp == NULL) return -1; - - io.setHandle (fp); - return 1; - } - - int closeFile (File& io) - { - fclose ((FILE*)io.getHandle()); - return 0; - } - - ssize_t readFile (File& io, char_t* buf, size_t len) - { - FILE* fp = (FILE*)io.getHandle(); - if (ase_fgets (buf, len, fp) == ASE_NULL) - { - if (ferror(fp)) return -1; - return 0; - } - - return ase_strlen(buf); - } - - ssize_t writeFile (File& io, char_t* buf, size_t len) - { - FILE* fp = (FILE*)io.getHandle(); - size_t left = len; - - while (left > 0) - { - if (*buf == ASE_T('\0')) - { - if (ase_fputc (*buf, fp) == ASE_CHAR_EOF) return -1; - left -= 1; buf += 1; - } - else - { - int n = ase_fprintf (fp, ASE_T("%.*s"), left, buf); - if (n < 0 || n > left) return -1; - left -= n; buf += n; - } - } - - return len; - } - - int flushFile (File& io) { return ::fflush ((FILE*)io.getHandle()); } - // console io handlers int openConsole (Console& io) { @@ -373,14 +246,18 @@ protected: { ConTrack* t = (ConTrack*)io.getHandle(); FILE* fp = t->handle; + ssize_t n = 0; - if (ase_fgets (buf, len, fp) == ASE_NULL) + while (n < len) { - if (ferror(fp)) return -1; - return 0; + ase_cint_t c = ase_fgetc (fp); + if (c == ASE_CHAR_EOF) break; + + buf[n++] = c; + if (c == ASE_T('\n')) break; } - return ase_strlen(buf); + return n; } ssize_t writeConsole (Console& io, char_t* buf, size_t len) @@ -456,39 +333,34 @@ protected: return 1; } - - // primitive operations - void* allocMem (size_t n) { return ::malloc (n); } - void* reallocMem (void* ptr, size_t n) { return ::realloc (ptr, n); } - void freeMem (void* ptr) { ::free (ptr); } - - bool_t isUpper (cint_t c) { return ase_isupper (c); } - bool_t isLower (cint_t c) { return ase_islower (c); } - bool_t isAlpha (cint_t c) { return ase_isalpha (c); } - bool_t isDigit (cint_t c) { return ase_isdigit (c); } - bool_t isXdigit (cint_t c) { return ase_isxdigit (c); } - bool_t isAlnum (cint_t c) { return ase_isalnum (c); } - bool_t isSpace (cint_t c) { return ase_isspace (c); } - bool_t isPrint (cint_t c) { return ase_isprint (c); } - bool_t isGraph (cint_t c) { return ase_isgraph (c); } - bool_t isCntrl (cint_t c) { return ase_iscntrl (c); } - bool_t isPunct (cint_t c) { return ase_ispunct (c); } - cint_t toUpper (cint_t c) { return ase_toupper (c); } - cint_t toLower (cint_t c) { return ase_tolower (c); } - - real_t pow (real_t x, real_t y) + void* allocMem (size_t n) { - return ::pow (x, y); + #ifdef _WIN32 + return ::HeapAlloc (heap, 0, n); + #else + return ::malloc (n); + #endif } - int vsprintf (char_t* buf, size_t size, const char_t* fmt, va_list arg) - { - return ase_vsprintf (buf, size, fmt, arg); + void* reallocMem (void* ptr, size_t n) + { + #ifdef _WIN32 + if (ptr == NULL) + return ::HeapAlloc (heap, 0, n); + else + return ::HeapReAlloc (heap, 0, ptr, n); + #else + return ::realloc (ptr, n); + #endif } - void vdprintf (const char_t* fmt, va_list arg) - { - ase_vfprintf (stderr, fmt, arg); + void freeMem (void* ptr) + { + #ifdef _WIN32 + ::HeapFree (heap, 0, ptr); + #else + ::free (ptr); + #endif } private: @@ -506,6 +378,10 @@ private: size_t numConOutFiles; const char_t* conOutFile[128]; + +#ifdef _WIN32 + void* heap; +#endif }; #ifndef NDEBUG @@ -683,15 +559,16 @@ int awk_main (int argc, ase_char_t* argv[]) return 0; } -extern "C" int ase_main (int argc, ase_char_t* argv[]) +int ase_main (int argc, ase_achar_t* argv[]) { + int n; #if defined(__linux) && defined(_DEBUG) mtrace (); #endif - n = awk_main (argc, argv); + n = ase_runmain (argc,argv,awk_main); #if defined(__linux) && defined(_DEBUG) muntrace (); diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index 12cc0d78..cbaaa92f 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.6 2007/05/13 14:57:43 bacon Exp $ + * $Id: awk.c,v 1.8 2007/05/16 09:15:14 bacon Exp $ */ #include @@ -46,13 +46,6 @@ struct mmgr_data_t }; #endif -#if defined(vms) || defined(__vms) -/* it seems that the main function should be placed in the main object file - * in OpenVMS. otherwise, the first function in the main object file seems - * to become the main function resulting in program start-up failure. */ -#include -#endif - #ifndef NDEBUG void ase_assert_abort (void) { @@ -1096,7 +1089,7 @@ static int awk_main (int argc, ase_char_t* argv[]) return 0; } -int ase_main (int argc, ase_char_t* argv[]) +int ase_main (int argc, ase_achar_t* argv[]) { int n; @@ -1109,7 +1102,7 @@ int ase_main (int argc, ase_char_t* argv[]) #endif */ - n = awk_main (argc, argv); + n = ase_runmain (argc, argv, awk_main); #if defined(__linux) && defined(_DEBUG) muntrace (); diff --git a/ase/test/lsp/lsp.c b/ase/test/lsp/lsp.c index ee5699e0..3bf4adfd 100644 --- a/ase/test/lsp/lsp.c +++ b/ase/test/lsp/lsp.c @@ -1,5 +1,5 @@ /* - * $Id: lsp.c,v 1.3 2007/04/30 08:32:50 bacon Exp $ + * $Id: lsp.c,v 1.5 2007/05/16 09:15:14 bacon Exp $ */ #include @@ -25,13 +25,6 @@ #include #endif -#if defined(vms) || defined(__vms) -/* it seems that the main function should be placed in the main object file - * in OpenVMS. otherwise, the first function in the main object file seems - * to become the main function resulting in program start-up failure. */ -#include -#endif - #ifndef NDEBUG void ase_assert_abort (void) { @@ -379,7 +372,7 @@ int lsp_main (int argc, ase_char_t* argv[]) return 0; } -int ase_main (int argc, ase_char_t* argv[]) +int ase_main (int argc, ase_achar_t* argv[]) { int n; @@ -387,7 +380,7 @@ int ase_main (int argc, ase_char_t* argv[]) mtrace (); #endif - n = lsp_main (argc, argv); + n = ase_runmain (argc, argv, lsp_main); #if defined(__linux) && defined(_DEBUG) muntrace (); diff --git a/ase/utl/main.c b/ase/utl/main.c index ad1a1111..5b895639 100644 --- a/ase/utl/main.c +++ b/ase/utl/main.c @@ -1,5 +1,5 @@ /* - * $Id: main.c,v 1.3 2007/04/30 08:32:50 bacon Exp $ + * $Id: main.c,v 1.5 2007/05/16 09:28:33 bacon Exp $ * * {License} */ @@ -10,19 +10,18 @@ #include #include -#if !defined(_WIN32) && defined(ASE_CHAR_IS_MCHAR) +#if defined(_WIN32) -int main (int argc, char* argv[], char** envp) +int ase_runmain (int argc, ase_achar_t* argv[], int(*mf) (int,ase_char_t*[])) { - setlocale (LC_ALL, ""); - return ase_main (argc, argv, envp); + return mf (argc, argv); } -#elif !defined(_WIN32) && defined(ASE_CHAR_IS_WCHAR) +#elif defined(ASE_CHAR_IS_WCHAR) #include -int main (int argc, char* argv[]/*, char** envp*/) +int ase_runmain (int argc, ase_achar_t* argv[], int(*mf) (int,ase_char_t*[])) { int i, ret; ase_char_t** v; @@ -73,7 +72,8 @@ int main (int argc, char* argv[]/*, char** envp*/) } /* TODO: envp... */ - ret = ase_main (argc, v, NULL); + //ret = mf (argc, v, NULL); + ret = mf (argc, v); exit_main: for (i = 0; i < argc; i++) @@ -86,4 +86,3 @@ exit_main: } #endif - diff --git a/ase/utl/main.h b/ase/utl/main.h index b9d83c2f..82de4a7e 100644 --- a/ase/utl/main.h +++ b/ase/utl/main.h @@ -1,5 +1,5 @@ /* - * $Id: main.h,v 1.4 2007/05/06 08:05:36 bacon Exp $ + * $Id: main.h,v 1.5 2007/05/16 09:14:10 bacon Exp $ */ #ifndef _ASE_UTL_MAIN_H_ @@ -9,18 +9,23 @@ #include #if defined(_WIN32) - #include #define ase_main _tmain - + typedef ase_char_t ase_achar_t; #else + #define ase_main main + typedef ase_mchar_t ase_achar_t; +#endif - #ifdef __cplusplus - /*extern "C" { int ase_main (...); }*/ - #else - extern int ase_main (); - #endif +#ifdef __cplusplus +extern "C" { +#endif + +int ase_runmain (int argc, ase_achar_t* argv[], int(*mf) (int,ase_char_t*[])); + +#ifdef __cplusplus +} #endif #endif