Re: q for the C hackers

2003-08-19 Thread Aaron Hope
On Mon, 2003-08-18 at 20:13, Erik Price wrote:
 However, what is the convention in C?  There seem to be two fine ways 
 of doing it -- using the preprocessor, or the const keyword:
 
 #define NUMBER_OF_UNITS 8
 
 const int NUMBER_OF_UNITS = 8;

Generally, the more the compiler knows, the better it can do it's job,
so I usually prefer the latter.  There are still some places in C (C99
specifically) where you you have no choice but to use macros, like array
declarations.  I believe that C++ const variables can be used wherever a
simple #define can.

aaron

BTW, Is there a reason why mailman isn't configured to set the 
reply-to header?


signature.asc
Description: This is a digitally signed message part


Re: Raw disk i/o

2003-08-19 Thread Aaron Hope
On Tue, 2003-08-19 at 00:21, Derek Martin wrote:
 On Mon, Aug 18, 2003 at 11:13:48PM -0400, Jeff Macdonald wrote:
  Hi,
  I am trying to understand how one uses raw disk i/o in Linux. I
 
 If you're not a filesystem engineer, you probably just really don't
 want to do this.  This is the level at which the filesystem reads and
 writes data -- it is a raw byte stream.  If you write data at this
 level, you will destroy your filesystem. 
 
  understand that the i/o skips the kernel buffer. 
 
 Well, IIRC, unlike most other Unix implementations, Linux disk I/O is
 /always/ block I/O (i.e. buffered by the kernel) unless you apply
 patches to the kernel.
 
 However, if what you're trying to do is avoid a layer of buffers to
 increase performance, have a look at memory-mapped I/O.  See the man
 page for mmap(2), and/or a good book on programming on Unix systems.
 I'd suggest W. Richard Stevens' Advanced Programming in the Unix
 Environment for starters.
 

I think that he's looking for the same raw i/o that oracle likes so
much:
http://www.tldp.org/HOWTO/SCSI-2.4-HOWTO/rawdev.html

But while you don't have to be writing a filesystem to want this, it's
still targeted for a pretty select audience.  Have you considered a
simple O_DIRECT instead?  As the parent post mentions, this may require
a patched kernel, depending on your vender and filesystem of choice. 
XFS has had it for a while, but isn't included in redhat kernels.  I
still recommend XFS for heavy I/O, as it was designed from the start to
be industrial strength.  According to the following, redhat kernels
don't support O_DIRECT for ext3 either (yet)
https://listman.redhat.com/archives/ext3-users/2003-March/msg00114.html

aaron


signature.asc
Description: This is a digitally signed message part


Re: q for the C hackers

2003-08-19 Thread Jerry Feldman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Mon, 18 Aug 2003 20:53:01 -0400
Ray Cote [EMAIL PROTECTED] wrote:

 At 8:13 PM -0400 8/18/03, Erik Price wrote:
 However, what is the convention in C?  There seem to be two fine 
 ways of doing it -- using the preprocessor, or the const keyword:
 
 #define NUMBER_OF_UNITS 8
 
 const int NUMBER_OF_UNITS = 8;
 This tends to be the nicer way to do it these days.
 Biggest advantage is that you get type checking with a const which 
 you don't get with a #define.
 Been so long since I used pure C (vs C++) compilers, that I'm not 
 sure whether const ever made it into the C standard, or if it is 
 still a C++ extension. Well supported, though. Works in all the 
 compilers I use.
The difference, in C, is that the const keyword was introduced by the
ANSI 89 standard. Unlike C++, NUMBER_OF_UNITS (const int) is a variable
and may even be altered. In C++, this construct would be a true constant
(as Aaron mentions). 

- -- 
Jerry Feldman [EMAIL PROTECTED]
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/QgoR+wA+1cUGHqkRAljfAJ0ZGX2IQ7ogou/wn6BGs7IDdacRlwCfRFUq
zg4UxBnSHaWGHIY+8LLpg3k=
=5VN8
-END PGP SIGNATURE-
___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Kevin D. Clark

Derek Martin [EMAIL PROTECTED] writes:

 On Mon, Aug 18, 2003 at 08:13:05PM -0400, Erik Price wrote:
  However, what is the convention in C?  There seem to be two fine
  ways of doing it -- using the preprocessor, or the const keyword:
  
  #define NUMBER_OF_UNITS 8
  
  const int NUMBER_OF_UNITS = 8;
 
 Normally, the former way is what you'd use.  The latter construct is
 most often used, in my experience, for function parameters which you
 want to make sure are not modified by the function to which they
 belong.  

This is confused.  Erik wasn't even asking about function parameters.
He just wants to use a constant in his program.

Sure, const carries some meaning when used with function parameters,
but Erik wasn't asking about this.

 I'm not a compiler guru, but I believe references to the #define'd
 macro will cause the compiler to use immediate mode addressing, using
 the value of the macro literally, requiring no additional storage
 beyond what is required to store the opcode and its operands.  Whereas
 the second method allocates storage in the segment of memory
 associated with initialized data that hangs around, so that it can
 contain the constant.

Like you stated in a later post, exactly *what* the compiler does for
these cases is implementation defined.

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Bob Bell
On Tue, Aug 19, 2003 at 02:50:01AM -0400, Aaron Hope [EMAIL PROTECTED] wrote:
On Mon, 2003-08-18 at 20:13, Erik Price wrote:
 However, what is the convention in C?  There seem to be two fine ways 
 of doing it -- using the preprocessor, or the const keyword:
 
 #define NUMBER_OF_UNITS 8
 
 const int NUMBER_OF_UNITS = 8;

Generally, the more the compiler knows, the better it can do it's job,
so I usually prefer the latter.  There are still some places in C (C99
specifically) where you you have no choice but to use macros, like array
declarations.  I believe that C++ const variables can be used wherever a
simple #define can.
   Actually, the following is valid C99:
   const int m = 10;
   int
   foo(int n) {
   char s[n];
   char t[m];
   ...
   }
BTW, Is there a reason why mailman isn't configured to set the 
reply-to header?
   Because we don't want it to.  Can we not go there again?  Convince
your mailer to set Mail-Followup-To, if you'd like (mutt does that).
--
Bob Bell [EMAIL PROTECTED]
-
If the only tool you have is a hammer, you tend to see every
 problem as a nail.
  -- Abraham Maslow
___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Kevin D. Clark

Aaron Hope [EMAIL PROTECTED] writes:

 On Mon, 2003-08-18 at 20:13, Erik Price wrote:
  However, what is the convention in C?  There seem to be two fine ways 
  of doing it -- using the preprocessor, or the const keyword:
  
  #define NUMBER_OF_UNITS 8
  
  const int NUMBER_OF_UNITS = 8;
 
 Generally, the more the compiler knows, the better it can do it's job,
 so I usually prefer the latter.  There are still some places in C (C99
 specifically) where you you have no choice but to use macros, like array
 declarations.  

Another possibility is to use enums, i.e.:


enum { BUFSIZE=512 };

char arr[BUFSIZE];

I use this frequently, and I recommend this.

 I believe that C++ const variables can be used wherever a
 simple #define can.

Well, they can be used for array initialization too.

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Bob Bell
On Tue, Aug 19, 2003 at 09:07:23AM -0400, Kevin D. Clark [EMAIL PROTECTED] wrote:
Another possibility is to use enums, i.e.:

enum { BUFSIZE=512 };

char arr[BUFSIZE];

I use this frequently, and I recommend this.
   One advantage of enum's is that symbolic debuggers can display the
symbolic name, instead of just the numeric value, if the data type is
right.  We do this in the HP-UX kernel.  It even works with bit flags.
It's nice when debugging.
--
Bob Bell [EMAIL PROTECTED]
-
Windows 98: n. minor bug-fix/patch release of 32-bit extensions
 and a graphical shell for a 16-bit patch to an 8-bit operating
 system originally coded for a 4-bit microprocessor, written by a
 2-bit company that can't stand 1 bit of competition.
  -- Author unknown
___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: Reply-To munging (was: q for the C hackers)

2003-08-19 Thread Jeff Macdonald
On Tue, 2003-08-19 at 09:53, [EMAIL PROTECTED] wrote:

   To avoid rehashing, here are the two arguments:
 
 Reply-To Munging Considered Harmful
 http://www.unicom.com/pw/reply-to-harmful.html
 
 Reply-To Munging Considered Useful
 http://www.metasystema.org/essays/reply-to-useful.mhtml

Thank God for Evolution's 'Reply to List' option!

:-)


___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


(no subject)

2003-08-19 Thread Bill Sconce

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: Raw disk i/o

2003-08-19 Thread Jeff Macdonald
On Tue, 2003-08-19 at 03:12, Aaron Hope wrote:
 I think that he's looking for the same raw i/o that oracle likes so
 much:
 http://www.tldp.org/HOWTO/SCSI-2.4-HOWTO/rawdev.html

Yep. I've also seen this reference.

 
 But while you don't have to be writing a filesystem to want this, it's
 still targeted for a pretty select audience.  Have you considered a
 simple O_DIRECT instead? 

I'm running 2.6.0-test3 so I think O_DIRECT may be supported. I'm under
the assumption that RAW i/o came before memory mapped i/o. Seems RAW
uses user space memory while memory mapped uses kernel space memory? Is
that right? I also found a paper that showed that RAW was actually
slower than EXT3 for a database system.

So advantages of RAW:

* data is definitely written to disk when write/pwrite returns (what
about the disk's cache?)
* no extra buffer
* no file system overhead

Disadvantages:

* must read/write in proper block size bytes
* no file system - it is just a stream of bytes


And to use a raw device:

* use raw to associate a block device with a raw device
* open() the raw device
* read/write to it - use seek to move around

Please correct me if I have the wrong idea. I do have Stevens' books and
consider them to be my bibles. :-)

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread David Long
 However, what is the convention in C?  There seem to be two fine ways 
 of doing it -- using the preprocessor, or the const keyword:
 
 #define NUMBER_OF_UNITS 8
 
 const int NUMBER_OF_UNITS = 8;
 
 
 
 I'm just interested in hearing about whether one is more appropriate 
 than the other in some contexts.  Thanks.

I would stick with defines.  More modern languages have the option of
effectively treating a const declaration as an immediate value, but I
do not believe that C can.  However there are times when a declaration
which allocates storage is necessary, as when you need to pass a pointer
to a value.  Also, for strings the C standard requires each literal
string constant to occupy unique read/write storage (in case the code
decides to rewrite part of it).  Therefore allocating a (optionally
const) variable will use less storage than repeated use of a define'd
string constant.  Alternatively most compilers provide an option for
making string constants read-only.

The const type modifier is part of the ANSI/ISO C language standard
(as is void and various other post KR enhancements).

-dl
-- 
David A. Long
JumpShift, LLC

[EMAIL PROTECTED]


___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Reply-to header, yet again (was Re: q for the C hackers)

2003-08-19 Thread Derek Martin
On Tue, Aug 19, 2003 at 02:50:01AM -0400, Aaron Hope wrote:
 BTW, Is there a reason why mailman isn't configured to set the 
 reply-to header?

Yes.  We've had this holy war before, and the (small) majority of list
members were against reply-to.  The logical argument:

Setting the reply-to header changes the behavior of your mailer, such
that it no longer does what it is intended to do when you use the
reply function: reply to the sender.  Setting the reply-to header
makes it impossible for well-behaved mailers to send a private reply
to the sender without manually editing the headers.  Leaving it out
makes it possible for well-behaved mailers to use a list-reply
function to respond to the list, when that is what we want to do, or
failing that to use the group-reply function, which virtually all
mailers have had for centuries now.  Setting reply-to also makes it
impossible to respond to posters who have themselves set the reply-to
header because they NEED it.  

That's the essence of it, but if you haven't heard enough, there's
this:

  http://www.unicom.com/pw/reply-to-harmful.html

People familiar with the argument also know about this:

  http://www.metasystema.org/essays/reply-to-useful.mhtml

In the end, it can be shown that munging reply-to causes some users
genuine damage (such as in the case of the guy who needs to set
reply-to in order to receive mail), whereas not munging it merely
reduces convenience for some people who have sh!tty mailers.
The rest of the world shouldn't be punished for your poor choice of
software...

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.
Replying to it will result in undeliverable mail.
Sorry for the inconvenience.  Thank the spammers.



pgp0.pgp
Description: PGP signature


Python notes - the Millenium - published at last

2003-08-19 Thread Bill Sconce
More excuses than memory leaks in a C++ program... :)
I apologize for the delay in getting my notes onto
the 'net.  At last they're available for browsing
and download.

These notes are exactly what was in the handouts, produced
from the same sources.  (By a Python program, natch).

http://www.in-spec-inc.com/pythontalk.html

Comments welcome.

-Bill


Footnote: incidentally, I've crossed a new horizon since
the talk: using Python for development on Winxx, programming
Excel and Access, pulling the puppets' strings using COM
and ADO.  Not my choice to have to do something so ugly,
but if one MUST Python makes it almost as easy as opening
a file.  It just works (tm).

Add to suggested reading: _Python Programming on Win32_,
Hammond and Robinson, O'Reilly, ISBN 1-56592-621-8.

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: apache serving non-existent pages

2003-08-19 Thread Derek Doucette
The page does not contain any php code, I have just defaulted to the
extension because I will incorporate some code in later.  My virtual host
section of httpd.conf looks as follows:

NameVirtualHost *

VirtualHost *
  ServerName derek.homeunix.org
  DocumentRoot /var/www/html
/VirtualHost

VirtualHost *
  ServerName deucedaily.homeunix.org
  DocumentRoot /var/www/html/html-deuce
/VirtualHost


As you can see very straight forward.  I have since added back in the
html-deuce folder, the new domain DocumentRoot.  I created another file
in there which will not show up.  I get a 404 not found, but it still
thinks it can find the index, which I renamed to index.php.old, as well
as index.html, and that is the only instance of the file on the whole
server, unless there is a temporary cached copy someplace.

Derek Doucette
http://derek.homeunix.org

Derek Martin said:
 On Mon, Aug 18, 2003 at 04:27:23PM -0400, Derek Doucette wrote:
 The page should look like the one at:
 http://derek.homeunix.org/deucedaily.php

 The only difference is with the link at the bottom regarding the
 E-mail.

 Is the index at the correct/preferred URL actually generated by a PHP
 script?  If so, perhaps you could post it...  If not, perhaps you
 could post the contents of the actual file?

 You might also post the virtual host portion of your apache
 configuration, including any alias sections for it, and any directory
 directives too.

 --
 Derek D. Martin
 http://www.pizzashack.org/
 GPG Key ID: 0xDFBEAD02
 -=-=-=-=-
 This message is posted from an invalid address.
 Replying to it will result in undeliverable mail.
 Sorry for the inconvenience.  Thank the spammers.



___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Reply-To munging (was: q for the C hackers)

2003-08-19 Thread bscott
On Tue, 19 Aug 2003, at 2:50am, [EMAIL PROTECTED] wrote:
 BTW, Is there a reason why mailman isn't configured to set the reply-to
 header?

  Some time back, the list took a vote, and more people voted harmful then
useful, and we went with the plurality.

  To avoid rehashing, here are the two arguments:

Reply-To Munging Considered Harmful
http://www.unicom.com/pw/reply-to-harmful.html 

Reply-To Munging Considered Useful
http://www.metasystema.org/essays/reply-to-useful.mhtml 

-- 
Ben Scott [EMAIL PROTECTED]
| The opinions expressed in this message are those of the author and do  |
| not represent the views or policy of any other person or organization. |
| All information is provided without warranty of any kind.  |

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Erik Price


Tom Fogal wrote:

I'm just interested in hearing about whether one is more appropriate 
than the other in some contexts.  Thanks.


Generally, I would use #defines for anything but function parameters.
Passing things as a constant reference (const type val) is a good way to
avoid passing a large value without the overhead of actual passing it.
I understand what you are saying, about passing a reference to something 
rather than passing the thing itself.  My understanding is that this is 
because the value of a reference is a memory address, which is usually 
smaller than say, some large value (please correct me if this is 
incorrect).  But why does it have to have const placed there?  This 
seems like it should prevent the value from being modified in the body 
of the function somehow, but is it required or are you suggesting it as 
good practice?

Unfortunately, references do not exist in C alone (they were introduced in C++)
I seem to be confused about the difference between references and a 
type's address.  Are you saying that

  val

is a reference, and that this is different from the address of 'val'?  I 
thought that this meant the address of 'val'.

Thanks everyone for contributing to this discussion.

Erik

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Kevin D. Clark
Tom Fogal [EMAIL PROTECTED] writes:

 the const int way stores the variable in read only memory, and thus, IMO is a
 waste of memory. Also, it would be required to do a memory lookup when 
 accessing the value.

The value *might* get stored in read-only memory.  The standard
doesn't require this.

[snip]

 Finally, I've never actually heard of 'const' in C. I know that it was
 introduced with C++, although i would not be surprised to see later editions
 of the C standard included it.
 It is not in KR ('the white book'), IIRC.

Unless you're looking at the old testament, I gotta believe its in
there.  const most certainly exists in C.

Regards,

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Tom Fogal
 Tom Fogal wrote:
 
 I'm just interested in hearing about whether one is more appropriate 
 than the other in some contexts.  Thanks.
  
  
  Generally, I would use #defines for anything but function parameters.
  Passing things as a constant reference (const type val) is a good way to
  avoid passing a large value without the overhead of actual passing it.
 
 I understand what you are saying, about passing a reference to something 
 rather than passing the thing itself.  My understanding is that this is 
 because the value of a reference is a memory address, which is usually 
 smaller than say, some large value (please correct me if this is 
 incorrect).  But why does it have to have const placed there?  This 
 seems like it should prevent the value from being modified in the body 
 of the function somehow, but is it required or are you suggesting it as 
 good practice?

The bit about memory addresses instead of some large value is entirely correct.
Practically however, this will only be better when passing a value larger than
the register size of the architecture you are on. For instance, on ix86 linux,
all pointers are 32-bit integers. Thus passing a constant reference to another
integer still means you have to pass an integer to the function, thus saving
nothing.
This is commonly used when you have a large record or object.

The const is purely optional; you could just as easily remember yourself that
'hey, i dont want to change that value in this function' and simply not do it.
The justification i was given for such usage is that someone who is not you
can quickly look at the function header/prototype and see, 'oh, this value is
const, it wont change when i pass it to the function'.
Also, supposedly it prevents you from 'forgetting' you didnt mean to change it,
and doing so on accident. IMHO though, if you can't remember you didn't want
to change a fqn parameter, you're functions are wy to long, or you aren't
cut out for the programming vocation :P

Btw, a similar gain can be obtained via pointers, so C programmers aren't
left out =).

  Unfortunately, references do not exist in C alone (they were introduced in 
 C++)
 
 I seem to be confused about the difference between references and a 
 type's address.  Are you saying that
 
val
 
 is a reference, and that this is different from the address of 'val'?  I 
 thought that this meant the address of 'val'.

Oh yes, this is a source of much confusion. You see, C++ introduced this idea
called a 'reference', which, for all intents and purposes is a pointer, but
you dont have to dereference it as such. thus if i have a procedure that wants
to change its integer parameter to 5, i could do the following in C++:

void change_int(int changeme) { changeme = 5; }

C programmers would flip at such a statement - 'Youll screw everything up! That
makes changeme have whatever is in memory location 5! That could be 
ANYTHING!' etc etc.
Well, thats true. In C, changeme means 'the address of changeme'. In C++, the
changeme could mean EITHER 'the address of changeme' OR 'a reference to 
changeme'. I've never had a good explanation as to how one could tell which
is meant. It seems to me that if its passed as a function parameter, it is a
reference. Within a function, it means 'address of'. Don't quote me on that.

Another CS major concurs with my interpretation, acutally.. perhaps I got it
right...

In any case, when programming in C only you don't need to worry about such
unwarranted complications (although i'm a bit biased in that i dislike C++ :).

 Thanks everyone for contributing to this discussion.

np, my pleasure =)

-tom

 
 Erik
___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Erik Price


Tom Fogal wrote:

The bit about memory addresses instead of some large value is entirely correct.
Practically however, this will only be better when passing a value larger than
the register size of the architecture you are on. For instance, on ix86 linux,
all pointers are 32-bit integers. Thus passing a constant reference to another
integer still means you have to pass an integer to the function, thus saving
nothing.
This is commonly used when you have a large record or object.
Okay, that makes sense.  Fundamentally, there seems to be little 
difference between passing a pointer to an object, and passing the 
address of the variable holding that object's value.  I seem to recall 
that there literally *is* no difference, actually -- a pointer is just 
the address of a variable IIRC.  But I'm glad you confirmed this.

The const is purely optional; you could just as easily remember yourself that
'hey, i dont want to change that value in this function' and simply not do it.
The justification i was given for such usage is that someone who is not you
can quickly look at the function header/prototype and see, 'oh, this value is
const, it wont change when i pass it to the function'.
I had forgotten about the header/prototype.  Yes, it seems desirable to 
use 'const' in any function declaration that doesn't modify the 
parameters, as a way of communicating to others that the parameters will 
not be modified.  I will get in the habit of using 'const' in function 
parameters.

(I don't know C++, but let me take a guess at something -- that, in C++ 
making a passed reference a constant by using 'const' in a function 
declaration doesn't make any assurances that the object which the 
reference points to will not be modified, only that the reference itself 
will not change.  In other words, it is much like passing a 'final' 
reference in Java.)

Btw, a similar gain can be obtained via pointers, so C programmers aren't
left out =).
And this is what I am more used to seeing -- it appears that usually a 
function will be written to accept a pointer, rather than a value's 
address, even if they are the same thing.

is a reference, and that this is different from the address of 'val'?  I 
thought that this meant the address of 'val'.


Oh yes, this is a source of much confusion. You see, C++ introduced this idea
called a 'reference', which, for all intents and purposes is a pointer, but
you dont have to dereference it as such.
I think I'm going to stay away from C++ for the moment, at least until I 
have a better grip on C and Objective-C.  (Coming from a Java 
perspective, Objective-C seems a little more straightforward to me than 
C++, esp since it doesn't seem to have changed any of the rules of C.)

Thanks again Tom and everyone.

Erik

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Apache on RH9 Crashed (Hacked?)

2003-08-19 Thread Gregory P. Bonnette
Ok I finally got access to my machine to assess the damage, I am running RH9,
Kernel 2.4.20-19.9 and Apache 2.0.40-21.3.

Here is the error message I recieved when trying to restard httpd:


Stopping httpd:[  OK  ]
Starting httpd: [Tue Aug 19 17:27:50 2003] [error] VirtualHost _default_:443 --
mixing * ports and non-* ports with a NameVirtualHost address is not supported,
proceeding with undefined results
   [  OK  ]


Im no to great at interpreting this stuff, but I made no changes to my system to
cause this error. I had been running stable for roughly 2 weeks with no problems
and then Apache started delivery 400's instead of serving up pages. Now I find
this... Any ideas?
___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Kevin D. Clark
Tom Fogal [EMAIL PROTECTED] writes:

 The const is purely optional; you could just as easily remember yourself that
 'hey, i dont want to change that value in this function' and simply not do it.
 The justification i was given for such usage is that someone who is not you
 can quickly look at the function header/prototype and see, 'oh, this value is
 const, it wont change when i pass it to the function'.
 Also, supposedly it prevents you from 'forgetting' you didnt mean to change it,
 and doing so on accident. IMHO though, if you can't remember you didn't want
 to change a fqn parameter, you're functions are wy to long, or you aren't
 cut out for the programming vocation :P

(Hmm.  Maybe I'm not cut out for programming...)


I must politely, but strenuously disagree.  const is incredibly
useful.

I can think of this large class library that I had trouble using in
the past, all because the people who implemented it had a bizarre idea
of who owned what memory.  Instead of being able to code to a
well-defined interface (and this involves const), I was told to look
at the implementation of each function/method.  This was tedious,
inconsistant, and when the underlying implementation changed (and it
didoften...), I found myself debugging code into the wee hours.

In a large project, const is invaluable.

[snip]

 Oh yes, this is a source of much confusion. You see, C++ introduced this idea
 called a 'reference', which, for all intents and purposes is a pointer, but
 you dont have to dereference it as such. thus if i have a procedure that wants
 to change its integer parameter to 5, i could do the following in C++:
 
 void change_int(int changeme) { changeme = 5; }
 
 C programmers would flip at such a statement - 'Youll screw everything up! That
 makes changeme have whatever is in memory location 5! That could be 
 ANYTHING!' etc etc.
 Well, thats true. In C, changeme means 'the address of changeme'. In C++, the
 changeme could mean EITHER 'the address of changeme' OR 'a reference to 
 changeme'. I've never had a good explanation as to how one could tell which
 is meant. It seems to me that if its passed as a function parameter, it is a
 reference. Within a function, it means 'address of'. Don't quote me on that.
 
 Another CS major concurs with my interpretation, acutally.. perhaps I got it
 right...

I find this to be a bit confused...

1:  In C++, if a is a reference to b, then a is ANOTHER NAME FOR
b.  THAT'S IT.  No magic here.

2:  C++ references are different from Java references in that it is
not possible/legal to have a null reference.  A lot of people get
hung up on this...

3:  C++ references might be implemented in terms of pointers, but you
shouldn't care about this.


There you go.

--kevin
-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread David Long
 ANSI C allows the implementation to store duplicate strings in the
 same memory location at runtime.
 

I stand corrected.  My claim came from a very old document.  The only
(draft) version of the ISO standard I have at my finger tips says it is
now unspecified.  I think my argument still stands though since it is
likely some compilers will not do this optimization (assuming it is
still unspecified), and probably none will do it across compilation
units.

One more case where the allocation of a const variable is useful though
is when you want to set the values at link time.  You can put all these
*constants* in one C file and link with the version of your choice. 
Especially handy for binary-only distributions.

-dl
-- 
David A. Long
JumpShift, LLC

[EMAIL PROTECTED]


___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


in the MX record??

2003-08-19 Thread Jason Kern
I will be hosting a site for someone who has an exchange server set up 
locally. Mail traffic for the domain needs to end up at that server 
rather than be hosted on my web server (sendmail). Can I just have the 
MX record in DNS set to point to their exchange server? Or does the MX 
record point to my server which redirects via SendMail config?  The 
exchange server has only a dedicated IP address.

Jason Kern



___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: q for the C hackers

2003-08-19 Thread Aaron Hope
On Tue, 2003-08-19 at 08:46, Bob Bell wrote:

 Actually, the following is valid C99:
 const int m = 10;
 int
 foo(int n) {
 char s[n];
 char t[m];
 ...
 }

Yes, C99 supports variable sized arrays, but that's not always what you
want.  They cannot be statically allocated and cannot be initialized. 
Consider the following:

const int m = 10;
int buf[m];
int
foo(int n) {
char s[n] = { 0 };
char t[m];
// code
}

% gcc -std=c99 t.c -o t
t.c:2: error: variable-size type declared outside of any function
t.c: In function `foo':
t.c:5: error: variable-sized object may not be initialized
t.c:5: warning: excess elements in array initializer
t.c:5: warning: (near initialization for `s')

aaron


signature.asc
Description: This is a digitally signed message part


Re: in the MX record??

2003-08-19 Thread Bill Mullen
On Tue, 19 Aug 2003, Jason Kern wrote:

 I will be hosting a site for someone who has an exchange server set up 
 locally. Mail traffic for the domain needs to end up at that server 
 rather than be hosted on my web server (sendmail). Can I just have the 
 MX record in DNS set to point to their exchange server? Or does the MX 
 record point to my server which redirects via SendMail config?  The 
 exchange server has only a dedicated IP address.

As long as their mail server has an IP address that is directly accessible
from the WAN, having the MX record point to it should work. If the target
system has a valid hostname that one can retrieve by doing a reverse
lookup on the IP address, then use that in the MX record - if not, use any
A record name that points to that IP address. CNAMEs should not be used
in MX records.

-- 
Bill Mullen   [EMAIL PROTECTED]   MA, USA   RLU #270075   MDK 8.1  9.0
There are two kinds of people in the world, those who believe there are
two kinds of people in the world and those who don't. - Robert Benchley
___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: in the MX record??

2003-08-19 Thread ken
You could certainly do it either way you outline, but by far the easiest
would be to simply have the MX record point to their mail server.  No
reason not to do it that way -- since it's pretty much the only time that
DNS allows you to separate out a service based on IP, and you might as
well take advantage of it.  (Gee, wouldn't it be handy if there were a
lookup table like DNS for all services?  If DNS has an HTTP port
assigned, go there, otherwise, port 80.  Ah, well...)

-Ken

 I will be hosting a site for someone who has an exchange server set up
 locally. Mail traffic for the domain needs to end up at that server
 rather than be hosted on my web server (sendmail). Can I just have the
 MX record in DNS set to point to their exchange server? Or does the MX
 record point to my server which redirects via SendMail config?  The
 exchange server has only a dedicated IP address.

 Jason Kern




 ___
 gnhlug-discuss mailing list
 [EMAIL PROTECTED]
 http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss



___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


RE: Apache on RH9 Crashed (Hacked?)

2003-08-19 Thread Greg Bonnette
Upon further inspection I found that my system had been hacked. I found
multiple directories 

/tmp/'usernameonmysystem'-orbit (multiple occurances, one for each
username)
/tmp/ssh1kzaah
/tmp/ssh2...

I think I know what orbit is, and I never installed it, but running a
netstat showed multiple connections to files in these directories. Can
anyone ID this root kit so I can begin pinpointing my security hole?
Google has turned up something called MAC_Daddy, but documentation is
limited. Anyone had experience with this?

-Greg

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gregory P.
Bonnette
Sent: Tuesday, August 19, 2003 12:37 PM
To: [EMAIL PROTECTED]
Subject: Apache on RH9 Crashed (Hacked?)

Ok I finally got access to my machine to assess the damage, I am running
RH9,
Kernel 2.4.20-19.9 and Apache 2.0.40-21.3.

Here is the error message I recieved when trying to restard httpd:


Stopping httpd:[  OK  ]
Starting httpd: [Tue Aug 19 17:27:50 2003] [error] VirtualHost
_default_:443 --
mixing * ports and non-* ports with a NameVirtualHost address is not
supported,
proceeding with undefined results
   [  OK  ]


Im no to great at interpreting this stuff, but I made no changes to my
system to
cause this error. I had been running stable for roughly 2 weeks with no
problems
and then Apache started delivery 400's instead of serving up pages. Now
I find
this... Any ideas?
___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


RE: Apache on RH9 Crashed (Hacked?)

2003-08-19 Thread Paul Iadonisi
On Tue, 2003-08-19 at 23:10, Greg Bonnette wrote:
 Upon further inspection I found that my system had been hacked. I found
 multiple directories 
 
 /tmp/'usernameonmysystem'-orbit (multiple occurances, one for each
 username)
 /tmp/ssh1kzaah
 /tmp/ssh2...

  Um, I'm not denying that your system could have been hacked, but these
directories are not the signature of any rootkit I know of.  In fact,
they are quite normal.  The /tmp/username-orbit directories always
appear (and are left behind) when username is running the Gnome
desktop.  Not sure of their exact nature, but they likely have to do
with the ORBit or ORBit2 libraries, which I believe are required by
Gnome.
  The /tmp/ssh* directories are the directories where the socket for
each user's instance of sshd that is running that has agent forwarding
turned on or each instance of ssh-agent that is running on the local
system.

 I think I know what orbit is, and I never installed it, but running a
 netstat showed multiple connections to files in these directories. Can
 anyone ID this root kit so I can begin pinpointing my security hole?
 Google has turned up something called MAC_Daddy, but documentation is
 limited. Anyone had experience with this?

  My search for MAC_Daddy on google doesn't turn up anything resembling
a rootkit.

  So, in sum, you definitely could have been cracked, but I think you
are barking up the wrong tree.  Well, maybe, that is.  You may be
identifying that a user's password or ssh key has been comprimised, but
the evidence doesn't support a rootkit.  At least not yet. ;-)  Grab
chkrootkit from http://www.chkrootkit.org/, build it, and run it as an
initial check.
  One thing that might help us help you determine what's wrong is by
posting the virtual host sections of your /etc/httpd/conf/http.conf, as
the message does look related to something in that area.  Also, do an
'ls -l' on the file to see when it was last modified.  Maybe the
'username' user who is/was logged in is the one who changed it.
-- 
-Paul Iadonisi
 Senior System Administrator
 Red Hat Certified Engineer / Local Linux Lobbyist
 Ever see a penguin fly?  --  Try Linux.
 GPL all the way: Sell services, don't lease secrets

___
gnhlug-discuss mailing list
[EMAIL PROTECTED]
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss