Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Message Mgmt Utility

Reply
Thread Tools

Message Mgmt Utility

 
 
Tennis
Guest
Posts: n/a
 
      01-07-2005
Hi,

Does anyone know of a utility that automatically manages the message
format, labeling and numbering of messages during collaborative program
development?

In the example below, the values "foo-001", "foo-002" would be
auto-generated and managed by the utility:

if ( problem == FILE_IO) {
printf("foo-001 File IO failed\n");
}

if ( problem == FILE_MISSING) {
printf("foo-002 File missing!\n");
}

The object, of course, is to keep the programmer from manually creating
and managing the values.

TIA,
-Tennis

 
Reply With Quote
 
 
 
 
Allin Cottrell
Guest
Posts: n/a
 
      01-08-2005
Tennis wrote:
> Hi,
>
> Does anyone know of a utility that automatically manages the message
> format, labeling and numbering of messages during collaborative program
> development?
>
> In the example below, the values "foo-001", "foo-002" would be
> auto-generated and managed by the utility:
>
> if ( problem == FILE_IO) {
> printf("foo-001 File IO failed\n");
> }
>
> if ( problem == FILE_MISSING) {
> printf("foo-002 File missing!\n");
> }
>
> The object, of course, is to keep the programmer from manually creating
> and managing the values.


In C, you may want to consider the __FILE__ and __LINE__ macros.
Quoting the gcc documentation:

__FILE__ and __LINE__ are useful in generating an error message to
report an inconsistency detected by the program; the message can
state the source line at which the inconsistency was detected.
For example,


fprintf (stderr, "Internal error: "
"negative string length "
"%d at %s, line %d.",
length, __FILE__, __LINE__);

Allin Cottrell

 
Reply With Quote
 
 
 
 
Thad Smith
Guest
Posts: n/a
 
      01-08-2005
Tennis wrote:

> Does anyone know of a utility that automatically manages the message
> format, labeling and numbering of messages during collaborative program
> development?
>
> In the example below, the values "foo-001", "foo-002" would be
> auto-generated and managed by the utility:
>
> if ( problem == FILE_IO) {
> printf("foo-001 File IO failed\n");
> }
>
> if ( problem == FILE_MISSING) {
> printf("foo-002 File missing!\n");
> }
>
> The object, of course, is to keep the programmer from manually creating
> and managing the values.


Depending on what you need, you may be able to use fairly
straight-forward C coding:

problist.h"
PROB(FILE_IO, "File IO Failed"),
PROB(FILE_MISSING, "File missing!"),
....

code.c:
/* Assign error numbers to list */
#define PROB(name,str) name
enum {
NOPROB = 0, /* first error will be 1 */
#include "problist.h"
NPROBS
};

/* Store problem strings */
#undef PROB
#define PROB(name,str) str
const char * const errmsg[] = {
"OK",
#include "problist.h"
};

....
problem = FILE_IO;
...
if (problem) {
printf ("foo-%3d - %s\n", problem, errmsg[problem]);
}

You probably want to change some details, but the gist is that one file,
problist.h here, contains a list of problem identifiers and strings.
The compiler assigns increasing error codes and stores the strings in a
table.

You could also write a simple program, using the same header, to
generate a list of error codes and strings.

Thad

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
session mgmt - redirection Fastau B ASP .Net 2 03-20-2006 12:05 PM
state mgmt issue =?Utf-8?B?QVZM?= ASP .Net 1 02-13-2006 07:51 AM
650x + multiple VLANs + l2trace on non-mgmt VLAN papi Cisco 7 05-16-2005 02:30 AM
Re: MGMT-4-OUTOFNVRAM - Catalyst 6513 NVRAM is full Mark Cisco 0 04-07-2004 02:11 PM
ASP .Net pages - instance mgmt Krishnan ASP .Net 0 04-05-2004 06:10 AM



Advertisments