diff --git a/doc/.cvsignore b/doc/.cvsignore deleted file mode 100644 index b5e570d5..00000000 --- a/doc/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile.in -Makefile -gnome-hackers -libgtop -libgtop-ref -table -*.ced -*.fot diff --git a/doc/ChangeLog b/doc/ChangeLog deleted file mode 100644 index 2882b812..00000000 --- a/doc/ChangeLog +++ /dev/null @@ -1,25 +0,0 @@ -1998-10-12 Martin Baulig - - * Makefile.am: New file. We are now using automake here. - * libgtopConf.sh: Removed. Since libgtop-docu now requires - LibGTop to be installed we use the installed version of this file. - * Makefile: Removed. - -1998-08-12 Martin Baulig - - * features: New directory. - * gnome-hackers.sgml: Updated documentation. - -1998-08-11 Martin Baulig - - * gnome-hackers.sgml: Updated documentation. - * autoconf.sgml: New file, included from `gnome-hackers.sgml'. - -1998-07-21 Martin Baulig - - * gnome-hackers.sgml: Added note that this file is - currently out of date and a link to the documentation - of the table () function. - - * table.sgml: New file - basic documentation for the - table () system call. diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index 79a85c62..00000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -htmldir = $(prefix)/html - -html_subdirs = libgtop gnome-hackers libgtop-ref table - -# Well, yes - you are using GNU Make, aren't you ... ? -stamp_FILES = $(addsuffix .stamp,$(html_subdirs)) -sgml_FILES = $(addsuffix .sgml,$(html_subdirs)) -dsl_FILES = $(addsuffix .dsl,$(html_subdirs)) - -EXTRA_DIST = $(sgml_FILES) $(dsl_FILES) dbtohtml.dsl autoconf.sgml - -noinst_DATA = $(stamp_FILES) - -CLEANFILES = $(stamp_FILES) - -distclean-local: - -rm -rf $(html_subdirs) - -libgtop.sgml: libgtopConf.sh - -gnome-hackers.sgml: autoconf.sgml $(top_builddir)/guile/reference.sgml \ - features/uptime.sgml features/uptime.txt features/proclist.sgml \ - features/procmem.sgml - -libgtopConf.sh: - @LN_S@ `@LIBGTOP_CONFIG@ --config` - -# You can set the $(JADE_FLAGS) in your shell to pass additional -# arguments like `-D /usr/lib/sgml' to jade. - -SUFFIXES = .stamp .sgml -.sgml.stamp: - echo rm -f $@ - -rm -rf $* - mkdir $* - jade $(JADE_FLAGS) -D $(srcdir) -D . -D $(top_builddir)/guile \ - -d $(srcdir)/$*.dsl -t sgml -V %no-make-index% $< \ - > /dev/null && touch $@ - -install-data-local: - $(mkinstalldirs) $(htmldir) - for subdir in $(html_subdirs) ; do \ - $(mkinstalldirs) $(htmldir)/$$subdir ; \ - for file in $$subdir/* ; do \ - $(INSTALL_DATA) $$file $(htmldir)/$$subdir ; \ - done \ - done - -dist-hook: - mkdir $(distdir)/features - cp -p $(srcdir)/features/*.sgml $(distdir)/features - cp -p $(srcdir)/features/*.txt $(distdir)/features - diff --git a/doc/autoconf.sgml b/doc/autoconf.sgml deleted file mode 100644 index 16bf1603..00000000 --- a/doc/autoconf.sgml +++ /dev/null @@ -1,253 +0,0 @@ - - Autoconf macros - - - All you need to check for &libgtop; is in &gnome-libgtop-check.m4;, - just use GNOME_INIT_LIBGTOP with an optional - fail argument in the same way like - GNOME_INIT: - - - Warn if &libgtop; cannot be found - - GNOME_INIT_LIBGTOP - - - - Abort if &libgtop; cannot be found - - GNOME_INIT_LIBGTOP(fail) - - - - This will define a HAVE_LIBGTOP automake - conditional and everything from the configuration script of - &libgtop;. - - - The configuration script of &libgtop; (&libgtopConf.sh;) - - - After a successful build of &libgtop;, a &libgtopConf.sh; script - containing useful configuration variables is created. - - - It defines the following variables which you can use in your - Makefile.am: - - - - LIBGTOP_LIBDIR - - - - The directory where the library files of &libgtop; are installed. - - - LIBGTOP_INCLUDEDIR - - - - The directory where the header files of &libgtop; are installed. - - - LIBGTOP_LIBS - - - - Use this to link your program with &libgtop;. - - - LIBGTOP_INCS - - - - Use this to get the header files for &libgtop;. - - - LIBGTOP_NAMES_LIBS - - - - Use this to link your program with &libgtop; and its - names interface. - - - LIBGTOP_NAMES_INCS - - - - Use this to get the header files for &libgtop; and the - required -DGLIBTOP_NAMES to get its - names interface. - - - LIBGTOP_GUILE_LIBS - - - - Use this to link your program with &libgtop; and its - guile interface. This will also include all the required - guile libraries. - - - LIBGTOP_GUILE_INCS - - - - Use this to get the header files for &libgtop; and guile - and the required -DGLIBTOP_GUILE to get - the guile interface of &libgtop;. - - - LIBGTOP_GUILE_NAMES_LIBS - - - - Use this to link your program with &libgtop; and both its - names and its guile interface. This will also include all the - required guile libraries. - - - LIBGTOP_GUILE_NAMES_INCS - - - - Use this to get the header files for &libgtop;, its guile - and its names interface, the guile header files and the - required -DGLIBTOP_GUILE and - -DGLIBTOP_NAMES. - - - LIBGTOP_BINDIR - - - - The directory where the binaries of &libgtop; are installed. - - - LIBGTOP_SERVER - - - - Full pathname of the &libgtop; server. - - - LIBGTOP_MAJOR_VERSION - - - - Major version of &libgtop;. - - - LIBGTOP_MINOR_VERSION - - - - Minor version of &libgtop;. - - - LIBGTOP_VERSION - - - - Full version of &libgtop;. - - - LIBGTOP_SERVER_VERSION - - - - Version of the &libgtop; server. This is incremented each - time the client/server protocol changes. - - - libgtop_sysdeps_dir - - - - The sysdeps directory that is used on your system. - - - libgtop_need_server - - - - Either yes or no. - - - libgtop_use_machine_h - - - - Either yes or no. - Intended for internal use only - and may be removed in future versions. - - - Note for &libgtop; hackers - - - This variable gets set in - macros/gnome-libgtop-sysdeps.m4. - - - If this is enabled, you need to put a - glibtop_machine.h header file in the - sysdeps directory which needs to define a structure of - type glibtop_machine. - - - This structure represents the - machine field of - glibtop defined in - glibtop.h - and can be used to store some - machine dependent data. - - - - libgtop_guile_found - - - - Either yes or no. - - - libgtop_want_examples - - - - Considered obsolete. - - - - - All this variables are taken from the - &libgtopConf.sh; script which is created during - the installation of &libgtop;. - - - - Sample &libgtopConf.sh; (gnome and guile are installed in - <filename>/home/baulig/INSTALL</filename> and &libgtop; in - <filename>/home/norwegen/TEST</filename>) - - - &example-libgtopConf-sh; - - - - - diff --git a/doc/catalog b/doc/catalog deleted file mode 100644 index 76a78096..00000000 --- a/doc/catalog +++ /dev/null @@ -1,3 +0,0 @@ -PUBLIC "-//James Clark//DTD DSSSL Flow Object Tree//EN" "fot.dtd" -PUBLIC "ISO/IEC 10179:1996//DTD DSSSL Architecture//EN" "dsssl.dtd" -PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" "style-sheet.dtd" diff --git a/doc/dbtohtml.dsl b/doc/dbtohtml.dsl deleted file mode 100644 index 5947abc6..00000000 --- a/doc/dbtohtml.dsl +++ /dev/null @@ -1,1627 +0,0 @@ - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; dbtohtml.dsl - DSSSL style sheet for DocBook to HTML conversion (jadeware) -; -; Author : Mark Burton (markb@ordern.com) -; Created On : Fri Jun 13 18:21:14 1997 -; Last Modified By: Mark Burton -; Last Modified On: Thu Jul 10 21:58:53 1997 -; -; $Id$ -; -; Usage: -; -; jade -d dbtohtml.dsl -t sgml yourdoc.sgm -; -; Additional command line options: -; -; -V %no-split-output% sends all the output to one file -; -V %no-make-index% disables index creation -; -V %no-make-toc% disables TOC creation -; -V %no-shade-screen% disables grey background to SCREEN regions -; -V %show-comments% includes contents of COMMENT regions - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Contributors - -; Mark Eichin (eichin@cygnus.com) -; Jason Molenda (crash@cygnus.co.jp) -; Mark Galassi (rosalia@cygnus.com) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Parameterisation - -; This style sheet can easily be parameterised by the use of a driver. -; Here is a simple example that sets the output file basename and directory. -; If the driver is foo.dsl, use: jade -d foo.dsl -t sgml yourdoc.sgm - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; declare non-standard functions - -(declare-flow-object-class element - "UNREGISTERED::James Clark//Flow Object Class::element") -(declare-flow-object-class empty-element - "UNREGISTERED::James Clark//Flow Object Class::empty-element") -(declare-flow-object-class document-type - "UNREGISTERED::James Clark//Flow Object Class::document-type") -(declare-flow-object-class processing-instruction - "UNREGISTERED::James Clark//Flow Object Class::processing-instruction") -(declare-flow-object-class entity - "UNREGISTERED::James Clark//Flow Object Class::entity") -(declare-flow-object-class entity-ref - "UNREGISTERED::James Clark//Flow Object Class::entity-ref") -(declare-flow-object-class formatting-instruction - "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction") - -(declare-characteristic preserve-sdata? - "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #f) -;; -;; try setting this to true to see if ISO character entities get translated -;;(declare-characteristic preserve-sdata? -;; "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #t) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; variables - -(define %no-split-output% #f) -(define %no-make-toc% #f) -(define %no-make-index% #f) -(define %no-shade-screen% #f) -(define %show-comments% #f) -(define %shade-width% "100%") ; width or #f -(define %email-element% "TT") ; font changing element or #f - -(define %html-public-id% "-//W3C//DTD HTML 3.2 Final//EN") -(define %body-bgcolor% "white") -(define %output-directory% ".") -(define %output-basename% "libgtop") -(define %output-suffix% ".shtml") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; top-level sections - -(define (book-common) - (cond (%no-split-output% ; everything goes in one file - (make-file (string-append %output-basename% %output-suffix%) - (make sequence - (process-children) - (cond ((not %no-make-index%) - (make sequence - (make-fat-rule) - (make-index))) - (#t (empty-sosofo)))))) - (#t ; split output into separate files - (make sequence - (make-file (string-append %output-basename% %output-suffix%) - (make sequence - (process-first-descendant "TITLE") - (process-first-descendant "BOOKINFO"))) - (process-matching-children "PREFACE" - "CHAPTER" - "APPENDIX" - "BIBLIOGRAPHY" - "GLOSSARY" - "ARTHEADER") - (cond ((not %no-make-index%) - (make-file (string-append %output-basename% - "-INDEX" - %output-suffix%) - (make-index))) - (#t (empty-sosofo))))))) - -(element BOOK (book-common)) - -(define generator-version - "Generated from Docbook 3.0 DTD, dbtohtml.dsl version $Revision$") - -(define (make-file file-name content) - (make entity - system-id: (string-append %output-directory% "/" file-name) - (make sequence - (make document-type - name: "html" - public-id: %html-public-id%) - (make formatting-instruction data: "<") - (make formatting-instruction data: "!--") - (literal generator-version) - (make formatting-instruction data: "--> -") - (make element - gi: "html" - (make sequence - (make element - gi: "head" - (make sequence - (make empty-element gi: "link" - attributes: (list (list "rel" "stylesheet") - (list "type" "text/css") - (list "href" "/style/docbook.css"))) - (make empty-element gi: "meta" - attributes: (list (list "name" "generator") - (list "content" generator-version))) - (make empty-element gi: "meta" - attributes: (list (list "name" "ObjectType") - (list "content" "book"))) - (make element - gi: "title" - (with-mode extract-title-text - (process-first-descendant "title"))))) - (make element - gi: "body" - attributes: (list (list "bgcolor" %body-bgcolor%)) - (make sequence - (make-anchor) - content - (make-footer) - (make formatting-instruction data: "<") - (make formatting-instruction data: "!--#include virtual=\"/includes/docbook_footer\"") - (make formatting-instruction data: "-->")))))))) - -(define (make-footer) - (let ((copyright (select-elements (descendants (book-node)) - '("COPYRIGHT" "BOOKINFO")))) - (cond ((node-list-empty? copyright) (empty-sosofo)) - (#t (make sequence - (make-fat-rule) - (process-node-list copyright)))))) - -(define (node-list-last nl) - (node-list-ref nl (- (node-list-length nl) 1))) - -(define (make-nav-links parent-gi) - (make sequence - (make empty-element - gi: "P") - (make element - gi: "A" - attributes: (list (list "href" (link-file-name (ancestor parent-gi)))) - (literal "Up")) - (literal " ") - (if (absolute-last-sibling?) - (empty-sosofo) - (make element - gi: "A" - attributes: (list (list "href" - (link-file-name (node-list-first - (follow (current-node)))))) - (literal "Forward"))) - (literal " ") - (if (absolute-first-sibling?) - (empty-sosofo) - (make element - gi: "A" - attributes: (list (list "href" - (link-file-name (node-list-last - (preced (current-node)))))) - (literal "Back"))) - (make empty-element - gi: "P"))) - -(define (make-pref-chap-app) - (cond (%no-split-output% - (make sequence - (make-anchor) - (make-fat-rule) - (process-children))) - (#t - (make-file (link-file-name (current-node)) - (make sequence - (make-nav-links "BOOK") - (process-children) - (make-nav-links "BOOK")))))) - -;;(element ARTICLE (process-children)) -(element ARTICLE (book-common)) - -(element PREFACE (make-pref-chap-app)) - -(element CHAPTER (make-pref-chap-app)) - -(element APPENDIX (make-pref-chap-app)) - -(element BEGINPAGE (make sequence - (make empty-element gi: "P") - (make empty-element gi: "HR"))) - -(element BIBLIOGRAPHY (make-pref-chap-app)) - -(element BOOKBIBLIO (process-children)) - -(element BIBLIODIV (process-children)) - -(element GLOSSARY (make-pref-chap-app)) - -; (element GLOSSDIV (make-pref-chap-app)) - -;;(element ARTHEADER (make-pref-chap-app)) -(element ARTHEADER - (make sequence - (cond ((not %no-make-toc%) - (make sequence - (make-fat-rule) - (make element - gi: "h2" - attributes: (list "align" "center") - (literal "Contents")) - (make element - gi: "ul" - attributes: (list "align" "center") - (with-mode make-toc-links - (process-node-list (book-node)))))) - (#t (empty-sosofo))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; sections - -(element SECT1 - (make sequence - (make-anchor) - (process-children))) - -(element SECT2 - (make sequence - (make-anchor) - (process-children))) - -(element SECT3 - (make sequence - (make-anchor) - (process-children))) - -(element SECT4 - (make sequence - (make-anchor) - (process-children))) - -(element SECT5 - (make sequence - (make-anchor) - (process-children))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; titles - -(mode extract-title-text - (element (TITLE) - (process-children))) - -(mode extract-title-text - (element (BRIDGEHEAD) - (process-children))) - -(element (BOOK TITLE) - (make element - gi: "h1" - attributes: (list "align" "center") - (process-children))) - -(element (ARTICLE TITLE) - (make element - gi: "h1" - attributes: (list "align" "center") - (process-children))) - -(element (CHAPTER TITLE) - (make sequence - (make element - gi: "h1" - (make sequence - (literal (chap-app-head-label "Chapter")) - (process-children-trim))))) - -(element (PREFACE TITLE) - (make element - gi: "h1" - (make sequence - (literal "Preface: ") - (process-children-trim)))) - -(element (APPENDIX TITLE) - (make element - gi: "H1" - (make sequence - (literal (chap-app-head-label "Appendix")) - (process-children-trim)))) - -(element (BIBLIOGRAPHY TITLE) - (make element gi: "H1" - (make sequence - (literal (chap-app-head-label "Bibliography")) - (process-children-trim)))) - -(element (BOOKBIBLIO TITLE) - (make element gi: "H2" - (make sequence -;;; (literal (chap-app-head-label "Bibliography")) - (process-children-trim)))) - -(element (BIBLIODIV TITLE) - (make element gi: "H2" - (make sequence - (process-children-trim)))) - -(element (GLOSSARY TITLE) - (make element gi: "H1" - (make sequence - (literal "Glossary") -; (process-children-trim) -))) - -(element (GLOSSDIV TITLE) - (make element gi: "H2" - (process-children-trim))) - -(element (ARTHEADER TITLE) - (make element gi: "H1" - (process-children-trim))) - -(element (ARTHEADER DATE) - (make element gi: "P")) - -(element (ARTHEADER SUBTITLE) - (make element - gi: "H2" - (make element - gi: "i" - (process-children-trim) - ))) - -(element (SECT1 TITLE) (make element gi: "H2")) - -(element (SECT2 TITLE) (make element gi: "H3")) - -(element (SECT3 TITLE) (make element gi: "H4")) - -(element (SECT4 TITLE) (make element gi: "H5")) - -(element (SECT5 TITLE) (make element gi: "H6")) - -(element (FORMALPARA TITLE) (make element gi: "H6")) - -(element BRIDGEHEAD (make element gi: "H4")) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; font changers - -(element EMPHASIS - (make element gi: "EM")) - -(element TYPE - (make element gi: "STRONG" - (make element gi: "TT"))) - -(element TOKEN - (make element gi: "EM" - (make element gi: "STRONG" - (make element gi: "TT")))) - -(element REPLACEABLE (make element gi: "EM")) - -(element FIRSTTERM (make element gi: "EM")) - -(element APPLICATION (make element gi: "TT")) - -(element FILENAME (make element gi: "TT")) - -(element LITERAL (make element gi: "TT")) - -(element GUIMENU (make element gi: "TT")) -(element GUIMENUITEM (make element gi: "TT")) - -(element ENVAR (make element gi: "TT")) - -(element SUBSCRIPT (make element gi: "SUB")) - -(element SUPERSCRIPT (make element gi: "SUP")) - -(element CITATION (process-children)) -(element CITETITLE (make element gi: "I")) - -(element COMMAND (make element gi: "TT")) - -(element STRUCTFIELD (make element gi: "TT")) - -(element OPTION (make element gi: "TT")) - -(element USERINPUT (make element gi: "TT")) - -(element COMPUTEROUTPUT (make element gi: "TT")) - -(element PROMPT (make element gi: "TT")) - -(element PRODUCTNAME (make element gi: "I")) - -(element SGMLTAG (make element gi: "TT")) -(element CLASSNAME (make element gi: "TT")) -(element SYMBOL (make element gi: "TT")) -(element LITERALLAYOUT (make element gi: "PRE")) -(element PROGRAMLISTING (make element gi: "PRE")) - -(element FOREIGNPHRASE (make element gi: "I")) - -;; I think that title abbreviations don't really have a place in HTML. -;; The only place in which I can imagine them being useful is if the -;; HTML secret title (the one that goes in your bookmarks and stuff) -;; is derived from the DocBook title abbrev -;; -;; (element ABBREV (process-children-trim)) -(element ABBREV (empty-sosofo)) -(element TITLEABBREV (empty-sosofo)) - -(element EMAIL - (if %email-element% - (make element - gi: %email-element% - (process-children-trim)) - (process-children-trim))) - -(element QUOTE - (make sequence - (make entity-ref - name: "quot") - (process-children-trim) - (make entity-ref - name: "quot"))) - -(element ADDRESS - (make element - gi: "address" - (make element - gi: "em" - (process-children-trim)))) - -(element (ADDRESS CITY) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS COUNTRY) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS EMAIL) - (make sequence - (make empty-element - gi: "BR") - ;; Now throw some space between street address and the email - ;; address. Sadly, the only way I know how to do it in HTML is to - ;; throw in an empty paragraph tag. - (make empty-element - gi: "spacer" - attributes: '(("align" "vertical") ("size" "10"))) - (if %email-element% - (make element - gi: %email-element% - (process-children-trim)) - (process-children-trim)))) - -(element (ADDRESS FAX) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS OTHERADDR) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS POB) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS PHONE) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -(element (ADDRESS POSTCODE) - (process-children-trim)) - -(element (ADDRESS STATE) - (process-children-trim)) - -(element (ADDRESS STREET) - (make sequence - (make empty-element - gi: "BR") - (process-children-trim))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; paragraph like things - -(element CAUTION (make-special-para)) - -(element IMPORTANT (make-special-para)) - -(element WARNING (make-special-para)) - -(element NOTE (make-special-para)) - -(element TIP (make-special-para)) - -(element EXAMPLE (make-special-para)) - -(element INFORMALEXAMPLE - (make element - gi: "BLOCKQUOTE")) - -(element COMMENT - (cond (%show-comments% - (make element - gi: "FONT" - attributes: '(("color" "red")) - (make-special-para))) - (#t (empty-sosofo)))) - -(element PARA - (make sequence - (make empty-element - gi: "P") - (with-mode footnote-ref - (process-children)) - (with-mode footnote-def - (process-matching-children "FOOTNOTE")))) - -(element BLOCKQUOTE (make element gi: "BLOCKQUOTE")) - -(element SCREEN - (let ((gubbins (make element - gi: "PRE" - (process-children)))) - (make sequence - (make empty-element - gi: "P") - (if %no-shade-screen% - gubbins - (make element - gi: "TABLE" - attributes: (append (list '("border" "0") - '("bgcolor" "#E0E0E0")) - (if %shade-width% - (list (list "width" %shade-width%)) - '())) - (make element - gi: "TR" - (make element - gi: "TD" - gubbins))))))) - -(element FORMALPARA (process-children)) - -(element PHRASE (maybe-bold-children)) - -(mode footnote-ref - (element FOOTNOTE - (make sequence - (literal "[") - (literal (format-number (element-number (current-node)) "1")) - (literal "]")))) - -(mode footnote-def - (element FOOTNOTE - (make element - gi: "BLOCKQUOTE" - (make sequence - (literal "[") - (literal (format-number (element-number (current-node)) "1")) - (literal "]") - (process-children))))) - -(element (CAUTION TITLE) - (make element - gi: "H5")) - -(element (IMPORTANT TITLE) - (make element - gi: "H5")) - -(element (WARNING TITLE) - (make element - gi: "H5")) - -(element (NOTE TITLE) - (make element - gi: "H5")) - -(element (TIP TITLE) - (make element - gi: "H5")) - -(element (EXAMPLE TITLE) - (make element - gi: "H5")) - -(element (BIBLIOENTRY TITLE) - (make element - gi: "H3")) - -(element (BIBLIOENTRY PAGENUMS) - (make sequence - (literal "Pages: ") - (make element gi: "I"))) - -(element (BIBLIOENTRY DATE) - (make sequence - (literal " Date: ") - (make element gi: "I"))) - -(element (BIBLIOENTRY VOLUMENUM) - (make sequence - (literal " Volume: ") - (make element gi: "I"))) - -(element (BIBLIOENTRY SERIESINFO) (process-children)) - -(element (BIBLIOENTRY SERIESINFO TITLE) - (make element gi: "H4")) - -(element (BIBLIOENTRY BIBLIOMISC) - (make sequence - (literal " other: ") - (process-children))) - -; the para inside does the work, here... -(element (BIBLIOENTRY ABSTRACT) (process-children)) - -;; an article'sabstract is centered text -(element ABSTRACT - (make sequence - (make empty-element gi: "HR") - (make element - gi: "H2" - (literal "Abstract")) - (make element - gi: "DIV" - attributes: (list (list "align" "left")) - (make element gi: "BLOCKQUOTE" - (process-children))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; lists - -(element ITEMIZEDLIST - (make sequence - (make empty-element - gi: "P") - (make element - gi: "UL"))) - -(element ORDEREDLIST - (make sequence - (make empty-element - gi: "P") - (make element - gi: "OL"))) - -(element PROCEDURE - (make sequence - (make empty-element - gi: "P") - (make element - gi: "OL"))) - -(element SIMPLELIST - (make sequence - (make empty-element - gi: "P") - (make element - gi: "UL"))) - -(element (ITEMIZEDLIST LISTITEM) - (make sequence - (make empty-element - gi: "LI") - (process-children) - (make empty-element - gi: "P"))) - -(element (ORDEREDLIST LISTITEM) - (make sequence - (make empty-element - gi: "LI") - (process-children) - (make empty-element - gi: "P"))) - -(element STEP - (make sequence - (make empty-element - gi: "LI") - (process-children) - (make empty-element - gi: "P"))) - -(element (SIMPLELIST MEMBER) - (make sequence - (make empty-element - gi: "LI") - (process-children))) - -(element VARIABLELIST - (make sequence - (make empty-element - gi: "P") - (make element - gi: "DL"))) - -(element VARLISTENTRY - (make sequence - (make empty-element - gi: "DT") - (process-children))) - -(element (VARLISTENTRY LISTITEM) - (make sequence - (make empty-element - gi: "DD") - (process-children) - (make empty-element - gi: "P"))) - -(element TERM (maybe-bold-children)) - -(element GLOSSDIV - (make sequence - (make empty-element - gi: "P") - (make element - gi: "DL"))) - -; (define (gloss-entry-name indexterm) -; (string-append "gloss." (format-number (element-number indexterm) "1"))) -(define (gloss-entry-name glossterm) - (string-append "gloss." (data glossterm))) - -(element GLOSSENTRY - (process-children)) - -(element (GLOSSENTRY GLOSSTERM) - (make sequence - (make empty-element - gi: "DT") - (make empty-element - gi: "A" - attributes: (list (list "name" (gloss-entry-name (current-node))))) - (process-children))) - - -(element (GLOSSENTRY GLOSSDEF) - (make sequence - (make empty-element - gi: "DD") - (process-children) - (make empty-element - gi: "P"))) - -(element (GLOSSENTRY GLOSSSEE) - (make sequence - (make empty-element - gi: "DD") - (literal "See ") - (make element - gi: "A" - attributes: (list (list "href" - (string-append "#" - (gloss-entry-name (current-node))) - ))) - (make empty-element - gi: "P"))) - -; (element GLOSSTERM (maybe-bold-children)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; index - -(define (index-entry-name indexterm) - (string-append "index." (format-number (element-number indexterm) "1"))) - -(element INDEXTERM - (make sequence - (make element - gi: "A" - attributes: (list (list "name" (index-entry-name (current-node)))) - (literal "")) - (empty-sosofo))) - -; DIY string-ci>? - -(define (string-ci>? s1 s2) - (let ((len1 (string-length s1)) - (len2 (string-length s2))) - (let loop ((i 0)) - (cond ((= i len1) #f) - ((= i len2) #t) - (#t (let ((c1 (index-char-val (string-ref s1 i))) - (c2 (index-char-val (string-ref s2 i)))) - (cond - ((= c1 c2) (loop (+ i 1))) - (#t (> c1 c2))))))))) - -(define (index-char-val ch) - (case ch - ((#\A #\a) 65) - ((#\B #\b) 66) - ((#\C #\c) 67) - ((#\D #\d) 68) - ((#\E #\e) 69) - ((#\F #\f) 70) - ((#\G #\g) 71) - ((#\H #\h) 72) - ((#\I #\i) 73) - ((#\J #\j) 74) - ((#\K #\k) 75) - ((#\L #\l) 76) - ((#\M #\m) 77) - ((#\N #\n) 78) - ((#\O #\o) 79) - ((#\P #\p) 80) - ((#\Q #\q) 81) - ((#\R #\r) 82) - ((#\S #\s) 83) - ((#\T #\t) 84) - ((#\U #\u) 85) - ((#\V #\v) 86) - ((#\W #\w) 87) - ((#\X #\x) 88) - ((#\Y #\y) 89) - ((#\Z #\z) 90) - - ((#\ ) 32) - - ((#\0) 48) - ((#\1) 49) - ((#\2) 50) - ((#\3) 51) - ((#\4) 52) - ((#\5) 53) - ((#\6) 54) - ((#\7) 55) - ((#\8) 56) - ((#\9) 57) - - ; laziness precludes me from filling this out further - (else 0))) - -(define (string->number-list s) - (let loop ((i (- (string-length s) 1)) - (l '())) - (if (< i 0) - l - (loop (- i 1) (cons (index-char-val (string-ref s i)) l))))) - -(define (number-list>? l1 l2) - (cond ((null? l1) #f) - ((null? l2) #t) - ((= (car l1) (car l2)) - (number-list>? (cdr l1) (cdr l2))) - (#t (> (car l1) (car l2))))) - -; return the string data for a given index entry - -(define (get-index-entry-data entry) - (let ((primary (select-elements (descendants entry) "PRIMARY")) - (secondary (select-elements (descendants entry) "SECONDARY"))) - (if (node-list-empty? secondary) - (data primary) - (string-append (data primary) " - " (data secondary))))) - -(define (make-index-entry entry) - (let ((text (get-index-entry-data entry))) - (cons text - (make sequence - (make empty-element - gi: "LI") - (make element - gi: "A" - attributes: (list (list "href" - (string-append (link-file-name - entry) - "#" - (index-entry-name - entry)))) - (literal text)))))) - -(define (build-index nl) - (let loop ((result '()) - (nl nl)) - (if (node-list-empty? nl) - result - (loop (cons (make-index-entry (node-list-first nl)) result) - (node-list-rest nl))))) - -(define (sort-index il) - (letrec ((list-head (lambda (l n) - (if (> n 0) - (cons (car l) (list-head (cdr l) (- n 1))) - '()))) - (merge (lambda (il1 il2) - (cond ((null? il1) il2) - ((null? il2) il1) - ((string-ci>? (car (car il1)) (car (car il2))) - (cons (car il2) (merge il1 (cdr il2)))) - (#t - (cons (car il1) (merge (cdr il1) il2))))))) - (let* ((ll (length il)) - (ldiv2 (quotient ll 2))) - (if (> 2 ll) - il - (merge (sort-index (list-head il ldiv2)) - (sort-index (list-tail il ldiv2))))))) - -(define (output-index il) - (let extract-and-append ((il il) - (result (empty-sosofo))) - (if (null? il) - result - (extract-and-append (cdr il) (sosofo-append result (cdr (car il))))))) - -(define (make-index) - (make sequence - (make element - gi: "A" - attributes: (list (list "name" "INDEXTOP")) - (literal "")) - (make element - gi: "H1" - (literal "Index")) - (make element - gi: "UL" - (output-index - (sort-index - (build-index (select-elements (descendants (current-node)) - "INDEXTERM"))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; links & cross-references - -(define (link-file-name target) - (cond (%no-split-output% "") - (#t - (string-append - %output-basename% - (cond ((equal? (gi target) "CHAPTER") - (string-append - "-" - (format-number (child-number target) "1"))) - ((ancestor-child-number "CHAPTER" target) - (string-append - "-" - (format-number (ancestor-child-number "CHAPTER" target) "1"))) - ((equal? (gi target) "APPENDIX") - (string-append - "-" - (format-number (child-number target) "A"))) - ((ancestor-child-number "APPENDIX" target) - (string-append - "-" - (format-number (ancestor-child-number "APPENDIX" target) "A"))) - (#t "")) - %output-suffix%)))) - -(element ANCHOR - (make-anchor)) - -(element LINK - (let* ((target (element-with-id (attribute-string "linkend") - (book-node))) - (target-file-name (link-file-name target)) - (endterm (attribute-string "endterm")) - (target-title-sosofo (if endterm - (with-mode extract-xref-text - (process-node-list - (element-with-id endterm - (book-node)))) - (process-children)))) - (make element - gi: "A" - attributes: (list - (list "href" - (string-append - target-file-name - "#" - (attribute-string "linkend")))) - target-title-sosofo))) -(element ULINK - (make element - gi: "A" - attributes: (list - (list "href" (attribute-string "url"))))) - -(element XREF - (let* ((target (element-with-id (attribute-string "LINKEND") - (book-node))) - (target-file-name (link-file-name target))) - (make element - gi: "A" - attributes: (list - (list "href" - (string-append target-file-name - "#" - (attribute-string "linkend")))) - (with-mode extract-xref-text - (process-node-list target))))) - -(mode extract-xref-text - (default - (let ((title-sosofo (with-mode extract-title-text - (process-first-descendant "TITLE")))) - (if (sosofo? title-sosofo) - title-sosofo - (literal (string-append "Reference to " (gi))))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; figures - -(element FIGURE - (make sequence - (make empty-element - gi: "P") - (make-anchor) - (process-children) - (make empty-element - gi: "P"))) - -(element (FIGURE TITLE) - (make sequence - (make element - gi: "B") - (make empty-element - gi: "P"))) - -(element GRAPHIC - (let ((img - (make sequence - (make empty-element - gi: "P") - (make empty-element - gi: "IMG" - attributes: (list - (list "src" - (string-append (attribute-string "fileref") - ".gif"))))))) - (if (equal? - (attribute-string "align") - "CENTER") - (make element - gi: "CENTER" - img) - img))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; tables - -(element TABLE - (make sequence - (make empty-element - gi: "P") - (make element - gi: "TABLE" - attributes: (if (equal? - (attribute-string "frame") - "ALL") - '(("border" "2") ("cellpadding" "2")) - '())) - (make empty-element - gi: "P"))) - -(element (TABLE TITLE) - (make element - gi: "H4" - (make sequence - (literal "Table: ") - (process-children-trim)))) - -(element INFORMALTABLE - (make sequence - (make empty-element - gi: "P") - (make element - gi: "TABLE" - attributes: (if (equal? - (attribute-string "frame") - "ALL") - '(("border" "2") ("cellpadding" "2")) - '())) - (make empty-element - gi: "P"))) - -(element TGROUP (process-children)) - -(element THEAD (process-children)) - -(element (THEAD ROW) - (make sequence - (make empty-element - gi: "TR") - (process-children))) - -(element (THEAD ROW ENTRY) - (make sequence - (make empty-element - gi: "TD") - (make element - gi: "B" - (process-children)))) - -(element TBODY (process-children)) - -(element (TBODY ROW) - (make sequence - (make empty-element - gi: "TR") - (process-children))) - - -(element (TBODY ROW ENTRY) - (make sequence - (make empty-element - gi: "TD") - (process-children))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; book info - -(element BOOKINFO - (make sequence - (make element - gi: "CENTER" - (process-children)) - (cond ((not %no-make-toc%) - (make sequence - (make-fat-rule) - (make element - gi: "H2" - (literal "Contents")) - (make element - gi: "ul" - (with-mode make-toc-links - (process-node-list (book-node)))))) - (#t (empty-sosofo))))) - -(element (BOOKINFO DATE) - (make element gi: "P")) - -(element (BOOKINFO TITLE) - (make element gi: "H1")) - -(element (BOOKINFO SUBTITLE) - (make element - gi: "H2" - (make element - gi: "i" - (process-children-trim) - ))) - -(element AUTHORGROUP - (let ((reducer (lambda (sofar new) - (sosofo-append sofar (make element - gi: "H2" - (process-node-list new)))))) - (make sequence - (node-list-reduce (select-elements (descendants (current-node)) "AUTHOR") - reducer - (empty-sosofo)) - (node-list-reduce (select-elements (descendants (current-node)) "EDITOR") - reducer - (empty-sosofo)) - (node-list-reduce (select-elements (descendants (current-node)) "CORPAUTHOR") - reducer - (empty-sosofo))))) - -;; I make a new left-aligned DIV sandwiched between HRs for the author -;; blurb. -(element AUTHORBLURB - (make sequence - (make empty-element gi: "HR") - (make element - gi: "DIV" - attributes: '(("align" "left")) - (make element - gi: "h4" - attributes: '(("align" "left")) - (literal "Author blurb for ") - (make element - gi: "i" - (process-matching-children "TITLE") - (literal ":"))) - (process-matching-children "FORMALPARA" "PARA" "SIMPARA")) - (make empty-element gi: "HR"))) - -(element (AUTHORBLURB TITLE) - (make element gi: "B")) - -(element CORPNAME - (make element gi: "H2")) - -(element (BIBLIOENTRY AUTHORGROUP) - (let ((reducer (lambda (sofar new) - (sosofo-append sofar (make element - gi: "H3" - (process-node-list new)))))) - (make sequence - (node-list-reduce (select-elements (descendants (current-node)) "AUTHOR") - reducer - (empty-sosofo)) - (node-list-reduce (select-elements (descendants (current-node)) "EDITOR") - reducer - (empty-sosofo)) - (node-list-reduce (select-elements (descendants (current-node)) "CORPAUTHOR") - reducer - (empty-sosofo))))) - -(element COPYRIGHT - (make element - gi: "H4" - (make sequence - (make entity-ref - name: "copy") - (process-matching-children "HOLDER") - (process-matching-children "YEAR")))) - -(element HOLDER - (make sequence - (literal " ") - (process-children-trim))) - -(element YEAR - (make sequence - (literal " ") - (process-children-trim))) - -(element CORPAUTHOR - (process-children-trim)) - -(element AUTHOR - (process-children-trim)) - -(element EDITOR - (process-children-trim)) - -(element CONFGROUP - (process-children-trim)) - -(element CONFTITLE - (make sequence - (make empty-element - gi: "BR") - (make element gi: "I" (process-children)))) - -(element CONFDATES - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element HONORIFIC - (make sequence - (process-children-trim) - (literal " "))) - -(element FIRSTNAME - (make sequence - (process-children-trim) - (literal " "))) - -(element OTHERNAME - (make sequence - (process-children-trim) - (literal " "))) - -(element SURNAME - (make sequence - (process-children-trim) - (literal " "))) - -(element LINEAGE - (make sequence - (process-children-trim) - (literal " "))) - -(element TRADEMARK (process-children)) - -(element PUBLISHERNAME (process-children)) - -(element BIBLIOENTRY (process-children)) - -(element ACRONYM (process-children)) - -(element RELEASEINFO - (make sequence - (make empty-element - gi: "BR") - (make element gi: "B"))) - -(element AFFILIATION - (make sequence - (make element - gi: "I"))) - -(element ORGNAME - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -;;(element ORGNAME -;; (process-children)) - -(element JOBTITLE - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element ORGDIV - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element PUBLISHER - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element ISBN - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element PUBDATE - (make sequence - (make empty-element - gi: "BR") - (process-children))) - -(element REVHISTORY - (empty-sosofo)) - -(element LEGALNOTICE - (make sequence - (make element - gi: "H4" - attributes: '(("align" "left")) - (literal "Legal Notice: ")) - (make element - gi: "DIV" - attributes: '(("align" "left"))))) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; Synopses for command line, API functions and so forth -;;(element FUNCSYNOPSIS -;; (process-children)) - -(element FUNCSYNOPSIS - (make sequence - (make empty-element gi: "P") ; go to a new line - ;; just in case there is some synopsisinfo, like #include directives - (process-matching-children "FUNCSYNOPSISINFO") - (make empty-element gi: "P") ; go to a new line - (process-matching-children "FUNCDEF") ; this gives the function name - (literal " (") - (process-matching-children "PARAMDEF") ; this gives the function arguments - (literal ")") - )) - -(element FUNCDEF - (make element gi: "TT")) - -(element FUNCTION - (make element gi: "B")) - -(element STRUCTNAME - (make element gi: "B")) - -(element FUNCSYNOPSISINFO - (make element - gi: "PRE")) - -(element PARAMDEF - (make element - gi: "TT")) - -(element PARAMETER - (make element - gi: "I")) - -(element FUNCPROTOTYPE - (make element - gi: "PRE")) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; TOC - -(element LOF (empty-sosofo)) - -(element LOT (empty-sosofo)) - -(element TOC (empty-sosofo)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; DIY TOC - -(mode make-toc-links - (element (BOOK) - (sosofo-append - (process-children) - (cond ((not %no-make-index%) - (make sequence - (make empty-element - gi: "LI") - (make element - gi: "A" - attributes: (list (list "href" - (cond (%no-split-output% "#INDEXTOP") - (#t - (string-append %output-basename% - "-INDEX" - %output-suffix% - "#INDEXTOP"))))) - (literal "Index")))) - (#t (empty-sosofo))))) - (element (CHAPTER) - (make-chap-or-app-toc-links)) - (element (APPENDIX) - (make-chap-or-app-toc-links)) - (element (SECT1) - (make sequence - (make empty-element - gi: "LI") - (let ((title-text (with-mode extract-title-text - (process-first-descendant "TITLE")))) - (if (id) - (make element - gi: "A" - attributes: (list (list "href" (string-append (link-file-name (current-node)) - "#" - (id)))) - title-text) - title-text)))) - (default - (empty-sosofo))) - -(define (make-chap-or-app-toc-links) - (make sequence - (make empty-element - gi: "LI") - (let ((title-text - (make sequence - (literal (if (equal? (gi) "CHAPTER") - (string-append "Chapter " - (format-number - (element-number (current-node)) - "1") - " - ") - (string-append "Appendix " - (format-number - (element-number (current-node)) - "A") - " - "))) - (with-mode extract-title-text - (process-first-descendant "TITLE"))))) - (if (id) - (make element - gi: "A" - attributes: (list (list "href" (string-append (link-file-name (current-node)) - "#" - (id)))) - title-text) - title-text)) - (make element - gi: "UL" - (with-mode make-toc-links - (process-matching-children "SECT1"))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; make the unimplemented bits stand out - -(default - (make element - gi: "FONT" - attributes: '(("color" "red")) - (make sequence - (literal (string-append "<" (gi) ">")) - (process-children) - (literal (string-append ""))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; standard subroutines - -(define (node-list-reduce nl combine init) - (if (node-list-empty? nl) - init - (node-list-reduce (node-list-rest nl) - combine - (combine init (node-list-first nl))))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; various homebrew subroutines - -(define (book-node) - (cond ((equal? (gi) "BOOK") (current-node)) - (#t (let ((book-root (ancestor "BOOK"))) - (if (node-list-empty? book-root) - (cond ((equal? (gi) "CHAPTER") (current-node)) - (#t (ancestor "CHAPTER"))) - book-root))))) - -(define (make-fat-rule) - (make sequence - (make empty-element gi: "P") - (make empty-element gi: "HR"))) - -(define (chap-app-head-label chap-or-app) - (let ((label - (attribute-string "label" (ancestor chap-or-app)))) - (string-append - chap-or-app - " " - (if label - (if (equal? label "auto") - (format-number - (element-number (ancestor chap-or-app)) - (if (equal? chap-or-app "Chapter") "1" "A")) - label) - (format-number - (element-number (ancestor chap-or-app)) - (if (equal? chap-or-app "Chapter") "1" "A"))) - ". "))) - -(define (make-anchor) - (if (id) - (make element - gi: "A" - attributes: (list (list "name" (id))) - (literal "")) - (empty-sosofo))) - -(define (make-special-para) - (make sequence - (make empty-element - gi: "P") - (make element - gi: "B" - (literal (string-append (gi) ":"))) - (make element - gi: "BLOCKQUOTE" - (process-children)))) - -(define (maybe-bold-children) - (cond ((equal? (attribute-string "role") - "bold") - (make element - gi: "B" - (process-children-trim))) - (#t (process-children-trim)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; the end diff --git a/doc/features/proclist.sgml b/doc/features/proclist.sgml deleted file mode 100644 index d071a758..00000000 --- a/doc/features/proclist.sgml +++ /dev/null @@ -1,153 +0,0 @@ - - This functions takes the following additional parameters: - - - - which - - - - You can use the following constants (defined in - glibtop/proclist.h) to tell - glibtop_get_proclist () which processes - to fetch: - - - - GLIBTOP_KERN_PROC_ALL - - - - Fetch all processes. - - - - - GLIBTOP_KERN_PROC_PID - - - - Fetch process with pid arg or - nothing if no such process exists. - - - - - GLIBTOP_KERN_PROC_PGRP - - - - Fetch only processes which are in process group - arg. - - - - - GLIBTOP_KERN_PROC_SESSION - - - - Fetch only processes with session id - arg. - - - - - GLIBTOP_KERN_PROC_TTY - - - - Fetch only processes with tty id - arg. - - - - - GLIBTOP_KERN_PROC_UID - - - - Fetch only processes with effective user id - arg. - - - - - GLIBTOP_KERN_PROC_RUID - - - - Fetch only processes with real user id - arg. - - - - - - - You can use one or more of the following flags (with a - logical or) to hide some processes: - - - - GLIBTOP_EXCLUDE_IDLE - - - - Don't fetch idle processes. - - - - - GLIBTOP_EXCLUDE_SYSTEM - - - - Don't fetch system processes. - - - - - GLIBTOP_EXCLUDE_NOTTY - - - - Don't fetch processes that have no controlling tty. - - - - - - - - - arg - - - - Additional argument depending upon the - which argument. - - - - - - This function returns a pointer (of type unsigned *) to - the list of process ids. - - - You have to manually &glibtop-free; this pointer once finished with it. - - - \ No newline at end of file diff --git a/doc/features/procmem.sgml b/doc/features/procmem.sgml deleted file mode 100644 index 3394afba..00000000 --- a/doc/features/procmem.sgml +++ /dev/null @@ -1,103 +0,0 @@ - - The automatically generated description above is taken from the - manual page of the /proc filesystem under Linux - and is a little bit confusing, so I make this clear here. - - - Note for people porting &libgtop; to other systems - - - Well, every operating system has its own idea about the memory usage - of a processes, and also system utilities like ps - show different things on different systems. - - - Nevertheless, we should try to make &libgtop; as system independent - as possible, so I give you some hints here how &glibtop-get-procmem; - should work. - - - - - When you use &mmap; with either &MAP-SHARED; or &MAP-PRIVATE;, - this should only affect the &pmem-vsize; of the process and - none of its &pmem-size;, &pmem-resident;, &pmem-shared; and - &pmem-rss; sizes. - - - - As soon as you read some of the &mmap;ed pages, they will be - demand-loaded and thus count towards the &pmem-size; of the - process. Also - we assume there is enough free memory - they - are resident in memory until they get stolen or swapped out - and thus increase the &pmem-resident; and &pmem-rss; sizes of - the process. - - - - If the process has used &MAP-SHARED; and another process - attaches the same file also &MAP-SHARED; some of the pages - are shared with this process and thus increase the &pmem-shared; - sizes of both processes. - - - - If the process has used &MAP-PRIVATE; and writes to the &mmap;ed - pages, the only difference to reading from them is that they - get dirty and cannot be stolen any longer but will get swapped - out. - - - - If memory gets rare, clean pages are normally stolen which - decreases the &pmem-size;, &pmem-resident;, &pmem-shared; and - &pmem-rss; sizes of the process. - - - - When dirty pages are swapped out, this will - not decrease the &pmem-size; of the - process but only its &pmem-resident; and &pmem-rss; sizes - (dirty pages cannot be shared). - - - - The &pmem-vsize; of a process can only - be changed by the process itself when it requests or frees - memory but never due to swapping - activity of the system. - - - - If the &pmem-shared; size changes, this - only means that the number of pages that - are currently shared with other processes has changed; if this - happens, this will never affect any of the - other sizes of the process. - - - - - - - The hints above describe how it works under Linux - and we should try to - make &glibtop-get-procmem; show the same behavior under every other - system. - - - If you want to make any comments, flames, suggestions about this, please - feel free to do so. - - - \ No newline at end of file diff --git a/doc/features/uptime.sgml b/doc/features/uptime.sgml deleted file mode 100644 index ea504b6a..00000000 --- a/doc/features/uptime.sgml +++ /dev/null @@ -1,23 +0,0 @@ - - - - You can calculate this from the CPU usage (this one is taken - from the FreeBSD port): - - &include-uptime.txt; - - - - - \ No newline at end of file diff --git a/doc/features/uptime.txt b/doc/features/uptime.txt deleted file mode 100644 index be3f4489..00000000 --- a/doc/features/uptime.txt +++ /dev/null @@ -1,40 +0,0 @@ -#include <glibtop.h> -#include <glibtop/error.h> -#include <glibtop/uptime.h> - -#include <glibtop/cpu.h> - -#include <glibtop_suid.h> - -static const unsigned long _glibtop_sysdeps_uptime = -(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME); - -static const unsigned long _required_cpu_flags = -(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_IDLE) + -(1 << GLIBTOP_CPU_FREQUENCY); - -void -glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf) -{ - glibtop_cpu cpu; - - glibtop_init_p (server, GLIBTOP_SYSDEPS_UPTIME, 0); - - memset (buf, 0, sizeof (glibtop_uptime)); - - /* We simply calculate it from the CPU usage. */ - - glibtop_get_cpu_p (server, &cpu); - - /* Make sure all required fields are present. */ - - if ((cpu.flags & _required_cpu_flags) != _required_cpu_flags) - return; - - /* Calculate values. */ - - buf->uptime = (double) cpu.total / (double) cpu.frequency; - buf->idletime = (double) cpu.idle / (double) cpu.frequency; - - buf->flags = _glibtop_sysdeps_uptime; -} diff --git a/doc/gnome-hackers.dsl b/doc/gnome-hackers.dsl deleted file mode 100644 index dfecdeed..00000000 --- a/doc/gnome-hackers.dsl +++ /dev/null @@ -1,12 +0,0 @@ - -]> - - - -(define %output-basename% "gnome-hackers") -(define %output-directory% "gnome-hackers") - - - - diff --git a/doc/gnome-hackers.sgml b/doc/gnome-hackers.sgml deleted file mode 100644 index eabe0f73..00000000 --- a/doc/gnome-hackers.sgml +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - -libgtop"> - - - -macros/gnome-libgtop-check.m4"> -libgtopConf.sh"> -glibtop_free ()"> -glibtop_get_proc_mem ()"> -mmap ()"> -MAP_SHARED"> -MAP_PRIVATE"> -procmem.vsize"> -procmem.size"> -procmem.resident"> -procmem.shared"> -procmem.rss"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -]> - - - Using Libgtop in the Gnome Project - - - Martin - Baulig - -
- martin@home-of-linux.org -
-
-
-
- - 1998 - Martin Baulig - - - - - - This documentation is free software; you can redistribute - it and/or modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later - version. - - - This library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the GNU General Public License for more - details. - - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, - MA 02111-1307 USA - - - For more details see the file COPYING in the source - distribution of &libgtop;. - - - - - - - $Id$ - - - - This is a short introduction in how to use - libgtop in the GNOME project. - It describes the additional options configure - takes and the information stored in the automatically generated - libgtopConf.sh configuration script. - - - - Documentation about the new table () - function can be found here: - - - - - &home-of-linux;kernel/table/ - - - - - - -
- - - - - Configuration - - &include-autoconf.sgml; - - - - - Function Reference List - - &include-reference.sgml; - - - - - Porting &libgtop; to other systems - - - Here are some comments for people porting &libgtop; to other systems. - - - &glibtop-get-procmem; - Process Memory information - - - This section is copied here from the description of - &glibtop-get-procmem;. - - - &include-proc-mem.sgml; - - - - - -
- - diff --git a/doc/libgtop-ref.dsl b/doc/libgtop-ref.dsl deleted file mode 100644 index 78cd4cb8..00000000 --- a/doc/libgtop-ref.dsl +++ /dev/null @@ -1,12 +0,0 @@ - -]> - - - -(define %output-basename% "libgtop-ref") -(define %output-directory% "libgtop-ref") - - - - diff --git a/doc/libgtop-ref.sgml b/doc/libgtop-ref.sgml deleted file mode 100644 index dcf55133..00000000 --- a/doc/libgtop-ref.sgml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -]> - - - LibGTop Reference Manual - - - Martin - Baulig - -
- martin@home-of-linux.org -
-
-
-
- - - $Id$ - - - This reference manual is automatically generated from - doc/make-docbook.scm. It uses the - guile interface of libgtop to - get the names of all features the library defines and a - description of the structures. - - - - 1998 - Martin Baulig - - - - - This documentation is free software; you can redistribute - it and/or modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later - version. - - - This library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the GNU General Public License for more - details. - - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, - MA 02111-1307 USA - - - For more details see the file COPYING in the source - distribution of LibGTop. - - -
- - - - - Function Reference List - - &include-reference.sgml; - -
- - diff --git a/doc/libgtop.dsl b/doc/libgtop.dsl deleted file mode 100755 index 00deca64..00000000 --- a/doc/libgtop.dsl +++ /dev/null @@ -1,12 +0,0 @@ - -]> - - - -(define %output-basename% "libgtop") -(define %output-directory% "libgtop") - - - - diff --git a/doc/libgtop.sgml b/doc/libgtop.sgml deleted file mode 100644 index 0b3eec6d..00000000 --- a/doc/libgtop.sgml +++ /dev/null @@ -1,1332 +0,0 @@ - - - - - - GTop Library Project Documentation - - - Martin - Baulig - -
- martin@home-of-linux.org -
-
-
-
- - 1998 - Martin Baulig - - - - - This documentation is free software; you can redistribute - it and/or modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later - version. - - - This library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the GNU General Public License for more - details. - - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, - MA 02111-1307 USA - - - For more details see the file COPYING in the source - distribution of LibGTop. - - -
- - - - - Introduction - - - About the GTop Library Project - - - On some systems like DEC OSF/1). - - - Of cause making a program that uses some toolkit like - Because of this, some kind of server is needed that reada some - commands from standard input and dumps the requested information - to standard output. When written in a secure manner, it can be - SUID root on systems where this is needed. - - - Any program such as - This is what the - Project Overview - - - The following steps have to be taken: - - - - - Interface Design - - - - First, it is necessary to collect all sorts of information - that can be returned from the library and design some C - structures to hold them. Also, there has to be some method - to find out which elements are supported by the operating - system and which are not. - - - These C structures and definitions are then put in some - header files which are shared between server and client. - The idea behind this is that if they both use the same - header files - and thus the same interface - programs can - be linked directly with the server library on systems where - this is supported (where the server does not need any - priviledges such as under - Server Implementation - - - - After the general interface is designed, the server part of - the library can be written. We will put both the server and - the client code in two distinct libraries. - - - Client Implementation - - - - As the next step, we can implement the client side library. - This library will open a pipe to the server, pass it the - request as input and parse its output. - - - Rewriting existing applications - - - - At this point, the library is ready for use. We can now - begin to rewrite existing applications to use it (or even - write some very new applications). - - - Porting - - - - As the very last step - once everything is running under - - During development, I'll start under DEC OSF/1 V3.0/3.2. - - - - - Feedback - - - Please feel free to contact the author, - Martin Baulig - if you have any comments. - - - Getting Started - - - Using the Guile Interface - - - In examples/third there is a simple guile - interpreter. - - - On Linux systems, you should use the third_linux - executable, this is statically linked with the system dependent library - and works without installing the server first. - - - Let's start with a simple example: - - - $ ./third - guile> (glibtop-get-cpu) - (1107488 39049 0 21981 1046458) - guile> (quit) - - - - Fine, this is our current CPU usage, but what do this five numbers - really mean? Well, of cause one can look a the C header file: - - - typedef struct _glibtop_cpu glibtop_cpu; - - struct _glibtop_cpu - { - unsigned long flags, - total, /* GLIBTOP_CPU_TOTAL */ - user, /* GLIBTOP_CPU_USER */ - nice, /* GLIBTOP_CPU_NICE */ - sys, /* GLIBTOP_CPU_SYS */ - idle; /* GLIBTOP_CPU_IDLE */ - }; - - - - But there's also some easier way: - - - $ ./third_linux - guile> (glibtop-get-cpu) - (1604151 105343 0 63334 1435474) - guile> (glibtop-names-cpu) - ("total" "user" "nice" "sys" "idle") - guile> (quit) - - - - This displays the field names of the C structure - glibtop_cpu. They are not translated into - native language so that one can use guile to generate some C code - that deals with this data. - - - If you want to use this names in an application program, you should - use the following: - - - $ ./third_linux - guile> (glibtop-get-cpu) - (1642347 106696 0 63810 1471841) - guile> (glibtop-labels-cpu) - ("total" "user" "nice" "sys" "idle") - guile> (quit) - - - - There's no difference? You're correct, while I'm writing this manual, - translations in other languaged have not yet been made and labels have - not been written. - - - Let's use another example where this is already working: - - - $ ./third_linux - guile> (glibtop-get-shm_limits) - (33554432 1 128 128 4194304) - guile> (glibtop-names-shm_limits) - ("shmmax" "shmmin" "shmmni" "shmseg" "shmall") - guile> (glibtop-labels-shm_limits) - ("Max segment size" "Min segment size" "Max number of segments" - "Max shared segments per process" "Max total shared memory") - guile> (quit) - - - - Great! But how can I know what features are currently implemented by the - library? Well, basically there are two ways. - - - First, you can use - - - $ ./third_linux - guile> (apropos "glibtop-get") - the-root-module: glibtop-get-cpu #<primitive-procedure glibtop-get-cpu> - the-root-module: glibtop-get-uptime #<primitive-procedure glibtop-get-uptime> - the-root-module: glibtop-get-sysdeps #<primitive-procedure glibtop-get-sysdeps> - the-root-module: glibtop-get-loadavg #<primitive-procedure glibtop-get-loadavg> - the-root-module: glibtop-get-swap #<primitive-procedure glibtop-get-swap> - the-root-module: glibtop-get-proclist #<primitive-procedure glibtop-get-proclist> - the-root-module: glibtop-get-sem_limits #<primitive-procedure glibtop-get-sem_limits> - the-root-module: glibtop-get-msg_limits #<primitive-procedure glibtop-get-msg_limits> - the-root-module: glibtop-get-shm_limits #<primitive-procedure glibtop-get-shm_limits> - the-root-module: glibtop-get-mem #<primitive-procedure glibtop-get-mem> - guile> (quit) - - - - This gives you a basic idea which functions are defined in the library. - But there's also a better way: - - - $ ./third_linux - guile> (glibtop-get-sysdeps) - (31 127 7 3 1 31 127 1023 3) - guile> (glibtop-names-sysdeps) - ("cpu" "mem" "swap" "uptime" "loadavg" "shm_limits" "msg_limits" "sem_limits" - "proclist") - guile> (glibtop-labels-sysdeps) - ("CPU Usage" "Memory Usage" "Swap Usage" "System Uptime" "Load Averange" - "Shared Memory Limits" "Message Queue Limits" "Semaphore Set Limits" - "List of running Processes") - guile> (quit) - - - - Back to the glibtop_get_cpu. Here is a nice example - on how you can convert the returned data to percents: - - - [FIXME: not yet written] - - - Using system dependent features - - - Some of the features of the library are only implemented on some systems. - For instance, in our last example: - - - guile> (glibtop-get-cpu) - (2091847 130894 17 70602 1890334) - - - - Well fine - some process is running with nice now on my system - but in - the last section, we always got zero in the nice - field. When some feature is not implemented on a particular system, it is - set to zero. So how can we find out whether a feature is not implemented on - the current system or whether it is really zero all the time? - - - This is what the flags member of the C structure - is for. Since theese flags never change during the lifetime of a process, - on can call glibtop_get_sysdeps to get a structure - glibtop_sysdeps containing the - flags members of all currently available features. - The contents of the structure remains constant during the lifetime of a - process. - - - In guile, on can use glibgtop-get-sysdeps, too: - - - guile> (glibtop-get-sysdeps) - (31 127 7 3 1 31 127 1023 3) - - - - We already know that the first member of this list corresponds to - glibtop_cpu. So this 31 - tells us which features of glibtop_cpu are - implemented on this systems. The binary representation of - 31 is 11111. If the lowest bit - of this constant is set, this means that the first list element is - implemented on the current system and so on. If, for instance, the - user member of glibtop_cpu - is not implemented, this constant will be 11101 - or 29 in decimal representation. - - -Using the library in a C program - - -Well, in C things are a little bit more complicated than in guile. -Let's start with a very simple example: - - -First steps - - -#include <glibtop/open.h> -#include <glibtop/close.h> - -#include <glibtop/cpu.h> - -int -main (int argc, char *argv []) -{ - glibtop server; - glibtop_cpu cpu; - - glibtop_open (&server, argv [0]); - - glibtop_get_cpu (&server, &cpu); - - fprintf (stderr, "CPU: %lu, %lu, %lu, %lu, %lu\n", - cpu.total, cpu.user, cpu.nice, cpu.sys, cpu.idle); - - glibtop_close (&server); -} - - - - -This will print out: - - -$ ./first_linux -CPU: 2262741, 136828, 17, 72569, 2053327 - - - -Make sure to open a connection to the server by a call to -glibtop_open before calling any other function -of the library and to close that connection upon termination by a call to -glibtop_close. Otherwise your program may either -not work correctly or simply dump core. - - -Using names and labels in C - - -To dump out the field names of glibtop_cpu: - - -Dump field names of <structname>glibtop_cpu</structname>: - -<programlisting> -#include <glibtop/open.h> -#include <glibtop/close.h> - -#include <glibtop/cpu.h> - -int -main (int argc, char *argv []) -{ - fprintf (stderr, "CPU Names: %s, %s, %s, %s, %s\n", - glibtop_names_cpu [GLIBTOP_CPU_TOTAL], - glibtop_names_cpu [GLIBTOP_CPU_USER], - glibtop_names_cpu [GLIBTOP_CPU_NICE], - glibtop_names_cpu [GLIBTOP_CPU_SYS], - glibtop_names_cpu [GLIBTOP_CPU_IDLE]); -} -</programlisting> -</example> - -<para> -Since this are constants, they also work without the server connection. - -<para> -To dump all members of <structname>glibtop_cpu</structname> no matter -how many there are: - -<example> -<title>Dump all members of <structname>glibtop_cpu</structname> no matter -how many - - -#include <glibtop/open.h> -#include <glibtop/close.h> - -#include <glibtop/cpu.h> - -int -main (int argc, char *argv []) -{ - int i; - - for (i = 0; i < GLIBTOP_MAX_CPU; i++) - fprintf (stderr,"#%d: %s\n", i, glibtop_names_cpu [i]); -} - - - - -Finaly, let's dump the internationalized labels: - - -Dump internationalized labels - - -#include <glibtop.h> -#include <glibtop/open.h> -#include <glibtop/close.h> - -#include <glibtop/cpu.h> - -int -main (int argc, char *argv []) -{ - int i; - - setlocale (LC_ALL, ""); - bindtextdomain (PACKAGE, GTOPLOCALEDIR); - textdomain (PACKAGE); - - for (i = 0; i < GLIBTOP_MAX_CPU; i++) - fprintf (stderr,"#%d: %s\n", i, - gettext (glibtop_labels_cpu [i])); -} - - - - -Using system dependent features in C - - -In C, there are some constants defined in the header files: - - -#define GLIBTOP_CPU_TOTAL 0 -#define GLIBTOP_CPU_USER 1 -#define GLIBTOP_CPU_NICE 2 -#define GLIBTOP_CPU_SYS 3 -#define GLIBTOP_CPU_IDLE 4 - - - -The value used in the flags member to indicate -whether some feature is implemented on the current system is always -2 at the power of the corresponding constant. - - -For instance, if you want to print out the user -field of glibtop_cpu when it's implemented on the -current system, you can use: - - -Only print <structfield>user</structfield> member of -<structname>glibtop_cpu</structname> when it's implemented - - - -#include <glibtop/open.h> -#include <glibtop/close.h> - -#include <glibtop/cpu.h> - -int -main (int argc, char *argv []) -{ - glibtop server; - glibtop_cpu cpu; - - glibtop_open (&server, argv [0]); - - glibtop_get_cpu (&server, &cpu); - - fprintf (stderr, "CPU: %lu, ", cpu.total); - - /* FIXME: is this correct? */ - - if (cpu.flags & (1 << GLIBTOP_CPU_USER)) - fprintf (stderr, "%lu, ", cpu.user); - - fprintf (stderr, "%lu, %lu, %lu\n", cpu.nice, cpu.sys, cpu.idle); - - glibtop_close (&server); -} - - - - -Hacker's Guide - - -Extending the Library - - -This section will give you a step by step tutorial on how to extend the -library to add a new feature. It is not yet really complete. - - -The Header File - - -First, we'll start writing the C header file for our new feature we want -to add. Currently there is no support for getting information about a -particular process, so we'll add it here. - - -All header files are put into includes/glibtop and -are named after the feature they define. So we'll put everything into -procdata.h: - - -Start of <filename>procdata.h</filename> - -<programlisting> -#ifndef __GLIBTOP_PROCDATA_H__ -#define __GLIBTOP_PROCDATA_H__ - -#include <glibtop.h> -#include <glibtop/global.h> -</programlisting> -</example> - -<para> -This is how we start every header file. Make sure to include at lease -<filename>glibtop.h</filename> and <filename>glibtop/global.h</filename>. -They contain important declarations and include some other important -header files. - -<para> -Next, we look at the <filename>/proc</filename> filesystem of Linux to -find out which information can be fetched about a particular process: - -<screen> -<prompt>$</prompt> <userinput>cat /proc/self/stat</userinput> -14919 (cat) R 14886 14919 14886 1220 14919 1048576 24 0 63 0 0 1 0 0 15 0 -1 -0 1915281 835584 67 2147483647 134512640 134527808 3221222564 3221222372 -1074212972 0 0 2147483648 0 0 0 0 -</screen> - -<para> -Well, this is a rather complex example, but those are the most important -information we need about a process. I think it would be best to start -with the definition of the C structure -<structname>glibtop_procdata</structname> that will be used to store all -those information. We'll copy most from -<filename>gnome-utils/gtop/proc/readproc.h</filename>: - -<example> -<title>Definition of <structname>glibtop_procdata</structname> - -<programlisting> -typedef struct _glibtop_procdata glibtop_procdata; - -struct _glibtop_procdata -{ - unsigned long flags; - char cmd[40], /* basename of executable file in call to exec(2) */ - state; /* single-char code for process state (S=sleeping) */ - int uid, /* user id */ - pid, /* process id */ - ppid, /* pid of parent process */ - pgrp, /* process group id */ - session, /* session id */ - tty, /* full device number of controlling terminal */ - tpgid, /* terminal process group id */ - priority, /* kernel scheduling priority */ - nice, /* standard unix nice level of process */ - signal, /* mask of pending signals */ - blocked, /* mask of blocked signals */ - sigignore, /* mask of ignored signals */ - sigcatch; /* mask of caught signals */ - long start_time, /* start time of process -- seconds since 1-1-70 */ - utime, /* user-mode CPU time accumulated by process */ - stime, /* kernel-mode CPU time accumulated by process */ - cutime, /* cumulative utime of process and reaped children */ - cstime, /* cumulative stime of process and reaped children */ - /* the next 7 members come from /proc/#/statm */ - size, /* total # of pages of memory */ - resident, /* number of resident set (non-swapped) pages (4k) */ - share, /* number of pages of shared (mmap'd) memory */ - trs, /* text resident set size */ - lrs, /* shared-lib resident set size */ - drs, /* data resident set size */ - dt; /* dirty pages */ - unsigned long vsize, /* number of pages of virtual memory ... */ - rss, /* resident set size from /proc/#/stat */ - rss_rlim, /* resident set size ... ? */ - timeout, /* ? */ - it_real_value, /* ? */ - k_flags, /* kernel flags for the process */ - min_flt, /* number of minor page faults since process start */ - maj_flt, /* number of major page faults since process start */ - cmin_flt, /* cumulative min_flt of process and child processes */ - cmaj_flt, /* cumulative maj_flt of process and child processes */ - start_code, /* address of beginning of code segment */ - end_code, /* address of end of code segment */ - start_stack, /* address of the bottom of stack for the process */ - kstk_esp, /* kernel stack pointer */ - kstk_eip, /* kernel stack pointer */ - wchan; /* address of kernel wait channel proc is sleeping in */ -}; -</programlisting> -</example> - -<para> -For each field we now have to define an unique constant: - -<example> -<title>Constant definitions for <structname>glibtop_procdata</structname>: - - -#define GLIBTOP_PROCDATA_CMD 0 -#define GLIBTOP_PROCDATA_STATE 1 -#define GLIBTOP_PROCDATA_UID 2 -#define GLIBTOP_PROCDATA_PID 3 -#define GLIBTOP_PROCDATA_PPID 4 -#define GLIBTOP_PROCDATA_PGRP 5 -#define GLIBTOP_PROCDATA_SESSION 6 -#define GLIBTOP_PROCDATA_TTY 7 -#define GLIBTOP_PROCDATA_TPGID 8 -#define GLIBTOP_PROCDATA_PRIORITY 9 -#define GLIBTOP_PROCDATA_NICE 10 -#define GLIBTOP_PROCDATA_SIGNAL 11 -#define GLIBTOP_PROCDATA_BLOCKED 12 -#define GLIBTOP_PROCDATA_SIGIGNORE 13 -#define GLIBTOP_PROCDATA_SIGCATCH 14 -#define GLIBTOP_PROCDATA_START_TIME 15 -#define GLIBTOP_PROCDATA_UTIME 16 -#define GLIBTOP_PROCDATA_STIME 17 -#define GLIBTOP_PROCDATA_CUTIME 18 -#define GLIBTOP_PROCDATA_CSTIME 19 -#define GLIBTOP_PROCDATA_SIZE 20 -#define GLIBTOP_PROCDATA_RESIDENT 21 -#define GLIBTOP_PROCDATA_SHARE 22 -#define GLIBTOP_PROCDATA_TRS 23 -#define GLIBTOP_PROCDATA_LRS 24 -#define GLIBTOP_PROCDATA_DRS 25 -#define GLIBTOP_PROCDATA_DT 26 -#define GLIBTOP_PROCDATA_VSIZE 27 -#define GLIBTOP_PROCDATA_RSS 28 -#define GLIBTOP_PROCDATA_RSS_RLIM 29 -#define GLIBTOP_PROCDATA_TIMEOUT 30 -#define GLIBTOP_PROCDATA_IT_REAL_VALUE 31 -#define GLIBTOP_PROCDATA_K_FLAGS 32 -#define GLIBTOP_PROCDATA_MIN_FLT 33 -#define GLIBTOP_PROCDATA_MAJ_FLT 34 -#define GLIBTOP_PROCDATA_CMIN_FLT 35 -#define GLIBTOP_PROCDATA_CMAJ_FLT 36 -#define GLIBTOP_PROCDATA_START_CODE 37 -#define GLIBTOP_PROCDATA_END_CODE 38 -#define GLIBTOP_PROCDATA_START_STACK 39 -#define GLIBTOP_PROCDATA_KSTK_ESP 40 -#define GLIBTOP_PROCDATA_KSTK_EIP 41 -#define GLIBTOP_PROCDATA_WCHAN 42 - -#define GLIBTOP_MAX_PROCDATA 43 - - - - -Finally, we'll need some external definitions. They are discussed in detail -later. Basically, you can copy them from any other header file and just -change the names - in our example, we also have to add an additional -parameter to glibtop_get_procdata and -glibtop_guile_get_procdata: - - -External definitions - - -extern void glibtop_get_procdata (glibtop *, glibtop_procdata *, pid_t); - -#ifdef HAVE_GUILE - -/* You need to link with -lgtop_guile to get this stuff here. */ - -extern SCM glibtop_guile_get_procdata (SCM); - -#endif - -#ifdef GLIBTOP_GUILE_NAMES - -/* You need to link with -lgtop_guile_names to get this stuff here. */ - -extern SCM glibtop_guile_names_procdata (void); -extern SCM glibtop_guile_labels_procdata (void); -extern SCM glibtop_guile_descriptions_procdata (void); - -#endif - -#ifdef GLIBTOP_NAMES - -/* You need to link with -lgtop_names to get this stuff here. */ - -extern const char *glibtop_names_procdata []; -extern const char *glibtop_labels_procdata []; -extern const char *glibtop_descriptions_procdata []; - -#endif - - - - -The Stub File - - -The stub file is used when the library has not yet been ported to the -system it is used on. It goes into sysdeps/stub -and sets the whole structure glibtop_procdata -to zero: - - -<filename>sysdeps/stub/procdata.c</filename> - - -/* Provides detailed information about a process. */ - -void -glibtop_get_procdata (glibtop *server, glibtop_procdata *buf, pid_t pid) -{ - memset (buf, 0, sizeof (glibtop_procdata)); -} - - - - -We'll see later how to port this stub to a particular operating system. -At the moment it's enough to simply copy it to each of the other sysdeps -directories (except for common, -names and guile). - - -<filename>sysdeps/names</filename> - - -In sysdeps/names, we create the following file: - - -<filename>sysdeps/names/procdata.c</filename> - - -#include <glibtop/procdata.h> - -const char *glibtop_names_procdata [GLIBTOP_MAX_PROCDATA] = -{ "cmd", "state", "uid", "pid", "ppid", "pgrp", "session", - "tty", "tpgid", "priority", "nice", "signal", "blocked", - "sigignore", "sigcatch", "start_time", "utime", "stime", - "cutime", "cstime", "size", "resident", "share", "trs", - "lrs", "drs", "dt", "vsize", "rss", "rss_rlim", "timeout", - "it_real_value", "k_flags", "min_flt", "maj_flt", "cmin_flt", - "cmaj_flt", "start_code", "end_code", "start_stack", - "kstk_esp", "kstk_eip", "wchan" -}; - -const char *glibtop_labels_procdata [GLIBTOP_MAX_PROCDATA] = -{ N_("Cmd"), N_("Stat"), N_("UID"), N_("PID"), N_("PPID"), N_("PGRP"), - N_("Session"), N_("Tty"), N_("TPGID"), N_("Priority"), N_("Nice"), - N_("Signal"), N_("Blocked"), N_("SigIgnore"), N_("SigCatch"), - N_("Start_Time"), N_("UTime"), N_("STime"), N_("CUTime"), N_("CSTime"), - N_("Size"), N_("Resident"), N_("Share"), N_("TRS"), N_("LRS"), N_("DRS"), - N_("DT"), N_("VSize"), N_("RSS"), N_("RSS_RLim"), N_("Timeout"), - N_("It_Real_Value"), N_("Flags"), N_("Min_Flt"), N_("Maj_Flt"), - N_("CMin_Flt"), N_("Cmaj_Flt"), N_("Start_Code"), N_("End_Code"), - N_("Start_Stack"), N_("KSTK_ESP"), N_("KSTK_EIP"), N_("WChan") -}; - -const char *glibtop_descriptions_procdata [GLIBTOP_MAX_PROCDATA] = -{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL -}; - - - - -The Guile Interface - - -The next step is to create the guile interface. It goes into -sysdeps/guile: - - -<filename>sysdeps/guile/procdata.c</filename> - - -SCM -glibtop_guile_get_procdata (SCM pid) -{ - glibtop_procdata p; - - glibtop_get_procdata (&glibtop_global_server, &p, (pid_t) gh_scm2long (pid)); - - return gh_list (gh_str02scm (p.cmd), - gh_char2scm (p.state), - gh_long2scm (p.pid), - gh_long2scm (p.ppid), - gh_long2scm (p.pgrp), - gh_long2scm (p.session), - gh_long2scm (p.tty), - gh_long2scm (p.tpgid), - gh_long2scm (p.priority), - gh_long2scm (p.nice), - gh_long2scm (p.signal), - gh_long2scm (p.blocked), - gh_long2scm (p.sigignore), - gh_long2scm (p.sigcatch), - gh_long2scm (p.utime), - gh_long2scm (p.stime), - gh_long2scm (p.cutime), - gh_long2scm (p.cstime), - gh_long2scm (p.size), - gh_long2scm (p.resident), - gh_long2scm (p.share), - gh_long2scm (p.trs), - gh_long2scm (p.lrs), - gh_long2scm (p.drs), - gh_long2scm (p.dt), - gh_ulong2scm (p.vsize), - gh_ulong2scm (p.rss), - gh_ulong2scm (p.rss_rlim), - gh_ulong2scm (p.timeout), - gh_ulong2scm (p.it_real_value), - gh_ulong2scm (p.k_flags), - gh_ulong2scm (p.min_flt), - gh_ulong2scm (p.maj_flt), - gh_ulong2scm (p.cmin_flt), - gh_ulong2scm (p.cmaj_flt), - gh_ulong2scm (p.start_code), - gh_ulong2scm (p.end_code), - gh_ulong2scm (p.start_stack), - gh_ulong2scm (p.kstk_esp), - gh_ulong2scm (p.kstk_eip), - gh_ulong2scm (p.wchan), - SCM_UNDEFINED); -} - - - - -Guile Names and Labels - - -This is a little bit shorter again - all you have to do is copy one of -the other files and change the names: - - -<filename>sysdeps/guile/names/procdata.c</filename> - - -#include <glibtop.h> -#include <glibtop/procdata.h> - -#include <guile/gh.h> - -SCM -glibtop_guile_names_procdata (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROCDATA; i++) - list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_procdata [i]), SCM_UNDEFINED)); - - return list; -} - -SCM -glibtop_guile_labels_procdata (void) -{ - int i; - SCM list; - - list = gh_list (SCM_UNDEFINED); - - for (i = 0; i < GLIBTOP_MAX_PROCDATA; i++) - list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_procdata [i])), - SCM_UNDEFINED)); - - return list; -} - - - - -The Library File - - -The last one is the library file: - - -<filename>lib/procdata.c</filename> - - -#include <glibtop/procdata.h> -#include <glibtop/command.h> - -/* Provides detailed information about a process. */ - -void -glibtop_get_procdata (glibtop *server, glibtop_procdata *buf, pid_t pid) -{ - glibtop_call (server, GLIBTOP_CMND_PROCDATA, sizeof (pid_t), &pid, - sizeof (glibtop_procdata), buf); -} - - - - -Make sure to define GLIBTOP_CMND_PROCDATA in -command.h. The call to -glibtop_call is simple - we send -pid and its size and we get -buf which is of type -glibtop_procdata. - - -Sysdeps - - -Finally, we add an entry to sysdeps.h and -sysdeps.c: - - -<filename>includes/glibtop/sysdeps.h</filename> - - -#include <glibtop.h> -#include <glibtop/cpu.h> -#include <glibtop/mem.h> -#include <glibtop/swap.h> -#include <glibtop/uptime.h> -#include <glibtop/loadavg.h> -#include <glibtop/shm_limits.h> -#include <glibtop/msg_limits.h> -#include <glibtop/sem_limits.h> -#include <glibtop/proclist.h> -#include <glibtop/procdata.h> - -#define GLIBTOP_SYSDEPS_CPU 0 -#define GLIBTOP_SYSDEPS_MEM 1 -#define GLIBTOP_SYSDEPS_SWAP 2 -#define GLIBTOP_SYSDEPS_UPTIME 3 -#define GLIBTOP_SYSDEPS_LOADAVG 4 -#define GLIBTOP_SYSDEPS_SHM_LIMITS 5 -#define GLIBTOP_SYSDEPS_MSG_LIMITS 6 -#define GLIBTOP_SYSDEPS_SEM_LIMITS 7 -#define GLIBTOP_SYSDEPS_PROCLIST 8 -#define GLIBTOP_SYSDEPS_PROCDATA 9 - -#define GLIBTOP_MAX_SYSDEPS 10 - -typedef struct _glibtop_sysdeps glibtop_sysdeps; - -struct _glibtop_sysdeps -{ - unsigned long flags, - cpu, /* glibtop_cpu */ - mem, /* glibtop_mem */ - swap, /* glibtop_swap */ - uptime, /* glibtop_uptime */ - loadavg, /* glibtop_loadavg */ - shm_limits, /* glibtop_shm_limits */ - msg_limits, /* glibtop_msg_limits */ - sem_limits, /* glibtop_sem_limits */ - proclist, /* glibtop_proclist */ - procdata; /* glibtop_procdata */ -}; - - - - -Just make sure to include procdata.h, to define -GLIBTOP_SYSDEPS_PROCDATA, to increase -GLIBTOP_MAX_SYSDEPS by one and to add to new element -procdata to -glibtop_sysdeps. - - -After that, add a procdata to -glibtop_union -(it's defined in union.h) and include -procdata.h in that file: - - -<filename>include/glibtop/union.h</filename> - - -#include <glibtop/cpu.h> -#include <glibtop/mem.h> -#include <glibtop/swap.h> -#include <glibtop/uptime.h> -#include <glibtop/loadavg.h> -#include <glibtop/shm_limits.h> -#include <glibtop/msg_limits.h> -#include <glibtop/sem_limits.h> -#include <glibtop/proclist.h> -#include <glibtop/procdata.h> - -typedef union _glibtop_union glibtop_union; - -union _glibtop_union -{ - glibtop_cpu cpu; - glibtop_mem mem; - glibtop_swap swap; - glibtop_uptime uptime; - glibtop_loadavg loadavg; - glibtop_shm_limits shm_limits; - glibtop_msg_limits msg_limits; - glibtop_sem_limits sem_limits; - glibtop_proclist proclist; - glibtop_procdata procdata; -}; - - - - -Now we can append the following to glibtop_get_sysdeps -in sysdeps/common/sysdeps.c: - -Add this at the end of -<function>glibtop_get_sysdeps</function> in -<filename>sysdeps/common/sysdeps.c</filename> - - - - glibtop_get_procdata (server, &data.procdata, 0); - buf->procdata = data.procdata.flags; - - - - -Also add the new name and label to sysdeps/names/sysdeps.c - - -Adding the new command to the server - - -We have to add the following switch case: - -Add this to <filename>src/main.c</filename>: - - - case GLIBTOP_CMND_PROCDATA: - if (sscanf (parameter, "%d", &pid) != 1) pid = 0; - glibtop_get_procdata (&server, &data.procdata, pid); - glibtop_output (sizeof (glibtop_procdata), &data.procdata); - glibtop_output (0, NULL); - break; - - - - -Compiling ... - - -Now it's time to add procdata.c to the -Makefile.am in each directory we added -this file and run a make. - - -Interface Description - - -General information - - -<structname>glibtop_cpu</structname> - CPU usage - - -typedef struct _glibtop_cpu glibtop_cpu; - -struct _glibtop_cpu -{ - unsigned long flags, - total, /* GLIBTOP_CPU_TOTAL */ - user, /* GLIBTOP_CPU_USER */ - nice, /* GLIBTOP_CPU_NICE */ - sys, /* GLIBTOP_CPU_SYS */ - idle; /* GLIBTOP_CPU_IDLE */ -}; - - - -<structname>glibtop_mem</structname> - Memory usage - - -typedef struct _glibtop_mem glibtop_mem; - -struct _glibtop_mem -{ - unsigned long flags, - total, /* GLIBTOP_MEM_TOTAL */ - used, /* GLIBTOP_MEM_USED */ - free, /* GLIBTOP_MEM_FREE */ - shared, /* GLIBTOP_MEM_SHARED */ - buffer, /* GLIBTOP_MEM_BUFFER */ - cached, /* GLIBTOP_MEM_CACHED */ - user; /* GLIBTOP_MEM_USER */ -}; - - - -<structname>glibtop_swap</structname> - Swap usage - - -typedef struct _glibtop_swap glibtop_swap; - -struct _glibtop_swap -{ - unsigned long flags, - total, /* GLIBTOP_SWAP_TOTAL */ - used, /* GLIBTOP_SWAP_USED */ - free; /* GLIBTOP_SWAP_FREE */ -}; - - - -<structname>glibtop_uptime</structname> - uptime and idletime - - -typedef struct _glibtop_uptime glibtop_uptime; - -struct _glibtop_uptime -{ - unsigned long flags; - double uptime, /* GLIBTOP_UPTIME_UPTIME */ - idletime; /* GLIBTOP_UPTIME_IDLETIME */ -}; - - - -<structname>glibtop_loadavg</structname> - load averange - - -typedef struct _glibtop_loadavg glibtop_loadavg; - -struct _glibtop_loadavg -{ - unsigned long flags; - double loadavg [3]; /* GLIBTOP_LOADAVG_LOADAVG */ -}; - - - -Function Descriptions - - -Opening and Closing - - -Before you can use the library, you have to open a connection to the server. - - -<function>glibtop_open()</function> - connect to server - - - -#include <glibtop.h> -#include <glibtop/open.h> -void glibtop_open -glibtop *server, const char *program_name - - - - -server - - - -some data about the server (input and output pipes etc.) are stored here. - - -program_name - - - -program name (used in error messages). - - - -<function>glibtop_close()</function> - close connection to server - - - -#include <glibtop.h> -#include <glibtop/close.h> -void glibtop_close -glibtop *server - - - - -server - - - -the server you connected to. - - - -<function>glibtop_get_sysdeps()</function> - which features are implemented? - - - -#include <glibtop.h> -#include <glibtop/sysdeps.h> -void glibtop_get_sysdeps -glibtop *server, glibtop_sysdeps *sysdeps - - - -General information - - -<function>glibtop_get_cpu()</function> - get CPU usage - - - -#include <glibtop.h> -#include <glibtop/cpu.h> -void glibtop_get_cpu -glibtop *server, glibtop_cpu *cpu_usage - - - -<function>glibtop_get_mem()</function> - get memory usage - - - -#include <glibtop.h> -#include <glibtop/mem.h> -void glibtop_get_mem -glibtop *server, glibtop_mem *memory_usage - - - -<function>glibtop_get_swap()</function> - get swap usage - - - -#include <glibtop.h> -#include <glibtop/swap.h> -void glibtop_get_swap -glibtop *server, glibtop_swap *swap_usage - - - -<function>glibtop_get_uptime()</function> - get uptime and idle time - - - -#include <glibtop.h> -#include <glibtop/uptime.h> -void glibtop_get_uptime -glibtop *server, glibtop_uptime *uptime - - - -<function>glibtop_get_loadavg()</function> - get load averange - - - -#include <glibtop.h> -#include <glibtop/loadavg.h> -void glibtop_get_loadavg -glibtop *server, glibtop_loadavg *loadavg - - -
diff --git a/doc/table.announce.txt b/doc/table.announce.txt deleted file mode 100644 index 8104553e..00000000 --- a/doc/table.announce.txt +++ /dev/null @@ -1,161 +0,0 @@ -Path: news.uni-stuttgart.de!fu-berlin.de!taurus.uni-trier.DE!baulig -From: Martin Baulig -Newsgroups: comp.os.linux.development.system -Subject: RFC: New system call for /proc information ? -Date: 07 Jun 1998 20:22:47 +0200 -Lines: 143 -Sender: baulig@Taurus.uni-trier.de -Message-ID: -NNTP-Posting-Host: taurus.uni-trier.de (136.199.14.201) -Mime-Version: 1.0 -Content-Type: text/plain; charset=iso-8859-1 -Content-Transfer-Encoding: 8bit -NNTP-Posting-User: baulig -X-Access: 16 1542 1543 -X-Trace: fu-berlin.de 897243777 29527 baulig 136.199.14.201 -X-Newsreader: Gnus v5.6.11/XEmacs 20.3 - "Vatican City" -Xref: news.uni-stuttgart.de comp.os.linux.development.system:73539 - -[Posted to the Gnome Mailing List and to comp.os.linux.development.system] - -Request for Comments: -==================== - -Should we have a new system call under Linux which fetches information -from the /proc filesytem similar to the table() function of DEC OSF/1 ? - -The whole story: -=============== - -I am currently working on libgtop, a library that fetches information -from the proc filesystem for user processes. This library uses a suid -server on system where this is required. On Linux, the information are -fetched directly from the proc filesystem. - -Now, I made some profilings (fetches 50000 times cpu, memory, swap, -uptime and loadavg): - -Each sample counts as 0.01 seconds. - % cumulative self self total - time seconds seconds calls ns/call ns/call name - 91.86 348.03 348.03 read - 3.07 359.67 11.64 open - 0.67 362.22 2.55 close - 0.16 363.55 0.62 memset - 0.16 364.14 0.59 __ipc - 0.03 368.84 0.12 vsscanf (iovsscanf.c:31) - 0.01 374.49 0.05 sscanf (sscanf.c:28) - 0.00 378.71 0.01 semctl (semctl.c:32) - 0.00 378.73 0.01 shmctl (shmctl.c:30) - -granularity: each sample hit covers 4 byte(s) for 0.00% of 378.88 seconds - -index % time self children called name -[1] 91.9 348.03 0.00 read [1] ------------------------------------------------ -[2] 3.1 11.64 0.00 open [2] ------------------------------------------------ -[3] 0.7 2.55 0.00 close [3] ------------------------------------------------ -[5] 0.2 0.62 0.00 memset [5] ------------------------------------------------ -[6] 0.2 0.59 0.00 __ipc [6] ------------------------------------------------ -[35] 0.0 0.12 0.00 vsscanf (iovsscanf.c:31) [35] ------------------------------------------------ -[96] 0.0 0.05 0.00 sscanf (sscanf.c:28) [96] ------------------------------------------------ - -You see, it spends a lot of time in read() which is only used to read the -data from the files in /proc. Well, basically one can say that these -timings are not so bad, normally a process periodically fetches those -information say 10 times a seconds which makes 36000 invocations per -hour. - -This will make a total of about 250 seconds per hour or on even say: - -``a program fetching those information at a frequency of 10 will take - about 7 % of each hour just for reading files from /proc''. - -Now look at timings of __ipc, they're about 350 times better 'cause this -is done using system calls. - -So far so good, now look at how this is done on the DEC OSF/1 port of the -library (the following code is part of libgtop - GPL/LGPL): - -CPU usage: -{ - struct tbl_sysinfo sysinfo; - int ret; - - ret = table (TBL_SYSINFO, 0, (char *) &sysinfo, 1, - sizeof (struct tbl_sysinfo)); - - buf->user = sysinfo.si_user; - buf->nice = sysinfo.si_nice; - buf->sys = sysinfo.si_sys; - buf->idle = sysinfo.si_idle; -} - -Well, the table() command of DEC OSF/1 has may disadvantages, too - such -as requiring to be root to fetch any information about processes (well, for -each process that is not the current one). - -But this works using system calls rather that reading and parsing files -and should be about as fast as getting the IPC information on Linux. - -Under Linux, the current trend seems to be to move anything into the /proc -filesystem, but if you look at the timings, wouldn't it be better to also -implement a system call interface ? - -Don't understand me wrong: -========================= - -I *do not want* to *replace* the /proc filesystem - it's an excellent -idea to be able to fetch all information on the command line without -any program just a simple 'cat' - I want to *add* a *new* system call -to allow programmers to fetch those information faster that reading -from /proc. - -To come to the point: -===================== - -Is there any public interest in having a new system call under Linux -which can be used to fetch all information that are currently in the -/proc filesystem. - -Basically, this system would be defined like this: - - asmlinkage int - sys_table (int command, struct sysinfo_table *buf) - -and be invoked like this: - - #include - - { - struct sysinfo_cpu cpu; - struct sysinfo_mem mem; - - ret = table (TABLE_CPU, &cpu); - if (ret == -1) return; /* or invoke any error handler */ - - ret = table (TABLE_MEM, &mem); - if (ret == -1) return; - } - -What do you think, folks. Should we have such a system call under Linux ? -I can do the implementation of this system call, but I want to have some -feedback first. - -Martin - --- ------------------------------------------------------------------ - Martin Baulig - Angewandte Mathematik - Universitaet Trier - - baulig@castor.uni-trier.de, http://www.home-of-linux.com/ - Key: 1024-bit key with ID C8178435 created 1997/01/24 - ID: 67 C1 84 A0 47 F5 11 C5 5F 68 4C 84 99 05 C3 92 - Finger me for public key or fetch finger.txt from the url above ------------------------------------------------------------------- diff --git a/doc/table.dsl b/doc/table.dsl deleted file mode 100644 index 74fcf5aa..00000000 --- a/doc/table.dsl +++ /dev/null @@ -1,12 +0,0 @@ - -]> - - - -(define %output-basename% "table") -(define %output-directory% "table") - - - - diff --git a/doc/table.sgml b/doc/table.sgml deleted file mode 100644 index 58c0b9e2..00000000 --- a/doc/table.sgml +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - -libgtop"> -table ()"> -]> - - - The &table; system call under Linux - - - Martin - Baulig - -
- martin@home-of-linux.org -
-
-
-
- - 1998 - Martin Baulig - - - - - - This documentation is free software; you can redistribute - it and/or modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later - version. - - - This library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the GNU General Public License for more - details. - - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, - MA 02111-1307 USA - - - For more details see the file COPYING in the source - distribution of LibGTop. - - - - - - $Id$ - - - Under Linux, reading from - /proc is somehow slow because the data - needs to be converted into a stringified representation from - the kernel and to be parsed from the application program to - get the original data back. - - While doing the DEC OSF/1 port of - &libgtop; I got the idea to add something similar to the &table; - function there to the Linux kernel. - - This is what this document is about. - - -
- - - - - Why not <function>sysctl</function>? - - - Some weeks ago, I posted the initial proposal of the project to - &news-c-o-l-d-s; with - Message-ID <of7zpfprs08.fsf@Taurus.uni-trier.de>. - - - You can also read this article at my site: - - - - &table-announce-first; - - - - Some people told me to include all the stuff into - sysctl instead of inventing a new system call. - - - Basically this is a good idea, but the main problem with - sysctl is that this should be applied to standard - kernels and not just as a short patch. Well, AFAIK something similar - is on the "wish list" for 2.2er kernels - but of cause it'll need some - time until we have a real replacement of the /proc - filesystem in sysctl. - - - If someone thinks that this absolutely should be included in - sysctl: think about some kind of interface, - discuss it with the kernel developers, ... - - - About the &table; function - - - Using the &table; function will not affect any existing kernel - structures and can be done independent from kernel development. - - - So it can easily be used in &libgtop; until we have something - simliar in standard kernels. - - - If you want to use the &table; function in your own programs, be - aware that it is just intended to be some kind of quick solution - for &libgtop; until there's something better in standard kernels. - - - How to use the &table; function in &libgtop; - - - The source code of the &table; function is distributed together with - &libgtop;. It can be found in the kernel/table20 - directory for 2.0.xx kernels and in the kernel/table21 - directory for 2.1.xx kernels. - - - You can also download it from my site: - - - - &table20-tgz - (for kernel 2.0.xx) - - &table21-tgz - (for kernel 2.1.xx) - - - - Copy the contents of the appropriate directory to - /usr/src/linux/table, apply the - patch to the kernel and re-configure &libgtop;. - - - After that, you can unmount /proc and - &libgtop; will still work ! - - - - Maybe one could consider this as a bug, but currently there - isn't a configuration option to disable the &table; function - once you applied the patch ... - - - - - Currently I'm working on the 2.1.x version to implement some - features newer kernels have - so the 2.0.x version may not - have all features the 2.1.x one has. - - - - - The 2.1.x version of the &table; function is implemented - as a kernel module. You have to do a - insmod table/module.o manually to use it. - - - This has the advantage that you don't need to reboot if you - want to play around with the code a little bit. - - -
- - diff --git a/guile/.cvsignore b/guile/.cvsignore deleted file mode 100644 index d0df6b6f..00000000 --- a/guile/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -Makefile.in -Makefile -features.scm -reference.sgml diff --git a/guile/ChangeLog b/guile/ChangeLog deleted file mode 100644 index a307e923..00000000 --- a/guile/ChangeLog +++ /dev/null @@ -1,42 +0,0 @@ -1998-10-12 Martin Baulig - - * make-docbook.scm: Use `load-primitive' instead of `load'. - * Makefile.am: Make `make-docbook.sm' depend upon `features.scm' - and `dist-hook' depend upon `reference.sgml'. - -1998-10-11 Martin Baulig - - * reference.sgml: Removed. This is a generated file. - - * Makefile.am: Added rule to make `reference.sgml' from - `features.scm' using `make-docbook.scm'. - (DISTCLEANFILES): Added `reference.sgml'. - (EXTRA_DIST): Added `make-docbook.scm'. - (noinst_DATA): Added `reference.sgml'. - -1998-10-11 Martin Baulig - - This directory has been moved from the `libgtop' module to the - `libgtop-docu' module in the GNOME CVS. - - * make-docbook.scm: Make it work with the new Guile interface - of LibGTop from the libgtop-bindings module. - - * Makefile.am: Use the installed `features.def' file of LibGTop - to create the `features.scm'. - -1998-10-11 Martin Baulig - - * dynamic.c, dynamic_names.c: Removed. - * Makefile.am: No longer create `libgtop.so'. - -1998-07-29 Martin Baulig - - * dynamic.c, dynamic_names.c: New files. - - * Makefile.am: New file. Creates `libgtop.so' and - `libnames.so' which will be installed in - `$(datadir)/guile/libgtop'; just do a - `(use-modules (libgtop libgtop) (libgtop names))' in - guile to use them. - diff --git a/guile/Makefile.am b/guile/Makefile.am deleted file mode 100644 index 15b478a2..00000000 --- a/guile/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ - -CFLAGS = -Wall -W @CFLAGS@ - -noinst_DATA = features.scm reference.sgml - -EXTRA_DIST = features.awk make-docbook.scm - -CLEANFILES = features.scm - -DISTCLEANFILES = reference.sgml - -features.scm: features.awk $(top_builddir)/config.h @LIBGTOP_FEATURES_DEF@ - $(AWK) -f $(srcdir)/features.awk < @LIBGTOP_FEATURES_DEF@ > tmp-t - mv tmp-t features.scm - -reference.sgml: make-docbook.scm - guile -s $(srcdir)/make-docbook.scm > tmp-t - mv tmp-t reference.sgml - -make-docbook.scm: features.scm - -dist-hook: reference.sgml - diff --git a/guile/features.awk b/guile/features.awk deleted file mode 100644 index 476a887c..00000000 --- a/guile/features.awk +++ /dev/null @@ -1,61 +0,0 @@ -BEGIN { - string = ""; - names = ""; -} - -function output(line) { - split (line, line_fields, /\|/); - retval = line_fields[1]; - feature = line_fields[2]; - param_def = line_fields[4]; - - orig = feature; sub(/^@/,"",feature); - space = feature; gsub(/./," ",space); - - if (string == "") - string = " '("; - else - string = string" "; - string = string"(\""feature"\" (\""retval"\""; - - feature_nounder = feature; - sub(/_/, "-", feature_nounder); - - if (names == "") - names = " '("; - else - names = names" "; - names = names"(\""feature"\" \""feature_nounder"\")\n"; - - nr_params = split (param_def, params, /:/); - for (param = 1; param <= nr_params; param++) { - list = params[param]; - type = params[param]; - sub(/\(.*/, "", type); - sub(/^.*\(/, "", list); sub(/\)$/, "", list); - - string = string" (\""type"\""; - - count = split (list, fields, /,/); - for (field = 1; field <= count; field++) { - string = string" \""fields[field]"\""; - } - - string = string")"; - } - - string = string"))\n"; -} - -/^[^#]/ { output($0) } - - -END { - print "(define libgtop-features"; - print string" )"; - print ")\n"; - - print "(define libgtop-feature-names"; - print names" )"; - print ")\n"; -} diff --git a/guile/header.scm b/guile/header.scm deleted file mode 100644 index d3fa5ece..00000000 --- a/guile/header.scm +++ /dev/null @@ -1,440 +0,0 @@ -;; $Id$ - -(define cpu-type '(("name" . "cpu") - ("label" . "CPU Usage") - ("fields" . (list - (("name" . "total") - ("label" . "Total CPU Usage") - ("type" . "unsigned long")) - (("name" . "user") - ("type" . "unsigned long")) - (("name" . "nice") - ("type" . "unsigned long")) - (("name" . "sys") - ("type" . "unsigned long")) - (("name" . "idle") - ("type" . "unsigned long")) - (("name" . "name") - ("type" . "const char") - ("pointer" . #t)) - (("name" . "test")) - ) - ) - ) - ) - -(define main-function - (lambda (definition) - (letrec ((default-type "unsigned long") - (struct-label-comments #t) - (struct-name-comments #f) - (default-name-tabs-first 3) - (default-name-tabs 4) - (default-type-tabs 2) - (default-comment-tabs 5) - (default-definition-tabs 3) - (default-definition-value-tabs 2) - (default-max-line-length 60) - ;; set default values for unspecified fields - (check-field-definition - (lambda (fields) - (let ((newlist (list))) - (for-each - (lambda (field) - (if (not (assoc-ref field "type")) - (set! field (assoc-set! field "type" default-type))) - (if (assoc-ref field "label") - (set! field (assoc-set! field "has-label" #t)) - (begin - (set! field (assoc-set! field "label" (assoc-ref field "name"))) - (set! field (assoc-set! field "has-label" #f)) - ) - ) - (set! newlist (append newlist (list field))) - ) - (cdr fields)) - (set-cdr! fields newlist) - ) - ) - ) - ;; number fields sequentially - (make-field-numbers - (lambda (fields) - (let ((pos 0) (newlist (list))) - (for-each - (lambda (field) - (set! field (assoc-set! field "number" pos)) - (set! newlist (append newlist (list field))) - (set! pos (+ pos 1)) - ) - (cdr fields)) - (set-cdr! fields newlist) - (set! definition (assoc-set! definition "max-fields" pos)) - ) - ) - ) - ;; pad string with up to 'tabs' tabs - (tabify-string - (lambda (string tabs) - (let ((length (string-length string)) - (tlength (* tabs 8))) - (if (> tlength length) - (let* ((diff (- tlength length)) - (count (quotient (+ diff 7) 8))) - (string-append string - (make-string count #\tab)) - ) - (string-append string - #\space) - ) - ) - ) - ) - ;; pad string with spaces - (spacify-string - (lambda (string tabs) - (let ((length (string-length string)) - (tlength (* tabs 8))) - (if (> tlength length) - (string-append string - (make-string (- tlength length) #\space)) - (string-append string - #\space) - ) - ) - ) - ) - ;; creates comment string - (make-comment-string - (lambda (comment) - (if comment - (string "/* " - (spacify-string comment - default-comment-tabs) - " */") - (string) - ) - ) - ) - ;; create constant for entry (eg. GLIBTOP_CPU_TOTAL) - (entry-constant-name - (lambda (name) - (string-upcase! (string "GLIBTOP_" - (assoc-ref definition "name") - "_" - name - ) - ) - ) - ) - ;; create text that is displayed as comment along with entry - (entry-comment-text - (lambda (name label) - (if label - (if struct-label-comments label #f) - (if struct-name-comments (entry-constant-name name) #f) - ) - ) - ) - ;; starts struct definition - (make-struct-definition-head - (lambda () - (let* ((class (assoc-ref definition "name")) - ) - (string "struct _glibtop_" class "\n" - "{\n" - ) - ) - ) - ) - ;; terminates struct definition - (make-struct-definition-tail - (lambda () - (string "};\n\n") - ) - ) - ;; generate struct definition body - (make-struct-definition-body - (lambda (fields) - (letrec ((output (string)) - (is-first-entry #t) - (current-type #f) - (current-name #f) - (current-label #f) - (current-pointer #f) - ;; close entry (other = next entry is of other type) - (entry-end - (lambda (other) - (let ((old-first is-first-entry)) - (set! is-first-entry other) - (if current-type - (string (tabify-string (string (string (if current-pointer "*" "")) - current-name - (string (if other ";" ",")) - ) - (if old-first - default-name-tabs-first - default-name-tabs - ) - ) - (make-comment-string (entry-comment-text - current-name current-label)) - "\n") - (string) - ) - ) - ) - ) - ;; start new entry - (entry-start - (lambda (name type) - (if current-type - (if (equal? current-type type) - (string (entry-end #f) "\t\t") - (string (entry-end #t) "\t" - (tabify-string type default-type-tabs) - ) - ) - (string "\t" - (tabify-string type default-type-tabs) - ) - ) - ) - ) - ) - ;; main function - (for-each - (lambda (field) - (let ((name (assoc-ref field "name")) - (type (assoc-ref field "type")) - (pointer (assoc-ref field "pointer")) - (label (if (assoc-ref field "has-label") - (assoc-ref field "label") - #f) - ) - ) - (set! output (string-append output - (string (entry-start name type)) - ) - ) - ;; save current data - (set! current-type type) - (set! current-name name) - (set! current-label label) - (set! current-pointer pointer) - ) - ) - (cdr fields)) - ;; close last entry - (string-append output (entry-end #t)) - ) - ) - ) - ;; display complete struct definition - (make-struct-definition - (lambda (fields) - (string-append (make-struct-definition-head) - (make-struct-definition-body fields) - (make-struct-definition-tail) - ) - ) - ) - ;; make constant definition - (make-const-definition - (lambda (name value comment) - (let* ((nstring (string-upcase! (string "GLIBTOP_" name))) - (tabname (tabify-string nstring default-definition-tabs)) - (tabvalue (if comment - (tabify-string (string value) default-definition-value-tabs) - (string value)) - ) - (ctext (make-comment-string comment)) - (line (string "#define " tabname tabvalue ctext "\n")) - ) - line) - ) - ) - ;; creates constant definitions - (make-struct-constants - (lambda (fields) - (let ((class (assoc-ref definition "name")) - (output (string)) - ) - (for-each - (lambda (field) - (let* ((name (assoc-ref field "name")) - (number (assoc-ref field "number")) - (key (string class "_" name)) - (value (number->string number)) - (label (if (assoc-ref field "has-label") - (assoc-ref field "label") - #f) - ) - (line (make-const-definition key - value - (entry-comment-text name label) - ) - ) - ) - (set! output (string-append output line)) - ) - ) - (cdr fields)) - output) - ) - ) - ;; creates definition of maximum constant - (make-struct-max-constant - (lambda () - (let* ((class (assoc-ref definition "name")) - (max (assoc-ref definition "max-fields")) - ) - (make-const-definition (string "MAX_" class) - (number->string max) - #f) - ) - ) - ) - ;; adds new list element to string, inserting newline if necessary - (add-to-string - (lambda (output line element separator indent max-length) - (let* ((slen (string-length line)) - (elen (string-length element)) - (tlen (+ slen elen)) - (bsep (if separator - (string separator " ") - (string) - ) - ) - (nsep (string (if separator separator "") "\n")) - ) - (if (and (> slen 0) (> tlen max-length)) - (begin - (set! output (string-append output line nsep)) - (set! line (string indent element)) - ) - (set! line (string-append line bsep element)) - ) - (list output line) - ) - ) - ) - ;; create general list definition - (make-general-list-definition - (lambda (fields name symbol line-length make-element-string) - (letrec ((class (assoc-ref definition "name")) - (make-general-list-definition-head - (lambda () - (string "const char *" - "glibtop_" - symbol - "_" - class - " " - "[GLIBTOP_MAX_" - (string-upcase! (string class)) - "] = \n{ " - ) - ) - ) - (make-general-list-definition-tail - (lambda () - (string "\n};\n") - ) - ) - (make-general-list-definition-body - (lambda () - (let* ((first #t) (output (string)) (line (string))) - (for-each - (lambda (field) - (let* ((element (assoc-ref field name)) - (olist (add-to-string output line - (make-element-string element) - (if first #f ",") - " " - line-length)) - ) - (set! output (car olist)) - (set! line (car (cdr olist))) - (set! first #f) - ) - ) - (cdr fields)) - (set! output (string-append output line)) - output) - ) - ) - ) - ;; main function - (string-append (make-general-list-definition-head) - (make-general-list-definition-body) - (make-general-list-definition-tail) - ) - ) - ) - ) - ;; create name list definition - (make-name-list-definition - (lambda (fields) - (make-general-list-definition fields - "name" - "names" - default-max-line-length - (lambda (x) - (string #\" x #\") - ) - ) - ) - ) - ;; create label list definition - (make-label-list-definition - (lambda (fields) - (make-general-list-definition fields - "label" - "labels" - 0 - (lambda (x) - (string "gettext_noop (" #\" x #\" ")") - ) - ) - ) - ) - ;; create description list definition - (make-description-list-definition - (lambda (fields) - (make-general-list-definition fields - "description" - "descriptions" - default-max-line-length - (lambda (x) - (if x - (string "gettext_noop (" #\" x #\" ")") - (string "NULL") - ) - ) - ) - ) - ) - ) - ;; start of main function - (let ((fielddef (assoc-ref definition "fields"))) - (display fielddef) (newline) (newline) - (check-field-definition fielddef) - (make-field-numbers fielddef) - (display fielddef) (newline) (newline) - (display (make-struct-definition fielddef)) - (display (make-struct-constants fielddef)) (newline) - (display (make-struct-max-constant)) (newline) (newline) - (display (make-name-list-definition fielddef)) (newline) - (display (make-label-list-definition fielddef)) (newline) - (display (make-description-list-definition fielddef)) (newline) - ) - ) - ) - ) - -(begin - (main-function cpu-type) - (newline) - ) - diff --git a/guile/make-docbook.scm b/guile/make-docbook.scm deleted file mode 100644 index 8f5217c7..00000000 --- a/guile/make-docbook.scm +++ /dev/null @@ -1,347 +0,0 @@ -;; $Id$ - -(use-modules (libgtop names)) - -(primitive-load "features.scm") - -(define sysdeps-list '()) - -(define type-names '("void" - "int64_t" "u_int64_t" "double" - "int" "char" "const char *")) - -(define make-sysdeps-list - (lambda () - (letrec ((names (cdr glibtop-names-sysdeps)) - (labels (cdr glibtop-labels-sysdeps)) - (descriptions (cdr glibtop-descriptions-sysdeps)) - ) - (for-each (lambda (feature) - (let* ((label (car labels)) - (description (car descriptions)) - (list '()) - ) - (set! labels (cdr labels)) - (set! descriptions (cdr descriptions)) - (set! list (assoc-set! list 'name feature)) - (set! list (assoc-set! list 'label label)) - (set! list (assoc-set! list 'description description)) - (set! sysdeps-list (assoc-set! sysdeps-list feature list)) - ) - ) - names) - ) - ) - ) - -(define make-function-reference - (lambda (feature) - (let* ((feature-name (car (assoc-ref libgtop-feature-names feature))) - (names (eval-string (string "glibtop-names-" feature-name))) - (types (eval-string (string "glibtop-types-" feature-name))) - (labels (eval-string (string "glibtop-labels-" feature-name))) - (sysdeps (assoc-ref sysdeps-list feature)) - (retval (car (car (assoc-ref libgtop-features feature)))) - (name (assoc-ref sysdeps 'name)) - (label (assoc-ref sysdeps 'label)) - (description (assoc-ref sysdeps 'description)) - (descriptions (eval-string (string "glibtop-descriptions-" feature-name))) - (feature_nounder (car (assoc-ref libgtop-feature-names feature))) - (decl-list '()) (field-list '()) - - (synopsis-start-string - (string "Automatically generated function synopsis:\n\n")) - - (section-string - (string "\n" - "<function>glibtop_get_" feature "()</function> - " - label "\n\n") - ) - - (description-string - (string "\nAutomatically generated description:\n\n" - "
\n\n" - description "\n" - "\n
\n\n") - ) - - (definition-start-string - (string "Automatically generated declaration of " - "_glibtop_" feature ":\n\n") - ) - - (param-description-start-string - (string "Automatically generated descriptions of " - "_glibtop_" feature ":\n\n") - ) - - (funcsynopsisinfo-string - (string "\n" - "#include <glibtop.h>\n" - "#include <glibtop/" feature ".h>" - "") - ) - - (funcdef-string - (string "" retval " " - "glibtop_get_" feature "_l" - "\n") - ) - - (paramdef-string - (lambda () - (let ((start (string "glibtop *" - "server, glibtop_" - feature " *" feature - "") - ) - (param_string (string)) - (end (string "\n")) - (param_lists - (cdr (car (assoc-ref libgtop-features feature)))) - ) - (for-each - (lambda (x) - (let ((type (car x)) - (params (cdr x)) - ) - (for-each - (lambda (param) - (set! param_string (string param_string - ", " type - " " - param - "" - ) - ) - ) - params) - ) - ) - param_lists) - (string start param_string end)) - ) - ) - - (funcdef-noserver-string - (string "" retval " " - "glibtop_get_" feature "" - "\n") - ) - - (paramdef-noserver-string - (string "glibtop_" feature " *" - "" feature "\n" - "") - ) - - (field-name-constant - (lambda (name field) - (string "GLIBTOP_" - (string-upcase! (string name)) - "_" - (string-upcase! (string field))) - ) - ) - - (make-struct-name - (lambda (type) - (string "glibtop_" (assoc-ref type "name")) - ) - ) - - (tab-pad-string - (lambda (string tabs) - (let* ((slength (string-length string)) - (tlength (* tabs 8))) - (string-append string - (make-string - (if (> tlength slength) - (- tlength slength) - 1 - ) - #\space)) - ) - ) - ) - - (make-field-list - (lambda (name type fields) - (let* ((output (string)) (pos 1)) - (map - (lambda (x) - (let* ((sep (if (= pos (length fields)) ";" ",")) - (start (if (= pos 1) - (string "\t" - (tab-pad-string (string type) 2)) - (string "\t\t")) - ) - (comment (string (if (= pos 1) "" "\t") "/* " - (tab-pad-string - (field-name-constant name (car x)) 4) - " */")) - (field (tab-pad-string - (string-append (string (car x)) sep) 2)) - ) - (set! pos (+ pos 1)) - (string-append start field comment "\n") - ) - ) - fields) - ) - ) - ) - - (init-field-list - (lambda () - (let* ((old-type #f) - (type-list types) - (new-type #f) - (fields (list)) - ) - (for-each - (lambda (x) - (set! new-type (car type-list)) - (set! type-list (cdr type-list)) - (set! new-type (list-ref type-names new-type)) - (if (equal? old-type new-type) - (set-car! fields - (append (list new-type) - (cdr (car fields)) - (list (list x)) - ) - ) - (if (equal? old-type #f) - (set! fields (list (list new-type (list x)))) - (set! fields (append (list (list new-type (list x))) fields)) - ) - ) - (set! old-type new-type) - ) - names) - fields) - ) - ) - - (make-struct-body - (lambda (type) - (let* ((name (assoc-ref type "name")) - (data (assoc-ref type "fields")) - (output (string)) - ) - (for-each - (lambda (y) - (for-each - (lambda (z) - (set! output (string-append output z)) - ) - y) - ) - (map - (lambda (x) (make-field-list name (car x) (cdr x))) - data) - ) - output) - ) - ) - - (make-struct - (lambda (type) - (let* ((name (assoc-ref type "name")) - (data (assoc-ref type "fields")) - (output (string-append - (tab-pad-string - (string "typedef struct _glibtop_" name) - 5) - (string "glibtop_" name ";\n\n" - "struct _glibtop_" name "\n{\n\t" - "u_int64_t\tflags;\n") - ) - ) - ) - (string-append output (make-struct-body type) "};\n") - ) - ) - ) - - (make-param-description - (lambda () - (let* ((label-list labels) - (description-list descriptions) - (output (string)) - ) - (for-each - (lambda (name) - (let* ((label (car label-list)) - (description (car description-list)) - ) - (set! label-list (cdr label-list)) - (set! description-list (cdr description-list)) - (set! output - (string-append output - (string "\n" - "" - name - "\n\n" - "\n\n" - description "\n\n") - ) - ) - ) - ) - names) - output) - ) - ) - - ) - - (set! decl-list (assoc-set! decl-list "name" name)) - (set! decl-list (assoc-set! decl-list "label" label)) - (set! decl-list (assoc-set! decl-list "fields" (init-field-list))) - - (string-append section-string - description-string - synopsis-start-string - (string "
\n\n") - funcsynopsisinfo-string - funcdef-noserver-string - paramdef-noserver-string - (string "\n") - (string "\n") - funcdef-string - (paramdef-string) - (string "\n
\n") - definition-start-string - (string "
\n\n") - (make-struct decl-list) - (string "\n
\n") - param-description-start-string - "\n\n" - (make-param-description) - "\n\n" - "&include-" feature_nounder ".sgml;\n\n" - ) - ) - ) - ) - -;; -;; <function>glibtop_get_cpu()</function> - get CPU usage -;; -;; -;; -;; #include <glibtop.h> -;; #include <glibtop/cpu.h> -;; void glibtop_get_cpu -;; glibtop *server, glibtop_cpu *cpu_usage -;; - -(begin - (make-sysdeps-list) - - (for-each (lambda (x) - (display (make-function-reference x)) - ) - (cdr glibtop-names-sysdeps)) - ) diff --git a/guile/make-header.scm b/guile/make-header.scm deleted file mode 100644 index ec51216b..00000000 --- a/guile/make-header.scm +++ /dev/null @@ -1,195 +0,0 @@ -(define cpu-type '(("name" . "cpu") - ("label" . "CPU Usage") - ("fields" . (("unsigned long" ("total" "Total CPU Usage") - ("user") ("nice") ("sys") ("idle")) - ("const char" ("name")) - ) - ) - ) - ) - -;; computes constant for struct field (eg. GLIBTOP_CPU_TOTAL) - -(define field-name-constant - (lambda (name field) - (string "GLIBTOP_" - (string-upcase! (string name)) - "_" - (string-upcase! (string field))) - ) - ) - -;; computes structure name (eg. glibtop_cpu) - -(define make-struct-name - (lambda (type) - (string "glibtop_" (assoc-ref type "name")) - ) - ) - -(define tab-pad-string - (lambda (string tabs) - (string-append string (make-string (- (* tabs 8) (string-length string)) #\space)) - ) - ) - -(define make-field-list - (lambda (name type fields) - (let* ((output (string)) (pos 1)) - (map - (lambda (x) - (let* ((sep (if (= pos (length fields)) ";" ",")) - (start (if (= pos 1) - (string "\t" - (tab-pad-string (string type) 2)) - (string "\t\t")) - ) - (comment (string (if (= pos 1) "" "\t") "/* " - (tab-pad-string (field-name-constant name (car x)) 3) - " */")) - (field (tab-pad-string (string-append (string (car x)) sep) 2)) - ) - (set! pos (+ pos 1)) - (string-append start field comment "\n") - ) - ) - fields) - ) - ) - ) - -(define make-struct-body - (lambda (type) - (let* ((name (assoc-ref type "name")) - (data (assoc-ref type "fields")) - (output (string)) - ) - (for-each - (lambda (y) - (for-each - (lambda (z) - (set! output (string-append output z)) - ) - y) - ) - (map - (lambda (x) (make-field-list name (car x) (cdr x))) - data) - ) - output) - ) - ) - -(define make-struct - (lambda (type) - (let* ((name (assoc-ref type "name")) - (data (assoc-ref type "fields")) - (output (string-append - (tab-pad-string - (string "typedef struct _glibtop_" name) - 5) - (string "glibtop_" name ";\n\n" - "struct glibtop_" name "\n{\n\t" - "unsigned long\tflags;\n") - ) - ) - ) - (string-append output (make-struct-body type) "};\n") - ) - ) - ) - -(define make-field-name-list - (lambda (type) - (let* ((name (assoc-ref type "name")) - (data (assoc-ref type "fields")) - (return (list)) - ) - (map - (lambda (x) - (map - (lambda (y) (set! return (append return (list (car y))))) - (cdr x) - ) - ) - data) - return) - ) - ) - -(define make-field-constants - (lambda (type) - (let* ((name (assoc-ref type "name")) - (data (make-field-name-list type)) - (output (string - (tab-pad-string - (string "#define GLIBTOP_MAX_" - (string-upcase! (string name)) - ) 5) - (number->string (length data)) - "\n\n" - ) - ) - (pos 0) - ) - (for-each - (lambda (x) - (set! output (string-append output (string - (tab-pad-string - (string "#define GLIBTOP_" - (string-upcase! (string name)) - "_" - (string-upcase! (string x)) - ) 5) - (number->string pos) - "\n" - ) - ) - ) - (set! pos (+ pos 1)) - ) - data) - output) - ) - ) - -(define make-extern-defs - (lambda (type) - (let* ((name (assoc-ref type "name")) - ) - (string - (tab-pad-string (string "extern void glibtop_get_" name) 6) - "__P(glibtop *, glibtop_" name " *);\n\n" - "#ifdef HAVE_GUILE\n\n" - "/* You need to link with -lgtop_guile to get this stuff here. */\n\n" - (tab-pad-string (string "extern SCM glibtop_get_" name) 6) - "__P(void);\n\n" - "#endif /* HAVE_GUILE */\n\n" - "#ifdef GLIBTOP_GUILE_NAMES\n\n" - "/* You need to link with -lgtop_guile_names to get this stuff here. */\n\n" - (tab-pad-string (string "extern SCM glibtop_guile_names_" name) 6) - "__P(void);\n" - (tab-pad-string (string "extern SCM glibtop_guile_labels_" name) 6) - "__P(void);\n" - (tab-pad-string (string "extern SCM glibtop_guile_descriptions_" name) 6) - "__P(void);\n\n" - "#endif /* GLIBTOP_GUILE_NAMES */\n\n" - "#ifdef GLIBTOP_NAMES\n\n" - "/* You need to link with -lgtop_names to get this stuff here. */\n\n" - (tab-pad-string (string "extern const char *glibtop_names_" name) 6) - "[];\n" - (tab-pad-string (string "extern const char *glibtop_labels_" name) 6) - "[];\n" - (tab-pad-string (string "extern const char *glibtop_descriptions_" name) 6) - "[];\n\n" - "#endif /* GLIBTOP_NAMES */\n\n") - ) - ) - ) - -(begin - (display (make-field-constants cpu-type)) (newline) - (display (make-struct cpu-type)) (newline) - (display (make-extern-defs cpu-type)) (newline) - ) -