--------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2P00012 Date: 01/31/98 From: MICHAEL STAPLETON Time: 3:122am \/To: TOM TORFS (Read 2 times) Subj: Re: Memory exchange -=> Quoting Tom Torfs to Ahmad Al-Dousary <=- Hi Tom, AA> I was wondering if it was possible to exchange two areas of AA> memory without the use of an auxiliary storage in C.. TT> For integral types only: a ^= b ^= a ^= b; Didn't your mother ever teach you about sequence points? :) We had a long sequence points thread triggered by the above construction about a year ago. Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This tagline is encrypted --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2P00013 Date: 01/31/98 From: MICHAEL STAPLETON Time: 3:452am \/To: ROGER SCUDDER (Read 2 times) Subj: Re: Pointer To A String -=> On 09 Feb 98 13:27:42 you wrote to me <=- Hi Roger, RS>> I like to write utilities for local BBS Sysops in exchange for RS>> high access privileges. When I do I always try to have them RS>> write the docs with me acting as editor. The docs get passed RS>> back and forth until we are both satisfied with them. So far it RS>> has worked out quite well. MS> This sounds pretty good, but next time, try to get most of the docs MS> written *before* you start coding. This will eliminate many sources MS> of ambiguity in the design process. RS> Hmmm... that's quite a different approach. I'd really like to try RS> that, unfortunately it seems that the non programmers I have dealt RS> with need a little kick start. Sure, but that's the beauty of this radical approach. :) You put the ball right in their court. Instead of them hassling you at the end of the project with "is the program ready yet", you can hassle them at the start of the project about the docs! If you want to be really clever, don't let them know that they're actually designing the program. Then you can amaze them with your brilliance when you code the program in lightning speed. :) RS> They seem to have trouble writing down what they want a program RS> to be.. in more than say... two or three sentences... ;-) Typical bloody users, someone should shoot the lot of 'em. :) Getting an actual program spec out of users is always a major problem in program development, that's why God invented Systems Analysts. :) As an amateur programmer I don't have very much experience in writing programs to other people's specs, but I have written a few programs for money & the initial design phase was always the most painful. Generally people don't really know what they want, and the ones that do know may not be capable of expressing themselves with the clarity that a programmer would prefer. Once the design is decided & you've commenced coding, they will come up with great ideas to add to the program, or even radical changes when the coding is almost complete. This practice should be discouraged at all costs! :) Only someone who knows about programming in general, and preferably the API / environment that you're using could be competent to change the program design in midstream. Generally, end users do not fall into this category. :) Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... main(){int i=4;while(i--)putchar(101+i*(4+i*(5-3*i)));return 0;} --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2P00014 Date: 01/30/98 From: MICHAEL STAPLETON Time: 1:452am \/To: ROGER SCUDDER (Read 2 times) Subj: Re: Precede -=> On 09 Feb 98 13:31:40 you wrote to me <=- Hi Roger, RS> In order to write this message I must start by fessing up to RS> something. That being that I never tried your Precede game. RS> You may have noticed that I changed the subject when ever you RS> brought it up. Yeah, I noticed, you naughty boy. :) Actually, I must admit that I haven't played it much since writing it and my "precedence awareness" is slipping back to its previous level. :) RS> Well about a month ago I finally got around to compiling the RS> code... which compiled without errors. The problem came in RS> the running. I loaded an ANSI driver ( Michael J. Mefford's RS> ANSI.COM which is much more flexible than ANSI.SYS) and even RS> tested other ANSI gfx files to make sure it was loaded RS> correctly, but the escapes in Precede don't seem to work RS> correct on my PC. My first thought was that it is an Amiga RS> porting issue. Can you offer any insight into this? Oh, bugger! Has anyone else tried to use Precede? Most of the ANSI stuff is isolated at the top of the program (lines 33-58) and it should work on any ANSI terminal. However, there is also a little bit of ANSI in main(). From precede.c Lines 331: /* Clear screen & turn off cursor */ printf(ESC"c"CSI"0 p"); and on Line 345: printf(CSI"1 p""\n"); which should turn the cursor back on. ESCc is "Reset to initial state" & it is standard ANSI, however the cursor off & on sequences are Amiga-private. Sorry about that! So how *do* I turn the cursor off & on in your environment (preferably using ANSI sequences)? RS> I think the game is a great idea that could use a little more RS> exposure. Cool! I hope Bob puts it into Snippets, once we have this cursor business sorted out. (Are you reading this Bob? :) Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This tagline is encrypted --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2P00015 Date: 01/30/98 From: MICHAEL STAPLETON Time: 1:492am \/To: LESLIE SATENSTEIN (Read 2 times) Subj: Re: 'C' & 'C++' -=> Quoting Leslie Satenstein to Adam Majer <=- Hi Leslie, AM> I guess you're right. But many C programmers will simply not AM> understand the C++ jargon. I guess that's another reason. I don't do C++, but I don't find it hard to understand OOP & C++ jargon, although I do find the C++ class syntax a little verbose. Still, I prefer to keep things seperate, mainly to avoid confusing the newbies. LS> If you could learn C, you certainly could learn C++. In fact, as Java LS> takes hold, look for a dwindling set of both C and C++ programmers. I certainly hope not! LS> I know several languages, and each has it's peculiarities, but each LS> has ways to express the same ideas for loops, case statements etc... In programming languages, as in natural languages, there are several different families of related languages. Languages in different families are generally quite different from one another in many ways, although there are some borderline cases. C is in the largest family, the procedural languages. This family also includes COBOL, FORTRAN, BASIC, PL/I, Algol, Pascal, REXX, etc. It also includes the stack-based languages like Forth and PostScript, although it may be useful to consider them as a sub-family. Languages that are not procedural include APL, Prolog and some database query languages. It is unusual to write iterative loops in these languages: Prolog & the query languages use pattern matching instead of explicit iteration, and APL does everything with vectors. Certainly it's possible to write compilers & interpreters for these languages in C, but it may not be possible to use their techniques directly in C. Anyway, this message is going beyond the scope of this echo & this author, so I'd better leave it there. :) I'm sure that Jonathon P could tell you more, and correct any errors in the above account. Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This tagline is encrypted --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2P00016 Date: 01/30/98 From: MICHAEL STAPLETON Time: 7:572am \/To: BOB STOUT (Read 2 times) Subj: Re: CRC model -=> On 08 Feb 98 17:57:38 you wrote to me <=- Hi Bob, > The original program requires the CRC parameters to be hard-coded > into the source, but I've fixed it up to read the CRC parameters > from files, using Auke's CFG routines. Do you want the new code for > Snippets? RS> Sure - thanks! Great! I'll put it in this packet. Please let me know if you don't get it. > Unfortunately, most of the sample parameter sets given in the text > are inverted in some way, or just plain wrong. (Or maybe the > program author got his code backwards?) Here are the correct > parameter sets: I take it that you don't have any other CRC algorithms / parameter sets to add to the collection. RS> Great - thanks for the update! My pleasure! Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This tagline is encrypted --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2P00017 Date: 01/30/98 From: MICHAEL STAPLETON Time: 8:132am \/To: TIKA CARR (Read 2 times) Subj: Re: software testing -=> On 08 Feb 98 19:40:00 you wrote to me <=- Hi Tika, TC> I know* I'll get a slap on the hand from the moderator but I TC> have to say I got a very good laugh out of that post! :D If the TC> effect is right, then we could all be laughing instead of TC> tearing our hair out every time our programs crash. ;) Thanks, but you should include "thankyou" message as part of a legitimate message if you want to avoid annoying the moderator. :) Like this: /* * K N I T O U R * * Chess Knight's tour * * Written by M. Stapleton of Graphic Bits, 1995 * Converted to C Jun 3 1997 * Public Domain */ #include #include /* Compile-time output style options */ #define COLOUR 1 #define SPINNER 2 #define HOME 4 /* #define STYLE (COLOUR | SPINNER | HOME) */ #define STYLE (COLOUR) #define ESC "\x1b" /* List of legal knight moves */ #define MNUM 8 int mlist[MNUM][2] = { {-2, -1}, {-2, 1}, {-1, -2}, {-1, 2}, {1, -2}, {1, 2}, {2, -1}, {2, 1} }; int side, ssq, maxlen, *board; /* 2D indexing of allocated array */ #define brd(xx, yy) (board[(xx) + side*(yy)]) void CheckPath(int x, int y, int plen); void PutPath(int plen); #if STYLE & SPINNER void spin(void); #endif int main(int argc, char *argv[]) { int x, y, s1; if (argc > 1) side = atoi(argv[1]); if (side < 3) side = 5; ssq = side * side; if (!(board = calloc(ssq, sizeof(int)))) return EXIT_FAILURE; printf("\f%d x %d Knight's tour\n", side, side); maxlen = ssq - side; /* Max path length so far */ s1 = side / 2; for (y = 0; y < s1; y++) for (x = y; x < s1; x++) CheckPath(x, y, 0); free(board); return EXIT_SUCCESS; } /* Determine if move is valid */ #define GoodMove(xx, yy) ((0 <= xx) && (xx < side) \ && (0 <= yy) && (yy < side) && (brd(xx, yy) == 0)) /* Check next move down the path */ void CheckPath(int x, int y, int plen) { int i, nx, ny; /* Make move */ brd(x, y) = ++plen; if (plen == ssq) { PutPath(plen); } else { /* Check all possible next moves */ for (i = 0; i < MNUM; i++) { nx = x + mlist[i][0]; ny = y + mlist[i][1]; if (GoodMove(nx, ny)) CheckPath(nx, ny, plen); else PutPath(plen); } } /* Clear move */ brd(x, y) = 0; return; } /* Display the path */ void PutPath(int plen) { int x, y, m; if (plen > maxlen || plen == ssq) { #if STYLE & HOME printf(ESC "[H\n"); #endif maxlen = plen; printf("\n%2d:\n\n", plen); for (y = 0; y < side; y++) { for (x = 0; x < side; x++) { #if STYLE & COLOUR /* Checker background colour */ printf(ESC "[4%dm", (x + y) & 1 ? 0 : 7); #endif if (m = brd(x, y)) printf("%2d ", m); else printf("%s ", ".."); } #if STYLE & COLOUR printf(ESC "[40m\n"); #else printf("\n"); #endif } printf("\n"); } #if STYLE & SPINNER else spin(); #endif } #if STYLE & SPINNER #define SPIN (sizeof spinner -1) #define SLOWDOWN 4096 void spin() { static int k = 0, scount = 0; char spinner[] = "|/-\\"; if (++k == SLOWDOWN) { printf("\r%c", spinner[scount++]); scount %= SPIN; k = 0; } } #endif You might need to modify some of the ANSI stuff for your system. Michael Stapleton of Graphic Bits. * AmyBW v2.10 * ... This tagline is encrypted --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2P00018 Date: 01/30/98 From: MICHAEL STAPLETON Time: 7:522am \/To: ALL (Read 2 times) Subj: CrcModel [01/12] >>>>>>>>>> CSplit: Version 2.2 >>>>>>>>>> >>>>>>>>>> CSplit: Begin part 1/12 >>>>>>>>>> >>>>>>>>>> CSplit: Begin file CrcModel.Txt >>>>>>>>>> 15. A Parameterized Model For CRC Algorithms -------------------------------------------- NAME: This is a name given to the algorithm. A string value. WIDTH: This is the width of the algorithm expressed in bits. This is one less than the width of the Poly. POLY: This parameter is the poly. This is a binary value that should be specified as a hexadecimal number. The top bit of the poly should be omitted. For example, if the poly is 10110, you should specify 06. An important aspect of this parameter is that it represents the unreflected poly; the bottom bit of this parameter is always the LSB of the divisor during the division regardless of whether the algorithm being modelled is reflected. INIT: This parameter specifies the initial value of the register when the algorithm starts. This is the value that is to be assigned to the register in the direct table algorithm. In the table algorithm, we may think of the register always commencing with the value zero, and this value being XORed into the register after the N'th bit iteration. This parameter should be specified as a hexadecimal number. REFIN: This is a boolean parameter. If it is FALSE, input bytes are processed with bit 7 being treated as the most significant bit (MSB) and bit 0 being treated as the least significant bit. If this parameter is FALSE, each byte is reflected before being processed. REFOUT: This is a boolean parameter. If it is set to FALSE, the final value in the register is fed into the XOROUT stage directly, otherwise, if this parameter is TRUE, the final register value is reflected first. XOROUT: This is a WIDTH bit wide value that should be specified as a hexadecimal number. It is XORed to the final register value (after the REFOUT) stage before the value is returned as the official checksum. CHECK: This field is not strictly part of the definition, and, in the event of an inconsistency between this field and the other field, the other fields take precedence. This field is a check value that can be used as a weak validator of implementations of the algorithm. The field contains the checksum obtained when the ASCII string "123456789" is fed through the specified algorithm (i.e. 313233... (hexadecimal)). With these parameters defined, the model can now be used to specify a particular CRC algorithm exactly. Here is an example specification for a popular form of the CRC-16 algorithm. Name : "CRC-16" Width : 16 Poly : 8005 Init : 0000 RefIn : True RefOut : True XorOut : 0000 Check : BB3D 16. A Catalog of Parameter Sets for Standards --------------------------------------------- At this point, I would like to give a list of the specifications for commonly used CRC algorithms. However, most of the algorithms that I have come into contact with so far are specified in such a vague way that this has not been possible. What I can provide is a list of polys for various CRC standards I have heard of: X25 standard : 1021 [CRC-CCITT, ADCCP, SDLC/HDLC] X25 reversed : 0811 CRC16 standard : 8005 CRC16 reversed : 4003 [LHA] CRC32 : 04C11DB7 [PKZIP, AUTODIN II, Ethernet, FDDI] I would be interested in hearing from anyone out there who can tie down the complete set of model parameters for any of these standards. However, a program that was kicking around seemed to imply the following specifications. Can anyone confirm or deny them? Name : "CRC-16/CITT" Width : 16 Poly : 1021 >>>>>>>>>> CSplit: End part 1/12 crc: 5810 >>>>>>>>>> --- AdeptXBBS v1.11z (FREEWare/2) * Origin: Mach One BBS (3:713/615) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F2P00019 Date: 01/30/98 From: MICHAEL STAPLETON Time: 7:522am \/To: ALL (Read 2 times) Subj: CrcModel [02/12] >>>>>>>>>> CSplit: Version 2.2 >>>>>>>>>> >>>>>>>>>> CSplit: Begin part 2/12 >>>>>>>>>> Init : FFFF RefIn : False RefOut : False XorOut : 0000 Check : 29b1 Name : "XMODEM" Width : 16 Poly : 8408 Init : 0000 RefIn : True RefOut : True XorOut : 0000 Check : 0c73 Name : "ARC" Width : 16 Poly : 8005 Init : 0000 RefIn : True RefOut : True XorOut : 0000 Check : BB3D Here is the specification for the CRC-32 algorithm which is reportedly used in PKZip, AUTODIN II, Ethernet, and FDDI. Name : "CRC-32" Width : 32 Poly : 04C11DB7 Init : FFFFFFFF RefIn : True RefOut : True XorOut : FFFFFFFF Check : CBF43926 >>>>>>>>>> CSplit: End file CrcModel.Txt >>>>>>>>>> >>>>>>>>>> CSplit: Begin file Cfg.H >>>>>>>>>> /* +++Date last modified: 17-Nov-1995 */ /* \ \ ======================================================================= CFG.h Configuration file handler. A. Reitsma, Delft, The Netherlands. v1.00 94-07-09 Public Domain.