Changeset 3007
- Timestamp:
- 2002-02-27T11:50:16+13:00 (22 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/collectoraction.cpp
r2908 r3007 45 45 #include "argdb.h" 46 46 #include "cgiutils.h" 47 #include <stdio.h> 48 #include <fcntl.h> 47 49 48 50 #if !defined (__WIN32__) … … 581 583 582 584 // now write cfg file back out 583 #ifdef __WIN32__ 584 ofstream cfg_out (cfgfilec, ios::binary); 585 #else 586 ofstream cfg_out (cfgfilec); 585 int fd=open(cfgfilec, O_WRONLY | O_CREAT | O_TRUNC 586 #if defined(__WIN32__) 587 | O_BINARY 587 588 #endif 588 if (cfg_out) { 589 ); 590 591 if (fd != -1) { 589 592 // lock the file 590 int fd = GSDL_GET_FILEDESC(cfg_out);591 593 int lock_val = 1; 592 594 GSDL_LOCK_FILE (fd); 593 595 if (lock_val != 0) { 594 596 logout << "Error: Couldn't lock file " << cfgfilec << "\n"; 595 c fg_out.close();597 close(fd); 596 598 message = "tmpfail"; 597 599 … … 601 603 vector<text_tarray>::const_iterator end_line = cfgarray.end(); 602 604 while (this_line != end_line) { 603 write_cfg_line ( cfg_out, *this_line);605 write_cfg_line (fd, *this_line); 604 606 this_line ++; 605 607 } 606 608 GSDL_UNLOCK_FILE (fd); 607 c fg_out.close();609 close(fd); 608 610 } 609 611 … … 633 635 // make sure collect.cfg isn't read-only 634 636 _chmod (cfgfilec, _S_IREAD | _S_IWRITE); 635 ofstream cfg_out (cfgfilec, ios::binary);636 #else637 ofstream cfg_out (cfgfilec);638 637 #endif 639 640 if (cfg_out) { 638 639 int fd=open(cfgfilec, O_WRONLY | O_CREAT | O_TRUNC 640 #if defined(__WIN32__) 641 | O_BINARY 642 #endif 643 ); 644 645 if (fd) { 641 646 // lock the file 642 int fd = GSDL_GET_FILEDESC(cfg_out);643 647 int lock_val = 1; 644 648 GSDL_LOCK_FILE (fd); 645 649 if (lock_val != 0) { 646 650 logout << "Error: Couldn't lock file " << cfgfilec << "\n"; 647 c fg_out.close();651 close(fd); 648 652 message = "tmpfail"; 649 653 … … 651 655 652 656 outconvertclass text_t2ascii; 653 cfg_out << text_t2ascii << args["cfgfile"]; 657 text_t2ascii << args["cfgfile"]; 658 size_t buffersize=args["cfgfile"].size(); 659 char *buffer=new char[buffersize]; 660 size_t num_chars; 661 convertclass::status_t status; 662 text_t2ascii.convert(buffer, buffersize, num_chars, status); 663 // ignore status - assume it is "finished" as buffer is big enough 664 write(fd, buffer, num_chars); 654 665 GSDL_UNLOCK_FILE (fd); 655 cfg_out.close(); 666 close(fd); 667 delete buffer; 656 668 657 669 // now that we've written the file we'll read it back again and … … 1490 1502 shortname.clear(); 1491 1503 int use_words = (num_words <= 6) ? num_words : 6; 1492 int substr_len = 6 / use_words;1504 unsigned int substr_len = 6 / use_words; 1493 1505 1494 1506 for (int i = 0; i < use_words; i++) { -
trunk/gsdl/src/recpt/receptionist.cpp
r2957 r3007 37 37 #include <assert.h> 38 38 #include <time.h> 39 #include <stdio.h> 39 #include <stdio.h> // for open() 40 #include <fcntl.h> // for open() flags 40 41 // following 2 are for printing Last-Modified http header. 41 42 #include <sys/stat.h> … … 695 696 char *lfile = filename.getcstr(); 696 697 697 ofstream log (lfile, ios::app);698 699 if ( !log) {698 int fd = open(lfile,O_APPEND); 699 700 if (fd == -1) { 700 701 logout << "Error: Couldn't open file " << lfile << "\n"; 701 702 delete lfile; … … 703 704 } 704 705 705 int fd = GSDL_GET_FILEDESC(log);706 //int fd = GSDL_GET_FILEDESC(log); 706 707 707 708 // lock_val is set to 0 if file is locked successfully … … 709 710 GSDL_LOCK_FILE (fd); 710 711 if (lock_val == 0) { 711 log << text_t2utf8 << logstr; 712 text_t2utf8 << logstr; 713 char *buffer=new char[logstr.size()]; 714 size_t num_chars; 715 convertclass::status_t status; 716 text_t2utf8.convert(buffer, logstr.size(), num_chars, status); 717 // ignore status - assume it is "finished" as buffer is big enough 718 write(fd, buffer, num_chars); 712 719 GSDL_UNLOCK_FILE (fd); 720 delete buffer; 713 721 } else { 714 722 logout << "Error: Couldn't lock file " << lfile << "\n"; 715 log.close();723 close(fd); 716 724 delete lfile; 717 725 return false; 718 726 } 719 727 720 log.close();728 close(fd); 721 729 722 730 delete lfile; … … 797 805 contentout << "Last-Modified: " << asctime(utc_latest); 798 806 } 799 } 807 } // end of collection != "" 800 808 801 809 /* -
trunk/gsdl/src/recpt/statusaction.cpp
r2939 r3007 32 32 #include "gsdltools.h" 33 33 #include <assert.h> 34 34 #include <stdio.h> 35 #include <fcntl.h> // for open() stuff 35 36 36 37 void statusaction::output_frameset (cgiargsclass &/*args*/, displayclass &disp, … … 885 886 text_t cfgfile = filename_cat(gsdlhome, "etc", "main.cfg"); 886 887 char *cfgfilec = cfgfile.getcstr(); 887 #ifdef __WIN32__ 888 ofstream cfg_out (cfgfilec, ios::binary);889 # else890 ofstream cfg_out (cfgfilec); 888 889 int fd=open(cfgfilec, O_WRONLY | O_CREAT | O_TRUNC 890 #if defined(__WIN32__) 891 | O_BINARY 891 892 #endif 892 893 if (cfg_out) { 894 // lock the file895 int fd = GSDL_GET_FILEDESC(cfg_out); 893 ); 894 895 if (fd != -1) { 896 896 897 int lock_val = 1; 897 898 GSDL_LOCK_FILE (fd); 898 899 if (lock_val != 0) { 899 900 logout << "statusaction::change_maincfg: Error: Couldn't lock file " << cfgfilec << "\n"; 900 cfg_out.close();901 901 textout << outconvert << disp << "_status:changemaincfgfail_"; 902 902 close (fd); 903 903 } else { 904 905 904 outconvertclass text_t2ascii; 906 cfg_out << text_t2ascii << args["cfgfile"]; 905 text_t2ascii << args["cfgfile"]; 906 size_t buffersize=args["cfgfile"].size(); 907 char *buffer=new char[buffersize]; 908 size_t num_chars; 909 convertclass::status_t status; 910 text_t2ascii.convert(buffer, buffersize, num_chars, status); 911 // ignore status - assume it is "finished" as buffer is big enough 912 write(fd, buffer, num_chars); 907 913 GSDL_UNLOCK_FILE (fd); 908 cfg_out.close(); 914 delete buffer; 915 close (fd); 909 916 textout << outconvert << disp << "_status:changemaincfgsuccess_"; 910 917 } … … 913 920 textout << outconvert << disp << "_status:changemaincfgfail_"; 914 921 } 922 delete cfgfilec; 915 923 } 916 924
Note:
See TracChangeset
for help on using the changeset viewer.