Ignore:
Timestamp:
2000-07-13T10:21:53+12:00 (24 years ago)
Author:
sjboddie
Message:

merged changes to trunk into New_Config_Format branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/New_Config_Format-branch/gsdl/lib/gsdltools.cpp

    r1076 r1279  
    2828/*
    2929   $Log$
     30   Revision 1.3.2.1  2000/07/12 22:20:55  sjboddie
     31   merged changes to trunk into New_Config_Format branch
     32
     33   Revision 1.5  2000/05/19 04:56:01  sjboddie
     34   added gsdl_system function for spawning off new processes under windows
     35
     36   Revision 1.4  2000/05/04 05:16:23  sjboddie
     37   Moved dm_safe from htmlutils to gsdltools. Also made it escape '\'
     38   characters to prevent their mysterious disapearance from things like
     39   windows filenames when they get passed through the macro expander.
     40
    3041   Revision 1.3  2000/04/06 19:58:01  cs025
    3142   Correcting a correction - reinstated all lib files due to silly
     
    4960}
    5061
     62text_t dm_safe (const text_t &instring) {
    5163
     64  text_t outstring;
     65  text_t::const_iterator here = instring.begin();
     66  text_t::const_iterator end = instring.end();
     67  while (here != end) {
     68    if (*here == '_' || *here == '\\') outstring.push_back('\\');
     69    outstring.push_back(*here);
     70    here ++;
     71  }
     72  return outstring;
     73}
     74
     75// gsdl_system spawns a completely separate program (i.e. the calling
     76// program continues and terminates normally). Arguments containing special
     77// characters (e.g. '&') should be quoted with ""
     78
     79// on unix systems youcan get the same effext as this function by doing a
     80// system call and putting the spawned process in the background
     81// (e.g. system (funcname options &);
     82
     83#if defined (__WIN32__)
     84#include <windows.h>
     85void gsdl_system (char *cmd, ostream &logout) {
     86
     87  STARTUPINFO ps = {sizeof(STARTUPINFO), NULL, NULL, NULL,
     88                    0, 0, 0, 0, 0, 0,
     89                    0, 0,
     90                    0, 0, NULL,
     91                    NULL, NULL, NULL};
     92  PROCESS_INFORMATION pi;
     93  BOOL res = CreateProcess(NULL,
     94                           cmd,
     95                           NULL,
     96                           NULL,
     97                           FALSE,
     98                           DETACHED_PROCESS,
     99                           NULL,
     100                           NULL,
     101                           &ps,
     102                           &pi);
     103  if (!res) {
     104    logout << "Failed to start " << cmd << " process, error code " << GetLastError();
     105  }
     106
     107  CloseHandle(pi.hProcess);
     108  CloseHandle(pi.hThread);
     109}
     110
     111#endif
Note: See TracChangeset for help on using the changeset viewer.