Re: [PATCH] Proposed clarification of the snapshot installation FAQ

2006-01-12 Thread Joshua Daniel Franklin
On 1/11/06, Igor Peshansky wrote:
> As mentioned in ,
> here's a patch to the FAQ to clarify the section on installing snapshots.
> I didn't know whether the various *.texinfo files are still used, so I
> ported the modifications there as well, just in case.

Applied to faq-setup.xml (the texinfo files are no longer used... I suppose I
should remove them). It would be nice to have a sample batch file that automated
the cygwin1.dll replacement, too.


Re: [Patch]: Changes to how-programming.texinfo

2005-07-15 Thread Joshua Daniel Franklin
On 7/15/05, Brian Dessent wrote:
> Christopher Faylor wrote:
> 
> > Btw, the "other license" provision in the cygwin licensing web page was
> > really meant as a way to accommodate other, already existing projects.

So do we want to change the wording at all? 

> Last I checked RHEL and FC were *still* packaging this ancient
> version as their default, though that might have finally changed in
> RHEL4 and FC4, I don't know.

They have, and even with RHEL3 it was pretty easy to download and install
the RPMs from MySQL.com, though you needed to keep on top of security
updates yourself.

And, since we're having off-topic discussions, I'm now a father:
http://joshuadf.blogspot.com/2005_07_01_joshuadf_archive.html


Re: [Patch] Loading cygwin1.dll from MinGW and MSVC

2005-06-04 Thread Joshua Daniel Franklin
On 6/4/05, Christopher Faylor wrote:
> If you want to me to revert the patch, please let me know.  
> Otherwise, please just massage it as you see fit.

No, not a problem. I'll just edit it a bit.


Re: [Patch] Loading cygwin1.dll from MinGW and MSVC

2005-06-04 Thread Joshua Daniel Franklin
On 6/3/05, Max Kaehn wrote:
> This patch contains the changes to make it possible to dynamically load
> cygwin1.dll from MinGW and MSVC applications.  The changes to dcrt0.cc are
> minimal and only affect cygwin_dll_init().  I've also added a MinGW test
> program to testsuite and a FAQ so people will be able to locate the
> test program easily.

Assuming the code patches are fine, instead of a new section could we just 
add your FAQ hint to "How do I link against `cygwin1.dll' with Visual Studio?"

The title could be changed to something like "How do I use `cygwin1.dll' with 
MinGW or Visual Studio?"

I'm a little torn since I'm not sure this is actually frequently asked but it's 
certainly good to have the info. Ideally I can put it in the User's Guide.


keep Cygwin docs well-formed and valid

2004-12-24 Thread Joshua Daniel Franklin
I just did a commit that touched a lot of sgml files. Now both the
User's Guide (cygwin-ug-net.sgml) and API Reference (cygwin-api.sgml)
are well-formed and valid DocBook XML. The current SGML tools still
work fine with it, but I hope to move the doc Makefile to xmlto soon
to end the confusion with different SGML toolchains (as far as I know
xmlto is standard across platforms, and it's already packaged for
Cygwin).

For anyone who edits the documentation, though, please keep the files
well-formed and valid! This means:

--All tags should be in lower case (like , not , close it with 
--Use entities for 8-bit characters, like © for © and ® for ®.
--Close empty tags, though note that  is weirdly NOT empty but
should be used like this: 
--Always put tag attributes in quotes

Thanks.


Re: [UG Patch] kmem and check_case typo

2004-05-29 Thread Joshua Daniel Franklin
> >On Fri, 21 May 2004 10:22:20 -0500, Brian Ford wrote:

> >> Ok, then shouldn't we apply the following patch to the users 
> >> guide? (plus a typo fix)

Applied with the "planned for development" euphamism.


Re: ssp.c (usage): Add missing linefeed.

2004-05-29 Thread Joshua Daniel Franklin
I went ahead and applied this. It doesn't appear to break anything. :)

On Mon, 24 May 2004 05:11:51 +0100, John Paul Wallington <[EMAIL PROTECTED]> wrote:
> 
> 2004-05-24  John Paul Wallington  <[EMAIL PROTECTED]>
> 
> * ssp.c (usage): Add missing linefeed.
> 
> --- ssp.c   14 Feb 2004 19:43:07 +  1.8
> +++ ssp.c   24 May 2004 05:09:52 +0100
> @@ -801,7 +801,7 @@ usage (FILE * stream)
>  "  ssp -v -s -l -d 0x61001000 0x6108 hello.exe\n"
>  "\n");
>if (stream == stderr)
> -fprintf (stream, "Try '%s --help' for more information.", prog_name);
> +fprintf (stream, "Try '%s --help' for more information.\n", prog_name);
>exit (stream == stderr ? 1 : 0);
>  }
>


Re: [UG Patch] kmem and check_case typo

2004-05-24 Thread Joshua Daniel Franklin
On Fri, 21 May 2004 10:22:20 -0500, Brian Ford <[EMAIL PROTECTED]> wrote:
> 
> On Thu, 20 May 2004, Corinna Vinschen wrote:
> 
> > On May 20 09:22, Igor Pechtchanski wrote:
> > > BTW, should /dev/kmem work also?
> >
> > No, only /dev/mem and /dev/port are working.  /dev/kmem is still looking
> > for a contributor.
> 
> Ok, then shouldn't we apply the following patch to the users guide? (plus
> a typo fix)
> 
> 2004-05-21  Brian Ford  <[EMAIL PROTECTED]>
> 
> * pathnames.sgml: Remove /dev/kmem from the supported POSIX device
> list.
> 
> * cygwinenv.sgml: Fix typo in check_case description.
> 

Looks good to me, I'll apply this weekend unless someone beats me to it. 

Thanks for the typo catch. I've been spellchecking lately but
ovbiously don't catch them all.


Re: Are cygwin-ug and cygwin-api-int used?

2004-01-20 Thread Joshua Daniel Franklin
On Sun, Jan 11, 2004 at 02:45:20PM -0800, Joshua Daniel Franklin wrote:
> I would like to remove two build targets from winsup/doc/Makefile.in:
> 
> cygwin-ug/cygwin-ug.html 
> cygwin-api-int/cygwin-api-int.html 
> 
> As far as I can tell, these are not used for anything and have
> references to "the GNUPro release". This would not effect the
> "net release" versions of the User's Guide and API Reference:
> 
> cygwin-ug-net/cygwin-ug-net.html
> cygwin-api/cygwin-api.html
> 
> I will remove them in a week if no one has any reason not to.
> 

This is now done.


Added Quick Start to Users' Guide

2004-01-15 Thread Joshua Daniel Franklin
I just checked in a couple patches to the Users' Guide. The big news
is two short "Quick Start" sections focused on those with
Windows or Unix experience. 

2004-01-15  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* setup-net.sgml: Add "internet-setup" id anchor.
* overview.sgml: Update "What is it?" section. Add links to
"Is it free software?" section. Update "Brief History" section.
* overview2.sgml: Rewrite "Expectations for {Windows,Unix}"
as "Quick Start for those more experienced with {Windows,Unix}".

__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus


Are cygwin-ug and cygwin-api-int used?

2004-01-11 Thread Joshua Daniel Franklin
I would like to remove two build targets from winsup/doc/Makefile.in:

cygwin-ug/cygwin-ug.html 
cygwin-api-int/cygwin-api-int.html 

As far as I can tell, these are not used for anything and have
references to "the GNUPro release". This would not effect the
"net release" versions of the User's Guide and API Reference:

cygwin-ug-net/cygwin-ug-net.html
cygwin-api/cygwin-api.html

I will remove them in a week if no one has any reason not to.

__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus


Many updates to winsup/doc

2004-01-11 Thread Joshua Daniel Franklin
I just committed several changes to winsup/doc. Most are
small edits to various sections of the User's Guide, but
there are two that I should draw attention to. 

First, I updated the DTD declaration in the sgml.in files to the
official DocBook 4.2 SGML DTD, added a new DSSSL stylesheet 
called cygwin.dsl, and edited Makefile.in to use cygwin.dsl 
instead of cygnus-both.dsl. This fixes a couple small problems
from the 1998 DTDs and makes it easier to make the single-file
HTML version of the User's Guide.

Second, I applied an FAQ patch that was submitted to the mailing
list about 3 months ago. David's said recently that he is very behind:

and so I thought I'd help out since this one that's I'd noted down
was for the FAQ:

"Hannu E K Nevalainen" 
http://www.cygwin.com/ml/cygwin/2003-10/msg01052.html
-how-programming.texinfo: Add some words about -mno-cygwin,
the difference with regard to preprocessor symbols and how to
investigate it further.

The small edits were:

DONE
"Dave Korn" 
http://www.cygwin.com/ml/cygwin/2004-01/msg00111.html
-default values of CYGWIN=(no)ntsec (no)export error_start

DONE
"Gary L. Feldman" 
http://cygwin.com/ml/cygwin/2003-08/msg00668.html
-add reminder to not unselect any Base category packages

DONE
linda w 
http://cygwin.com/ml/cygwin/2003-12/msg00716.html
-add /proc discussion to User's Guide

DONE
"Roy Clemmons" 
http://cygwin.com/ml/cygwin/2003-12/msg00839.html
-add discussion of cyg prefix to dll section

__
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus


New Doc section, "Using Cygwin Effectively with Windows"

2003-07-31 Thread Joshua Daniel Franklin
2003-07-31  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* effectively.sgml: New file, "Using Cygwin Effectively with Windows".
* legal.sgml: Update year in copyright notice.
* using.sgml: Include "Using Cygwin Effectively with Windows" section.



Using Cygwin effectively with Windows


Cygwin is not a full operating system, and so must rely on Windows for
accomplishing some tasks. For example, Cygwin provides a POSIX view
of the Windows filesystem, but does not provide filesystem drivers of 
its own. Therefore part of using Cygwin effectively is learning to use
Windows effectively. 
Many Windows utilities provide a good way to interact with Cygwin's 
predominately command-line environment. For example, 
ipconfig.exe provides information about network 
configuration, and net.exe views and configures
network file and printer resources.  Most of these tools
support the /? switch to display usage information. 



Unfortunately, no standard set of tools included with all versions of 
Windows exists.  If you are unfamiliar with the tools available 
on your system, here is a general guide.  Windows 95, 98, and ME have 
very limited command-line configuration tools.  Windows NT 4.0 has much 
better coverage, which Windows 2000 and XP expanded. 
Microsoft also provides free downloads for Windows NT 4.0 (the Resource Kit 
Support Tools), Windows 2000 (the Resource Kit Tools), and XP (the 
Windows Support Tools). Additionally, many independent sites such as 
http://download.com.com";>download.com, 
http://simtel.net";>simtel.net, 
and http://sysinternals.com";>sysinternals.com
provide command-line utilities.  A few Windows tools, such as 
find.exe and sort.exe,
may conflict with the Cygwin versions; make sure that you use the full 
path (/usr/bin/find) or that your Cygwin 
bin directory comes first in your PATH.


 Pathnames


Windows programs do not understand POSIX pathnames, so any arguments 
that reference the filesystem must be in Windows (or DOS) format or 
translated.  Cygwin provides the cygpath utility for 
converting between Windows and POSIX paths. A complete description of its 
options and examples of its usage are in , 
including a shell script for starting Windows Explorer in any directory. 
The same format works for most Windows programs, for example 

notepad.exe "$(cygpath -aw "Desktop/Phone Numbers.txt")"

A few programs require a Windows-style, semicolon-delimited path list, 
which cygpath can translate from a POSIX path with the
-p option. For example, a Java compilation from 
bash might look like this: 

javac -cp "$(cygpath -pw "$CLASSPATH")" hello.java

Since using quoting and subshells is somewhat awkward, it is often 
preferable to use cygpath in shell scripts.




 Console Programs

Another issue is receiving output from or giving input to the console-based 
Windows programs.  Unfortunately, interacting with Windows console 
applications is not a simple matter of using a translation utility. Windows 
console applications and designed to run under command.com 
or cmd.exe, and some do not deal gracefully with other
situations.  Cygwin can receive console input only if it
is also running in a console (DOS box) since Windows does not provide
any way to attach to the backend of the console device. Another
traditional Unix input/output method, ptys (pseudo-terminals), are 
supported by Cygwin but not entirely by Windows.  The basic problem is 
that a Cygwin pty is a pipe and some Windows applications do not like 
having their input or output redirected to pipes.  



To help deal with these issues, Cygwin supports customizable levels of 
Windows verses Unix compatibility behavior.  To be most compatible with 
Windows programs, use a DOS prompt, running only the occasional Cygwin 
command or script. Next would be to run bash with 
the default DOS box. To make Cygwin more Unix compatible in this case, 
set CYGWIN=tty (see ).
Alternatively, the optional rxvt package provides 
a native-Windows version of the popular X11 terminal emulator (it is not 
necessary to set CYGWIN=tty with rxvt). 
Using rxvt.exe provides the most Unix-like environment, 
but expect some compatibility problems with Windows programs.




 Cygwin and Windows Networking

Many popular Cygwin packages, such as ncftp, 
lynx, and wget, require a 
network connection.  Since Cygwin relies on Windows for connectivity, 
if one of these tools is not working as expected you may need to 
troubleshoot using Windows tools. The first test is to see if you
can reach the URL's host with ping.exe, one of the 
few utilities included with every Windows version since Windows 95.
If you chose to install the inetutils package, you may have both
Windows and Cygwin versions of utilities such as ftp
and telnet. If you are having problems using one
of these programs, see if the alternate one works as expected. 



There are a va

Re: mkpasswd and mkgroup

2003-04-05 Thread Joshua Daniel Franklin
--- "Pierre A. Humblet" <[EMAIL PROTECTED]> wrote:
> Corinna,

Hmm. I feel like I'm eavesdropping.

> Following remarks made on the list this patch
> - allows to specify several domains at once with -d

I just don't understand this one. Can someone be logged into 
multiple domains at once?

> - only prints SYSTEM and specials when the -l switch is given

Isn't this a rather abrupt change from how these utilities have
been working? 

Also, please do a patch for utils.sgml explaining the significance
of the new functionality.

__
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com


Improve setup-net.sgml based on comments

2003-03-23 Thread Joshua Daniel Franklin
I checked in some changes. 

2003-03-23  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* setup-net.sgml: Improve setup.exe documentation

Index: setup-net.sgml
===
RCS file: /cvs/src/src/winsup/doc/setup-net.sgml,v
retrieving revision 1.7
diff -u -p -r1.7 setup-net.sgml
--- setup-net.sgml  22 Mar 2003 21:16:25 -  1.7
+++ setup-net.sgml  23 Mar 2003 16:22:09 -
@@ -65,11 +65,16 @@ determine access to installed files.
 The Install For options of 
 All Users or 
 Just Me are especially for multiuser systems
-or Domain users. If you have a single-user workstation, this 
-option probably does not concern you. If you are seeking to rollout
-Cygwin on a large Domain, you will want to see 
-in the Cygwin User's Guide and possibly consult the Cygwin
-mailing list archives about others' experiences.
+or Domain users. If you have access to a user account that is a local 
+Administrator or a member of the Administrators group, it is best to
+install for All Users. You should only install for
+Just Me if you do not have write access to 
+HKEY_LOCAL_MACHINE in the registry or the 
+All Users Start Menu, even if you are the only user planning to use 
+Cygwin on the machine.  If you are seeking to rollout
+Cygwin on a large Domain, you will want to read 
+in the Cygwin User's Guide and consult the Cygwin mailing list archives 
+about others' experiences.
 
 
 The Default Text File Type should be left on
@@ -83,7 +88,7 @@ have a very good reason to switch it to 
 
 The Local Package Directory is the cache where 
 setup.exe stores the packages before they are
-installed. The cache should not be the same folder as the Cygwin
+installed. The cache must not be the same folder as the Cygwin
 root. Within the cache, a separate directory is created for each
 Cygwin mirror, which allows setup.exe to use 
 multiple mirrors and custom packages. After installing Cygwin,
@@ -94,10 +99,11 @@ or in case you need to reinstall a packa
 
 Connection Method
 
-For most users, the Direct Connection method
-of downloading is the best choice. If you have a proxy server,
-you can use the Use IE5 Settings if it is 
-already set up in Internet Exlporer, or manually type it into 
+The Direct Connection method of downloading will 
+directly download the packages, while the IE5 method will leverage your 
+IE5 cache for performance. If your organisation uses a proxy server or
+auto-configuration scripts, the IE5 method also uses these settings.
+If you have a proxy server, you can manually type it into 
 the Use Proxy section. Unfortunately, 
 setup.exe does not currently support password
 authorization for proxy servers.
@@ -120,16 +126,21 @@ mirror) you can add it.
 Choosing Packages
 
 For each selected mirror site, setup.exe downloads a 
-small text file called setup.ini that contains a list
+small text file called setup.bz2 that contains a list
 of packages available from that site along with some basic information about
-each package (version number, dependencies, checksum, etc.) which 
-setup.exe parses and uses to create the chooser window.
+each package which setup.exe parses and uses to create the 
+chooser window. For details about the format of this file, see
+http://sources.redhat.com/cygwin-apps/setup.html#setup.ini";>
+http://sources.redhat.com/cygwin-apps/setup.html.
 
 
 The chooser is the most complex part of setup.exe. 
-Packages are divided into categories. By default setup.exe
+Packages are grouped into categories, and one package may belong to multiple 
+categories (assigned by the volunteer package maintainer). Each package
+can be found under any of those categories in the heirarchial chooser view.
+By default setup.exe
 will install only the packages in the Base category
-and their dependencies, resulting in a very basic Cygwin installation.
+and their dependencies, resulting in a minimal Cygwin installation.
 However, this will not include many commonly used tools such as 
 gcc (which you will find in the Devel 
 category). 
@@ -197,13 +208,13 @@ use these shortcuts as a guide to creati
 Last of all, setup.exe will run any post-install
 scripts to finish correctly setting up installed packages. Since each
 script is run separately, several windows may pop up. If you are 
-interested in what is being done, the scripts are kept in the 
-/etc/postinstall/ directory, renamed with a 
-done extension after being run. When the last
-post-install script is completed, setup.exe will
-display a box announcing the completion. A few packages, such as
+interested in what is being done, see the Cygwin Package Contributor's
+Guide at http://cygwin.com/setup.html";>http://cygwin.com/setup.html
+When the last post-install script is completed, setup.exe 
+will display a box announcing the completion. A few packages, such as
 the OpenSSH server, require some manual site-specific configuration. 
-Relevant do

Re: Patched doc/setup-net.sgml

2003-03-22 Thread Joshua Daniel Franklin
--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> On Sat, Mar 22, 2003 at 12:47:08PM -0800, Joshua Daniel Franklin wrote:
> >Is this going to matter?
> 
> No.

Committed.

__
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com


Re: Patched doc/setup-net.sgml

2003-03-22 Thread Joshua Daniel Franklin
--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> >> Feel free to update the cygwin web pages if you want.
> >
> >OK... how?
> 
> CVS - :ext:cygwin.com:/cvs/cygwin

I've got this ready to go, but there are quite a few small 
differences between the ones in htdocs/cygwin-ug-net and my
cygwin-ug-net, I suspect related to:

-CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
-">http://platinum.yahoo.com


Re: Patched doc/setup-net.sgml

2003-03-22 Thread Joshua Daniel Franklin
--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> On Sat, Mar 22, 2003 at 02:11:32PM -0600, Joshua Daniel Franklin wrote:
> >I just committed a big pactch to doc/setup-net.sgml that more or less
> >documents setup.exe. Resulting HTML can temporarily be seen at:
> >
> ><http://iocc.com/~joshua/cygwin/setup-net.html>
> >
> >2003-03-22  Joshua Daniel Franklin <[EMAIL PROTECTED]>
> >
> >* setup-net.sgml: Document setup.exe
> 
> Feel free to update the cygwin web pages if you want.

OK... how?

__
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com


Patched doc/setup-net.sgml

2003-03-22 Thread Joshua Daniel Franklin
I just committed a big pactch to doc/setup-net.sgml that more or less
documents setup.exe. Resulting HTML can temporarily be seen at:

<http://iocc.com/~joshua/cygwin/setup-net.html>

2003-03-22  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* setup-net.sgml: Document setup.exe



Re: [PATCH] docs/install.texinfo

2003-03-03 Thread Joshua Daniel Franklin
On Mon, Mar 03, 2003 at 07:29:41PM -0500, Pierre A. Humblet wrote:
> here is an upgrade to the FAQ.

Actually, the FAQ is davidsb's territory, though it looks good to me.


Re: utils.sgml (was Re: mkpasswd & mkgroup)

2003-03-01 Thread Joshua Daniel Franklin
> At 02:45 PM 2/25/2003 -0800, Joshua Daniel Franklin wrote:
> >Any progress on documenting these in utils.sgml?
 
On Sat, Mar 01, 2003 at 11:43:20AM -0500, Pierre A. Humblet wrote:
> Yes!

Thanks Pierre! I checked this in with only a small grammatical
change.
? utils.sgml-orig
? utils.sgml-patch
Index: utils.sgml
===
RCS file: /cvs/src/src/winsup/utils/utils.sgml,v
retrieving revision 1.35
diff -h -u -p -r1.35 utils.sgml
--- utils.sgml  3 Feb 2003 00:30:45 -   1.35
+++ utils.sgml  1 Mar 2003 17:28:37 -
@@ -372,6 +372,7 @@ This program prints a /etc/group file to
 
 Options:
-l,--local print local group information
+   -c,--current   print current group, if a domain account
-d,--domainprint global group information from the domain
   specified (or from the current domain if there is
   no domain specified)
@@ -389,14 +390,15 @@ One of `-l' or `-d' must be given on NT/
 
 The mkgroup program can be used to help
 configure your Windows system to be more UNIX-like by creating an
-initial /etc/group substitute (some commands need this
-file) from your system information. It only works on the NT series
-(Windows NT, 2000, and XP). mkgroup does not work on 
-the Win9x series (Windows 95, 98, and Me) because they lack the security model 
-to support it. To initially set up your machine, you'd do something like 
-this:
-
-Setting up the groups file
+initial /etc/group.
+Its use is essential on the NT series (Windows NT, 2000, and XP) to
+include Windows security information.
+It can also be used on the Win9x series (Windows 95, 98, and Me) to
+create a file with the correct format.
+To initially set up your machine if you are a local user, you'd do
+something like this:
+  
+Setting up the groups file for local accounts
 
 $ mkdir /etc
 $ mkgroup -l > /etc/group
@@ -408,16 +410,24 @@ information in your system, you'll need 
 for it to have the new information.
 
 The -d and -l options
-allow you to specify where the information comes from, either the
-local machine or the default (or given) domain.  The -o
-option allows for special cases (such as multiple domains) where the GIDs 
-might match otherwise. The -s
+allow you to specify where the information comes from, the
+local machine or the domain (default or given), or both.
+With the  -d option the program contacts the Domain
+Controller, which my be unreachable or have restricted access.
+An entry for the current domain user can then be created by using the
+option -c together with -l,
+but -c has no effect when used with -d.
+The -o option allows for special cases
+(such as multiple domains) where the GIDs might match otherwise.
+The -s
 option omits the NT Security Identifier (SID).  For more information on 
 SIDs, see  in the Cygwin User's Guide.  The
 -u option causes mkgroup to 
 enumerate the users for each group, placing the group members in the 
 gr_mem (last) field.  Note that this can greatly increase
 the time for mkgroup to run in a large domain.
+Having gr_mem fields is helpful when a domain user logs in remotely
+while the local machine is disconnected from the Domain Controller.
 
 
 
@@ -431,6 +441,7 @@ This program prints a /etc/passwd file t
 
 Options:
-l,--local  print local user accounts
+   -c,--currentprint current account, if a domain account
-d,--domain print domain accounts (from current domain
if no domain specified)
-o,--id-offset offset   change the default offset (1) added to uids
@@ -450,14 +461,17 @@ One of `-l', `-d' or `-g' must be given 
 
 The mkpasswd program can be used to help
 configure your Windows system to be more UNIX-like by creating an
-initial /etc/passwd substitute (some commands
-need this file) from your system information. It only works on the NT series
-(Windows NT, 2000, and XP). mkpasswd does not work on 
-the Win9x series (Windows 95, 98, and Me) because they lack the security model 
-to support it. To initially set up your machine, you'd do something like 
-this:
-
-Setting up the passwd file
+initial /etc/passwd from your system information.
+Its use is essential on the NT series (Windows NT, 2000, and XP) to
+include Windows security information, but the actual passwords are
+determined by Windows, not by the content of /etc/passwd.
+On the Win9x series (Windows 95, 98, and Me) the password field must be
+replaced by the output of crypt your_password
+if remote access is desired.
+To initially set up your machine if you are a local user, you'd do
+something like this:
+  
+Setting up the passwd file for local accounts
 
 $ mkdir /etc
 $ mkpasswd -l > /etc/passwd
@@ -469,10 +483,16 @@ information in your system, you'll need 
 for it to have the new information.
 
 The -d and -l opt

Re: mkpasswd & mkgroup

2003-02-25 Thread Joshua Daniel Franklin
--- "Pierre A. Humblet" <[EMAIL PROTECTED]> wrote:
> Earlier I have added a -c switch to mkpasswd & mkgroup. 

Any progress on documenting these in utils.sgml?

__
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/


Re: Produce beeps using soundcard

2003-02-13 Thread Joshua Daniel Franklin
>From 'man bash':
   escape sequences, if present, are decoded as follows:
  \a alert (bell)

Wouldn't this be better called "bell" or "alert"?

--- Vaclav Haisman <[EMAIL PROTECTED]> wrote:
> 
> Hi,
> this small patch adds an ability to produce beeps (\a) using soundcard by
> MessageBeep() call. It can be enabled by new CYGWIN option winbeep.
> 
> Vaclav Haisman
> 
> 2003-02-13  Vaclav Haisman  <[EMAIL PROTECTED]>
>   * environ.cc (windows_beep): New variable declaration.
>   (parse_thing): New CYGWIN option.
>   * fhandler_console.cc (windows_beep): New variable definition.
>   (fhandler_console::write_normal):  Handle the new option.
>   * Makefile.in (DLL_IMPORTS): Add libuser32.a for MessageBeep.

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com



heap_chunk_in_mb patch

2003-02-05 Thread Joshua Daniel Franklin
I committed this patch to document heap_chunk_in_mb.

2003-02-05  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* setup-net.sgml: Add "setup-maxmem" section 
* setup2.sgml: New section "setup-maxmem" to document heap_chunk_in_mb


Index: setup-net.sgml
===
RCS file: /cvs/src/src/winsup/doc/setup-net.sgml,v
retrieving revision 1.4
diff -u -p -r1.4 setup-net.sgml
--- setup-net.sgml  4 Dec 2001 04:20:31 -   1.4
+++ setup-net.sgml  6 Feb 2003 02:49:33 -
@@ -10,6 +10,7 @@ Follow the instructions on each screen t
 
 
 DOCTOOL-INSERT-setup-env
+DOCTOOL-INSERT-setup-maxmem
 DOCTOOL-INSERT-ntsec
 DOCTOOL-INSERT-setup-files
 
Index: setup2.sgml
===
RCS file: /cvs/src/src/winsup/doc/setup2.sgml,v
retrieving revision 1.5
diff -u -p -r1.5 setup2.sgml
--- setup2.sgml 4 Dec 2001 04:20:31 -   1.5
+++ setup2.sgml 6 Feb 2003 02:49:33 -
@@ -55,6 +55,74 @@ first starts.  Most Cygwin applications 
 
 
 
+Changing Cygwin's Maximum Memory
+
+
+By default no Cygwin program can allocate more than 384 MB of memory 
+(program+data).  You should not need to change this default in most 
+circumstances.  However, if you need to use more real or virtual memory in 
+your machine you may add an entry in the either the 
+HKEY_LOCAL_MACHINE (to change the limit for all users) or 
+HKEY_CURRENT_USER (for just the current user) section of 
+the registry. 
+
+
+
+Add the DWORD value heap_chunk_in_mb 
+and set it to the desired memory limit in decimal MB. It is preferred to do 
+this in Cygwin using the regtool program included in the 
+Cygwin package.
+(For more information about regtool or the other Cygwin 
+utilities, see  or use each the
+--help option of each util.)  You should always be careful 
+when using regtool since damaging your system registry can 
+result in an unusable system.  This example sets memory limit to 1024 MB:
+
+
+regtool -i set /HKLM/Software/Cygnus\ Solutions/Cygwin/heap_chunk_in_mb 1024
+regtool -v list /HKLM/Software/Cygnus\ Solutions/Cygwin
+
+
+
+
+Exit all running Cygwin processes and restart them. Memory can be allocated up 
+to the size of the system swap space minus any the size of any running 
+processes. The system swap should be at least as large as the physically 
+installed RAM and can be modified under the System category of the 
+Control Panel.  
+
+
+
+Here is a small program written by DJ Delorie that tests the 
+memory allocation limit on your system:
+
+
+main()
+{
+  unsigned int bit=0x4000, sum=0;
+  char *x;
+  
+  while (bit > 4096) 
+  {
+x = malloc(bit);
+if (x)
+sum += bit;
+bit >>= 1;
+  }
+  printf("%08x bytes (%.1fMb)\n", sum, sum/1024.0/1024.0);
+  return 0;
+}
+
+
+You can compile this program using:
+
+gcc max_memory.c -o max_memory.exe
+
+
+Run the program and it will output the maximum amount of allocatable memory.
+
+
+
 Customizing bash
 
 



Re: doc patch for CYGWIN codepage=, regtool

2003-02-02 Thread Joshua Daniel Franklin
> Incidentally, does anyone know where the source of the regtool manpage is?
> It should be patched accordingly, but I couldn't find it.

(Also replied to in [EMAIL PROTECTED])
>From /usr/doc/Cygwin/cygwin-doc-1.3-2.README :
-
The two intro pages (intro.1 and intro.3) were written by hand by me.
The rest of the cygwin man pages are autogenerated from the SGML files
found in CVS. 
-

Expect a refresh of cygwin-doc (relatively) soon.

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



doc patch for CYGWIN codepage=, regtool

2003-02-02 Thread Joshua Daniel Franklin
I've checked in this documentation patch that fixes a couple of things. 
There was talk of a codepage:none option, but it's not in cygwin yet
so I'm ignoring it for now. 

I missed the regtool patch that added -K way back in August

http://sources.redhat.com/ml/cygwin-patches/2002-q3/msg00238.html

but it would be great to get patches for utils.sgml whenever a util
is patched, or at least a heads-up.

2003-02-02  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* cygwinenv.sgml: Add section for "CYGWIN codepage:[ansi|oem]"
* dll.sgml: Add pointer to GCC website for more information
* utils.sgml: Update regtool for -K,--key-separator option

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


tmp.patch
Description: tmp.patch


grammar in doc/ntsec.sgml

2002-10-22 Thread Joshua Daniel Franklin
I applied this patch to fix the grammar issues mentioned here:

http://www.cygwin.com/ml/cygwin/2002-10/msg01293.html

I also applied the earlier patch to doc/dll.sgml mentioned:

http://www.cygwin.com/ml/cygwin-patches/2002-q4/msg7.html

ChangeLog:

2002-10-22  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* ntsec.sgml: Correct some minor grammatical errors.




User's Guide DLL building patch

2002-10-16 Thread Joshua Daniel Franklin

Here is a patch suggested some time ago by Gerrit to
make the process of building a dll more clear:

http://sources.redhat.com/ml/cygwin/2002-08/msg01224.html

I have changed it to C instead of C++ and also added a remark
in the "Linking to DLLs" section about building your own
import lib.

ChangeLog (this is in the doc subdir):

2002-10-16  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* dll.sgml: Clarify discussion of building dlls.


--- dll.sgml-orig   2002-10-15 22:48:29.0 -0500
+++ dll.sgml2002-10-15 23:31:47.0 -0500
@@ -39,19 +39,18 @@ For this example, we'll use a single fil
 mydll.c for the contents of the dll
 (mydll.dll).
 
-Now compile everything to objects:
-
-gcc -c myprog.c
-gcc -c mydll.c
-
 Fortunately, with the latest gcc and binutils the process for building a dll
 is now pretty simple. Say you want to build this minimal function in mydll.c:
 
-int WINAPI
-mydll_init(HANDLE h, DWORD reason, void *foo)
+
+#include <stdio.h>
+
+int
+hello()
 {
-  return 1;
-}
+  printf ("Hello World!\n");
+}  
+
 
 First compile mydll.c to object code:
 
@@ -61,7 +60,26 @@ mydll_init(HANDLE h, DWORD reason, void 
 
 gcc -shared -o mydll.dll mydll.o
 
-That's it! However, if you are building a dll as an export library,
+
+That's it! To finish up the example, you can now link to the
+dll with a simple program:
+
+
+
+int 
+main ()
+{
+  hello ();
+}  
+
+
+
+Then link to your dll with a command like:
+
+
+gcc -o myprog myprog.ca -L./ -lmydll
+
+However, if you are building a dll as an export library,
 you will probably want to use the complete syntax:
 
 gcc -shared -o cyg${module}.dll \
@@ -80,9 +98,10 @@ link against, e.g '-lpng -lz -L/usr/loca
 Linking Against DLLs
 
 If you have an existing DLL already, you need to build a
-Cygwin-compatible import library (The supplied ones should work, but
-you might not have them) to link against.  Unfortunately, there is not
-yet any tool to do this automatically.  However, you can get most of
+Cygwin-compatible import library.  If you have the source to compile
+the DLL, see  for details on having 
+gcc build one for you.  If you do not have the
+source or a supplied working import library, you can get most of
 the way by creating a .def file with these commands (you might need to
 do this in bash for the quoting to work
 correctly):



a utils.sgml patch

2002-06-24 Thread Joshua Daniel Franklin

Mon, 24 Jun 2002 18:56:45 -0500ere is a first patch for utils.sgml.
This patch simply updates each of the  sections that
show the --help output to reflect the 1.3.11-3 utils.
It seems like a good thing to get out of the way before attacking
the section for each util.

ChangeLog:

2002-06-24  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* utils.sgml: Update screen sections to reflect --help
output changes.


--- utils.sgml-orig 2002-06-24 18:40:48.0 -0500
+++ utils.sgml  2002-06-24 18:49:21.0 -0500
@@ -8,14 +8,15 @@ specifically for Cygwin.
 cygcheck
 
 
-Usage: cygcheck [-s] [-v] [-r] [-h] [program ...]
-  -c   check current package setup
-  -h   give help about the info
-  -s   system information
-  -v   verbose output (indented) (for -s or programs)
-  -r   registry search (requires -s)
-  -V   version info
-You must at least give either -s or a program name
+Usage: cygcheck [OPTIONS] [program ...]
+ -c, --check-setup  check packages installed via setup.exe
+ -s, --sysinfo  system information (not with -k)
+ -v, --verbose  verbose output (indented) (for -s or programs)
+ -r, --registry registry search (requires -s)
+ -k, --keycheck perform a keyboard check session (not with -s)
+ -h, --help give help about the info (not with -c)
+ -V, --version  output version information and exit
+You must at least give either -s or -k or a program name
 
 
 The cygcheck program is a diagnostic utility
@@ -71,29 +72,32 @@ or if you know what everything is alread
 cygpath
 
 
-Usage: cygpath [-p|--path] (-w|--windows) ([-s|--short-name]|[-l|--long-name]) 
filename
-Usage: cygpath [-p|--path] (-u|--unix) filename
-Usage: cygpath (-H|--homeroot)|(-S|--sysdir)|(-W|--windir) [-s|--short-name]
-Usage: cygpath [-A|--allusers] (-D|--desktop)|(-P|--smprograms) [-s|--short-name]
+Usage: cygpath.exe (-u|-w|-t TYPE) [-c HANDLE] [-f FILE] [options] NAME
+   cygpath.exe [-ADHPSW] 
+Output type options (required):
+  -u|--unix print Unix form of NAME (default)
+  -w|--windows  print Windows form of NAME 
+  -t|--type print Windows form of NAME with TYPE one of
+ dosdrive letter with backslashes (C:\WINNT)
+ mixed  drive letter with regular slashes (C:/WINNT)
+Path conversion options:
   -a|--absolute output absolute path
-  -c|--close handle close handle (for use in captured process)
-  -f|--file fileread file for input path information
+  -c|--close HANDLE close HANDLE (for use in captured process)
+  -f|--file FILEread FILE for input; use - to read from STDIN
   -i|--ignore   ignore missing argument
-  -l|--long-nameprint Windows long form of filename
-  -p|--path filename argument is a path
-  -s|--short-name   print Windows short form of filename
-  -u|--unix print Unix form of filename
-  -t|--type print Windows form of filename with specified
- dosdrive letter with backslashes (c:\winnt)
- mixed  drive letter with regular slashes (c:/winnt)
-  -v|--version  output version information and exit
-  -w|--windows  print Windows form of filename
+  -l|--long-nameprint Windows long form of NAME (with -w only)
+  -p|--path NAME is a PATH list (i.e., '/bin:/usr/bin')
+  -s|--short-name   print Windows short form of NAME (with -w only)
+System information output:
   -A|--allusers use `All Users' instead of current user for -D, -P
-  -H|--homerootoutput `Profiles' directory (home root) and exit
   -D|--desktop  output `Desktop' directory and exit
+  -H|--homeroot output `Profiles' directory (home root) and exit
   -P|--smprograms   output Start Menu `Programs' directory and exit
   -S|--sysdir   output system directory and exit
   -W|--windir   output `Windows' directory and exit
+Other options:
+  -h|--help output usage information and exit
+  -v|--version  output version information and exit
 
 
 The cygpath program is a utility that
@@ -159,9 +163,13 @@ The -ws options can b
 kill
 
 
-Usage: kill [-f] [-sigN] [-s sigN] pid1 [pid2 ...]
-Usage: kill -l [signal]
-Usage: Kill -h
+Usage: kill [-f] [-signal] [-s signal] pid1 [pid2 ...]
+   kill -l [signal]
+ -f, --force force, using win32 interface if necessary
+ -l, --list  print a list of signal names
+ -s, --signalsend signal (use kill --list for a list)
+ -h, --help  output usage information and exit
+ -v, --version   output version information and exit
 
 
 The kill program allows you to send arbitrary
@@ -241,20 +249,25 @@ SIGUSR2 31user defined signal 2
 mkgroup
 
 
-usage: mkgroup [options] [domain]
-  This program prints a /etc/group

Re: YACP

2002-06-22 Thread Joshua Daniel Franklin

> >It would be fine with me to leave the '--type TYPE' syntax as an
> >alternative to --unix, --windows, --mixed, but having the --type mixed
> >as the only way to get a forward-slash Windows path seemed counter-
> >intuitive to me. Also --type dos to me should mean short-name as well.
> >So should I put together another patch to do this as well?
>
> Actually, I think that specifying the output via --type makes things a
> little more structured.  We can't go back now, though, because users
> would complain.  It looks like I should have added a '--type unix' if
> I was going to be consistent, though.
>
> I dunno.  I don't feel really strongly about this, though.  If no one
> agrees then I don't mind changing it.

That does sound like a better idea. This patch is therefore better.
It fleshes out the --type option so that one can specify: 'dos', 'mixed',
'unix', or 'windows'. The 'dos' type includes short-name. While I was
at it, I added a --dos option which is the same as --windows --short-name.
It's too bad about the feature bloat, but having both should satisfy both
structure and users.

I feel good about changing the default action to --unix since before
-u or -w was required in every case, so the only thing it would change
(to users) is if before they were always typing something like
'cygpath c:' and getting errors now they will get UNIXy path output.

I also corrected an apparent bug in the long_options that prevented
"close", "file" and "type" from working, even though -c, -f, and -t
did. I'm not intimate with getopt but it looks like the flag part of
long_options struct should be set to NULL if you're using the optarg.

ChangeLog:

2002-06-22  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* cygpath.cc (long_options): Add "dos" and "mixed", correct
"close", "file" and "type" to use NULL flag.
(usage): Clean up usage output (more), accomodate new options.
(main): Add --dos and --mixed options; accomodate all output
forms in --type. Make UNIXy output default.



--- cygpath.cc-orig Thu Jun 20 17:28:00 2002
+++ cygpath.cc  Sat Jun 22 11:35:50 2002
@@ -30,28 +30,30 @@ static int path_flag, unix_flag, windows
 static int shortname_flag, longname_flag;
 static int ignore_flag, allusers_flag, output_flag;
 static int mixed_flag;
-static const char *windows_format_arg;
+static const char *format_type_arg;
 
 static struct option long_options[] = {
-  {(char *) "help", no_argument, NULL, 'h'},
   {(char *) "absolute", no_argument, NULL, 'a'},
+  {(char *) "close", required_argument, NULL, 'c'},
+  {(char *) "dos", no_argument, NULL, 'd'},
+  {(char *) "file", required_argument, NULL, 'f'},
+  {(char *) "help", no_argument, NULL, 'h'},
+  {(char *) "ignore", no_argument, NULL, 'i'},
+  {(char *) "long-name", no_argument, NULL, 'l'},
+  {(char *) "mixed", no_argument, NULL, 'm'},
   {(char *) "option", no_argument, NULL, 'o'},
   {(char *) "path", no_argument, NULL, 'p'},
-  {(char *) "close", required_argument, (int *) &close_arg, 'c'},
+  {(char *) "short-name", no_argument, NULL, 's'},
+  {(char *) "type", required_argument, NULL, 't'},
   {(char *) "unix", no_argument, NULL, 'u'},
-  {(char *) "file", required_argument, (int *) &file_arg, 'f'},
   {(char *) "version", no_argument, NULL, 'v'},
   {(char *) "windows", no_argument, NULL, 'w'},
-  {(char *) "short-name", no_argument, NULL, 's'},
-  {(char *) "long-name", no_argument, NULL, 'l'},
-  {(char *) "windir", no_argument, NULL, 'W'},
-  {(char *) "sysdir", no_argument, NULL, 'S'},
-  {(char *) "ignore", no_argument, NULL, 'i'},
   {(char *) "allusers", no_argument, NULL, 'A'},
   {(char *) "desktop", no_argument, NULL, 'D'},
-  {(char *) "smprograms", no_argument, NULL, 'P'},
-  {(char *) "type", required_argument, (int *) &windows_format_arg, 't'},
   {(char *) "homeroot", no_argument, NULL, 'H'},
+  {(char *) "smprograms", no_argument, NULL, 'P'},
+  {(char *) "sysdir", no_argument, NULL, 'S'},
+  {(char *) "windir", no_argument, NULL, 'W'},
   {0, no_argument, 0, 0}
 };
 
@@ -60,33 +62,41 @@ usag

Re: YACP

2002-06-20 Thread Joshua Daniel Franklin

So is the UNC type coming back at some point? 

It would be fine with me to leave the '--type TYPE' syntax as an 
alternative to --unix, --windows, --mixed, but having the --type mixed
as the only way to get a forward-slash Windows path seemed counter-
intuitive to me. Also --type dos to me should mean short-name as well.
So should I put together another patch to do this as well?

And BTW, is the UNIXy default OK?

--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> On Thu, Jun 20, 2002 at 06:17:21PM -0500, Joshua Daniel Franklin wrote:
> >YACP (Yet Another Cygpath Patch)
> >
> >The major change that this make is setting the UNIXy output to be the
> >default. This was already true for the -ADHPSW options. If this is a
> >bad idea for some reason unknown to me, there were only 3 lines changed
> >to do it. (Everything still works with --unix, of course.)
> >
> >Also, thinking about this new --type TYPE option, I was wondering what
> >exactly the 'dos' type did. So I look at the code:
> >
> >- if (strcasecmp (windows_format_arg, "mixed") == 0)
> >-   mixed_flag = 1;
> >- else if (strcasecmp (windows_format_arg, "dos") == 0)
> >-   /* nothing */;
> >- else
> >-   usage (stderr, 1);
> >- break;
> >
> >Ah! It does /* nothing */, I see. So also this patch REMOVES the
> >-t, --type option and changes it to -m, --mixed instead. This is hopefully
> >easier to understand.
> 
> Actually, there was another option but it was obsolete so I removed it.
> I figured that the --type option would provide the capability for other
> formats for filenames in the future, like //?/ or whatever.
> 
> cgf


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



YACP

2002-06-20 Thread Joshua Daniel Franklin

YACP (Yet Another Cygpath Patch)

The major change that this make is setting the UNIXy output to be the
default. This was already true for the -ADHPSW options. If this is a
bad idea for some reason unknown to me, there were only 3 lines changed
to do it. (Everything still works with --unix, of course.)

Also, thinking about this new --type TYPE option, I was wondering what
exactly the 'dos' type did. So I look at the code:

- if (strcasecmp (windows_format_arg, "mixed") == 0)
-   mixed_flag = 1;
- else if (strcasecmp (windows_format_arg, "dos") == 0)
-   /* nothing */;
- else
-   usage (stderr, 1);
- break;

Ah! It does /* nothing */, I see. So also this patch REMOVES the
-t, --type option and changes it to -m, --mixed instead. This is hopefully
easier to understand.

Also there is gratuitous alphabetizing of the longopts and options, and
various cleanup in usage().

ChangeLog:

2002-06-18  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* cygpath.cc (usage): Clean up usage output (more).
(main): Change --type option to --mixed; remove '/* nothing */'.
Make UNIXy output default.



--- cygpath.cc-orig Thu Jun 20 17:28:00 2002
+++ cygpath.cc  Thu Jun 20 18:06:23 2002
@@ -30,28 +30,27 @@ static int path_flag, unix_flag, windows
 static int shortname_flag, longname_flag;
 static int ignore_flag, allusers_flag, output_flag;
 static int mixed_flag;
-static const char *windows_format_arg;
 
 static struct option long_options[] = {
-  {(char *) "help", no_argument, NULL, 'h'},
   {(char *) "absolute", no_argument, NULL, 'a'},
+  {(char *) "close", required_argument, (int *) &close_arg, 'c'},
+  {(char *) "file", required_argument, (int *) &file_arg, 'f'},
+  {(char *) "help", no_argument, NULL, 'h'},
+  {(char *) "ignore", no_argument, NULL, 'i'},
+  {(char *) "long-name", no_argument, NULL, 'l'},
+  {(char *) "mixed", no_argument, NULL, 'm'},
   {(char *) "option", no_argument, NULL, 'o'},
   {(char *) "path", no_argument, NULL, 'p'},
-  {(char *) "close", required_argument, (int *) &close_arg, 'c'},
+  {(char *) "short-name", no_argument, NULL, 's'},
   {(char *) "unix", no_argument, NULL, 'u'},
-  {(char *) "file", required_argument, (int *) &file_arg, 'f'},
   {(char *) "version", no_argument, NULL, 'v'},
   {(char *) "windows", no_argument, NULL, 'w'},
-  {(char *) "short-name", no_argument, NULL, 's'},
-  {(char *) "long-name", no_argument, NULL, 'l'},
-  {(char *) "windir", no_argument, NULL, 'W'},
-  {(char *) "sysdir", no_argument, NULL, 'S'},
-  {(char *) "ignore", no_argument, NULL, 'i'},
   {(char *) "allusers", no_argument, NULL, 'A'},
   {(char *) "desktop", no_argument, NULL, 'D'},
-  {(char *) "smprograms", no_argument, NULL, 'P'},
-  {(char *) "type", required_argument, (int *) &windows_format_arg, 't'},
   {(char *) "homeroot", no_argument, NULL, 'H'},
+  {(char *) "smprograms", no_argument, NULL, 'P'},
+  {(char *) "sysdir", no_argument, NULL, 'S'},
+  {(char *) "windir", no_argument, NULL, 'W'},
   {0, no_argument, 0, 0}
 };
 
@@ -60,32 +59,31 @@ usage (FILE * stream, int status)
 {
   if (!ignore_flag || !status)
 fprintf (stream, "\
-Usage: %s (-u|-w|-t TYPE) [-c HANDLE] [-f FILE] [options] NAME\n\n\
-   %s [-ADHPSW] \n\n\
-Output type options (required):\n\
-  -u|--unixprint Unix form of NAME (default)\n\
-  -w|--windows print Windows form of NAME \n\n\
-  -t|--type print Windows form of NAME with TYPE one of\n\
- dosdrive letter with backslashes (C:\\WINNT)\n\
- mixed  drive letter with regular slashes (C:/WINNT)\n\
+Usage: %s (-u|-w|-t TYPE) [-c HANDLE] [-f FILE] [options] NAME\n\
+   %s [-ADHPSW] \n\
+Output type options:\n\
+  -u, --unix   (default) print Unix form of NAME (/cygdrive/c/winnt)\n\
+  -w, --windows print Windows form of NAME (C:\\WINNT)\n\
+  -m, --mixed   like --windows, but with regular slashes (C:/WINNT)\n\
 Path conversion options:\n\
-  -a|--absoluteoutput absolute path\n\
-  -c|--close HANDLE close HANDLE (for use in captured process)\n\
-  -f|--file FILEread FILE for input; use - to read from STDIN\n\
-  -i|--ignore  ignore missing argument\n\
-  

cygpath costmetics

2002-06-18 Thread Joshua Daniel Franklin

Here is a mostly cosmetic change for cygpath. I organized the usage
output so that it is more clear (to me) that the -ADHPSW options do
not require an argument. I also changed the desciption for --help
to 'output usage' from 'print this help' since the latter looks mighty
silly on the web or man page.

The only non-cosmetic part is an attempted fix for the new
'--type mixed' option. I have to confess that I don't understand how the
'--type dos' option is different from --windows, or why '--type mixed'
is a better solution than a --mixed option. I'm CC'ing the author of
that patch so perhaps he can enlighten us if not already reading this
mailing list. In any case, however,
the -ADHPSW options should respect the new option and I think these
two lines of code will do it. I'm still not able to compile the utils
right now, though, so that code is untested.

ChangeLog:

2002-06-18  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* cygpath.cc (usage): Clean up usage output.
(dowin): Correct output of -t mixed for -ADHPSW options.



--- cygpath.cc-orig Tue Jun 18 19:33:22 2002
+++ cygpath.cc  Tue Jun 18 20:00:43 2002
@@ -60,29 +60,33 @@ usage (FILE * stream, int status)
 {
   if (!ignore_flag || !status)
 fprintf (stream, "\
-Usage: %s (-u|--unix)|(-w|--windows) [options] filename\n\n\
-  -u|--unixprint Unix form of filename\n\
-  -w|--windows print Windows form of filename\n\n\
-Other options:\n\
-  -a|--absoluteoutput absolute path\n\
-  -c|--close handleclose handle (for use in captured process)\n\
-  -f|--file file   read file for input path information\n\
-  -i|--ignore  ignore missing argument\n\
-  -l|--long-name   print Windows long form of filename (with -w only)\n\
-  -p|--pathfilename argument is a path\n\
-  -s|--short-name  print Windows short form of filename (with -w only)\n\
-  -t|--type print Windows form of filename with specified\n\
+Usage: %s (-u|-w|-t TYPE) [-c HANDLE] [-f FILE] [options] NAME\n\n\
+   %s [-ADHPSW] \n\n\
+Output type options (required):\n\
+  -u|--unixprint Unix form of NAME (default)\n\
+  -w|--windows print Windows form of NAME \n\n\
+  -t|--type print Windows form of NAME with TYPE one of\n\
  dosdrive letter with backslashes (C:\\WINNT)\n\
  mixed  drive letter with regular slashes (C:/WINNT)\n\
+Path conversion options:\n\
+  -a|--absoluteoutput absolute path\n\
+  -c|--close HANDLE close HANDLE (for use in captured process)\n\
+  -f|--file FILEread FILE for input; use - to read from STDIN\n\
+  -i|--ignore  ignore missing argument\n\
+  -l|--long-name   print Windows long form of NAME (with -w only)\n\
+  -p|--pathNAME is a PATH list (i.e., '/bin:/usr/bin')\n\
+  -s|--short-name  print Windows short form of NAME (with -w only)\n\
+System information output:\n\
   -A|--allusersuse `All Users' instead of current user for -D, -P\n\
   -D|--desktop output `Desktop' directory and exit\n\
   -H|--homerootoutput `Profiles' directory (home root) and exit\n\
   -P|--smprograms  output Start Menu `Programs' directory and exit\n\
   -S|--sysdir  output system directory and exit\n\
   -W|--windir  output `Windows' directory and exit\n\n\
-Informative output:\n\
-  -h|--help print this help, then exit\n\
-  -v|--version output version information and exit\n", prog_name);
+Other options:\n\
+  -h|--help output usage information and exit\n\
+  -v|--version output version information and exit\n\
+  ", prog_name, prog_name);
   exit (ignore_flag ? 0 : status);
 }
 
@@ -373,6 +377,8 @@ dowin (char option)
 {
   if (shortname_flag)
 buf = get_short_name (buf);
+  if (mixed_flag)
+buf = get_mixed_name (buf);
 }
   printf ("%s\n", buf);
   exit (0);



Re: passwd edited /etc/passwd patch

2002-06-13 Thread Joshua Daniel Franklin

--- Corinna Vinschen <[EMAIL PROTECTED]> wrote:
> On Tue, Jun 11, 2002 at 08:18:15PM -0500, Joshua Daniel Franklin wrote:
> > +  /* Try getting a Win32 username in case the user edited /etc/passwd */
> > +  if (ret == NERR_UserNotFound)
> > +  {
> > +if ((pw = getpwnam (user)))
> > +  cygwin_internal (CW_EXTRACT_DOMAIN_AND_USER, pw, domain, (char *)
> user);
> 
> Thanks for the patch but, hmm, I think I'd prefer to look always for
> the Cygwin username first.
> It's unlikely and probably just an academic case but you could have
> the Cygwin username user_a for the windows user user_b and vice versa.
> 

Umm...kay. I was trying to avoid the extra system call, but I guess it
probably won't make much difference. I'm having build problems right now 
but I think this patch will do what you're asking. 


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


passwd.c-patch
Description: passwd.c-patch


passwd edited /etc/passwd patch

2002-06-11 Thread Joshua Daniel Franklin

Here is that patch for passwd.c to deal with user-edited /etc/passwd
files. I poked around about adding the CW_EXTRACT_DOMAIN_AND_USER
then did a CVS update and Corinna already had done it. Sorry for the
delay, I apparently haven't been paying attention for more than a week...

ChangeLog:

2002-06-11  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* passwd.c (GetPW): Handle case of user-edited /etc/passwd
with cygwin_internal (CW_EXTRACT_DOMAIN_AND_USER, ...)



--- passwd.c-orig   Tue Jun 11 20:13:51 2002
+++ passwd.cTue Jun 11 19:59:17 2002
@@ -16,6 +16,7 @@ details. */
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -107,9 +108,21 @@ GetPW (const char *user)
   WCHAR name[512];
   DWORD ret;
   PUSER_INFO_3 ui;
-
+  struct passwd *pw;
+  char *domain = (char *) malloc (MAX_PATH + 1);
+ 
   MultiByteToWideChar (CP_ACP, 0, user, -1, name, 512);
   ret = NetUserGetInfo (NULL, name, 3, (LPBYTE *) &ui);
+  /* Try getting a Win32 username in case the user edited /etc/passwd */
+  if (ret == NERR_UserNotFound)
+  {
+if ((pw = getpwnam (user)))
+  cygwin_internal (CW_EXTRACT_DOMAIN_AND_USER, pw, domain, (char *) user);
+MultiByteToWideChar (CP_ACP, 0, user, -1, name, 512);
+ret = NetUserGetInfo (NULL, name, 3, (LPBYTE *) &ui);
+if (ret == (int) NULL)
+  printf ("Windows username : %s\n", user);
+  }
   return EvalRet (ret, user) ? NULL : ui;
 }
 



Re: Patch for sub-second resolution in stat(2)

2002-06-06 Thread Joshua Daniel Franklin

You know, I had some trouble with this, too. 
Maybe it would be worth adding to contrib.html that attaching 
a "ChangeLog.txt" file works well to preserve formatting?

--- Conrad Scott <[EMAIL PROTECTED]> wrote:
> "Earnie Boyd" <[EMAIL PROTECTED]> wrote:
> > Attach the ChangeLog entry to the mail, make sure the mime for the
> > attachment is text or make sure the file has a .txt suffix.  Most mail
> > clients will then display the attachment within the body of the mail.
> 
> Thanks for the hint: I've just had a look and yes, OE was attaching the
> changelog file as 'application/octet-stream' (i.e. binary). I'll try saving
> the file as 'changelog.txt' and attaching that next time.
> 
> Thanks.
> 
> // Conrad
> 
> 


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



strace patch

2002-06-05 Thread Joshua Daniel Franklin

Here is a patch for strace that changes the method of version output
to be consistent with the other utils. CVS should now automatically
update version information. I also changed usage () so that the MASK
information will only display with --help.

ChangeLog:

2002-06-05  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* strace.cc (version): New global variable.
(usage): Accomodate stdout output.
(print_version): New function.



--- strace.cc-orig  Wed Jun  5 21:44:21 2002
+++ strace.cc   Wed Jun  5 21:43:54 2002
@@ -35,7 +35,7 @@ int _impure_ptr;
 #define alloca __builtin_alloca
 
 // Version string.
-static const char *version_string = "@(#)strace V1.0, Copyright (C) 2001, 2002 Red 
Hat Inc., " __DATE__ "\n";
+static const char version[] = "$Revision: 1.21 $";
 
 static const char *pgm;
 static int forkdebug = 1;
@@ -782,25 +782,27 @@ parse_mask (const char *ms, char **endpt
 }
 
 static void
-usage ()
+usage (FILE *where = stderr)
 {
-  fprintf (stderr, "\
-Usage: strace [OPTIONS] \n\
+  fprintf (where, "\
+Usage: %s [OPTIONS] \n\
   -b, --buffer-size=SIZE   set size of output file buffer\n\
   -d, --no-delta   don't display the delta-t microsecond timestamp\n\
   -f, --trace-children trace child processes (toggle - default true)\n\
-  -h, --help   display this help info\n\
+  -h, --help   output usage information and exit\n\
   -m, --mask=MASK  set message filter mask\n\
   -o, --output=FILENAMEset output file to FILENAME\n\
   -p, --pid=n  attach to executing program with cygwin pid n\n\
   -n, --crack-error-numbersoutput descriptive text instead of error\n\
numbers for Windows errors\n\
   -S, --flush-period=PERIODflush buffered strace output every PERIOD secs\n\
-  -t, --timestamp  use an absolute hh:mm:ss timestamp insted of the\n\
-   default microsecond timestamp.  Implies -d\n\
-  -v, --versiondisplay version info\n\
+  -t, --timestamp  use an absolute hh:mm:ss timestamp insted of \n\
+   the default microsecond timestamp.  Implies -d\n\
+  -v, --versionoutput version information and exit\n\
   -w, --new-window spawn program under test in a new window\n\
-\n\
+\n", pgm);
+  if ( where == stdout)
+fprintf (stdout, "\
 MASK can be any combination of the following mnemonics and/or hex values\n\
 (0x is optional).  Combine masks with '+' or ',' like so:\n\
 \n\
@@ -822,17 +824,14 @@ Usage: strace [OPTIONS] \n
 sigp 0x00800 (_STRACE_SIGP) Trace signal and process handling.\n\
 minimal  0x01000 (_STRACE_MINIMAL)  Very minimal strace output.\n\
 exitdump 0x04000 (_STRACE_EXITDUMP) Dump strace cache on exit.\n\
-system   0x08000 (_STRACE_SYSTEM)   Serious error which goes to console and 
log.\n\
+system   0x08000 (_STRACE_SYSTEM)   Serious error; goes to console and log.\n\
 nomutex  0x1 (_STRACE_NOMUTEX)  Don't use mutex for synchronization.\n\
 malloc   0x2 (_STRACE_MALLOC)   Trace malloc calls.\n\
 thread   0x4 (_STRACE_THREAD)   Thread-locking calls.\n\
 ");
-}
-
-static void
-version ()
-{
-  fputs (version_string + 4, stderr);
+  if (where == stderr)
+fprintf (stderr, "Try '%s --help' for more information.\n", pgm);
+  exit (where == stderr ? 1 : 0 );
 }
 
 struct option longopts[] = {
@@ -854,6 +853,28 @@ struct option longopts[] = {
 
 static const char *const opts = "b:dhfm:no:p:S:tuvw";
 
+static void
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+%s (cygwin) %.*s\n\
+System Trace\n\
+Copyright 2000, 2001, 2002 Red Hat, Inc.\n\
+Compiled on %s", pgm, len, v, __DATE__);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -881,8 +902,7 @@ main (int argc, char **argv)
break;
   case 'h':
// Print help and exit
-   usage ();
-   return 1;
+   usage (stdout);
break;
   case 'm':
{
@@ -921,13 +941,16 @@ character #%d.\n", optarg, (int) (endptr
break;
   case 'v':
// Print version info and exit
-   version ();
-   return 1;
+   print_version ();
+   return 0;
break;
   case 'w':
new_window ^= 1;
break;
   }
+
+  if ( argv[optind] == NULL)
+usage ();
 
   if (!mask)
 mask = 1;



ssp.c patch

2002-06-05 Thread Joshua Daniel Franklin

This patch changes ssp to use getopt instead of just hand-rolled
option handling. There were two issues with doing this:

The -dll option ( -d -l -l to getopt) is now -l. So if someone was using
a script that did ssp -d -dll 0x401000 0x403000 hello.exe it will work
identically, but without the -d option it will behave differently.

The -tc, which getopt interprets as -t -c, is now just -c. The -t option
stayed the same, so the same issues as above apply.

I also included the whole of ssp.txt in the --help output, since that
text file really isn't that long and it doesn't make sense to me that
users need to download the cygwin source to learn to use a util. Hopefully
soon this info can be moved into userland documentation.

I considered submitting separate patches for this but it wouldn't make
sense to do the getopt change without updating the help output, and the
--version part is only a few lines. I could leave the --version part out
but this made more sense to me.

P.S. I also found two variable-name typos in the run_program (char * cmdline)
function and fixed it.

ChangeLog:

2002-06-03  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* ssp.c (version): New global variable.
(longopts): Ditto.
(opts): Ditto.
(run_program): Correct cmd_line typos to cmdline.
(usage): New function. Standardize usage output.
Add ssp.txt to --help output.
(print_version): New function.
(main): Accomodate getopt.



--- ssp.c-orig  Tue Jun  4 20:37:17 2002
+++ ssp.c   Wed Jun  5 11:37:55 2002
@@ -20,53 +20,26 @@
 #include 
 #include 
 #include 
+#include 
 
-#ifdef __GNUC__
-const char *help_text = "\
-Usage: ssp [options] low_pc high_pc command...\n\
-\n\
-The SSP is a `single-step profiler' - it uses the debug API to\n\
-single-step your program, noting *everything* your program runs, not\n\
-just random places hit by random timer interrupts.  You must specify\n\
-the range of EIP values to profile.  For example, you could profile\n\
-just a function, or just a line of code, or the whole thing.\n\
-Use \"objdump -h\" to find the start of .text and the section following\n\
-it; this is what you want.\n\
-\n\
-There are many options to ssp.  Since step-profiling makes your\n\
-program run about 1,000 times slower than normal, it's best to\n\
-understand all the options so that you can narrow down the parts\n\
-of your program you need to single-step.\n\
-\n\
--v = verbose messages about debug events.\n\
-\n\
--d, -e = disable/enable single-stepping by default.  Use\n\
-OutputDebugString (\"ssp on\") to enable stepping, or \"ssp off\" to\n\
-disable it.  Thus, you can profile a single function call or block.\n\
-\n\
--t = trace every EIP value to a file TRACE.SSP.  This gets big *fast*.\n\
-Use \"addr2line -C -f -s -e foo.exe < trace.ssp > lines.ssp\" and then\n\
-\"perl cvttrace\" to convert to symbolic traces.\n\
-\n\
--tc = trace every EIP value to the console.  *Lots* slower.\n\
-\n\
--s = trace sub-threads too.  Dangerous if you have race conditions.\n\
-\n\
--dll = enable dll profiling.  A chart of relative DLL usage is\n\
-produced after the run.\n\
-\n\
-Examples:\n\
-  ssp 0x401000 0x403000 hello.exe\n\
-  ssp -v -d -dll 0x401000 0x44 foo.exe\n\
-\n\
-The output is a file \"gmon.out\" that can be read with gprof:\n\
-  gprof -b foo.exe\n\
-\n\
-See ssp.txt in the cygwin sources for more information.\n\
-";
-#else
-char *help_text = "Usage: get cygwin!\n";
-#endif
+static const char version[] = "$Revision: 1.3 $";
+static char *prog_name;
+
+static struct option longopts[] =
+{
+  {"console-trace", no_argument, NULL, 'c' },
+  {"disable", no_argument, NULL, 'd' },
+  {"enable", no_argument, NULL, 'e' },
+  {"help", no_argument, NULL, 'h' },
+  {"dll", no_argument, NULL, 'l' },
+  {"sub-threads", no_argument, NULL, 's' },
+  {"trace-eip", no_argument, NULL, 't' },
+  {"verbose", no_argument, NULL, 'v' },
+  {"version", no_argument, NULL, 'V' },
+  {NULL, 0, NULL, 0}
+};
+
+static char opts[] = "cdehlstvV";
 
 #define KERNEL_ADDR 0x7700
 
@@ -102,7 +75,6 @@ typedef struct {
 int low_pc=0, high_pc=0;
 unsigned int last_pc=0, pc, last_sp=0, sp;
 int total_cycles, count;
-char *cmd_line;
 HANDLE hProcess;
 PROCESS_INFORMATION procinfo;
 STARTUPINFO startup;
@@ -330,7 +302,7 @@ run_program (char *cmdline)
   memset (&startup, 0, sizeof (startup));
   startup.cb = sizeof (startup);
 
-  if (!CreateProcess (0, cmd_line, 0, 0, 0,
+  if (!CreateProcess (0, cmdline, 0, 0, 0,
 CREATE_NEW_PROCESS_GROUP
 

umount version patch

2002-06-03 Thread Joshua Daniel Franklin

Here is the help/version patch for umount.

ChangeLog:

2002-06-03  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* umount.cc (version): New global variable.
(longopts): Accomodate new --version option.
(opts): Ditto.
(usage): Standardize usage output.
(print_version): New function.
(main): Accomodate --help, --version options.



--- umount.cc-orig  Mon Jun  3 20:16:49 2002
+++ umount.cc   Mon Jun  3 20:17:09 2002
@@ -1,6 +1,6 @@
 /* umount.cc
 
-   Copyright 1996, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1996, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -21,6 +21,7 @@ static void remove_all_user_mounts ();
 static void remove_all_system_mounts ();
 static void remove_cygdrive_prefix (int flags);
 
+static const char version[] = "$Revision: 1.10 $";
 static const char *progname;
 
 struct option longopts[] =
@@ -32,23 +33,27 @@ struct option longopts[] =
   {"remove-user-mounts", no_argument, NULL, 'U'},
   {"system", no_argument, NULL, 's'},
   {"user", no_argument, NULL, 'u'},
+  {"version", no_argument, NULL, 'v'},
   {NULL, 0, NULL, 0}
 };
 
-char opts[] = "hASUsuc";
+char opts[] = "AchsSuUv";
 
 static void
-usage (void)
+usage (FILE *where = stderr)
 {
-  fprintf (stderr, "Usage %s [OPTION] []\n\
+  fprintf (where, "\
+Usage: %s [OPTION] []\n\
   -A, --remove-all-mounts   remove all mounts\n\
   -c, --remove-cygdrive-prefix  remove cygdrive prefix\n\
+  -h, --helpoutput usage information and exit\n\
   -s, --system  remove system mount (default)\n\
   -S, --remove-system-mountsremove all system mounts\n\
   -u, --userremove user mount\n\
   -U, --remove-user-mounts  remove all user mounts\n\
+  -v, --version output version information and exit\n\
 ", progname);
-  exit (1);
+  exit (where == stderr ? 1 : 0);
 }
 
 static void
@@ -58,13 +63,34 @@ error (const char *path)
   exit (1);
 }
 
+static void
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+%s (cygwin) %.*s\n\
+Filesystem Utility\n\
+Copyright 1996, 1998, 1999, 2000, 2001, 2002\n\
+Compiled on %s", progname, len, v, __DATE__);
+}
+
 int
 main (int argc, char **argv)
 {
   int i;
   int flags = 0;
   int default_flag = MOUNT_SYSTEM;
-  progname = argv[0];
   enum do_what
   {
 nada,
@@ -74,6 +100,14 @@ main (int argc, char **argv)
 saw_remove_all_user_mounts
   } do_what = nada;
 
+  progname = strrchr (argv[0], '/');
+  if (progname == NULL)
+progname = strrchr (argv[0], '\\');
+  if (progname == NULL)
+progname = argv[0];
+  else
+progname++;
+
   if (argc == 1)
 usage ();
 
@@ -90,6 +124,8 @@ main (int argc, char **argv)
  usage ();
do_what = saw_remove_cygdrive_prefix;
break;
+  case 'h':
+   usage (stdout);
   case 's':
flags |= MOUNT_SYSTEM;
break;
@@ -107,6 +143,9 @@ main (int argc, char **argv)
  usage ();
do_what = saw_remove_all_user_mounts;
break;
+  case 'v':
+   print_version ();
+   exit (0);
   default:
usage ();
   }



Re: regtool help/version patch

2002-06-03 Thread Joshua Daniel Franklin


--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> On Sun, Jun 02, 2002 at 10:58:33PM -0400, Christopher Faylor wrote:
> >On Sun, Jun 02, 2002 at 09:45:30PM -0500, Joshua Daniel Franklin wrote:
> >>2002-06-02  Joshua Daniel Franklin <[EMAIL PROTECTED]>
> >>
> >>* regtool.cc (prog_name): New global variable.
> >>(longopts): Ditto.
> >>(opts): Ditto.
> >>(usage): Standardize usage output. Rearrange/add descriptions.
> >>(print_version): New function.
> >>(main): Accomodate longopts and new --help, --version options.
> >>Add check for (_argv[optind+1] == NULL).
> >
> >Applied.
> >
> >Thanks, as always.
> 
> Joshua, it just occurred to me that you don't seem to be patching the
> .sgml documentation when you make a change to a utility.
> 
> Do you think you could take a run over the utils.sgml file and see
> if there are missing options that could be added?  Also, if you're
> adding examples to the output then utils.sgml would be a good place
> for that, too.
> 
> cgf

I was going to try to get all the --help/--version patches in for the
next release, then patch utils.sgml at leisure. My logic is that the
binaries are hard to change, but the using-utils.html page and the
cygwin-doc package (which I have full control over) are easy. Also I
may have a lot of questions on certain explanations in utils.sgml
(about, for example, setfacl or strace) that really are not related to
the patches but could slow down the patching if I were working on it at 
the same time.

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



regtool help/version patch

2002-06-02 Thread Joshua Daniel Franklin

Here is the --help, --version patch for regtool. I reorganized the
usage output in a hopefully more logical manner. As Corinna suggested
for some of the other utils, --help produces more verbose output, but
an error usage() still retains useful info. I also added a check for
(_argv[optind+1] == NULL) after the getopt, which was causing a core
dump on 'regtool get' with no KEY.

ChangeLog:

2002-06-02  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* regtool.cc (prog_name): New global variable.
(longopts): Ditto.
(opts): Ditto.
(usage): Standardize usage output. Rearrange/add descriptions.
(print_version): New function.
(main): Accomodate longopts and new --help, --version options.
Add check for (_argv[optind+1] == NULL).



--- regtool.cc-orig Sun Jun  2 18:44:03 2002
+++ regtool.cc  Sun Jun  2 21:32:11 2002
@@ -1,6 +1,6 @@
 /* regtool.cc
 
-   Copyright 2000 Red Hat Inc.
+   Copyright 2000, 2001, 2002 Red Hat Inc.
 
 This file is part of Cygwin.
 
@@ -23,6 +23,27 @@ enum
 #define LIST_VALS  0x02
 #define LIST_ALL   (LIST_KEYS | LIST_VALS)
 
+static const char version[] = "$Revision: 1.8 $";
+static char *prog_name;
+
+static struct option longopts[] =
+{
+  {"expand-string", no_argument, NULL, 'e' },
+  {"help", no_argument, NULL, 'h' },
+  {"integer", no_argument, NULL, 'i' },
+  {"keys", no_argument, NULL, 'k'},
+  {"list", no_argument, NULL, 'l'},
+  {"multi-string", no_argument, NULL, 'm'},
+  {"postfix", no_argument, NULL, 'p'},
+  {"quiet", no_argument, NULL, 'q'},
+  {"string", no_argument, NULL, 's'},
+  {"verbose", no_argument, NULL, 'v'},
+  {"version", no_argument, NULL, 'V'},
+  {NULL, 0, NULL, 0}
+};
+
+static char opts[] = "ehiklmpqsvV";
+
 int listwhat = 0;
 int postfix = 0;
 int verbose = 0;
@@ -32,38 +53,78 @@ char **argv;
 HKEY key;
 char *value;
 
-const char *usage_msg[] = {
-  "Regtool Copyright (c) 2000 Red Hat Inc",
-  " regtool -h  - print this message",
-  " regtool [-v|-p|-k|-l] list [key]  - list subkeys and values",
-  " -p=postfix, like ls -p, appends \\ postfix to key names",
-  " -k=keys, lists only keys",
-  " -l=values, lists only values",
-  " regtool [-v] add [key\\subkey]  - add new subkey",
-  " regtool [-v] remove [key]  - remove key",
-  " regtool [-v|-q] check [key]  - exit 0 if key exists, 1 if not",
-  " regtool [-i|-s|-e|-m] set [key\\value] [data ...]  - set value",
-  " -i=integer -s=string -e=expand-string -m=multi-string",
-  " regtool [-v] unset [key\\value]  - removes value from key",
-  " regtool [-q] get [key\\value]  - prints value to stdout",
-  " -q=quiet, no error msg, just return nonzero exit if key/value missing",
-  " keys are like \\prefix\\key\\key\\key\\value, where prefix is any of:",
-  "   root HKCR  HKEY_CLASSES_ROOT",
-  "   config   HKCC  HKEY_CURRENT_CONFIG",
-  "   user HKCU  HKEY_CURRENT_USER",
-  "   machine  HKLM  HKEY_LOCAL_MACHINE",
-  "   usersHKU   HKEY_USERS",
-  " example: \\user\\software\\Microsoft\\Clock\\iFormat",
-  0
-};
-
-void
-usage (void)
+static void
+usage (FILE *where = stderr)
 {
-  int i;
-  for (i = 0; usage_msg[i]; i++)
-fprintf (stderr, "%s\n", usage_msg[i]);
-  exit (1);
+  fprintf (where, ""
+  "Usage: %s [OPTION] (add | check | get | list | remove | unset) KEY\n"
+  "\n"
+  "", prog_name);
+  if (where == stdout)
+fprintf (where, ""
+"Actions:\n"
+" add KEY\\SUBKEY add new SUBKEY\n"
+" check KEY  exit 0 if KEY exists, 1 if not\n"
+" get KEY\\VALUE  prints VALUE to stdout\n"
+" list KEY   list SUBKEYs and VALUEs\n"
+" remove KEY remove KEY\n"
+" set KEY\\VALUE [data ...]   set VALUE\n"
+" unset KEY\\VALUEremoves VALUE from KEY\n"
+"\n");
+  fprintf (where, ""
+  "Options for 'list' Action:\n"
+  " -k, --keys   print only KEYs\n"
+  " -l, --list   print only VALUEs\n"
+  " -p, --postfixlike ls -p, appends '\\' postfix to KEY names\n"
+  "\n"
+  "Options for 'set' Action:\n"
+  " -e, --expand-string  set type to REG_EXPAND_SZ\n"
+  " -i, --integer   

Re: passwd help/version patch

2002-05-30 Thread Joshua Daniel Franklin

--- Corinna Vinschen <[EMAIL PROTECTED]> wrote:
> > > Or perhaps change passwd to take the Cygwin name and
> > > convert it to the windows name???
> > >
> > > Corinna
> >
> > Maybe I'm missing something, but there doesn't seem to be any Win32
> > function to get a username from a uid other than NetUserEnum, but
> > I really don't think people running 'passwd bob' are wanting to enum
> > all users. The code to do it wouldn't be that hard, but it wouldn't
> > work for those people with domains (unless they specify a domain like
> > for mkpasswd).
> >
> > Maybe mkpasswd should cache the info somewhere other than just /etc/passwd
> > for this purpose? Or use the GECOS field?
>
> I'm sorry if my mail wasn't clear but I just asked for getting the
> Win32 name from the cygwin name.  The cygwin name is the one given
> on the command line or what is returned by getlogin().  The information
> about the Win32 name is then returned in the pw_gecos field by
> getpwnam().  Either a U-DOMAIN\NAME or a S-1-5-xxx sid.  If the
> U- field is given, it contains the name, otherwise a LookupAccountSid()
> gives the Win32 name from the SID.  If neither is given, the Cygwin
> username is equal to the Win32 name.
>
> There is already a function `extract_nt_dom_user()' in Cygwin, file
> security.cc which contains this functionality.  Unfortunately it
> isn't exported so it would have to be copied to passwd.c (and
> transformed to plain c).
>
> Or we export that function.  I think it is a useful functionality for
> Cygwin tools.  Perhaps with the "cygwin_" prefix.
>
> Corinna

Thanks very much for the pointers. However,
After working on it a while, I think that exporting a
cygwin_extract_nt_dom_user() would be best. The attached patch is a
halfway solution that just copies most of extract_nt_dom_user()
other than the SID code. It will get the correct username in the case of
a U-DOMAIN type of GECOS, but if only a ':S-1-5-xxx:' is in the GECOS
it fails with the old 'passwd: unknown user boalhg' message.
If a Win32 username is found, a line like: 'Windows username : bob'
is output.

I tried to build up the structures necessary for LookupAccountSid()
with the sec* stuff in winsup/cygwin as a guide, but it looks like
reinventing a C wheel from C++ spare parts. It'd be a lot better to
be able to just put cygwin_extract_nt_dom_user(pw, domain, (char *) user)
right in passwd.c IMHO.

Caveat: I don't have a real domain that I'm testing with.

2002-05-30  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* passwd.c (extract_nt_dom_user): New function.
(GetPW): Try to look up Win32 username in case of NERR_UserNotFound.


--- passwd.c-orig   Thu May 30 20:05:05 2002
+++ passwd.cThu May 30 20:54:10 2002
@@ -28,6 +28,7 @@ details. */
 #define USER_PRIV_ADMIN 2
 
 #define UF_LOCKOUT0x00010
+#define INTERNET_MAX_HOST_NAME_LENGTH 256
 
 static const char version[] = "$Revision: 1.4 $";
 static char *prog_name;
@@ -101,15 +102,66 @@ EvalRet (int ret, const char *user)
   return 1;
 }
 
+void
+extract_nt_dom_user (const struct passwd *pw, char *domain, char *user)
+{
+  char buf[INTERNET_MAX_HOST_NAME_LENGTH + UNLEN + 2];
+  char *c;
+
+  strcpy (domain, "");
+  strcpy (buf, pw->pw_name);
+
+  if ((pw && pw->pw_gecos) && (strrchr (pw->pw_gecos, ',') == NULL))
+  {
+return;
+  }
+
+  if (pw->pw_gecos)
+{
+  if ((c = strstr (pw->pw_gecos, "U-")) != NULL &&
+  (c == pw->pw_gecos || c[-1] == ','))
+{
+  buf[0] = '\0';
+  strncat (buf, c + 2, INTERNET_MAX_HOST_NAME_LENGTH + UNLEN + 1);
+  if ((c = strchr (buf, ',')) != NULL)
+*c = '\0';
+}
+}
+  if ((c = strchr (buf, '\\')) != NULL)
+{
+  *c++ = '\0';
+  strcpy (domain, buf);
+  strcpy (user, c);
+}
+  else
+{
+  strcpy (domain, "");
+  strcpy (user, buf);
+}
+}
+
 PUSER_INFO_3
 GetPW (const char *user)
 {
   WCHAR name[512];
   DWORD ret;
   PUSER_INFO_3 ui;
-
+  struct passwd *pw;
+  char *domain = (char *) malloc (MAX_PATH + 1);
+
   MultiByteToWideChar (CP_ACP, 0, user, -1, name, 512);
   ret = NetUserGetInfo (NULL, name, 3, (LPBYTE *) &ui);
+  /* Try getting a Win32 username in case the user edited /etc/passwd */
+  if (ret == NERR_UserNotFound)
+  {
+if ((pw = getpwnam (user)))
+  extract_nt_dom_user (pw, domain, (char *) user);
+MultiByteToWideChar (CP_ACP, 0, user, -1, name, 512);
+ret = NetUserGetInfo (NULL, name, 3, (LPBYTE *) &ui);
+if (ret == (int) NULL)
+  printf ("Windows username : %s\n", user);
+  }
+
   return EvalRet (ret, user) ? NULL : ui;
 }
 



Re: passwd help/version patch

2002-05-29 Thread Joshua Daniel Franklin

--- Corinna Vinschen <[EMAIL PROTECTED]> wrote:
> On Tue, May 28, 2002 at 10:56:21PM -0500, Joshua Daniel Franklin wrote:
> > Here is the --help, --version patch for passwd.
> > I used the idea from a recent cygpath patch to separate usage output into
> > sections, though I feel I've improved on it a bit. :)
> > Corinna, you might want to take a look at these longopt names I chose to
> > make sure they're OK:
> 
> Cool.  Applied.
> 
> While playing with it, I'd suddenly missed a short text in the usage,
> that the username has to be the windows username, not the Cygwin
> username.  Passwd has been written before all that ntsec stuff AFAIR,
> so it has no idea that the user "Administrator" might be renamed
> to "root" in /etc/passwd.  Do you think you could add something
> appropriate?  Or perhaps change passwd to take the Cygwin name and
> convert it to the windows name???
> 
> Corinna

Maybe I'm missing something, but there doesn't seem to be any Win32 
function to get a username from a uid other than NetUserEnum, but 
I really don't think people running 'passwd bob' are wanting to enum
all users. The code to do it wouldn't be that hard, but it wouldn't
work for those people with domains (unless they specify a domain like
for mkpasswd).

Maybe mkpasswd should cache the info somewhere other than just /etc/passwd 
for this purpose? Or use the GECOS field?

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



passwd help/version patch

2002-05-28 Thread Joshua Daniel Franklin

Here is the --help, --version patch for passwd.
I used the idea from a recent cygpath patch to separate usage output into
sections, though I feel I've improved on it a bit. :)
Corinna, you might want to take a look at these longopt names I chose to
make sure they're OK:

Usage: passwd (-l|-u|-S) [USER]
   passwd [-i NUM] [-n MINDAYS] [-x MAXDAYS] [-L LEN]

User operations:
 -l, --lock  lock USER's account
 -u, --unlockunlock USER's account
 -S, --statusdisplay password status for USER (locked, expired, etc.)

System operations:
 -i, --inactive  set NUM of days before inactive accounts are disabled
 (inactive accounts are those with expired passwords)
 -n, --minageset system minimum password age to MINDAYS
 -x, --maxageset system maximum password age to MAXDAYS
 -L, --lengthset system minimum password length to LEN


2002-05-28  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* passwd.c (prog_name): New global variable.
(longopts): Ditto.
(opts): Ditto.
(usage): Standardize output. Accomodate new options.
(print_version): New function.
(main): Accomodate longopts and new --help, --version options.



--- passwd.c-orig   Tue May 28 20:29:19 2002
+++ passwd.cTue May 28 21:56:13 2002
@@ -29,7 +29,24 @@ details. */
 
 #define UF_LOCKOUT0x00010
 
-char *myname;
+static const char version[] = "$Revision: 1.4 $";
+static char *prog_name;
+
+static struct option longopts[] =
+{
+  {"help", no_argument, NULL, 'h' },
+  {"inactive", required_argument, NULL, 'i'},
+  {"lock", no_argument, NULL, 'l'},
+  {"minage", required_argument, NULL, 'n'},
+  {"unlock", no_argument, NULL, 'u'},
+  {"version", no_argument, NULL, 'v'},
+  {"maxage", required_argument, NULL, 'x'},
+  {"length", required_argument, NULL, 'L'},
+  {"status", no_argument, NULL, 'S'},
+  {NULL, 0, NULL, 0}
+};
+
+static char opts[] = "L:x:n:i:luShv";
 
 int
 eprint (int with_name, const char *fmt, ...)
@@ -37,7 +54,7 @@ eprint (int with_name, const char *fmt, 
   va_list ap;
 
   if (with_name)
-fprintf(stderr, "%s: ", myname);
+fprintf(stderr, "%s: ", prog_name);
   va_start (ap, fmt);
   vfprintf (stderr, fmt, ap);
   va_end (ap);
@@ -200,14 +217,52 @@ SetModals (int xarg, int narg, int iarg,
   return EvalRet (ret, NULL);
 }
 
-int
-usage ()
+static void
+usage (FILE * stream, int status)
+{
+  fprintf (stream, ""
+  "Usage: %s (-l|-u|-S) [USER]\n"
+  "   %s [-i NUM] [-n MINDAYS] [-x MAXDAYS] [-L LEN]\n"
+  "\n"
+  "User operations:\n"
+  " -l, --lock  lock USER's account\n"
+  " -u, --unlockunlock USER's account\n"
+  " -S, --statusdisplay password status for USER (locked, expired, etc.)\n"
+  "\n"
+  "System operations:\n"
+  " -i, --inactive  set NUM of days before inactive accounts are disabled\n"
+  " (inactive accounts are those with expired passwords)\n"
+  " -n, --minageset system minimum password age to MINDAYS\n"
+  " -x, --maxageset system maximum password age to MAXDAYS\n"
+  " -L, --lengthset system minimum password length to LEN\n"
+  "\n"
+  "Other options:\n"
+  " -h, --help  output usage information and exit\n"
+  " -v, --version   output version information and exit\n"
+  "", prog_name, prog_name);
+  exit (status);
+}
+
+static void
+print_version ()
 {
-  fprintf (stderr, "usage: %s [name]\n", myname);
-  fprintf (stderr, "   %s [-L maxlen] [-x max] [-n min] [-i inact]\n",
-   myname);
-  fprintf (stderr, "   %s {-l|-u|-S} name\n", myname);
-  return 2;
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+%s (cygwin) %.*s\n\
+Password Utility\n\
+Copyright 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
+Compiled on %s", prog_name, len, v, __DATE__);
 }
 
 int
@@ -227,24 +282,33 @@ main (int argc, char **argv)
   int Sopt = 0;
   PUSER_INFO_3 ui, li;
 
- if ((myname = strrchr (argv[0], '/'))
-  || (myname = strrchr (argv[0], '\\')))
-++myname;
+  prog_name = strrchr (argv[0], '/');
+  if (prog_name == NULL)
+prog_name = strrchr (argv[0], '\\');
+  if (prog_name == NULL)
+prog_name = argv[0];
   else
-myname = argv[0];
-  c = strrchr (m

Re: ps help, version patch

2002-05-28 Thread Joshua Daniel Franklin

--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> Good formatting, wrong date == extremely minor problem.
> 
> Applied.
> 
> Thanks.
> 
> cgf

After getting some sleep, I also noticed this line in my usage function:

With options, %s outputs the long format by default\n", prog_name, prog_name);

which should probably read:

With no options, %s outputs the long format by default\n", prog_name,
prog_name);
 ^^

Do I need another patch for this, or can someone just fix YASM (yet another
stupid mistake)?

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



ps help, version patch

2002-05-27 Thread Joshua Daniel Franklin

Here is the --help, --version patch for ps. With, I hope, a proper
ChangeLog.

2002-05-13  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* ps.cc (prog_name): New global variable.
(longopts): Ditto.
(opts): Ditto.
(usage): New function.
(print_version): New function.
(main): Accomodate longopts and new --help, --version options.



--- ps.cc-orig  Mon May 27 21:55:10 2002
+++ ps.cc   Mon May 27 21:58:14 2002
@@ -1,6 +1,6 @@
 /* ps.cc
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -19,6 +19,25 @@ details. */
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.11 $";
+static char *prog_name;
+
+static struct option longopts[] =
+{
+  {"all", no_argument, NULL, 'a' },
+  {"everyone", no_argument, NULL, 'e' },
+  {"full", no_argument, NULL, 'f' },
+  {"help", no_argument, NULL, 'h' },
+  {"long", no_argument, NULL, 'l' },
+  {"summary", no_argument, NULL, 's' },
+  {"user", required_argument, NULL, 'u'},
+  {"version", no_argument, NULL, 'v'},
+  {"windows", no_argument, NULL, 'W'},
+  {NULL, 0, NULL, 0}
+};
+
+static char opts[] = "aefhlsu:vW";
+
 typedef BOOL (WINAPI *ENUMPROCESSMODULES)(
   HANDLE hProcess,  // handle to the process
   HMODULE * lphModule,  // array to receive the module handles
@@ -177,6 +196,46 @@ ttynam (int ntty)
   return buf;
 }
 
+static void
+usage (FILE * stream, int status)
+{
+  fprintf (stream, "\
+Usage: %s [-aefls] [-u UID]\n\
+ -a, --all   show processes of all users\n\
+ -e, --everyone  show processes of all users\n\
+ -f, --full  show process uids, ppids\n\
+ -h, --help  output usage information and exit\n\
+ -l, --long  show process uids, ppids, pgids, winpids\n\
+ -s, --summary   show process summary\n\
+ -u, --user  list processes owned by UID\n\
+ -v, --version   output version information and exit\n\
+ -W, --windows   show windows as well as cygwin processes\n\
+With options, %s outputs the long format by default\n", prog_name, prog_name);
+  exit (status);
+}
+
+static void
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+%s (cygwin) %.*s\n\
+Process Statistics\n\
+Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
+Compiled on %s", prog_name, len, v, __DATE__);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -195,7 +254,15 @@ main (int argc, char *argv[])
   uid = getuid ();
   lflag = 1;
 
-  while ((ch = getopt (argc, argv, "aelfsu:W")) != -1)
+  prog_name = strrchr (argv[0], '/');
+  if (prog_name == NULL)
+prog_name = strrchr (argv[0], '\\');
+  if (prog_name == NULL)
+prog_name = argv[0];
+  else
+prog_name++;
+
+  while ((ch = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
 switch (ch)
   {
   case 'a':
@@ -205,6 +272,8 @@ main (int argc, char *argv[])
   case 'f':
 fflag = 1;
 break;
+  case 'h':
+usage (stdout, 0);
   case 'l':
 lflag = 1;
 break;
@@ -221,25 +290,22 @@ main (int argc, char *argv[])
   uid = pw->pw_uid;
 else
   {
-fprintf (stderr, "user %s unknown\n", optarg);
+fprintf (stderr, "%s: user %s unknown\n", prog_name, optarg);
 exit (1);
   }
   }
 break;
+  case 'v':
+print_version ();
+exit (0);
+break;
   case 'W':
query = CW_GETPINFO_FULL;
aflag = 1;
break;
 
   default:
-fprintf (stderr, "Usage %s [-aefl] [-u uid]\n", argv[0]);
-fprintf (stderr, "-f = show process uids, ppids\n");
-fprintf (stderr, "-l = show process uids, ppids, pgids, winpids\n");
-fprintf (stderr, "-u uid = list processes owned by uid\n");
-fprintf (stderr, "-a, -e = show processes of all users\n");
-   fprintf (stderr, "-s = show process summary\n");
-   fprintf (stderr, "-W = show windows as well as cygwin processes\n");
-exit (1);
+usage (stderr, 1);
   }
 
   if (sflag)



Re: setfacl version patch

2002-05-24 Thread Joshua Daniel Franklin

--- Corinna Vinschen <[EMAIL PROTECTED]> wrote:
> However, I had to correct your above ChangeLog again, as I had already
> with the getfacl patch.  You forgot the empty line between the header
> and the body and there are colons missing after the name of the functions.
> 

I'm very sorry about this. I had a 'template' ChangeLog that I made myself
instead of copying from the real ChangeLog, which was obviously a mistake.
I noticed that my entry for kill.c also has the no-colon problem. I will
correct my file.

__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com



setfacl version patch

2002-05-23 Thread Joshua Daniel Franklin

> I understand your reasoning.  I've applied your latest patch, though
> since I think the --examples isn't straightforward enough.  It's not
> a really good point, it's just an opinion, so...
>
> OTOH, perhaps we should drop that text completely at a later point as
> soon as we have the man page?!?

Yes, I think that might be a good idea. The man page (and the using-utils
web page) will shortly contain all this information. I think it would be
the best place to update documentation instead of --help output. Perhaps
we could get some more examples of it making life easier on the web page,
too. But, for now...

Here is a patch to setfacl that adds longopts for all options,
standardizes the usage output, and adds the GNU standard --version option.
It uses the same method of outputting lots of info. I put the info in
what seems to me a more logical order, with the description of Acl_entries
first and then the options in alphabetical order. You might want to take
a look and make sure I didn't screw anything up in the description.

2002-05-23  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* setfacl.c (usage) Standardize usage output. Change return type to
static void.
(print_version) New function.
(longopts) Added longopts for all options.
(main) Accommodate changes in usage function and new version option.


--- setfacl.c-orig  Thu May 23 12:38:30 2002
+++ setfacl.c   Thu May 23 19:32:39 2002
@@ -37,6 +37,9 @@ details. */
 #define ILLEGAL_MODE ((mode_t)0x)
 #endif
 
+static const char version[] = "$Revision: 1.13 $";
+static char *prog_name;
+
 typedef enum {
   NoAction,
   Set,
@@ -46,8 +49,6 @@ typedef enum {
   SetFromFile
 } action_t;
 
-char *myname;
-
 mode_t getperm (char *in)
 {
   if (isdigit (*in) && !in[1])
@@ -267,118 +268,157 @@ setfacl (action_t action, char *path, ac
   if (action == Set)
 {
   if (acl (path, SETACL, cnt, acls))
-perror (myname);
+perror (prog_name);
   return;
 }
   if ((lcnt = acl (path, GETACL, MAX_ACL_ENTRIES, lacl)) < 0
   || (lcnt = modacl (lacl, lcnt, acls, cnt)) < 0
   || (lcnt = acl (path, SETACL, lcnt, lacl)) < 0)
-perror (myname);
+perror (prog_name);
 }
 
-#define pn(txt)fprintf (fp, txt "\n", myname)
-#define p(txt) fprintf (fp, txt "\n")
-
-int
-usage (int help)
+static void
+usage (FILE * stream)
 {
-  FILE *fp = help ? stdout : stderr;
-
-  pn ("usage: %s [-r] -s acl_entries file...");
-  pn ("   %s [-r] -md acl_entries file...");
-  pn ("   %s [-r] -f acl_file file...");
-  if (!help)
-pn ("Try `%s --help' for more information.");
+  fprintf (stream, ""
+"Usage: %s [-r] (-f ACL_FILE | -s acl_entries) FILE...\n"
+"   %s [-r] ([-d acl_entries] [-m acl_entries]) FILE...\n"
+"\n"
+"Modify file and directory access control lists (ACLs)\n"
+"\n"
+"  -d, --delete delete one or more specified ACL entries\n"
+"  -f, --file   set ACL entries for FILE to ACL entries read\n"
+"   from a ACL_FILE\n"
+"  -m, --modify modify one or more specified ACL entries\n"
+"  -r, --replacereplace mask entry with maximum permissions\n"
+"   needed for the file group class\n"
+"  -s, --substitute substitute specified ACL entries for the\n"
+"   ACL of FILE\n"
+"  -h, --help   output usage information and exit\n"
+"  -v, --versionoutput version information and exit\n"
+"\n"
+"At least one of (-d, -f, -m, -s) must be specified\n"
+"\n"
+"", prog_name, prog_name);
+  if (stream == stdout) 
+  {
+printf(""
+" Acl_entries are one or more comma-separated ACL entries \n"
+" from the following list:\n"
+"\n"
+" u[ser]::perm\n"
+" u[ser]:uid:perm\n"
+" g[roup]::perm\n"
+" g[roup]:gid:perm\n"
+" m[ask]::perm\n"
+" o[ther]::perm\n"
+"\n"
+" Default entries are like the above with the\n"
+" default identifier. For example: \n"
+"\n"
+" d[efault]:u[ser]:uid:perm\n"

mount --version pathc

2002-05-22 Thread Joshua Daniel Franklin

Here is a --version patch for mount.  I also alphabetized longopts,
opts, and the getopt case statement.

ChangeLog:

2002-05-22  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* mount.cc (version) New global variable.
(usage) Standardize usage output. Accomodate new version option.
(print_version) New function.
(longopts) Accomodate new version option.
(opts) Ditto.
(main) Ditto.


--- mount.cc-orig   Wed May 22 22:17:02 2002
+++ mount.ccWed May 22 22:45:16 2002
@@ -1,6 +1,6 @@
 /* mount.cc
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -33,6 +33,7 @@ static int mount_already_exists (const c
 // static short create_missing_dirs = FALSE;
 static short force = FALSE;
 
+static const char version[] = "$Revision: 1.14 $";
 static const char *progname;
 
 static void
@@ -111,46 +112,73 @@ do_mount (const char *dev, const char *w
 
 static struct option longopts[] =
 {
-  {"help", no_argument, NULL, 'h' },
   {"binary", no_argument, NULL, 'b'},
-  {"force", no_argument, NULL, 'f'},
-  {"system", no_argument, NULL, 's'},
-  {"text", no_argument, NULL, 't'},
-  {"user", no_argument, NULL, 'u'},
-  {"executable", no_argument, NULL, 'x'},
-  {"no-executable", no_argument, NULL, 'E'},
   {"change-cygdrive-prefix", no_argument, NULL, 'c'},
   {"cygwin-executable", no_argument, NULL, 'X'},
-  {"show-cygdrive-prefix", no_argument, NULL, 'p'},
+  {"executable", no_argument, NULL, 'x'},
+  {"force", no_argument, NULL, 'f'},
+  {"help", no_argument, NULL, 'h' },
   {"import-old-mounts", no_argument, NULL, 'i'},
   {"mount-commands", no_argument, NULL, 'm'},
+  {"no-executable", no_argument, NULL, 'E'},
+  {"show-cygdrive-prefix", no_argument, NULL, 'p'},
+  {"system", no_argument, NULL, 's'},
+  {"text", no_argument, NULL, 't'},
+  {"user", no_argument, NULL, 'u'},
+  {"version", no_argument, NULL, 'v'},
   {NULL, 0, NULL, 0}
 };
 
-static char opts[] = "hbfstuxXEpicm";
+static char opts[] = "bcfhimpstuvxEX";
 
 static void
-usage (void)
+usage (FILE *where = stderr)
 {
-  fprintf (stderr, "Usage: %s [OPTION] [ ]\n\
+  fprintf (where, "Usage: %s [OPTION] [ ]\n\
   -b, --binary  text files are equivalent to binary files\n\
(newline = \\n)\n\
   -c, --change-cygdrive-prefix  change the cygdrive path prefix to \n\
   -f, --force   force mount, don't warn about missing mount\n\
point directories\n\
+  -h, --helpoutput usage information and exit\n\
   -i, --import-old-mounts   copy old registry mount table mounts into the\n\
 current mount areas\n\
+  -m, --mount-commands  write mount commands to replace user and\n\
+   system mount points and cygdrive prefixes\n\
   -p, --show-cygdrive-prefixshow user and/or system cygdrive path prefix\n\
   -s, --system (default)add system-wide mount point\n\
   -t, --text   (default)text files get \\r\\n line endings\n\
   -u, --useradd user-only mount point\n\
+  -v, --version output version information and exit\n\
   -x, --executable  treat all files under mount point as executables\n\
+  -E, --no-executable   treat all files under mount point as \n\
+   non-executables\n\
   -X, --cygwin-executable   treat all files under mount point as cygwin\n\
executables\n\
-  -m, --mount-commands  write mount commands to replace user and\n\
-   system mount points and cygdrive prefixes\n\
 ", progname);
-  exit (1);
+  exit (where == stderr ? 1 : 0);
+}
+
+static void
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+%s (cygwin) %.*s\n\
+Filesystem Utility\n\
+Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
+Compiled on %s", progname, len, v, __DATE__);
 }
 
 int
@@ -168,7 +196,13 @@ main (int argc, char **argv)
 saw_mount_commands
 

Re: getfacl help/version patch

2002-05-22 Thread Joshua Daniel Franklin

--- Corinna Vinschen <[EMAIL PROTECTED]> wrote:
> On Tue, May 21, 2002 at 05:23:22PM -0500, Joshua Daniel Franklin wrote:
> > > On Mon, May 20, 2002 at 05:33:01PM -0500, Joshua Daniel Franklin wrote:
> > > > Here is a patch to getfacl that adds longopts for all options,
> > > > standardizes the usage output, and adds the GNU standard --version
> option.
> > >
> What I don't get is
> the reasoning for introducing the --examples option.  From my point
> of view that output should still be a part of --help.  
> 
> Corinna

OK, here is a patch that does as you suggested. I don't like all the 
information being part of usage for several reasons:
1. It is not 'standard' behavior. I couldn't find any other GNU or 
   other utilities that gave so much info on 'foo --help' (maybe 'less',
   but it just uses itself to display the help anyway). Some GNU stuff
   has mulitple pages of output but that's because there are so many
   options ('ls'). 
2. The information is pretty obvious from just the output, at least to
   someone who's familiar with UNIX. What I need the --help for is if I
   forget, for example if you get UID numbers with -n or -u. I find it 
   frustrating that to actually get the simple usage info I need I have to
   do 'getfacl --help | head' or 'getfacl --nosuchoption' However, I also
   think that having helpful explanations in the binary could be useful,
   so I came up with --examples
3. The extra information is difficult to process for the autogenerated
   man pages I make. There is a perl function that takes the output and
   creates the "OPTIONS" section. There is no page for getfacl yet, but
   I plan on making one after I finish adding --help,--version to all the
   utils. See 'man strace' to see what I mean. It'd be easier if it was 
   standard usage output. This is of course entirely my own problem that
   doesn't effect anyone else, but I thought it's worth a try to 'fix' it.

Anyway, you should now have working patches that either include the extra
information or not. I am fine and happy with either though of course I prefer
the one without. 

Have a nice day!

Joshua Daniel Franklin

__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

--- getfacl.c-orig  Tue May 21 17:16:56 2002
+++ getfacl.c   Wed May 22 12:36:14 2002
@@ -1,6 +1,6 @@
 /* getfacl.c
 
-   Copyright 2000, 2001 Red Hat Inc.
+   Copyright 2000, 2001, 2002 Red Hat Inc.
 
Written by Corinna Vinschen <[EMAIL PROTECTED]>
 
@@ -20,6 +20,9 @@ details. */
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.13 $";
+static char *prog_name;
+
 char *
 permstr (mode_t perm)
 {
@@ -58,68 +61,84 @@ groupname (gid_t gid)
   return gbuf;
 }
 
-#define pn(txt)fprintf (fp, txt "\n", name)
-#define p(txt) fprintf (fp, txt "\n")
-
-int
-usage (const char *name, int help)
+static void
+usage (FILE * stream)
 {
-  FILE *fp = help ? stdout : stderr;
-
-  pn ("usage: %s [-adn] file...");
-  if (!help)
-pn ("Try `%s --help' for more information.");
-  else
+  fprintf (stream, "Usage: %s [-adn] FILE [FILE2...]\n"
+"Display file and directory access control lists (ACLs).\n"
+"\n"
+"  -a, --all  display the filename, the owner, the group, and\n"
+" the ACL of the file\n"
+"  -d, --dir  display the filename, the owner, the group, and\n"
+" the default ACL of the directory, if it exists\n"
+"  -h, --help output usage information and exit\n"
+"  -n, --noname   display user and group IDs instead of names\n"
+"  -v, --version  output version information and exit\n"
+"\n"
+"When multiple files are specified on the command line, a blank\n"
+"line separates the ACLs for each file.\n", prog_name);
+  if (stream == stdout) 
 {
-  p ("");
-  p ("Display file and directory access control lists (ACLs).");
-  p ("");
-  p ("For each argument that is a regular file, special file or");
-  p ("directory, getfacl displays the owner, the group, and the ACL.");
-  p ("For directories getfacl displays additionally the default ACL.");
-  p ("");
-  p ("With no options specified, getfacl displays the filename, the");
-  p ("owner, the group, and both the ACL and the default ACL, if it");
-  p ("exists.");
-  p ("");
-  p ("

Re: getfacl help/version patch

2002-05-21 Thread Joshua Daniel Franklin

> On Mon, May 20, 2002 at 05:33:01PM -0500, Joshua Daniel Franklin wrote:
> > Here is a patch to getfacl that adds longopts for all options,
> > standardizes the usage output, and adds the GNU standard --version option.
>
> I'm all for it but the patch doesn't apply cleanly against current CVS.
> Could you please send another diff?
>
> Corinna
>
Yes. Here it is.


--- getfacl.c-orig  Tue May 21 17:16:56 2002
+++ getfacl.c   Tue May 21 17:20:53 2002
@@ -1,6 +1,6 @@
 /* getfacl.c
 
-   Copyright 2000, 2001 Red Hat Inc.
+   Copyright 2000, 2001, 2002 Red Hat Inc.
 
Written by Corinna Vinschen <[EMAIL PROTECTED]>
 
@@ -20,6 +20,9 @@ details. */
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.13 $";
+static char *prog_name;
+
 char *
 permstr (mode_t perm)
 {
@@ -58,68 +61,90 @@ groupname (gid_t gid)
   return gbuf;
 }
 
-#define pn(txt)fprintf (fp, txt "\n", name)
-#define p(txt) fprintf (fp, txt "\n")
-
-int
-usage (const char *name, int help)
+static void
+usage (FILE * stream)
 {
-  FILE *fp = help ? stdout : stderr;
+  fprintf (stream, "Usage: %s [-adn] FILE [FILE2...]\n"
+"Display file and directory access control lists (ACLs).\n"
+"\n"
+"  -a, --all  display the filename, the owner, the group, and\n"
+" the ACL of the file\n"
+"  -d, --dir  display the filename, the owner, the group, and\n"
+" the default ACL of the directory, if it exists\n"
+"  -e, --examples output examples and explanation of output and exit\n"
+"  -h, --help output usage information and exit\n"
+"  -n, --noname   display user and group IDs instead of names\n"
+"  -v, --version  output version information and exit\n\n"
+"ACL output for multiple files is separated by a blank line\n\n"
+"Report bugs to <[EMAIL PROTECTED]>.\n"
+"", prog_name);
+}
 
-  pn ("usage: %s [-adn] file...");
-  if (!help)
-pn ("Try `%s --help' for more information.");
-  else
-{
-  p ("");
-  p ("Display file and directory access control lists (ACLs).");
-  p ("");
-  p ("For each argument that is a regular file, special file or");
-  p ("directory, getfacl displays the owner, the group, and the ACL.");
-  p ("For directories getfacl displays additionally the default ACL.");
-  p ("");
-  p ("With no options specified, getfacl displays the filename, the");
-  p ("owner, the group, and both the ACL and the default ACL, if it");
-  p ("exists.");
-  p ("");
-  p ("The following options are supported:");
-  p ("");
-  p ("-a   Display the filename, the owner, the group, and the ACL");
-  p (" of the file.");
-  p ("");
-  p ("-d   Display the filename, the owner, the group, and the default");
-  p (" ACL of the directory, if it exists.");
-  p ("");
-  p ("-n   Display user and group IDs instead of names.");
-  p ("");
-  p ("The format for ACL output is as follows:");
-  p (" # file: filename");
-  p (" # owner: name or uid");
-  p (" # group: name or uid");
-  p (" user::perm");
-  p (" user:name or uid:perm");
-  p (" group::perm");
-  p (" group:name or gid:perm");
-  p (" mask:perm");
-  p (" other:perm");
-  p (" default:user::perm");
-  p (" default:user:name or uid:perm");
-  p (" default:group::perm");
-  p (" default:group:name or gid:perm");
-  p (" default:mask:perm");
-  p (" default:other:perm");
-  p ("");
-  p ("When multiple files are specified on the command line, a blank");
-  p ("line separates the ACLs for each file.");
-}
-  return 1;
+static void
+print_examples ()
+{
+  printf ("\n"
+  "For each argument that is a regular file, special file or\n"
+  "directory, getfacl displays the owner, the group, and the ACL.\n"
+  "For directories getfacl displays additionally the default ACL.\n"
+  "\n"
+  "With no options specif

getfacl help/version patch

2002-05-20 Thread Joshua Daniel Franklin

Here is a patch to getfacl that adds longopts for all options,
standardizes the usage output, and adds the GNU standard --version option.

2002-05-07  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* getfacl.c (usage) Standardize usage output. Change return type to
static void. Remove examples of output.
(print_examples) New function.
(print_version) New function.
(longopts) Added longopts for all options.
(main) Accommodate new help and version options.


--- getfacl.c-orig  Sun Feb 24 13:28:27 2002
+++ getfacl.c   Mon May 20 17:24:48 2002
@@ -1,6 +1,6 @@
 /* getfacl.c
 
-   Copyright 2000, 2001 Red Hat Inc.
+   Copyright 2000, 2001, 2002 Red Hat Inc.
 
Written by Corinna Vinschen <[EMAIL PROTECTED]>
 
@@ -20,6 +20,9 @@ details. */
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.13 $";
+static char *prog_name;
+
 char *
 permstr (mode_t perm)
 {
@@ -58,68 +61,90 @@ groupname (gid_t gid)
   return gbuf;
 }
 
-#define pn(txt)fprintf (fp, txt "\n", name)
-#define p(txt) fprintf (fp, txt "\n")
-
-int
-usage (const char *name, int help)
+static void
+usage (FILE * stream)
 {
-  FILE *fp = help ? stdout : stderr;
+  fprintf (stream, "Usage: %s [-adn] FILE [FILE2...]\n"
+"Display file and directory access control lists (ACLs).\n"
+"\n"
+"  -a, --all  display the filename, the owner, the group, and\n"
+" the ACL of the file\n"
+"  -d, --dir  display the filename, the owner, the group, and\n"
+" the default ACL of the directory, if it exists\n"
+"  -e, --examples output examples and explanation of output and exit\n"
+"  -h, --help output usage information and exit\n"
+"  -n, --noname   display user and group IDs instead of names\n"
+"  -v, --version  output version information and exit\n\n"
+"ACL output for multiple files is separated by a blank line\n\n"
+"Report bugs to <[EMAIL PROTECTED]>.\n"
+"", prog_name);
+}
 
-  pn ("usage: %s [-adn] file...");
-  if (!help)
-pn ("Try `%s --help' for more information.");
-  else
-{
-  p ("");
-  p ("Display file and directory access control lists (ACLs).");
-  p ("");
-  p ("For each argument that is a regular file, special file or");
-  p ("directory, getfacl displays the owner, the group, and the ACL.");
-  p ("For directories getfacl displays additionally the default ACL.");
-  p ("");
-  p ("With no options specified, getfacl displays the filename, the");
-  p ("owner, the group, and both the ACL and the default ACL, if it");
-  p ("exists.");
-  p ("");
-  p ("The following options are supported:");
-  p ("");
-  p ("-a   Display the filename, the owner, the group, and the ACL");
-  p (" of the file.");
-  p ("");
-  p ("-d   Display the filename, the owner, the group, and the default");
-  p (" ACL of the directory, if it exists.");
-  p ("");
-  p ("-n   Display user and group IDs instead of names.");
-  p ("");
-  p ("The format for ACL output is as follows:");
-  p (" # file: filename");
-  p (" # owner: name or uid");
-  p (" # group: name or uid");
-  p (" user::perm");
-  p (" user:name or uid:perm");
-  p (" group::perm");
-  p (" group:name or gid:perm");
-  p (" mask:perm");
-  p (" other:perm");
-  p (" default:user::perm");
-  p (" default:user:name or uid:perm");
-  p (" default:group::perm");
-  p (" default:group:name or gid:perm");
-  p (" default:mask:perm");
-  p (" default:other:perm");
-  p ("");
-  p ("When multiple files are specified on the command line, a blank");
-  p ("line separates the ACLs for each file.");
-}
-  return 1;
+static void
+print_examples ()
+{
+  printf ("\n"
+  "For each argument that is a regular file, special file or\n"
+  "directory, getfacl displays the owner, the group, and the ACL.\n"
+  "For directories getfacl displays additionally 

kill.cc version patch

2002-05-13 Thread Joshua Daniel Franklin

Here is a version option patch against Chris' new kill.cc with
signal listing. It also adds a prog_name variable as a small way
of helping prevent /bin/kill vs bash's kill confusion.

ChangeLog:

2002-05-13  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* kill.cc (prog_name) New global variable.
(usage) Standardize usage output. Add descriptions.
(print_version) New function.
(longopts) Accomodate new version option.
(opts) Ditto.
(main) Ditto.


--- kill.cc-origMon May 13 17:47:17 2002
+++ kill.cc Mon May 13 18:23:03 2002
@@ -1,6 +1,6 @@
 /* kill.cc
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -18,27 +18,60 @@ details. */
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.14 $";
+static char *prog_name;
+
 static struct option longopts[] =
 {
   {"help", no_argument, NULL, 'h' },
   {"list", optional_argument, NULL, 'l'},
   {"force", no_argument, NULL, 'f'},
   {"signal", required_argument, NULL, 's'},
+  {"version", no_argument, NULL, 'v'},
   {NULL, 0, NULL, 0}
 };
 
-static char opts[] = "hl::fs:";
+static char opts[] = "hl::fs:v";
 
 extern "C" const char *strsigno (int);
 
 static void
 usage (FILE *where = stderr)
 {
-  fputs ("usage: kill [-signal] [-s signal] pid1 [pid2 ...]\n"
-"   kill -l [signal]\n", where);
+  fprintf (where , ""
+   "Usage: %s [-f] [-signal] [-s signal] pid1 [pid2 ...]\n"
+   "   %s -l [signal]\n"
+   " -f, --force force, using win32 interface if necessary\n"
+   " -l, --list  print a list of signal names\n"
+   " -s, --signalsend signal (use %s --list for a list)\n"
+   " -h, --help  output usage information and exit\n"
+   " -v, --version   output version information and exit\n"
+   "", prog_name, prog_name, prog_name);
   exit (where == stderr ? 1 : 0);
 }
 
+static void
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+%s (cygwin) %.*s\n\
+Process Signaller\n\
+Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
+Compiled on %s", prog_name, len, v, __DATE__);
+}
+
 static int
 getsig (const char *in_sig)
 {
@@ -65,7 +98,7 @@ test_for_unknown_sig (int sig, const cha
 {
   if (sig < 0 || sig > NSIG)
 {
-  fprintf (stderr, "kill: unknown signal: %s\n", sigstr);
+  fprintf (stderr, "%s: unknown signal: %s\n", prog_name, sigstr);
   usage ();
   exit (1);
 }
@@ -111,6 +144,14 @@ main (int argc, char **argv)
   char *gotsig = NULL;
   int ret = 0;
 
+  prog_name = strrchr (argv[0], '/');
+  if (prog_name == NULL)
+prog_name = strrchr (argv[0], '\\');
+  if (prog_name == NULL)
+prog_name = argv[0];
+  else
+prog_name++;
+
   if (argc == 1)
 usage ();
 
@@ -147,6 +188,9 @@ main (int argc, char **argv)
case 'h':
  usage (stdout);
  break;
+   case 'v':
+ print_version ();
+ break;
case '?':
  if (gotsig)
usage ();
@@ -170,7 +214,7 @@ main (int argc, char **argv)
   int pid = strtol (*argv, &p, 10);
   if (*p != '\0')
{
- fprintf (stderr, "kill: illegal pid: %s\n", *argv);
+ fprintf (stderr, "%s: illegal pid: %s\n", prog_name, *argv);
  ret = 1;
}
   else if (kill (pid, sig) == 0)
@@ -183,7 +227,7 @@ main (int argc, char **argv)
   else
{
  char buf[1000];
- sprintf (buf, "kill %d", pid);
+ sprintf (buf, "%s %d", prog_name, pid);
  perror (buf);
  ret = 1;
}



Re: long-option kill patch

2002-05-13 Thread Joshua Daniel Franklin


--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> On Sun, May 12, 2002 at 08:30:09PM -0700, Joshua Daniel Franklin wrote:
> >Is there something wrong with the patch for kill.cc?
> >It's a very simple patch:
> >
> >http://www.cygwin.com/ml/cygwin-patches/2002-q2/msg00146.html
> >
> >I'd be happy to fix it if there is something wrong, but I'm
> >not psycic about what...
> 
> As I'd previously indicated, I preferred if the option processing was
> done via getopt.  I just checked in a patch to do that.  I also
> implemented the -l and -s options.
> 
> Sorry for not providing feedback, I'd had a partial implementation
> sitting in my sandbox and I just polished it off tonight.
> 

I'm impressed. After I saw the util-linux version of kill didn't use
getopt I gave up on it. Obviously, I'll stick with being an admin...

__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com



Re: long-option kill patch

2002-05-12 Thread Joshua Daniel Franklin

Is there something wrong with the patch for kill.cc?
It's a very simple patch:

http://www.cygwin.com/ml/cygwin-patches/2002-q2/msg00146.html

I'd be happy to fix it if there is something wrong, but I'm
not psycic about what...

__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com



Re: Patch for mkpasswd

2002-04-29 Thread Joshua Daniel Franklin

--- Corinna Vinschen <[EMAIL PROTECTED]> wrote:
> On Sat, Apr 27, 2002 at 12:10:03PM -0500, Joshua Daniel Franklin wrote:
> Applied.  Additionally I've changed all exit() calls in main() to return
> statements.

Thanks, I will use this from now on.
 
> However, did you have a look into your ChangeLog entry?  Its format
> is somewhat disappointing... and it's interesting that you've hold back
> your changes more than a year now ;-)

Yes, the odd dates--not only my year was wrong, but this is April!
Sorry about the tabs, I cut-and-pasted from a file and didn't re-edit.


__
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com



Patch for mkpasswd

2002-04-27 Thread Joshua Daniel Franklin

Here is a patch for mkpasswd. It brings mkpasswd up to date with the
changes already made to mkgroup.

Changelog:

2001-03-19  Joshua Daniel Franklin  [EMAIL PROTECTED]
* mkpasswd.c (usage): Simplify usage output.  Generalize to allow use
for help. Correct '?' typo to 'h'.
(longopts): Add version option.
(opts): Add 'v' version option.
(print_version): New function.
(main): Accommodate new version option.  Accommodate usage parameter
changes. 



mkpasswd.c-patch
Description: Binary data


Re: stackdump.sgml new file

2002-04-03 Thread Joshua Daniel Franklin

> 2) The patch is included is an html attachment.
> 
> Obviously 1) is a no-op but we really need just a straight patch in
> regular text.
> 
Well, I'm not sure this is what you mean, here is the straight text of the
file.
Seems kinda silly for one this short. I put it in stackdump.sgml in
/src/winsup/cygwin/:


cygwin_stackdump


extern "C" void
cygwin_stackdump



 Produce a stackdump from the called location





__
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/



stackdump.sgml new file

2002-04-03 Thread Joshua Daniel Franklin

I was thinking about writing some updated documentation as requested
lately on the mailing list
(http://www.cygwin.com/ml/cygwin/2002-03/msg01633.html)
I've started by writing a new file to document the existance of the 
cygwin_stackdump() function. ChangeLog:

2001-04-03  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* stackdump.sgml: New file. Document cygwin_stackdump() function.

The function is described as "Temporary?" when first mentioned in the
ChangeLog, but since it appears to have been around since the first
net-release:
http://www.cygwin.com/ml/cygwin-announce/2000/msg0.html
I thought it's probably permanent enough to have its own sgml file.

I'm not abandoning my quest to add --help and --version options to all
the utils, but I've got two patches out right now and would like to wait on 
these to keep it all managable in my thought. For reference, the patches are
for mkpasswd (similar to the applied mkgroup patch):
http://cygwin.com/ml/cygwin-patches/2002-q1/msg00352.html

and for kill.cc:
http://cygwin.com/ml/cygwin-patches/2002-q1/msg00339.html

__
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/
Title: cygwin_stackdump
--- stackdump.sgml-orig	Wed Apr  3 21:36:00 2002
+++ stackdump.sgml	Wed Apr  3 20:57:07 2002
@@ -0,0 +1,14 @@
+
+
+
+
+
+extern "C" void
+cygwin_stackdump
+
+
+
+ Produce a stackdump from the called location
+
+
+


mkpasswd patch

2002-03-19 Thread Joshua Daniel Franklin

Here is a patch for mkpasswd that is very similar to the one for 
mkgroup just checked in. It uses string concatenation similar to the current
CVS of mkgroup, maintaining spacing. 

Also, do I need to resubmit the kill.cc long-options patch from:

http://cygwin.com/ml/cygwin-patches/2002-q1/msg00339.html

I forgot the attachment the first time and never heard anything more...
Thanks.

Changelog:

2001-03-19  Joshua Daniel Franklin  <[EMAIL PROTECTED]>
* mkpasswd.c (usage): Simplify usage output.  Generalize to allow use
for help. Correct '?' typo to 'h'.
(longopts): Add version option.
(opts): Add 'v' version option.
(print_version): New function.
(main): Accommodate new version option.  Accommodate usage parameter
changes. 

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

--- mkpasswd.c-orig Sun Feb 24 13:28:27 2002
+++ mkpasswd.c  Tue Mar 19 19:21:32 2002
@@ -1,6 +1,6 @@
 /* mkpasswd.c:
 
-   Copyright 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
This file is part of Cygwin.
 
@@ -21,6 +21,8 @@
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.20 $";
+
 SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
 SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
 
@@ -393,26 +395,27 @@ print_special (int print_sids,
 }
 
 int
-usage ()
+usage (FILE * stream, int status)
 {
-  fprintf (stderr, "Usage: mkpasswd [OPTION]... [domain]\n\n");
-  fprintf (stderr, "This program prints a /etc/passwd file to stdout\n\n");
-  fprintf (stderr, "Options:\n");
-  fprintf (stderr, "   -l,--local  print local user accounts\n");
-  fprintf (stderr, "   -d,--domain print domain accounts (from current 
domain\n");
-  fprintf (stderr, "   if no domain specified)\n");
-  fprintf (stderr, "   -o,--id-offset offset   change the default offset (1) 
added to uids\n");
-  fprintf (stderr, "   in domain accounts.\n");
-  fprintf (stderr, "   -g,--local-groups   print local group information too\n");
-  fprintf (stderr, "   if no domain specified\n");
-  fprintf (stderr, "   -m,--no-mount   don't use mount points for home 
dir\n");
-  fprintf (stderr, "   -s,--no-sidsdon't print SIDs in GCOS field\n");
-  fprintf (stderr, "   (this affects ntsec)\n");
-  fprintf (stderr, "   -p,--path-to-home path  use specified path instead of user 
account home dir\n");
-  fprintf (stderr, "   -u,--username username  only return information for the 
specified user\n");
-  fprintf (stderr, "   -?,--help   displays this message\n\n");
-  fprintf (stderr, "One of `-l', `-d' or `-g' must be given on NT/W2K.\n");
-  return 1;
+  fprintf (stream, "Usage: mkpasswd [OPTION]... [domain]\n\n"
+   "This program prints a /etc/passwd file to stdout\n\n"
+   "Options:\n"
+   "   -l,--local  print local user accounts\n"
+   "   -d,--domain print domain accounts (from current 
+domain\n"
+   "   if no domain specified)\n"
+   "   -o,--id-offset offset   change the default offset (1) 
+added to uids\n"
+   "   in domain accounts.\n"
+   "   -g,--local-groups   print local group information too\n"
+   "   if no domain specified\n"
+   "   -m,--no-mount   don't use mount points for home dir\n"
+   "   -s,--no-sidsdon't print SIDs in GCOS field\n"
+   "   (this affects ntsec)\n"
+   "   -p,--path-to-home path  use specified path instead of user 
+account home dir\n"
+   "   -u,--username username  only return information for the 
+specified user\n"
+   "   -h,--help   displays this message\n"
+   "   -v,--versionversion information and exit\n\n"
+   "One of `-l', `-d' or `-g' must be given on NT/W2K.\n");
+  return status;
 }
 
 struct option longopts[] = {
@@ -425,10 +428,33 @@ struct option longopts[] = {
   {"path-to-home", required_argument, NULL, 'p'

new mkgroup patch

2002-03-16 Thread Joshua Daniel Franklin

Here is a new patch that retains the multiple fprintf's instead of 
using a multiline one in the usage function. Also adds version option, etc.:

2002-03-16  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* mkgroup.c (usage): Simplify usage output.  Generalize to allow use
for help. Correct '?' typo to 'h'.
(longopts): Add version option.
(opts): Add 'v' version option.
(print_version): New function.
(main): Accommodate new version option.  Accommodate usage parameter
changes.  Use usage to output help message.


__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

--- mkgroup.c-orig  Sat Mar 16 23:31:49 2002
+++ mkgroup.c   Sat Mar 16 23:36:19 2002
@@ -1,6 +1,6 @@
 /* mkgroup.c:
 
-   Copyright 1997, 1998 Cygnus Solutions.
+   Copyright 1997, 1998, 2002 Cygnus Solutions.
 
This file is part of Cygwin.
 
@@ -20,6 +20,8 @@
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.10 $";
+
 SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
 SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
 
@@ -402,23 +404,24 @@ print_special (int print_sids,
 }
 
 int
-usage ()
+usage (FILE * stream, int status)
 {
-  fprintf (stderr, "Usage: mkgroup [OPTION]... [domain]\n\n");
-  fprintf (stderr, "This program prints a /etc/group file to stdout\n\n");
-  fprintf (stderr, "Options:\n");
-  fprintf (stderr, "   -l,--local print local group information\n");
-  fprintf (stderr, "   -d,--domainprint global group information from the 
domain\n");
-  fprintf (stderr, "  specified (or from the current domain 
if there is\n");
-  fprintf (stderr, "  no domain specified)\n");
-  fprintf (stderr, "   -o,--id-offset offset  change the default offset (1) added 
to uids\n");
-  fprintf (stderr, "  in domain accounts.\n");
-  fprintf (stderr, "   -s,--no-sids   don't print SIDs in pwd field\n");
-  fprintf (stderr, "  (this affects ntsec)\n");
-  fprintf (stderr, "   -u,--users print user list in gr_mem field\n");
-  fprintf (stderr, "   -?,--help  print this message\n\n");
-  fprintf (stderr, "One of `-l' or `-d' must be given on NT/W2K.\n");
-  return 1;
+  fprintf (stream, "Usage: mkgroup [OPTION]... [domain]\n\n");
+  fprintf (stream, "This program prints a /etc/group file to stdout\n\n");
+  fprintf (stream, "Options:\n");
+  fprintf (stream, "   -l,--local print local group information\n");
+  fprintf (stream, "   -d,--domainprint global group information from the 
+domain\n");
+  fprintf (stream, "  specified (or from the current domain 
+if there is\n");
+  fprintf (stream, "  no domain specified)\n");
+  fprintf (stream, "   -o,--id-offset offset  change the default offset (1) added 
+to uids\n");
+  fprintf (stream, "  in domain accounts.\n");
+  fprintf (stream, "   -s,--no-sids   don't print SIDs in pwd field\n");
+  fprintf (stream, "  (this affects ntsec)\n");
+  fprintf (stream, "   -u,--users print user list in gr_mem field\n");
+  fprintf (stream, "   -h,--help  print this message\n\n");
+  fprintf (stream, "   -v,--version   print version information and 
+exit\n\n");
+  fprintf (stream, "One of `-l' or `-d' must be given on NT/W2K.\n");
+  return status;
 }
 
 struct option longopts[] = {
@@ -428,10 +431,32 @@ struct option longopts[] = {
   {"no-sids", no_argument, NULL, 's'},
   {"users", no_argument, NULL, 'u'},
   {"help", no_argument, NULL, 'h'},
+  {"version", no_argument, NULL, 'v'},
   {0, no_argument, NULL, 0}
 };
 
-char opts[] = "ldo:suh";
+char opts[] = "ldo:suhv";
+
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+mkgroup (cygwin) %.*s\n\
+group File Generator\n\
+Copyright 1997, 1998, 2002 Red Hat, Inc.\n\
+Compiled on %s", len, v, __DATE__);
+}
 
 int
 main (int argc, char **argv)
@@ -461,7 +486,7 @@ main (int argc, char **argv)
   if (GetVersion () < 0x8000)
 {
   if (argc == 1)
-   return usage ();
+   ret

Re: mkgroup usage/version patch

2002-03-14 Thread Joshua Daniel Franklin

--- Corinna Vinschen <[EMAIL PROTECTED]> wrote:
> While I'm going with the decision to add a version information
> I don't understand why you changed 
> 
> - the usage output method.  I don't like to have a big multiline format
>   string in fprintf.
Well, I could just as easily changed all the lines to 
fprintf(stream, "...
I just used :s/foo/bar/12 anyway. I did it with the multiline since 
1. That's how cygcheck, cygpath, etc. do it now
2. I find it easier to read, personally. (It looks a lot like the 
   CLI output that way)
 
> - the function usage() to exit instead of returning the exitcode.
Again, no reason. That's just the way some of the other utils work.
I was going for consitency in all the code in /winsup/utils

Looking at the patch on the website at
http://cygwin.com/ml/cygwin-patches/2002-q1/msg00342.html
I'm seeing something else weird:
+   print_version ();
+exit (0);
^
What's this extra space? That's not in my code. Do other people see it
in their attachments, or is it just in the HTML? I already deleted the
message from myself.

__
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/



mkgroup usage/version patch

2002-03-13 Thread Joshua Daniel Franklin

This patch generalizes the usage function to allow output to stdout in
addition to stderr, and fixes an apparent typo where the help option
is listed as -?,--help, while in reality the code supports -h,--help.
It also adds a -v,--version option with Chris' print_version function.

2002-03-13  Joshua Daniel Franklin <[EMAIL PROTECTED]>

* mkgroup.c (usage): Simplify usage output.  Generalize to allow use
for help. Correct '?' typo to 'h'.
(longopts): Add version option.
(opts): Add 'v' version option.
(print_version): New function.
(main): Accommodate new version option.  Accommodate usage parameter
changes.  Use usage to output help message.

__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--- mkgroup.c-orig  Sun Feb 24 13:28:27 2002
+++ mkgroup.c   Wed Mar 13 15:17:49 2002
@@ -18,6 +18,8 @@
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.9 $";
+
 SID_IDENTIFIER_AUTHORITY sid_world_auth = {SECURITY_WORLD_SID_AUTHORITY};
 SID_IDENTIFIER_AUTHORITY sid_nt_auth = {SECURITY_NT_AUTHORITY};
 
@@ -399,24 +401,27 @@ print_special (int print_sids,
 }
 }
 
-int
-usage ()
+static void
+usage (FILE *stream, int status)
 {
-  fprintf (stderr, "Usage: mkgroup [OPTION]... [domain]\n\n");
-  fprintf (stderr, "This program prints a /etc/group file to stdout\n\n");
-  fprintf (stderr, "Options:\n");
-  fprintf (stderr, "   -l,--local print local group information\n");
-  fprintf (stderr, "   -d,--domainprint global group information from the 
domain\n");
-  fprintf (stderr, "  specified (or from the current domain 
if there is\n");
-  fprintf (stderr, "  no domain specified)\n");
-  fprintf (stderr, "   -o,--id-offset offset  change the default offset (1) added 
to uids\n");
-  fprintf (stderr, "  in domain accounts.\n");
-  fprintf (stderr, "   -s,--no-sids   don't print SIDs in pwd field\n");
-  fprintf (stderr, "  (this affects ntsec)\n");
-  fprintf (stderr, "   -u,--users print user list in gr_mem field\n");
-  fprintf (stderr, "   -?,--help  print this message\n\n");
-  fprintf (stderr, "One of `-l' or `-d' must be given on NT/W2K.\n");
-  return 1;
+fprintf(stream, "\
+Usage: mkgroup [OPTION]... [domain]\n\n\
+Print a /etc/group file to stdout\n\
+Options:\n\
+   -l,--local print local group information\n\
+   -d,--domainprint global group information from the domain\n\
+  specified (or from the current domain if there is\n\
+  no domain specified)\n\
+   -o,--id-offset offset  change the default offset (1) added to uids\n\
+  in domain accounts.\n\
+   -s,--no-sids   don't print SIDs in pwd field\n\
+  (this affects ntsec)\n\
+   -u,--users print user list in gr_mem field\n\
+   -h,--help  print this message\n\
+   -v,--version   output version information and exit\n\
+One of `-l' or `-d' must be given on NT/W2K.\n\
+");
+  exit (status);
 }
 
 struct option longopts[] = {
@@ -426,10 +431,32 @@ struct option longopts[] = {
   {"no-sids", no_argument, NULL, 's'},
   {"users", no_argument, NULL, 'u'},
   {"help", no_argument, NULL, 'h'},
+  {"version", no_argument, NULL, 'v'},
   {0, no_argument, NULL, 0}
 };
 
-char opts[] = "ldo:suh";
+char opts[] = "ldo:suhv";
+
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+mkgroup (cygwin) %.*s\n\
+group File Generator\n\
+Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
+Compiled on %s", len, v, __DATE__);
+}
 
 int
 main (int argc, char **argv)
@@ -453,7 +480,7 @@ main (int argc, char **argv)
   if (GetVersion () < 0x8000)
 {
   if (argc == 1)
-   return usage ();
+   usage (stderr, 1);
   else
{
  while ((i = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
@@ -475,7 +502,10 @@ main (int argc, char **argv)
print_users = 1;
break;
  case 'h':
-   return usage ();
+   usage (stdout, 0);
+ case 'v':
+   print_version ();
+exit (0);
  default:
fprintf (stderr, "Try `%s --help' for more information.\n", argv[0]);
return 1;



long-option patch for kill.cc

2002-03-11 Thread Joshua Daniel Franklin

Um. And here's the patch.


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--- kill.cc-origMon Mar 11 19:48:34 2002
+++ kill.cc Mon Mar 11 19:55:19 2002
@@ -1,6 +1,6 @@
 /* kill.cc
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -61,26 +61,50 @@ main (int argc, char **argv)
   int force = 0;
   int gotsig = 0;
   int ret = 0;
+  int opt = 0;
+  char *longopt;
 
   if (argc == 1)
 usage ();
 
   while (*++argv && **argv == '-')
-if (strcmp (*argv + 1, "f") == 0)
-  force = 1;
-else if (gotsig)
-  break;
-else if (strcmp(*argv + 1, "0") != 0)
-  {
-   sig = getsig (*argv + 1);
-   gotsig = 1;
-  }
-else
-  {
-   argv++;
-   sig = 0;
-   goto sig0;
-  }
+{
+  opt = *(*argv + 1);
+  if (!gotsig)
+switch (opt)
+  {
+  case 'f':
+force = 1;
+break;
+
+  case '0':
+argv++;
+sig = 0;
+goto sig0;
+return ret;
+
+  /* Handle long options */
+  case '-':
+longopt = *argv + 2;
+if (strcmp (longopt, "force") == 0)
+  force = 1;
+else
+  {
+fprintf (stderr, "kill: unknown long option: --%s\n\n",
+ longopt);
+usage ();
+  }
+*argv += strlen (longopt);
+break;
+  /* End of long options */
+
+  default:
+sig = getsig (*argv + 1);
+gotsig = 1;
+  }
+  else
+break;
+}
 
   if (sig <= 0 || sig > NSIG)
 {



long-option patch for kill.cc

2002-03-11 Thread Joshua Daniel Franklin

I apologize for my hasty Changelog.

I was suprised to find in the util-linux sources included with RH7.2
that kill.c is actually BSD-licenced. So any fears were unfounded. However,
the signals (for -l, --list) are indeed hard-coded, and options are handled
in the same basic way as this patch (not getopt), so I didn't really find what 
I was looking for.

This patch changes the option-handling in kill to use a switch instead
of if/else if/else clauses. It also enables basic long-option handling.

2001-03-11 Joshua Daniel Franklin <[EMAIL PROTECTED]>
* kill.cc (main): Handle options in a switch. Add long-option for --force.



__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/



(small) kill.cc patch

2002-03-11 Thread Joshua Daniel Franklin

Here is a patch that moves the functions in kill.cc to the top.
That's all it does.

This is for consistency with the other utils.

2001-03-11 Joshua Daniel Franklin <[EMAIL PROTECTED]>
* kill.cc (usage) move to top of file
  (getsig) ditto
  (forcekill) ditto


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--- kill.cc-origSun Feb 24 13:28:27 2002
+++ kill.cc Mon Mar 11 12:07:40 2002
@@ -17,9 +17,42 @@ details. */
 #include 
 #include 
 
-static void usage (void);
-static int __stdcall getsig (char *);
-static void __stdcall forcekill (int, int, int);
+static void
+usage (void)
+{
+  fprintf (stderr, "Usage: kill [-sigN] pid1 [pid2 ...]\n");
+  exit (1);
+}
+
+static int
+getsig (char *in_sig)
+{
+  char *sig;
+  char buf[80];
+
+  if (strncmp (in_sig, "SIG", 3) == 0)
+sig = in_sig;
+  else
+{
+  sprintf (buf, "SIG%s", in_sig);
+  sig = buf;
+}
+  return (strtosigno (sig) ?: atoi (in_sig));
+}
+
+static void __stdcall
+forcekill (int pid, int sig, int wait)
+{
+  external_pinfo *p = (external_pinfo *) cygwin_internal (CW_GETPINFO_FULL, pid);
+  if (!p)
+return;
+  HANDLE h = OpenProcess (PROCESS_TERMINATE, FALSE, (DWORD) p->dwProcessId);
+  if (!h)
+return;
+  if (!wait || WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
+TerminateProcess (h, sig << 8);
+  CloseHandle (h);
+}
 
 int
 main (int argc, char **argv)
@@ -82,41 +115,4 @@ sig0:
   argv++;
 }
   return ret;
-}
-
-static void
-usage (void)
-{
-  fprintf (stderr, "Usage: kill [-sigN] pid1 [pid2 ...]\n");
-  exit (1);
-}
-
-static int
-getsig (char *in_sig)
-{
-  char *sig;
-  char buf[80];
-
-  if (strncmp (in_sig, "SIG", 3) == 0)
-sig = in_sig;
-  else
-{
-  sprintf (buf, "SIG%s", in_sig);
-  sig = buf;
-}
-  return (strtosigno (sig) ?: atoi (in_sig));
-}
-
-static void __stdcall
-forcekill (int pid, int sig, int wait)
-{
-  external_pinfo *p = (external_pinfo *) cygwin_internal (CW_GETPINFO_FULL, pid);
-  if (!p)
-return;
-  HANDLE h = OpenProcess (PROCESS_TERMINATE, FALSE, (DWORD) p->dwProcessId);
-  if (!h)
-return;
-  if (!wait || WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
-TerminateProcess (h, sig << 8);
-  CloseHandle (h);
 }



Re: big kill patch (adds list/help/version)

2002-03-11 Thread Joshua Daniel Franklin


--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> >> How does the linux kill program handle this?
> >RedHat's prints a list like
> > 1) SIGHUP   2) SIGINT   3) SIGQUIT  4) SIGILL
> > 5) SIGTRAP  6) SIGABRT  7) SIGBUS   8) SIGFPE
> >...
> >Looks hard-coded to me, but I didn't look at the sources. I'll hard-code 
> >the list in the print_list () function.
> 
> You're looking at the bash built-in.  /bin/kill just does this:
> 
> HUP INT QUIT ILL ABRT FPE KILL SEGV PIPE ALRM TERM USR1 USR2 CHLD CONT
> STOP TSTP TTIN TTOU TRAP IOT BUS SYS STKFLT URG IO POLL CLD XCPU XFSZ
> VTALRM PROF PWR WINCH UNUSED
> 
Indeed. Now, am I correct in thinking that I cannot look at the util-linux
sources to see how it works?

__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/



Re: big kill patch (adds list/help/version)

2002-03-11 Thread Joshua Daniel Franklin

--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> No lectures, please.  If you want to get rid of a goto, fine. 
'twas a joke. Sorry. 

> I'm sorry but 'kill -l' has an established way of working.  
> How does the linux kill program handle this?
RedHat's prints a list like
 1) SIGHUP   2) SIGINT   3) SIGQUIT  4) SIGILL
 5) SIGTRAP  6) SIGABRT  7) SIGBUS   8) SIGFPE
...
Looks hard-coded to me, but I didn't look at the sources. I'll hard-code 
the list in the print_list () function.

> If you think that the functions just *have* to be moved before main(), then 
> submit a patch for that.
OK. I was just trying to have the sources be consistant, but main followed by
functions is fine.

> I would prefer that getopt still be used for this functionality.  It should
> still be possible to parse signals by detecting illegal options and seeing
> if they happen to be signal numbers.
I really don't think it's possible since getopt does the illegal-option
parsing. I'm not a getopt expert, but GNU getopt
won't recognize anything that's not in the "ab:cdef". I think the only way
would be to put all possible signals in the long_options struct like:
  { "HUP", no_argument, NULL, SIGHUP},
in which case I *think* the numbers would be recognized, but stuff like -HUP
would have to be --HUP. The problem is that getopt will only parse the first
character after a single dash (and then, if it's another dash, proceed).

Well, I have no political views about goto so I'll probably leave it for
simplicity in a new patch. I'll probably leave out the -l option, too, and 
just stick with adding -h and -v.

__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/



big kill patch (adds list/help/version)

2002-03-10 Thread Joshua Daniel Franklin

As a result of the 'kill -sigN' functionality, kill does not use
GNU getopt to process options, so this patch required quite a few
changes. While ./kill.exe works the same as /bin/kill for me, as
usual I'm not saying it has any MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE. Send me test cases and I will test if you desire.

I also made two "unecessary" changes, which I like to think of as
improvements. First, I removed the goto statement and moved the 
code into a new function called sig0 (the label from the goto). This
and all the other functions now appear above main (). I thought a 
goto was absolutely necessary (even though I haven't needed one since 
VAX assembly), until I read:

Edsger W. Dijkstra "Go To Statement Considered Harmful"
http://www.acm.org/classics/oct95/

No code was harmed in this move. In fact, being lazy I left all the
variable names the same.
Second, there is now a -l, --list option that will list signal numbers
and a *description* of the signal such as:

24: CPU time limit exceeded

I would like to add the symbolic names like XCPU, HUP, etc. to the list 
option, but I don't know of a dynamic way to do so. Is there something like
strsignal for this, or would it have to be hard-coded?

2002-03-10  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* kill.cc (sig0) New function. Process signals given on command line.
  (usage) Generalize to allow use for help. Describe options.
  (list_signals) New fucntion.
  (print_version) New function. 
  (main) Accomodate new options. Add long options for each. 
   Move goto functionality to sig0.


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--- kill.cc-origSun Feb 24 13:28:27 2002
+++ kill.cc Sun Mar 10 19:55:13 2002
@@ -1,6 +1,6 @@
 /* kill.cc
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -17,52 +17,52 @@ details. */
 #include 
 #include 
 
-static void usage (void);
-static int __stdcall getsig (char *);
-static void __stdcall forcekill (int, int, int);
+static const char version[] = "$Revision: 1.10 $";
+static char *prog_name;
 
-int
-main (int argc, char **argv)
+static void __stdcall
+forcekill (int pid, int sig, int wait)
 {
-  int sig = SIGTERM;
-  int force = 0;
-  int gotsig = 0;
-  int ret = 0;
-
-  if (argc == 1)
-usage ();
+  external_pinfo *p =
+(external_pinfo *) cygwin_internal (CW_GETPINFO_FULL, pid);
+  if (!p)
+return;
+  HANDLE h = OpenProcess (PROCESS_TERMINATE, FALSE, (DWORD) p->dwProcessId);
+  if (!h)
+return;
+  if (!wait || WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
+TerminateProcess (h, sig << 8);
+  CloseHandle (h);
+}
 
-  while (*++argv && **argv == '-')
-if (strcmp (*argv + 1, "f") == 0)
-  force = 1;
-else if (gotsig)
-  break;
-else if (strcmp(*argv + 1, "0") != 0)
-  {
-   sig = getsig (*argv + 1);
-   gotsig = 1;
-  }
-else
-  {
-   argv++;
-   sig = 0;
-   goto sig0;
-  }
+static int
+getsig (char *in_sig)
+{
+  char *sig;
+  char buf[80];
 
-  if (sig <= 0 || sig > NSIG)
+  if (strncmp (in_sig, "SIG", 3) == 0)
+sig = in_sig;
+  else
 {
-  fprintf (stderr, "kill: unknown signal: %s\n", argv[-1]);
-  exit (1);
+  sprintf (buf, "SIG%s", in_sig);
+  sig = buf;
 }
+  return (strtosigno (sig) ? : atoi (in_sig));
+}
+
+int
+sig0 (char **argv, int sig, int force)
+{
+  int ret = 0;
 
-sig0:
   while (*argv != NULL)
 {
   char *p;
   int pid = strtol (*argv, &p, 10);
   if (*p != '\0')
{
- fprintf (stderr, "kill: illegal pid: %s\n", *argv);
+ fprintf (stderr, "%s: illegal pid: %s\n", prog_name, *argv);
  ret = 1;
}
   else if (kill (pid, sig) == 0)
@@ -85,38 +85,139 @@ sig0:
 }
 
 static void
-usage (void)
+usage (FILE * stream, int status)
 {
-  fprintf (stderr, "Usage: kill [-sigN] pid1 [pid2 ...]\n");
-  exit (1);
+  fprintf (stream, "\
+Usage: %s [ [-f] -sigN] pid1 [pid2 ...]\n\
+ -f, --force force kill, use win32 interface if necessary\n\
+ -sigN   send signal N (see sys/signal.h for names)\n\
+ -l, --list  list signal numbers, what each signifies and exit\n\
+ -h, --help  output usage information and exit\n\
+ -v, --version   output version information and exit\n\
+", prog_name);
+  exit (status);
 }
 
-static int
-getsig (char *in_sig)
+static void
+list_signals ()
 {
-  char *sig;
-  char buf[80];
+  int sig;
+  for (sig = 0; sig < NSIG; sig++)
+printf ("%d: %s\n", sig, strsignal (sig));
+}
 
-  if (strncmp (in_sig, "

Re: getfacl.c help/version patch

2002-03-09 Thread Joshua Daniel Franklin

--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> Can I ask you to also take a look at the utils.sgml file and update the
> documentation there, too?  It should be self-explanatory.
> 
> If you feel like regularizing the presentation in this file so that all
> of the options are displayed in the same way that would be an added
> plus.

Yeah, I am meaning to do just one patch for utils.sgml after all the rest.
It appears that the "regular" way of showing options is to box up the
usage output. Everything except kill demonstrates options that way, but
after I standardize kill it will to. I can also add entries in utils.sgml
for dumper, getfacl, and setfacl. Is this what you had in mind?

Speaking of kill, by the way, I wrote a bash script to test signals and it
complained about SIGCLD (20) and SIGPOLL (23) like this:

./testkill.bash: trap: POLL: not a signal specification

Are these signals no longer defined? 

It also looks like I'm going to need to make more substantial changes to
kill.cc to get it to use getopt...and to get rid of that goto if possible.


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/



getfacl.c help/version patch

2002-03-09 Thread Joshua Daniel Franklin

It would probably be good to have Corinna look at this one, too. 
I have been trying to verify that the utils in my build tree are
functioning identically (other than the help/version output) to the
ones in /bin/, but since I didn't write them there is always the
chance I missed a nuance.

2002-03-09  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* getfacl.c (usage) Standardize usage output. Change return type to static
void.
Add exit point within function.
(longopts) Added longopts for all options.
(print_version) New function. 
(main) Accommodate new help and version options. 


__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--- getfacl.c-orig  Sun Feb 24 13:28:27 2002
+++ getfacl.c   Sat Mar  9 15:05:05 2002
@@ -1,6 +1,6 @@
 /* getfacl.c
 
-   Copyright 2000, 2001 Red Hat Inc.
+   Copyright 2000, 2001, 2002 Red Hat Inc.
 
Written by Corinna Vinschen <[EMAIL PROTECTED]>
 
@@ -20,6 +20,9 @@ details. */
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.13 $";
+static char *prog_name;
+
 char *
 permstr (mode_t perm)
 {
@@ -58,68 +61,86 @@ groupname (gid_t gid)
   return gbuf;
 }
 
-#define pn(txt)fprintf (fp, txt "\n", name)
-#define p(txt) fprintf (fp, txt "\n")
-
-int
-usage (const char *name, int help)
+static void
+usage (FILE * stream, int status)
 {
-  FILE *fp = help ? stdout : stderr;
-
-  pn ("usage: %s [-adn] file...");
-  if (!help)
-pn ("Try `%s --help' for more information.");
-  else
-{
-  p ("");
-  p ("Display file and directory access control lists (ACLs).");
-  p ("");
-  p ("For each argument that is a regular file, special file or");
-  p ("directory, getfacl displays the owner, the group, and the ACL.");
-  p ("For directories getfacl displays additionally the default ACL.");
-  p ("");
-  p ("With no options specified, getfacl displays the filename, the");
-  p ("owner, the group, and both the ACL and the default ACL, if it");
-  p ("exists.");
-  p ("");
-  p ("The following options are supported:");
-  p ("");
-  p ("-a   Display the filename, the owner, the group, and the ACL");
-  p (" of the file.");
-  p ("");
-  p ("-d   Display the filename, the owner, the group, and the default");
-  p (" ACL of the directory, if it exists.");
-  p ("");
-  p ("-n   Display user and group IDs instead of names.");
-  p ("");
-  p ("The format for ACL output is as follows:");
-  p (" # file: filename");
-  p (" # owner: name or uid");
-  p (" # group: name or uid");
-  p (" user::perm");
-  p (" user:name or uid:perm");
-  p (" group::perm");
-  p (" group:name or gid:perm");
-  p (" mask:perm");
-  p (" other:perm");
-  p (" default:user::perm");
-  p (" default:user:name or uid:perm");
-  p (" default:group::perm");
-  p (" default:group:name or gid:perm");
-  p (" default:mask:perm");
-  p (" default:other:perm");
-  p ("");
-  p ("When multiple files are specified on the command line, a blank");
-  p ("line separates the ACLs for each file.");
-}
-  return 1;
+  fprintf (stream, "usage: %s [-adn] FILE...\n", prog_name);
+  if (status)
+fprintf (stream, "Try `%s --help' for more information.\n", prog_name);
+  else 
+fprintf (stream, "\
+Display file and directory access control lists (ACLs).\n\
+\n\
+For each argument that is a regular file, special file or\n\
+directory, getfacl displays the owner, the group, and the ACL.\n\
+For directories getfacl displays additionally the default ACL.\n\
+\n\
+With no options specified, getfacl displays the filename, the\n\
+owner, the group, and both the ACL and the default ACL, if it\n\
+exists.\n\
+\n\
+The following options are supported:\n\
+\n\
+-a, --all  Display the filename, the owner, the group, and the ACL\n\
+   of the file.\n\
+-d, --dir  Display the filename, the owner, the group, and the default\n\
+   ACL of the directory, if it exists.\n\
+-n, --noname   Display user and group IDs instead of names.\n\
+\n\
+The format for ACL output is as follows:\n\
+ # file: filename\n\
+ # owner: name or uid\n\
+ # group: name or uid\n\
+ user::perm\n\
+ user:name or uid:

dumper.exe help/version patch

2002-03-08 Thread Joshua Daniel Franklin

Here is the next in the series of patches to standardize the help and
version options in the utils. This also adds GNUish options to dumper.
I left the "Compiled on __DATE__" out of
print_version since there is a #ifdef __GNUC__ in the file and I don't
know whether that trick works with all compilers.

2002-03-09  Joshua Daniel Franklin <[EMAIL PROTECTED]>
* dumper.cc (usage) Standardize usage output. Generalize to allow use for help.
(longopts) New struct. Added longopts for all options.
(print_version) New function. 
(main) Change getopt to getopt_long. Accommodate new help and 
version options. 

__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--- dumper.cc-orig  Sun Feb 24 19:33:06 2002
+++ dumper.cc   Sat Mar  9 00:34:02 2002
@@ -1,6 +1,6 @@
 /* dumper.cc
 
-   Copyright 1999,2001 Red Hat Inc.
+   Copyright 1999, 2001, 2002 Red Hat Inc.
 
Written by Egor Duda <[EMAIL PROTECTED]>
 
@@ -36,6 +36,8 @@ __attribute__ ((packed))
 #endif
   note_header;
 
+static const char version[] = "$Revision: 1.8 $";
+
 BOOL verbose = FALSE;
 
 int deb_printf (const char *format,...)
@@ -770,14 +772,46 @@ dumper::write_core_dump ()
 }
 
 static void
-usage ()
+usage (FILE * stream, int status)
 {
-  fprintf (stderr, "Usage: dumper [options] filename pid\n");
-  fprintf (stderr, "filename -- dump core to filename.core\n");
-  fprintf (stderr, "pid  -- win32-pid of process to dump\n\n");
-  fprintf (stderr, "Possible options are:\n");
-  fprintf (stderr, "-d   -- be verbose while dumping\n");
-  fprintf (stderr, "-q   -- be quite while dumping (default)\n");
+  fprintf (stream, "\
+Usage: dumper [OPTION] FILENAME WIN32PID\n\
+Dump core from WIN32PID to FILENAME.core\n\
+ -d, --verbose  be verbose while dumping\n\
+ -h, --help output help information and exit\n\
+ -q, --quietbe quiet while dumping (default)\n\
+ -v, --version  output version information and exit\n\
+");
+  exit (status);
+}
+
+struct option longopts[] = {
+  {"verbose", no_argument, NULL, 'd'},
+  {"help", no_argument, NULL, 'h'},
+  {"quiet", no_argument, NULL, 'q'},
+  {"version", no_argument, 0, 'v'},
+  {0, no_argument, NULL, 0}
+};
+
+static void 
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+dumper (cygwin) %.*s\n\
+Core Dumper for Cygwin\n\
+Copyright 1999, 2001, 2002 Red Hat, Inc.\n", len, v);
 }
 
 int
@@ -788,7 +822,7 @@ main (int argc, char **argv)
   DWORD pid;
   char win32_name [MAX_PATH];
 
-  while ((opt = getopt (argc, argv, "dq")) != EOF)
+  while ((opt = getopt_long (argc, argv, "dqhv", longopts, NULL) ) != EOF)
 switch (opt)
   {
   case 'd':
@@ -797,8 +831,13 @@ main (int argc, char **argv)
   case 'q':
verbose = FALSE;
break;
+  case 'h':
+   usage (stdout, 0);
+  case 'v':
+   print_version ();
+   exit (0);
   default:
-   usage ();
+   usage (stderr, 1);
break;
   }
 
@@ -814,7 +853,7 @@ main (int argc, char **argv)
 }
   else
 {
-  usage ();
+  usage (stderr, 1);
   return -1;
 }
 



Re: cygpath copyright/version patch

2002-03-07 Thread Joshua Daniel Franklin


--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> On Wed, Feb 27, 2002 at 12:56:34PM -0800, Joshua Daniel Franklin wrote:
> >Changelog:
> >
> >2002-02-27 Joshua Daniel Franklin <[EMAIL PROTECTED]>
> >
> >* cygpath.cc (print_version): New function.
> >(main): Accommodate new version function. Initialize 'o' to prevent warning.
> 
> Applied with some minor tweaks.
> 
> I also ran indent over the file.  It had accumulated a strange mishmash of
> GNU and non-GNU formatting.
> 
> cgf

Thanks. I read over the GNU formatting guidelines and will try to make sure 
any changes I make in the future will meet them.

__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/



cygpath copyright/version patch

2002-02-27 Thread Joshua Daniel Franklin

--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> I've checked in a modified version of your patch.  I cleaned up some of
> the non-GNU formatting, added a ChangeLog, and added a "print_version"
> function which parses the 'version' array for version info.
> 
Your patch looks much cleaner. I will try to read up on GNU formatting to avoid
this in the future. I assume my indenting was off. 

Here is a patch for cygpath that fixes the copyright dates I changed
incorrectly. It also uses cgf's print_version() instead of the previous
hard-coded and wrong version. (The current cygpath.exe outputs version 1.2,
while in reality the CVS version is 1.13.) The first line of the new version
output is in the GNU standard "file (package) #.##", i.e. "cygpath (cygwin)
1.13" or "ls (fileutils) 4.1". It also initializes the variable 'o' to prevent
a compiler warning.

Changelog:

2002-02-27 Joshua Daniel Franklin <[EMAIL PROTECTED]>

* cygpath.cc (print_version): New function.
(main): Accommodate new version function. Initialize 'o' to prevent warning.

__
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--- cygpath.cc-orig Sun Feb 24 13:28:27 2002
+++ cygpath.cc  Wed Feb 27 14:32:51 2002
@@ -1,5 +1,5 @@
 /* cygpath.cc -- convert pathnames between Windows and Unix format
-   Copyright 1998-2002 Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -21,6 +21,8 @@ details. */
 #include 
 #include 
 
+static const char version[] = "$Revision: 1.13 $";
+
 static char *prog_name;
 static char *file_arg;
 static char *close_arg;
@@ -231,6 +233,28 @@ doit (char *filename)
   puts (buf);
 }
 
+static void
+print_version ()
+{
+  const char *v = strchr (version, ':');
+  int len;
+  if (!v)
+{
+  v = "?";
+  len = 1;
+}
+  else
+{
+  v += 2;
+  len = strchr (v, ' ') - v;
+}
+  printf ("\
+cygpath (cygwin) %.*s\n\
+Path Conversion Utility\n\
+Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n\
+Compiled on %s", len, v, __DATE__);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -257,6 +281,7 @@ main (int argc, char **argv)
   options_from_file_flag = 0;
   allusers_flag = 0;
   output_flag = 0;
+  o=0;
   while ((c = getopt_long (argc, argv, (char *) "hac:f:opsSuvwWiDPA", long_options, 
(int *) NULL))
 != EOF)
 {
@@ -341,8 +366,7 @@ main (int argc, char **argv)
  break;
 
case 'v':
- printf ("Cygwin path conversion version 1.2\n");
- printf ("Copyright 1998-2002 Red Hat, Inc.\n");
+  print_version();
  exit (0);
 
default:



Re: help/version patches

2002-02-27 Thread Joshua Daniel Franklin


--- Christopher Faylor <[EMAIL PROTECTED]> wrote:
> There's no need for a loop.  There really shouldn't be any need to
> accommodate the missing colon but it doesn't hurt too much to add a test
> case.
> 
> I've checked in a modified version of your patch.  I cleaned up some of
> the non-GNU formatting, added a ChangeLog, and added a "print_version"
> function which parses the 'version' array for version info.
> 
> I appreciate the submission very much but, next time, I would also
> appreciate a ChangeLog and more attention to formatting issues.

Sorry, I didn't read this first. Ignore my last message.

__
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com



Re: version information for cygcheck

2002-02-27 Thread Joshua Daniel Franklin

--- Warren Young <[EMAIL PROTECTED]> wrote:
> Joshua Daniel Franklin wrote:
> > 
> >  -z, --version  output version information and exit
> > 
> > I used -z since -v is --verbose. It could also have no character
> > option if that would be better. 
> 
> Why not -V?

No no no. Makes much too much sense. You'd think I was adding version
information for the users or someting.

Lastest patch: 
corrects copyright dates
version now -V, not -z

I think this one's going to work, so here's a changelog:

2001-02-27  Joshua Daniel Franklin  <[EMAIL PROTECTED]>

* cygcheck.cc: added -V --version option, corrected -h to output to stdout


__
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--- cygcheck.cc-origSun Feb 24 13:28:27 2002
+++ cygcheck.cc Wed Feb 27 11:57:32 2002
@@ -1,6 +1,6 @@
 /* cygcheck.cc
 
-   Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
This file is part of Cygwin.
 
@@ -33,6 +33,8 @@ typedef __int64 longlong;
 
 void dump_setup (int, char **, bool);
 
+const char *revision="$Revision: 1.22 $ ";
+
 const char *known_env_vars[] = {
   "c_include_path",
   "compiler_path",
@@ -1216,17 +1218,19 @@ check_keys ()
 }
 
 void
-usage ()
+usage (FILE *stream, int status)
 {
-  fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n");
-  fprintf (stderr, "  -c, --check-setup = check packages installed via setup.exe\n");
-  fprintf (stderr, "  -s, --sysinfo = system information (not with -k)\n");
-  fprintf (stderr, "  -v, --verbose = verbose output (indented) (for -s or 
programs)\n");
-  fprintf (stderr, "  -r, --registry= registry search (requires -s)\n");
-  fprintf (stderr, "  -k, --keycheck= perform a keyboard check session (not with 
-s)\n");
-  fprintf (stderr, "  -h, --help= give help about the info (not with -c)\n");
-  fprintf (stderr, "You must at least give either -s or -k or a program name\n");
-  exit (1);
+  fprintf (stream, "\
+Usage: cygcheck [OPTIONS] [program ...]\n\
+ -c, --check-setup  check packages installed via setup.exe\n\
+ -s, --sysinfo  system information (not with -k)\n\
+ -v, --verbose  verbose output (indented) (for -s or programs)\n\
+ -r, --registry registry search (requires -s)\n\
+ -k, --keycheck perform a keyboard check session (not with -s)\n\
+ -h, --help give help about the info (not with -c)\n\
+ -V, --version  output version information and exit\n\
+You must at least give either -s or -k or a program name\n");
+  exit (status);
 }
 
 struct option longopts[] = {
@@ -1236,15 +1240,32 @@ struct option longopts[] = {
   {"verbose", no_argument, NULL, 'v'},
   {"keycheck", no_argument, NULL, 'k'},
   {"help", no_argument, NULL, 'h'},
+  {"version", no_argument, 0, 'V'},
   {0, no_argument, NULL, 0}
 };
 
-char opts[] = "srvkhc";
+char opts[] = "chkrsvV";
 
 int
 main (int argc, char **argv)
 {
   int i;
+  char *version;
+  
+  /* Get version number out of the autogenerated revision string  */
+  (void *) version = malloc(sizeof(revision));
+  strcpy(version, revision+9);
+  if (version[0] != ':')
+*version=0;
+  else
+  {
+version = version+2;
+char *temp=version + strlen (version);
+while (isspace((int)*--temp) || *temp=='$' && temp >= version)
+  temp[1]='\0';
+  }
+
+  version[strlen(version)-1]= 0;
 
   while ((i = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
 switch (i)
@@ -1267,17 +1288,27 @@ main (int argc, char **argv)
   case 'h':
givehelp = 1;
break;
+  case 'V':
+printf ("cygcheck (cygwin) %s\n", version);
+printf ("System Checker\n");
+printf ("Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n");
+fputs ("Compiled "__DATE__"\n", stdout);
+exit (0);
   default:
-   usage ();
+   usage (stderr, 1);
/*NOTREACHED*/}
   argc -= optind;
   argv += optind;
 
-  if (argc == 0 && !sysinfo && !keycheck && !check_setup)
-usage ();
+  if (argc == 0 && !sysinfo && !keycheck && !check_setup) {
+ if (givehelp)
+   usage (stdout, 0);
+ else
+   usage (stderr, 1);
+ }
 
   if ((check_setup || sysinfo) && keycheck)
-usage ();
+   usage (stderr, 1);
 
   if (keycheck)
 return check_keys ();



Re: version information for cygcheck

2002-02-27 Thread Joshua Daniel Franklin


--- Warren Young <[EMAIL PROTECTED]> wrote:
> Joshua Daniel Franklin wrote:
> > 
> >  -z, --version  output version information and exit
> > 
> > I used -z since -v is --verbose. It could also have no character
> > option if that would be better. 
> 
> Why not -V?

No no no. Makes much too much sense. You'd think I was adding version
information for the users or someting.

Lastest patch: 
corrects copyright dates
version now -V, not -z

I think this one's going to work, so here's a changelog:

2001-02-27  Joshua Daniel Franklin  <[EMAIL PROTECTED]>

* cygcheck.cc: added -V --version option, corrected -h to output to stdout




__
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--- cygcheck.cc-origSun Feb 24 13:28:27 2002
+++ cygcheck.cc Wed Feb 27 11:57:32 2002
@@ -1,6 +1,6 @@
 /* cygcheck.cc
 
-   Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
 
This file is part of Cygwin.
 
@@ -33,6 +33,8 @@ typedef __int64 longlong;
 
 void dump_setup (int, char **, bool);
 
+const char *revision="$Revision: 1.22 $ ";
+
 const char *known_env_vars[] = {
   "c_include_path",
   "compiler_path",
@@ -1216,17 +1218,19 @@ check_keys ()
 }
 
 void
-usage ()
+usage (FILE *stream, int status)
 {
-  fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n");
-  fprintf (stderr, "  -c, --check-setup = check packages installed via setup.exe\n");
-  fprintf (stderr, "  -s, --sysinfo = system information (not with -k)\n");
-  fprintf (stderr, "  -v, --verbose = verbose output (indented) (for -s or 
programs)\n");
-  fprintf (stderr, "  -r, --registry= registry search (requires -s)\n");
-  fprintf (stderr, "  -k, --keycheck= perform a keyboard check session (not with 
-s)\n");
-  fprintf (stderr, "  -h, --help= give help about the info (not with -c)\n");
-  fprintf (stderr, "You must at least give either -s or -k or a program name\n");
-  exit (1);
+  fprintf (stream, "\
+Usage: cygcheck [OPTIONS] [program ...]\n\
+ -c, --check-setup  check packages installed via setup.exe\n\
+ -s, --sysinfo  system information (not with -k)\n\
+ -v, --verbose  verbose output (indented) (for -s or programs)\n\
+ -r, --registry registry search (requires -s)\n\
+ -k, --keycheck perform a keyboard check session (not with -s)\n\
+ -h, --help give help about the info (not with -c)\n\
+ -V, --version  output version information and exit\n\
+You must at least give either -s or -k or a program name\n");
+  exit (status);
 }
 
 struct option longopts[] = {
@@ -1236,15 +1240,32 @@ struct option longopts[] = {
   {"verbose", no_argument, NULL, 'v'},
   {"keycheck", no_argument, NULL, 'k'},
   {"help", no_argument, NULL, 'h'},
+  {"version", no_argument, 0, 'V'},
   {0, no_argument, NULL, 0}
 };
 
-char opts[] = "srvkhc";
+char opts[] = "chkrsvV";
 
 int
 main (int argc, char **argv)
 {
   int i;
+  char *version;
+  
+  /* Get version number out of the autogenerated revision string  */
+  (void *) version = malloc(sizeof(revision));
+  strcpy(version, revision+9);
+  if (version[0] != ':')
+*version=0;
+  else
+  {
+version = version+2;
+char *temp=version + strlen (version);
+while (isspace((int)*--temp) || *temp=='$' && temp >= version)
+  temp[1]='\0';
+  }
+
+  version[strlen(version)-1]= 0;
 
   while ((i = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
 switch (i)
@@ -1267,17 +1288,27 @@ main (int argc, char **argv)
   case 'h':
givehelp = 1;
break;
+  case 'V':
+printf ("cygcheck (cygwin) %s\n", version);
+printf ("System Checker\n");
+printf ("Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.\n");
+fputs ("Compiled "__DATE__"\n", stdout);
+exit (0);
   default:
-   usage ();
+   usage (stderr, 1);
/*NOTREACHED*/}
   argc -= optind;
   argv += optind;
 
-  if (argc == 0 && !sysinfo && !keycheck && !check_setup)
-usage ();
+  if (argc == 0 && !sysinfo && !keycheck && !check_setup) {
+ if (givehelp)
+   usage (stdout, 0);
+ else
+   usage (stderr, 1);
+ }
 
   if ((check_setup || sysinfo) && keycheck)
-usage ();
+   usage (stderr, 1);
 
   if (keycheck)
 return check_keys ();



Re: version information for cygcheck

2002-02-27 Thread Joshua Daniel Franklin


--- Warren Young <[EMAIL PROTECTED]> wrote:
> Joshua Daniel Franklin wrote:
> > 
> >  -z, --version  output version information and exit
> > 
> > I used -z since -v is --verbose. It could also have no character
> > option if that would be better. 
> 
> Why not -V?

No no no. Makes much too much sense. You'd think I was adding version
information for the users or someting.

Lastest patch: 
corrects copyright dates
version now -V, not -z

I think this one's going to work, so here's a changelog:

2001-02-27  Joshua Daniel Franklin  <[EMAIL PROTECTED]>

* cygcheck.cc: added -V --version option, corrected -h to output to stdout




__
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com



RE: help/version patches

2002-02-26 Thread Joshua Daniel Franklin


--- Robert Collins <[EMAIL PROTECTED]> wrote:
> 
> 
> > -Original Message-
> > From: Joshua Daniel Franklin [mailto:[EMAIL PROTECTED]] 
> 
> +const char *revision="$Revision: 1.22 $";
> 
> This is suspect: The revision string can look like $Revision:$ in some
> circumstances - see man co again - which is why I had "$Revision: $ " - note
> the space after the second $ sign.

Hmm. Sounds like if -kk is used, it could be replaced with just "$Revision$",
which gives the +11 part problems. Another if...

> Likewise, the 
> +  /* Get version number out of the autogenerated revision string  */
> +  (void *) version = malloc(sizeof(revision));
> +  strcpy(version, revision+11);
> +  version[strlen(version)-1]= 0;
> 
> Could be more robustly done as 
> +  version = (char *) malloc(sizeof(revision));
> +  strcpy(version, revision+11);
> +  {
> +char *temp=version + strlen (version);
> +while (isspace(--temp) && temp >= version);
> +temp[1]='\0';
> +  }
> 
> Which will munch an arbitrary amount of whitespace.

Well, except that that loop does away with the whole point--eating the
trailing '$'. Here's another go. I tested it with "$Revision$", 
"$Revision:$", "$Revision: $ ", "$Revision: 1.22 $ ", and "$Revision: 1.2 2 $ "
(in the unlikely event of a version number with spaces) and it does the right
thing on each.


__
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

--- cygcheck.cc-origSun Feb 24 13:28:27 2002
+++ cygcheck.cc Tue Feb 26 22:55:33 2002
@@ -1,6 +1,6 @@
 /* cygcheck.cc
 
-   Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1998-2002 Red Hat, Inc.
 
This file is part of Cygwin.
 
@@ -33,6 +33,8 @@ typedef __int64 longlong;
 
 void dump_setup (int, char **, bool);
 
+const char *revision="$Revision: 1.22 $ ";
+
 const char *known_env_vars[] = {
   "c_include_path",
   "compiler_path",
@@ -1216,17 +1218,19 @@ check_keys ()
 }
 
 void
-usage ()
+usage (FILE *stream, int status)
 {
-  fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n");
-  fprintf (stderr, "  -c, --check-setup = check packages installed via setup.exe\n");
-  fprintf (stderr, "  -s, --sysinfo = system information (not with -k)\n");
-  fprintf (stderr, "  -v, --verbose = verbose output (indented) (for -s or 
programs)\n");
-  fprintf (stderr, "  -r, --registry= registry search (requires -s)\n");
-  fprintf (stderr, "  -k, --keycheck= perform a keyboard check session (not with 
-s)\n");
-  fprintf (stderr, "  -h, --help= give help about the info (not with -c)\n");
-  fprintf (stderr, "You must at least give either -s or -k or a program name\n");
-  exit (1);
+  fprintf (stream, "\
+Usage: cygcheck [OPTIONS] [program ...]\n\
+ -c, --check-setup  check packages installed via setup.exe\n\
+ -s, --sysinfo  system information (not with -k)\n\
+ -v, --verbose  verbose output (indented) (for -s or programs)\n\
+ -r, --registry registry search (requires -s)\n\
+ -k, --keycheck perform a keyboard check session (not with -s)\n\
+ -h, --help give help about the info (not with -c)\n\
+ -z, --version  output version information and exit\n\
+You must at least give either -s or -k or a program name\n");
+  exit (status);
 }
 
 struct option longopts[] = {
@@ -1236,15 +1240,32 @@ struct option longopts[] = {
   {"verbose", no_argument, NULL, 'v'},
   {"keycheck", no_argument, NULL, 'k'},
   {"help", no_argument, NULL, 'h'},
+  {"version", no_argument, 0, 'z'},
   {0, no_argument, NULL, 0}
 };
 
-char opts[] = "srvkhc";
+char opts[] = "chkrsvz";
 
 int
 main (int argc, char **argv)
 {
   int i;
+  char *version;
+  
+  /* Get version number out of the autogenerated revision string  */
+  (void *) version = malloc(sizeof(revision));
+  strcpy(version, revision+9);
+  if (version[0] != ':')
+*version=0;
+  else
+  {
+version = version+2;
+char *temp=version + strlen (version);
+while (isspace((int)*--temp) || *temp=='$' && temp >= version)
+  temp[1]='\0';
+  }
+
+  version[strlen(version)-1]= 0;
 
   while ((i = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
 switch (i)
@@ -1267,17 +1288,27 @@ main (int argc, char **argv)
   case 'h':
givehelp = 1;
break;
+  case 'z':
+printf ("cygcheck (cygwin) %s\n", version);
+printf ("System Checker\n");
+printf ("Copyright 1998-2002 Red 

Re: help/version patches

2002-02-25 Thread Joshua Daniel Franklin

> > I'm not sure I understand. Hard-code the revision in a const char 
> 
> man co might enlighten you.
> 

I'm afraid I've never used CVS/RCS before. :(
Am I reading this right? If I just put $Revision$ in the code, once
it's checked in/out that'll be replaced with the correct version number?
I see strace.cc has a line:
static const char *version_string = "@(#)strace V1.0, Copyright (C) 2001 Red
Hat
 Inc., " __DATE__ "\n";

That doesn't look autogenerated, but maybe it is.

Anyway here is a patch for cygcheck that I think does the right thing.
Somebody want to take a look?

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--- cygcheck.cc-origSun Feb 24 13:28:27 2002
+++ cygcheck.cc Mon Feb 25 21:03:02 2002
@@ -1,6 +1,6 @@
 /* cygcheck.cc
 
-   Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1998-2002 Red Hat, Inc.
 
This file is part of Cygwin.
 
@@ -33,6 +33,8 @@ typedef __int64 longlong;
 
 void dump_setup (int, char **, bool);
 
+const char *revision="$Revision: 1.22 $";
+
 const char *known_env_vars[] = {
   "c_include_path",
   "compiler_path",
@@ -1216,17 +1218,19 @@ check_keys ()
 }
 
 void
-usage ()
+usage (FILE *stream, int status)
 {
-  fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n");
-  fprintf (stderr, "  -c, --check-setup = check packages installed via setup.exe\n");
-  fprintf (stderr, "  -s, --sysinfo = system information (not with -k)\n");
-  fprintf (stderr, "  -v, --verbose = verbose output (indented) (for -s or 
programs)\n");
-  fprintf (stderr, "  -r, --registry= registry search (requires -s)\n");
-  fprintf (stderr, "  -k, --keycheck= perform a keyboard check session (not with 
-s)\n");
-  fprintf (stderr, "  -h, --help= give help about the info (not with -c)\n");
-  fprintf (stderr, "You must at least give either -s or -k or a program name\n");
-  exit (1);
+  fprintf (stream, "\
+Usage: cygcheck [OPTIONS] [program ...]\n\
+ -c, --check-setup  check packages installed via setup.exe\n\
+ -s, --sysinfo  system information (not with -k)\n\
+ -v, --verbose  verbose output (indented) (for -s or programs)\n\
+ -r, --registry registry search (requires -s)\n\
+ -k, --keycheck perform a keyboard check session (not with -s)\n\
+ -h, --help give help about the info (not with -c)\n\
+ -z, --version  output version information and exit\n\
+You must at least give either -s or -k or a program name\n");
+  exit (status);
 }
 
 struct option longopts[] = {
@@ -1236,15 +1240,22 @@ struct option longopts[] = {
   {"verbose", no_argument, NULL, 'v'},
   {"keycheck", no_argument, NULL, 'k'},
   {"help", no_argument, NULL, 'h'},
+  {"version", no_argument, 0, 'z'},
   {0, no_argument, NULL, 0}
 };
 
-char opts[] = "srvkhc";
+char opts[] = "chkrsvz";
 
 int
 main (int argc, char **argv)
 {
   int i;
+  char *version;
+  
+  /* Get version number out of the autogenerated revision string  */
+  (void *) version = malloc(sizeof(revision));
+  strcpy(version, revision+11);
+  version[strlen(version)-1]= 0;
 
   while ((i = getopt_long (argc, argv, opts, longopts, NULL)) != EOF)
 switch (i)
@@ -1267,17 +1278,27 @@ main (int argc, char **argv)
   case 'h':
givehelp = 1;
break;
+  case 'z':
+printf ("cygcheck (cygwin) %s\n", version);
+printf ("System Checker\n");
+printf ("Copyright 1998-2002 Red Hat, Inc.\n");
+fputs ("Compiled "__DATE__"\n", stdout);
+exit (0);
   default:
-   usage ();
+   usage (stderr, 1);
/*NOTREACHED*/}
   argc -= optind;
   argv += optind;
 
-  if (argc == 0 && !sysinfo && !keycheck && !check_setup)
-usage ();
+  if (argc == 0 && !sysinfo && !keycheck && !check_setup) {
+ if (givehelp)
+   usage (stdout, 0);
+ else
+   usage (stderr, 1);
+ }
 
   if ((check_setup || sysinfo) && keycheck)
-usage ();
+   usage (stderr, 1);
 
   if (keycheck)
 return check_keys ();



Re: help/version patches

2002-02-25 Thread Joshua Daniel Franklin

> Adding version numbers is not a bad idea (although, I can't honestly
> think of a time when it would have helped to have this information).
> Adding version numbers in the middle of the program, in the middle of a
> text string is, IMO, a bad idea.  The version number should be at
> the top of the program in a
>
> const char version[] = "something";
> 
> and referenced in the version string.
> 
> As Robert indicated, using the CVS version number is probably the best
> way to handle this.  setup.exe currently uses the CVS version.  Use that
> as an example.

I was trying to avoid doing what setup.exe does. In the Makefile.in there
is a grep/sed combo that grabs the version from the Changelog and creates
a file to include. This is fine for a lot of files that compile into one
(setup.exe) but is it really necessary for 13 utils, most of which take 
only one file of code? What about a sed script that takes that CVS/Entries
file and creates something like versions.c with:

const char cygcheck_version[]= "1.23";
const char cygpath_version[]= "4.56";

which could then be #include'd in each file? Then at least no one would have
to edit the version code; it would just make. (BTW, I used cygpath.cc as a 
reference point for the version code; it is currently in a hard-coded printf.)


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



Re: help/version patches

2002-02-25 Thread Joshua Daniel Franklin

> Adding version numbers is not a bad idea (although, I can't honestly
> think of a time when it would have helped to have this information).
> Adding version numbers in the middle of the program, in the middle of a
> text string is, IMO, a bad idea.  The version number should be at
> the top of the program in a
>
> const char version[] = "something";
> 
> and referenced in the version string.
> 
> As Robert indicated, using the CVS version number is probably the best
> way to handle this.  setup.exe currently uses the CVS version.  Use that
> as an example.

I was trying to avoid doing what setup.exe does. In the Makefile.in there
is a grep/sed combo that grabs the version from the Changelog and creates
a file to include. This is fine for a lot of files that compile into one
(setup.exe) but is it really necessary for 13 utils, most of which take 
only one file of code? What about a sed script that takes that CVS/Entries
file and creates something like versions.c with:

const char cygcheck_version[]= "1.23";
const char cygpath_version[]= "4.56";

which could then be #include'd in each file? Then at least no one would have
to edit the version code; it would just make. (BTW, I used cygpath.cc as a 
reference point for the version code; it is currently in a hard-coded printf.)


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



Re: help/version patches

2002-02-25 Thread Joshua Daniel Franklin

> Adding version numbers is not a bad idea (although, I can't honestly
> think of a time when it would have helped to have this information).
> Adding version numbers in the middle of the program, in the middle of a
> text string is, IMO, a bad idea.  The version number should be at
> the top of the program in a
>
> const char version[] = "something";
> 
> and referenced in the version string.
> 
> As Robert indicated, using the CVS version number is probably the best
> way to handle this.  setup.exe currently uses the CVS version.  Use that
> as an example.

I was trying to avoid doing what setup.exe does. In the Makefile.in there
is a grep/sed combo that grabs the version from the Changelog and creates
a file to include. This is fine for a lot of files that compile into one
(setup.exe) but is it really necessary for 13 utils, most of which take 
only one file of code? What about a sed script that takes that CVS/Entries
file and creates something like versions.c with:

const char cygcheck_version[]= "1.23";
const char cygpath_version[]= "4.56";

which could then be #include'd in each file? Then at least no one would have
to edit the version code; it would just make. (BTW, I used cygpath.cc as a 
reference point for the version code; it is currently in a hard-coded printf.)


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



Re: help/version patches

2002-02-25 Thread Joshua Daniel Franklin

> Adding version numbers is not a bad idea (although, I can't honestly
> think of a time when it would have helped to have this information).
> Adding version numbers in the middle of the program, in the middle of a
> text string is, IMO, a bad idea.  The version number should be at
> the top of the program in a
>
> const char version[] = "something";
> 
> and referenced in the version string.
> 
> As Robert indicated, using the CVS version number is probably the best
> way to handle this.  setup.exe currently uses the CVS version.  Use that
> as an example.

I was trying to avoid doing what setup.exe does. In the Makefile.in there
is a grep/sed combo that grabs the version from the Changelog and creates
a file to include. This is fine for a lot of files that compile into one
(setup.exe) but is it really necessary for 13 utils, most of which take 
only one file of code? What about a sed script that takes that CVS/Entries
file and creates something like versions.c with:

const char cygcheck_version[]= "1.23";
const char cygpath_version[]= "4.56";

which could then be #include'd in each file? Then at least no one would have
to edit the version code; it would just make. (BTW, I used cygpath.cc as a 
reference point for the version code; it is currently in a hard-coded printf.)


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



RE: help/version patches

2002-02-25 Thread Joshua Daniel Franklin

--- Robert Collins <[EMAIL PROTECTED]> wrote:
> Some confusion here: I was meaning that having something like:
> const char *revision="$Revision: $ ";
> in the file allows you to then use:
> const char *version = revision[11];
> to obtain the correct version number.
> 
> Rob

I'm not sure I understand. Hard-code the revision in a const char 
instead of directly in a printf? Is that just so it's near the top
of the file and easier to get to? Or is there a way to automate
(without a bunch of sed mess in the Makefile) version numbers?
It looks like the mingw headers have a lines like "* $Revision: 1.2 $ "
in the comments, but I assume that's for a script of some sort to use.


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



help/version patches

2002-02-24 Thread Joshua Daniel Franklin

I've got patches for each of the utils to add/correct the help and
version output options. There are 13 in all. I incremented the
version number 0.01 from the ones in CVS/Entries with the
exception of cygpath. I also added a line based on one found in
strace that imbeds the compile date into the version output:

case 'v':
  printf ("cygpath (cygwin) 1.21\n");
  printf ("Path Conversion Utility\n");
  printf ("Copyright 1998-2002 Red Hat, Inc.\n");
  fputs("Compiled "__DATE__"\n", stdout);
  exit (0);

Please someone let me know if this is a Bad Idea for some reason.
I would also very much like to know the best way to submit these.
Thanks.

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



Re: version information for cygcheck

2002-02-24 Thread Joshua Daniel Franklin

>The usual thing to do for versions is to get the CVS version number and
>apply that.

I'm assuming that lines like this in CVS/Entries give the version numbers:

/cygcheck.cc/1.22/Tue Jan 29 03:08:42 2002/-ko/
/cygpath.cc/1.13/Thu Jan 17 16:54:01 2002/-ko/
/dump_setup.cc/1.4/Tue Jan 29 18:37:00 2002//
/dumper.cc/1.8/Fri Sep 14 15:07:31 2001//
/dumper.h/1.2/Thu Aug 30 16:47:51 2001//
/getfacl.c/1.5/Tue Jan 29 03:08:42 2002/-ko/
/kill.cc/1.10/Mon Oct  8 03:06:25 2001/-ko/
/mkgroup.c/1.9/Tue Jan 29 03:08:42 2002/-ko/
/mkpasswd.c/1.20/Thu Jan 31 12:43:29 2002/-ko/
...

I've got a problem then. Currently `cygpath --version` outputs 1.2, where it
should be 1.13 apparently. Is there a way to get the CVS version up to 1.21
with a patch? Also, if I add --version options to each util,
should I increment the version by .01 each time, so cygcheck will be v1.23,
mkgroup 1.91, etc.? I guess the question should be, does CVS automatically
increment the version by a certain amount after a patch?

Also, if I'm going to patch several files, should I tar up several 
.cc-patch files or do one big patch?

Thanks.

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



version information for cygcheck

2002-02-23 Thread Joshua Daniel Franklin

Here is a patch for cygcheck that adds an option:
 -z, --version  output version information and exit

I used -z since -v is --verbose. It could also have no character 
option if that would be better. Current output is:

$ ./cygcheck.exe --version
cygcheck (Cygwin) System checker 1.2
Copyright 1998-2002 Red Hat, Inc.

I used 1.2 since 1.0 would probably confuse people (as cygcheck has been
around a long time) and there is no real version infomation available AFAIK.

This patch also changes the usage() function to accept a stream and
exit value, so that if only the --help option is specified usage will
be output to stdout instead of stderr, which is more standard behaviour.

I hope to provide similar patches for the other utils if there
are no objections.

Changelog:

2001-02-23 Joshua Daniel Franklin <[EMAIL PROTECTED]>

* cygcheck.cc (main): added a --version option
* cygcheck.cc (usage): added parameters to accept a stream and exit value

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--- cygcheck.cc-origSat Feb 23 20:24:25 2002
+++ cygcheck.cc Sat Feb 23 20:52:06 2002
@@ -1216,17 +1216,19 @@ check_keys ()
 }
 
 void
-usage ()
+usage (FILE *stream, int status)
 {
-  fprintf (stderr, "Usage: cygcheck [OPTIONS] [program ...]\n");
-  fprintf (stderr, "  -c, --check-setup = check packages installed via setup.exe\n");
-  fprintf (stderr, "  -s, --sysinfo = system information (not with -k)\n");
-  fprintf (stderr, "  -v, --verbose = verbose output (indented) (for -s or 
programs)\n");
-  fprintf (stderr, "  -r, --registry= registry search (requires -s)\n");
-  fprintf (stderr, "  -k, --keycheck= perform a keyboard check session (not with 
-s)\n");
-  fprintf (stderr, "  -h, --help= give help about the info (not with -c)\n");
-  fprintf (stderr, "You must at least give either -s or -k or a program name\n");
-  exit (1);
+  fprintf (stream, "\
+Usage: cygcheck [OPTIONS] [program ...]\n\
+ -c, --check-setup  check packages installed via setup.exe\n\
+ -s, --sysinfo  system information (not with -k)\n\
+ -v, --verbose  verbose output (indented) (for -s or programs)\n\
+ -r, --registry registry search (requires -s)\n\
+ -k, --keycheck perform a keyboard check session (not with -s)\n\
+ -h, --help give help about the info (not with -c)\n\
+ -z, --version  output version information and exit\n\
+You must at least give either -s or -k or a program name\n");
+  exit (status);
 }
 
 struct option longopts[] = {
@@ -1236,6 +1238,7 @@ struct option longopts[] = {
   {"verbose", no_argument, NULL, 'v'},
   {"keycheck", no_argument, NULL, 'k'},
   {"help", no_argument, NULL, 'h'},
+  {"version", no_argument, 0, 'z'},
   {0, no_argument, NULL, 0}
 };
 
@@ -1267,17 +1270,25 @@ main (int argc, char **argv)
   case 'h':
givehelp = 1;
break;
+  case 'z':
+printf ("cygcheck (Cygwin) System checker 1.2\n");
+printf ("Copyright 1998-2002 Red Hat, Inc.\n");
+exit (0);
   default:
-   usage ();
+   usage (stderr, 1);
/*NOTREACHED*/}
   argc -= optind;
   argv += optind;
 
-  if (argc == 0 && !sysinfo && !keycheck && !check_setup)
-usage ();
+  if (argc == 0 && !sysinfo && !keycheck && !check_setup) {
+ if (givehelp)
+   usage (stdout, 0);
+ else
+   usage (stderr, 1);
+ }
 
   if ((check_setup || sysinfo) && keycheck)
-usage ();
+   usage (stderr, 1);
 
   if (keycheck)
 return check_keys ();



New file for winsup/utils

2002-02-20 Thread Joshua Daniel Franklin

OK, here is a new util:

Usage mkshortcut.exe [OPTION]... TARGET 
NOTE: All filename arguments must be in unix (POSIX) format
  -a|--arguments=ARGS   use arguments ARGS 
  -h|--help output usage information and exit
  -i|--icon icon file for link to use
  -j|--iconoffset   offset of icon in icon file (default is 0)
  -n|--name name for link (defaults to TARGET)
  -v|--version  output version information and exit
  -A|--allusers use 'All Users' instead of current user for -D,-P
  -D|--desktop  create link relative to 'Desktop' directory
  -P|--smprograms   create link relative to Start Menu 'Programs' directory

For example:
./mkshortcut -a '-rv -e /bin/bash --login -i' -D /bin/rxvt
creates a shortcut to rxvt with bash login on the Desktop.

This will allow the creation of Windows shortcuts from scripts or batch
files. My goal is to include this in the cygwin package so that it can be
used from setup.exe to create the cygwin bash shortcuts (allowing the 
removal of mklink.c and much (more) of desktop.cc), and used from packages
to create shortcuts to executables, manuals, FAQs, websites, etc. Changelog:

2001-02-20 Joshua Daniel Franklin <[EMAIL PROTECTED]>

* mkshortcut.c: new file, utility to create shortcuts from scripts
* utils.sgml: updated to include mkshortcut

--- Robert Collins <[EMAIL PROTECTED]> wrote:
> 
> ===
> - Original Message - 
> From: "Joshua Franklin" <[EMAIL PROTECTED]>
> 
> > I've written a program that does just this. It's a
> > fully scriptable and can set icons. I'm 
> > hoping to get it included in cygwin sometime, but
> > I'm waiting until the new setup.exe comes out to 
> > bother developers with it. In the meantime, you can
> > get it at:
> 
> Why are you waiting? 
> 
> Rob
> 


__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

/* mkshortcut.c -- create a Windows shortcut 
   Copyright 2002 Red Hat, Inc.

This file is part of Cygwin.

This software is a copyrighted work licensed under the terms of the
Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
details. 

Written by Joshua Daniel Franklin

Exit values
1: user error (syntax error)
2: system error (out of memory, etc.)
3: windows error (interface failed)
*/

#define NOCOMATTRIBUTE

#include 
#include 
#include 
#include 

static char *prog_name;
static char *argument_arg, *name_arg;
static int icon_flag, unix_flag, windows_flag;
static int allusers_flag, desktop_flag, smprograms_flag;

static struct option long_options[] =
{
  { "arguments", required_argument, NULL, 'a'},
  { "help", no_argument, NULL, 'h'},
  { "icon", required_argument, NULL, 'i'},
  { "iconoffset", required_argument, NULL, 'j'},
  { "name", required_argument, NULL, 'n'},
  { "version", no_argument, NULL, 'v'},
  { "allusers", no_argument, NULL, 'A'},
  { "desktop", no_argument, NULL, 'D'},
  { "smprograms", no_argument, NULL, 'P'},
  { NULL, 0, NULL, 0 }
};
  
static void
usage (FILE *stream, int status)
{
  fprintf (stream, "\
Usage %s [OPTION]... TARGET \n\
NOTE: All filename arguments must be in unix (POSIX) format\n\
  -a|--arguments=ARGS   use arguments ARGS \n\
  -h|--help output usage information and exit\n\
  -i|--icon icon file for link to use\n\
  -j|--iconoffset   offset of icon in icon file (default is 0)\n\
  -n|--name name for link (defaults to TARGET)\n\
  -v|--version  output version information and exit\n\
  -A|--allusers use 'All Users' instead of current user for -D,-P\n\
  -D|--desktop  create link relative to 'Desktop' directory\n\
  -P|--smprograms   create link relative to Start Menu 'Programs' directory\
", prog_name);
  exit (status);
}

int
main (int argc, char **argv)
{
  LPITEMIDLIST id;
  HRESULT hres;
  IShellLink *sl;
  IPersistFile *pf;
  WCHAR widepath[MAX_PATH];

  int opt, tmp, offset;
  char *args, *str2, *str1;
  char lname[MAX_PATH], exename[MAX_PATH], dirname[MAX_PATH], iconname[MAX_PATH];

  prog_name = strrchr (argv[0], '/');
  if (prog_name == NULL)
prog_name = strrchr (argv[0], '\\');
  if (prog_name == NULL)
prog_name = argv[0];
  else
prog_name++;

  offset=0;
  icon_flag=0;
  unix_flag=0;
  windows_flag=0;
  allusers_flag=0;
  desktop_flag=0;
  smprograms_flag=0;

  while ( (opt = getopt_long(argc, argv, (char *) "a:i:j:n:hvADP", long_options, NULL) 
) != EOF)
  {
switch(opt)
  {
  case 'a':
ar

Cygpath patch resend

2002-01-17 Thread Joshua Daniel Franklin

OK, I've abandoned the web-based email client which will hopefully fix the
spacing issue. Here it is again:

I've added these options to cygpath:

  -A|--allusersuse `All Users' instead of current user for -D, -P
  -D|--desktopoutput `Desktop' directory and exit
  -P|--smprogramsoutput Start Menu `Programs' directory and exit

I've also fixed the issue where options that depend on other options do not
behave as expected. For example, -Ww and -wW behaved differently but now
will do the right thing.

Here's a changelog:

2001-01-16 Joshua Daniel Franklin <[EMAIL PROTECTED]>

* cygpath.cc (main): Added options to show Desktop and Start Menu's Programs
directory for current user or all users
* cygpath.cc (main): moved bulk of DPWS options outside the getopt case
statement
 (since their output depends on uwA switches)
* utils.sgml: updated cygpath section for ADPWS options





cygpath.cc-patch
Description: Binary data


utils.sgml-patch
Description: Binary data