WWW: Local file handling (PATCH)

dcmartin@ckm.ucsf.edu (David C. Martin)
Message-id: <9305111724.AA25897@knowman.lib.ucsf.EDU>
From: dcmartin@ckm.ucsf.edu (David C. Martin)
Organization: UCSF Center for Knowledge Management
Email: dcmartin@ckm.ucsf.edu or uunet!dcmartin
Phone: 415/476-6111
Fax: 415/476-4653
To: "Peter Lister, Cranfield Computer Centre" <ccprl@xdm001.ccc.cranfield.ac.uk>
Cc: timbl@nxoc01.cern.ch, www-talk@nxoc01.cern.ch, marca@ncsa.uiuc.edu
In-reply-to: Your message of Tue, 11 May 93 17:16:32 +0000
	<9305111616.AA15294@xdm039> 
Subject: WWW: Local file handling (PATCH)
Date: Tue, 11 May 93 10:27:14 MDT
Sender: dcmartin@lib.ucsf.edu
*** gui2.c-orig	Sat Apr 17 22:52:44 1993
--- gui2.c	Tue May 11 10:12:54 1993
***************
*** 258,284 ****
  
  /* ---------------------- mo_post_open_local_window ----------------------- */
  
  static XmxCallback (open_local_win_cb)
  {
!   char *fname;
!   char *url;
!   mo_window *win = mo_fetch_window_by_id (XmxExtractUniqid ((int)client_data));
  
!   XtUnmanageChild (win->open_local_win);
!   fname = (char *)malloc (128 * sizeof (char));
    
!   XmStringGetLtoR (((XmFileSelectionBoxCallbackStruct *)call_data)->value,
!                    XmSTRING_DEFAULT_CHARSET,
!                    &fname);
! 
!   url = (char *)malloc 
!     ((strlen (fname) + strlen (shortmachine) + 16) * sizeof (char));
!   sprintf (url, "file://%s%s\0", shortmachine, fname);
!   if (url[strlen(url)-1] == '/')
!     url[strlen(url)-1] = '\0';
!   mo_load_window_text (win, url, NULL);
! 
!   return;
  }
  
  mo_status mo_post_open_local_window (mo_window *win)
--- 258,292 ----
  
  /* ---------------------- mo_post_open_local_window ----------------------- */
  
+ #include <sys/param.h>
+ 
  static XmxCallback (open_local_win_cb)
  {
!     char	buf[MAXPATHLEN];
!     int		bufsiz = 0;
!     char*	fname;
!     char*	url;
!     mo_window*	win = mo_fetch_window_by_id(XmxExtractUniqid((int)client_data));
  
!     XtUnmanageChild (win->open_local_win);
!     fname = (char *)malloc (128 * sizeof (char));
    
!     XmStringGetLtoR (((XmFileSelectionBoxCallbackStruct *)call_data)->value,
! 		     XmSTRING_DEFAULT_CHARSET,
! 		     &fname);
!     if ((bufsiz = readlink(fname, &buf)) > 0) {
! 	url = (char*) malloc((bufsiz + 1) * sizeof(char));
! 	buf[bufsiz] = (char) NULL;
! 	(void) strcpy(url, buf);
!     } else {
! 	url = (char*) malloc((strlen (fname) + strlen (shortmachine) + 16) * 
! 			     sizeof (char));
! 	sprintf (url, "file://%s%s\0", shortmachine, fname);
! 	if (url[strlen(url)-1] == '/')
! 	    url[strlen(url)-1] = '\0';
!     }
!     mo_load_window_text (win, url, NULL);
!     return;
  }
  
  mo_status mo_post_open_local_window (mo_window *win)