/* -*- Mode:C; tab-width: 8 -*- * netscape-snapshot 1.0.1 (12 Feb 1997) * TRIVIALLY derived from remote.c 1.1.0 * by Adam M. Costello * * To compile (requires ANSI C): * cc -o netscape-snapshot netscape-snapshot.c -lXmu -lX11 * * To use: * netscape-snapshot * * The titles and URLs of all netscape windows are printed to stdout. * * Original comments: * * remote.c --- remote control of Netscape Navigator for Unix. * version 1.1.0, for Netscape Navigator 1.1 and newer. * * Copyright © 1995 Netscape Communications Corporation, all rights reserved. * Created: Jamie Zawinski , 24-Dec-94. * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation. No representations are made about the suitability of this * software for any purpose. It is provided "as is" without express or * implied warranty. * * To compile: * * cc -o netscape-remote remote.c -DSTANDALONE -lXmu -lX11 * * To use: * * netscape-remote -help * * Documentation for the protocol which this code implements may be found at: * * http://home.netscape.com/newsref/std/x-remote.html * * Bugs and commentary to x_cbug@netscape.com. */ #include #include #include #include #include #include #include /* for XmuClientWindow() */ /* vroot.h is a header file which lets a client get along with `virtual root' window managers like swm, tvtwm, olvwm, etc. If you don't have this header file, you can find it at "http://home.netscape.com/newsref/std/vroot.h". If you don't care about supporting virtual root window managers, you can comment this line out. */ #include /* AMC */ #define STANDALONE /* AMC */ #ifdef STANDALONE static const char *progname = 0; static const char *expected_mozilla_version = "1.1N"; #else /* !STANDALONE */ extern const char *progname; extern const char *expected_mozilla_version; #endif /* !STANDALONE */ #define MOZILLA_URL "_MOZILLA_URL" #define WM_NAME "WM_NAME" static Atom XA_MOZILLA_URL = 0; static Window mozilla_remote_find_window (Display *dpy) { int i; Window root = RootWindowOfScreen (DefaultScreenOfDisplay (dpy)); Window root2, parent, *kids; unsigned int nkids; Window result = 0; Window tenative = 0; unsigned char *tenative_version = 0; XA_MOZILLA_URL = XInternAtom (dpy, MOZILLA_URL, False); if (! XQueryTree (dpy, root, &root2, &parent, &kids, &nkids)) abort (); if (root != root2) abort (); if (parent) abort (); if (! (kids && nkids)) abort (); for (i = 0; i < nkids; i++) { Atom type; int format; unsigned long nitems, bytesafter; unsigned char *url = 0; unsigned char *title = 0; Window w = XmuClientWindow (dpy, kids[i]); int status = XGetWindowProperty (dpy, w, XA_MOZILLA_URL, 0, (65536 / sizeof (long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &url); if (url) { status = XGetWindowProperty (dpy, w, XA_WM_NAME, 0, (65536 / sizeof (long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &title); fprintf(stdout, "%s\n%s\n\n", title, url); /* AMC */ } } } int mozilla_remote_commands (Display *dpy, Window window, char **commands) { Bool raise_p = True; int status = 0; Atom type; int format; unsigned long nitems, bytesafter; unsigned char *url = 0; window = mozilla_remote_find_window (dpy); } #ifdef STANDALONE void main (int argc, char **argv) { Display *dpy; char *dpy_string = 0; char **remote_commands = 0; int remote_command_count = 0; int remote_command_size = 0; unsigned long remote_window = 0; Bool sync_p = False; int i; dpy = XOpenDisplay (dpy_string); if (! dpy) exit (-1); if (sync_p) XSynchronize (dpy, True); exit (mozilla_remote_commands (dpy, (Window) remote_window, remote_commands)); } #endif /* STANDALONE */