Back to index

plt-scheme  4.2.1
Defines | Functions
Utilities.h File Reference
#include "Net.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define min(a, b)   ((a)<(b)?(a):(b))
#define max(a, b)   ((a)>(b)?(a):(b))
#define wxNumberOf(arr)   ((int)(sizeof(arr)/sizeof(arr[0])))
#define DirExists   wxDirExists
#define FileExists   wxFileExists
#define FileNameFromPath   wxFileNameFromPath
#define PathOnly   wxPathOnly

Functions

void wxExit (void)
void wxFlushEvents (void)
Bool wxYield (void)
Bool wxDirExists (char *dirname)
Bool wxFileExists (char *filename)
Bool wxRemoveFile (char *filename)
char * wxFileNameFromPath (char *path)
char * wxPathOnly (char *path)
char * wxGetUserHome (const char *user)
char * wxGetTempFileName (char *prefix, char *dest)
char * copystring (const char *s)
void wxGetLabelAndKey (char *label, char **clean_label, char **clean_key)
char * wxStripMenuCodes (char *in, char *out)
Bool wxColourDisplay (void)
int wxDisplayDepth (void)
void wxDisplaySize (int *width, int *height, int flags=0)
void wxDisplayOrigin (int *x, int *y)
void wxBeginBusyCursor (wxCursor *cursor=wxHOURGLASS_CURSOR)
void wxEndBusyCursor (void)
Bool wxIsBusy (void)
void wxHideCursor (void)
void wxUnhideCursor (void)
int wxCheckHiddenCursors ()
int wxUnhideCursorInFrame (wxObject *o, int busy)
void wxDebugMsg (const char *fmt,...)
void wxError (const char *msg, const char *title="wxWindows Error")
Bool wxExecute (char **argv, Bool Async=FALSE)
Bool wxExecute (const char *command, Bool Async=FALSE)
void wxFatalError (const char *msg, const char *title="wxWindows Fatal Error")
char * wxNow (void)
Bool wxGetResource (const char *section, const char *entry, char **value, const char *file=NULL)
Bool wxGetResource (const char *section, const char *entry, float *value, const char *file=NULL)
Bool wxGetResource (const char *section, const char *entry, long *value, const char *file=NULL)
Bool wxGetResource (const char *section, const char *entry, int *value, const char *file=NULL)
Bool wxWriteResource (const char *section, const char *entry, char *value, const char *file=NULL)
Bool wxWriteResource (const char *section, const char *entry, float value, const char *file=NULL)
Bool wxWriteResource (const char *section, const char *entry, long value, const char *file=NULL)
Bool wxWriteResource (const char *section, const char *entry, int value, const char *file=NULL)

Define Documentation

#define DirExists   wxDirExists

Definition at line 56 of file Utilities.h.

#define FileExists   wxFileExists

Definition at line 57 of file Utilities.h.

Definition at line 58 of file Utilities.h.

#define max (   a,
  b 
)    ((a)>(b)?(a):(b))

Definition at line 37 of file Utilities.h.

#define min (   a,
  b 
)    ((a)<(b)?(a):(b))

Definition at line 35 of file Utilities.h.

#define PathOnly   wxPathOnly

Definition at line 59 of file Utilities.h.

#define wxNumberOf (   arr)    ((int)(sizeof(arr)/sizeof(arr[0])))

Definition at line 39 of file Utilities.h.


Function Documentation

char* copystring ( const char *  s)

Definition at line 36 of file String.cc.

{
  size_t len;
  char *news;

  if (s == NULL) s = "";
  len = strlen (s) + 1;
  news = new WXGC_ATOMIC char[len];
  memcpy(news, s, len);        // Should be the fastest
  return news;
}

Here is the caller graph for this function:

Definition at line 128 of file BusyCursor.cc.

{
  int busy;

  busy = wxGetBusyState();
  if (busy >= 0) {
    busy++;
    wxSetBusyState(busy);
  } else {
    /* Blanked, so "increment", but don't change cursor */
    --busy;
    wxSetBusyState(busy);
    return;
  }

  if (busy == 1) {
    set_all_cursors(NULL, cursor);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 211 of file BusyCursor.cc.

{
  if (some_hidden) {
    some_hidden = 0;
    return 1;
  }
  return 0;
}

Definition at line 37 of file GDI.cc.

{
    return (wxDisplayDepth() > 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void wxDebugMsg ( const char *  fmt,
  ... 
)
Bool wxDirExists ( char *  dirname)

Definition at line 33 of file Directory.cc.

{
    struct stat sbuf;
    return ((stat(dir, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE);
}

Here is the caller graph for this function:

Definition at line 32 of file GDI.cc.

{
  return wx_visual_depth;
}

Here is the caller graph for this function:

void wxDisplayOrigin ( int x,
int y 
)

Definition at line 53 of file GDI.cc.

{
  *x = *y = 0;
}

Here is the caller graph for this function:

void wxDisplaySize ( int width,
int height,
int  flags = 0 
)

Definition at line 42 of file GDI.cc.

{
  if (wxTheApp) {
      *width = DisplayWidth(wxAPP_DISPLAY, DefaultScreen(wxAPP_DISPLAY));
      *height = DisplayHeight(wxAPP_DISPLAY, DefaultScreen(wxAPP_DISPLAY));
  } else {
      *width = 1024; // a good bet
      *height = 768;
  }
}

Here is the caller graph for this function:

Definition at line 150 of file BusyCursor.cc.

{
  int busy;

  busy = wxGetBusyState();
  if ((busy == 0) || (busy == -1))
    return;
  if (busy > 0) {
    busy--;
    wxSetBusyState(busy);
  } else {
    /* Blanked, so "decrement", but don't change cursor */
    busy++;
    wxSetBusyState(busy);
    return;
  }

  if (busy == 0) {
    set_all_cursors(NULL, NULL);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void wxError ( const char *  msg,
const char *  title = "wxWindows Error" 
)

Definition at line 45 of file Error.cc.

{  
    fprintf(stderr, "%s: %s\n", title, msg);
}

Here is the caller graph for this function:

Bool wxExecute ( char **  argv,
Bool  Async = FALSE 
)
Bool wxExecute ( const char *  command,
Bool  Async = FALSE 
)
void wxExit ( void  )

Definition at line 35 of file Application.cc.

{
  int v;
  v = wxTheApp->OnExit();
  exit(v);
}

Here is the call graph for this function:

void wxFatalError ( const char *  msg,
const char *  title = "wxWindows Fatal Error" 
)

Definition at line 50 of file Error.cc.

{
    fprintf(stderr, "%s: %s\n", title, msg);
    exit(1);
}

Here is the caller graph for this function:

Bool wxFileExists ( char *  filename)

Definition at line 39 of file Directory.cc.

{
    struct stat stbuf;

    return (filename && !stat((char *)filename, &stbuf));
}

Here is the caller graph for this function:

char* wxFileNameFromPath ( char *  path)

Definition at line 31 of file Path.cc.

{
    if (path) {
      int tcp, slen;
      
      tcp = slen = strlen(path);
      while (--tcp >= 0) {
       if (path[tcp] == '/') {
         char *naya;
         tcp++;
         naya = new WXGC_ATOMIC char[slen + 1 - tcp];
         memcpy(naya, path + tcp, slen + 1 - tcp);
         return naya;
       }
      }
    }

    return path;
}

Here is the caller graph for this function:

Definition at line 46 of file Application.cc.

{
}
void wxGetLabelAndKey ( char *  label,
char **  clean_label,
char **  clean_key 
)

Definition at line 61 of file String.cc.

{
    char *key, *s;

    s = copystring(label); // make private copy
    *clean_label = s;
#if 0
    char *amp;
    if ((amp = strchr(*clean_label, '&'))) { // is there an ampersand? -> erase
       memmove(amp, amp+1, strlen(amp+1) + 1);
    }
#endif
    if ((key=strchr(*clean_label, '\t'))) // is there a key binding? -> split
       *key++ ='\0';
    if (clean_key)
      *clean_key = key; // point to key binding in private copy
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool wxGetResource ( const char *  section,
const char *  entry,
char **  value,
const char *  file = NULL 
)

Definition at line 215 of file Resources.cc.

{
    XrmValue xvalue;
    char *str_type[20];
    char buf[150];
    Bool success;
    XrmDatabase database;

    if (!wxResourceDatabase)
       wxXMergeDatabases();

    if (file) {
      char buffer[500];
      wxNode *node;

      (void)GetIniFile(buffer, file);
      
      node = wxResourceCache->Find(buffer);
      if (node)
       database = (XrmDatabase)node->Data();
      else {
       database = wxXrmGetFileDatabase(buffer);
       wxResourceCache->Append(buffer, (wxObject *)database);
      }
    } else
      database = wxResourceDatabase;
    
    strcpy(buf, section);
    strcat(buf, ".");
    strcat(buf, entry);

    success = XrmGetResource(database, buf, "*", str_type, &xvalue);
    if (success) {
      char *v;
      v = new WXGC_ATOMIC char[xvalue.size + 1];
      *value = v;
      strncpy(*value, xvalue.addr, (int)xvalue.size);
      return TRUE;
    }
    return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool wxGetResource ( const char *  section,
const char *  entry,
float *  value,
const char *  file = NULL 
)

Definition at line 258 of file Resources.cc.

{
  char *s = NULL;
  Bool succ;
  succ = wxGetResource(section, entry, &s, file);
  if (succ) {
    float v;
    v = (float)strtod(s, NULL);
    *value = v;
    return TRUE;
  } else
    return FALSE;
}

Here is the call graph for this function:

Bool wxGetResource ( const char *  section,
const char *  entry,
long *  value,
const char *  file = NULL 
)

Definition at line 273 of file Resources.cc.

{
  char *s = NULL;
  Bool succ;
  succ = wxGetResource(section, entry, &s, file);
  if (succ) {
    long v;
    v = strtol(s, NULL, 10);
    *value = v;
    return TRUE;
  } else
    return FALSE;
}

Here is the call graph for this function:

Bool wxGetResource ( const char *  section,
const char *  entry,
int value,
const char *  file = NULL 
)

Definition at line 288 of file Resources.cc.

{
    char *s = NULL;
    Bool succ;
    succ = wxGetResource(section, entry, &s, file);
    if (succ) {
       // Handle True, False here 
       // True, Yes, Enables, Set or  Activated 
       if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
           *value = TRUE;
       // False, No, Disabled, Reset, Cleared, Deactivated
       else if (*s == 'F' || *s == 'N' || *s == 'D' || *s == 'R' || *s == 'C')
           *value = FALSE;
       // Handle as Integer
       else {
         int v;
         v = (int)strtol(s, NULL, 10);
         *value = v;
       }
       return TRUE;
    } else
       return FALSE;
}

Here is the call graph for this function:

char* wxGetTempFileName ( char *  prefix,
char *  dest 
)

Definition at line 32 of file TempFile.cc.

{
    static short last_temp = 0;    // cache last to speed things a bit
    // At most 1000 temp files to a process! We use a ring count.
    char buf[64];
    short suffix;

    for (suffix = last_temp + 1; suffix != last_temp; ++suffix %= 1000) {
      int pid;
      pid = (int)getpid();
      sprintf (buf, "/tmp/%s%d.%03x", prefix, pid, (int)suffix);
      if (!wxFileExists(buf)) {
       // Touch the file to create it (reserve name)
       FILE *fd;
       fd = fopen (buf, "w");
       if (fd)
         fclose (fd);
       last_temp = suffix;
       if (dest)
         strcpy(dest, buf);
       else {
         dest = copystring(buf);
       }
       return dest;
       }
    }
    
    wxError("wxWindows: error finding temporary file name.");
    if (dest) dest[0] = 0;

    return NULL;
}

Here is the call graph for this function:

char* wxGetUserHome ( const char *  user)

Definition at line 34 of file Home.cc.

{
    struct passwd *who = NULL;

    if (user == NULL || *user == '\0') {
       register char *ptr;

       if ((ptr = getenv("HOME")) != NULL) 
           return ptr;
       if ((ptr = getenv("USER")) != NULL
       || (ptr = getenv("LOGNAME")) != NULL) {
           who = getpwnam(ptr);
       }
       // We now make sure the user exists!
       if (who == NULL)
           who = getpwuid(getuid());
    } else
       who = getpwnam (user);
    return who ? who->pw_dir : (char*)NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 182 of file BusyCursor.cc.

{
  int busy;
  busy = wxGetBusyState();

  if (busy >= 0) {
    some_hidden++;
    busy = -(busy + 1);
    wxSetBusyState(busy);
    set_all_cursors(NULL, wxBLANK_CURSOR);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 172 of file BusyCursor.cc.

{
  int busy;
  busy = wxGetBusyState();
  return ((busy > 0) || (busy < -1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* wxNow ( void  )

Definition at line 35 of file Date+Time.cc.

{
    time_t now;
    char *date;
    now = time(NULL);
    date = ctime(&now); 
    date[24] = '\0';
    return date;
}
char* wxPathOnly ( char *  path)

Definition at line 51 of file Path.cc.

{
  if (path) {
    int p, last_slash = 0;
    char *buf;

    buf = new WXGC_ATOMIC char[strlen(path) + 1];
    
    // copy path and keep the last slash or baskslash in mind
    for (p = 0; path[p]; p++) {
      buf[p] = path[p];
      if (buf[p] == '/')
       last_slash = p;
    }
    if (last_slash) {
      buf[last_slash] = 0;
      return buf;
    }
  }

  return NULL;
}
Bool wxRemoveFile ( char *  filename)

Definition at line 46 of file Directory.cc.

{
    return !unlink(file);
}
char* wxStripMenuCodes ( char *  in,
char *  out 
)

Definition at line 3018 of file wxscheme.cxx.

{
  int i, j, cnt;
  char *naya;

  if (!label)
    return NULL;
  
  for (i = 0; label[i]; i++) {
    if ((label[i] == '&')
       || (label[i] == '\t')) {
      /* Strip it: */
      if (target)
       naya = target;
      else
       naya = new WXGC_ATOMIC char[strlen(label) + 1];
      j = 0;
      for (i = 0; label[i]; i++) {
        if (label[i] == '&') {
          if (label[i + 1]) {
            naya[j++] = label[i + 1];
            i++;
          }
        } else if (label[i] == '\t') {
         break;
       } else if ((cnt = starts_paren_accel(label, i))) {
         i += (cnt - 1);
       } else {
          naya[j++] = label[i];
       }
      }
      naya[j] = 0;
      
      return naya;
    }
  }

  if (target)
    strcpy(target, label);
  
  return label;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 196 of file BusyCursor.cc.

{
  int busy;
  busy = wxGetBusyState();

  if (busy < 0) {
    if (some_hidden)
      --some_hidden;
    busy = -(busy + 1);
    wxSetBusyState(busy);
    set_all_cursors(NULL, (busy > 0) ? wxHOURGLASS_CURSOR : NULL);
  }  
}

Here is the call graph for this function:

Here is the caller graph for this function:

int wxUnhideCursorInFrame ( wxObject o,
int  busy 
)

Definition at line 222 of file BusyCursor.cc.

{
  if (busy < 0) {
    busy = -(busy + 1);
    set_all_cursors(o, (busy > 0) ? wxHOURGLASS_CURSOR : NULL);
  }
  return busy;
}

Here is the call graph for this function:

Bool wxWriteResource ( const char *  section,
const char *  entry,
char *  value,
const char *  file = NULL 
)

Definition at line 150 of file Resources.cc.

{
    char buffer[500];
    char resName[300];
    int isnull;
    XrmDatabase database;
    wxNode *node;

    if (!entry)
      return FALSE;

    (void)GetIniFile(buffer, file);

    node = wxResourceCache->Find(buffer);
    if (node)
      database = (XrmDatabase)node->Data();
    else {
      database = wxXrmGetFileDatabase(buffer);
      node = wxResourceCache->Append(buffer, (wxObject *)database);
    }
    strcpy(resName, section ? section : "wxWindows");
    strcat(resName, ".");
    strcat(resName, entry);

    isnull = !database;
    XrmPutStringResource(&database, resName, value);
    if (isnull) {
      if (node)
       wxResourceCache->DeleteNode(node);
      wxResourceCache->Append(buffer, (wxObject *)database);
    }

    XrmPutFileDatabase(database, buffer);

    return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool wxWriteResource ( const char *  section,
const char *  entry,
float  value,
const char *  file = NULL 
)

Definition at line 188 of file Resources.cc.

{
    char buf[50];
    sprintf(buf, "%.4f", value);
    return wxWriteResource(section, entry, buf, file);
}

Here is the call graph for this function:

Bool wxWriteResource ( const char *  section,
const char *  entry,
long  value,
const char *  file = NULL 
)

Definition at line 196 of file Resources.cc.

{
    char buf[50];
    sprintf(buf, "%ld", value);
    return wxWriteResource(section, entry, buf, file);
}

Here is the call graph for this function:

Bool wxWriteResource ( const char *  section,
const char *  entry,
int  value,
const char *  file = NULL 
)

Definition at line 204 of file Resources.cc.

{
    char buf[50];
    sprintf(buf, "%d", value);
    return wxWriteResource(section, entry, buf, file);
}

Here is the call graph for this function:

Bool wxYield ( void  )

Definition at line 54 of file Application.cc.

{
  int ever = 0;
  int one_more;

  do {
    XFlush(wxAPP_DISPLAY);
    XSync(wxAPP_DISPLAY, FALSE);
    one_more = 0;
    while (wxTheApp->Pending()) {
      one_more = 1;
      ever = 1;
      wxTheApp->Dispatch();
    }
  } while (one_more);

  return ever;
}

Here is the call graph for this function:

Here is the caller graph for this function: