Re: [vox-tech] [C newbie]C program is acting weird...

2002-01-31 Thread ME

On Thu, 31 Jan 2002, Ryan wrote:
> for some reason this is spitting out 3 char responses once in a while, anyone 
> have any ideas? I don't know much C, this is just some code I modified.
> 
> Also, if anyone knows how to get it to include numbers mixed in with the 
> letters i'd like to know how.

This is a test message for responses to coding questions to find limits on
the list.

Which of the two response would be better?
Response 1:
Wht not compute the min and max ranges for "length" by plugging in min and
max values for each point and see why you get 3 chars?

Maybe an array of valid chars with other c functions for size would be
good?

Response 2:
Do you know the range of random(), and the effects of the minimum value of
this on your equations for length and allowance for compatability off
ASCII biased systems?

An array of valid chars allows for expandability in the future to allow
for more valid chars and use of strlen (if you array is null
terminated) would make this code more dynamic.

Response 3:

Trying to make a random password generator for your linux system? Maybe
making a keycode random key generator? There are pre-packaged systems to
do the former, while more cryptography and checksums might be better for
the later, but some thoughts on this:

Why not make an array of "valid chars" and then you can make your code
more portable? (To non ASCII systems for example.) (Also, a function call
to this araay with the c string lib for strlen(chr arry for valid
chars) would provide with a new array size for possible charts to choose
from.)

Why not seed your random() with something like time()?

Why not just multiply the [0,1) ranged random() value by the max range
allowed for the random number?

You know the max possible size of your string,and since only up to 3 chars
are added, why not look to avoid char* and instead try explicit limits to
a char array?


/* terminated with null in case string operations are desired, and
to allow for strlen() computations to work and not count the
null in the length */ 
char validChar[] = 
['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0',0];
int validCharLen = strlen(validChar);

You have: 
> length = MIN_LEN + random() / (RAND_MAX / (MAX_LEN + 2 - MIN_LEN))-1;

Where is RAND_MAX #defined?

so, random range [0,1), order of operations breaks this down to:
length = (4 + ([0,1) / ( 9 / ?RAND_MAX? / (9 + 2 - 4))) - 1
length = (([0,1) / ( 9 / ?RAND_MAX? / 7 )) + 3
length = (0 / 9 / ? / 7) + 3 = [3,?] (We dont know what RAND_MAX is, so
range limits are made too difficult to address here.)

(You should check what random() does and values it produces. I could be
very wrong here, but it has been a while for me.)

Since random() can be zero (I sem to recall, but am not sure right now),
there is risk for zero being divded by the rest (except the +3) leaving
your length only 3.

The above does not even begin to address your RAND_MAX

/* and for your length= computation, consider */
length = MIN_LEN + ((MAX_LEN - MIN_LEN)*int(random(time(;

/* and for the for loop, what about: */
 string[i] = 'a' + validChar[(int(random(time()))*validCharLen)];

You could change a lot in your code depending upon the intention.

If this is determined to be for a class, I will not be answering any more
questions for you. 

Response 4:
I did not want to go into more detail than the above.

What is considered acceptable onthe list for answers to coding problems?

-ME

-BEGIN GEEK CODE BLOCK-
Version: 3.12
GCS/CM$/IT$/LS$/S/O$ !d--(++) !s !a+++(-) C++$() U$(+$) P+$>+++ 
L+++$(++) E W+++$(+) N+ o K w+$>++>+++ O-@ M+$ V-$>- !PS !PE Y+ !PGP
t@-(++) 5+@ X@ R- tv- b++ DI+++ D+ G--@ e+>++> h(++)>+ r*>? z?
--END GEEK CODE BLOCK--
decode: http://www.ebb.org/ungeek/ about: http://www.geekcode.com/geek.html

> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> 
> #include "version.h"
> 
> #define SESSION_TIMEOUT 20
> 
> #define MAX_RESPONSE 200
> #define MAX_REQUEST 100
> 
> #define MIN_LEN 4
> #define MAX_LEN 9
> 
> char *randusername()
> {
> char *string;
> int i, length;
> // randomly choose a length betweem MIN_LEN and MAX_LEN
> length = MIN_LEN + random() / (RAND_MAX / (MAX_LEN + 2 - MIN_LEN))-1;
> if (string = malloc(length + 2), string == NULL)
> return NULL;
> for (i = 0; i < length; i++)
> // does your head hurt yet?
> string[i] = 'a' + random() / (RAND_MAX / ('z' + 1 - 'a'));
> // zero terminate!
> i++;
> string[i] = '\0';
> return string;
> }




___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] [C newbie]C program is acting weird...

2002-01-31 Thread nbs

On Thu, Jan 31, 2002 at 11:10:48PM -0800, Mark K. Kim wrote:
> What do you *want* it to do?
> 
> Including numbers will need some math trickery.  The place with 'z' and
> 'a' is where it's picking a letter between 'a' and 'z', but since numbers
> aren't in a sequential order in the ASCII system, you can do something
> like expanding the range and 'if'-ing the range for a letter or number.

Or use that nifty "?" operator that I never use ;) ;)

-bill!
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] [C newbie]C program is acting weird...

2002-01-31 Thread Ryan

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thursday, January 31 2002 10:54 pm, Ryan wrote:

> for (i = 0; i < length; i++)
> // does your head hurt yet?
> string[i] = 'a' + random() / (RAND_MAX / ('z' + 1 - 'a'));
> // zero terminate!
> i++;
> string[i] = '\0';
> return string;

This was breaking things, old stuff was getting left at the end to break 
things.

If anyone cares, i'm modifing a fibbing ident server to give random responses.

- -- 
No Microsoft products were used in any way for the creation of this message.
PGP Public key at http://mother.com/~ryan/ryan_at_mother_dot_com.asc
It is also on the servers: Key ID 0x72177BC7
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8WkOqEd9E83IXe8cRAuq9AJ9+J0jvXSQ3lmdiSK3/vEc3zWvUPgCgk65c
3TlvBjrpUhroIf/kKZpv6b8=
=Sx3e
-END PGP SIGNATURE-
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] [C newbie]C program is acting weird...

2002-01-31 Thread Jeff Newmiller

On Thu, 31 Jan 2002, Ryan wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> for some reason this is spitting out 3 char responses once in a while, anyone 
> have any ideas? I don't know much C, this is just some code I modified.
> 
> Also, if anyone knows how to get it to include numbers mixed in with the 
> letters i'd like to know how.

Change the loop statement to a block of code that assigns a number from,
say, 0 to 35, to string[i].  Then use an if statement or ?: operator to
add either 'a' or ('0'-26) to that number depending whether it is less
than 26 or not.

> - --
> 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> 
> #include "version.h"
> 
> #define SESSION_TIMEOUT 20
> 
> #define MAX_RESPONSE 200
> #define MAX_REQUEST 100
> 
> #define MIN_LEN 4
> #define MAX_LEN 9
> 
> char *randusername()
> {
> char *string;

You have not initialized space to put the characters that this string
points to, so you are putting them in, ah, unpredictable locations in
memory.  The behavior of the program after you write to string[0] is
undefined. I would recommend "static char string[ MAX_LEN+1 ]".

> int i, length;
> // randomly choose a length betweem MIN_LEN and MAX_LEN
> length = MIN_LEN + random() / (RAND_MAX / (MAX_LEN + 2 - MIN_LEN))-1;

random() may return zero.  length = 4 + stuff_that_could_be_zero - 1,
which can be looked at as length = 3 + stuff_that_could_be_zero.

> if (string = malloc(length + 2), string == NULL)
> return NULL;
> for (i = 0; i < length; i++)
> // does your head hurt yet?
> string[i] = 'a' + random() / (RAND_MAX / ('z' + 1 - 'a'));

So, if length == 3, after this loop i == 3 and string[0] through
string[2] are initialized ...

> // zero terminate!
> i++;

... now i is 4 ...

> string[i] = '\0';

and if string[0] through string[2] are 'a', 'b', and 'c', then who knows
what string[3] is because it never got initialized, but now 
string[4] == '\0' and we have a four character string with a garbage
character just before the null character.  Just to make things
interesting, this garbage character could be a null character!

> return string;
> }

I highly recommend learning how to use gdb or ddd to trace through things
like this.

---
Jeff NewmillerThe .   .  Go Live...
DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...2k
---


___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] [C newbie]C program is acting weird...

2002-01-31 Thread Mark K. Kim

What do you *want* it to do?

Including numbers will need some math trickery.  The place with 'z' and
'a' is where it's picking a letter between 'a' and 'z', but since numbers
aren't in a sequential order in the ASCII system, you can do something
like expanding the range and 'if'-ing the range for a letter or number.

-Mark

On Thu, 31 Jan 2002, Ryan wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> for some reason this is spitting out 3 char responses once in a while, anyone
> have any ideas? I don't know much C, this is just some code I modified.
>
> Also, if anyone knows how to get it to include numbers mixed in with the
> letters i'd like to know how.
> - --
>
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
>
> #include "version.h"
>
> #define SESSION_TIMEOUT 20
>
> #define MAX_RESPONSE 200
> #define MAX_REQUEST 100
>
> #define MIN_LEN 4
> #define MAX_LEN 9
>
> char *randusername()
> {
> char *string;
> int i, length;
> // randomly choose a length betweem MIN_LEN and MAX_LEN
> length = MIN_LEN + random() / (RAND_MAX / (MAX_LEN + 2 - MIN_LEN))-1;
> if (string = malloc(length + 2), string == NULL)
> return NULL;
> for (i = 0; i < length; i++)
> // does your head hurt yet?
> string[i] = 'a' + random() / (RAND_MAX / ('z' + 1 - 'a'));
> // zero terminate!
> i++;
> string[i] = '\0';
> return string;
> }
> - --
> No Microsoft products were used in any way for the creation of this message.
> PGP Public key at http://mother.com/~ryan/ryan_at_mother_dot_com.asc
> It is also on the servers: Key ID 0x72177BC7
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
>
> iD8DBQE8WjuYEd9E83IXe8cRArkBAJ9KZAmEZrqQbbBWY0MBv6EFid9ZRACfXKDc
> G2u947jK74bVhkLKjjEPsIg=
> =kHSN
> -END PGP SIGNATURE-
> ___
> vox-tech mailing list
> [EMAIL PROTECTED]
> http://lists.lugod.org/mailman/listinfo/vox-tech
>

--
Mark K. Kim
http://www.cbreak.org/mark/
PGP key available upon request.

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



[vox-tech] [C newbie]C program is acting weird...

2002-01-31 Thread Ryan

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

for some reason this is spitting out 3 char responses once in a while, anyone 
have any ideas? I don't know much C, this is just some code I modified.

Also, if anyone knows how to get it to include numbers mixed in with the 
letters i'd like to know how.
- --

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#include "version.h"

#define SESSION_TIMEOUT 20

#define MAX_RESPONSE 200
#define MAX_REQUEST 100

#define MIN_LEN 4
#define MAX_LEN 9

char *randusername()
{
char *string;
int i, length;
// randomly choose a length betweem MIN_LEN and MAX_LEN
length = MIN_LEN + random() / (RAND_MAX / (MAX_LEN + 2 - MIN_LEN))-1;
if (string = malloc(length + 2), string == NULL)
return NULL;
for (i = 0; i < length; i++)
// does your head hurt yet?
string[i] = 'a' + random() / (RAND_MAX / ('z' + 1 - 'a'));
// zero terminate!
i++;
string[i] = '\0';
return string;
}
- --
No Microsoft products were used in any way for the creation of this message.
PGP Public key at http://mother.com/~ryan/ryan_at_mother_dot_com.asc
It is also on the servers: Key ID 0x72177BC7
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8WjuYEd9E83IXe8cRArkBAJ9KZAmEZrqQbbBWY0MBv6EFid9ZRACfXKDc
G2u947jK74bVhkLKjjEPsIg=
=kHSN
-END PGP SIGNATURE-
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] mutt mailbox sorting

2002-01-31 Thread Bill Broadley

> Don't worry about that. Procmail is written in lean C with years of tuning.
> It is EXTREMELY fast and low in overhead.

It's very robust as well, it does the absolute best thing possible in
most any case.  It handles out of memory, out of file descriptors, out
of disk space, no permission with various warnings, leaving something
in the spool, saving it to a temporary file, or worst case returning
a fatal error if nothing can be done.

-- 
Bill Broadley
Mathematics/Institute of Theoretical Dynamics
UC Davis
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] mutt mailbox sorting

2002-01-31 Thread Bill Broadley

On Thu, Jan 31, 2002 at 08:59:41PM -0800, Gabriel Rosa wrote:
> On Thu, 31 Jan 2002, Peter Jay Salzman wrote:
> 
> > you just described the basic, most fundamental use of procmail.   :)
> >
> 
> Ya, I think my best bet is picking up some procmail.
> What I'm concerned about is that if i get a bizillion messages a day,
> procmail will run a bizillion times a day.
> 
> I wanted a read-time solution. :)

Procmail can be run on your incoming spool at login or whatever.


-- 
Bill Broadley
Mathematics/Institute of Theoretical Dynamics
UC Davis
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] mutt mailbox sorting

2002-01-31 Thread Henry House

On Thu, Jan 31, 2002 at 08:59:41PM -0800, Gabriel Rosa wrote:
> On Thu, 31 Jan 2002, Peter Jay Salzman wrote:
> > you just described the basic, most fundamental use of procmail.   :)
> Ya, I think my best bet is picking up some procmail.
> What I'm concerned about is that if i get a bizillion messages a day,
> procmail will run a bizillion times a day.

Don't worry about that. Procmail is written in lean C with years of tuning.
It is EXTREMELY fast and low in overhead.

-- 
Henry House
The attached file is a digital signature. See 
for information.  My OpenPGP key: .



msg01383/pgp0.pgp
Description: PGP signature


Re: [vox-tech] mutt mailbox sorting

2002-01-31 Thread Stephen M. Helms

Peter Jay Salzman wrote:

> hmmm.  you may have this one backwards.
>
> consider -- suppose lkml has a light day, and you only get 500 messages
> from the list.  but you can't check your email for some reason.  you get
> home and now you want to read your email.
>
> which do you think would be more frustrating -- sorting on the fly or
> already sorted?   either way, sorting needs to be done.  would you
> rather watch the sorting being done or would you rather not watch it?
> :-)

I would rather have my computer say, "Hello Stephen, Would you like me to read
your mail?"

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] mutt mailbox sorting

2002-01-31 Thread Peter Jay Salzman

hmmm.  you may have this one backwards.

consider -- suppose lkml has a light day, and you only get 500 messages
from the list.  but you can't check your email for some reason.  you get
home and now you want to read your email.

which do you think would be more frustrating -- sorting on the fly or
already sorted?   either way, sorting needs to be done.  would you
rather watch the sorting being done or would you rather not watch it?
:-)

pete


begin Gabriel Rosa <[EMAIL PROTECTED]> 
> On Thu, 31 Jan 2002, Peter Jay Salzman wrote:
> 
> > you just described the basic, most fundamental use of procmail.   :)
> >
> 
> Ya, I think my best bet is picking up some procmail.
> What I'm concerned about is that if i get a bizillion messages a day,
> procmail will run a bizillion times a day.
> 
> I wanted a read-time solution. :)
> 
> -Gabe
> 
> ___
> vox-tech mailing list
> [EMAIL PROTECTED]
> http://lists.lugod.org/mailman/listinfo/vox-tech

-- 
The mathematics [of physics] has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's `Fearful Symmetry'

PGP Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] mutt mailbox sorting

2002-01-31 Thread Gabriel Rosa

On Thu, 31 Jan 2002, Peter Jay Salzman wrote:

> you just described the basic, most fundamental use of procmail.   :)
>

Ya, I think my best bet is picking up some procmail.
What I'm concerned about is that if i get a bizillion messages a day,
procmail will run a bizillion times a day.

I wanted a read-time solution. :)

-Gabe

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] mutt mailbox sorting

2002-01-31 Thread Peter Jay Salzman

begin Gabriel Rosa <[EMAIL PROTECTED]> 
> 
> Hey all,
> 
> looking thru man muttrc, I notice that mutt allows you to move messages
> to different mailboxes after they're read. Is there a way to make it pre-sort
> messages to different mailboxes?
> 
> For example, I'd like to receive all vox-tech mail to one mailbox, all
> linux-kernel to another, and leave the inbox for messages directly addressed
> to me. That way if I don't read my mail for 3 days, i can just trash the
> mailing list boxes, and be done with it.
 
you just described the basic, most fundamental use of procmail.   :)

> also, is there a 'folder list' type menu, where I could pick which mailbox
> I want to read?

look at .

pete

-- 
The mathematics [of physics] has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's `Fearful Symmetry'

PGP Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



[vox-tech] mutt mailbox sorting

2002-01-31 Thread Gabriel Rosa


Hey all,

looking thru man muttrc, I notice that mutt allows you to move messages
to different mailboxes after they're read. Is there a way to make it pre-sort
messages to different mailboxes?

For example, I'd like to receive all vox-tech mail to one mailbox, all
linux-kernel to another, and leave the inbox for messages directly addressed
to me. That way if I don't read my mail for 3 days, i can just trash the
mailing list boxes, and be done with it.

also, is there a 'folder list' type menu, where I could pick which mailbox
I want to read?

thanks,

-Gabe

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] Safe to run 486dx2 w/o fan?

2002-01-31 Thread Ryan

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

http://support.intel.com/support/processors/embedded/intel486/8005.htm
"The Intel 486DX2® microprocessor is specified for operation when Tc (The 
Case Temperature) is within range of 0 degrees C to 85 Degrees C. Tc may be 
measured in any environment to determine whether the Intel486DX2 
microprocessor is within specified operating range. The case temperature 
should be measured at the center of the top surface opposite the pins."

That's what, 150 F?


On Wednesday, January 30 2002 11:41 pm, Jeff Newmiller wrote:
> On Wed, 30 Jan 2002, Bill Broadley wrote:
> > On Tue, Jan 29, 2002 at 06:52:58AM -0800, Ryan wrote:
> > > I just took the fan off my 486DX2 66 tu use on my gfx card (the card's
> > > fan developed an extreamly annoying buzz)
> > >
> > > Think the 486 will fry if I just slap some thermal grease and a
> > > heatsink on it?
> >
> > The specs are available afaik, just get a temp probe and measure
> > it yourself.  Airflow over the fins from the case could easily
> > make a factor of 10 difference.
>
> I don't think package surface temperature is useful for identifying
> problems... it can be 10 or 20 degrees C different than die temperature.
>
> ---
> Jeff NewmillerThe .   .  Go Live...
> DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...2k
> ---
>
> ___
> vox-tech mailing list
> [EMAIL PROTECTED]
> http://lists.lugod.org/mailman/listinfo/vox-tech

- -- 
No Microsoft products were used in any way for the creation of this message.
PGP Public key at http://mother.com/~ryan/ryan_at_mother_dot_com.asc
It is also on the servers: Key ID 0x72177BC7
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8WQCyEd9E83IXe8cRAq92AJwN9A8CZbnuBz+gX7M1tHxvK/rIgACfXFtm
3y8qKaHDi0SkWzD5n2UCDd4=
=imh+
-END PGP SIGNATURE-
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech