You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(447) |
Nov
(163) |
Dec
(57) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(172) |
Feb
|
Mar
(123) |
Apr
(64) |
May
(1) |
Jun
(278) |
Jul
(89) |
Aug
(97) |
Sep
(62) |
Oct
(53) |
Nov
(119) |
Dec
(60) |
| 2006 |
Jan
(76) |
Feb
(1094) |
Mar
(363) |
Apr
(163) |
May
(57) |
Jun
(43) |
Jul
(39) |
Aug
(15) |
Sep
(33) |
Oct
(62) |
Nov
(8) |
Dec
|
| 2007 |
Jan
(9) |
Feb
(34) |
Mar
(2) |
Apr
(14) |
May
(8) |
Jun
(40) |
Jul
(21) |
Aug
(1) |
Sep
(20) |
Oct
(15) |
Nov
(26) |
Dec
|
| 2008 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
(1) |
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(32) |
Jun
|
Jul
|
Aug
(3) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
| 2010 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(7) |
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Andre R. <and...@us...> - 2006-03-10 09:58:54
|
Update of /cvsroot/frontierkernel/Frontier/Common/resources/Mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22926/Common/resources/Mac Modified Files: lang.r Log Message: Added error message about missing command shell. Index: lang.r =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/resources/Mac/lang.r,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** lang.r 31 Jan 2006 19:11:32 -0000 1.10 --- lang.r 10 Mar 2006 09:58:49 -0000 1.11 *************** *** 716,720 **** "Can't execute command because the replacement string contains a non-existant group name at character #^0.", /* [161] */ ! "An item named Ò^0Ó already exists." // Replace it or create a duplicate?" /* 2005-09-26 creedon */ } }; --- 716,722 ---- "Can't execute command because the replacement string contains a non-existant group name at character #^0.", /* [161] */ ! "An item named Ò^0Ó already exists." // Replace it or create a duplicate?", /* 2005-09-26 creedon */ ! /* [162] */ ! "Can't run shell command because the shell \042^0\042 was not found.", /* 2006-03-10 aradke */ } }; |
|
From: Andre R. <and...@us...> - 2006-03-10 09:58:47
|
Update of /cvsroot/frontierkernel/Frontier/Common/resources/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22858/Common/resources/Win32 Modified Files: WinLand.rc Log Message: Added error message about missing command shell. Index: WinLand.rc =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/resources/Win32/WinLand.rc,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** WinLand.rc 25 Feb 2006 18:44:27 -0000 1.19 --- WinLand.rc 10 Mar 2006 09:58:41 -0000 1.20 *************** *** 1533,1536 **** --- 1533,1537 ---- 160 Lang_Errors DISCARDABLE BEGIN "Can't execute command because the replacement string contains a non-existant group name at character #^0.\0" END 161 Lang_Errors DISCARDABLE BEGIN "An item named \042^0\042 already exists.\0" END // Replace it or create a duplicate?" /* 2005-09-26 creedon */ + 162 Lang_Errors DISCARDABLE BEGIN "Can't run shell command because the shell \042^0\042 was not found.\0" END /* 2006-03-10 aradke */ 1 Mac_Errors DISCARDABLE BEGIN "The \042^0\042 folder is full.\0" END |
|
From: Andre R. <and...@us...> - 2006-03-10 09:58:13
|
Update of /cvsroot/frontierkernel/Frontier/Common/headers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22484/Common/headers Modified Files: langinternal.h Log Message: Added error message about missing command shell. Index: langinternal.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/langinternal.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** langinternal.h 30 Sep 2005 15:29:13 -0000 1.7 --- langinternal.h 10 Mar 2006 09:58:08 -0000 1.8 *************** *** 202,205 **** --- 202,206 ---- #define frnonexistantgroupnameerror 160 #define replaceitemerror 161 /* 2005-09-26 creedon */ + #define cmdshellnotfounderror 162 /* 2006-03-10 aradke */ #define langstacklist 137 |
|
From: Andre R. <and...@us...> - 2006-03-10 09:57:24
|
Update of /cvsroot/frontierkernel/Frontier/Common/headers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22251/Common/headers Modified Files: memory.h Log Message: Added pushcharhandle. Index: memory.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/memory.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** memory.h 9 Mar 2006 22:18:39 -0000 1.3 --- memory.h 10 Mar 2006 09:57:19 -0000 1.4 *************** *** 230,233 **** --- 230,235 ---- extern boolean pushhandle (Handle, Handle); + extern boolean pushcharhandle (char, Handle); /*2006-03-10 aradke*/ + extern boolean pushstringhandle (const bigstring, Handle); |
|
From: Andre R. <and...@us...> - 2006-03-10 09:57:07
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21956/Common/source Modified Files: memory.c Log Message: Added pushcharhandle. Index: memory.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/memory.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** memory.c 9 Mar 2006 22:18:57 -0000 1.7 --- memory.c 10 Mar 2006 09:56:57 -0000 1.8 *************** *** 1397,1400 **** --- 1397,1419 ---- + boolean pushcharhandle (char ch, Handle htext) { + + /* + 2006-03-10 aradke: grow handle by one and push char onto end + */ + + unsigned long size; + + size = gethandlesize (htext); + + if (!sethandlesize (htext, size + 1)) + return (false); + + (*htext)[size] = ch; + + return (true); + } /*pushcharhandle*/ + + boolean pushstringhandle (const bigstring bs, Handle htext) { |
|
From: Andre R. <and...@us...> - 2006-03-09 22:19:58
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4451/Common/source Modified Files: sysshellcall.c Log Message: Extended winshellcall code to deal with the situation when the COMSPEC environment variable is not defined or does not point to an existing file. Index: sysshellcall.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/sysshellcall.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sysshellcall.c 9 Mar 2006 18:37:00 -0000 1.3 --- sysshellcall.c 9 Mar 2006 22:19:54 -0000 1.4 *************** *** 32,35 **** --- 32,36 ---- #include "strings.h" #include "threads.h" + #include "error.h" #include "sysshellcall.h" *************** *** 158,162 **** 7.0b51: Call the UNIX popen command, which evaluates a string as if it were typed ! ôn the command line. Verb: sys.unixShellCommand. Code adapted by Timothy Paustian from Apple sample code. This routine by PBS. --- 159,163 ---- 7.0b51: Call the UNIX popen command, which evaluates a string as if it were typed ! on the command line. Verb: sys.unixShellCommand. Code adapted by Timothy Paustian from Apple sample code. This routine by PBS. *************** *** 207,210 **** --- 208,263 ---- #ifdef WIN95VERSION + static boolean getenvironmentvariable (char *name, boolean flwinerror, Handle *hresult) { + + /* + 2006-03-09 aradke: utility function for getting a Windows environment variable + as a handle without terminating nil char. + */ + + Handle h; + long res; + + res = GetEnvironmentVariable (name, nil, 0); + + if (res == 0) { + if (flwinerror) + winerror (); + return (false); + } + + if (!newclearhandle (res, &h)) + return (false); + + lockhandle (h); + + res = GetEnvironmentVariable (name, *h, res); + + unlockhandle (h); + + if (!sethandlesize (h, res)) { /*drop trailing nil char*/ + disposehandle (h); + return (false); + } + + *hresult = h; + + return (true); + } /*getenvironmentvariable*/ + + + static boolean cmdshellexists (Handle hshell) { + + DWORD attr; + + lockhandle (hshell); + + attr = GetFileAttributes (*hshell); + + unlockhandle (hshell); + + return (attr != INVALID_FILE_ATTRIBUTES); + } /*cmdshellexists*/ + + static boolean getcmdshell (Handle *hshell) { *************** *** 216,275 **** */ ! Handle h; ! long res; ! ! res = GetEnvironmentVariable("COMSPEC", nil, 0); ! ! if (res > 0) { /*var exists, allocate buffer and get its value*/ ! ! if (!newclearhandle (res, &h)) ! return (false); ! ! lockhandle (h); ! res = GetEnvironmentVariable("COMSPEC", *h, res); /*FIXME: check result, dispose h*/ ! unlockhandle (h); ! assert (res == gethandlesize (h) - 1); ! ! sethandlesize (h, res); /*drop trailing nil char*/ } else { ! OSVERSIONINFO osinfo; ! bigstring bs; ! osinfo.dwOSVersionInfoSize = sizeof (osinfo); ! ! GetVersionEx (&osinfo); /*FIXME: check result, report error*/ ! if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { ! copystring ("\x0b" "command.com", bs); /*Win95/98/ME: actual DOS command interpreter*/ } ! else { ! copystring ("\x07" "cmd.exe", bs); /*WinNT and successors: DOS emulation*/ } ! ! if (!newtexthandle (bs, &h)) return (false); ! } - *hshell = h; - return (true); ! } /*getcmdshell*/ ! boolean runcmdshell (Handle hshell, Handle hcommand, HANDLE *hout) { /* 2006-03-09 aradke: launch the command shell as a child process. TO DO: - check length of hcmdline < MAX_PATH - - make sure handles in processinfo struct are closed - - before creating process, check whether hshell exists - - if we can't access hshell, do a search path lookup - - proper error checking and reporting */ --- 269,419 ---- */ ! OSVERSIONINFO osinfo; ! bigstring bs; ! ! if (getenvironmentvariable ("COMSPEC", false, hshell)) ! return (true); ! osinfo.dwOSVersionInfoSize = sizeof (osinfo); ! if (GetVersionEx (&osinfo) == nil) { ! winerror (); ! return (false); ! } ! if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { ! copystring ("\x0b" "command.com", bs); /*Win95/98/ME: actual DOS command interpreter*/ } else { ! copystring ("\x07" "cmd.exe", bs); /*WinNT and successors: DOS emulation*/ ! } ! return (newtexthandle (bs, hshell)); ! } /*getcmdshell*/ ! ! #define CHDOUBLEQUOTE '"' ! #define CHSEMICOLON ';' ! #define CHBACKSLASH '\\' ! ! ! static boolean getnextpath (Handle hpath, long *ixstart, Handle *hitem) { ! ! Handle h; ! handlestream s; ! char ch; ! ! openhandlestream (hpath, &s); ! s.pos = *ixstart; ! ! /*first pass: locate end of next path item*/ ! ! skiphandlestreamchars (&s, CHSEMICOLON); /*ignore leading semicolons*/ ! *ixstart = s.pos; ! ! while (!athandlestreameof (&s)) { ! ! ch = nexthandlestreamcharacter (&s); ! ! if (ch == CHSEMICOLON) { ! break; } ! else if (ch == CHDOUBLEQUOTE) { ! s.pos++; ! seekhandlestreamchar (&s, CHDOUBLEQUOTE); /*skip over contents of doublequotes*/ } ! ! s.pos++; ! }/*while*/ ! ! /*extract item*/ ! ! if (!loadfromhandletohandle (s.data, ixstart, s.pos - *ixstart, false, &h)) ! return (false); ! ! /*second pass: remove included doublequotes*/ ! ! openhandlestream (h, &s); ! ! while (true) { ! ! seekhandlestreamchar (&s, CHDOUBLEQUOTE); ! ! if (athandlestreameof (&s)) ! break; ! ! pullfromhandlestream (&s, 1, nil); ! }/*while*/ ! ! if (lasthandlestreamcharacter (&s) != CHBACKSLASH) ! if (!writehandlestreamchar (&s, CHBACKSLASH)) { ! disposehandlestream (&s); return (false); ! } ! ! *hitem = closehandlestream (&s); return (true); ! } /*getnextpath*/ ! ! ! static boolean searchcmdpath (Handle *hshell) { + /* + 2006-03-09 aradke: get the PATH environment variable and parse it. + see if the command shell is located in any of the directories. + caller is responsible for disposing hshell. + + TO DO: + - check length of hshell < MAX_PATH + */ + + Handle hpath = nil; + Handle h = nil; + long ix = 0; ! /*obtain path environment variable*/ ! ! if (!getenvironmentvariable ("PATH", true, &hpath)) ! return (false); ! ! /*parse path*/ ! ! while (getnextpath (hpath, &ix, &h)) { ! ! if (!pushhandle (*hshell, h)) ! goto exit; ! ! if (!enlargehandle (h, 1, "\0")) ! goto exit; ! ! if (cmdshellexists (h)) { ! disposehandle (*hshell); ! *hshell = h; ! return (true); ! } ! ! disposehandle (h); ! }/*while*/ ! ! /*not found*/ ! ! oserror (ERROR_FILE_NOT_FOUND); ! ! exit: ! disposehandle (hpath); ! ! return (false); ! } /*searchcmdpath*/ ! ! ! static boolean runcmdshell (Handle hshell, Handle hcommand, HANDLE *hout) { /* 2006-03-09 aradke: launch the command shell as a child process. + we consume hshell, but caller is responsible for closing hout if we return true. TO DO: - check length of hcmdline < MAX_PATH */ *************** *** 280,287 **** HANDLE hpiperead = nil; HANDLE hpipewrite = nil; - DWORD attr; boolean fl; /*create pipe for reading from command shell*/ clearbytes (&securityinfo, sizeof (securityinfo)); securityinfo.nLength = sizeof (securityinfo); --- 424,431 ---- HANDLE hpiperead = nil; HANDLE hpipewrite = nil; boolean fl; /*create pipe for reading from command shell*/ + clearbytes (&securityinfo, sizeof (securityinfo)); securityinfo.nLength = sizeof (securityinfo); *************** *** 289,298 **** securityinfo.bInheritHandle = true; ! fl = CreatePipe (&hpiperead, &hpipewrite, &securityinfo, nil); ! ! if (!fl) ! goto exit; ! SetHandleInformation (hpiperead, HANDLE_FLAG_INHERIT, 0); /*init structs for creating process*/ --- 433,441 ---- securityinfo.bInheritHandle = true; ! if (!CreatePipe (&hpiperead, &hpipewrite, &securityinfo, nil)) ! goto error; ! if (!SetHandleInformation (hpiperead, HANDLE_FLAG_INHERIT, 0)) ! goto error; /*init structs for creating process*/ *************** *** 324,336 **** /*check whether command shell can be accessed*/ ! lockhandle (hshell); ! ! attr = GetFileAttributes(*hshell); ! ! unlockhandle (hshell); ! ! if (attr == INVALID_FILE_ATTRIBUTES) ! goto exit; /*not found, try searching PATH for command shell?*/ ! /*create command shell process*/ --- 467,475 ---- /*check whether command shell can be accessed*/ ! if (!cmdshellexists (hshell)) { ! if (!searchcmdpath (&hshell)) /*do a search path lookup*/ ! goto exit; ! } ! /*create command shell process*/ *************** *** 356,372 **** if (!fl) ! goto exit; ! CloseHandle (hpipewrite); /*inherited by child process*/ CloseHandle (processinfo.hProcess); CloseHandle (processinfo.hThread); disposehandle (hcmdline); *hout = hpiperead; return (true); ! ! exit: if (!hpiperead) CloseHandle (hpiperead); --- 495,516 ---- if (!fl) ! goto error; ! CloseHandle (hpipewrite); /*now inherited by child process*/ ! CloseHandle (processinfo.hProcess); CloseHandle (processinfo.hThread); disposehandle (hcmdline); + disposehandle (hshell); *hout = hpiperead; return (true); ! ! error: ! winerror (); /*note fall through*/ ! ! exit: /*error is already set*/ if (!hpiperead) CloseHandle (hpiperead); *************** *** 376,379 **** --- 520,524 ---- disposehandle (hcmdline); + disposehandle (hshell); return (false); *************** *** 381,389 **** ! boolean readcmdresult (HANDLE hread, Handle hreturn) { ! char buf [1024]; long ct = 0; boolean fl; while (true) { --- 526,540 ---- ! static boolean readcmdresult (HANDLE hread, Handle hreturn) { ! ! /* ! 2006-03-09 aradke: read data from pipe until eof. ! we close our end of the pipe (hread) whether we succeed or not. ! */ ! char buf[1024]; long ct = 0; boolean fl; + DWORD err = 0; while (true) { *************** *** 393,412 **** fl = ReadFile (hread, buf, sizeof (buf), &ct, nil); ! grabthreadglobals (); ! if (!fl) /*an error occurred*/ ! break; ! if (fl && (ct == 0)) /*end of file*/ break; ! if (ct > 0) ! if (!enlargehandle (hreturn, ct, buf)) break; } /*while*/ CloseHandle (hread); ! return (true); } /*readcmdresult*/ --- 544,577 ---- fl = ReadFile (hread, buf, sizeof (buf), &ct, nil); ! if (!fl) ! err = GetLastError (); ! grabthreadglobals (); ! if (fl && (ct == 0)) /*regular end of file*/ break; + + if (!fl) { + + if (err == ERROR_BROKEN_PIPE) + fl = true; /*ignore broken pipe*/ + else + oserror (err); + + break; + } ! if (ct > 0) { ! ! fl = enlargehandle (hreturn, ct, buf); ! ! if (!fl) break; + } } /*while*/ CloseHandle (hread); ! return (fl); } /*readcmdresult*/ *************** *** 425,445 **** if (!getcmdshell (&hshell)) ! goto exit; if (!runcmdshell (hshell, hcommand, &hread)) ! goto exit; if (!readcmdresult (hread, hreturn)) ! goto exit; ! ! disposehandle (hshell); return (true); - - exit: - - disposehandle (hshell); - - return (false); } /*winshellcall*/ --- 590,602 ---- if (!getcmdshell (&hshell)) ! return (false); if (!runcmdshell (hshell, hcommand, &hread)) ! return (false); if (!readcmdresult (hread, hreturn)) ! return (false); return (true); } /*winshellcall*/ *************** *** 460,464 **** FILE *f; ! char buf [1024]; long ct = 0; --- 617,621 ---- FILE *f; ! char buf[1024]; long ct = 0; |
|
From: Andre R. <and...@us...> - 2006-03-09 22:19:00
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3827/Common/source Modified Files: memory.c Log Message: Added seekhandlestreamchar. Index: memory.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/memory.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** memory.c 21 Mar 2005 02:43:14 -0000 1.6 --- memory.c 9 Mar 2006 22:18:57 -0000 1.7 *************** *** 2575,2578 **** --- 2575,2601 ---- + long seekhandlestreamchar (handlestream *s, byte chseek) { + + /* + return the number of characters skipped + */ + + byte *p = *(*s).data; + long ctskipped = 0; + + while ((*s).pos < (*s).eof) { + + if (p [(*s).pos] == chseek) + break; + + ++ctskipped; + + ++(*s).pos; + } + + return (ctskipped); + } /*skiphandlestreamchars*/ + + boolean readhandlestreamfieldtohandle (handlestream *s, byte chdelimiter, Handle *hreturned) { |
|
From: Andre R. <and...@us...> - 2006-03-09 22:18:42
|
Update of /cvsroot/frontierkernel/Frontier/Common/headers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3628/Common/headers Modified Files: memory.h Log Message: Added seekhandlestreamchar. Index: memory.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/memory.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** memory.h 11 Jan 2005 22:48:01 -0000 1.2 --- memory.h 9 Mar 2006 22:18:39 -0000 1.3 *************** *** 284,287 **** --- 284,289 ---- extern boolean skiphandlestreamwhitespace (handlestream *); + extern long seekhandlestreamchar (handlestream *s, byte chseek); + extern boolean readhandlestreamfieldtohandle (handlestream *s, byte chdelimiter, Handle *hreturned); |
|
From: Andre R. <and...@us...> - 2006-03-09 18:37:16
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22013/Common/source Modified Files: sysshellcall.c Log Message: Replaced code for winshellcall with an implementation that relies on the win32 api only and does not require the popen function to be available from the c runtime library (useful for Metroworks). Still lacks systematic error checking and reporting. Index: sysshellcall.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/sysshellcall.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sysshellcall.c 9 Mar 2006 11:08:50 -0000 1.2 --- sysshellcall.c 9 Mar 2006 18:37:00 -0000 1.3 *************** *** 30,33 **** --- 30,34 ---- #include "memory.h" + #include "strings.h" #include "threads.h" #include "sysshellcall.h" *************** *** 47,62 **** #define O_NONBLOCK 0x0004 /* no delay */ #endif //__MWERKS__ - #endif //MACVERSION && TARGET_API_MAC_CARBON - - - #ifdef WIN95VERSION - - #include <stdio.h> - #include <stdlib.h> - - #endif //WIN95VERSION - - - #if defined(MACVERSION) && (TARGET_API_MAC_CARBON == 1) /*System.framework functions: popen, pclose, fread, fcntl, feof, and fileno.*/ --- 48,51 ---- *************** *** 157,171 **** /* ! 2006-01-29 creedon: change buf from 32 to 1024 to increase performance of function, we can do this now because fread is now in non-blocking mode, kernel remains repsonsive ! 2006-01-10 creedon: laid down the groundwork for a timeoutsecs parameter, what is a good default? longinfinity? several minutes? I know that some commands I've done have taken 15 - 30 minutes ! fread now reads in non-blocking mode, no error checking 2005-10-02 creedon: changed buf size from 256 to 32, makes envrionment more responsive ! added call to new unixshellcallbackgroundtask function so kernel doesn't lock up while waiting for a lot of data to be read ! 7.0b51: Call the UNIX popen command, which evaluates a string as if it were typed on the command line. Verb: sys.unixShellCommand. ! Code adapted by Timothy Paustian from Apple sample code. ! This routine by PBS. */ --- 146,164 ---- /* ! 2006-01-29 creedon: change buf from 32 to 1024 to increase performance of function, ! we can do this now because fread is now in non-blocking mode, kernel remains repsonsive ! 2006-01-10 creedon: laid down the groundwork for a timeoutsecs parameter, what is a good default? ! longinfinity? several minutes? I know that some commands I've done have taken 15 - 30 minutes ! fread now reads in non-blocking mode, no error checking 2005-10-02 creedon: changed buf size from 256 to 32, makes envrionment more responsive ! added call to new unixshellcallbackgroundtask function so kernel doesn't lock up ! while waiting for a lot of data to be read ! 7.0b51: Call the UNIX popen command, which evaluates a string as if it were typed ! ôn the command line. Verb: sys.unixShellCommand. ! Code adapted by Timothy Paustian from Apple sample code. ! This routine by PBS. */ *************** *** 173,178 **** char buf [1024]; long ct = 0; - // unsigned long timeoutsecs = 60 * 5; - // long timeoutticks = gettickcount () + (timeoutsecs * 60); if (!unixshellcallinit ()) --- 166,169 ---- *************** *** 194,210 **** ct = freadfunc (buf, 1, sizeof buf, f); /*fread*/ ! if (ct > 0) // { ! ! if (!insertinhandle (hreturn, gethandlesize (hreturn), buf, ct)) break; - - // timeoutticks = gettickcount () + (timeoutsecs * 60); - // } if (feoffunc (f)) break; - - /* if (gettickcount () > timeoutticks) - break; */ if (!unixshellcallbackgroundtask ()) --- 185,194 ---- ct = freadfunc (buf, 1, sizeof buf, f); /*fread*/ ! if (ct > 0) ! if (!enlargehandle (hreturn, ct, buf)) break; if (feoffunc (f)) break; if (!unixshellcallbackgroundtask ()) *************** *** 223,231 **** #ifdef WIN95VERSION boolean winshellcall (Handle hcommand, Handle hreturn) { /* 2006-03-09 aradke: call the Windows shell and execute the given command. ! release thread globals before each sys call in order not to block other kernel threads. */ --- 207,460 ---- #ifdef WIN95VERSION + static boolean getcmdshell (Handle *hshell) { + + /* + 2006-03-09 aradke: return name or path of command shell in hshell. + check the COMSPEC environment variable first. if it does not exist, resort + to guessing the name of the shell based on the current OS version. + caller is responsible for disposing the handle if we return true. + */ + + Handle h; + long res; + + res = GetEnvironmentVariable("COMSPEC", nil, 0); + + if (res > 0) { /*var exists, allocate buffer and get its value*/ + + if (!newclearhandle (res, &h)) + return (false); + + lockhandle (h); + + res = GetEnvironmentVariable("COMSPEC", *h, res); /*FIXME: check result, dispose h*/ + + unlockhandle (h); + + assert (res == gethandlesize (h) - 1); + + sethandlesize (h, res); /*drop trailing nil char*/ + } + else { + OSVERSIONINFO osinfo; + bigstring bs; + + osinfo.dwOSVersionInfoSize = sizeof (osinfo); + + GetVersionEx (&osinfo); /*FIXME: check result, report error*/ + + if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { + copystring ("\x0b" "command.com", bs); /*Win95/98/ME: actual DOS command interpreter*/ + } + else { + copystring ("\x07" "cmd.exe", bs); /*WinNT and successors: DOS emulation*/ + } + + if (!newtexthandle (bs, &h)) + return (false); + } + + *hshell = h; + + return (true); + } /*getcmdshell*/ + + + boolean runcmdshell (Handle hshell, Handle hcommand, HANDLE *hout) { + + /* + 2006-03-09 aradke: launch the command shell as a child process. + + TO DO: + - check length of hcmdline < MAX_PATH + - make sure handles in processinfo struct are closed + - before creating process, check whether hshell exists + - if we can't access hshell, do a search path lookup + - proper error checking and reporting + */ + + Handle hcmdline = nil; + SECURITY_ATTRIBUTES securityinfo; + STARTUPINFO startupinfo; + PROCESS_INFORMATION processinfo; + HANDLE hpiperead = nil; + HANDLE hpipewrite = nil; + DWORD attr; + boolean fl; + + /*create pipe for reading from command shell*/ + clearbytes (&securityinfo, sizeof (securityinfo)); + securityinfo.nLength = sizeof (securityinfo); + securityinfo.lpSecurityDescriptor = nil; + securityinfo.bInheritHandle = true; + + fl = CreatePipe (&hpiperead, &hpipewrite, &securityinfo, nil); + + if (!fl) + goto exit; + + SetHandleInformation (hpiperead, HANDLE_FLAG_INHERIT, 0); + + /*init structs for creating process*/ + + clearbytes (&startupinfo, sizeof (startupinfo)); + startupinfo.cb = sizeof (startupinfo); + startupinfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; + startupinfo.hStdInput = GetStdHandle (STD_INPUT_HANDLE); + startupinfo.hStdOutput = hpipewrite; + startupinfo.hStdError = GetStdHandle (STD_ERROR_HANDLE); + startupinfo.wShowWindow = SW_HIDE; + + clearbytes (&processinfo, sizeof (processinfo)); + + /*synthesize command string*/ + + if (!inserttextinhandle (hcommand, 0, "\x04" " /c ")) + goto exit; + + if (!concathandles (hshell, hcommand, &hcmdline)) + goto exit; + + if (!enlargehandle (hshell, 1, "\0")) + goto exit; + + if (!enlargehandle (hcmdline, 1, "\0")) + goto exit; + + /*check whether command shell can be accessed*/ + + lockhandle (hshell); + + attr = GetFileAttributes(*hshell); + + unlockhandle (hshell); + + if (attr == INVALID_FILE_ATTRIBUTES) + goto exit; /*not found, try searching PATH for command shell?*/ + + /*create command shell process*/ + + lockhandle (hshell); + lockhandle (hcmdline); + + fl = CreateProcess ( + *hshell, /*IN LPCSTR lpApplicationName*/ + *hcmdline, /*IN LPSTR lpCommandLine*/ + nil, /*IN LPSECURITY_ATTRIBUTES lpProcessAttributes*/ + nil, /*IN LPSECURITY_ATTRIBUTES lpThreadAttributes*/ + true, /*IN BOOL bInheritHandles*/ + 0, /*IN DWORD dwCreationFlags*/ + nil, /*IN LPVOID lpEnvironment: use parent's*/ + nil, /*IN LPCSTR lpCurrentDirectory: use parent's*/ + &startupinfo, /*IN LPSTARTUPINFOA lpStartupInfo*/ + &processinfo); /*OUT LPPROCESS_INFORMATION lpProcessInformation*/ + + unlockhandle (hshell); + unlockhandle (hcmdline); + + /*handle result*/ + + if (!fl) + goto exit; + + CloseHandle (hpipewrite); /*inherited by child process*/ + CloseHandle (processinfo.hProcess); + CloseHandle (processinfo.hThread); + + disposehandle (hcmdline); + + *hout = hpiperead; + + return (true); + + exit: + if (!hpiperead) + CloseHandle (hpiperead); + + if (!hpipewrite) + CloseHandle (hpipewrite); + + disposehandle (hcmdline); + + return (false); + } /*runcmdshell*/ + + + boolean readcmdresult (HANDLE hread, Handle hreturn) { + + char buf [1024]; + long ct = 0; + boolean fl; + + while (true) { + + releasethreadglobals (); + + fl = ReadFile (hread, buf, sizeof (buf), &ct, nil); + + grabthreadglobals (); + + if (!fl) /*an error occurred*/ + break; + + if (fl && (ct == 0)) /*end of file*/ + break; + + if (ct > 0) + if (!enlargehandle (hreturn, ct, buf)) + break; + } /*while*/ + + CloseHandle (hread); + + return (true); + } /*readcmdresult*/ + + boolean winshellcall (Handle hcommand, Handle hreturn) { /* 2006-03-09 aradke: call the Windows shell and execute the given command. ! our caller owns hcommand and hreturn, whether we succeed or not. ! this implementation relies on the win32 api only and does not ! require popen etc to be available in the c runtime library. ! */ ! ! Handle hshell = nil; ! HANDLE hread; ! ! if (!getcmdshell (&hshell)) ! goto exit; ! ! if (!runcmdshell (hshell, hcommand, &hread)) ! goto exit; ! ! if (!readcmdresult (hread, hreturn)) ! goto exit; ! ! disposehandle (hshell); ! ! return (true); ! ! exit: ! ! disposehandle (hshell); ! ! return (false); ! } /*winshellcall*/ ! ! ! #if 0 //!__MWERKS__ ! ! #include <stdio.h> ! #include <stdlib.h> ! ! boolean winshellcall (Handle hcommand, Handle hreturn) { ! ! /* ! 2006-03-09 aradke: simple version relying on popen to be available ! from the c runtime library. that is the case with microsoft's ! runtime library, but not with metrowerks. see our own ! implementation above using only win32 api calls. */ *************** *** 242,250 **** f = _popen (*hcommand, "r"); - - unlockhandle (hcommand); grabthreadglobals (); while (true) { --- 471,479 ---- f = _popen (*hcommand, "r"); grabthreadglobals (); + unlockhandle (hcommand); + while (true) { *************** *** 256,260 **** if (ct > 0) ! if (!insertinhandle (hreturn, gethandlesize (hreturn), buf, ct)) break; --- 485,489 ---- if (ct > 0) ! if (!enlargehandle (hreturn, ct, buf)) break; *************** *** 269,272 **** --- 498,503 ---- } /*winshellcall*/ + #endif + #endif //WIN95VERSION |
|
From: Andre R. <and...@us...> - 2006-03-09 13:58:56
|
Update of /cvsroot/frontierkernel/Frontier/build_CWPro8 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31659/build_CWPro8 Modified Files: OPML.mcp Frontier.mcp Log Message: Added sysshellcall.h/.c Index: Frontier.mcp =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/build_CWPro8/Frontier.mcp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 Binary files /tmp/cvsE0IeTb and /tmp/cvs0B5c5a differ Index: OPML.mcp =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/build_CWPro8/OPML.mcp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 Binary files /tmp/cvsWgm9Tg and /tmp/cvsLwCAjg differ |
|
From: Andre R. <and...@us...> - 2006-03-09 13:44:32
|
Update of /cvsroot/frontierkernel/Frontier/build_GNU In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22981 Modified Files: Makefile Log Message: Added sysshellcall.h/.c Index: Makefile =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/build_GNU/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 10 Feb 2006 21:21:15 -0000 1.5 --- Makefile 9 Mar 2006 13:44:21 -0000 1.6 *************** *** 346,349 **** --- 346,350 ---- $(SRCDIR)/Common/headers/odbinternal.h \ $(SRCDIR)/Common/headers/CallMachOFrameWork.h \ + $(SRCDIR)/Common/headers/sysshellcall.h \ $(SRCDIR)/Common/headers/langhtml.h \ $(SRCDIR)/Common/headers/langxml.h \ *************** *** 685,688 **** --- 686,690 ---- $(SRCDIR)/Common/source/smallicon.c \ $(SRCDIR)/Common/source/sounds.c \ + $(SRCDIR)/Common/source/sysshellcall.c \ $(SRCDIR)/Common/source/textedit.c \ $(SRCDIR)/Common/source/threads.c \ *************** *** 721,724 **** --- 723,727 ---- $(OBJDIR)/Common/source/smallicon.o \ $(OBJDIR)/Common/source/sounds.o \ + $(OBJDIR)/Common/source/sysshellcall.o \ $(OBJDIR)/Common/source/textedit.o \ $(OBJDIR)/Common/source/threads.o \ |
|
From: Andre R. <and...@us...> - 2006-03-09 11:08:55
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22903/Common/source Modified Files: CallMachOFrameWork.c langstartup.c shellsysverbs.c sysshellcall.c Log Message: Moved unixshellcall from CallMachOFrameWork.c to sysshellcall.c Index: sysshellcall.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/sysshellcall.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sysshellcall.c 9 Mar 2006 09:46:29 -0000 1.1 --- sysshellcall.c 9 Mar 2006 11:08:50 -0000 1.2 *************** *** 33,39 **** --- 33,225 ---- #include "sysshellcall.h" + + #if defined(MACVERSION) && (TARGET_API_MAC_CARBON == 1) + + #include "shell.h" + #include "lang.h" + #include "CallMachOFramework.h" + #include <fcntl.h> /* 2006-01-10 creedon */ + + /* 2006-01-29 creedon - define the following for CodeWarrior compilation because it doesn't have these defined in its headers, as Xcode does */ + #ifdef __MWERKS__ + #define F_GETFL 3 /* get file status flags */ + #define F_SETFL 4 /* set file status flags */ + #define O_NONBLOCK 0x0004 /* no delay */ + #endif //__MWERKS__ + #endif //MACVERSION && TARGET_API_MAC_CARBON + + + #ifdef WIN95VERSION + #include <stdio.h> #include <stdlib.h> + #endif //WIN95VERSION + + + #if defined(MACVERSION) && (TARGET_API_MAC_CARBON == 1) + + /*System.framework functions: popen, pclose, fread, fcntl, feof, and fileno.*/ + + typedef FILE* (*popenptr) (const char* command, const char *type); + typedef int (*pcloseptr) (FILE* f); + typedef size_t (*freadptr) (void *ptr, size_t size, size_t nobj, FILE* f); + typedef int (*fcntlptr) (int fd, int cmd, int arg); /* 2006-01-10 creedon */ + typedef int (*feofptr) (FILE *f); /* 2006-01-10 creedon */ + typedef int (*filenoptr) (FILE *f); /* 2006-01-10 creedon */ + + static popenptr popenfunc; + static pcloseptr pclosefunc; + static freadptr freadfunc; + static fcntlptr fcntlfunc; /* 2006-01-10 creedon */ + static feofptr feoffunc; /* 2006-01-10 creedon */ + static filenoptr filenofunc; /* 2006-01-10 creedon */ + + static boolean unixshellcallinited = false; + static CFBundleRef sysBundle = nil; + + + static boolean unixshellcallinit (void) { + + /* + 2006-01-10 creedon: added fcntlfunc, feoffunc and filenofunc + + 7.0b51 PBS: load the bundle and get the function pointers the first time called. + */ + + if (unixshellcallinited) /*already inited*/ + return (true); + + if (sysBundle == nil) + if (LoadFrameworkBundle (CFSTR ("System.framework"), &sysBundle) != noErr) + return (false); + + popenfunc = (popenptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("popen")); + + if (popenfunc == nil) + return (false); + + freadfunc = (freadptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("fread")); + + if (freadfunc == nil) + return (false); + + pclosefunc = (pcloseptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("pclose")); + + if (pclosefunc == nil) + return (false); + + fcntlfunc = (fcntlptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("fcntl")); + + if (fcntlfunc == nil) + return (false); + + feoffunc = (feofptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("feof")); + + if (feoffunc == nil) + return (false); + + filenofunc = (filenoptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("fileno")); + + if (filenofunc == nil) + return (false); + + unixshellcallinited = true; + + return (true); + } /*unixshellcallinit*/ + + + static boolean unixshellcallbackgroundtask (void) { + + /* + 2005-10-02 creedon: created, cribbed from OpenTransportNetEvents.c: fwsbackgroundtask + */ + + boolean fl = true; + + if (inmainthread ()) { + EventRecord ev; + short mask = osMask|activMask|mDownMask|keyDownMask; // |highLevelEventMask|updateMask + long sleepTime = 6; // 1/10 of a second by default + + if (WaitNextEvent (mask, &ev, sleepTime, nil)) /* might return false to indicate a null event, but that's not an error */ + fl = shellprocessevent (&ev); + } + else + fl = langbackgroundtask (true); + + return (fl); + }/* unixshellcallbackgroundtask */ + + + boolean unixshellcall (Handle hcommand, Handle hreturn) { + + /* + 2006-01-29 creedon: change buf from 32 to 1024 to increase performance of function, we can do this now because fread is now in non-blocking mode, kernel remains repsonsive + + 2006-01-10 creedon: laid down the groundwork for a timeoutsecs parameter, what is a good default? longinfinity? several minutes? I know that some commands I've done have taken 15 - 30 minutes + fread now reads in non-blocking mode, no error checking + + 2005-10-02 creedon: changed buf size from 256 to 32, makes envrionment more responsive + added call to new unixshellcallbackgroundtask function so kernel doesn't lock up while waiting for a lot of data to be read + + 7.0b51: Call the UNIX popen command, which evaluates a string as if it were typed on the command line. Verb: sys.unixShellCommand. + Code adapted by Timothy Paustian from Apple sample code. + This routine by PBS. + */ + + FILE *f; + char buf [1024]; + long ct = 0; + // unsigned long timeoutsecs = 60 * 5; + // long timeoutticks = gettickcount () + (timeoutsecs * 60); + + if (!unixshellcallinit ()) + return (false); + + if (!enlargehandle (hcommand, 1, "\0")) + return (false); + + lockhandle (hcommand); + + f = popenfunc (*hcommand, "r"); /*popen*/ + + unlockhandle (hcommand); + + fcntlfunc (filenofunc (f), F_SETFL, fcntlfunc (filenofunc (f), F_GETFL, 0) | O_NONBLOCK); + + while (true) { + + ct = freadfunc (buf, 1, sizeof buf, f); /*fread*/ + + if (ct > 0) // { + + if (!insertinhandle (hreturn, gethandlesize (hreturn), buf, ct)) + break; + + // timeoutticks = gettickcount () + (timeoutsecs * 60); + // } + + if (feoffunc (f)) + break; + + /* if (gettickcount () > timeoutticks) + break; */ + + if (!unixshellcallbackgroundtask ()) + break; + + } /*while*/ + + pclosefunc (f); /*pclose*/ + + return (true); + } /*unixshellcall*/ + + #endif //MACVERSION + + + #ifdef WIN95VERSION boolean winshellcall (Handle hcommand, Handle hreturn) { *************** *** 83,84 **** --- 269,272 ---- } /*winshellcall*/ + #endif //WIN95VERSION + Index: langstartup.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langstartup.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** langstartup.c 18 Feb 2006 15:02:13 -0000 1.8 --- langstartup.c 9 Mar 2006 11:08:50 -0000 1.9 *************** *** 42,48 **** #include "resources.h" #include "WinSockNetEvents.h" ! #if TARGET_API_MAC_CARBON == 1 ! #include "CallMachOFrameWork.h" /* 2004-11-19 creedon */ ! #endif --- 42,46 ---- #include "resources.h" #include "WinSockNetEvents.h" ! #include "sysshellcall.h" /* 2006-03-09 aradke: unixshellcall moved from CallMachOFramework.h */ Index: CallMachOFrameWork.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/CallMachOFrameWork.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CallMachOFrameWork.c 30 Jan 2006 01:42:04 -0000 1.10 --- CallMachOFrameWork.c 9 Mar 2006 11:08:50 -0000 1.11 *************** *** 28,179 **** #include "frontier.h" #include "standard.h" - #include "threads.h" - #include "shell.h" - #include "lang.h" #include "CallMachOFrameWork.h" - #include "memory.h" - #include "fcntl.h" /* 2006-01-10 creedon */ - - - /*System.framework functions: popen, pclose, fread, fcntl, feof, and fileno.*/ - - typedef FILE* (*popenptr) (const char* command, const char *type); - typedef int (*pcloseptr) (FILE* f); - typedef size_t (*freadptr) (void *ptr, size_t size, size_t nobj, FILE* f); - typedef int (*fcntlptr) (int fd, int cmd, int arg); /* 2006-01-10 creedon */ - typedef int (*feofptr) (FILE *f); /* 2006-01-10 creedon */ - typedef int (*filenoptr) (FILE *f); /* 2006-01-10 creedon */ - - static popenptr popenfunc; - static pcloseptr pclosefunc; - static freadptr freadfunc; - static fcntlptr fcntlfunc; /* 2006-01-10 creedon */ - static feofptr feoffunc; /* 2006-01-10 creedon */ - static filenoptr filenofunc; /* 2006-01-10 creedon */ - - static boolean unixshellcallinited = false; - static CFBundleRef sysBundle = nil; - - - /* prototypes */ - static boolean unixshellcallinit (void); - static boolean unixshellcallbackgroundtask (void); - - - boolean unixshellcall (Handle hcommand, Handle hreturn) { - - /* - 2006-01-29 creedon: change buf from 32 to 1024 to increase performance of function, we can do this now because fread is now in non-blocking mode, kernel remains repsonsive - - 2006-01-10 creedon: laid down the groundwork for a timeoutsecs parameter, what is a good default? longinfinity? several minutes? I know that some commands I've done have taken 15 - 30 minutes - fread now reads in non-blocking mode, no error checking - - 2005-10-02 creedon: changed buf size from 256 to 32, makes envrionment more responsive - added call to new unixshellcallbackgroundtask function so kernel doesn't lock up while waiting for a lot of data to be read - - 7.0b51: Call the UNIX popen command, which evaluates a string as if it were typed on the command line. Verb: sys.unixShellCommand. - Code adapted by Timothy Paustian from Apple sample code. - This routine by PBS. - */ - - FILE *f; - char buf [1024]; - long ct = 0; - // unsigned long timeoutsecs = 60 * 5; - // long timeoutticks = gettickcount () + (timeoutsecs * 60); - - if (!unixshellcallinit ()) - return (false); - - if (!enlargehandle (hcommand, 1, "\0")) - return (false); - - lockhandle (hcommand); - - f = popenfunc (*hcommand, "r"); /*popen*/ - - unlockhandle (hcommand); - - fcntlfunc (filenofunc (f), F_SETFL, fcntlfunc (filenofunc (f), F_GETFL, 0) | O_NONBLOCK); - - while (true) { - - ct = freadfunc (buf, 1, sizeof buf, f); /*fread*/ - - if (ct > 0) // { - - if (!insertinhandle (hreturn, gethandlesize (hreturn), buf, ct)) - break; - - // timeoutticks = gettickcount () + (timeoutsecs * 60); - // } - - if (feoffunc (f)) - break; - - /* if (gettickcount () > timeoutticks) - break; */ - - if (!unixshellcallbackgroundtask ()) - break; - - } /*while*/ - - pclosefunc (f); /*pclose*/ - - return (true); - } /*unixshellcall*/ - - - static boolean unixshellcallinit (void) { - - /* - 2006-01-10 creedon: added fcntlfunc, feoffunc and filenofunc - - 7.0b51 PBS: load the bundle and get the function pointers the first time called. - */ - - if (unixshellcallinited) /*already inited*/ - return (true); - - if (sysBundle == nil) - if (LoadFrameworkBundle (CFSTR ("System.framework"), &sysBundle) != noErr) - return (false); - - popenfunc = (popenptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("popen")); - - if (popenfunc == nil) - return (false); - - freadfunc = (freadptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("fread")); - - if (freadfunc == nil) - return (false); - - pclosefunc = (pcloseptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("pclose")); - - if (pclosefunc == nil) - return (false); - - fcntlfunc = (fcntlptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("fcntl")); - - if (fcntlfunc == nil) - return (false); - - feoffunc = (feofptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("feof")); - - if (feoffunc == nil) - return (false); - - filenofunc = (filenoptr) CFBundleGetFunctionPointerForName (sysBundle, CFSTR ("fileno")); - - if (filenofunc == nil) - return (false); - - unixshellcallinited = true; - - return (true); - } /*unixshellcallinit*/ --- 28,33 ---- *************** *** 316,341 **** DisposePtr (cfmfp); } /*disposecfmfuncptr*/ - - - static boolean unixshellcallbackgroundtask (void) { - - /* - 2005-10-02 creedon: created, cribbed from OpenTransportNetEvents.c: fwsbackgroundtask - */ - - boolean fl = true; - - if (inmainthread ()) { - EventRecord ev; - short mask = osMask|activMask|mDownMask|keyDownMask; // |highLevelEventMask|updateMask - long sleepTime = 6; // 1/10 of a second by default - - if (WaitNextEvent (mask, &ev, sleepTime, nil)) /* might return false to indicate a null event, but that's not an error */ - fl = shellprocessevent (&ev); - } - else - fl = langbackgroundtask (true); - - return (fl); - }/* unixshellcallbackgroundtask */ - --- 170,171 ---- Index: shellsysverbs.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/shellsysverbs.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** shellsysverbs.c 9 Mar 2006 09:46:29 -0000 1.8 --- shellsysverbs.c 9 Mar 2006 11:08:50 -0000 1.9 *************** *** 59,68 **** #include "process.h" #include "processinternal.h" ! #if TARGET_API_MAC_CARBON == 1 ! #include "CallMachOFrameWork.h" ! #endif ! #ifdef WIN95VERSION ! #include "sysshellcall.h" ! #endif #include "langsystem7.h" //6.1b7 AR: we need coercetolist --- 59,63 ---- #include "process.h" #include "processinternal.h" ! #include "sysshellcall.h" #include "langsystem7.h" //6.1b7 AR: we need coercetolist |
|
From: Andre R. <and...@us...> - 2006-03-09 11:08:55
|
Update of /cvsroot/frontierkernel/Frontier/build_XCode/Frontier.xcode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22903/build_XCode/Frontier.xcode Modified Files: project.pbxproj Log Message: Moved unixshellcall from CallMachOFrameWork.c to sysshellcall.c Index: project.pbxproj =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/build_XCode/Frontier.xcode/project.pbxproj,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** project.pbxproj 8 Feb 2006 21:37:19 -0000 1.25 --- project.pbxproj 9 Mar 2006 11:08:50 -0000 1.26 *************** *** 282,285 **** --- 282,286 ---- 65059A3909968C1400410571, 65059A3A09968C1400410571, + 65AA438709C03C6D00A4B237, ); isa = PBXHeadersBuildPhase; *************** *** 1827,1830 **** --- 1828,1832 ---- 65059B3209968C1400410571, 65059B3309968C1400410571, + 65AA438C09C03C8900A4B237, ); isa = PBXSourcesBuildPhase; *************** *** 3855,3858 **** --- 3857,3861 ---- 65B70CE00797CEAD008C2F1A, 65B70CEA0797CF78008C2F1A, + 65AA438609C03C6D00A4B237, ); isa = PBXHeadersBuildPhase; *************** *** 4110,4113 **** --- 4113,4117 ---- 65B70CDC0797CE4A008C2F1A, 65B70CE60797CF2D008C2F1A, + 65AA438B09C03C8900A4B237, ); isa = PBXSourcesBuildPhase; *************** *** 5376,5379 **** --- 5380,5384 ---- 65152608072BFC6700411831, 65152609072BFC6700411831, + 65AA438A09C03C8900A4B237, 6515260A072BFC6700411831, 6515260B072BFC6700411831, *************** *** 11874,11877 **** --- 11879,11924 ---- }; }; + 65AA438509C03C6D00A4B237 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = sysshellcall.h; + path = ../Common/headers/sysshellcall.h; + refType = 2; + sourceTree = SOURCE_ROOT; + }; + 65AA438609C03C6D00A4B237 = { + fileRef = 65AA438509C03C6D00A4B237; + isa = PBXBuildFile; + settings = { + }; + }; + 65AA438709C03C6D00A4B237 = { + fileRef = 65AA438509C03C6D00A4B237; + isa = PBXBuildFile; + settings = { + }; + }; + 65AA438A09C03C8900A4B237 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + name = sysshellcall.c; + path = /Volumes/Data/Development/frontierkernel_main/Frontier/Common/source/sysshellcall.c; + refType = 0; + sourceTree = "<absolute>"; + }; + 65AA438B09C03C8900A4B237 = { + fileRef = 65AA438A09C03C8900A4B237; + isa = PBXBuildFile; + settings = { + }; + }; + 65AA438C09C03C8900A4B237 = { + fileRef = 65AA438A09C03C8900A4B237; + isa = PBXBuildFile; + settings = { + }; + }; 65AC81D808DC792700ADD675 = { fileEncoding = 30; *************** *** 12081,12084 **** --- 12128,12132 ---- 65152924072BFFD200411831, 651527E0072BFE3900411831, + 65AA438509C03C6D00A4B237, 65152906072BFF6800411831, 651528B8072BFF0700411831, |
|
From: Andre R. <and...@us...> - 2006-03-09 11:08:55
|
Update of /cvsroot/frontierkernel/Frontier/Common/headers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22903/Common/headers Modified Files: CallMachOFrameWork.h sysshellcall.h Log Message: Moved unixshellcall from CallMachOFrameWork.c to sysshellcall.c Index: sysshellcall.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/sysshellcall.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sysshellcall.h 9 Mar 2006 09:49:14 -0000 1.1 --- sysshellcall.h 9 Mar 2006 11:08:50 -0000 1.2 *************** *** 26,29 **** ******************************************************************************/ ! boolean winshellcall (Handle hcommand, Handle hreturn); --- 26,39 ---- ******************************************************************************/ ! #if defined(MACVERSION) && (TARGET_API_MAC_CARBON == 1) ! ! boolean unixshellcall (Handle, Handle); ! ! #endif + + #ifdef WIN95VERSION + + boolean winshellcall (Handle, Handle); + + #endif Index: CallMachOFrameWork.h =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/headers/CallMachOFrameWork.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CallMachOFrameWork.h 29 Jan 2006 23:25:59 -0000 1.7 --- CallMachOFrameWork.h 9 Mar 2006 11:08:50 -0000 1.8 *************** *** 29,43 **** #define callmachoframework - /* 2006-01-29 creedon - define the following for CodeWarrior compilation because it doesn't have these defined in its headers, as Xcode does */ - - #ifdef __MWERKS__ - #define F_GETFL 3 /* get file status flags */ - #define F_SETFL 4 /* set file status flags */ - #define O_NONBLOCK 0x0004 /* no delay */ - #endif - - - extern boolean unixshellcall (Handle hcommand, Handle hreturn); - extern OSStatus LoadFrameworkBundle(CFStringRef framework, CFBundleRef *bundlePtr); --- 29,32 ---- |
|
From: Andre R. <and...@us...> - 2006-03-09 09:49:16
|
Update of /cvsroot/frontierkernel/Frontier/Common/headers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6762/Common/headers Added Files: sysshellcall.h Log Message: Added sys.winShellCommand, a new kernel verb for calling the system shell on Windows. Complements the Mac OS X only sys.unixShellCommand. --- NEW FILE: sysshellcall.h --- /* $Id: sysshellcall.h,v 1.1 2006/03/09 09:49:14 andreradke Exp $ */ /****************************************************************************** UserLand Frontier(tm) -- High performance Web content management, object database, system-level and Internet scripting environment, including source code editing and debugging. Copyright (C) 1992-2004 UserLand Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ******************************************************************************/ boolean winshellcall (Handle hcommand, Handle hreturn); |
|
From: Andre R. <and...@us...> - 2006-03-09 09:46:32
|
Update of /cvsroot/frontierkernel/Frontier/build_VC2K3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4889/build_VC2K3 Modified Files: Frontier.vcproj Log Message: Added sys.winShellCommand, a new kernel verb for calling the system shell on Windows. Complements the Mac OS X only sys.unixShellCommand. Index: Frontier.vcproj =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/build_VC2K3/Frontier.vcproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Frontier.vcproj 31 Mar 2005 14:21:02 -0000 1.1 --- Frontier.vcproj 9 Mar 2006 09:46:29 -0000 1.2 *************** *** 2255,2258 **** --- 2255,2261 ---- </File> <File + RelativePath="..\Common\source\sysshellcall.c"> + </File> + <File RelativePath="..\Common\source\textedit.c"> <FileConfiguration *************** *** 7231,7234 **** --- 7234,7240 ---- </File> <File + RelativePath="..\Common\headers\sysshellcall.h"> + </File> + <File RelativePath="..\Common\headers\tabledisplay.h"> </File> |
|
From: Andre R. <and...@us...> - 2006-03-09 09:46:32
|
Update of /cvsroot/frontierkernel/Frontier/Common/resources/Mac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4889/Common/resources/Mac Modified Files: kernelverbs.r Log Message: Added sys.winShellCommand, a new kernel verb for calling the system shell on Windows. Complements the Mac OS X only sys.unixShellCommand. Index: kernelverbs.r =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/resources/Mac/kernelverbs.r,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** kernelverbs.r 27 Feb 2006 01:23:41 -0000 1.4 --- kernelverbs.r 9 Mar 2006 09:46:28 -0000 1.5 *************** *** 845,849 **** "getenvironmentvariable", "setenvironmentvariable", ! "unixshellcommand" } } --- 845,850 ---- "getenvironmentvariable", "setenvironmentvariable", ! "unixshellcommand", ! "winshellcommand" /* 2006-03-09 aradke */ } } |
|
From: Andre R. <and...@us...> - 2006-03-09 09:46:32
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4889/Common/source Modified Files: shellsysverbs.c Added Files: sysshellcall.c Log Message: Added sys.winShellCommand, a new kernel verb for calling the system shell on Windows. Complements the Mac OS X only sys.unixShellCommand. --- NEW FILE: sysshellcall.c --- /* $Id: sysshellcall.c,v 1.1 2006/03/09 09:46:29 andreradke Exp $ */ /****************************************************************************** UserLand Frontier(tm) -- High performance Web content management, object database, system-level and Internet scripting environment, including source code editing and debugging. Copyright (C) 1992-2004 UserLand Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ******************************************************************************/ #include "frontier.h" #include "standard.h" #include "memory.h" #include "threads.h" #include "sysshellcall.h" #include <stdio.h> #include <stdlib.h> boolean winshellcall (Handle hcommand, Handle hreturn) { /* 2006-03-09 aradke: call the Windows shell and execute the given command. release thread globals before each sys call in order not to block other kernel threads. */ FILE *f; char buf [1024]; long ct = 0; if (!enlargehandle (hcommand, 1, "\0")) return (false); lockhandle (hcommand); releasethreadglobals (); f = _popen (*hcommand, "r"); unlockhandle (hcommand); grabthreadglobals (); while (true) { releasethreadglobals (); ct = fread (buf, 1, sizeof (buf), f); /*fread*/ grabthreadglobals (); if (ct > 0) if (!insertinhandle (hreturn, gethandlesize (hreturn), buf, ct)) break; if (feof (f)) break; } /*while*/ _pclose (f); return (true); } /*winshellcall*/ Index: shellsysverbs.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/shellsysverbs.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** shellsysverbs.c 17 Feb 2006 18:25:56 -0000 1.7 --- shellsysverbs.c 9 Mar 2006 09:46:29 -0000 1.8 *************** *** 62,65 **** --- 62,68 ---- #include "CallMachOFrameWork.h" #endif + #ifdef WIN95VERSION + #include "sysshellcall.h" + #endif #include "langsystem7.h" //6.1b7 AR: we need coercetolist *************** *** 112,115 **** --- 115,120 ---- unixshellcommandfunc, + winshellcommandfunc, + ctsysverbs } tysystoken; *************** *** 686,691 **** } ! #endif default: --- 691,723 ---- } + #endif ! #ifdef WIN95VERSION ! ! case winshellcommandfunc: { ! Handle hcommand, hreturn; ! ! newemptyhandle (&hreturn); ! ! flnextparamislast = true; ! ! if (!getexempttextvalue (hparam1, 1, &hcommand)) ! return (false); ! ! if (!winshellcall (hcommand, hreturn)) { ! ! disposehandle (hreturn); ! ! disposehandle (hcommand); ! ! return (false); ! } /*if*/ ! ! disposehandle (hcommand); ! ! return (setheapvalue (hreturn, stringvaluetype, v)); ! } ! ! #endif //WIN95VERSION default: |
|
From: Andre R. <and...@us...> - 2006-03-09 09:46:32
|
Update of /cvsroot/frontierkernel/Frontier/Common/resources/Win32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4889/Common/resources/Win32 Modified Files: kernelverbs.rc Log Message: Added sys.winShellCommand, a new kernel verb for calling the system shell on Windows. Complements the Mac OS X only sys.unixShellCommand. Index: kernelverbs.rc =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/resources/Win32/kernelverbs.rc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** kernelverbs.rc 27 Feb 2006 01:23:59 -0000 1.4 --- kernelverbs.rc 9 Mar 2006 09:46:29 -0000 1.5 *************** *** 791,795 **** "sys\0", //Function Processor Name false, //Window required ! 14, //Count of verbs "osversion\0", /*sys*/ "systemtask\0", --- 791,795 ---- "sys\0", //Function Processor Name false, //Window required ! 16, //Count of verbs "osversion\0", /*sys*/ "systemtask\0", *************** *** 806,810 **** "getenvironmentvariable\0", "setenvironmentvariable\0", ! "unixshellcommand\0" END --- 806,811 ---- "getenvironmentvariable\0", "setenvironmentvariable\0", ! "unixshellcommand\0", ! "winshellcommand\0" /* 2006-03-09 aradke */ END |
|
From: creecode <icr...@us...> - 2006-03-08 02:02:23
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/extensions/latintomac In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26982 Added Files: mactolatin convert Log Message: these verbs are depreciated but kept for compatibility --- NEW FILE: convert --- (This appears to be a binary file; contents omitted.) --- NEW FILE: mactolatin --- (This appears to be a binary file; contents omitted.) |
|
From: creecode <icr...@us...> - 2006-03-07 05:46:20
|
Update of /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder/search/utilities In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10061 Modified Files: cleanText Log Message: replace calls to verbs at extensions.latinToMac with string.(latin/mac)To(Latin/Mac) verbs Index: cleanText =================================================================== RCS file: /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder/search/utilities/cleanText,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** cleanText 26 Mar 2005 21:46:13 -0000 1.1.1.1 --- cleanText 7 Mar 2006 05:46:16 -0000 1.2 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:mainResponder.search.utilities.cleanText ! on cleanText (s) { ÇPrepare text to be indexed. ÇReplace whitespace characters and punctuation with spaces. Ç(Don't replace #, <, >, {, and } characters.) ÇThen strip HTML tags and macros. ÇChanges Ç8/2/02; 5:18:49 PM by JES ÇUse string.multipleReplaceAll, if available. if defined (string.multipleReplaceAll) { local (replchars = "\r\n\t.-\\/:?!;@$%^&*)([]"); local (t); new (tableType, @t); local (i, ch, ct=sizeOf (replchars)); for i = 1 to ct { t.[replchars[i]] = " "}; s = string.multipleReplaceAll (s, @t)} else { //replace characters one at a time -- original behavior s = string.replaceAll (s, "\r", " "); s = string.replaceAll (s, "\n", " "); s = string.replaceAll (s, "\t", " "); s = string.replaceAll (s, ".", " "); s = string.replaceAll (s, "-", " "); s = string.replaceAll (s, "\\", " "); s = string.replaceAll (s, "/", " "); s = string.replaceAll (s, ":", " "); s = string.replaceAll (s, "?", " "); s = string.replaceAll (s, "!", " "); s = string.replaceAll (s, ";", " "); s = string.replaceAll (s, "@", " "); s = string.replaceAll (s, "$", " "); s = string.replaceAll (s, "%", " "); s = string.replaceAll (s, "^", " "); s = string.replaceAll (s, "&", " "); s = string.replaceAll (s, "*", " "); s = string.replaceAll (s, ")", " "); s = string.replaceAll (s, "(", " "); s = string.replaceAll (s, "[", " "); s = string.replaceAll (s, "]", " ")}; s = searchEngine.stripMarkup (s); //strip HTML tags and macros if system.environment.isMac { s = latinToMac.convert (s)}; //convert Latin to Mac characters return (s)}; Çbundle //test code ÇmainResponder.search.utilities.cleanText ("foo-bar's bim!") Ç"foo bar's bim " \ No newline at end of file --- 1,54 ---- ! FrontierVcsFile:2:scpt:mainResponder.search.utilities.cleanText ! on cleanText (s) { ! «Changes ! «2/28/06; 11:54:00 AM by TAC ! «replace extensions.latinToMac.convert with string.latinToMac ! «8/2/02; 5:18:49 PM by JES ! «Use string.multipleReplaceAll, if available. ! «Prepare text to be indexed. ! «Replace whitespace characters and punctuation with spaces. ! «(Don't replace #, <, >, {, and } characters.) ! «Then strip HTML tags and macros. ! ! if defined (string.multipleReplaceAll) { ! local (replchars = "\r\n\t.-\\/:?!;@$%^&*)([]"); ! local (t); new (tableType, @t); ! local (i, ch, ct = sizeOf (replchars)); ! ! for i = 1 to ct { ! t.[replchars [i]] = " "}; ! s = string.multipleReplaceAll (s, @t)} ! else { //replace characters one at a time -- original behavior ! s = string.replaceAll (s, "\r", " "); ! s = string.replaceAll (s, "\n", " "); ! s = string.replaceAll (s, "\t", " "); ! s = string.replaceAll (s, ".", " "); ! s = string.replaceAll (s, "-", " "); ! s = string.replaceAll (s, "\\", " "); ! s = string.replaceAll (s, "/", " "); ! s = string.replaceAll (s, ":", " "); ! s = string.replaceAll (s, "?", " "); ! s = string.replaceAll (s, "!", " "); ! s = string.replaceAll (s, ";", " "); ! s = string.replaceAll (s, "@", " "); ! s = string.replaceAll (s, "$", " "); ! s = string.replaceAll (s, "%", " "); ! s = string.replaceAll (s, "^", " "); ! s = string.replaceAll (s, "&", " "); ! s = string.replaceAll (s, "*", " "); ! s = string.replaceAll (s, ")", " "); ! s = string.replaceAll (s, "(", " "); ! s = string.replaceAll (s, "[", " "); ! s = string.replaceAll (s, "]", " ")}; ! ! s = searchEngine.stripMarkup (s); //strip HTML tags and macros ! ! if system.environment.isMac { ! s = string.latinToMac (s)}; //convert Latin to Mac characters ! ! return (s)}; ! ! «bundle // testing ! «mainResponder.search.utilities.cleanText ("foo-bar's bim!") ! «"foo bar's bim " \ No newline at end of file |
|
From: creecode <icr...@us...> - 2006-03-07 05:46:07
|
Update of /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9760 Modified Files: parseMultipart respond Log Message: replace calls to verbs at extensions.latinToMac with string.(latin/mac)To(Latin/Mac) verbs Index: respond =================================================================== RCS file: /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder/respond,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** respond 18 Oct 2005 16:22:09 -0000 1.2 --- respond 7 Mar 2006 05:46:03 -0000 1.3 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:mainResponder.respond ! on respond (adrparamtable, fldebug=false) { ÇStarted 9/26/98; 10:54:02 AM by DW ÇA clean fresh start for the user.webserver.responders table. ÇBuild a fast kernelizable responder that supports a very high level concept of a website. ÇChanges: Ç10/23/04; 1:17:48 AM by JES ÇRespect config.mainResponder.prefs.flMapFirstLevelOfUrlsToManilaSites. If false, then do not map the first level of the path in incoming requests to Manila sites. Default is to preserve existing behavior in existing installs, and to not map to Manila sites in new installs. (See mainResponder.init and mainResponder.install.) Ç9/16/04; 2:11:44 AM by JES ÇFix a bug in latin-to-mac translation when parsing POST args where more than one argument has the same name. ÇSingle arguments were handled fine, but subsequent same-name ones weren't. ÇFix bug where high-ascii characters in the path were not handled properly on MacOS. ÇFix a bug in If-Modified-Since handling, which prevented it from working properly unless mainResponder debugging was turned on. Ç11/5/02; 2:47:14 PM by JES ÇHandle HEAD requests according to the HTTP 1.1 specification. Saves bandwidth when responding to clients which support the HEAD method. Çhttp://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4 Ç9/16/02; 2:43:53 AM by JES ÇFix a bug which causes sites on the last leaf of an XML siteTree to return an error, by de-referencing the address attribute of the site in the tableDive sub-function of the responder. ÇPreviously, the address of an XML table would be returned, and this table was not a valid website. Nobody was following the address on the last leaf of the siteTree. ÇNow we dereference the address attribute, and return the address for the value of "nomad". This is normally a valid website, as long as the siteTree is valid, and the site still exists. Ç9/10/02; 5:01:56 PM by JES ÇCall userland.trialVersionCheck to find out if the trial has expired, instead of checking userland.trialVersion.flTrialVersion and userland.trialVersion.flExpired directly. Ç7/2/02; 1:43:28 AM by JES ÇNew XML siteTree type, redirect. Implements the same functionality as redirect strings for old-style config.mainResponder.domains records. Ç1/7/02; 12:38:55 PM by PBS ÇDon't serve any objects whose name begins with . (dot). This prevents the server from, for example, serving .DS_Store files on Mac OS X. Ç10/1/01; 3:34:37 PM by PBS ÇManila sites with names like 123test couldn't be found because 123test, when it's an address, needs to be in quotes and bracketted. Fixed. Ç01/03/01; 2:44:11 AM by JES ÇFixed a text conversion problem: On Macintosh, convert both searchArgs and pathArgs to Mac text, even if no postArgs are specified. Ç2000: Ç05/11/00; 5:19:40 PM by PBS ÇIf the manilaMacros table in manila.root is defined, add that to the search path for macro evaluation. Ç06/10/00; 5:05:24 PM by PBS ÇSupport for XML siteTree feature, which allows one to specify a hierarchy of sites in XML. siteTrees are legal in config.mainResponder.domains and config.mainResponder.sites. Ç06/14/00; 4:31:26 PM by PBS ÇAdded /mainResponderResources/ as a system website, so the Pike button and other icons have a constant path despite the settings at config.mainResponder.domains. Ç06/27/00; 12:56:31 PM by JES ÇBug fix -- make sure an XML siteTree outline exists if the structure exists. Ç07/05/00; 12:47:57 PM by PBS ÇIf an entry in config.mainResponder.domains is a string containing a URL to redirect to, and the request contains path args, make sure the path args are added to the URL that the browser is redirected to. Ç07/06/00; 5:48:03 PM by PBS ÇIf the domain is set up as an XML siteTree domain, but the site we're looking for isn't in the XML outline, check the config.manila.sites and config.mainResponder.sites tables. This makes it work the same way as when your default domain points to Guest Databases/www/ -- which is how people expect this to work. This should cut way down, or eliminate entirely, the reports about not being able to figure out how to make one's sites accessible. Ç07/22/00 at 4:06:35 AM by AR ÇRe-enabled the controlAccess callback loop. Ç08/09/00; 12:43:44 PM by PBS ÇClosed security hole. Certain combinations of characters could, in some circumstances, allow one to get outside the static files folder. Ç08/31/00; 8:01:51 PM by PBS ÇFixed a bug in serving tables -- the last line of the serveTable handler now references adrTable. See Matt Neuburg's diagnosis: http://frontier.userland.com/discuss/msgReader$5439 Ç10/27/00; 11:32:10 AM by PBS ÇChanged profiling prefix from /profile to /profile/. Ç10/31/00; 5:16:54 PM by JES ÇFixed bug where redirecting using the scriptError ("!redirect [url]") method wouldn't redirect to URLs longer than 254 characters. To use the fix properly, first call mainResponder.redirect to set the redirect URL in adrParamTable^.responderAttributes, and then call scriptError with the same URL to short-circuit rendering and force redirection. Ç11/08/00; 3:02:42 PM by PBS ÇFixed a problem when serving from the file system on Windows. (When serving Gems, for example.) Folder paths would have doubled backslash characters in the path, which had to be collapsed when turning a path to a filespec. Ç1999: Ç7/29/99 by DW ÇIf you have a #redirect directive in a website, when the responder dives into the table it will remap the url thru the string value of #redirect. It's smart, so it will keep the partial URL intact. Ç7/30/99; 10:51:13 by PBS ÇIf a table is being rendered as a page via the #renderTableWith mechanism, don't add a trailing slash. If a trailing slash is present, redirect to remove the trailing slash. New subroutine: pathMustNotEndWithSlash, it's the opposite of pathMustEndWithSlash. ÇIf the host ends with the port, as in nirvana.userland.com:81, find nirvana.userland.com in the config.mainResponder.domains table if nirvana.userland.com:81 is not present in that table. Also handle cases where a trailing period is present, such as nirvana.userland.com. or nirvana.userland.com.:81. ÇIf an object isn't found in a website, the website can over-ride mainResponder.respond's built-in behavior, which is to scriptError with a message about the object not being found. A website can have a page -- script, wpText, whatever -- called #objectNotFoundHandler. This is what gets called if the object isn't found. It's rendered or called with regard to the standard rules -- allowScriptsToRun, flRender, etc. are all obeyed, so there are no suprises. This adds a potentially powerful feature: a script can be defined which implements a virtual hierarchy -- in other words, you could write a script which dives into an outline: you could create an entire website, or part of a site, from a single outline. There are many possibilities. Ç8/1/99; 1:13:33 by PBS ÇError pages are now iso8859-encoded. This is because some Frontier error messages may contain characters which should be translated to HTML entities. ÇMacintosh file uploading fixed -- post args are not converted from Latin to Mac text for attached files -- only "regular" post args are converted. Ç8/11/99; 2:56:17 PM by PBS ÇFolded in Dave's fixes for #redirect feature. Check to be sure objectName and path are defined. ÇFix for custom scripts for tableToHTML and FolderToHTML -- the scripts should be found now. Previously an error was generated. Previous error: "Can't call folderToHTML because it isn't a script." De-referencing solves this problem. Ç8/25/99; 12:09:37 PM by PBS ÇCall html.deletePageTableAddress at the end -- there is no need to keep the dangling pta in the system.temp.pageTableAddresses table. In fact, not deleting it can lead to crashes in certain circumstances. ÇAdded pathEvaluation callback. Scripts in the config.mainResponder.callbacks.pathEvaluation table can over-ride mainResponder's normal path evaluation. ÇThe param table is in scope for these callbacks. There are two special items: ÇdomainPath -- this is the path for this domain, as specified in config.mainResponder.domains. It may be any value that's legal in config.mainResponder.domains. ÇadrObjectToServe -- this is nil. If a callback places a value here, then that's the object that will be served. The value can be any type that mainResponder.respond knows how to handle. ÇNote: attributes will be gathered at the level of adrObjectToServe^. If you want to gather more attributes, you'll have to do it in your callback or in a filter. This is because mainResponder's normal attribute-gathering routine is circumvented when a callback handles path evaluation. ÇAlso note: if there is a scriptError in any of these callbacks, that scriptError will be reflected in the page. These callbacks must be coded carefully. This is an advanced feature, and one is responsible for one's own code. ÇThis was originally requested by Seth Dillingham on the Frontier-Server list. ÇAdded serveFromCache callback. ÇWhen mainResponder wants to serve an object from the cache, the scripts in config.mainResponder.callbacks.serveFromCache are called. ÇThe param table is in scope. It contains a special boolean, flServeFromCache, set to true. ÇIf any callback sets this to false, then mainResponder.respond will build the object rather than use the cache. ÇThis was originally requested by Matt Daw on the Frontier-Server list. ÇMacintosh file uploading, which was thought to be fixed earlier, is now fixed completely. The final problem was a hard-to-see typo: Çif typeOf (adrPostTable^ [i] == stringType) Ç...should have read... Çif typeOf (adrPostTable^ [i]) == stringType ÇYou can now turn on Mac text conversion at config.mainResponder.prefs.flConvertToMacText and have files that are uploaded remain unconverted. Ç9/25/99; 5:44:51 PM by PBS ÇA serveFromCacheCallback can get the address of the requested object that's been cached. It's at adrParamTable^.adrCachedObject. This callback can also get the address of the cached version, in cache.root. It's at adrParamTable^.adrCacheItem. Ç10/25/99; 3:53:16 PM by PBS ÇFixed two minor bugs in supporting the controlPanel system website. Changed the scope of flsystemwebsite and check the existence of config.mainResponder.prefs.flControlPanel before checking its value. Ç11/9/99; 8:37:55 PM by PBS ÇShort URLs for Manila sites. If the domain points to the www folder, and the first part of the path is a name in config.manila.sites, then short-circuit the walk -- set nomad to point to the Manila site. This way, instead of URLs like http://myserver.com/mySite/mySite/, you can have URLs like http://myserver.com/mySite/, even though the website is at [mySite.root].mySite, even though the domain points to the www folder. This change is compatible with 6.0: if you don't have a config.manila.sites table, then nothing special happens. Ç12/16/99; 2:50:24 PM by PBS ÇShort URLs for mainResponder sites: if a table at config.mainResponder.sites exists, and the first part of the path matches a name in that table, and the domain points to the www folder, then follow the address in config.mainResponder.sites. This works similarly to config.manila.sites. However, items in config.mainResponder.sites can also be tables or filespecs. Ç12/16/99; 3:36:36 PM by PBS ÇFix a #redirect bug. When requesting /x, the redirected URL might be /x/x -- part of the path was being doubled. on core () { mainResponder.callbackLoop (@config.mainresponder.callbacks.controlAccess, adrparamtable); local (flCallbackParsedPath = false); //PBS 8/25/99: a callback may evaluate the path, then this gets set to true local (flprofile = false); //if true, we return the text of the profile, not the page if config.mainresponder.prefs.flProfiling { local (prefix = "/profile/"); //PBS 10/27/00: prefix changed from /profile to /profile/ -- to avoid conflict with Manila's profiles and any other URL that begins with /profile Çmsg (adrparamtable^.path) if adrparamtable^.path beginswith prefix { adrparamtable^.path = string.delete (adrparamtable^.path, 1, sizeof (prefix)); adrparamtable^.path = "/" + adrparamtable^.path; script.startProfile (true); flprofile = true}}; local (adrdebuglog = nil); //it stays nil if debugging isn't on on addDebugLog (name, val) { xml.addvalue (adrdebuglog, name, val)}; local (fldebug = config.mainresponder.prefs.flDebug); if fldebug { if adrparamtable^.requestHeaders.["User-Agent"] == "Testing in Debugger" { fldebug = false} else { if not defined (config.mainresponder.debugLog) { new (tabletype, @config.mainresponder.debugLog)}; adrdebuglog = xml.addtable (@config.mainresponder.debugLog, string.timestring ()); addDebugLog ("paramsIn", adrparamtable^); addDebugLog ("path", adrparamtable^.path); addDebugLog ("client", tcp.dns.getDomainName (adrparamtable^.client))}}; adrparamtable^.responseHeaders.["Content-Type"] = "text/html"; //the most common value bundle { //for debugging, save a copy of the param table in a global if config.mainresponder.prefs.flKeepParamTable { try { //might not have a User-Agent field if adrparamtable^.requestHeaders.["User-Agent"] != "Testing in Debugger" { scratchpad.paramtable = adrparamtable^}}}}; local (adratts = @adrparamtable^.responderAttributes); adratts^ = config.mainresponder.globals; on noFolderError (f) { scriptError ("There is no folder or object database named \"" + (file.filefrompath (f) - file.getpathchar ()) + "\" in the folder \"" + file.folderfrompath (f) + "\".")}; on gatherAttributes (adrtable) { //copy all #attributes from the table into adratts^ Çthis does something different from html.buildPageTable Çit adds them one level at a time, we don't care how we got here Çin html.buildPageTable we pop all the way out to the top of the website. Çthat would be incorrect for the web server local (adrsecurityscript = @adrtable^.["#security"]); if defined (adrsecurityscript^) { //great! the sysop is using a cool feature callScript (adrsecurityscript, {}, adrparamtable)}; //scriptError to kill request local (i, ct = sizeof (adrtable^), adritem, name); for i = 1 to ct { adritem = @adrtable^ [i]; name = nameof (adritem^); if not (name beginswith "#") { break}; name = string.delete (name, 1, 1); //pop off the # case string.lower (name) { "redirect" { ÇDW 7/29/99: If you have a #redirect directive in a website, when the responder dives into the table it will remap the url thru the string value of #redirect. It's smart, so it will keep the partial URL intact. local (url = string (adritem^)); Çif defined (objectName) //PBS 12/16/99: commented out to fix a bug where URLs would have repeated elements, such as /foo/foo rather than /foo. (Was: make sure objectName is defined.) Çurl = url + objectName if defined (path) { //make sure path is defined if sizeof (path) > 0 { if not (url endswith "/") { url = url + "/"}; url = url + path}}; Çdialog.alert (url) scriptError ("!redirect " + url)}}; case typeof (adritem^) { tabletype { if string.lower (name) == "prefs" { local (i, ct = sizeof (adritem^), adrprefsitem, name); for i = 1 to ct { adrprefsitem = @adritem^ [i]; name = nameof (adrprefsitem^); if name beginswith "#" { name = string.delete (name, 1, 1)}; adratts^.[name] = adrprefsitem^}} else { //copy the address of the table try {delete (@adrAtts^.[name])}; //work around an apparent kernel bug adratts^.[name] = adritem}}; outlinetype; scripttype; menubartype; binarytype; wptexttype { adratts^.[name] = adritem}} //copy the address else { adratts^.[name] = adritem^}}}; on attMustBeTrue (attname) { on attError () { scriptError ("The attribute \"" + attname + "\" must be true.")}; local (adratt = @adratts^.[attname]); if defined (adratt^) { if not adratt^ { //it's false attError ()}} else { attError ()}; return (true)}; on attIsTrue (attname) { local (adratt = @adratts^.[attname]); if defined (adratt^) { return (boolean (adratt^))} else { return (false)}}; on serveAsXml (folder) { if not file.isFolder (folder) { scriptError ("Can't serve \"" + folder + "\" as XML because it isn't a folder.")}; local (xmltext = "", indentlevel = 0, f, pc = file.getpathchar ()); on add (s) { xmltext = xmltext + string.filledString ("\t", indentlevel) + s + "\r"}; add ("<?xml version=\"1.0\"?>"); add ("<directory>"); indentlevel++; fileloop (f in folder) { local (name = file.filefrompath (f)); if name endswith pc { name = string.delete (name, sizeof (name), 1)}; add ("<file>"); indentlevel++; add ("<name>" + name + "</name>"); bundle { //add type local (mimetype); if file.isfolder (f) { mimeType = "folder"} else { if name endswith ".root" { mimetype = "application/x-frontier-database"} else { local (objectType = file.type (f)); case sys.os () { // decide what the MIME type is "Win95"; "WinNT" { local (extension = objectType); extension = string.replaceAll (extension, " ", ""); // strip spaces if defined (user.webserver.prefs.ext2MIME.[extension]) { mimeType= user.webserver.prefs.ext2MIME.[extension]} else { mimeType = "text/plain"}}; "MacOS" { if defined (user.webserver.prefs.type2MIME.[objectType]) { mimeType = user.webserver.prefs.type2MIME.[objectType]} else { mimeType = "text/plain"}}}}}; add ("<type>" + mimeType + "</type>")}; add ("<creationDate>" + date.netStandardString (file.created (f)) + "</creationDate>"); add ("<modificationDate>" + date.netStandardString (file.modified (f)) + "</modificationDate>"); add ("<size>" + file.size (f) + "</size>"); add ("</file>"); indentlevel--}; add ("</directory>"); indentlevel--; adrparamtable^.responseHeaders.["Content-Type"] = "text/xml"; adrparamtable^.responseBody = xmltext}; on serveFile (f) { adrparamtable^.responseBody = string (file.readwholefile (f)); adrparamtable^.responseHeaders.["Content-Type"] = mainResponder.getFileMimeType (f); adrparamtable^.responseHeaders.["Last-Modified"] = date.netStandardString (file.modified (f))}; on serveScript (adrscript) { adrparamtable^.responseBody = string (callScript (adrscript, {}, adrparamtable))}; on serveObject (adr) { bundle { //set up the URLs table if not defined (adratts^.urls) { //there's no #urls server attribute adratts^.urls = @config.mainresponder.urls}}; mainResponder.members.checkMembership (adr, adrparamtable); //scriptErrors if redirecting if (adratts^.flrender) and (typeof (adr^) != binaryType) { //pass it thru the website framework local (adrcacheitem = nil); if defined (adratts^.flRenderingCache) and (adratts^.flRenderingCache) { //this page can be cached local (adrcache = mainResponder.cache.getCacheTable ()); adrcacheitem = @adrcache^.[string (adr)]; if defined (adrcacheitem^) { if timeModified (adrcacheitem) >= timeModified (adr) { //the cache is still good if typeof (adr^) != scripttype { ÇPBS 8/25/99: call a callback that can decide whether or not to serve this from the cache. adrParamTable^.flServeFromCache = true; if defined (config.mainResponder.callbacks.serveFromCache) { adrParamTable^.adrCachedObject = adr; //PBS 9/25/99: allow callback to get the address of the object being requested adrParamTable^.adrCacheItem = adrCacheItem; //PBS 9/25/99: allow callback to get the address of the cached version, in cache.root mainResponder.callbackLoop (@config.mainResponder.callbacks.serveFromCache, adrParamTable)}; if adrParamTable^.flServeFromCache == true { adrparamtable^.responseBody = string (adrcacheitem^.text); adrcacheitem^.hits++; return}}}}}; if defined (manilaMacros) { //PBS 05/11/00: if defined, add manilaMacros to macro evaluation path with manilaMacros { adrparamtable^.responseBody = html.buildObject (adr, adrparamtable)}} else { adrparamtable^.responseBody = html.buildObject (adr, adrparamtable)}; if adrcacheitem != nil { //caching is enabled if not defined (adrcacheitem^) { new (tabletype, adrcacheitem)}; adrcacheitem^.hits = 0; wp.newtextobject (adrparamtable^.responseBody, @adrcacheitem^.text); fileMenu.saveMyRoot (adrcacheitem)}; local (adrredirecturl = @adrparamtable^.responderAttributes.redirectUrl); if defined (adrredirecturl^) { scriptError ("!redirect " + adrredirecturl^)}} else { case typeof (adr^) { scripttype { serveScript (adr)}} else { if defined (adratts^.rawTextPreformatted) and (adratts^.rawTextPreformatted) { local (s = string.replaceall (string (adr^), "<", "<")); adrparamtable^.responseBody = "<html><body><pre>\r" + s + "\r</pre></body></html>"} else { adrparamtable^.responseBody = string (adr^)}; adrparamtable^.responseHeaders.["Content-Type"] = mainResponder.getODBMimeType (adr); local (moddate = timeModified (adr)); if typeof (moddate) == booleantype { moddate = clock.now (); try { //JES 9/16/04: use mod date of parent table if typeOf (parentOf (adr^)^) == tabletype { moddate = timeModified (parentOf (adr^))}}}; adrparamtable^.responseHeaders.["Last-Modified"] = date.netStandardString (moddate)}}}; on folderToHTML (folder) { attMustBeTrue ("allowDirectoryListings"); bundle { //set up the URLs table; Fri, 12 Mar 1999 00:50:44 GMT by AR if not defined (adratts^.urls) { //there's no #urls server attribute adratts^.urls = @config.mainresponder.urls}}; local (adrscript = @mainResponder.folderToHTML); if defined (adratts^.folderToHTML) { adrscript = @adratts^.folderToHTML; if typeOf (adrScript^) == addressType { //PBS 8/11/99: if adrScript^ is an address, de-reference adrScript = adrScript^}}; return (adrscript^ (folder, adrparamtable))}; on tableToHTML (adrtable) { gatherAttributes (adrtable); attMustBeTrue ("allowDirectoryListings"); bundle { //set up the URLs table; Fri, 12 Mar 1999 00:50:40 GMT by AR if not defined (adratts^.urls) { //there's no #urls server attribute adratts^.urls = @config.mainresponder.urls}}; local (adrscript = @mainResponder.tableToHTML); if defined (adratts^.tableToHTML) { adrscript = @adratts^.tableToHTML; if typeOf (adrScript^) == addressType { //PBS 8/11/99: if adrScript^ is an address, de-reference adrScript = adrScript^}}; return (adrscript^ (adrtable, adrparamtable))}; on openRootFile (f) { if not window.isOpen (f) { if file.filefrompath (f) beginswith "#" { scriptError ("Can't open the file \"" + f + "\" because its name begins with a pound-sign.")}; fileMenu.open (f, hidden:true); if config.mainResponder.prefs.flLogDatabaseOpens { Çyou may want to add this file to user.databases local (adrtable = @system.temp.mainResponder.databaseOpensLog); if not defined (adrtable^) { new (tabletype, adrtable)}; adrtable^.[f] = clock.now ()}}}; on checkPoundsign (name) { //scriptErrors if the name begins with a # if name beginswith "#" { scriptError ("Can't serve \"" + name + "\" because its name begins with a pound-sign.")}}; on tableDive (nomad, name) { bundle { //handle siteTree XML structures in config.root if inSiteTreeXmlTable (nomad) { local (name = string.lower (name)); local (adrItem); for adrItem in nomad { local (itemName = string.lower (xml.convertToDisplayName (nameOf (adrItem^)))); if itemName == "site" { local (siteName = string.lower (adrItem^.["/atts"].name)); Çif siteName == name Çif defined (adrItem^.["/atts"].address) //JES 9/16/02: dereference the last address in the siteTree Çreturn (address (adrItem^.["/atts"].address)) Çreturn (dereferenceXmlTable (adrItem)) Çreturn (adrItem) if siteName == name { // 03/03/03 JTC installed workaround by Tom Clifton local (xmlAddress); try { xmlAddress = xml.getAddress (adrItem, "site")} else { if defined (adrItem^.["/atts"].address) { //JES 9/16/02: dereference the last address in the siteTree Çreturn (address (adrItem^.["/atts"].address)) return (dereferenceXmlTable (adrItem))}}; return (adrItem)}}}; ÇCheck config.manila.sites and config.mainResponder.sites. PBS 07/06/00. if defined (stack) and sizeOf (stack) == 0 { local (flMapFirstLevelOfUrlsToManilaSites = true); if defined (config.mainResponder.prefs.flMapFirstLevelOfUrlsToManilaSites) { flMapFirstLevelOfUrlsToManilaSites = config.mainResponder.prefs.flMapFirstLevelOfUrlsToManilaSites}; if flMapFirstLevelOfUrlsToManilaSites and defined (config.manila.sites.[objectName]) { // 10/22/04; 4:27:33 PM by EDS added pref return (config.manila.sites.[objectName])} else { if defined (config.mainResponder.sites) { if defined (config.mainResponder.sites.[objectName]) { nomad = @config.mainResponder.sites.[objectName]; if defined (config.mainResponder.sites.[objectName].siteTree.directory) { return (initialXmlSiteTreeDive (nomad))}; return(nomad)}}}}; // 10/22/04; 4:01:55 PM by EDS need to return the nomad even if it's not a site tree. ÇDe-reference current nomad, site not found. nomad = dereferenceXmlTable (nomad); if typeOf (nomad) == fileSpecType { return (folderDive (nomad, name))}}}; gatherAttributes (nomad); //get the attributes before we dive checkPoundsign (name); //scriptErrors if the name begins with a # if not defined (nomad^.[name]) { if (string.lower (name) == "images") and (defined (nomad^.["#images"])) { name = "#images"} else { if table.tableContains (@config.mainResponder, nomad) and defined (nomad^.siteTree.directory) { //PBS 06/10/00: support for XML siteTree in config.mainResponder.sites return (initialXmlSiteTreeDive (nomad))} else { if defined (adrAtts^.objectNotFoundHandler) { //PBS 7/30/99: a website can define an object -- page, script, whatever -- to handle object not found conditions. It will be called via the standard rules, based on the website's preferences (allowScriptsToRun, etc.) return (adrAtts^.objectNotFoundHandler)} else { scriptError ("Can't process the request because there is no object named \"" + name + "\".")}}}}; return (@nomad^.[name])}; on folderDive (f, name) { local (pc = file.getpathchar ()); if not file.exists (f) { //allow URLs to reference odbs without including ".root" local (name = file.filefrompath (f) - pc); //for error message f = f + ".root"; if not file.exists (f) { noFolderError (f)}}; if file.isfolder (f) { if not (f endswith pc) { f = f + pc}; return (filespec (f + name))} else { //it might be a guest database if not (string.lower (f) endsWith ".root") { scriptError ("Can't dive into \"" + f + "\" because its name doesn't end with \".root\".")}; openRootFile (f); return (tableDive (@[f], name))}}; on pathMustEndWithSlash () { local (s = string.trimWhiteSpace (adrparamtable^.path)); if not (s endswith "/") { scriptError ("!redirect " + s + "/")}}; on pathMustNotEndWithSlash () { //PBS 7/30/99: tables rendered as pages must not end with a slash local (s = string.trimWhiteSpace (adrparamtable^.path)); if s endsWith "/" { s = string.delete (s, sizeOf (s), 1); scriptError ("!redirect " + s)}}; on serveTable (adrtable) { bundle { //PBS 06/09/00: de-reference XML siteTree table adrTable = dereferenceXmlTable (adrTable); if typeOf (adrTable) == fileSpecType { return (serveFolder (adrTable))}}; //it's really a filespec local (defaults = list (adratts^.defaultDirectoryItems), item, adritem, flnotfound = true); if defined (adrTable^.["#defaultDirectoryItems"]) { //Fri, 12 Mar 1999 01:24:15 GMT by AR defaults = list (adrTable^.["#defaultDirectoryItems"])}; if defined (adrTable^.["#prefs"].defaultDirectoryItems) { defaults = list (adrTable^.["#prefs"].defaultDirectoryItems)}; for item in defaults { adritem = @adrtable^.[item]; if defined (adritem^) { gatherattributes (adrtable); pathMustEndWithSlash (); //possibly redirect serveObject (adritem); flnotfound = false; break}}; if flnotfound { if defined (adratts^.renderTableWith) { pathMustNotEndWithSlash (); //PBS 7/30/99: this table is a page: it must not end in a slash serveObject (adrtable)} else { pathMustEndWithSlash (); //possibly redirect adrparamtable^.responseBody = tableToHTML (adrTable)}}}; //PBS 08/31/00: adrTable, not nomad, is correct here on serveFolder (folder) { pathMustEndWithSlash (); //possibly redirect local (pc = file.getpathchar ()); if not (folder endswith pc) { folder = folder + pc}; local (defaults = list (adratts^.defaultDirectoryItems), item, f, flnotfound = true); for item in defaults { f = folder + item; if file.exists (f) { serveFile (f); flnotfound = false; break}}; if flnotfound { Çadrparamtable^.responseBody = folderToHTML (nomad) adrparamtable^.responseBody = folderToHTML (folder)}}; on compileXmlIfNeeded (adrTable) { //PBS 06/09/00: compile an XML siteTree structure if needed if defined (adrTable^.structure) { if timeModified (@adrTable^.outline) <= timeModified (@adrTable^.structure) { return (true)}}; //no need to compile xml.compile (string (adrTable^.outline), @adrTable^.structure); //compile needed return (true)}; on inSiteTreeXmlTable (adrTable) { //PBS 06/09/00: is adrTable in an XML siteTree structure? if nameOf (adrTable^) contains "\t" { if table.tableContains (@config, adrTable) { return (true)}}; return (false)}; on dereferenceXmlTable (adrTable) { //PBS 06/09/00: get an address or filespec from an XML siteTree entry if inSiteTreeXmlTable (adrTable) { if defined (adrTable^.["/atts"].address) { try { return (address (adrTable^.["/atts"].address))} else { //PBS 10/01/01: the address might be a name like 123test, which needs to be in quotes return (address ("[\"" + adrTable^.["/atts"].address + "\"]"))}} else { if defined (adrTable^.["/atts"].folderPath) { Çreturn (fileSpec (string (fileSpec (adrTable^.["/atts"].folderPath)))) local (path = adrTable^.["/atts"].folderPath); if system.environment.isWindows { //PBS 11/08/00: fix problem with folder paths in the siteTree XML on Windows path = string.replaceAll (path, "\\\\", "\\")}; return (fileSpec (path))} else { if defined (adrTable^.["/atts"].redirect) { scriptError ("!redirect " + adrTable^.["/atts"].redirect)}}}}; return (adrTable)}; on gatherGlobals (adrGlobals) { //PBS 06/09/00: broken out into a subroutine for siteTree support local (i, ct = sizeOf (adrGlobals^), adritem); for i = 1 to ct { adritem = @adrGlobals^ [i]; adratts^.[nameof (adritem^)] = adritem^}; return (true)}; on initialXmlSiteTreeDive (adrTable) { //PBS 06/10/00: XML siteTree support, broken out because used in two places -- this routine dives into the XML structure, first re-compiling if necessary if defined (adrTable^.siteTree.globals) { gatherGlobals (@adrTable^.siteTree.globals)}; if not defined (adrTable^.siteTree.directory) { scriptError ("Server configuration error. siteTree table must contain an element named directory.")}; if not defined (adrTable^.siteTree.directory.outline) { if defined (adrTable^.siteTree.directory.structure) { // 06/27/00 JES: make sure an outline exists if an XML structure does local (xmlText, xmlWpText); xmlText = xml.decompile (@adrTable^.siteTree.directory.structure); local (xmlHeader = string.nthField (xmlText, '\r', 1)); xmlText = string.delete (xmlText, 1, sizeOf (xmlHeader)); xmlText = string.trimWhiteSpace (xmlText); wp.newTextObject (xmlText, @xmlWpText); table.assign (@adrTable^.siteTree.directory.outline, xmlWpText)} else { scriptError ("Server configuration error. A siteTree's directory table must contain an element named outline.")}}; compileXmlIfNeeded (@adrTable^.siteTree.directory); if not defined (adrTable^.siteTree.directory.structure [1]) { scriptError ("Server configuration error. A siteTree's XML structure must not be empty.")}; return (@adrTable^.siteTree.directory.structure [1] [1])}; //return a new value for nomad case string.upper (adrparamtable^.method) { //initialization based on method "POST" { if string.lower (adrparamtable^.requestHeaders.["Content-type"]) beginsWith "multipart/form-data" { mainResponder.parseMultipart (adrparamtable)} //parse multipart form into adrparamtable^.postArgs else { local (adrtable = @adrparamtable^.postArgs); new (tabletype, adrtable); webserver.parseArgs (adrparamtable^.requestBody, adrtable)}}}; local (nomad); bundle { //JES 4/8/02: handle expired trials -- load the serial number page or error if defined (userland.trialVersionCheck) { if userland.trialVersionCheck (false) { local (domain = adrparamtable^.host, lowerpath = string.lower (adrparamtable^.path)); if domain contains ":" { domain = string.nthField (domain, ":", 1)}; local (flRedirectToSerialNumberPage = false); bundle { //if serving to a the same machine, or viewing a control panel page, redirect to the serial number page if tcp.equalNames (domain, "127.0.0.1") { flRedirectToSerialNumberPage = true}; if (lowerpath beginsWith "/controlpanel/") { flRedirectToSerialNumberPage = true}; if (lowerpath == "/controlpanel/serialnumber") { flRedirectToSerialNumberPage = false}; if (lowerpath beginsWith "/mainresponderresources/") { flRedirectToSerialNumberPage = false}; if defined (mainResponder.adminSite.urls.serialNumber) { if lowerpath beginsWith string.lower (mainResponder.adminSite.urls.serialNumber) { flRedirectToSerialNumberPage = false}}}; if flRedirectToSerialNumberPage { if defined (mainResponder.adminSite.urls.serialNumber) { scriptError ("!redirect http://" + adrparamtable^.host + mainResponder.adminSite.urls.serialNumber)} else { scriptError ("!redirect http://" + adrparamtable^.host + "/controlPanel/serialNumber")}} else { local (flerror = true); if lowerpath == "/controlpanel/serialnumber" { flerror = false}; if lowerpath beginsWith "/mainresponderresources/" { flerror = false}; if defined (mainResponder.adminSite.urls.serialNumber) { if lowerpath == string.lower (mainResponder.adminSite.urls.serialNumber) { flerror = false}}; if flerror { scriptError ("Can't respond to the request because this trial installation of Frontier has expired.")}}}}}; bundle { //convert text from latin to Mac character sets, if this is a Mac ÇSat, Mar 20, 1999 at 4:54:21 PM by PBS if system.environment.isMac { //PBS 3/20/99: convert Mac text if config.mainResponder.prefs.flConvertToMacText { if defined (adrParamTable^.postArgs) { on convertTable (adrPostTable) { //PBS 8/1/99: convert post args tables, recursively. ÇDon't convert uploaded files. local (i); local (flAttachedFile = defined (adrPostTable^.["Content-Type"])); for i = 1 to sizeOf (adrPostTable^) { if not flAttachedFile { if typeOf (adrPostTable^ [i]) == stringType { adrPostTable^ [i] = latinToMac.convert (adrPostTable^ [i])}; if typeOf (adrPostTable^ [i]) == listType { //JES 9/16/04: fix bug with multiple same-name arguments adrPostTable^ [i] = list (latinToMac.convert (adrPostTable^ [i]))}}; if typeOf (adrPostTable^ [i]) == tableType { convertTable (@adrPostTable^ [i])}}; return (true)}; convertTable (@adrParamTable^.postArgs); }; if defined (adrParamTable^.searchArgs) { //01/03/01 JES: convert to Mac text even if postArgs aren't present if adrParamTable^.searchArgs != "" { adrparamtable^.searchArgs = latinToMac.convert (adrparamtable^.searchArgs)}}; if defined (adrParamTable^.pathArgs) { //01/03/01 JES: convert to Mac text even if postArgs aren't present if adrParamTable^.pathArgs != "" { adrparamtable^.pathArgs = latinToMac.convert (adrparamtable^.pathArgs)}}}}}; bundle { //initialize nomad, this is where virtual hosting is implemented local (adrDomain = @config.mainResponder.domains.default); if defined (adrParamTable^.host) { on lookUpHost (hostName) { //PBS 7/30/99: look up a host in config.mainResponder.domains and set adrDomain if defined (config.mainResponder.domains.[hostName]) { adrDomain = @config.mainResponder.domains.[hostName]; return (true)}; return (false)}; if not (lookUpHost (adrParamTable^.host)) { //first do the standard lookup ÇPBS 7/30/99: The standard look up wasn't found. Try removing the port and any trailing dots. local (hostName = adrParamTable^.host); if hostName contains ":" { hostName = string.popSuffix (hostName, ":")}; //PBS 7/30/99: remove trailing port hostName = string.popTrailing (hostName, '.'); //PBS 7/30/99: remove trailing dot lookUpHost (hostName)}}; bundle { //based on type, initialize nomad on setnomad (adrdomain) { case typeOf (adrdomain^) { tabletype { if defined (adrDomain^.siteTree) { //PBS 06/09/00: handle XML siteTree tables nomad = initialXmlSiteTreeDive (adrDomain); return (true)} else { //look for a docTree item if not defined (adrdomain^.doctree) { scriptError ("Server configuration error. Domain table must contain an element named docTree.")}}; if defined (adrdomain^.globals) { //add the elements of this table to the responder attributes table gatherGlobals (@adrDomain^.globals); //PBS 06/09/00: code below was broken out, since it was used in multiple places Çlocal (i, ct = sizeof (adrdomain^.globals), adritem) Çfor i = 1 to ct Çadritem = @adrdomain^.globals [i] Çadratts^.[nameof (adritem^)] = adritem^}; setnomad (@adrdomain^.doctree)}; //recurse stringtype { local (s = adrdomain^); if string.lower (s) beginsWith "http://" { //redirect! ÇscriptError ("!redirect " + s + adrparamtable^.path) scriptError ("!redirect " + s + string.nthField (adrparamtable^.firstLine, ' ', 2))}; //JES 07/04/00: if the path contains path args, make sure they're part of the URL redirected to nomad = filespec (adrdomain^)}; addresstype; filespectype { nomad = adrdomain^}} else { scriptError ("Server configuration error. The type of a domain doctree must be either table, string or filespec.")}}; setnomad (adrdomain)}; if fldebug { addDebugLog ("home", nomad)}}; bundle { //PBS 8/25/99: give callbacks a chance to override standard path evaluation local (adrCallbacks = @config.mainResponder.callbacks.pathEvaluation); if defined (adrCallbacks^) { adrParamTable^.domainPath = nomad; //this might be an address or filespec adrParamTable^.adrObjectToServe = nil; //callback places a value here if it wants to over-ride standard path evaluation mainResponder.callbackLoop (adrCallbacks, adrParamTable); //call the callbacks if defined (adrParamTable^.adrObjectToServe) and adrParamTable^.adrObjectToServe != nil { //did a callback evaluate the path? nomad = adrParamTable^.adrObjectToServe; //set nomad to the callback-specified value flCallbackParsedPath = true}}}; //this is so the rest of this script knows that the callback handle path evaluation bundle { //leave nomad pointing to the object to be served if not flCallbackParsedPath { //PBS 8/25/99: if callback evaluated path, skip this bundle local (stack = {}, path, objectname); Çpath = string.lower (string.urlDecode (adrparamtable^.path)) if system.environment.isMac { //JES 9/16/04: handle high-ascii in URL properly path = string.lower (string.latinToMac (string.urlDecode (adrparamtable^.path)))} else { //not MacOS -- just do string.lower, without character translation path = string.lower (string.urlDecode (adrparamtable^.path))}; if path beginswith "/" { path = string.delete (path, 1, 1)}; bundle { //when Frontier is running behind a web server like WebSTAR or IIS, ignore .wsf extensions if defined (adrparamtable^.wsfSuffixRequired) { if adrparamtable^.wsfSuffixRequired { if string.lower (path) endsWith ".wsf" { path = string.mid (path, 1, sizeof (path) - 4)}}}}; while sizeof (path) > 0 { local (flsystemwebsite = false); //PBS 10/25/99: moved this declaration so it gets set false for the next part of the path. Otherwise URLs inside the system website won't work. objectname = string.nthField (path, '/', 1); bundle { //check for system websites, like controlPanel if sizeof (stack) == 0 { //check for special mainResponder-implemented websites flsystemwebsite = false; case string.lower (objectname) { "controlpanel" { if defined (config.mainResponder.prefs.flControlPanel) and config.mainResponder.prefs.flControlPanel { //PBS 10/25/99: flControlPanel may not exist; check that it exists before checking its value nomad = @mainResponder.controlPanel; flsystemwebsite = true}}; "mainresponderresources" { //PBS 06/14/00: /mainResponderResources/ is now a system website pointing to mainResponder.resources, which contains various icons, including Pike buttons. This way the Pike button (etc.) will show up regardless of the settings at config.mainResponder.domains. nomad = @mainResponder.resources; flsystemwebsite = true}} else { //PBS 11/9/99: short URLs for Manila sites: if the first part of the path points to an item in config.manila.sites, set nomad to config.manila.sites.[objectName]. if string.lower (nomad) == string.lower (Frontier.getSubFolder ("www")) { Ç10/22/04; 4:08:36 PM by EDS Çnot changing this, since in this one case, this is the best behavior for the manila site name short curcuit behavior. if defined (config.manila.sites.[objectName]) { nomad = config.manila.sites.[objectName]; flsystemwebsite = true}; if not flsystemwebsite { //PBS 12/16/99: short URLs for mainResponder sites. The mechanism works similarly to the mechanism for Manila sites, except that the table is at config.mainResponder.sites. However, an entry at config.mainResponder sites can be a table itself or a filespec, it doesn't have to be an address if defined (config.mainResponder.sites) { if defined (config.mainResponder.sites.[objectName]) { nomad = @config.mainResponder.sites.[objectName]; if defined (config.mainResponder.sites.[objectName].siteTree.directory) { nomad = initialXmlSiteTreeDive (nomad)}; flsystemwebsite = true}}}}}}}; if not flsystemwebsite { if objectname == ".." { //pop the stack local (sizestack = sizeof (stack)); if sizestack == 0 { scriptError ("Can't surface beyond the root of the website.")}; nomad = stack [sizestack]; delete (@stack [sizestack]); continue}; bundle { //PBS 08/09/00: close security hole if objectName beginsWith ".." { //DW 08/09/00: close security hole scriptError ("Can't process objects with names beginning with \"..\".")}; if objectName contains "\\" { scriptError ("Can't process objects with names containing \"\\\".")}; if objectName contains ":" { scriptError ("Can't process objects with names containing \":\".")}}; bundle { //PBS 01/07/02: don't serve files or folders whose name begins with a dot. if objectName beginsWith "." { scriptError ("Can't process objects with names beginning with a dot.")}}; case typeof (nomad) { addresstype { while (typeof (nomad^) == addresstype) {nomad = nomad^}; case typeof (nomad^) { tabletype { //diving into a table nomad = tableDive (nomad, objectname)}; filespectype { //nomad now becomes a filespec nomad = folderDive (nomad^, objectname)}}}; filespectype { nomad = folderDive (nomad, objectname)}}}; if fldebug { addDebugLog ("step", nomad)}; ÇPBS 7/30/99: if the object wasn't found, and the website wants to handle this condition itself, it can over-ride mainResponder.respond's built-in behavior. ÇBreak out of this loop: there's no point to continue walking the path, since we know the current object wasn't found. if defined (adrAtts^.objectNotFoundHandler) and nomad == adrAtts^.objectNotFoundHandler { ÇHints for the object not found handler: stuff the remaining path in the page table and the last good nomad. adrParamTable^.lastNomad = nomad; if sizeOf (stack) > 0 { adrParamTable^.lastNomad = stack [sizeOf (stack)]}; adrParamTable^.remainingPath = path; break}; path = string.delete (path, 1, sizeof (objectname) + 1); stack = stack + nomad}} else { //PBS 8/25/99: callback handled path parsing, but we need to gather attributes if typeOf (nomad) == addressType { if typeOf (nomad^) == tableType { gatherAttributes (nomad)} else { gatherAttributes (parentOf (nomad^))}}}}; bundle { //serve the object nomad points to on serveFilespec (nomad) { if file.exists (nomad) { if file.isFolder (nomad) { serveFolder (nomad)} else { if string.lower (nomad) endswith ".root" { openRootFile (nomad); serveAddress (@[nomad])} else { serveFile (nomad)}}} else { //the file doesn't exist try { //see if there's an odb with the name, open it and serve from it local (f = nomad + ".root"); openRootFile (f); nomad = @[f]; serveAddress (nomad)} else { if tryError beginswith "!" { //it's a redirect, rethrow it scriptError (tryError)}; on error () { noFolderError (nomad)}; local (f = file.folderfrompath (nomad) + "#" + file.filefrompath (nomad)); if file.exists (f) { serveFile (f)} else { if string.lower (nomad) endswith ".xml" { //try to serve it as XML local (f = string.delete (nomad, sizeof (nomad) - 3, 4)); //pop off the .xml if not file.exists (f) { error ()}; serveAsXml (f)} else { error ()}}}}}; on serveAddress (nomad) { case typeof (nomad^) { addresstype { serveAddress (nomad^)}; filespectype { serveFileSpec (nomad^)}; scripttype { if adratts^.flrender { serveObject (nomad)} else { if attIsTrue ("allowScriptsToRun") { serveScript (nomad)} else { if attMustBeTrue ("allowScriptListings") { local (s = string.replaceall (string (nomad^), "<", "<")); Çlocal (s = mainResponder.neuterText (string (nomad^), false, true)) adrparamtable^.responseBody = "<html><body><pre>\r" + s + "\r</pre></body></html>"}}}}; tabletype { serveTable (nomad)}} else { serveObject (nomad)}}; case typeof (nomad) { filespectype { serveFilespec (nomad)}; addresstype { serveAddress (nomad)}}}; bundle { //compare If-Modified-Since with, maybe we can avoid serving it try { local (cachedate = date (adrparamtable^.requestHeaders.["If-Modified-Since"])); local (localdate = date (adrparamtable^.responseHeaders.["Last-Modified"])); if flDebug { //JES 9/16/04: debug calls only work if debugging is on, so this code probably never worked properly addDebugLog ("cachedate", cachedate); addDebugLog ("localdate", localdate)}; if cachedate >= localdate { //the cached object is fresh, so don't send it again adrParamTable^.code = 304; adrparamtable^.responseBody = ""}}}; bundle { //call the lightweightMacros routines mainResponder.callbackLoop (@config.mainresponder.callbacks.lightweightMacros, adrparamtable)}; bundle { //for debugging, save a copy of the param table in a global if fldebug { addDebugLog ("paramsOut", adrparamtable^)}; Çif config.mainresponder.prefs.flKeepParamTable Çif adrparamtable^.requestHeaders.["User-Agent"] != "Testing in Debugger" Çscratchpad.paramtable = adrparamtable^}; bundle { //if profile, return that text instead of the text of the request if flprofile { local (info); script.stopProfile (@info); local (oldtarget = target.set (@info)); table.sortby ("Value"); target.set (oldtarget); local (htmltext = "", indentlevel = 0); on add (s) { htmltext = htmltext + string.filledString ("\t", indentlevel) + s + "\r"}; add ("<html>"); indentlevel++; add ("<head>"); indentlevel++; local (title = "Profiling results for \"" + adrparamtable^.path + "\"", adritem); add ("<title>" + title + "</title>"); add ("</head>"); indentlevel--; add ("<body>"); indentlevel++; add ("<blockquote>"); indentlevel++; add ("<h2>" + title + "</h2>"); add ("<blockquote>"); indentlevel++; add ("<table cellspacing=\"5\">"); indentlevel++; add ("<tr><td><b>" + "Procedure" + "</b></td><td><b>" + "Ticks" + "</b></td></tr>"); for i = sizeof (info) downto 1 { adritem = @info [i]; add ("<tr><td><font size=\"-1\">" + nameof (adritem^) + "</font></td><td><center><font size=\"-1\">" + adritem^ + "</font></center></td></tr>")}; add ("</table>"); indentlevel--; add ("</blockquote>"); indentlevel--; add ("</blockquote>"); indentlevel--; add ("</body>"); indentlevel--; add ("</html>"); indentlevel--; adrparamtable^.responseBody = htmltext}}; bundle { //for membership info, if a callback is defined, call it if defined (adrparamtable^.adrMemberInfo) { //we had a member record for this user local (groupname = adrparamtable^.memberGroupName); local (adrmembers = mainResponder.members.getMembershipTable (groupname)); local (adrcallbacks = @adrmembers^.callbacks); if defined (adrcallbacks^) { //there's a callbacks table in the membership table local (adrcallback = @adrcallbacks^.closeMemberTable); if defined (adrcallback^) { adrcallback^ (adrparamtable^.adrMemberInfo)}}}}; return (true)}; if fldebug { core ()} else { try { //everything happens in the context of this try core ()} else { //some code threw a scriptError, catch it local (s = tryError); if s [1] == "!" { //it's a faked error local (command = string.nthfield (s, ' ', 1)); local (args = string.delete (s, 1, sizeof (command) + 1)); case command { "!redirect" { adrparamtable^.code = 302; //non-permanent redirect adrparamtable^.responseBody = webserver.util.buildErrorPage ("302 FOUND", "Found the page."); if defined (adrparamtable^.responderAttributes.redirectUrl) { // 10/31/00 JES: fixed problem redirecting to urls longer than 245 characters ÇFor this to work, first call mainResponder.redirect to set the redirect URL, and then scriptError ("!redirect " + url). if adrparamtable^.responderAttributes.redirectUrl beginsWith args { args = adrparamtable^.responderAttributes.redirectUrl}}; adrparamtable^.responseHeaders.location = args; adrparamtable^.responseHeaders.URI = args; try {delete (@adrparamtable^.responseHeaders.["Content-Type"])}}}} else { //show the error to the user local (msgForSysop = s); local (title = "Frontier Server Error"); local (htmltext = "", indentlevel = 0); on add (s) { htmltext = htmltext + string.filledString ("\t", indentlevel) + s + "\r"}; add ("<html>"); indentlevel++; add ("<head>"); indentlevel++; add ("<title>" + title + "</title>"); add ("</head>"); indentlevel--; add ("<body>"); indentlevel++; add ("<blockquote>"); indentlevel++; add ("<blockquote>"); indentlevel++; add ("<font size=\"+2\" face=\"helvetica,arial\">"); indentlevel++; add ("<br><b>" + "<i>Sorry!</i> There was an error: </b>" + msgForSysop); add ("</font>"); indentlevel--; Çadd ("<blockquote>"); indentlevel++ add ("<font size=\"+0\" face=\"helvetica,arial\">"); indentlevel++; Çadd ("<p>Object: " + nomad + ".") add ("<p>The error was detected by "+ "Frontier " + Frontier.version ()); add (" in " + "mainResponder.respond" + "."); add (" Webmaster: " + user.prefs.mailaddress + "."); add (" Time: " + date.netstandardstring (clock.now ()) + "."); add ("</font>"); indentlevel--; Çadd ("</blockquote>"); indentlevel-- add ("</blockquote>"); indentlevel--; add ("</blockquote>"); indentlevel--; add ("</body>"); indentlevel--; add ("</html>"); indentlevel--; bundle { //PBS 8/1/99: iso8859 encode the error page. Some error messages may contain characters which should be translated to HTML entities. if system.environment.isWindows { htmltext = string.iso8859encode (htmltext, @html.data.iso8859.win)}; if system.environment.isMac { htmltext = string.iso8859encode (htmltext, @html.data.iso8859.mac)}}; adrparamtable^.responseBody = htmltext}}; try { //logging code, we want to log everything, including errors if config.mainresponder.prefs.flLog { mainResponder.log.add (adrparamtable)}; }};Çnote: for the log timing stats to be meaningful, the log code must be called as late as possible bundle { //JES 11/5/02: handle HTTP 1.1 HEAD requests if adrparamtable^.method == "HEAD" { adrparamtable^.responseHeaders.["Content-Length"] = sizeOf (adrparamtable^.responseBody); adrparamtable^.responseBody = ""}}; html.deletePageTableAddress (); //PBS 8/25/99: don't leave a dangling pta in the temp table return (true)}; Çbundle // testing Çif dialog.ask ("URL:", @config.mainResponder.prefs.lastPath) Çlocal (parts = string.urlsplit (config.mainResponder.prefs.lastPath)) Çlocal (paramtable = mainresponder.testing.testparams) Çparamtable.path = parts [3] Çparamtable.uri = paramtable.path Çparamtable.host = parts [2] Çif paramtable.host contains ":" Çparamtable.port = string.nthField (paramtable.host, ":", 2) ÇmainResponder.respond (@paramtable, true) Çtemp.z = paramtable Çbundle //old test code Çlocal (fltiming = false) Çif fltiming Çlocal (olddebug = config.mainresponder.prefs.flDebug) Çconfig.mainresponder.prefs.flDebug = false Çlocal (ctloops = 100, i, s, ticks, tickspercall) ÇmainResponder.testing.paramTableFixed.requestHeaders.["User-Agent"] = "Testing in Debugger" Çticks = clock.ticks () Çfor i = 1 to ctloops Çrespond (@mainResponder.data.paramTableFixed) Çtickspercall = double (clock.ticks () - ticks) / ctloops Çconfig.mainresponder.prefs.flDebug = olddebug Çif not defined (mainResponder.data.timingOutline) Çnew (outlinetype, @mainResponder.data.timingOutline) Çedit (@mainResponder.data.timingOutline) Çop.firstsummit () Çop.insert (tickspercall + " ticks per call at " + string.timeString (), up) Çelse Çlocal (params = table.getcursoraddress ()^) //put cursor on param table you want to run Çparams.requestHeaders.["User-Agent"] = "Testing in Debugger" Çtry {delete (@params.paramtable.responderAtts)} Çrespond (@params) \ No newline at end of file --- 1,1029 ---- ! FrontierVcsFile:2:scpt:mainResponder.respond ! on respond (adrParamTable, fldebug = false) { ! «Changes ! «2/28/06; 11:21:17 AM by TAC [...1005 lines suppressed...] ! «local (olddebug = config.mainresponder.prefs.flDebug) ! «config.mainresponder.prefs.flDebug = false ! «local (ctloops = 100, i, s, ticks, tickspercall) ! «mainResponder.testing.paramTableFixed.requestHeaders.["User-Agent"] = "Testing in Debugger" ! «ticks = clock.ticks () ! «for i = 1 to ctloops ! «respond (@mainResponder.data.paramTableFixed) ! «tickspercall = double (clock.ticks () - ticks) / ctloops ! «config.mainresponder.prefs.flDebug = olddebug ! «if not defined (mainResponder.data.timingOutline) ! «new (outlinetype, @mainResponder.data.timingOutline) ! «edit (@mainResponder.data.timingOutline) ! «op.firstsummit () ! «op.insert (tickspercall + " ticks per call at " + string.timeString (), up) ! «else ! «local (params = table.getcursoraddress ()^) //put cursor on param table you want to run ! «params.requestHeaders.["User-Agent"] = "Testing in Debugger" ! «try {delete (@params.paramtable.responderAtts)} ! «respond (@params) \ No newline at end of file Index: parseMultipart =================================================================== RCS file: /cvsroot/frontierkernel/odbs/mainResponderRoot/mainResponder/parseMultipart,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** parseMultipart 26 Mar 2005 21:45:06 -0000 1.1.1.1 --- parseMultipart 7 Mar 2006 05:46:03 -0000 1.2 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:mainResponder.parseMultipart ! on parseMultipart (adrparamtable) { ÇChanges Ç9/16/04; 1:46:27 AM by JES ÇIf running on MacOS, convert argument names to mac characters. ÇChanges before 2004 Ç08/28/01; 12:31:27 AM by JES ÇAdded support for <select multiple> form elements, per feedback from Seth Dillingham. Ç12/02/1999; 5:18:51 PM by AR ÇDisabled debugging code: No longer write to scratchpad.headers. Ç1/17/99; 1:39:20 PM by DW ÇThanks to Kurt Egger for prodding me to do this code, and to Jeff Willden for a great example to work with. I rewrote the code to make better use of Frontier, to perform better and have a flatter interface for the application. ÇOur goal is to fill the postArgs table with info from the request local (boundaryString); bundle { //get the boundary string that separates each form element local (s = adrparamtable^.requestHeaders.["Content-Type"]); Çmultipart/form-data; boundary=---------------------------7cf1873b3e070a boundaryString = string.popLeading (string.nthField (s, '=', 2), '-')}; local (body); bundle { //initialize body, pop off leading dashes followed by boundary string body = string (adrparamtable^.requestBody); body = string.popLeading (body, '-'); body = string.delete (body, 1, sizeof (boundaryString))}; local (adrtable = @adrparamtable^.postArgs); new (tabletype, adrtable); //fill this table with info from the request loop { //get each form element, delimited by the boundary string local (ix = string.patternMatch (boundaryString, body)); if ix == 0 { //no more encoded elements break}; local (s = string.popTrailing (string.mid (body, 1, ix - 1), '-')); bundle { //digest the element ... [truncated message content] |
|
From: creecode <icr...@us...> - 2006-03-07 05:40:20
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7312 Modified Files: save Log Message: replace calls to verbs at extensions.latinToMac with string.(latin/mac)To(Latin/Mac) verbs Index: save =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/windowTypes/commands/save,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** save 6 Feb 2006 00:20:38 -0000 1.4 --- save 7 Mar 2006 05:40:15 -0000 1.5 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.save ! on save (adrItem = nil, flClosing = false) { ÇChanges Ç2/5/06; 11:14:02 AM by TAC Çupdate run callbacks to deal with the callback table not being there Ç10/25/05; 7:02:08 PM by TAC Çfix for items created with New menu not being saved when using File menu Save menu item Ç2001 Ç3/16/01; 10:30:51 PM by PBS ÇIf the About window is already open, don't call window.about (), as that messes up window cascade order. Ç02/21/01; 2:16:27 AM by JES ÇSave the file using the recorded line-ending format. Preserve Mac type/creator codes. Ç02/08/01; 4:05:36 PM by JES ÇBug fix: If the About Window is frontmost, save Radio.root. Ç01/24/01; 1:46:18 PM by JES ÇIf an opml file contained any xml headers like xml-stylesheet declarations, include them when saving the file. Ç2000 Ç12/31/00; 12:33:46 AM by JES ÇOn Macs, convert opml text to latin text before saving local outlines to disk. Ç12/26/00; 3:04:22 PM by PBS ÇWhen doing a save as plain text, allow the user to decide the extension, don't force an .xml or whatever extension. If no extension is provided, then use .txt. Ç12/21/00; 11:07:10 AM by PBS ÇBring the window being saved back to front only if the About window is frontmost. Fixes bug reported on Scripting News: http://scriptingnews.userland.com/backissues/2000/12/21 Ç12/20/00; 1:19:14 AM by JES ÇBug fix: View in Browser works for new stories and new messages. Ç11/29/00; 10:34:08 PM by JES ÇDereference callback addresses in a try block in case a tool's odb is not opened Ç11/21/00; 1:22:36 AM by PBS ÇUse generic template save routine when the template doesn't have a dedicated handler. Ç11/20/00; 10:19:36 PM by JES ÇAllow callbacks to consume the save action for weblog pages and local outlines. Ç11/20/00; 3:39:43 PM by JES ÇCall the user callbacks when saving local outlines or rendering wsf pages. Ç11/03/00; 1:13:17 AM by JES ÇHandle saving the message as opml if the server is compatible. Ç10/07/00; 1:37:06 PM by PBS ÇIf there's an error saving, report the actual error to the user. Ç10/03/00; 6:41:58 PM by PBS ÇCallbacks can be addresses. Ç09/22/00; 5:00:21 PM by PBS ÇBefore saving to a Manila server, check the offline status. Ç09/21/00; 5:35:57 PM by PBS ÇWhen saving an OPML file, save with Radio UserLand's file creator code and OPML file type. Ç09/16/00; 3:16:02 PM by PBS ÇSave file system objects -- classic text files -- okay. Ç09/16/00; 5:22:22 PM by PBS Ç.opml is the default extension when saving new files. Ç09/15/00; 1:55:51 PM by PBS ÇIf the outline is raw XML, don't try to save it as an outlineDocument. ÇSat, Aug 26, 2000 at 6:13:44 PM by JES ÇSave weblog pages by rendering with the website framework, according to their #ftpSite table settings. Ç08/23/00; 3:14:32 AM by PBS ÇSupport custom serialization routines for advanced items. This allows the plain XML display to be over-ridden. Ç08/22/00; 9:59:29 PM by PBS ÇWhen saving a message, don't promote it to a story if storyInfo.flAddToStoriesList exists and is false. This preserves backwards compatibility, but it also provides a way for people to create and reply to dg messages without making them stories. ÇMonday, August 21, 2000 at 5:48:56 AM by DW ÇProvide feedback when saving local files. Ç08/16/00; 10:38:06 PM by JES ÇAlways bring the last frontmost window to the front after saving. Ç07/23/00; 7:59:16 PM by PBS ÇIf it's a local outline document, save it to disk at the right location. ÇFri, Jul 7, 2000 at 11:00:09 PM by AR ÇCall any scripts in user.pike.commandCallbacks.save ÇIf one of the scripts returns true, we're done Ç03/24/00; 6:41:08 PM by PBS ÇConvert cascadingStyleSheet to css -- because manila.css is the name of the handler. This fixes saving CSS items back to the server. Ç03/24/00; 11:14:47 AM by PBS ÇDon't update the last saved date after a failed save. Display a friendly error message explaining that there was a communication error -- display the title of the object and the name of the server. Ç03/23/00; 12:15:17 PM by PBS ÇUse the About Window for feedback when saving. Ç02/05/00; 5:29:12 PM by PBS ÇBuild the table of information about this window, so we can preserve size, position, scroll state, and expansion state. ÇHandle the Save command. if adrItem == nil { //default to frontmost window adrItem = window.frontmost ()}; on saveDatabase () { msg ("Saving database..."); if typeOf (adrItem) == addressType { fileMenu.saveMyRoot (adritem)} else { fileMenu.save ()}; msg ("")}; //clear the feedback message if not defined (adrItem^) { //save Radio.root adrItem = @root; saveDatabase (); return (true)}; on runCallbacks (stringAddress) { //call callbacks if defined (stringAddress^) { local (flConsumed = false); local (adrScript); for adrScript in @stringAddress^ { try { //11/30/00 JES while typeOf (adrScript^) == addressType { //follow addresses adrScript = adrScript^}; flConsumed = adrScript^ (adrItem, flClosing)}; if flConsumed { return (true)}}}; return (false)}; if runCallbacks ("user.tools.commandCallbacks.save") { return (true)}; if system.environment.isRadio { if runCallbacks ("user.pike.commandCallbacks.save") { return (true)}}; bundle { //look for a windowType that handles this command local (type, adrType); if window.attributes.getOne ("type", @type, adrItem) { if Frontier.tools.windowTypes.findWindowType (type, @adrType, adrItem) { if defined (adrType^.save) { if adrType^.save (adrItem, flClosing) { window.attributes.setOne ("lastSaved", timeModified (adrItem), adrItem); saveDatabase (); return (true)} else { return (false)}}}}}; if not (system.environment.isRadio) { // save windows created by the new menu or opened from the file system local (f = window.getFile (adrItem)); if f == "" or file.type (f) != 'TABL' { if fileMenu.save (adrItem) { return (true)}}}; saveDatabase (); return (true)}; Çbundle //old code Çif adrItem == nil //get the current selection Çtry {adrItem = table.getCursorAddress ()} Çlocal (frontWindow = window.frontMost ()) Çlocal (aboutWindowName = "About Radio UserLand") Ç Çon saveDatabase () // 8/26/00 JES: factored saving code Çmsg ("Saving database...") Çif typeOf (adrItem) == addressType ÇfileMenu.saveMyRoot (adritem) Çelse ÇfileMenu.save () Ç Çif window.frontMost () == aboutWindowName //PBS 12/21/00: bring editing window back to front only if the About window is frontmost Çtry {edit (frontWindow)} //JES 08/16/00 Ç Çmsg ("") //clear the feedback message Ç Çlocal (flConsumed = false) Çif adrItem != nil //11/20/00 JES: call the user callbacks Çif defined (user.pike.commandCallbacks.save) Çlocal (adrcallback) Çfor adrcallback in @user.pike.commandCallbacks.save Çtry //11/30/00 JES Çwhile typeOf (adrcallback^) == addressType //follow addresses Çadrcallback = adrcallback^ ÇflConsumed = adrcallback^ (adrItem, flClosing) Çif flConsumed Çbreak Ç Çif not defined (adrItem^) //save Radio.root ÇadrItem = @root ÇsaveDatabase () Çreturn (true) Ç Çif not flConsumed //JES 08/26/00: handle rendering website framework pages Çif defined (suites.playlist.weblog.utilities.windowIsWebPage) and suites.playlist.weblog.utilities.windowIsWebPage (adrItem) Çhtml.buildOnePage (adrItem) Ç ÇsaveDatabase () Ç Çif not flConsumed //PBS 07/23/00: handle local outline documents Çif pike.isLocalOutline (adrItem) //handle local outlines only in this block Çlocal (adrTable = parentOf (adrItem^)) Çlocal (f) Çon saveFile () Çmsg ("Saving \"" + f + "\".") //Monday, August 21, 2000 at 5:47:45 AM by DW ÇadrTable^.title = file.fileFromPath (f) Çwindow.setTitle (adrItem, adrTable^.title) Çlocal (xmlText) Çif defined (adrTable^.flOutlineDocument) //PBS 09/15/00: it may be raw XML Çif not (adrTable^.flOutlineDocument) ÇxmlText = string (adrItem^) //raw XML is just string of the outline Çbundle //add linefeeds if this is Windows Çif system.environment.isWindows ÇxmlText = string.replaceAll (xmlText, "\r", "\r\n") Çif defined (adrTable^.fileCreator) //02/21/2001 JES: save with recorded type/creator Çfile.writeWholeFile (f, xmlText, adrTable^.fileType, adrTable^.fileCreator) Çelse Çfile.writeWholeFile (f, xmlText, 'TEXT', 'Radu') Çif xmlText == nil //if it's an outlineDocument, xmlText is not yet set ÇxmlText = op.outlineToXml (adrItem) //convert to outlineDocument Çif defined (adrTable^.lineEnding) //02/21/2001 JES: save the file with the recorded line-endings ÇxmlText = string.replaceAll (xmlText, "\r", adrTable^.lineEnding) Çbundle //01/23/01 JES: support style sheet declarations Çif defined (adrTable^.xmlHeaders) Çlocal (ix = string.patternMatch ("?>", xmlText) + 3) ÇxmlText = string.insert (adrTable^.xmlHeaders, xmlText, ix) Çif system.environment.isMac //12/31/00 JES: convert Mac text to latin ÇxmlText = latinToMac.macToLatin (xmlText) Çif defined (adrTable^.fileCreator) //02/21/2001 JES: save with recorded type/creator Çfile.writeWholeFile (f, xmlText, adrTable^.fileType, adrTable^.fileCreator) Çelse Çfile.writeWholeFile (f, xmlText, 'OPML', 'Radu') //PBS 09/21/00: save with Mac codes ÇadrTable^.f = f ÇadrTable^.lastSaved = clock.now () Çmsg ("") Çreturn (true) Çif defined (adrTable^.f) Çf = adrTable^.f ÇsaveFile () Çelse Çif not (file.putFileDialog ("Save as:", @f)) Çreturn (false) Çlocal (defaultExtension = ".opml") Çlocal (flOutlineDocument = false) Çif defined (adrTable^.flOutlineDocument) //PBS 12/26/00: check extension only with OPML documents Çif adrTable^.flOutlineDocument ÇflOutlineDocument = true Ç Çif flOutlineDocument //ensure .opml extension Çif not (string.lower (f) endsWith defaultExtension) Çf = f + defaultExtension Çelse //PBS 12/26/00: if no extension, use .txt extension Çlocal (fname = file.fileFromPath (f)) Çif not (fname contains ".") Çf = f + ".txt" Ç ÇsaveFile () Ç Çreturn (true) Ç Çbundle //PBS 09/18/00: handle saving the home page of the server Çlocal (adrHomePage = @system.temp.playlist.serverHomePage) Çif defined (adrHomePage^) Çif adrItem == adrHomePage Çlocal (s = string (adrHomePage^)) //get the text Çlocal (f = user.playlist.prefs.wwwFolder + "index.html") Çfile.writeWholeFile (f, s, 'TEXT', user.html.prefs.textFileCreator, clock.now ()) Çreturn (true) Ç Çlocal (flAboutWindowOpen = window.isOpen (aboutWindowName)) Ç Çon savingError (displayTitle) ÇHandle errors in saving the document. Display a message and clean up. ÇfileMenu.save () Çmsg ("") ÇPBS 04/03/00: save the actual tryError Çif not defined (temp.pike) Çnew (tableType, @temp.pike) Çwp.newTextObject (tryError, @temp.pike.lastSaveError) Çif not flAboutWindowOpen //close the About Window if it wasn't open before doing a save Çwindow.close (aboutWindowName) Çlocal (hostName = pike.getServerHostName (adrItem)) ÇscriptError ("Can't save " + displayTitle + " because of an error communicating with the server, " + hostName + ".") ÇscriptError ("Can't save " + displayTitle + " because " + tryError + ".") Ç Çif adrItem!= nil Çbundle //PBS 03/23/00: display feedback message Çif not flAboutWindowOpen //PBS 03/16/01: this call messes up window cascade order if the About window was already open Çwindow.about () Ç Çif not flConsumed Çlocal (windowType = pike.getWindowType (adrItem)) Çif windowType != "" Ç Çif not (playlist.tcpOkay ()) //PBS 09/22/00: check offline status Çreturn (false) Ç Çlocal (adrTable = parentOf (adrItem^)) Ç Çlocal (bodyType = "text/x-outline-tabbed") Ç Çlocal (windowInfoTable = pike.buildWindowInfoTable (adrItem)) //PBS 02/05/00: get the window info table Ç Çlocal (flServerAcceptsOpml = false) Çif defined (adrTable^.siteInfo.flAcceptsOpml) //11/03/00 JES ÇflServerAcceptsOpml = adrTable^.siteInfo.flAcceptsOpml Çcase windowType Ç"advancedItems" Çlocal (itemTypeName = nameOf (adrTable^)) Çmsg ("Saving " + itemTypeName + "...") Çlocal (handlerName = pike.advancedItemToHandlerName (itemTypeName)) Çtry Çlocal (s = string (adrItem^)) Çif defined (adrTable^.itemInfo.adrSerializeRoutine) //PBS 08/23/00: call serialization routine if there is one Çif defined (adrTable^.itemInfo.adrSerializeRoutine^) Çs = adrTable^.itemInfo.adrSerializeRoutine^ (adrTable) Çif defined (manila.[handlerName].set) Çmanila.[handlerName].set (@adrTable^.siteinfo, s, windowInfoTable) Çelse //PBS 11/20/00: use generic save routine Çmanila.advancedPref.set (@adrTable^.siteInfo, itemTypeName, s, windowInfoTable) Çelse ÇsavingError ("the " + itemTypeName) ÇadrTable^.lastSaved = clock.now () Ç"savedStories" Çif flServerAcceptsOpml ÇbodyType = "text/x-opml" Çlocal (subject = adrTable^.storyinfo.subject) Çmsg ("Saving \"" + subject + "\"...") Çlocal (adrStory = @adrTable^.storyinfo) Çtry Çif flServerAcceptsOpml //11/03/00 JES Çlocal (opmlText = op.outlineToXml (adrItem, ownerEmail:adrTable^.siteInfo.username)) Çmanila.message.set (@adrTable^.siteinfo, adrStory^.msgnum, adrStory^.subject, opmlText, bodyType, windowInfoTable) //PBS 02/05/00: added windowInfoTable parameter Çelse Çmanila.message.set (@adrTable^.siteinfo, adrStory^.msgnum, adrStory^.subject, string (adrItem^), bodyType, windowInfoTable) //PBS 02/05/00: added windowInfoTable parameter Çelse Çtemp.errorText = tryError ÇsavingError ("\"" + subject + "\"") ÇadrTable^.lastSaved = clock.now () Ç"newStories" Çif flServerAcceptsOpml ÇbodyType = "text/x-opml" Çlocal (subject = adrTable^.storyinfo.subject) Çmsg ("Saving \"" + subject + "\"...") Ç Çlocal (resulttable) Çtry Çlocal (inResponseTo = 0) Çif defined (adrTable^.storyInfo.inResponseTo) ÇinResponseTo = adrTable^.storyInfo.inResponseTo Çif flServerAcceptsOpml //11/03/00 JES Çlocal (opmlText = op.outlineToXml (adrItem, ownerEmail:adrTable^.siteInfo.username)) Çresulttable = manila.message.create (@adrTable^.siteinfo, subject, opmlText, bodyType, inResponseTo, windowInfoTable) Çelse Çresulttable = manila.message.create (@adrTable^.siteinfo, subject, string (adrItem^), bodyType, inResponseTo, windowInfoTable) Çelse Çtemp.errorText = tryError ÇsavingError ("\"" + subject + "\"") Ç Çif not flClosing //copy to savedStories Çlocal (adrStoryTable = pike.getStoryTableAddress (@adrTable^.siteinfo, resulttable.msgnum)) ÇadrStoryTable^.siteinfo = adrTable^.siteinfo ÇadrStoryTable^.storyinfo = resulttable Ç Çtable.move (adrItem, adrStoryTable) Çpike.setWindowTitle (adrStoryTable) Ç ÇadrTable^.storyinfo.url = adrStoryTable^.storyinfo.url //12/20/00 JES: make view in browser work for new stories Ç ÇadrStoryTable^.lastSaved = clock.now () Ç Çlocal (flAddToStoriesList = true) //PBS 08/22/00: if flAddToStoriesList exists and is false, don't add to stories. This way we can have messages that aren't stories. Çif defined (adrTable^.storyInfo.flAddToStoriesList) Çif not (adrTable^.storyInfo.flAddToStoriesList) ÇflAddToStoriesList = false Çif flAddToStoriesList Çmanila.message.addToStoriesList (@adrTable^.siteinfo, resulttable.msgnum) Ç Çif window.isOpen (adrItem) Çedit (adrItem) //PBS 03/24/00: bring it back to the front, in case the About Window came to the front Ç ÇsaveDatabase () Çbundle // factored code Çmsg ("Saving database...") Çif typeOf (adrItem) == addressType ÇfileMenu.saveMyRoot (adritem) Çelse ÇfileMenu.save () Ç Çtry {edit (frontWindow)} //JES 08/16/00 Ç Çmsg ("") //clear the feedback message Çif not flAboutWindowOpen //close the About Window if it wasn't open before doing a save Çwindow.close (aboutWindowName) Ç Çreturn (true) Çbundle // testing Çsave (window.frontMost ()) \ No newline at end of file --- 1,375 ---- ! FrontierVcsFile:2:scpt:system.verbs.builtins.Frontier.tools.windowTypes.commands.save ! on save (adrItem = nil, flClosing = false) { ! «Changes ! «2/28/06; 1:03:16 PM by TAC ! «replace latinToMac.macToLatin with string.macToLatin ! «2/5/06; 11:14:02 AM by TAC ! «update run callbacks to deal with the callback table not being there ! «10/25/05; 7:02:08 PM by TAC ! «fix for items created with New menu not being saved when using File menu Save menu item ! «2001 ! «3/16/01; 10:30:51 PM by PBS ! «If the About window is already open, don't call window.about (), as that messes up window cascade order. ! «02/21/01; 2:16:27 AM by JES ! «Save the file using the recorded line-ending format. Preserve Mac type/creator codes. ! «02/08/01; 4:05:36 PM by JES ! «Bug fix: If the About Window is frontmost, save Radio.root. ! «01/24/01; 1:46:18 PM by JES ! «If an opml file contained any xml headers like xml-stylesheet declarations, include them when saving the file. ! «2000 ! «12/31/00; 12:33:46 AM by JES ! «On Macs, convert opml text to latin text before saving local outlines to disk. ! «12/26/00; 3:04:22 PM by PBS ! «When doing a save as plain text, allow the user to decide the extension, don't force an .xml or whatever extension. If no extension is provided, then use .txt. ! «12/21/00; 11:07:10 AM by PBS ! «Bring the window being saved back to front only if the About window is frontmost. Fixes bug reported on Scripting News: http://scriptingnews.userland.com/backissues/2000/12/21 ! «12/20/00; 1:19:14 AM by JES ! «Bug fix: View in Browser works for new stories and new messages. ! «11/29/00; 10:34:08 PM by JES ! «Dereference callback addresses in a try block in case a tool's odb is not opened ! «11/21/00; 1:22:36 AM by PBS ! «Use generic template save routine when the template doesn't have a dedicated handler. ! «11/20/00; 10:19:36 PM by JES ! «Allow callbacks to consume the save action for weblog pages and local outlines. ! «11/20/00; 3:39:43 PM by JES ! «Call the user callbacks when saving local outlines or rendering wsf pages. ! «11/03/00; 1:13:17 AM by JES ! «Handle saving the message as opml if the server is compatible. ! «10/07/00; 1:37:06 PM by PBS ! «If there's an error saving, report the actual error to the user. ! «10/03/00; 6:41:58 PM by PBS ! «Callbacks can be addresses. ! «09/22/00; 5:00:21 PM by PBS ! «Before saving to a Manila server, check the offline status. ! «09/21/00; 5:35:57 PM by PBS ! «When saving an OPML file, save with Radio UserLand's file creator code and OPML file type. ! «09/16/00; 3:16:02 PM by PBS ! «Save file system objects -- classic text files -- okay. ! «09/16/00; 5:22:22 PM by PBS ! «.opml is the default extension when saving new files. ! «09/15/00; 1:55:51 PM by PBS ! «If the outline is raw XML, don't try to save it as an outlineDocument. ! «Sat, Aug 26, 2000 at 6:13:44 PM by JES ! «Save weblog pages by rendering with the website framework, according to their #ftpSite table settings. ! «08/23/00; 3:14:32 AM by PBS ! «Support custom serialization routines for advanced items. This allows the plain XML display to be over-ridden. ! «08/22/00; 9:59:29 PM by PBS ! «When saving a message, don't promote it to a story if storyInfo.flAddToStoriesList exists and is false. This preserves backwards compatibility, but it also provides a way for people to create and reply to dg messages without making them stories. ! «Monday, August 21, 2000 at 5:48:56 AM by DW ! «Provide feedback when saving local files. ! «08/16/00; 10:38:06 PM by JES ! «Always bring the last frontmost window to the front after saving. ! «07/23/00; 7:59:16 PM by PBS ! «If it's a local outline document, save it to disk at the right location. ! «Fri, Jul 7, 2000 at 11:00:09 PM by AR ! «Call any scripts in user.pike.commandCallbacks.save ! «If one of the scripts returns true, we're done ! «03/24/00; 6:41:08 PM by PBS ! «Convert cascadingStyleSheet to css -- because manila.css is the name of the handler. This fixes saving CSS items back to the server. ! «03/24/00; 11:14:47 AM by PBS ! «Don't update the last saved date after a failed save. Display a friendly error message explaining that there was a communication error -- display the title of the object and the name of the server. ! «03/23/00; 12:15:17 PM by PBS ! «Use the About Window for feedback when saving. ! «02/05/00; 5:29:12 PM by PBS ! «Build the table of information about this window, so we can preserve size, position, scroll state, and expansion state. ! «Handle the Save command. ! ! if adrItem == nil { //default to frontmost window ! adrItem = window.frontmost ()}; ! ! on saveDatabase () { ! msg ("Saving database..."); ! if typeOf (adrItem) == addressType { ! fileMenu.saveMyRoot (adritem)} ! else { ! fileMenu.save ()}; ! msg ("")}; //clear the feedback message ! ! if not defined (adrItem^) { //save Radio.root ! adrItem = @root; ! saveDatabase (); ! return (true)}; ! ! on runCallbacks (stringAddress) { //call callbacks ! if defined (stringAddress^) { ! local (flConsumed = false); ! local (adrScript); ! for adrScript in @stringAddress^ { ! try { //11/30/00 JES ! while typeOf (adrScript^) == addressType { //follow addresses ! adrScript = adrScript^}; ! flConsumed = adrScript^ (adrItem, flClosing)}; ! if flConsumed { ! return (true)}}}; ! return (false)}; ! ! if runCallbacks ("user.tools.commandCallbacks.save") { ! return (true)}; ! ! if system.environment.isRadio { ! if runCallbacks ("user.pike.commandCallbacks.save") { ! return (true)}}; ! ! bundle { //look for a windowType that handles this command ! local (type, adrType); ! if window.attributes.getOne ("type", @type, adrItem) { ! if Frontier.tools.windowTypes.findWindowType (type, @adrType, adrItem) { ! if defined (adrType^.save) { ! if adrType^.save (adrItem, flClosing) { ! window.attributes.setOne ("lastSaved", timeModified (adrItem), adrItem); ! saveDatabase (); ! return (true)} ! else { ! return (false)}}}}}; ! ! if not (system.environment.isRadio) { // save windows created by the new menu or opened from the file system ! local (f = window.getFile (adrItem)); ! if f == "" or file.type (f) != 'TABL' { ! if fileMenu.save (adrItem) { ! return (true)}}}; ! ! saveDatabase (); ! ! return (true)}; ! «bundle //old code ! «if adrItem == nil //get the current selection ! «try {adrItem = table.getCursorAddress ()} ! «local (frontWindow = window.frontMost ()) ! «local (aboutWindowName = "About Radio UserLand") ! « ! «on saveDatabase () // 8/26/00 JES: factored saving code ! «msg ("Saving database...") ! «if typeOf (adrItem) == addressType ! «fileMenu.saveMyRoot (adritem) ! «else ! «fileMenu.save () ! « ! «if window.frontMost () == aboutWindowName //PBS 12/21/00: bring editing window back to front only if the About window is frontmost ! «try {edit (frontWindow)} //JES 08/16/00 ! « ! «msg ("") //clear the feedback message ! « ! «local (flConsumed = false) ! «if adrItem != nil //11/20/00 JES: call the user callbacks ! «if defined (user.pike.commandCallbacks.save) ! «local (adrcallback) ! «for adrcallback in @user.pike.commandCallbacks.save ! «try //11/30/00 JES ! «while typeOf (adrcallback^) == addressType //follow addresses ! «adrcallback = adrcallback^ ! «flConsumed = adrcallback^ (adrItem, flClosing) ! «if flConsumed ! «break ! « ! «if not defined (adrItem^) //save Radio.root ! «adrItem = @root ! «saveDatabase () ! «return (true) ! « ! «if not flConsumed //JES 08/26/00: handle rendering website framework pages ! «if defined (suites.playlist.weblog.utilities.windowIsWebPage) and suites.playlist.weblog.utilities.windowIsWebPage (adrItem) ! «html.buildOnePage (adrItem) ! « ! «saveDatabase () ! « ! «if not flConsumed //PBS 07/23/00: handle local outline documents ! «if pike.isLocalOutline (adrItem) //handle local outlines only in this block ! «local (adrTable = parentOf (adrItem^)) ! «local (f) ! «on saveFile () ! «msg ("Saving \"" + f + "\".") //Monday, August 21, 2000 at 5:47:45 AM by DW ! «adrTable^.title = file.fileFromPath (f) ! «window.setTitle (adrItem, adrTable^.title) ! «local (xmlText) ! «if defined (adrTable^.flOutlineDocument) //PBS 09/15/00: it may be raw XML ! «if not (adrTable^.flOutlineDocument) ! «xmlText = string (adrItem^) //raw XML is just string of the outline ! «bundle //add linefeeds if this is Windows ! «if system.environment.isWindows ! «xmlText = string.replaceAll (xmlText, "\r", "\r\n") ! «if defined (adrTable^.fileCreator) //02/21/2001 JES: save with recorded type/creator ! «file.writeWholeFile (f, xmlText, adrTable^.fileType, adrTable^.fileCreator) ! «else ! «file.writeWholeFile (f, xmlText, 'TEXT', 'Radu') ! «if xmlText == nil //if it's an outlineDocument, xmlText is not yet set ! «xmlText = op.outlineToXml (adrItem) //convert to outlineDocument ! «if defined (adrTable^.lineEnding) //02/21/2001 JES: save the file with the recorded line-endings ! «xmlText = string.replaceAll (xmlText, "\r", adrTable^.lineEnding) ! «bundle //01/23/01 JES: support style sheet declarations ! «if defined (adrTable^.xmlHeaders) ! «local (ix = string.patternMatch ("?>", xmlText) + 3) ! «xmlText = string.insert (adrTable^.xmlHeaders, xmlText, ix) ! «if system.environment.isMac //12/31/00 JES: convert Mac text to latin ! «xmlText = string.macToLatin (xmlText) ! «if defined (adrTable^.fileCreator) //02/21/2001 JES: save with recorded type/creator ! «file.writeWholeFile (f, xmlText, adrTable^.fileType, adrTable^.fileCreator) ! «else ! «file.writeWholeFile (f, xmlText, 'OPML', 'Radu') //PBS 09/21/00: save with Mac codes ! «adrTable^.f = f ! «adrTable^.lastSaved = clock.now () ! «msg ("") ! «return (true) ! «if defined (adrTable^.f) ! «f = adrTable^.f ! «saveFile () ! «else ! «if not (file.putFileDialog ("Save as:", @f)) ! «return (false) ! «local (defaultExtension = ".opml") ! «local (flOutlineDocument = false) ! «if defined (adrTable^.flOutlineDocument) //PBS 12/26/00: check extension only with OPML documents ! «if adrTable^.flOutlineDocument ! «flOutlineDocument = true ! « ! «if flOutlineDocument //ensure .opml extension ! «if not (string.lower (f) endsWith defaultExtension) ! «f = f + defaultExtension ! «else //PBS 12/26/00: if no extension, use .txt extension ! «local (fname = file.fileFromPath (f)) ! «if not (fname contains ".") ! «f = f + ".txt" ! « ! «saveFile () ! « ! «return (true) ! « ! «bundle //PBS 09/18/00: handle saving the home page of the server ! «local (adrHomePage = @system.temp.playlist.serverHomePage) ! «if defined (adrHomePage^) ! «if adrItem == adrHomePage ! «local (s = string (adrHomePage^)) //get the text ! «local (f = user.playlist.prefs.wwwFolder + "index.html") ! «file.writeWholeFile (f, s, 'TEXT', user.html.prefs.textFileCreator, clock.now ()) ! «return (true) ! « ! «local (flAboutWindowOpen = window.isOpen (aboutWindowName)) ! « ! «on savingError (displayTitle) ! «Handle errors in saving the document. Display a message and clean up. ! «fileMenu.save () ! «msg ("") ! «PBS 04/03/00: save the actual tryError ! «if not defined (temp.pike) ! «new (tableType, @temp.pike) ! «wp.newTextObject (tryError, @temp.pike.lastSaveError) ! «if not flAboutWindowOpen //close the About Window if it wasn't open before doing a save ! «window.close (aboutWindowName) ! «local (hostName = pike.getServerHostName (adrItem)) ! «scriptError ("Can't save " + displayTitle + " because of an error communicating with the server, " + hostName + ".") ! «scriptError ("Can't save " + displayTitle + " because " + tryError + ".") ! « ! «if adrItem!= nil ! «bundle //PBS 03/23/00: display feedback message ! «if not flAboutWindowOpen //PBS 03/16/01: this call messes up window cascade order if the About window was already open ! «window.about () ! « ! «if not flConsumed ! «local (windowType = pike.getWindowType (adrItem)) ! «if windowType != "" ! « ! «if not (playlist.tcpOkay ()) //PBS 09/22/00: check offline status ! «return (false) ! « ! «local (adrTable = parentOf (adrItem^)) ! « ! «local (bodyType = "text/x-outline-tabbed") ! « ! «local (windowInfoTable = pike.buildWindowInfoTable (adrItem)) //PBS 02/05/00: get the window info table ! « ! «local (flServerAcceptsOpml = false) ! «if defined (adrTable^.siteInfo.flAcceptsOpml) //11/03/00 JES ! «flServerAcceptsOpml = adrTable^.siteInfo.flAcceptsOpml ! «case windowType ! «"advancedItems" ! «local (itemTypeName = nameOf (adrTable^)) ! «msg ("Saving " + itemTypeName + "...") ! «local (handlerName = pike.advancedItemToHandlerName (itemTypeName)) ! «try ! «local (s = string (adrItem^)) ! «if defined (adrTable^.itemInfo.adrSerializeRoutine) //PBS 08/23/00: call serialization routine if there is one ! «if defined (adrTable^.itemInfo.adrSerializeRoutine^) ! «s = adrTable^.itemInfo.adrSerializeRoutine^ (adrTable) ! «if defined (manila.[handlerName].set) ! «manila.[handlerName].set (@adrTable^.siteinfo, s, windowInfoTable) ! «else //PBS 11/20/00: use generic save routine ! «manila.advancedPref.set (@adrTable^.siteInfo, itemTypeName, s, windowInfoTable) ! «else ! «savingError ("the " + itemTypeName) ! «adrTable^.lastSaved = clock.now () ! «"savedStories" ! «if flServerAcceptsOpml ! «bodyType = "text/x-opml" ! «local (subject = adrTable^.storyinfo.subject) ! «msg ("Saving \"" + subject + "\"...") ! «local (adrStory = @adrTable^.storyinfo) ! «try ! «if flServerAcceptsOpml //11/03/00 JES ! «local (opmlText = op.outlineToXml (adrItem, ownerEmail:adrTable^.siteInfo.username)) ! «manila.message.set (@adrTable^.siteinfo, adrStory^.msgnum, adrStory^.subject, opmlText, bodyType, windowInfoTable) //PBS 02/05/00: added windowInfoTable parameter ! «else ! «manila.message.set (@adrTable^.siteinfo, adrStory^.msgnum, adrStory^.subject, string (adrItem^), bodyType, windowInfoTable) //PBS 02/05/00: added windowInfoTable parameter ! «else ! «temp.errorText = tryError ! «savingError ("\"" + subject + "\"") ! «adrTable^.lastSaved = clock.now () ! «"newStories" ! «if flServerAcceptsOpml ! «bodyType = "text/x-opml" ! «local (subject = adrTable^.storyinfo.subject) ! «msg ("Saving \"" + subject + "\"...") ! « ! «local (resulttable) ! «try ! «local (inResponseTo = 0) ! «if defined (adrTable^.storyInfo.inResponseTo) ! «inResponseTo = adrTable^.storyInfo.inResponseTo ! «if flServerAcceptsOpml //11/03/00 JES ! «local (opmlText = op.outlineToXml (adrItem, ownerEmail:adrTable^.siteInfo.username)) ! «resulttable = manila.message.create (@adrTable^.siteinfo, subject, opmlText, bodyType, inResponseTo, windowInfoTable) ! «else ! «resulttable = manila.message.create (@adrTable^.siteinfo, subject, string (adrItem^), bodyType, inResponseTo, windowInfoTable) ! «else ! «temp.errorText = tryError ! «savingError ("\"" + subject + "\"") ! « ! «if not flClosing //copy to savedStories ! «local (adrStoryTable = pike.getStoryTableAddress (@adrTable^.siteinfo, resulttable.msgnum)) ! «adrStoryTable^.siteinfo = adrTable^.siteinfo ! «adrStoryTable^.storyinfo = resulttable ! « ! «table.move (adrItem, adrStoryTable) ! «pike.setWindowTitle (adrStoryTable) ! « ! «adrTable^.storyinfo.url = adrStoryTable^.storyinfo.url //12/20/00 JES: make view in browser work for new stories ! « ! «adrStoryTable^.lastSaved = clock.now () ! « ! «local (flAddToStoriesList = true) //PBS 08/22/00: if flAddToStoriesList exists and is false, don't add to stories. This way we can have messages that aren't stories. ! «if defined (adrTable^.storyInfo.flAddToStoriesList) ! «if not (adrTable^.storyInfo.flAddToStoriesList) ! «flAddToStoriesList = false ! «if flAddToStoriesList ! «manila.message.addToStoriesList (@adrTable^.siteinfo, resulttable.msgnum) ! « ! «if window.isOpen (adrItem) ! «edit (adrItem) //PBS 03/24/00: bring it back to the front, in case the About Window came to the front ! « ! «saveDatabase () ! «bundle // factored code ! «msg ("Saving database...") ! «if typeOf (adrItem) == addressType ! «fileMenu.saveMyRoot (adritem) ! «else ! «fileMenu.save () ! « ! «try {edit (frontWindow)} //JES 08/16/00 ! « ! «msg ("") //clear the feedback message ! «if not flAboutWindowOpen //close the About Window if it wasn't open before doing a save ! «window.close (aboutWindowName) ! « ! «return (true) ! ! «bundle // testing ! «save (window.frontMost ()) \ No newline at end of file |
|
From: creecode <icr...@us...> - 2006-03-07 05:39:35
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/data/windowTypes/outlinerFile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6904 Modified Files: saveAsHtml Log Message: replace calls to verbs at extensions.latinToMac with string.(latin/mac)To(Latin/Mac) verbs Index: saveAsHtml =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/tools/data/windowTypes/outlinerFile/saveAsHtml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** saveAsHtml 26 Mar 2005 19:42:52 -0000 1.1.1.1 --- saveAsHtml 7 Mar 2006 05:39:32 -0000 1.2 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.tools.data.windowTypes.outlinerFile.saveAsHtml ! on saveAsHtml (adrOutline, adrFilepath=nil, flPreview=false) { //Render an outline as HTML and save it to disk. ÇChanges Ç4/27/02; 9:51:38 AM by DW ÇThe flPreview flag is nutty. It's always false based on the way it's called from the kernel. Setting it true doesn't get the document to open in the browser which is what previewing should do. Further, if it's false, it opens the document in an outline window. Oy. So I changed it, so that unconditionally, the HTML rendering is displayed in the browser after you save it. Don't try turning it on, please. It's not a well-designed feature. Ç4/27/02; 9:30:14 AM by DW ÇThere were two references to "adr" in this script, and apparently, at one time, the address of the outline was called adr, but not any more. These two changes made Save As HTML command in the File menu work on a relatively virgin Radio 8 installation. Ç1/30/02; 2:07:42 AM by JES ÇRemoved reference to pike.getPreferencesFolder. Ç1/29/02; 10:39:41 PM by JES ÇRemoved references to pike.isLocalOutline and pike.titleToHtmlFileName. Ç12/10/01; 12:33:40 AM by JES ÇCommented out the block where a default file path was set. Not only did it reference the deprecated pike.getPreferencesFolder, but it wasn't needed in the first place. Now all we set is the default filename. Ç12/15/00; 6:20:38 PM by PBS ÇCall user.pike.renderOutline to create the HTML document. This script may be changed by the user to over-ride the standard behavior. Ç12/20/00; 2:02:56 AM by JES ÇIf on a Mac, convert Mac characters to latin before writing the file to disk. Ç12/26/00; 2:43:55 PM by PBS ÇWorks with non-file-based outlines -- gets title from window title. If local, file based outline, get it from file info table. Ç12/13/00; 5:41:50 PM by PBS ÇCreated. Render an outline as HTML and save it to disk. Çadr is the address of the window to save ÇadrFilepath is the address from which to get the file path. If adrFilepath^ == nil, it will be set to the generated file path. ÇIf flPreview is true, the file is saved in [Radio Folder]/Preferences/View in Browser/[outlineName].html. ÇIf flPreview is false, the HTML file is opened in Radio. local (f); if adrFilepath != nil { f = adrFilepath^}; if f == nil { //construct a file path if not specified f = Frontier.tools.windowTypes.getDefaultFilename (adrOutline, user.html.prefs.fileExtension); local (appFolder = file.folderFromPath (Frontier.getProgramPath ())); local (viewInBrowserFolder = appFolder + "View in Browser" + file.getPathChar ()); f = viewInBrowserFolder + f; file.sureFilePath (f)}; if not flPreview { //ask the user for a path if not file.putFileDialog ("Save as HTML:", @f) { return (true)}}; //consume the command local (htmlText); bundle { //render the HTML on runUserRenderer (adrRenderer) { if defined (adrRenderer^) { local (adrScript = adrRenderer); try { while (typeOf (adrScript^) == addressType) { adrScript = adrScript^}}; htmlText = adrScript^ (adrOutline); return (true)}; return (false)}; local (htmlSetByUserRenderer = false); if runUserRenderer (@user.tools.renderOutline) { htmlSetByUserRenderer = true} else { //legacy support for user.pike.renderOutline if system.environment.isRadio { if defined (user.pike) { if runUserRenderer (@user.pike.renderOutline) { htmlSetByUserRenderer = true}}}}; if not htmlSetByUserRenderer { //do default rendering on renderOutline (adrOutline) { //from pike.renderOutline ÇRender an outline. Return the text of the rendering. ÇIf the outline contains rules, use pikeRenderer. Otherwise do a default unordered list rendering. Ç12/13/00; 5:03:46 PM by PBS ÇChanges: Ç12/26/00; 2:44:31 PM by PBS ÇWorks with non-file-based outlines -- gets title from window title. If local, file based outline, get it from file info table. Ç12/26/00; 5:11:21 PM by PBS ÇAdd HTML 4.01 Transitional doctype declaration. local (s); local (adrParentTable = parentOf (adrOutline^)); local (title = window.getTitle (adrOutline)); //PBS 12/26/00: get window title window.attributes.getOne ("title", @title, adrOutline); //4/27/02 by DW, change adr to adrOutline if string.lower (title) endsWith ".opml" { title = string.popSuffix (title)}; local (localOutline = adrOutline^); //make a copy of the outline adrOutline = @localOutline; if string (adrOutline) contains "<rules>" { //rules? local (pt); new (tableType, @pt); html.setPageTableAddress (@pt); local (oldTarget = target.set (@localOutline)); s = pikeRenderer.theRenderer (adrOutline); try {target.set (oldTarget)}; s = string.replaceAll (s, "\r\r", "<p>\r"); html.deletePageTableAddress ()} else { //no rules; use unordered list rendering s = html.getOutlineHtml (adrOutline, "\r<ul>", "\r</ul>", "\r<li>", "</li>")}; bundle { //add HTML header and footer ÇHeader. local (headerText = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r"); //PBS 12/26/00: add DOCTYPE declaration headerText = headerText + "<html>\r\t<head><title>" + title + "</title></head>\r"; headerText = headerText + "\t<body bgcolor=\"white\">\r"; ÇHTML title. headerText = headerText + "<h2>" + title + "</h2>\r"; s = headerText + s; ÇFooter. local (footerText = "\r\t\t</body>\r\t</html>"); s = s + footerText}; bundle { //if this is a PC, add line feeds if system.environment.isWindows { s = string.replaceAll (s, "\r", "\r\n")}}; return (s)}; htmlText = renderOutline (adrOutline)}}; //4/27/02 by DW, change adr to adrOutline if system.environment.isMac { //12/20/00 JES: if on a Mac, convert Mac characters to latin htmlText = latinToMac.macToLatin (htmlText)}; file.writeWholeFile (f, htmlText, 'TEXT', user.html.prefs.textFileCreator, clock.now ()); if adrFilepath != nil { //tell the caller where the file is -- used for View in Browser adrFilepath^ = f}; bundle { //4/27/02 by DW, see comment at head of script Çif not flPreview Çreturn (Frontier.tools.windowTypes.commands.open (f)) webbrowser.opendocument (f)}; return (true)} \ No newline at end of file --- 1,133 ---- ! FrontierVcsFile:2:scpt:system.verbs.builtins.Frontier.tools.data.windowTypes.outlinerFile.saveAsHtml ! on saveAsHtml (adrOutline, adrFilepath=nil, flPreview=false) { //Render an outline as HTML and save it to disk. ! «Changes ! «2/28/06; 1:03:16 PM by TAC ! «replace latinToMac.macToLatin with string.macToLatin ! «2002 ! «4/27/02; 9:51:38 AM by DW ! «The flPreview flag is nutty. It's always false based on the way it's called from the kernel. Setting it true doesn't get the document to open in the browser which is what previewing should do. Further, if it's false, it opens the document in an outline window. Oy. So I changed it, so that unconditionally, the HTML rendering is displayed in the browser after you save it. Don't try turning it on, please. It's not a well-designed feature. ! «4/27/02; 9:30:14 AM by DW ! «There were two references to "adr" in this script, and apparently, at one time, the address of the outline was called adr, but not any more. These two changes made Save As HTML command in the File menu work on a relatively virgin Radio 8 installation. ! «1/30/02; 2:07:42 AM by JES ! «Removed reference to pike.getPreferencesFolder. ! «1/29/02; 10:39:41 PM by JES ! «Removed references to pike.isLocalOutline and pike.titleToHtmlFileName. ! «12/10/01; 12:33:40 AM by JES ! «Commented out the block where a default file path was set. Not only did it reference the deprecated pike.getPreferencesFolder, but it wasn't needed in the first place. Now all we set is the default filename. ! «2000 ! «12/26/00; 2:43:55 PM by PBS ! «Works with non-file-based outlines -- gets title from window title. If local, file based outline, get it from file info table. ! «12/20/00; 2:02:56 AM by JES ! «If on a Mac, convert Mac characters to latin before writing the file to disk. ! «12/15/00; 6:20:38 PM by PBS ! «Call user.pike.renderOutline to create the HTML document. This script may be changed by the user to over-ride the standard behavior. ! «12/13/00; 5:41:50 PM by PBS ! «Created. Render an outline as HTML and save it to disk. ! «adr is the address of the window to save ! «adrFilepath is the address from which to get the file path. If adrFilepath^ == nil, it will be set to the generated file path. ! «If flPreview is true, the file is saved in [Radio Folder]/Preferences/View in Browser/[outlineName].html. ! «If flPreview is false, the HTML file is opened in Radio. ! ! local (f); ! if adrFilepath != nil { ! f = adrFilepath^}; ! ! if f == nil { //construct a file path if not specified ! f = Frontier.tools.windowTypes.getDefaultFilename (adrOutline, user.html.prefs.fileExtension); ! local (appFolder = file.folderFromPath (Frontier.getProgramPath ())); ! local (viewInBrowserFolder = appFolder + "View in Browser" + file.getPathChar ()); ! f = viewInBrowserFolder + f; ! file.sureFilePath (f)}; ! ! if not flPreview { //ask the user for a path ! if not file.putFileDialog ("Save as HTML:", @f) { ! return (true)}}; //consume the command ! ! local (htmlText); ! bundle { //render the HTML ! on runUserRenderer (adrRenderer) { ! if defined (adrRenderer^) { ! local (adrScript = adrRenderer); ! try { ! while (typeOf (adrScript^) == addressType) { ! adrScript = adrScript^}}; ! htmlText = adrScript^ (adrOutline); ! return (true)}; ! return (false)}; ! local (htmlSetByUserRenderer = false); ! if runUserRenderer (@user.tools.renderOutline) { ! htmlSetByUserRenderer = true} ! else { //legacy support for user.pike.renderOutline ! if system.environment.isRadio { ! if defined (user.pike) { ! if runUserRenderer (@user.pike.renderOutline) { ! htmlSetByUserRenderer = true}}}}; ! if not htmlSetByUserRenderer { //do default rendering ! on renderOutline (adrOutline) { //from pike.renderOutline ! «Render an outline. Return the text of the rendering. ! «If the outline contains rules, use pikeRenderer. Otherwise do a default unordered list rendering. ! «12/13/00; 5:03:46 PM by PBS ! «Changes: ! «12/26/00; 2:44:31 PM by PBS ! «Works with non-file-based outlines -- gets title from window title. If local, file based outline, get it from file info table. ! «12/26/00; 5:11:21 PM by PBS ! «Add HTML 4.01 Transitional doctype declaration. ! ! local (s); ! local (adrParentTable = parentOf (adrOutline^)); ! local (title = window.getTitle (adrOutline)); //PBS 12/26/00: get window title ! window.attributes.getOne ("title", @title, adrOutline); //4/27/02 by DW, change adr to adrOutline ! if string.lower (title) endsWith ".opml" { ! title = string.popSuffix (title)}; ! ! local (localOutline = adrOutline^); //make a copy of the outline ! adrOutline = @localOutline; ! ! if string (adrOutline) contains "<rules>" { //rules? ! local (pt); ! new (tableType, @pt); ! html.setPageTableAddress (@pt); ! local (oldTarget = target.set (@localOutline)); ! s = pikeRenderer.theRenderer (adrOutline); ! try {target.set (oldTarget)}; ! s = string.replaceAll (s, "\r\r", "<p>\r"); ! html.deletePageTableAddress ()} ! else { //no rules; use unordered list rendering ! s = html.getOutlineHtml (adrOutline, "\r<ul>", "\r</ul>", "\r<li>", "</li>")}; ! ! bundle { //add HTML header and footer ! «Header. ! local (headerText = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\r"); //PBS 12/26/00: add DOCTYPE declaration ! headerText = headerText + "<html>\r\t<head><title>" + title + "</title></head>\r"; ! headerText = headerText + "\t<body bgcolor=\"white\">\r"; ! ! «HTML title. ! headerText = headerText + "<h2>" + title + "</h2>\r"; ! ! s = headerText + s; ! ! «Footer. ! local (footerText = "\r\t\t</body>\r\t</html>"); ! ! s = s + footerText}; ! ! bundle { //if this is a PC, add line feeds ! if system.environment.isWindows { ! s = string.replaceAll (s, "\r", "\r\n")}}; ! ! return (s)}; ! htmlText = renderOutline (adrOutline)}}; //4/27/02 by DW, change adr to adrOutline ! ! if system.environment.isMac { //12/20/00 JES: if on a Mac, convert Mac characters to latin ! htmlText = string.macToLatin (htmlText)}; ! file.writeWholeFile (f, htmlText, 'TEXT', user.html.prefs.textFileCreator, clock.now ()); ! ! if adrFilepath != nil { //tell the caller where the file is -- used for View in Browser ! adrFilepath^ = f}; ! ! bundle { //4/27/02 by DW, see comment at head of script ! «if not flPreview ! «return (Frontier.tools.windowTypes.commands.open (f)) ! webbrowser.opendocument (f)}; ! return (true)} \ No newline at end of file |
|
From: creecode <icr...@us...> - 2006-03-07 05:39:30
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/apps/Manila/windowTypes/types/manilaTemplate/scripts/siteStructure In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6874 Modified Files: xmlToOutline outlineToXml Log Message: replace calls to verbs at extensions.latinToMac with string.(latin/mac)To(Latin/Mac) verbs Index: outlineToXml =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/apps/Manila/windowTypes/types/manilaTemplate/scripts/siteStructure/outlineToXml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** outlineToXml 26 Mar 2005 19:42:27 -0000 1.1.1.1 --- outlineToXml 7 Mar 2006 05:39:26 -0000 1.2 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:system.verbs.apps.Manila.windowTypes.types.manilaTemplate.scripts.siteStructure.outlineToXml ! on outlineToXml (adrOutline) { ÇChanges: Ç2/11/04; 1:58:45 AM by JES ÇAdded support for redirects from within a Manila site structure. Ç12/22/01; 3:53:29 AM by JES ÇCall latinToMac.macToLatin instead of playlist.convertToLatin. Ç12/19/01; 2:46:03 PM by JES ÇAdded some msg calls to let the user know that we're building the site structure XML. This is important for large site structure outlines, like the DocServer site structure outline. Ç7/22/01; 12:32:07 AM by JES ÇEncode xml entities in name and description attributes. Ç3/18/01; 4:23:29 PM by PBS ÇClose <category> tags that don't contain any stories or other categories. Fixes the bug reported on this page: http://radio.userland.com/discuss/msgReader$5625?mode=day Ç12/31/00; 5:18:02 PM by JES ÇOn Macs, convert opml text from Mac to latin. ÇFri, Dec 8, 2000 at 1:07:34 PM by JES ÇBug fix: Always add non-empty descriptions for categories, not just when the category doesn't have an associated message number. ÇTuesday, September 19, 2000 at 2:24:04 PM by PBS ÇGet description attributes and add to XML text. ÇWed, Aug 23, 2000 at 2:26:50 AM by PBS ÇCreated. Turn a fancy site structure editor into its plain XML text representation. Return XML text. This is just like an outline renderer -- it's a special case of outline renderer. local (xmlText = "<hierarchy>\r"); local (localOutline = adrOutline^); //use a copy so as not to make the screen go nuts local (oldTarget = target.set (@localOutline)); op.setDisplay (false); //it's faster op.firstSummit (); op.fullexpand (); local (level = 1); on add (s) { xmlText = xmlText + string.filledString ('\t', level) + s + "\r"}; on getDescription (adrAtts) { //PBS 09/19/00: get description attribute if not defined (adrAtts^.description) { return ("")}; return (string.trimWhiteSpace (adrAtts^.description))}; on visit (message="Building site structure XML: ") { loop { local (ctSubs = op.countSubs (1)); local (flHasSubs = ctSubs > 0); local (s = ""); local (linetext = op.getLineText ()); local (atts); op.attributes.getAll (@atts); case atts.type { "manilaSiteStructureMessage" { if string.lower (linetext) != "index" { //special case local (msgNum = atts.msgNum); local (name = atts.name); local (pathname = string.trimWhiteSpace (linetext)); msg (message + pathname + "..."); local (description = getDescription (@atts)); if string.lower (name) == "untitled" { name = pathname}; if description == "" { //it's already been white-space-trimmed add ("<story msgNum=\"" + msgNum + "\" name=\"" + name + "\"" + " pathname=\"" + pathName + "\"/>")} else { //PBS 09/19/00: add description to XML add ("<story msgNum=\"" + msgNum + "\" name=\"" + name + "\"" + " pathname=\"" + pathName + "\"><description>" + description + "</description></story>")}}}; "manilaSiteStructureCategory" { local (name = atts.name); local (pathname = string.trimWhiteSpace (linetext)); local (description = getDescription (@atts)); if string.lower (name) == "untitled" { name = pathname}; local (msgNum); local (cursor = op.getCursor ()); bundle { //look ahead for index item if op.go (right, 1) { loop { local (linetext = op.getLineText ()); if string.lower (linetext) == "index" { local (atts); op.attributes.getAll (@atts); msgNum = atts.msgNum; break}; if not (op.go (down, 1)) { break}}; op.setCursor (cursor)}}; if msgNum != nil { add ("<category msgNum=\"" + msgNum + "\" name=\"" + name + "\"" + " pathname=\"" + pathName + "\">")} else { add ("<category name=\"" + name + "\"" + " pathname=\"" + pathName + "\">")}; if description != "" { //it's already been white-space-trimmed //12/08/00 JES: always add non-empty descriptions, not just when msgNum == nil. add ("<description>" + description + "</description>")}; //PBS 09/19/00: add description if flHasSubs { op.go (right, 1); level++; visit (message + pathname + "/"); add ("</category>"); level--; op.go (left, 1)} else { //PBS 03/18/01: close off categories that don't contain anything add ("</category>")}}; "manilaSiteStructureRedirect" { local (url = atts.url); local (pathname = string.trimWhiteSpace (linetext)); msg (message + pathname + "..."); add ("<redirect pathname=\"" + pathName + "\" url=\"" + url + "\"/>")}}; if not (op.go (down, 1)) { break}}}; visit (); try {target.set (oldTarget)}; xmlText = xmlText + "</hierarchy>"; if system.environment.isMac { xmltext = latinToMac.macToLatin (xmlText)}; return (xmlText)}; Çbundle //test code Çwp.newTextObject (outlineToXml (window.frontmost ()), @workspace.xtext) \ No newline at end of file --- 1,120 ---- ! FrontierVcsFile:2:scpt:system.verbs.apps.Manila.windowTypes.types.manilaTemplate.scripts.siteStructure.outlineToXml ! on outlineToXml (adrOutline) { ! «Changes ! «2/28/06; 1:03:16 PM by TAC ! «replace latinToMac.macToLatin with string.macToLatin ! «2/11/04; 1:58:45 AM by JES ! «Added support for redirects from within a Manila site structure. ! «2001 ! «12/22/01; 3:53:29 AM by JES ! «Call latinToMac.macToLatin instead of playlist.convertToLatin. ! «12/19/01; 2:46:03 PM by JES ! «Added some msg calls to let the user know that we're building the site structure XML. This is important for large site structure outlines, like the DocServer site structure outline. ! «7/22/01; 12:32:07 AM by JES ! «Encode xml entities in name and description attributes. ! «3/18/01; 4:23:29 PM by PBS ! «Close <category> tags that don't contain any stories or other categories. Fixes the bug reported on this page: http://radio.userland.com/discuss/msgReader$5625?mode=day ! «2000 ! «12/31/00; 5:18:02 PM by JES ! «On Macs, convert opml text from Mac to latin. ! «Fri, Dec 8, 2000 at 1:07:34 PM by JES ! «Bug fix: Always add non-empty descriptions for categories, not just when the category doesn't have an associated message number. ! «Tuesday, September 19, 2000 at 2:24:04 PM by PBS ! «Get description attributes and add to XML text. ! «Wed, Aug 23, 2000 at 2:26:50 AM by PBS ! «Created. Turn a fancy site structure editor into its plain XML text representation. Return XML text. This is just like an outline renderer -- it's a special case of outline renderer. ! ! local (xmlText = "<hierarchy>\r"); ! ! local (localOutline = adrOutline^); //use a copy so as not to make the screen go nuts ! local (oldTarget = target.set (@localOutline)); ! op.setDisplay (false); //it's faster ! op.firstSummit (); ! op.fullexpand (); ! local (level = 1); ! ! on add (s) { ! xmlText = xmlText + string.filledString ('\t', level) + s + "\r"}; ! ! on getDescription (adrAtts) { //PBS 09/19/00: get description attribute ! if not defined (adrAtts^.description) { ! return ("")}; ! return (string.trimWhiteSpace (adrAtts^.description))}; ! ! on visit (message="Building site structure XML: ") { ! loop { ! local (ctSubs = op.countSubs (1)); ! local (flHasSubs = ctSubs > 0); ! local (s = ""); ! local (linetext = op.getLineText ()); ! local (atts); ! op.attributes.getAll (@atts); ! case atts.type { ! "manilaSiteStructureMessage" { ! if string.lower (linetext) != "index" { //special case ! local (msgNum = atts.msgNum); ! local (name = atts.name); ! local (pathname = string.trimWhiteSpace (linetext)); ! msg (message + pathname + "..."); ! local (description = getDescription (@atts)); ! if string.lower (name) == "untitled" { ! name = pathname}; ! if description == "" { //it's already been white-space-trimmed ! add ("<story msgNum=\"" + msgNum + "\" name=\"" + name + "\"" + " pathname=\"" + pathName + "\"/>")} ! else { //PBS 09/19/00: add description to XML ! add ("<story msgNum=\"" + msgNum + "\" name=\"" + name + "\"" + " pathname=\"" + pathName + "\"><description>" + description + "</description></story>")}}}; ! "manilaSiteStructureCategory" { ! local (name = atts.name); ! local (pathname = string.trimWhiteSpace (linetext)); ! local (description = getDescription (@atts)); ! if string.lower (name) == "untitled" { ! name = pathname}; ! local (msgNum); ! local (cursor = op.getCursor ()); ! bundle { //look ahead for index item ! if op.go (right, 1) { ! loop { ! local (linetext = op.getLineText ()); ! if string.lower (linetext) == "index" { ! local (atts); ! op.attributes.getAll (@atts); ! msgNum = atts.msgNum; ! break}; ! if not (op.go (down, 1)) { ! break}}; ! op.setCursor (cursor)}}; ! if msgNum != nil { ! add ("<category msgNum=\"" + msgNum + "\" name=\"" + name + "\"" + " pathname=\"" + pathName + "\">")} ! else { ! add ("<category name=\"" + name + "\"" + " pathname=\"" + pathName + "\">")}; ! if description != "" { //it's already been white-space-trimmed //12/08/00 JES: always add non-empty descriptions, not just when msgNum == nil. ! add ("<description>" + description + "</description>")}; //PBS 09/19/00: add description ! if flHasSubs { ! op.go (right, 1); ! level++; ! visit (message + pathname + "/"); ! add ("</category>"); ! level--; ! op.go (left, 1)} ! else { //PBS 03/18/01: close off categories that don't contain anything ! add ("</category>")}}; ! "manilaSiteStructureRedirect" { ! local (url = atts.url); ! local (pathname = string.trimWhiteSpace (linetext)); ! msg (message + pathname + "..."); ! add ("<redirect pathname=\"" + pathName + "\" url=\"" + url + "\"/>")}}; ! if not (op.go (down, 1)) { ! break}}}; ! visit (); ! ! try {target.set (oldTarget)}; ! ! xmlText = xmlText + "</hierarchy>"; ! ! if system.environment.isMac { ! xmltext = string.macToLatin (xmlText)}; ! ! return (xmlText)} ! «bundle //test code ! «wp.newTextObject (outlineToXml (window.frontmost ()), @workspace.xtext) \ No newline at end of file Index: xmlToOutline =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/apps/Manila/windowTypes/types/manilaTemplate/scripts/siteStructure/xmlToOutline,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** xmlToOutline 26 Mar 2005 19:42:27 -0000 1.1.1.1 --- xmlToOutline 7 Mar 2006 05:39:26 -0000 1.2 *************** *** 1,3 **** ! FrontierVcsFile:1:scpt:system.verbs.apps.Manila.windowTypes.types.manilaTemplate.scripts.siteStructure.xmlToOutline ! on xmlToOutline (xmltext, adrOutline) { ÇChanges: Ç2/11/04; 1:53:08 AM by JES ÇAdded support for redirects from within a Manila site structure. Ç12/28/01; 6:23:53 PM by JES ÇFixed a bug where site structure outlines would not open on Windows. Ç12/19/01; 2:27:03 PM by JES ÇAdded some msg calls, so the user has some indication that the outline is being built. This is important for large site structure outlines, like the DocServer site structure outline. Ç7/22/01; 12:31:40 AM by JES ÇDecode xml entities in name and description attributes. Ç12/31/00; 5:11:47 PM by JES ÇOn Macs, convert latin opml text to Mac text. ÇTuesday, September 19, 2000 at 2:11:18 PM by PBS ÇGet descriptions and add as attributes. If an item has no description, then description attribute is "". ÇWed, Aug 23, 2000 at 1:45:20 AM by PBS ÇCreated. Build a site structure outline. This script over-rides the plain XML that Pike gives us. Çlocal (adrOutline = @adrTable^.outline) //the actual window local (adrinfo); window.attributes.getOne ("adrSiteInfo", @adrinfo, adrOutline); local (siteUrl = nameOf (adrinfo^)); bundle { //if port 80, pull the port out of the siteUrl local (parts = string.urlSplit (siteUrl)); if parts[2] contains ":" { if string.nthField (parts[2], ':', 2) == "80" { siteUrl = parts[1] + string.nthField (parts[2], ':', 1) + "/" + parts[3]}}}; local (t); new (tableType, @t); if system.environment.isMac { //12/31/00 JES: convert to Mac text xml.compile (latinToMac.convert (xmltext), @t)} else { xml.compile (xmltext, @t)}; new (outlineType, adrOutline); local (oldTarget = target.set (adrOutline)); on getDescription (adrTable) { //PBS 09/19/00: get an item's description local (adrItem); for adrItem in adrTable { local (itemName = xml.convertToDisplayName (nameOf (adrItem^))); if string.lower (itemName) == "description" { return (adrItem^)}}; return ("")}; on doTable (adrTable, flGoneRight, message="Building site structure outline: ") { local (dir = down); if not flGoneRight { dir = right}; local (adrItem); for adrItem in adrTable { if typeOf (adrItem^) != tableType { continue}; local (itemName = xml.convertToDisplayName (nameOf (adrItem^))); local (lowerName = string.lower (itemName)); case lowerName { "story" { local (atts); new (tableType, @atts); atts.siteUrl = siteUrl; atts.type = "manilaSiteStructureMessage"; atts.msgNum = adrItem^.["/atts"].msgNum; atts.name = adrItem^.["/atts"].name; atts.description = getDescription (adrItem); local (linetext = adrItem^.["/atts"].pathName); msg (message + linetext + "..."); if (sizeOf (adrOutline^) == 1) and (op.getLineText () == "") { op.setLineText (linetext)} else { op.insert (linetext, dir)}; dir = down; op.attributes.addGroup (@atts)}; "category" { local (atts); new (tableType, @atts); atts.siteUrl = siteUrl; atts.type = "manilaSiteStructureCategory"; local (linetext = adrItem^.["/atts"].pathName); if defined (adrItem^.["/atts"].name) { atts.name = adrItem^.["/atts"].name} else { atts.name = adrItem^.["/atts"].pathName}; atts.description = getDescription (adrItem); if (sizeOf (adrOutline^) == 1) and (op.getLineText () == "") { op.setLineText (linetext)} else { op.insert (linetext, dir)}; op.attributes.addGroup (@atts); dir = down; if defined (adrItem^.["/atts"].msgNum) { local (atts); new (tableType, @atts); atts.siteUrl = siteUrl; atts.type = "manilaSiteStructureMessage"; atts.msgNum = adrItem^.["/atts"].msgNum; atts.name = adrItem^.["/atts"].name; linetext = "index"; op.insert (linetext, right); op.attributes.addGroup (@atts); doTable (adrItem, true, message + linetext + "/")} else { doTable (adrItem, false, message + linetext + "/")}}; "redirect" { local (atts); new (tableType, @atts); atts.siteUrl = siteUrl; atts.type = "manilaSiteStructureRedirect"; atts.url = adrItem^.["/atts"].url; local (linetext = adrItem^.["/atts"].pathName); if (sizeOf (adrOutline^) == 1) and (op.getLineText () == "") { op.setLineText (linetext)} else { op.insert (linetext, dir)}; dir = down; op.attributes.addGroup (@atts)}}}; op.go (left, 1)}; doTable (@t [1], true); msg (""); try {target.set (oldTarget)}; return (true)} \ No newline at end of file --- 1,128 ---- ! FrontierVcsFile:2:scpt:system.verbs.apps.Manila.windowTypes.types.manilaTemplate.scripts.siteStructure.xmlToOutline ! on xmlToOutline (xmltext, adrOutline) { ! «Changes ! «2/28/06; 12:14:56 PM by TAC ! «replace extensions.latinToMac.convert with string.latinToMac ! «2/11/04; 1:53:08 AM by JES ! «Added support for redirects from within a Manila site structure. ! «2001 ! «12/28/01; 6:23:53 PM by JES ! «Fixed a bug where site structure outlines would not open on Windows. ! «12/19/01; 2:27:03 PM by JES ! «Added some msg calls, so the user has some indication that the outline is being built. This is important for large site structure outlines, like the DocServer site structure outline. ! «7/22/01; 12:31:40 AM by JES ! «Decode xml entities in name and description attributes. ! «2000 ! «12/31/00; 5:11:47 PM by JES ! «On Macs, convert latin opml text to Mac text. ! «9/19/00; 2:11:18 PM by PBS ! «Get descriptions and add as attributes. If an item has no description, then description attribute is "". ! «8/23/00; 1:45:20 AM by PBS ! «Created. Build a site structure outline. This script over-rides the plain XML that Pike gives us. ! ! «local (adrOutline = @adrTable^.outline) //the actual window ! ! local (adrinfo); ! window.attributes.getOne ("adrSiteInfo", @adrinfo, adrOutline); ! local (siteUrl = nameOf (adrinfo^)); ! bundle { //if port 80, pull the port out of the siteUrl ! local (parts = string.urlSplit (siteUrl)); ! if parts[2] contains ":" { ! if string.nthField (parts[2], ':', 2) == "80" { ! siteUrl = parts[1] + string.nthField (parts[2], ':', 1) + "/" + parts[3]}}}; ! ! local (t); ! new (tableType, @t); ! if system.environment.isMac { //12/31/00 JES: convert to Mac text ! xml.compile (string.latinToMac (xmltext), @t)} ! else { ! xml.compile (xmltext, @t)}; ! new (outlineType, adrOutline); ! local (oldTarget = target.set (adrOutline)); ! ! on getDescription (adrTable) { //PBS 09/19/00: get an item's description ! local (adrItem); ! for adrItem in adrTable { ! local (itemName = xml.convertToDisplayName (nameOf (adrItem^))); ! if string.lower (itemName) == "description" { ! return (adrItem^)}}; ! return ("")}; ! ! on doTable (adrTable, flGoneRight, message="Building site structure outline: ") { ! local (dir = down); ! if not flGoneRight { ! dir = right}; ! local (adrItem); ! for adrItem in adrTable { ! if typeOf (adrItem^) != tableType { ! continue}; ! local (itemName = xml.convertToDisplayName (nameOf (adrItem^))); ! local (lowerName = string.lower (itemName)); ! case lowerName { ! "story" { ! local (atts); ! new (tableType, @atts); ! atts.siteUrl = siteUrl; ! atts.type = "manilaSiteStructureMessage"; ! atts.msgNum = adrItem^.["/atts"].msgNum; ! atts.name = adrItem^.["/atts"].name; ! atts.description = getDescription (adrItem); ! local (linetext = adrItem^.["/atts"].pathName); ! msg (message + linetext + "..."); ! if (sizeOf (adrOutline^) == 1) and (op.getLineText () == "") { ! op.setLineText (linetext)} ! else { ! op.insert (linetext, dir)}; ! dir = down; ! op.attributes.addGroup (@atts)}; ! "category" { ! local (atts); ! new (tableType, @atts); ! atts.siteUrl = siteUrl; ! atts.type = "manilaSiteStructureCategory"; ! local (linetext = adrItem^.["/atts"].pathName); ! if defined (adrItem^.["/atts"].name) { ! atts.name = adrItem^.["/atts"].name} ! else { ! atts.name = adrItem^.["/atts"].pathName}; ! atts.description = getDescription (adrItem); ! if (sizeOf (adrOutline^) == 1) and (op.getLineText () == "") { ! op.setLineText (linetext)} ! else { ! op.insert (linetext, dir)}; ! op.attributes.addGroup (@atts); ! dir = down; ! if defined (adrItem^.["/atts"].msgNum) { ! local (atts); ! new (tableType, @atts); ! atts.siteUrl = siteUrl; ! atts.type = "manilaSiteStructureMessage"; ! atts.msgNum = adrItem^.["/atts"].msgNum; ! atts.name = adrItem^.["/atts"].name; ! linetext = "index"; ! op.insert (linetext, right); ! op.attributes.addGroup (@atts); ! doTable (adrItem, true, message + linetext + "/")} ! else { ! doTable (adrItem, false, message + linetext + "/")}}; ! "redirect" { ! local (atts); ! new (tableType, @atts); ! atts.siteUrl = siteUrl; ! atts.type = "manilaSiteStructureRedirect"; ! atts.url = adrItem^.["/atts"].url; ! local (linetext = adrItem^.["/atts"].pathName); ! if (sizeOf (adrOutline^) == 1) and (op.getLineText () == "") { ! op.setLineText (linetext)} ! else { ! op.insert (linetext, dir)}; ! dir = down; ! op.attributes.addGroup (@atts)}}}; ! op.go (left, 1)}; ! doTable (@t [1], true); ! msg (""); ! ! try {target.set (oldTarget)}; ! ! return (true)} \ No newline at end of file |