wmnd/0040755000211400001440000000000007275375300011273 5ustar wavexxuserswmnd/COPYING0100644000211400001440000004307607146456765012351 0ustar wavexxusers GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program 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 program 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., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. wmnd/CHANGELOGS0100644000211400001440000001514607275364650012642 0ustar wavexxusers Changes in WMND ------------------------------------------------------------------------------ 0.3.2 More bugfixes, linux compatibility restored - Some bugfixes in solaris drivers (testing_dummy, solaris_kstat) - Linux proc driver finally reported to linux, I can't report linux ppp since my linux machine hasn't any ppp connections. Ask to reed :) - Solaris_fpppd works on any streams compatible kernel (some *bsd and svr4), also solaris_kstat works in kstat compatible kernels (some *bsd). - Fine tuneup of makefile version detection, now we can change the wmnd version only touching src/wmnd.h Wave++ 0.3.1 Some bugfixes, new drivers - 26/04/2K+1 Wave++ has restarted coding: first fix: now a specific device for a driver can fail without removing the entire driver. - uhm, too many comments here :), I start feeling the need of cvs :). However: minor modification in main: now when a device disconnects the graph won't be fucked up with gigantic values (eg: 2450-2500 on unsigned) - started to develope a kstat driver for solaris. I think also that solaris_fpppd driver with some little hack will work also on linux (just installing mandrake to test it :)) - kstat driver completed, how cooool :), new fix for graph scale fuckup with random values ( wmnd.c::main ) - It's a good idea to not undefine TESTING_DUMMY in config.h, so when wmnd can't find any device, at least shows the dummy device "off" - Corrected minor bug on MAX history calculation ( has someone noticed that this changelog is in reverse order?) - Minor correction with makefile (directive clean) Wave++ 0.3.0 Added drivers architecture wmnd driver interface: - Sorry for new code reindentation, but I'm a c++ developer so I've found this pretty ugly :) - Now main driver selection is done in config.h, warning: some drivers cannot tell the devices list. contact me for any portability issues portability modifications history: - removed #include : it's a portable function but it's definition is in stdio.h (getopt.h it's usually for gnu version) - removed asm/bitops.h and replaced with bits.c/h for more portability see bits.h for infos, functions names terminate with a trailing "bit" - added config.h, devices.h, devices.c, and created 2 drivers, including a dummy test driver for debugging purposes - removed original device handling functions and (for now) moved to drivers.c - moved preprocessor defines in wmnd.h - added definition of MAX in wmnd.h - urgh! beat.c captures a SIGALRM and in the same time we call usleep? removed beat.* and replaced with a time() check (why using microsecond when we need only simple seconds?) - added CFG_SHOWTIME for any device, toggle with main region with Button3 - added command line attributes and config file values for any customizable part of wmnd - added more responsiveness to the app :)), look at the X loop - modifyed conf_read so now existing values that differs from standard won't be overwritten - now usage shows also built-in drivers - the draw_error function is now obsolete. still there, commented out Wave++ 0.2.1 Bug fix Wrong scale at 1K, 1M, and 1G. Wrong display scale when (rx_max + tx_max) is bigger than the value of the unsigned long int. 0.2.0 Thank to Timecop who has re-written almost whole codes of wmnd and given it optimization of efficiency. User configurable items in wmnd source file (.wmndrc) rx/tx graph color status refresh interval graph scroll speed user scripts for 3 buttons PPP conection time. 0.1.0 Changed time gap method from time() to signal driven. This change resolves the race problem when the system wakes up from hibernation mode. The values of max-meter and rate-meter are defaultly scaled by base 10 floating point division. K=1000 (10e3), M=10000000 (10e6), G=1000000000 (10e9). Using the option -b scales bitwise instead. K=1024 (2^10), M=1048576 (2^20), G=1073741824 (2^30). There is no floating point in binary mode. Displayed device name defaults to short format. Right click on the device name to toggle between full name and short name. For example, tunl1 is normally shortened to tun1, but in full name mode, tunl1 is displayed. Added a new graph display mode that is similar to wmnet, right click on the main display area to switch modes. Now there are two modes for max-meter. Default shows the maximum value from screen graphed. The second mode shows the maximum value from historical record since wmnd is started. Left click on max-meter to switch modes, right click on max-meter to toggle the display of the max-meter. Fixed the overflow bug when reading a statistics value from /proc/net/dev that's larger than INT_MAX by replacing a long integer with an unsigned long integer. 0.0.4 One more bug has been fixed. Replace line 1200 in wmnd.c while (!stat_devices[j].name[0] && j < MAX_STAT_DEVICES) { with while (j < MAX_STAT_DEVICES && !stat_devices[j].name[0]) { This bug allowed stat_devices[j] to be checked even if j is out of the range of stat_devices[], and causes a segmentation fault on some system. Thanks to Ben (rain@insane.loonybin.net) 0.0.3b The size of the device name buffer from WMiFS is 4. In other words, if there are more than 4 network devices on system, wmnd will crash. I do not know what the reasonable number is. Just change 4 to 32 if you need more. Theoretically, it will support up to 32 devices. Thanks to Paul (paul@luon.net) 0.0.3 Bug fix Changed the size of reading buffer to 256 bytes. The original size is 128 bytes, and will cause segmentation fault when the line from /proc/net/dev or /proc/net/route is longer than 128 bytes. Thanks to John Bafford (dshadow@zort.net) 0.0.2 Bug fix Corrected the AddMouseRegion for mouse-triggered user script. Thanks to Anstinus (http://www.acm.rpi.edu/~anstinus/) Added codes to skip the statistics reading of invalid device "irda?." The invalid entries in /proc/net/dev look like this: ... irda0: No statistics available. irlan0: 0 0 0 0 ... ... Thanks to Paul (paul@luon.net) 0.0.1 Initially created by Reed Lai (reed@wingeer.org) Created and modified based on WMiFS-1.3b. Displays last send and receive bytes/packets. Displays the maxima for rx and tx in current display history. Default update time gap is 1 sec. Defaults to waveform mode. Runtime switchable to waveform or traditional mode. Runtime switchable to packets or bytes mode. Runtime togglable display of maxima. wmnd/INSTALL0100644000211400001440000000370307275144464012331 0ustar wavexxusersInstallation instructions for WMND. Configuration (wmnd =>0.3) -------------------------------------------------------------- Look at these files: src/config.h (main driver selection) Makefile (platform specific flags) Installation -------------------------------------------------------------- 1) % tar -zxvf wmnd_version.tar.gz 2) % cd wmnd 3) % make 4) % su root 5) # make install or for example % make install prefix=$HOME or whatever you want. The install can be influenced by the following variables (the values listed are the defaults): prefix = /usr/local bindir = $(prefix)/bin mandir = $(prefix)/share/man/ datadir = $(prefix)/share/ docdir = $(datadir)/doc/wmnd/ 6) If this is your first time to install wmnd, copy src/wmndrc to your your home directory. Since the wmnd 0.2 has diffenent style of wmndrc to old, you should copy the new one instead of the old one. The copy command is looked like % cp wmndrc ~/.wmndrc wmnd can be run without .wmndrc, it just use the default value, and no user script defined. 7) % Edit .wmndrc to suit your use. 7) % wmnd & (or wmnd -h for brief help). Usage ------------------------------------------------------------- WMND support the following commandline options: -h Help screen -b Scale value by bitwise, read the version section 0.1.0 of file CHANGELOGS for detail. -d X server display where wmnd should appear (default = 0:0) -i Interface name, note: 'lo' can ONLY be specified with '-i lo' ;-) (default = default interface as it appears in /proc/net/route) -w Draw the statistics graph in waveform like mode. -v Print wmnd version number General Notes -------------------------------------------------------------- Note 1: Please DO read the HINTS, this file contains some very usefull tips about WMND. wmnd/TODO0100644000211400001440000000104507275365070011763 0ustar wavexxusersTODO list for WMND. ------------------------------------------------------------------------ Your feedback! If you have nice suggestions, ideas, whatever, that aren't on this list, feel free to post to Wall or mail them to me :) - Use auto(conf|make) (I can do this right now, but I want a confirmation by reed, this thing add more complexity to the project) Build some kind of good documentation :) Change every occurence of "proting" to "porting" in wmnd homepage ;) TODO are updated at web page http://www.wingeer.org/wmnd/todo.shtml wmnd/man/0040755000211400001440000000000007272554312012045 5ustar wavexxuserswmnd/man/wmnd.10100644000211400001440000001010207214621306013055 0ustar wavexxusers.\" Hey, EMACS: -*- nroff -*- .\" .\" This documentation may be distributed under the terms of .\" the GNU General Public Licence version 2. .\" .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH WMND 1 "Dec 8, 2000" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME wmnd \- WindowMaker network device monitor .SH SYNOPSIS .BR wmnd " [ " -v " | " -h " | [ " -d .IR display " ] [ " .BI -i " interface " .RB " ] [ " -w " ] [ " -b " ] ]" .SH DESCRIPTION .BR wmnd (1) is a WindowMaker dock application that shows a graph of the network traffic of the past few minutes, current activity and current and overall send and receive rates. Additionally it can launch any program in response to mouse clicks. .PP There are two modes for the max-meter (the one on top of the graph). Per default it shows the maximum value on the graph. The second mode shows the maximum value of a historical record since wmnd was started. You may left click on max-meter to switch modes, right click on max-meter to hide the max-meter. .SH OPTIONS .TP .BI "\-i " interface Start showing the status of network interface \fIinterface\fP. .TP .B \-w Draw the graph in waveform mode (default is inverse waveform mode). Right clicks cycle through all available modes. .TP .B \-b Scale the values of the maximum and current rate by factors of base 2 instead of the default 10-based scaling. (\fB1K\fP equals 1024 in binary mode, but 1000 in decimal mode.) .TP .B \-h Show summary of options. .TP .BI "\-d " display Draw onto X11 display \fIdisplay\fP. .TP .B \-v Show version of wmnd. .SH USAGE .SS Active Interface You can cycle in realtime through all available active interfaces by simply left-clicking on the interface name gadget on the upperleft corner of wmnd. .PP The 'lo' interface is an exception, 'lo' ONLY works when invoked from the commandline (\fBwmnd \-i lo\fP), lo was mainly built in for testing purposes. .SS Device Name By default, wmnd show device name in short term of four characters, for example, the ippp0 will be displayed as ipp0. You can toggle the device name between short and long by right-click on it. .SS Graphic Mode Left-click on the main graphic area to cycle the graphic mode. .SS Max Meter Left-click to toggle the history max or screen max, default is screen max when wmnd is startup. Right-click to hide or display. .SS Byte/Packet Mode Left-click on the letter gadgeted on the right-top corner can switch between the Byte or Packet counter mode. "B" for byte, "p" for packet. .SS User Script Click on the bottom rate meter can invoke the user command defined in resource file .wmndrc. .SS Dragging WMND Be sure to drag WMND on it's outer edges, it's a bit picky due to the large gfx pixmap it keeps. You can also use a keyboard and mouse shortcut (perhaps ALT+left-click) in your window manager to drag it around. .SH FILES ~/.wmndrc User configuration. .PP The format of this file is: .nf .IP # WMND configuration file .IP # middle line in wave mode color md_color=#71e371 .IP # RX/TX color (can be #xxxxxx, or color name from rgb.txt) rx_color=#188a86 tx_color=#00fff2 .IP # refresh between status polling (not graph scroll speed) # numbering in nanoseconds refresh=50000 .IP # bar graph scroll speed (in seconds) this setting also affectsi # the rate and max speed displays. the longer the delay, more # inaccurate these are since the max and rate values are averaged # across this interval scroll=1 .IP # buttons for user scripts # bt1_action=su -c ethereal # bt2_action= # bt3_action= .fi .SH SEE ALSO .BR X (3x), .BR wmaker (1x). .SH AUTHOR This manual page was written by Arthur Korn . wmnd/src/0040755000211400001440000000000007275363662012072 5ustar wavexxuserswmnd/src/wmnd.c0100644000211400001440000010271707275152224013176 0ustar wavexxusers/* * wmnd.c * by Reed Lai * * This program 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 program 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. * */ #include "wmnd.h" #include "misc.h" #include "master.xpm" #include "drivers.h" struct var *vars; /* config file option structure */ struct Devices *devices; /* devices to monitor */ DevTable wmnd; /* interesting information about devices */ Dockapp dockapp; /* dockapp structure */ MRegion mr[32]; /* mouse regions */ /* GUI */ static void redraw_window(void); unsigned long get_color(char *name); void new_window(char *name, int width, int height); /* config file read/write */ void conf_read(char *filename); void conf_write(char *filename); void assign(char *name, char *value); void vdel(char *name); struct var *lookup(char *name); char *value(char *name); char *vcopy(char *str); /* utils for command line */ int strval_fe(const struct pair_strint *data, const char *val); int defcon_lk(const char *token); void defcon_touch(char *token, char *val); /* support */ int add_mr(int index, int x, int y, int width, int height); int check_mr(int x, int y); void beat_event(void); void click_event(unsigned int region, unsigned int button); static void led_control(const unsigned char led, const unsigned char mode); void scale(char *rx_buf, char *tx_buf, unsigned long rx, unsigned long tx); void metric_scale(unsigned char sign, unsigned long value, char *buf); void binary_scale(unsigned char sign, unsigned long value, char *buf); void draw_string(unsigned char *buf, unsigned int x, unsigned int y); /* device statistics */ void draw_interface(void); void draw_rate(unsigned long rx, unsigned long tx); void draw_max(unsigned long rx, unsigned long tx); void draw_stats(struct Devices *ptr); /* driver functions */ int devices_init(const char *driver, const char *interface); /* init all drivers and fills up the devices list */ void devices_select(const char *interface); void devices_getstat(struct Devices *device, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob); void devices_destroy(); /* useless shit */ void usage(void); void printversion(void); #define copy_xpm_area(x, y, w, h, dx, dy) \ { \ XCopyArea(dockapp.d, dockapp.pixmap, dockapp.pixmap, dockapp.gc, \ x, y, w, h, dx, dy); \ dockapp.update = 1; \ } int add_mr(int index, int x, int y, int width, int height) { mr[index].enable = 1; mr[index].x = x; mr[index].y = y; mr[index].width = width; mr[index].height = height; return 0; } int check_mr(int x, int y) { register int i; register int found = 0; for (i = 0; i < 32 && !found; i++) { if (mr[i].enable && x >= mr[i].x && x <= mr[i].x + mr[i].width && y >= mr[i].y && y <= mr[i].y + mr[i].height) found = 1; } if (!found) return -1; return (i - 1); } static void redraw_window(void) { if (dockapp.update) { eprint(0, "redrawing window"); XCopyArea(dockapp.d, dockapp.pixmap, dockapp.iconwin, dockapp.gc, 0, 0, dockapp.width, dockapp.height, 0, 0); XCopyArea(dockapp.d, dockapp.pixmap, dockapp.win, dockapp.gc, 0, 0, dockapp.width, dockapp.height, 0, 0); dockapp.update = 0; } } unsigned long get_color(char *name) { XColor color; XWindowAttributes attr; color.pixel = 0; XGetWindowAttributes(dockapp.d, DefaultRootWindow(dockapp.d), &attr); XParseColor(dockapp.d, DefaultColormap(dockapp.d, DefaultScreen(dockapp.d)), name, &color); color.flags = DoRed | DoGreen | DoBlue; XAllocColor(dockapp.d, attr.colormap, &color); eprint(1, "pixel: %08lx\n", color.pixel); return color.pixel; } void new_window(char *name, int width, int height) { XpmAttributes attr; XpmColorSymbol cols[3] = { {"rx_color", NULL, 0}, {"tx_color", NULL, 0}, {"md_color", NULL, 0} }; Pixel fg, bg; XGCValues gcval; XSizeHints sizehints; XClassHint classhint; XWMHints wmhints; dockapp.width = width; dockapp.height = height; dockapp.screen = DefaultScreen(dockapp.d); dockapp.root = DefaultRootWindow(dockapp.d); sizehints.flags = USSize | USPosition; sizehints.x = dockapp.x ? dockapp.x : 0; sizehints.y = dockapp.y ? dockapp.y : 0; sizehints.width = width; sizehints.height = height; fg = BlackPixel(dockapp.d, dockapp.screen); bg = WhitePixel(dockapp.d, dockapp.screen); dockapp.win = XCreateSimpleWindow(dockapp.d, dockapp.root, sizehints.x, sizehints.y, sizehints.width, sizehints.height, 1, fg, bg); dockapp.iconwin = XCreateSimpleWindow(dockapp.d, dockapp.win, sizehints.x, sizehints.y, sizehints.width, sizehints.height, 1, fg, bg); XSetWMNormalHints(dockapp.d, dockapp.win, &sizehints); classhint.res_name = name; classhint.res_class = name; XSetClassHint(dockapp.d, dockapp.win, &classhint); XSelectInput(dockapp.d, dockapp.win, ExposureMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask); XSelectInput(dockapp.d, dockapp.iconwin, ExposureMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask); XStoreName(dockapp.d, dockapp.win, name); XSetIconName(dockapp.d, dockapp.win, name); gcval.foreground = fg; gcval.background = bg; gcval.graphics_exposures = False; dockapp.gc = XCreateGC(dockapp.d, dockapp.win, GCForeground | GCBackground | GCGraphicsExposures, &gcval); cols[0].pixel = get_color(value("rx_color")); cols[1].pixel = get_color(value("tx_color")); cols[2].pixel = get_color(value("md_color")); attr.exactColors = 0; attr.alloc_close_colors = 1; attr.closeness = 1L << 15; attr.colorsymbols = cols; attr.numsymbols = 3; attr.valuemask = (XpmColorSymbols | XpmExactColors | XpmAllocCloseColors | XpmCloseness); if (XpmCreatePixmapFromData (dockapp.d, dockapp.win, master_xpm, &dockapp.pixmap, &dockapp.mask, &attr) != XpmSuccess) { fprintf(stderr, "Not enough colors!\n"); exit(-1); } XShapeCombineMask(dockapp.d, dockapp.win, ShapeBounding, 0, 0, dockapp.mask, ShapeSet); XShapeCombineMask(dockapp.d, dockapp.iconwin, ShapeBounding, 0, 0, dockapp.mask, ShapeSet); wmhints.initial_state = WithdrawnState; wmhints.flags = StateHint; wmhints.icon_window = dockapp.iconwin; wmhints.icon_x = sizehints.x; wmhints.icon_y = sizehints.y; wmhints.window_group = dockapp.win; wmhints.flags = StateHint | IconWindowHint | IconPositionHint | WindowGroupHint; XSetWMHints(dockapp.d, dockapp.win, &wmhints); XMapWindow(dockapp.d, dockapp.win); dockapp.xfd = ConnectionNumber(dockapp.d); } /* support function - chop cr/lf off the end of a string */ void chomp(char *buffer) { int i = strlen(buffer) - 1; while (buffer[i] == '\n' || buffer[i] == '\r') { buffer[i--] = '\0'; } } void conf_read(char *filename) { FILE *fp; char buf[1024]; int pos; int line = 0; int exist; char *lk; fp = fopen(filename, "r"); if (fp) { /* actually read in the config file, skipping over short and #lines */ while (fgets(buf, 1024, fp)) { line++; if (buf[0] == '#' || (strlen(buf) < 2)) { continue; } chomp(buf); pos = strcspn(buf, "="); if (pos < strlen(buf)) { buf[pos++] = '\0'; /* check for existent value */ exist = 0; lk = value(buf); exist = defcon_lk(buf); /* search for buf in defaults */ if (exist != -1 && !pss_defcon[exist].used) exist = -1; if (exist == -1) /* only if isn't a default or it's not on cmdline */ assign(buf, buf+pos); } memset(buf, 0, 1024); } fclose(fp); } else { /* can't open the rc file, make a new one */ fprintf(stderr, "Can't open WMND config file %s\n", filename); fprintf(stderr, "Using default settings\n"); conf_write(filename); } } void conf_write(char *filename) { FILE *fp; struct var *vp; fp = fopen(filename, "w"); if (!fp) { fprintf(stderr, "Can't open config file for writing\n"); exit(1); } fprintf(fp, "# WMND configuration file (generated automatically)\n\n"); for (vp = vars; vp; vp = vp->v_next) fprintf(fp, "%s=%s\n", vp->v_name, vp->v_value); fclose(fp); } void assign(char *name, char *value) { struct var *vp; struct var *new; new = (struct var *) malloc(sizeof(struct var)); vdel(name); if (vars == NULL || strcmp(vars->v_name, name) >= 0) { new->v_next = vars; vars = new; } else { vp = vars; while (vp->v_next && strcmp(vp->v_next->v_name, name) <= 0) { vp = vp->v_next; } new->v_next = vp->v_next; vp->v_next = new; } new->v_name = vcopy(name); new->v_value = vcopy(value); } void vdel(char *name) { struct var *vp; struct var *new; while (vars && !strcmp(vars->v_name, name)) { vp = vars->v_next; free((struct var *) vars); vars = vp; } if (vars) { for (new = vars; new->v_next;) if (!strcmp(new->v_next->v_name, name)) { vp = new->v_next->v_next; free(new->v_next); new->v_next = vp; } else new = new->v_next; } } char *vcopy(char *str) { char *new; unsigned int len; if (str == NULL) return ""; len = strlen(str) + 1; new = malloc(len); memcpy(new, str, len); return new; } int strval_fe(const struct pair_strint *data, const char *val) { /* returns the correct value for val as int */ int cnt = 0; while (data[cnt].strval) { if (!strcmp(val,data[cnt].strval)) return data[cnt].val; cnt++; } /* not found, return default[0] */ return data[cnt].val; } int defcon_lk(const char *token) { int rtval = 0; while (pss_defcon[rtval].token) { if (!strcmp(token,pss_defcon[rtval].token)) return rtval; rtval++; } return -1; } void defcon_touch(char *token, char *val) { int idx = defcon_lk(token); assign(token, val); if (idx != -1) pss_defcon[idx].used = 1; } struct var *lookup(char *name) { struct var *vp; for (vp = vars; vp; vp = vp->v_next) if (!strcmp(name, vp->v_name)) return vp; return NULL; } char *value(char *name) { struct var *vp; if ((vp = lookup(name)) == NULL) return NULL; return vp->v_value; } void beat_event(void) { unsigned long diff; unsigned int min, hr; char temp[16]; eprint(0, "activated"); if (!wmnd.curdev->online) { if (!bit_get(RUN_ONLINE)) { bit_set(RUN_ONLINE); led_control(LED_POWER, 1); } } else { if (bit_get(RUN_ONLINE)) { bit_off(RUN_ONLINE); led_control(LED_POWER, 0); } } if (bit_get(CFG_SHOWTIME) && wmnd.curdev->devstart) { diff = difftime(time(NULL), wmnd.curdev->devstart) / 60; min = diff % 60; hr = (diff / 60) % 100; sprintf(temp, "%02d.%02d", hr, min); draw_string(temp, 71, 36); } } void click_event(unsigned int region, unsigned int button) { char *action = NULL; if (region == -1) /* no region */ return; eprint(1, "clicked btn %d in region %d", button, region); if (region == 0) { switch (button) { case Button1: devices_select(NULL); draw_interface(); break; case Button3: bit_tgl(CFG_SHORTNAME); eprint(1, "shortname: %d", bit_get(CFG_SHORTNAME)); draw_interface(); break; } } else if (region == 1) { if (button == Button1) { bit_tgl(CFG_MODE); led_control(LED_POWER, bit_get(RUN_ONLINE)); } } else if (region == 2) { if (button == Button1) { if (wmnd.wavemode < 2) wmnd.wavemode++; else wmnd.wavemode = 0; eprint(1, "wavemode: %d", wmnd.wavemode); } else if(button == Button3) /* switch time visualization */ bit_tgl(CFG_SHOWTIME); } else if (region == 3) { switch (button) { case Button1: /* switch max screen/history */ bit_tgl(CFG_MAXSCREEN); break; case Button3: /* toggle max display */ bit_tgl(CFG_SHOWMAX); break; } } else if (region == 4) { switch (button) { case Button1: action = value("bt1_action"); break; case Button2: action = value("bt2_action"); break; case Button3: action = value("bt3_action"); break; } if (action) execCommand(action); } } int main(int argc, char **argv) { char *dispname = NULL; char *active_interface = NULL; char *drv_interface = NULL; char *drv_name = NULL; int parse_conf = 1; char *conf_file = NULL; struct Devices *ptr; unsigned long int ib, ob, ip, op; time_t beat_time; int ch; int btn = 0, rgn = -1; XEvent event; #ifdef PRO int counter = 10000; #endif eprint(1, "wmnd start"); wmnd.wavemode = 2; wmnd.scale = metric_scale; /* * set default config options before option parsing so command line can * overwrite config options */ wmnd.nr_devices = 0; wmnd.flags = 0; bit_set(RUN_ONLINE); bit_set(CFG_MODE); /* * initalize default values using pss_defcon * we can use ch, because it's used later */ ch = 0; while (pss_defcon[ch].token) { assign(pss_defcon[ch].token,pss_defcon[ch].value); ch++; } /* parse command line */ while ((ch = getopt(argc, argv, "bc:C:L:d:i:hlmMf:Fr:s:tvw:D:I:")) != EOF) { switch (ch) { case 'b': defcon_touch("binary_scale","yes"); break; case 'c': defcon_touch("tx_color", optarg); break; case 'C': defcon_touch("rx_color", optarg); break; case 'L': defcon_touch("md_color", optarg); break; case 'd': dispname = strdup(optarg); break; case 'i': defcon_touch("interface_name",optarg); break; case 'l': defcon_touch("use_long_names","yes"); break; case 'm': defcon_touch("show_max_values","no"); break; case 'M': defcon_touch("use_max_history","yes"); break; case 'f': conf_file = strdup(optarg); break; case 'F': parse_conf = 0; break; case 'r': defcon_touch("refresh", optarg); break; case 's': defcon_touch("scroll", optarg); break; case 't': defcon_touch("display_time","no"); break; case 'v': printversion(); exit(0); break; case 'w': defcon_touch("wave_mode",optarg); break; case 'D': defcon_touch("driver",optarg); break; case 'I': defcon_touch("driver_interface",optarg); break; default: usage(); exit(0); break; } } if (parse_conf) { if (!conf_file) { char *tmp; tmp = getenv("HOME"); conf_file = calloc(1, strlen(tmp) + 9); strcat(conf_file, tmp); strcat(conf_file, "/.wmndrc"); } conf_read(conf_file); } /* set stuff here */ wmnd.refresh = atoi(value("refresh")); wmnd.scroll = atoi(value("scroll")); if (strval_fe(psi_bool,value("binary_scale"))) wmnd.scale = binary_scale; else wmnd.scale = metric_scale; active_interface = strdup(value("interface_name")); if (!strcmp(active_interface,"%first")) { free(active_interface); active_interface = NULL; } if (!strval_fe(psi_bool,value("use_long_names"))) bit_set(CFG_SHORTNAME); if (strval_fe(psi_bool,value("show_max_values"))) bit_set(CFG_SHOWMAX); if (!strval_fe(psi_bool,value("use_max_history"))) bit_set(CFG_MAXSCREEN); if (strval_fe(psi_bool,value("display_time"))) bit_set(CFG_SHOWTIME); wmnd.wavemode = strval_fe(psi_wavemode,value("wave_mode")); drv_name = strdup(value("driver")); if (!strcmp(drv_name,"%auto")) { free(drv_name); drv_name = NULL; } drv_interface = strdup(value("driver_interface")); if (!strcmp(drv_interface,"%any")) { free(drv_interface); drv_interface = NULL; } /* initialize drivers and devices */ if (!active_interface) active_interface = drv_interface; if (devices_init(drv_name, drv_interface)) { fprintf(stderr, "No network interfaces found, exiting\n"); exit(1); } eprint(1, "open X display"); if (!(dockapp.d = XOpenDisplay(dispname))) { fprintf(stderr, "Unable to open display '%s'\n", dispname); exit(-1); } new_window("wmnd", 64, 64); add_mr(0, 3, 3, 38, 9); /* device */ add_mr(1, 54, 3, 7, 9); /* up/down packet/byte mode */ add_mr(2, 3, 22, 58, 31); /* main display area */ add_mr(3, 3, 13, 58, 9); /* scale meter */ add_mr(4, 3, 54, 58, 7); /* user script? huh wtf does that do */ time(&beat_time); /* init graph updates */ wmnd.draw = draw_stats; if (!active_interface) /* set default device name */ wmnd.curdev = devices; else devices_select(active_interface); eprint(1, "found %d devices [%s]", wmnd.nr_devices, wmnd.curdev->name); draw_interface(); eprint(1, "looping"); XSync(dockapp.d, False); /* kick off X11 queue */ /* loop forever */ #ifndef PRO #define EVER 1 #else #define EVER (counter--) #endif while (EVER) { unsigned int j; time_t beat_ctime; /* get statistics for each existing device */ for (ptr = devices; ptr; ptr = ptr->next) { devices_getstat(ptr, &ip, &op, &ib, &ob); /* check for device shutdown */ if (ib < ptr->ib_stat_last) ptr->ib_stat_last = ib; if (ob < ptr->ob_stat_last) ptr->ob_stat_last = ob; if (ip < ptr->ip_stat_last) ptr->ip_stat_last = ip; if (op < ptr->op_stat_last) ptr->op_stat_last = op; ptr->his[57][0] += ib - ptr->ib_stat_last; ptr->his[57][1] += ob - ptr->ob_stat_last; ptr->his[57][2] += ip - ptr->ip_stat_last; ptr->his[57][3] += op - ptr->op_stat_last; ptr->ib_max_his = MAX(ptr->ib_max_his, ptr->his[57][0]); ptr->ob_max_his = MAX(ptr->ob_max_his, ptr->his[57][1]); ptr->ip_max_his = MAX(ptr->ip_max_his, ptr->his[57][2]); ptr->op_max_his = MAX(ptr->op_max_his, ptr->his[57][3]); if (ptr == wmnd.curdev) { /* displayed */ if (ptr->ib_stat_last == ib) { led_control(LED_RX, 0); } else { led_control(LED_RX, 1); } if (ptr->ob_stat_last == ob) { led_control(LED_TX, 0); } else { led_control(LED_TX, 1); } } ptr->ib_stat_last = ib; ptr->ob_stat_last = ob; ptr->ip_stat_last = ip; ptr->op_stat_last = op; } /* end get statistics */ time(&beat_ctime); if ((beat_ctime-beat_time) >= wmnd.scroll) { beat_time = beat_ctime; beat_event(); /* scroll the statistics */ wmnd.draw(wmnd.curdev); for (ptr = devices; ptr; ptr = ptr->next) { for (j = 1; j < 58; j++) { ptr->his[j - 1][0] = ptr->his[j][0]; ptr->his[j - 1][1] = ptr->his[j][1]; ptr->his[j - 1][2] = ptr->his[j][2]; ptr->his[j - 1][3] = ptr->his[j][3]; } ptr->his[57][0] = 0; ptr->his[57][1] = 0; ptr->his[57][2] = 0; ptr->his[57][3] = 0; } } /* * beat_event and redraw added also on expose and button release * events. Now the app is much responsive to user action */ while (XPending(dockapp.d)) { eprint(1, "X11 activity"); XNextEvent(dockapp.d, &event); switch (event.type) { case Expose: dockapp.update = 1; redraw_window(); beat_event(); wmnd.draw(wmnd.curdev); break; case DestroyNotify: XCloseDisplay(dockapp.d); exit(0); break; case ButtonPress: btn = event.xbutton.button; rgn = check_mr(event.xbutton.x, event.xbutton.y); break; case ButtonRelease: if (btn == event.xbutton.button) { if (rgn == check_mr(event.xbutton.x, event.xbutton.y)) { click_event(rgn, btn); beat_event(); wmnd.draw(wmnd.curdev); } } break; } } redraw_window(); #ifndef PRO usleep(wmnd.refresh); #endif } devices_destroy(); exit(0); } void binary_scale(unsigned char sign, unsigned long value, char *buf) { unsigned char scale; unsigned int i; char *r; if (value > 1073741823) { /* scale in giga */ value = value >> 30; scale = 'G'; } else if (value > 1048575) { /* scale in mega */ value = value >> 20; scale = 'M'; } else if (value > 1023) { /* scale in kilo */ value = value >> 10; scale = 'K'; } else { scale = ' '; } sprintf(buf, "%c%lu", sign, value); /* to string */ r = buf; r++; for (i = 3; i > 0 && *r != '\0'; i--) { if (*r == '+' || *r == '-' || *r == '.') { ++i; } ++r; } *r++ = scale; *r = '\0'; } void metric_scale(unsigned char sign, unsigned long value, char *buf) { float f; unsigned char scale; unsigned int i; char *r; f = (float) value; if (value > 999999999) { /* scale in giga */ f /= 1000000000; scale = 'G'; } else if (value > 999999) { /* scale in mega */ f /= 1000000; scale = 'M'; } else if (value > 999) { /* scale in kilo */ f /= 1000; scale = 'K'; } else { scale = ' '; } sprintf(buf, "%c%f", sign, f); /* to string */ r = buf; r++; for (i = 3; i > 0 && *r != '\0'; i--) { if (*r == '+' || *r == '-' || *r == '.') { ++i; } ++r; } *r++ = scale; *r = '\0'; } void scale(char *rx_buf, char *tx_buf, unsigned long rx, unsigned long tx) { char rx_sign, tx_sign; if (rx > tx) { rx_sign = '+'; tx_sign = '#'; } else if (rx < tx) { rx_sign = '-'; tx_sign = '*'; } else { rx_sign = '-'; tx_sign = '#'; } if (wmnd.scroll != 1) { tx /= wmnd.scroll; rx /= wmnd.scroll; } wmnd.scale(tx_sign, tx, tx_buf); wmnd.scale(rx_sign, rx, rx_buf); } void draw_string(unsigned char *buf, unsigned int x, unsigned int y) { unsigned int w, sx = 0, sy = 0; unsigned int draw; char *r; w = 3; draw = 0; for (r = buf; *r != '\0'; r++) { if (*r >= '0' && *r <= '9') { w = 5; sx = 1 + (w * (*r - '0')); sy = 85; draw = 1; } else if (*r == '.') { w = 2; sx = 62; sy = 85; draw = 1; } else if (*r >= 'A' && *r <= 'Z') { w = 5; sx = 1 + (w * (*r - 'A')); sy = 93; draw = 1; } else if (*r == '+') { w = 6; if (bit_get(CFG_MAXSCREEN)) { sx = 133; sy = 93; } else { sx = 66; sy = 46; } draw = 1; } else if (*r == '-') { w = 6; if (bit_get(CFG_MAXSCREEN)) { sx = 139; sy = 93; } else { sx = 72; sy = 46; } draw = 1; } else if (*r == '*') { w = 6; if (bit_get(CFG_MAXSCREEN)) { sx = 145; sy = 93; } else { sx = 78; sy = 46; } draw = 1; } else if (*r == '#') { w = 6; if (bit_get(CFG_MAXSCREEN)) { sx = 151; sy = 93; } else { sx = 84; sy = 46; } draw = 1; } if (draw) { copy_xpm_area(sx, sy, w, 7, x, y); draw = 0; } x += w; } } void draw_rate(unsigned long rx, unsigned long tx) { char rx_buf[16]; char tx_buf[16]; /* clear rate bar */ copy_xpm_area(100, 85, 58, 7, 3, 54); /* put rx/tx numbers into strings, scaling them */ scale(rx_buf, tx_buf, rx, tx); /* draw rx/tx strings */ draw_string(rx_buf, 3, 54); draw_string(tx_buf, 32, 54); } void draw_max(unsigned long rx, unsigned long tx) { char rx_buf[16]; char tx_buf[16]; /* clear rate bar */ copy_xpm_area(100, 85, 58, 7, 3, 11); /* put rx/tx numbers into strings, scaling them */ scale(rx_buf, tx_buf, rx, tx); /* draw rx/tx strings */ draw_string(rx_buf, 3, 11); draw_string(tx_buf, 32, 11); } /* * void draw_error(struct Devices *ptr) *{ * copy_xpm_area(25, 75, 5, 7, 12, 30); * copy_xpm_area(103, 75, 5, 7, 18, 30); * copy_xpm_area(103, 75, 5, 7, 24, 30); * copy_xpm_area(85, 75, 5, 7, 30, 30); * copy_xpm_area(103, 75, 5, 7, 36, 30); *} */ void draw_stats(struct Devices *ptr) { int bpp = 1; /* bytes per pixel */ unsigned int k; unsigned long int *p; unsigned int in, out; unsigned long int rx_max_his, tx_max_his; unsigned long long int rx_max, tx_max, max; unsigned int size; if (bit_get(CFG_SHOWMAX)) size = 35; /* with max bar mode */ else size = 41; /* without max bar */ if (bit_get(CFG_MODE)) { /* bytes mode */ in = 0; out = 1; rx_max_his = ptr->ib_max_his; tx_max_his = ptr->ob_max_his; } else { /* packets mode */ in = 2; out = 3; rx_max_his = ptr->ip_max_his; tx_max_his = ptr->op_max_his; } /* find maximum value in screen history */ rx_max = tx_max = 0; p = (unsigned long *) ptr->his; for (k = 0; k < 58; k++) { rx_max = MAX(rx_max, p[in]); tx_max = MAX(tx_max, p[out]); p += 4; } if ((max = rx_max + tx_max) > size) { bpp = max / size; if ((max % size) > 0) { ++bpp; } } /* draw rx/tx rate */ p -= 4; /* sets p to his[58] or so */ draw_rate(p[in], p[out]); if (bit_get(CFG_MAXSCREEN)) draw_max(rx_max, tx_max); else draw_max(rx_max_his, tx_max_his); p = (unsigned long *) ptr->his; switch (wmnd.wavemode) { case 0: /* traditional mode */ for (k = 0; k < 58; k++) { unsigned int txlev, rxlev, nolev; rxlev = p[in] / bpp; txlev = p[out] / bpp; nolev = size - (rxlev + txlev); copy_xpm_area(66, 0, 1, txlev, k + 3, 53 - (rxlev + txlev)); copy_xpm_area(65, 0, 1, nolev, k + 3, 53 - size); copy_xpm_area(67, 0, 1, rxlev, k + 3, 53 - rxlev); p += 4; } copy_xpm_area(70, 1, 58, 1, 3, 53 - size); break; case 1: /* wave form mode */ for (k = 0; k < 58; k++) { unsigned int txlev, rxlev, center; rxlev = p[in] / bpp / 2; /* we need them like this */ txlev = p[out] / bpp / 2; /* we need it like this */ center = 53 - size / 2; copy_xpm_area(65, 0, 1, size, k + 3, 53 - size); copy_xpm_area(66, 0, 1, txlev, k + 3, (center - rxlev) - txlev); copy_xpm_area(66, 0, 1, txlev, k + 3, (center + rxlev)); copy_xpm_area(67, 0, 1, rxlev * 2, k + 3, center - rxlev); p += 4; } copy_xpm_area(70, 1, 58, 1, 3, 53 - size); copy_xpm_area(70, 0, 58, 1, 3, 53 - size / 2); break; case 2: /* WMNET mode */ for (k = 0; k < 58; k++) { unsigned int txlev, rxlev, nolev; txlev = p[out] / bpp; rxlev = p[in] / bpp; nolev = size - (rxlev + txlev); copy_xpm_area(66, 0, 1, txlev, k + 3, 53 - size); copy_xpm_area(65, 0, 1, nolev, k + 3, (53 - size) + txlev); copy_xpm_area(67, 0, 1, rxlev, k + 3, 53 - rxlev); p += 4; } copy_xpm_area(70, 1, 58, 1, 3, 53 - size); break; } /* copy PPP connection time over the graph */ if (bit_get(CFG_SHOWTIME) && wmnd.curdev->devstart) { copy_xpm_area(70, 36, 23, 7, 37, 46); } } static void led_control(const unsigned char led, const unsigned char mode) { eprint(0, "led: %02x[%02x]", led, mode); switch (led) { case LED_POWER: switch (bit_get(CFG_MODE)) { case 1: /* bytes */ if (mode) { /* on-line */ copy_xpm_area(116, 64, 5, 7, 55, 4); } else { /* off-line */ copy_xpm_area(122, 64, 5, 7, 55, 4); } break; case 0: /* packets */ if (mode) { /* on-line */ copy_xpm_area(128, 64, 5, 7, 55, 4); } else { /* off-line */ copy_xpm_area(134, 64, 5, 7, 55, 4); } break; } break; case LED_RX: if (mode) { /* turn on */ if (bit_get(LED_RX)) { eprint(0, "RX led already on"); return; /* already on */ } copy_xpm_area(86, 69, 5, 4, 41, 4); bit_set(LED_RX); eprint(0, "RX led on"); } else { /* turn off */ if (!bit_get(LED_RX)) { eprint(0, "RX led already off"); return; } copy_xpm_area(92, 69, 5, 4, 41, 4); bit_off(LED_RX); eprint(0, "RX led off"); } break; case LED_TX: if (mode) { /* turn on */ if (bit_get(LED_TX)) { eprint(0, "TX led already on"); return; /* already on */ } copy_xpm_area(86, 64, 5, 4, 48, 4); bit_set(LED_TX); eprint(0, "TX led on"); } else { /* turn off */ if (!bit_get(LED_TX)) { eprint(0, "TX led already off"); return; } copy_xpm_area(92, 64, 5, 4, 48, 4); bit_off(LED_TX); eprint(0, "TX led off"); } break; } } void draw_interface(void) { int i; int c; int k = 3; unsigned char temp[7]; char *cur_name = wmnd.curdev->name; int cur_namelen = strlen(cur_name); /* refresh */ copy_xpm_area(65, 54, 38, 9, 3, 3); led_control(LED_POWER, bit_get(RUN_ONLINE)); /* * little modify to handle names shorter than 4 chars and minor bugfix * for names shorter than 6 chars (memory overwrite) */ if (bit_get(CFG_SHORTNAME)) { strncpy(temp, cur_name, (cur_namelen<4)?cur_namelen:3); temp[3] = (cur_namelen<4)?'\0':cur_name[cur_namelen - 1]; temp[4] = '\0'; } else { if (cur_namelen>6) cur_namelen = 6; strncpy(temp, cur_name, cur_namelen); temp[cur_namelen] = '\0'; } for (i = 0; temp[i]; i++) { c = temp[i]; if (c >= '0' && c <= '9') { c -= '0'; copy_xpm_area(c * 6, 64, 6, 9, k, 3); k += 6; } else { if (c >= 'a' && c <= 'z') c = c - 'a' + 'A'; c -= 'A'; copy_xpm_area(c * 6, 74, 6, 9, k, 3); k += 6; } } } void usage(void) { int cnt = 0; fprintf(stderr, "\nwmnd - WindowMaker Network Devices v%s\n" "Home page: http://www.wingeer.org/wmnd/\n\n" "usage:\n" " -b base 2 scale (no fractions)\n" " -c tx color\n" " -C rx color\n" " -L middle line color\n" " -d \n" " -h this help screen\n" " -i select this interface at startup\n" " -l start using long device names\n" " -m start with max values hidden\n" " -M use max values from the entire history\n" " -f read config instead of ~/.wmndrc\n" " -F don't parse ~/.wmndrc\n" " -r refresh rate in microseconds\n" " -s scroll rate in seconds\n" " -t start without displaying time\n" " -v print the version number\n" " -w select mode: traditional, waveform, wmnet\n" " -D specify a driver to use\n" " -I tell to driver/s the interface to monitor\n" "buitin drivers: ", WMND_VERSION); while(drivers_table[cnt].driver_name) { if (drivers_table[cnt+1].driver_name) fprintf(stderr,"%s, ",drivers_table[cnt].driver_name); else fprintf(stderr,"%s.\n",drivers_table[cnt].driver_name); cnt++; } } void printversion(void) { fprintf(stderr, "%s\n", WMND_VERSION); } int devices_init(const char *driver, const char *interface) { /* * devices init, initializes all drivers/devices * return: 0 on success, 1 on error */ int cnt = -1; int devnum; int in_loop0; struct Devices *prt; struct Devices *aftPrt; struct Devices *tmpPrt; wmnd.nr_devices = 0; /* creating and empy first device */ devices = malloc(sizeof(struct Devices)); devices->next = NULL; prt = devices; /* starting all drivers */ do { cnt++; /* check if driver is specified and check devicename */ if (driver && strcmp(driver, drivers_table[cnt].driver_name)) continue; /* device matches or driver is NULL, than check if driver is avaible */ aftPrt = prt; devnum = (*drivers_table[cnt].list_devices)(interface, prt); if (!devnum) continue; /* driver is avaible, set up all driver's devices */ for (in_loop0 = 0; in_loop0 < devnum; in_loop0++) { prt = prt->next; prt->drvnum = cnt; /* set hes driver */ if ((*drivers_table[cnt].init_driver)(prt) == 1) /* init the device */ { fprintf(stderr, "Failed to initialize device %s,%d\n", drivers_table[cnt].driver_name, in_loop0); devnum--; /* last element in list */ if (in_loop0 == devnum-1 || !devnum) { free(prt); prt = aftPrt; continue; } /* remove device from list */ tmpPrt = prt->next; free(prt); prt = tmpPrt; if (in_loop0 == devnum) continue; aftPrt = prt; in_loop0--; } else { /* initialize statistics for this device */ int cnt; unsigned long int ib, ob, ip, op; /* sample some stats to inizialize cleanly the graph */ (*drivers_table[prt->drvnum].get_stats)(prt, &ip, &op, &ib, &ob); prt->ib_max_his = ib; prt->ob_max_his = ob; prt->ip_max_his = ip; prt->op_max_his = op; prt->ib_stat_last = ib; prt->ob_stat_last = ob; prt->ip_stat_last = ip; prt->op_stat_last = op; /* cleaning history */ for (cnt = 0; cnt < 58; cnt++) { prt->his[cnt][0] = 0; prt->his[cnt][1] = 0; prt->his[cnt][2] = 0; prt->his[cnt][3] = 0; } } } /* all new devices are ok */ wmnd.nr_devices += devnum; } while (drivers_table[cnt+1].driver_name); /* remove the first null element */ prt = devices; devices = prt->next; free(prt); /* no drivers loaded */ if (!wmnd.nr_devices) return 1; return 0; } void devices_select(const char *interface) { /* * devices_select: sets wmnd.curdev looking up a name * if name is null, cycles for next device */ struct Devices *prt = devices; if (interface) { /* searching for a device */ wmnd.curdev = devices; while(prt) { if (!strcmp(interface, prt->name)) { /* name matches */ wmnd.curdev = prt; break; } prt = prt->next; } } else { /* switching active device */ if (!wmnd.curdev->next) wmnd.curdev = devices; /* last element, back to first */ else wmnd.curdev = wmnd.curdev->next; } } void devices_getstat(struct Devices *device, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob) { /* * devices_getstat: run appropriate get_stats for device */ device->online = (*drivers_table[device->drvnum].get_stats)(device, ip, op, ib, ob); } void devices_destroy() { /* * devices_destroy: sends destroy signal to all devices and frees devices */ struct Devices *ptr; while (devices->next) { ptr = devices; devices = devices->next; (*drivers_table[ptr->drvnum].terminate_driver)(ptr); free(ptr); } } wmnd/src/master.xpm0100644000211400001440000004077507204536723014115 0ustar wavexxusers/* XPM */ static char * master_xpm[] = { "160 100 27 1", " c None", ". c #202020", "+ c #00FFFF s tx_color", "@ c #1C8C8C s rx_color", "# c #004941", "$ c #72E572 s md_color", "% c #000000", "& c #333133", "* c #666366", "= c #999599", "- c #22332F", "; c #283C38", "> c #C7C3C7", ", c #B59900", "' c #D8BB00", ") c #188A86", "! c #20B2AE", "~ c #FFDD00", "{ c #00FFF2", "] c #B60418", "^ c #009900", "/ c #FF0724", "( c #00EB00", "_ c #00AD00", ": c #F7F3FF", "< c #1E1E27", "[ c #1F1F22", " .+@# $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ", " .+@# ########################################################## ", " %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&* .+@# ", " %..........................................................= .+@# ", " %.-###-.-###-.-###-.-###-..-###-.-###-.;;;;;....;....-;;;-.> .+@# ", " %.#...#.#...#.#...#.#...#..#...#.#...#..;;;....;;;...;...;.> .+@# ", " %.#...#.#...#.#...#.#...#..#...#.#...#..;;;....;;;...;...;.> .+@# ", " %.-###-.-###-.-###-.-###-..-###-.-###-...;....;;;;;..-;;;-.> .+@# ", " %.#...#.#...#.#...#.#...#..#...#.#...#...............;...;.> .+@# ", " %.#...#.#...#.#...#.#...#..#...#.#...#.-;-;-..-;-;-..;...;.> .+@# ", " %.-###-.-###-.-###-.-###-..-###-.-###-.;.;.;..;.;.;..-;;;-.> .+@# ", " %..........................................................> .+@# ", " %##########################################################> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %##########################################################> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> .+@# ........................ ", " %..........................................................> .+@# ........................ ", " %..........................................................> .+@# ........................ ", " %..........................................................> .+@# ........................ ", " %..........................................................> .+@# ........................ ", " %..........................................................> .+@# ........................ ", " %..........................................................> .+@# ........................ ", " %..........................................................> .+@# ........................ ", " %..........................................................> .+@# ", " %..........................................................> .+@# ", " %..........................................................> ......................................................................... ", " %..........................................................> .,''',.)!!!)...,.....)...,''',.)!!!)...,.....)...,''',.)!!!)...,.....)... ", " %..........................................................> ...~.....{.....'.....!.....~.....{.....'.....!...,.~...).{.....'.....!... ", " %..........................................................> ...~.....{.....~.....{....'~'...!{!...'~'...!{!..,.~...).{...,.~...).{... ", " %..........................................................> ...'.....!.....~.....{.....'.....!.....~.....{.....'.....!...,.~...).{... ", " %..........................................................> ...,.....)...,''',.)!!!)...,.....)...,''',.)!!!)...,.....)...,''',.)!!!). ", " %..........................................................> ......................................................................... ", " %##########################################################> ", " %..........................................................> .......................................................... ,~,~, ,~~, ", " %..........................................................> .-###-.-###-.-###-.-###-..-###-.-###-.;;;;;....;....-;;;-. ~.~.~ ~..~ ", " %..........................................................> .#...#.#...#.#...#.#...#..#...#.#...#..;;;....;;;...;...;. ", " %..........................................................> .#...#.#...#.#...#.#...#..#...#.#...#..;;;....;;;...;...;. ", " %..........................................................> .-###-.-###-.-###-.-###-..-###-.-###-...;....;;;;;..-;;;-. ", " %..........................................................> .#...#.#...#.#...#.#...#..#...#.#...#...............;...;. ,~,~, ,~~, ", " &..........................................................> .#...#.#...#.#...#.#...#..#...#.#...#.-;-;-..-;-;-..;...;. ~.~.~ ~..~ ", " *=>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> .-###-.-###-.-###-.-###-..-###-.-###-.;.;.;..;.;.;..-;;;-. ", " .......................................................... ", " ", "............................................................................... ..].. ..^.. ..;.. .//. .((. .;;. _(((- ]///- _(((_ ]///] -;;;- ", "..!!!...###).)!!!).)!!!).)###).)!!!).)!!!).)!!!).)!!!).)!!!)................... .]/]. .^(^. .-;-. /:// (:(( ;;;; (...( /.../ (...( /.../ ;...; ", ".!...!.#...!.#...!.#...!.!...!.!...#.!...#.#...!.!...!.!...!............!...... .///. .(((. .;;;. //// (((( ;;;; (...( /.../ (...( /.../ ;...; ", ".!...!.#...!.#...!.#...!.!...!.!...#.!...#.#...!.!...!.!...!.......!....!...... ]///] ^(((^ -;;;- .//. .((. .;;. _(((; ]///; _(((_ ]///] -;;;- ", ".)###)..###).)!!!)..!!!).)!!!).)!!!).)!!!)..###).)!!!).)!!!)..)!...)...!....... (...( /.../ (...; /...; ;...; ", ".!...!.#...!.!...#.#...!.#...!.#...!.!...!.#...!.!...!.#...!...........!....... ]///] ^(((^ -;;;- ]//] _((_ -;;- (...( /.../ (...; /...; ;...; ", ".!...!.#...!.!...#.#...!.#...!.#...!.!...!.#...!.!...!.#...!.......!..!........ .///. .(((. .;;;. //// (((( ;;;; _(((- ]///- _;;;. ];;;. -;;;- ", "..!!!...###).)!!!).)!!!)..###).)!!!).)!!!)..###).)!!!).)!!!).......)..!........ .]/]. .^(^. .-;-. //// (((( ;;;; ", "............................................................................... ..].. ..^.. ..;.. ]//] _((_ -;;- ", " ", "................................................................................................................................................................", ".#!!!#.)!!!...!!!).)!!!..)!!!).)!!!).)!!!).)###)..###)..###).)###).)###..!###!.)!!!..)!!!).)!!!).)!!!).)!!!).)!!!).)!!!).)###).)###).)###).)###).)###).)!!!)....", ".!...!.!...!.!...#.!...!.!...#.!...#.!...#.!...!.#...!.#...!.!...!.!...#.!!.!!.!...!.!...!.!...!.!...!.!...!.!...#.#.!.#.!...!.!...!.!...!.!...!.!...!.#...!....", ".!...!.!...!.!...#.!...!.!...#.!...#.!...#.!...!.#...!.#...!.!...!.!...#.!.!.!.!...!.!...!.!...!.!...!.!...!.!...#.#.!.#.!...!.!...!.!...!..!.!..!...!.#..!#....", ".)!!!).)!!!..)###..)###).)!!!..)!!!..)#)!).)!!!)..###)..###).)!!!..)###..)###).)###).)###).)!!!).)!##).)!!!..)!!!)..#)#..)###).)###).)###)...!...)!!!)..#!#.....", ".!...!.!...!.!...#.!...!.!...#.!...#.!...!.!...!.#...!.#...!.!...!.!...#.!...!.!...!.!...!.!...#.!.!.!.!...!.#...!.#.!.#.!...!.!...!.!.!.!..!.!..#...!.#!..#....", ".!...!.!...!.!...#.!...!.!...#.!...#.!...!.!...!.#...!.#...!.!...!.!...#.!...!.!...!.!...!.!...#.!..!!.!...!.#...!.#.!.#.!...!.!...!.!!.!!.!...!.#...!.!...#....", ".)###).)!!!...!!!).)!!!..)!!!).)###..)!!!).)###)..###).)!!!).)###).)!!!).)###).)###).)!!!).)###..)!!!).)###).)!!!)..#)#..)!!!!..!!!..)###).)###).)!!!).)!!!)....", "................................................................................................................................................................", " ", " ", "................................................................... .......................................................... ", "..!!...##).)!!).)!!).)##).)!!).)!!).)!!).)!!).)!!)................. .......................................................... ", ".!..!.#..!.#..!.#..!.!..!.!..#.!..#.#..!.!..!.!..!..........!...)!. .......................................................... ", ".)##)..##).)!!)..!!).)!!).)!!).)!!)..##).)!!).)!!)..)!..!..!....<[. .......................................................... ", ".!..!.#..!.!..#.#..!.#..!.#..!.!..!.#..!.!..!.#..!.........!....)!. .......................................................... ", "..!!...##).)!!).)!!)..##).)!!).)!!)..##).)!!).)!!)......!.!...{.... .......................................................... ", "................................................................... .......................................................... ", " ", "................................................................................................................................... ......................... ", ".#!!#.)!!...!!).)!!..)!!).)!!).)!!).)##)..##)..##).)##).)##..!##!.)!!..)!!).)!!).)!!).)!!).)!!).)!!).)##).)##).)##).)##).)##).)!!). .,''',.)!!!)...,.....)... ", ".!..!.!..!.!..#.!..!.!..#.!..#.!..#.!..!.#..!.#..!.!.!..!..#.!!!!.!..!.!..!.!..!.!..!.!..!.!..#.#.!#.!..!.!..!.!..!.!..!.!..!.#..!. ..'~'...!{!....'.....!... ", ".)!!).)!!..)##..)##).)!!..)!!..)#)).)!!)..##)..##).)!...)##..)##).)##).)##).)!!).)!#).)!!..)!!)..#)..)##).)##).)##)..!!..)!!)..#!.. ..,~,...){)...,~,...){).. ", ".!..!.!..!.!..#.!..!.!..#.!..#.!..!.!..!.#..!.#..!.!.!..!..#.!..!.!..!.!..!.!..#.!.!!.!..!.#..!.#.!#.!..!.!..!.!..!.!..!.#..!.#!.#. ...'.....!....'~'...!{!.. ", ".)##).)!!...!!).)!!..)!!).)##..)!!).)##)..##).)!!).)##).)!!).)##).)##).)!!).)##..)!!!.)##).)!!)..#)..)!!!..!!..)##).)##).)!!).)!!). ...,.....)...,''',.)!!!). ", "...................................................................................!............................................... ......................... "}; wmnd/src/misc.c0100644000211400001440000000714507224536173013166 0ustar wavexxusers/* * dock.c- built-in Dock module for WindowMaker WindowMaker window * manager Copyright (c) 1997 Alfredo K. Kojima This program 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 program 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., 675 Mass Ave, Cambridge, * MA 02139, USA. */ #include #include #include "list.h" #include "misc.h" /* *---------------------------------------------------------------------- * parse_command-- * Divides a command line into a argv/argc pair. *---------------------------------------------------------------------- */ #define PRC_ALPHA 0 #define PRC_BLANK 1 #define PRC_ESCAPE 2 #define PRC_DQUOTE 3 #define PRC_EOS 4 #define PRC_SQUOTE 5 typedef struct { short nstate; short output; } DFA; static DFA mtable[9][6] = { { {3, 1}, {0, 0}, {4, 0}, {1, 0}, {8, 0}, {6, 0}}, { {1, 1}, {1, 1}, {2, 0}, {3, 0}, {5, 0}, {1, 1}}, { {1, 1}, {1, 1}, {1, 1}, {1, 1}, {5, 0}, {1, 1}}, { {3, 1}, {5, 0}, {4, 0}, {1, 0}, {5, 0}, {6, 0}}, { {3, 1}, {3, 1}, {3, 1}, {3, 1}, {5, 0}, {3, 1}}, { {-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* final state */ { {6, 1}, {6, 1}, {7, 0}, {6, 1}, {5, 0}, {3, 0}}, { {6, 1}, {6, 1}, {6, 1}, {6, 1}, {5, 0}, {6, 1}}, { {-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* final state */ }; char *next_token(char *word, char **next) { char *ptr; char *ret, *t; int state, ctype; t = ret = malloc(strlen(word) + 1); ptr = word; state = 0; *t = 0; while (1) { if (*ptr == 0) ctype = PRC_EOS; else if (*ptr == '\\') ctype = PRC_ESCAPE; else if (*ptr == '"') ctype = PRC_DQUOTE; else if (*ptr == '\'') ctype = PRC_SQUOTE; else if (*ptr == ' ' || *ptr == '\t') ctype = PRC_BLANK; else ctype = PRC_ALPHA; if (mtable[state][ctype].output) { *t = *ptr; t++; *t = 0; } state = mtable[state][ctype].nstate; ptr++; if (mtable[state][0].output < 0) { break; } } if (*ret == 0) t = NULL; else t = strdup(ret); free(ret); if (ctype == PRC_EOS) *next = NULL; else *next = ptr; return t; } extern void parse_command(char *command, char ***argv, int *argc) { LinkedList *list = NULL; char *token, *line; int count, i; line = command; do { token = next_token(line, &line); if (token) { list = list_cons(token, list); } } while (token != NULL && line != NULL); count = list_length(list); *argv = malloc(sizeof(char *) * count); i = count; while (list != NULL) { (*argv)[--i] = list->head; list_remove_head(&list); } *argc = count; } extern pid_t execCommand(char *command) { pid_t pid; char **argv; int argc; parse_command(command, &argv, &argc); if (argv == NULL) { return 0; } if ((pid = fork()) == 0) { char **args; int i; args = malloc(sizeof(char *) * (argc + 1)); if (!args) exit(10); for (i = 0; i < argc; i++) { args[i] = argv[i]; } args[argc] = NULL; execvp(argv[0], args); exit(10); } return pid; } wmnd/src/README0100644000211400001440000000026107204547606012740 0ustar wavexxusersdon't edit master.xpm using gimp or any other image editing tool. or if you do, make sure and restore the symbolic color names (see inside file). better just not mess with it. wmnd/src/list.c0100644000211400001440000000713007224536173013200 0ustar wavexxusers/* * Generic single linked list to keep various information Copyright (C) * 1993, 1994 Free Software Foundation, Inc. * * * Author: Kresten Krab Thorup * * Many modifications by Alfredo K. Kojima * * * This file is part of GNU CC. * * GNU CC 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, or (at your option) any later * version. * * GNU CC 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 GNU CC; see the file COPYING. If not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * As a special exception, if you link this library with files compiled * with GCC to produce an executable, this does not cause the resulting * executable to be covered by the GNU General Public License. This * exception does not however invalidate any other reasons why the * executable file might be covered by the GNU General Public License. */ #include "list.h" #ifdef HAVE_SYS_TYPES_H #include #endif #include /* * Return a cons cell produced from (head . tail) */ INLINE LinkedList * list_cons(void *head, LinkedList * tail) { LinkedList *cell; cell = (LinkedList *) malloc(sizeof(LinkedList)); cell->head = head; cell->tail = tail; return cell; } /* * Return the length of a list, list_length(NULL) returns zero */ INLINE int list_length(LinkedList * list) { int i = 0; while (list) { i += 1; list = list->tail; } return i; } /* * Return the Nth element of LIST, where N count from zero. If N larger * than the list length, NULL is returned */ INLINE void * list_nth(int index, LinkedList * list) { while (index-- != 0) { if (list->tail) list = list->tail; else return 0; } return list->head; } /* * Remove the element at the head by replacing it by its successor */ INLINE void list_remove_head(LinkedList ** list) { if (!*list) return; if ((*list)->tail) { LinkedList *tail = (*list)->tail; /* fetch next */ *(*list) = *tail; /* copy next to list head */ free(tail); /* free next */ } else { /* only one element in list */ free(*list); (*list) = 0; } } /* * Remove the element with `car' set to ELEMENT */ /* * INLINE void list_remove_elem(LinkedList** list, void* elem) { while * (*list) { if ((*list)->head == elem) list_remove_head(list); *list = * (*list ? (*list)->tail : NULL); } } */ INLINE LinkedList * list_remove_elem(LinkedList * list, void *elem) { LinkedList *tmp; if (list) { if (list->head == elem) { tmp = list->tail; free(list); return tmp; } list->tail = list_remove_elem(list->tail, elem); return list; } return NULL; } /* * Return element that has ELEM as car */ INLINE LinkedList * list_find(LinkedList * list, void *elem) { while (list) { if (list->head == elem) return list; list = list->tail; } return NULL; } /* * Free list (backwards recursive) */ INLINE void list_free(LinkedList * list) { if (list) { list_free(list->tail); free(list); } } /* * Map FUNCTION over all elements in LIST */ INLINE void list_mapcar(LinkedList * list, void (*function) (void *)) { while (list) { (*function) (list->head); list = list->tail; } } wmnd/src/list.h0100644000211400001440000000364307224536173013212 0ustar wavexxusers/* * Generic single linked list to keep various information Copyright (C) * 1993, 1994 Free Software Foundation, Inc. * * Author: Kresten Krab Thorup * * This file is part of GNU CC. * * GNU CC 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, or (at your option) any later * version. * * GNU CC 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 GNU CC; see the file COPYING. If not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * As a special exception, if you link this library with files compiled * with GCC to produce an executable, this does not cause the resulting * executable to be covered by the GNU General Public License. This * exception does not however invalidate any other reasons why the * executable file might be covered by the GNU General Public License. */ #ifndef __LIST_H_ #define __LIST_H_ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define INLINE inline #else #define INLINE #endif typedef struct LinkedList { void *head; struct LinkedList *tail; } LinkedList; INLINE LinkedList *list_cons(void *head, LinkedList * tail); INLINE int list_length(LinkedList * list); INLINE void *list_nth(int index, LinkedList * list); INLINE void list_remove_head(LinkedList ** list); INLINE LinkedList *list_remove_elem(LinkedList * list, void *elem); INLINE void list_mapcar(LinkedList * list, void (*function) (void *)); INLINE LinkedList *list_find(LinkedList * list, void *elem); INLINE void list_free(LinkedList * list); #endif wmnd/src/misc.h0100644000211400001440000000025007224536173013161 0ustar wavexxusers#ifndef __MISC_H #define __MISC_H #include extern void parse_command(char *, char ***, int *); extern pid_t execCommand(char *); #endif /* __MISC_H */ wmnd/src/support/0040755000211400001440000000000007272362637013604 5ustar wavexxuserswmnd/src/support/pppio.h0100644000211400001440000001064607224137126015076 0ustar wavexxusers/* * pppio.h - ioctl and other misc. definitions for STREAMS modules. * * Copyright (c) 1994 The Australian National University. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation is hereby granted, provided that the above copyright * notice appears in all copies. This software is provided without any * warranty, express or implied. The Australian National University * makes no representations about the suitability of this software for * any purpose. * * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, * OR MODIFICATIONS. * * $Id: pppio.h,v 1.8 1996/08/28 06:36:51 paulus Exp $ */ #define _PPPIO(n) (('p' << 8) + (n)) #define PPPIO_NEWPPA _PPPIO(130) /* allocate a new PPP unit */ #define PPPIO_GETSTAT _PPPIO(131) /* get PPP statistics */ #define PPPIO_GETCSTAT _PPPIO(132) /* get PPP compression stats */ #define PPPIO_MTU _PPPIO(133) /* set max transmission unit */ #define PPPIO_MRU _PPPIO(134) /* set max receive unit */ #define PPPIO_CFLAGS _PPPIO(135) /* set/clear/get compression flags */ #define PPPIO_XCOMP _PPPIO(136) /* alloc transmit compressor */ #define PPPIO_RCOMP _PPPIO(137) /* alloc receive decompressor */ #define PPPIO_XACCM _PPPIO(138) /* set transmit asyncmap */ #define PPPIO_RACCM _PPPIO(139) /* set receive asyncmap */ #define PPPIO_VJINIT _PPPIO(140) /* initialize VJ comp/decomp */ #define PPPIO_ATTACH _PPPIO(141) /* attach to a ppa (without putmsg) */ #define PPPIO_LASTMOD _PPPIO(142) /* mark last ppp module */ #define PPPIO_GCLEAN _PPPIO(143) /* get 8-bit-clean flags */ #define PPPIO_DEBUG _PPPIO(144) /* request debug information */ #define PPPIO_BIND _PPPIO(145) /* bind to SAP */ #define PPPIO_NPMODE _PPPIO(146) /* set mode for handling data pkts */ #define PPPIO_GIDLE _PPPIO(147) /* get time since last data pkt */ #define PPPIO_PASSFILT _PPPIO(148) /* set filter for packets to pass */ #define PPPIO_ACTIVEFILT _PPPIO(149) /* set filter for "link active" pkts */ /* * Values for PPPIO_CFLAGS */ #define COMP_AC 0x1 /* compress address/control */ #define DECOMP_AC 0x2 /* decompress address/control */ #define COMP_PROT 0x4 /* compress PPP protocol */ #define DECOMP_PROT 0x8 /* decompress PPP protocol */ #define COMP_VJC 0x10 /* compress TCP/IP headers */ #define COMP_VJCCID 0x20 /* compress connection ID as well */ #define DECOMP_VJC 0x40 /* decompress TCP/IP headers */ #define DECOMP_VJCCID 0x80 /* accept compressed connection ID */ #define CCP_ISOPEN 0x100 /* look at CCP packets */ #define CCP_ISUP 0x200 /* do packet comp/decomp */ #define CCP_ERROR 0x400 /* (status) error in packet decomp */ #define CCP_FATALERROR 0x800 /* (status) fatal error ditto */ #define CCP_COMP_RUN 0x1000 /* (status) seen CCP ack sent */ #define CCP_DECOMP_RUN 0x2000 /* (status) seen CCP ack rcvd */ /* * Values for 8-bit-clean flags. */ #define RCV_B7_0 1 /* have rcvd char with bit 7 = 0 */ #define RCV_B7_1 2 /* have rcvd char with bit 7 = 1 */ #define RCV_EVNP 4 /* have rcvd char with even parity */ #define RCV_ODDP 8 /* have rcvd char with odd parity */ /* * Values for the first byte of M_CTL messages passed between * PPP modules. */ #define PPPCTL_OERROR 0xe0 /* output error [up] */ #define PPPCTL_IERROR 0xe1 /* input error (e.g. FCS) [up] */ #define PPPCTL_MTU 0xe2 /* set MTU [down] */ #define PPPCTL_MRU 0xe3 /* set MRU [down] */ #define PPPCTL_UNIT 0xe4 /* note PPP unit number [down] */ /* * Values for the integer argument to PPPIO_DEBUG. */ #define PPPDBG_DUMP 0x10000 /* print out debug info now */ #define PPPDBG_LOG 0x100 /* log various things */ #define PPPDBG_DRIVER 0 /* identifies ppp driver as target */ #define PPPDBG_IF 1 /* identifies ppp network i/f target */ #define PPPDBG_COMP 2 /* identifies ppp compression target */ #define PPPDBG_AHDLC 3 /* identifies ppp async hdlc target */ wmnd/src/support/ppp_defs.h0100644000211400001440000001411407224137140015535 0ustar wavexxusers/* $Id: ppp_defs.h,v 1.14 1999/08/13 01:55:40 paulus Exp $ */ /* * ppp_defs.h - PPP definitions. * * Copyright (c) 1994 The Australian National University. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation is hereby granted, provided that the above copyright * notice appears in all copies. This software is provided without any * warranty, express or implied. The Australian National University * makes no representations about the suitability of this software for * any purpose. * * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, * OR MODIFICATIONS. */ #ifndef _PPP_DEFS_H_ #define _PPP_DEFS_H_ /* * The basic PPP frame. */ #define PPP_HDRLEN 4 /* octets for standard ppp header */ #define PPP_FCSLEN 2 /* octets for FCS */ /* * Packet sizes * * Note - lcp shouldn't be allowed to negotiate stuff outside these * limits. See lcp.h in the pppd directory. * (XXX - these constants should simply be shared by lcp.c instead * of living in lcp.h) */ #define PPP_MTU 1500 /* Default MTU (size of Info field) */ #define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN) #define PPP_MINMTU 64 #define PPP_MRU 1500 /* default MRU = max length of info field */ #define PPP_MAXMRU 65000 /* Largest MRU we allow */ #define PPP_MINMRU 128 #define PPP_ADDRESS(p) (((u_char *)(p))[0]) #define PPP_CONTROL(p) (((u_char *)(p))[1]) #define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3]) /* * Significant octet values. */ #define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ #define PPP_UI 0x03 /* Unnumbered Information */ #define PPP_FLAG 0x7e /* Flag Sequence */ #define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ #define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ /* * Protocol field values. */ #define PPP_IP 0x21 /* Internet Protocol */ #define PPP_AT 0x29 /* AppleTalk Protocol */ #define PPP_IPX 0x2b /* IPX protocol */ #define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ #define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ #define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ #define PPP_COMP 0xfd /* compressed packet */ #define PPP_IPCP 0x8021 /* IP Control Protocol */ #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ #define PPP_IPXCP 0x802b /* IPX Control Protocol */ #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ #define PPP_CCP 0x80fd /* Compression Control Protocol */ #define PPP_LCP 0xc021 /* Link Control Protocol */ #define PPP_PAP 0xc023 /* Password Authentication Protocol */ #define PPP_LQR 0xc025 /* Link Quality Report protocol */ #define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ #define PPP_CBCP 0xc029 /* Callback Control Protocol */ /* * Values for FCS calculations. */ #define PPP_INITFCS 0xffff /* Initial FCS value */ #define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) /* * A 32-bit unsigned integral type. */ #if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \ && !defined(__FreeBSD__) && (NS_TARGET < 40) #ifdef UINT32_T typedef UINT32_T u_int32_t; #else typedef unsigned int u_int32_t; typedef unsigned short u_int16_t; #endif #endif /* * Extended asyncmap - allows any character to be escaped. */ typedef u_int32_t ext_accm[8]; /* * What to do with network protocol (NP) packets. */ enum NPmode { NPMODE_PASS, /* pass the packet through */ NPMODE_DROP, /* silently drop the packet */ NPMODE_ERROR, /* return an error */ NPMODE_QUEUE /* save it up for later. */ }; /* * Statistics. */ struct pppstat { unsigned int ppp_ibytes; /* bytes received */ unsigned int ppp_ipackets; /* packets received */ unsigned int ppp_ierrors; /* receive errors */ unsigned int ppp_obytes; /* bytes sent */ unsigned int ppp_opackets; /* packets sent */ unsigned int ppp_oerrors; /* transmit errors */ }; struct vjstat { unsigned int vjs_packets; /* outbound packets */ unsigned int vjs_compressed; /* outbound compressed packets */ unsigned int vjs_searches; /* searches for connection state */ unsigned int vjs_misses; /* times couldn't find conn. state */ unsigned int vjs_uncompressedin; /* inbound uncompressed packets */ unsigned int vjs_compressedin; /* inbound compressed packets */ unsigned int vjs_errorin; /* inbound unknown type packets */ unsigned int vjs_tossed; /* inbound packets tossed because of error */ }; struct ppp_stats { struct pppstat p; /* basic PPP statistics */ struct vjstat vj; /* VJ header compression statistics */ }; struct compstat { unsigned int unc_bytes; /* total uncompressed bytes */ unsigned int unc_packets; /* total uncompressed packets */ unsigned int comp_bytes; /* compressed bytes */ unsigned int comp_packets; /* compressed packets */ unsigned int inc_bytes; /* incompressible bytes */ unsigned int inc_packets; /* incompressible packets */ unsigned int ratio; /* recent compression ratio << 8 */ }; struct ppp_comp_stats { struct compstat c; /* packet compression statistics */ struct compstat d; /* packet decompression statistics */ }; /* * The following structure records the time in seconds since * the last NP packet was sent or received. */ struct ppp_idle { time_t xmit_idle; /* time since last NP packet sent */ time_t recv_idle; /* time since last NP packet received */ }; #ifndef __P #ifdef __STDC__ #define __P(x) x #else #define __P(x) () #endif #endif #endif /* _PPP_DEFS_H_ */ wmnd/src/support/README0100644000211400001440000000016307224137341014446 0ustar wavexxuserssupport directory ----------------- In this directory: - Platform specific includes - System support functions wmnd/src/support/getopt.c0100644000211400001440000007276307224142522015250 0ustar wavexxusers/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO #define _NO_PROTO #endif #ifdef HAVE_CONFIG_H #include #endif #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include #include #endif /* GNU C library. */ #ifdef VMS #include #if HAVE_STRING_H - 0 #include #endif #endif #if defined (WIN32) && !defined (__CYGWIN32__) /* It's not Unix, really. See? Capital letters. */ #include #define getpid() GetCurrentProcessId() #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ #ifdef HAVE_LIBINTL_H # include # define _(msgid) gettext (msgid) #else # define _(msgid) (msgid) #endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include #define my_index strchr #else /* Avoid depending on library functions or files whose names are inconsistent. */ char *getenv (); extern int strncmp(const char *s1, const char *s2, size_t len); static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ #if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); #endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ /* Defined in getopt_init.c */ extern char *__getopt_nonoption_flags; static int nonoption_flags_max_len; static int nonoption_flags_len; static int original_argc; static char *const *original_argv; extern pid_t __libc_pid; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void __attribute__ ((unused)) store_args_and_env (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ original_argc = argc; original_argv = argv; } text_set_element (__libc_subinit, store_args_and_env); # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ { \ char __tmp = __getopt_nonoption_flags[ch1]; \ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ __getopt_nonoption_flags[ch2] = __tmp; \ } #else /* !_LIBC */ # define SWAP_FLAGS(ch1, ch2) #endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined (__STDC__) && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ #ifdef _LIBC /* First make sure the handling of the `__getopt_nonoption_flags' string can work normally. Our top argument must be in the range of the string. */ if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { /* We must extend the array. The user plays games with us and presents new arguments. */ char *new_str = malloc (top + 1); if (new_str == NULL) nonoption_flags_len = nonoption_flags_max_len = 0; else { memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len); memset (&new_str[nonoption_flags_max_len], '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } } #endif while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined (__STDC__) && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #ifdef _LIBC if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { if (nonoption_flags_max_len == 0) { if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') nonoption_flags_max_len = -1; else { const char *orig_str = __getopt_nonoption_flags; int len = nonoption_flags_max_len = strlen (orig_str); if (nonoption_flags_max_len < argc) nonoption_flags_max_len = argc; __getopt_nonoption_flags = (char *) malloc (nonoption_flags_max_len); if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else { memcpy (__getopt_nonoption_flags, orig_str, len); memset (&__getopt_nonoption_flags[len], '\0', nonoption_flags_max_len - len); } } } nonoption_flags_len = nonoption_flags_max_len; } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { optarg = NULL; if (optind == 0 || !__getopt_initialized) { if (optind == 0) optind = 1; /* Don't scan ARGV[0], the program name. */ optstring = _getopt_initialize (argc, argv, optstring); __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && __getopt_nonoption_flags[optind] == '1')) #else #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) fprintf (stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ wmnd/src/support/getopt.h0100644000211400001440000001075407224142523015246 0ustar wavexxusers/* Declarations for getopt. Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _GETOPT_H #define _GETOPT_H 1 #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Set to an option character which was unrecognized. */ extern int optopt; /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { #if defined (__STDC__) && __STDC__ const char *name; #else char *name; #endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ #define no_argument 0 #define required_argument 1 #define optional_argument 2 #if defined (__STDC__) && __STDC__ #ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ extern int getopt (); #endif /* __GNU_LIBRARY__ */ extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind, int long_only); #else /* not __STDC__ */ extern int getopt (); extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); #endif /* __STDC__ */ #ifdef __cplusplus } #endif #endif /* _GETOPT_H */ wmnd/src/bits.c0100644000211400001440000000135107224536173013165 0ustar wavexxusers/* * bits operators - platform indipendent version operating on chars * small source file, by Wave++ */ #include "bits.h" inline __bytearray getmask(const int pos) { __bytearray rtval = 1; if (!pos) return 1; #ifdef WORDS_BIGENDIAN return (rtval >> pos); #else return (rtval << pos); #endif } inline void onbit(__bytearray * obj, const int pos) { *obj |= getmask(pos); } inline void offbit(__bytearray * obj, const int pos) { *obj &= ~getmask(pos); } inline int getbit(const __bytearray * obj, const int pos) { __bytearray tmpobj = *obj; tmpobj &= getmask(pos); return tmpobj ? 1 : 0; } inline void invbit(__bytearray * obj, const int pos) { *obj ^= getmask(pos); } wmnd/src/drivers.c0100644000211400001440000002237307275355172013715 0ustar wavexxusers /* * wmnd - window maker network devices - drivers.c * * drivers definitions * */ #include "config.h" #include "drivers.h" /* * short explanation of what a function must do * *_list: allocate new elements in the list and assign a name for each device * *_init: launched for each device allocated by *_list. Prepare device status * *_getstats: obtain infos about the device * *_term: deallocate name, eventually drvdata and close fds */ #ifdef USE_SOLARIS_FPPPD /* strioclt is a support function, not previously declared */ int solaris_fpppd_strioctl(int fd, int cmd, char *ptr, int ilen, int olen) { struct strioctl str; str.ic_cmd = cmd; str.ic_timout = 0; str.ic_len = ilen; str.ic_dp = ptr; if (ioctl(fd, I_STR, &str) == -1) return -1; if (str.ic_len != olen) fprintf(stderr, "wmnd [solaris_fpppd]: strioctl expected %d bytes, got %d for cmd %x\n", olen, str.ic_len, cmd); return 0; } int solaris_fpppd_list(const char *devname, struct Devices *list) { int unit; char *devn = NULL; struct Devices *ndev; struct solaris_fpppd_drvdata *ndata; struct Devices *ptr; int dta; /* device name testing */ if (devname) devn = strdup(devname); if (devn) /* device specified */ { if (sscanf(devn, "ppp%d", &unit) != 1) { fprintf(stderr, "wmnd [solaris_fpppd]: invalid interface '%s' specified\n", devn); free(devn); return 0; } dta = 1; /* allocate only one device, using unit */ } else { /* check all devices from 0 until error */ ndev = malloc(sizeof(struct Devices)); ndev->name = NULL; unit = 0; while(1) { ndata = malloc(sizeof(struct solaris_fpppd_drvdata)); ndata->mustconnect = failed; ndata->unit = unit; ndev->drvdata = ndata; dta = solaris_fpppd_init(ndev); solaris_fpppd_term(ndev); if (dta) break; /* device initialization failed */ fprintf(stderr,"wmnet [solaris_fpppd]: detected ppp%d\n",unit); unit++; } free(ndev); if (!unit) return 0; dta = unit; unit = 0; } /* allocate new dta devices structures */ ptr = list; while(dta--) { ndata = malloc(sizeof(struct solaris_fpppd_drvdata)); ndata->mustconnect = untested; ndata->unit = unit; ndev = malloc(sizeof(struct Devices)); ptr->next = ndev; ptr = ndev; ndev->next = NULL; ndev->drvdata = ndata; ndev->name = malloc(10); sprintf(ndev->name,"ppp%d",unit); unit++; } return (devn)?free(devn),1:unit; } int solaris_fpppd_init(struct Devices *dev) { struct solaris_fpppd_drvdata *drvdata = dev->drvdata; /* opening fd */ if (drvdata->mustconnect < opened) { dev->devstart = 0; if ((drvdata->fd = open(solaris_fpppd_device, O_RDONLY)) < 0) { drvdata->mustconnect = failed; return 1; } else if (drvdata->mustconnect < opened) { if (drvdata->mustconnect == untested) { /* supposing the device is down */ drvdata->mustconnect = opened; return 0; } drvdata->mustconnect = opened; } } /* attaching to fd device's signals */ if (drvdata->mustconnect < connected) { if (solaris_fpppd_strioctl(drvdata->fd, PPPIO_ATTACH, (char *)&drvdata->unit, sizeof(int), 0) < 0) { drvdata->mustconnect = opened; dev->devstart = 0; return 1; } else { drvdata->mustconnect = connected; time(&dev->devstart); } } return 0; } int solaris_fpppd_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob) { static struct ppp_stats curp; struct solaris_fpppd_drvdata *drvdata = dev->drvdata; /* clear vars (not clearing will fuck up all scales when disconnecting */ *ip = *op = *ib = *ob = 0; if (drvdata->mustconnect < connected) { /* trying to activate the device */ if (solaris_fpppd_init(dev)) return 1; } if (solaris_fpppd_strioctl(drvdata->fd, PPPIO_GETSTAT, (char *)&curp, 0, sizeof(curp)) < 0) { /* the connection has probably shutted down */ drvdata->mustconnect = failed; close(drvdata->fd); return 1; } *ip = curp.p.ppp_ipackets; *ib = curp.p.ppp_ibytes; *op = curp.p.ppp_opackets; *ob = curp.p.ppp_obytes; return 0; } void solaris_fpppd_term(struct Devices *dev) { close(((struct solaris_fpppd_drvdata *) dev->drvdata)->fd); free(dev->drvdata); free(dev->name); } #endif /* USE_SOLARIS_FPPPD */ #ifdef USE_SOLARIS_KSTAT int solaris_kstat_list(const char *devname, struct Devices *list) { struct Devices *ndev; struct solaris_kstat_drvdata *ndata; struct Devices *ptr; kstat_t *ksp; int dta = 0; /* opening /dev/kstat */ solaris_kstat_kc = kstat_open(); if (!solaris_kstat_kc) { fprintf(stderr,"wmnd [solaris_kstat]: unable to open /dev/kstat\n"); return 0; } /* check all devices of class net */ ptr = list; for (ksp = solaris_kstat_kc->kc_chain; ksp; ksp = ksp->ks_next) { if (!strcmp(ksp->ks_class, "net")) { kstat_read(solaris_kstat_kc, ksp, NULL); if ((!devname || (devname && !strcmp(devname,ksp->ks_name))) && kstat_data_lookup(ksp, "ipackets") && kstat_data_lookup(ksp, "opackets") && kstat_data_lookup(ksp, "rbytes") && kstat_data_lookup(ksp, "obytes")) { /* device is suitable */ ndev = malloc(sizeof(struct Devices)); ndev->devstart = 0; ndev->name = strdup(ksp->ks_name); ndata = malloc(sizeof(struct solaris_kstat_drvdata)); ndata->ksp = ksp; ptr->next = ndev; ndev->next = NULL; ndev->drvdata = ndata; ptr = ndev; fprintf(stderr,"wmnet [solaris_kstat]: detected %s\n",ndev->name); dta++; } } } return dta; } int solaris_kstat_init(struct Devices *dev) { struct solaris_kstat_drvdata *drvdata = dev->drvdata; drvdata->in_pkt = kstat_data_lookup(drvdata->ksp,"ipackets"); drvdata->in_byte = kstat_data_lookup(drvdata->ksp,"rbytes"); drvdata->out_pkt = kstat_data_lookup(drvdata->ksp,"opackets"); drvdata->out_byte = kstat_data_lookup(drvdata->ksp,"obytes"); return (drvdata->in_pkt && drvdata->in_byte && drvdata->out_pkt && drvdata->out_byte)?0:1; } int solaris_kstat_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob) { struct solaris_kstat_drvdata *drvdata = dev->drvdata; *ip = *op = *ib = *ob = 0; if (kstat_read(solaris_kstat_kc, drvdata->ksp, NULL) == -1) return 1; else { *ip = (drvdata->in_pkt->value.ui32); *op = (drvdata->out_pkt->value.ui32); *ib = (drvdata->in_byte->value.ui32); *ob = (drvdata->out_byte->value.ui32); } return 0; } void solaris_kstat_term(struct Devices *dev) { free(dev->drvdata); free(dev->name); } #endif /* USE_SOLARIS_KSTAT */ #ifdef USE_TESTING_DUMMY int testing_dummy_list(const char *devname, struct Devices *list) { char *devn; struct Devices *ndev; if (devname == NULL) devn = strdup("off"); else devn = strdup(devname); ndev = malloc(sizeof(struct Devices)); list->next = ndev; ndev->next = NULL; ndev->name = devn; return 1; /* usually returns the number of devices */ } int testing_dummy_init(struct Devices *dev) { dev->devstart = 0; return 0; } int testing_dummy_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob) { *ip = *op = *ib = *ob = 0; return 1; } void testing_dummy_term(struct Devices *dev) { free(dev->name); } #endif /* USE_TESTING_DUMMY */ #ifdef USE_LINUX_PROC int linux_proc_list(const char *devname, struct Devices *list) { FILE* fd; int dta = 0; char temp[MAXBUF]; /* string buffer */ char* tokens = " :\t\n"; /* parse tokens */ struct Devices* ndev; char* p; fd = fopen(linux_proc_netDevice, "r"); /* Skip the first 2 lines */ fgets(temp, MAXBUF, fd); fgets(temp, MAXBUF, fd); /* grab all active devices, adding them as we go */ while (fgets(temp, MAXBUF, fd)) { p = strtok(temp, tokens); if (!strncmp(p, "dummy", 5) || !strncmp(p, "irda", 4)) continue; if ((devname && !strcmp(p, devname)) || (!devname && strcmp(p, "lo"))) { dta++; ndev = malloc(sizeof(struct Devices)); ndev->devstart = 0; ndev->name = strdup(p); ndev->next = NULL; ndev->drvdata = NULL; list->next = ndev; list = ndev; } } fclose(fd); return dta; } int linux_proc_init(struct Devices *dev) { /* linux proc doesn't need single device initialization */ return 0; } int linux_proc_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob) { /* * this driver is badly optimized, re-reading each time the file consumes * many cpu clocks, only for finding the device name, however we cannot use * an offset so it's the only way to get some king of statistics */ FILE* fp; char temp[MAXBUF]; char* p; int active = 1; /* read statistics from network device's list */ fp = fopen(linux_proc_netDevice, "r"); fgets(temp, MAXBUF, fp); fgets(temp, MAXBUF, fp); *ib = *ob = *ip = *op = 0; while (fgets(temp, MAXBUF, fp)) { if (strstr(temp, dev->name)) { p = strchr(temp, ':'); p++; sscanf(p, "%lu %lu %*s %*s %*s %*s %*s %*s %lu %lu", ib, ip, ob, op); active = 0; break; } } fclose(fp); return active; } void linux_proc_term(struct Devices *dev) { free(dev->name); } #endif /* USE_LINUX_PROC */ wmnd/src/drivers.h0100644000211400001440000001016007275353261013706 0ustar wavexxusers/* * wmnd - window maker network devices - drivers.h * * drivers prototypes and includes */ #ifndef __drivers_h #define __drivers_h #include "config.h" #include "wmnd.h" /* * how a driver works: * first wmnd calls p_list_devs, for populating the Devices struct. If the * driver does not support listing, then only requested device in devname * will be listed. this function returns the number of devices avaible for * this driver and fills up the Devices struct * than the driver must be initialized using p_init_drv. The function * must return 0 if successfull, or 1. * When the driver is up&running p_updt_stats will be called periodically to * get device statistics. If it returns 0 the device is ok, 1 for offline. * wmnd will continue calling it, even if the device is offline. The driver * must detect by itself the device status. * finally, when removing a device or exiting, p_term_drv will be called */ typedef int (*p_list_devs) (const char *devname, struct Devices * list); typedef int (*p_init_drv) (struct Devices * dev); typedef int (*p_updt_stats) (struct Devices * dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob); typedef void (*p_term_drv) (struct Devices * dev); /* driver vars */ #ifdef USE_SOLARIS_FPPPD #include #include "support/ppp_defs.h" #include "support/pppio.h" #include /* on some systems may be /dev/streams/ppp */ static const char *solaris_fpppd_device = "/dev/ppp"; /* connection status (needed for dialup devices) */ enum solaris_fpppd_connstatus { untested, failed, opened, connected }; /* driver data in Devices, used for coding style */ struct solaris_fpppd_drvdata { int fd; int unit; enum solaris_fpppd_connstatus mustconnect; }; /* functions prototypes */ int solaris_fpppd_list(const char *devname, struct Devices *list); int solaris_fpppd_init(struct Devices *dev); int solaris_fpppd_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob); void solaris_fpppd_term(struct Devices *dev); #endif /* USE_SOLARIS_FPPPD */ #ifdef USE_SOLARIS_KSTAT #include static kstat_ctl_t *solaris_kstat_kc = NULL; /* driver data in Devices, used for coding style */ struct solaris_kstat_drvdata { kstat_t *ksp; kstat_named_t *in_pkt, *in_byte, *out_pkt, *out_byte; }; /* functions prototypes */ int solaris_kstat_list(const char *devname, struct Devices *list); int solaris_kstat_init(struct Devices *dev); int solaris_kstat_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob); void solaris_kstat_term(struct Devices *dev); #endif /* USE_SOLARIS_KSTAT */ #ifdef USE_TESTING_DUMMY int testing_dummy_list(const char *devname, struct Devices *list); int testing_dummy_init(struct Devices *dev); int testing_dummy_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob); void testing_dummy_term(struct Devices *dev); #endif /* USE_TESTING_DUMMY */ #ifdef USE_LINUX_PROC static const char* linux_proc_netDevice = "/proc/net/dev"; int linux_proc_list(const char *devname, struct Devices *list); int linux_proc_init(struct Devices *dev); int linux_proc_get(struct Devices *dev, unsigned long *ip, unsigned long *op, unsigned long *ib, unsigned long *ob); void linux_proc_term(struct Devices *dev); #endif /* USE_LINUX_PROC */ /* driver list */ static struct drivers_struct { char *driver_name; p_list_devs list_devices; p_init_drv init_driver; p_updt_stats get_stats; p_term_drv terminate_driver; } drivers_table[] = { #ifdef USE_LINUX_PROC {"linux_proc", linux_proc_list, linux_proc_init, linux_proc_get, linux_proc_term}, #endif #ifdef USE_SOLARIS_FPPPD {"solaris_fpppd", solaris_fpppd_list, solaris_fpppd_init, solaris_fpppd_get, solaris_fpppd_term}, #endif #ifdef USE_SOLARIS_KSTAT {"solaris_kstat", solaris_kstat_list, solaris_kstat_init, solaris_kstat_get, solaris_kstat_term}, #endif #ifdef USE_TESTING_DUMMY {"testing_dummy", testing_dummy_list, testing_dummy_init, testing_dummy_get, testing_dummy_term}, #endif {NULL, NULL, NULL, NULL, NULL} }; #endif wmnd/src/config.h0100644000211400001440000000110207275363662013477 0ustar wavexxusers/* * wmnd - window maker network devices - config.h * * wmnd design time configuration * */ #ifndef __config_h #define __config_h /* define below if you're on a big endian architecture */ /* #define WORDS_BIGENDIAN */ /* linux /proc/net/dev driver */ /* #define USE_LINUX_PROC */ /* free pppd for Solaris 2.x and compatible streams ppp devices */ #define USE_SOLARIS_FPPPD /* solaris kstat driver, also works on kstat compatible OSs */ #define USE_SOLARIS_KSTAT /* dummy driver for testing purposes, it's safe to leave it defined */ #define USE_TESTING_DUMMY #endif wmnd/src/wmnd.h0100644000211400001440000001106507275355367013213 0ustar wavexxusers/* * wmnd.h - window maker network devices - wmnd.h * * common structures and functions */ #ifndef __wmnd_h #define __wmnd_h #include "bits.h" /* portable bit functions */ #include #include #include #include #include #include #include #include #include #include #include #include #define WMND_VERSION "0.3.2" #define MAXBUF 256 #ifdef PRO #define eprint(level, fmt, arg...) \ switch (level) { \ case 0: \ break; \ case 1: \ fprintf(stderr, __FUNCTION__": " fmt, ##arg); \ fprintf(stderr, "\n"); \ break; \ } #else #define eprint(level, fmt, arg...) #endif #ifndef MAX #define MAX(a, b) (a * * portability: * using gnu automake: use the macro AC_C_BIGENDIAN * else: define WORDS_BIGENDIAN for big endian systems * * Originally an hpp extended file. Distributed under GNU GPL */ #ifndef __bits_h #define __bits_h /* a typedef for bits operation container */ typedef long int __bytearray; // core functions inline __bytearray getmask(const int pos); inline void onbit(__bytearray * obj, const int pos); inline void offbit(__bytearray * obj, const int pos); inline int getbit(const __bytearray * obj, const int pos); inline void invbit(__bytearray * obj, const int pos); #endif wmnd/Makefile0100644000211400001440000000414107275375300012730 0ustar wavexxusers################# # package infos # ################# PJ = wmnd VERSION = `sed -n "s/\#define WMND_VERSION \"\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)\"/\1\\.\2\\.\\3/p" src/wmnd.h` PRE = prefix = /usr/local/ bindir = $(prefix)/bin/ mandir = $(prefix)/man/ datadir = $(prefix)/share/ docdir = $(datadir)/doc/$(PJ)/ # X11 headers location may vary on some systems # XFree (linux etc): X11CFLAGS = -I/usr/X11R6/include X11LDFLAGS = -L/usr/X11R6/lib -lXpm -lXext -lX11 # OpenWindows (solaris, sco unixware etc): # X11CFLAGS = -I/usr/openwin/include # X11LDFLAGS = -L/usr/openwin/lib -lXpm -lXext -lX11 -lsocket -lnsl # Solaris specific (for use with kstat) LDFLAGS = -lkstat -lsocket -lnsl ################## # compiler flags # ################## # source code directory SRC = src/ MAN = man/ VPATH = $(SRC):$(MAN) # Optimizing CFLAGS = -Wall -O3 -fomit-frame-pointer -fstrict-aliasing -pipe # Profiling # CFLAGS = -Wall -ansi -pg -g -O3 -pipe -D_GNU_SOURCE -DPRO # Test coverage # CFLAGS = -fprofile-arcs -ftest-coverage -Wall -pipe -DPRO # Debugging # DEBUG = -ggdb ####################### # makefile directives # ####################### OBJS = wmnd.o misc.o list.o drivers.o bits.o .SUFFIXES: .c.o .c.o: $(CC) -c -o $@ $< $(CFLAGS) $(DEBUG) $(X11CFLAGS) all: $(PJ) $(PJ): $(OBJS) $(CC) -o $(PJ) $(OBJS) $(LDFLAGS) $(X11LDFLAGS) %.gz: % gzip -c9 $^ > $@ clean: $(foreach dir,./ $(subst :, ,$(VPATH)),(cd $(dir) && rm -f *.o wmnd *~ .*.swp trace *.bb *.bbg *.gcov *.da *.out *.gz ) && ) echo done. install: $(PJ) wmnd.1.gz set -e install -d $(bindir)/ $(mandir)/man1/ $(docdir)/example/ install -m 755 wmnd $(bindir)/ install wmndrc $(docdir)/example/ install wmnd.1.gz $(mandir)/man1/ package: clean ( \ PKGVER=$(VERSION) ; \ rm -f ../$(PJ)_$$PKGVER*.tar.gz ; \ cd .. && tar -cf - $(PJ) | gzip -c > $(PJ)_$$PKGVER$(PRE).tar.gz \ ) indent: indent -kr $(SRC)/*.c $(SRC)/*.h # indent -orig *.c *.h # modules dependencies drivers.c: drivers.h wmnd.h config.h wmnd.h: bits.h wmnd.c: wmnd.h bits.c: bits.h config.h list.c: list.h misc.c: list.h misc.h .PHONY = all clean install package indent # vim:nosta wmnd/README0100644000211400001440000000231107275145012012140 0ustar wavexxusersWMND -------------------------------------------------------------- Web site: http://www.wingeer.org/wmnd/ Author: Reed Lai http://www.wingeer.org/bv4qo/ Description -------------------------------------------------------------- WMND (WindowMaker Network Devices) is a network monitoring dock app improved and based on WMiFS 1.3b. The version 0.2 of wmnd is almost totally written by Timecop, given the optimization and flexibility. Enjoy! Files -------------------------------------------------------------- README This file. INSTALL Configuration and Installation instructions. HINTS Hints about what you can do with WMND. CHANGELOGS Description of changes. TODO Things we've already planned for WMND. COPYING GNU General Public License Version 2. Bugs -------------------------------------------------------------- If you discover any bugs in this software, please post it to http://www.wingeer.org/wmnd/wall/ Please describe the problems in as much detail as you can. Copyright -------------------------------------------------------------- WMND is copyright (c) 2000 by Reed Lai and licensed under the GNU General Public License. Read the COPYING file for the complete GNU license. wmnd/HINTS0100644000211400001440000000516507214100573012076 0ustar wavexxusersHints for WMND Generic -------------------------------------------------------------- WMND supports commandline options, 'wmnd -h' prints help about them. Use option -i to monitor a particular interface at startup: wmnd -i eth0 & wmnd -i ppp0 & wmnd -i lo & Without the -i option, wmnd will automagicly use the interface that is first found in /proc/net/dev, but skip the lo and irda. Active Interface You can cycle in realtime through all available active interfaces by simply left-clicking on the interface name gadget on the upperleft corner of wmnd. The 'lo' interface is an exception, 'lo' ONLY works when invoked from the commandline (wmnd -i lo), lo was mainly built in for testing purposes. Device Name By default, wmnd show device name in short term of four characters, for example, the ippp0 will be displayed as ipp0. You can toggle the device name between short and long by right-click on it. Graphic Mode Left-click on the main graphic area to cycle the graphic mode. Max Meter Left-click to toggle the history max or screen max, default is screen max when wmnd is startup. Right-click to hide or display. Byte/Packet Mode Left-click on the letter gadgeted on the right-top corner can switch between the Byte or Packet counter mode. "B" for byte, "p" for packet. User Script Click on the bottom rate meter can invoke the user command defined in resource file .wmndrc. Dragging WMND Be sure to drag WMND on it's outer edges, it's a bit picky due to the large gfx pixmap it keeps ;-). You can also use a keyboard+mouse shortcut (perhaps ALT+left-click) in your window manager to drag it around. WindowMaker -------------------------------------------------------------- WindowMaker users simply drag and drop the WMND dock.app on the WindowMaker Dock (preferred) or on the Fiend, and then press the rightmouse button on the outer edges of WMND and then enable 'Autolaunch' from the Dock popup menu. Afterstep -------------------------------------------------------------- Afterstep users put the following in their .steprc "Wharf wmnd - MaxSwallow "wmnd" wmnd -i eth0 -w &". Other WindowManagers -------------------------------------------------------------- For other windowmanagers, WMND runs nicely as 64x64 pixel shaped icon on your desktop. p.s. FVWM can swallow it too, so we've heard ;-) Creating PPP dialup scripts -------------------------------------------------------------- Because a very good PPP HowTo already exists, it's quite pointless for us to explain to you how you should and can make them. Read the PPP HowTo, and you'll see that it's very easy to create your own PPP scripts. wmnd/CREDIT0100644000211400001440000000221207275364672012174 0ustar wavexxusersCredits for wmnd This file lists names of people who have helped with the project of wmnd in one way or another. Since bug reports was logged to web page http://www.wingeer.org/wmnd/bugreport.shtml, I did not log them here. However, this file was created too late, if you feel you should be mentioned here, please drop a note to wmnd@wingeer.org Arthur Korn Wmnd man page author. Makefile maintenance. Debian package maintenance: http://www.korn.ch/arthur/wmnd-deb/ Michael Leuchtenburg http://otter.yi.org/ Web site adminstration: http://www.wingeer.org/wmnd/ English refinement of articles Paul van Tilburg (Mozillion) http://www.utopiamoo.net/ Provides ultimate test environment for function and stability of wmnd. Reed Lai http://www.wingeer.org/bv4qo/ Project initiation. Timecop http://www.ne.jp/asahi/linux/timecop/ Source code optimization (Re-wrote the source code of wmnd 0.2.0) Wave++ http://wavexx.dyndns.org Driver architecture (Re-wrote source of wmnd => 0.3) Many minor things (see CHANGELOGS) wmnd/todo/0040755000211400001440000000000007272314750012237 5ustar wavexxuserswmnd/todo/TODO.0.1.00100644000211400001440000000147707214065016013362 0ustar wavexxusersTODO list for WMND. ------------------------------------------------------------------------ Your feedback! If you have nice suggestions, ideas, whatever, that aren't on this list, feel free to post to Wall or mail them to me :) Reduce dirty and redundant codes, and debug. WMND is a great tool! I like it! But it would be even better if there's the possibility of adding a timer like in wmppp (pretty useful the timer in the countries where the phone costs a lot of $$) Thanks to Pascal Jermini Colors changable for your favor or video enhancement. Thanks to Mark Manning A larger font version? Thanks to Mark Manning Use the libdockapp? Thanks to Paulo E. Abreu TODO are updated at web page http://www.wingeer.org/wmnd/todo.shtml wmnd/wmndrc0100644000211400001440000000234507225372054012507 0ustar wavexxusers# WMND configuration file # middle line in wave mode color md_color=#71e371 # RX/TX color (can be #xxxxxx, or color name from rgb.txt) rx_color=#188a86 tx_color=#00fff2 # refresh between status polling (not graph scroll speed) # numbering in nanoseconds refresh=50000 # bar graph scroll speed (in seconds) this setting also affectsi # the rate and max speed displays. the longer the delay, more # inaccurate these are since the max and rate values are averaged # across this interval scroll=1 # buttons for user scripts # bt1_action=su -c ethereal # bt2_action= # bt3_action= # additional options since 0.3 # respects the -b in command line (yes, no) binary_scale=no # display or not the device uptime (yes, no) display_time=yes # use a specific driver (driver name, %auto for automatic) driver=%auto # driver interface to monitor (interface name, %any for all) driver_interface=%any # automaticalli select and show the interface on startup if avaible # (interface name, %first for first avaible) interface_name=%first # Show max values (yes, no) show_max_values=yes # Use long interface names (yes, no) use_long_names=no # Max values through entire history use_max_history=no # Wave mode (traditional, waveform, wmnet) wave_mode=wmnet