Changeset 1837
- Timestamp:
- 2001-01-15T15:21:43+13:00 (23 years ago)
- Location:
- trunk/gsdl
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/fileutil.cpp
r1815 r1837 337 337 } 338 338 339 // This is a fairly quick and nasty attempt at doing a "tail" on 340 // a file (i.e. returning the last numlines lines of filename). 341 // It has one important limitation in that it expects lines to be 342 // 256 characters long on average. 343 // This of course makes it possible that it won't return numlines 344 // lines if there are some very long lines. 345 // It also makes it fairly inefficient as it always reads in 346 // numlines*256 characters which is much more than generally 347 // necessary. 339 // This is a fairly quick and nasty attempt at doing a "tail" on a file 340 // (i.e. returning the last numlines lines of filename). It has one 341 // important limitation in that it expects lines to be linelength 342 // characters long on average. This of course makes it possible that it 343 // won't return numlines lines if there are some lines that are longer than 344 // linelength. It also makes it fairly inefficient as it always reads in 345 // numlines*linelength characters when it most often doesn't need them all. 348 346 // For current needs it's fine though. 349 text_t file_tail (const text_t &filename, int numlines) { 347 // -- Pass a linelength of 0 to use the default linelength (256 chars). 348 text_t file_tail (const text_t &filename, int numlines, int linelength) { 350 349 351 350 if (numlines < 1) numlines = 1; 352 streampos numchars = 256*numlines; 351 if (linelength == 0) linelength = 256; 352 353 streampos numchars = linelength*numlines; 353 354 354 355 text_tarray lines; … … 356 357 357 358 char *filenamec = filename.getcstr(); 358 char linec[ 256];359 char linec[linelength]; 359 360 ifstream file_in (filenamec); 360 361 delete filenamec; … … 366 367 367 368 while (!file_in.eof()) { 368 file_in.getline (linec, 256);369 file_in.getline (linec, linelength); 369 370 ret.setcstr(linec); 370 371 text_t::const_iterator here = ret.begin(); -
trunk/gsdl/lib/fileutil.h
r1739 r1837 56 56 bool file_copy (const text_t &fromfile, const text_t &tofile); 57 57 58 text_t file_tail (const text_t &filename, int numlines );58 text_t file_tail (const text_t &filename, int numlines, int linelength); 59 59 60 60 // returns true if directory created successfully -
trunk/gsdl/macros/status.dm
r1796 r1837 64 64 <a href="_httppagehome_" target=\_top>_textreturnhome_</a> 65 65 66 <p><b>_textconfigfiles_</b><br> 67 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=gsdlsite" target=infoframe>_textgsdlsite_</a><br> 68 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=maincfg" target=infoframe>_textmaincfg_</a> 69 70 <p><b>_textlogs_</b><br> 71 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=usagelog" target=infoframe>_textusagelog_</a><br> 72 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=initlog" target=infoframe>_textinitlog_</a><br> 73 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=errorlog" target=infoframe>_texterrorlog_</a> 74 66 75 _If_("_cgiarguma_" ne "\_cgiarguma\_", 67 76 <p><b>_textusermanage_</b><br> … … 77 86 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=browserinfo" target=infoframe>_textbrowsers_</a><br> 78 87 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=protocolinfo" target=infoframe>_textprotocols_</a> 79 80 <p><b>_textconfigfiles_</b><br>81 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=gsdlsite" target=infoframe>_textgsdlsite_</a><br>82 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=maincfg" target=infoframe>_textmaincfg_</a>83 84 <p><b>_textlogs_</b><br>85 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=initlog" target=infoframe>_textinitlog_</a><br>86 <a href="_gwcgi_?e=_compressedoptions_&a=status&p=errorlog" target=infoframe>_texterrorlog_</a>87 88 } 88 89 … … 94 95 _textchangepasswd_ {change password} 95 96 96 _textinfo_ { Information}97 _textinfo_ {Technical information} 97 98 _textgeneral_ {general} 98 99 _textarguments_ {arguments} … … 106 107 107 108 _textlogs_ {Logs} 109 _textusagelog_ {usage log} 108 110 _textinitlog_ {init log} 109 111 _texterrorlog_ {error log} … … 112 114 _textreturnhome_ {Greenstone home} 113 115 114 _titlewelcome_ { Maintenance andAdministration }116 _titlewelcome_ { Administration } 115 117 116 118 _welcome_ { -
trunk/gsdl/src/recpt/collectoraction.cpp
r1821 r1837 806 806 if (file_exists (bld_file + ".download")) { 807 807 statusline = "Downloading files ...<br>\n"; 808 statusline += file_tail (bld_file + ".download", 1 );808 statusline += file_tail (bld_file + ".download", 1, 0); 809 809 } else if (file_exists (bld_file + ".import")) { 810 810 statusline = "Importing collection ...<br>\n"; 811 statusline += file_tail (bld_file + ".import", 1 );811 statusline += file_tail (bld_file + ".import", 1, 0); 812 812 } else if (file_exists (bld_file + ".build")) { 813 813 statusline = "Building collection ...<br>\n"; 814 statusline += file_tail (bld_file + ".build", 1 );814 statusline += file_tail (bld_file + ".build", 1, 0); 815 815 } else { 816 816 statusline += "creating collection ...<br>\n"; 817 statusline += file_tail (bld_file, 1 );817 statusline += file_tail (bld_file, 1, 0); 818 818 } 819 819 … … 957 957 if (collector_page == "bildfail") { 958 958 text_t bldlog = filename_cat(gsdlhome, "tmp", args["bc1tmp"], args["bc1dirname"] + ".bld"); 959 text_t rawlog = file_tail (bldlog, 6 );959 text_t rawlog = file_tail (bldlog, 6, 0); 960 960 // we'll shove in some <br> tags where \n's occur 961 961 text_t faillog; -
trunk/gsdl/src/recpt/statusaction.cpp
r1801 r1837 742 742 } 743 743 744 void statusaction::output_usagelog (cgiargsclass &/*args*/, displayclass &disp, 745 outconvertclass &outconvert, 746 ostream &textout, ostream &/*logout*/) { 747 748 // output last 100 lines of usage.txt 749 750 text_t logfilename = filename_cat (gsdlhome, "etc", "usage.txt"); 751 752 textout << outconvert << disp << "_status:infoheader_(Usage log)\n"; 753 textout << outconvert << "<h2>Usage log</h2>\n"; 754 755 textout << outconvert << "<p>The usage log, " 756 << logfilename << ", contains the\n" 757 << "following information:\n" 758 << "<p>(note that if this file is more than 100 lines long only the last 100 lines will\n" 759 << "be displayed on this page)\n\n" 760 << "<pre>\n"; 761 762 // note that we're expecting lines to be no more than 1500 characters on 763 // average - should fix this file_tail() thing sometime 764 textout << outconvert << file_tail (logfilename, 100, 1500); 765 766 textout << outconvert << disp << "</pre>\n" 767 << "_status:infofooter_\n"; 768 } 769 744 770 void statusaction::output_initlog (cgiargsclass &/*args*/, displayclass &disp, 745 771 outconvertclass &outconvert, … … 762 788 if (initin) { 763 789 textout << outconvert << "<p>The initialisation error log, " 764 790 << initfilename << ", contains the\n"; 765 791 textout << outconvert << "following information:\n\n"; 766 792 text_t errorpage = "<p><pre>\n"; … … 779 805 } else { 780 806 textout << outconvert << "Couldn't read initialisation error log, " 781 807 << initfilename << ".\n"; 782 808 } 783 809 … … 1107 1133 else if (arg_p == "protocolinfo") output_protocolinfo (args, disp, outconvert, textout, logout); 1108 1134 else if (arg_p == "collectioninfo") output_collectioninfo (args, disp, outconvert, textout, logout); 1135 else if (arg_p == "usagelog") output_usagelog (args, disp, outconvert, textout, logout); 1109 1136 else if (arg_p == "initlog") output_initlog (args, disp, outconvert, textout, logout); 1110 1137 else if (arg_p == "errorlog") output_errorlog (args, disp, outconvert, textout, logout); -
trunk/gsdl/src/recpt/statusaction.h
r1794 r1837 75 75 ostream &textout, ostream &logout); 76 76 77 void output_usagelog (cgiargsclass &args, displayclass &disp, 78 outconvertclass &outconvert, 79 ostream &textout, ostream &logout); 80 77 81 void output_initlog (cgiargsclass &args, displayclass &disp, 78 82 outconvertclass &outconvert,
Note:
See TracChangeset
for help on using the changeset viewer.