WWW: Local file handling (PATCH)
David C. Martin ([email protected])
Tue, 11 May 93 10:27:14 MDT
*** 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)