©2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

common/macrostr.c

Go to the documentation of this file.
00001 /*
00002     Convert macro values to strings
00003     AUP2, Sec. 5.08 (not in book)
00004 
00005     Copyright 2003 by Marc J. Rochkind. All rights reserved.
00006     May be copied only for purposes and under conditions described
00007     on the Web page www.basepath.com/aup/copyright.htm.
00008 
00009     The Example Files are provided "as is," without any warranty;
00010     without even the implied warranty of merchantability or fitness
00011     for a particular purpose. The author and his publisher are not
00012     responsible for any damages, direct or incidental, resulting
00013     from the use or non-use of these Example Files.
00014 
00015     The Example Files may contain defects, and some contain deliberate
00016     coding mistakes that were included for educational reasons.
00017     You are responsible for determining if and how the Example Files
00018     are to be used.
00019 
00020 */
00021 #define __EXTENSIONS__
00022 #include "defs.h"
00023 
00024 #include <netdb.h>
00025 #include <sys/socket.h>
00026 #include <netinet/in.h>
00027 
00028 #if STD_UNIX_VERSION < SUV_SUS3
00029 #ifdef SOLARIS
00030 #undef __EXTENSIONS__
00031 #endif
00032 #endif
00033 #include "macrostr.h"
00034 #ifndef DARWIN
00035 #include <sys/msg.h>
00036 #endif
00037 #include <sys/sem.h>
00038 #include <sys/shm.h>
00039 #include <sys/mman.h>
00040 
00041 static struct {
00042     char *ms_cat;
00043     intptr_t ms_code;
00044     char *ms_macro;
00045     char *ms_desc;
00046 } macrostr_db[] = {
00047 #include "macrostr.incl"
00048     { NULL, 0, NULL, NULL}
00049 };
00050 
00051 char *get_macrostr(const char *cat, int code, char **desc)
00052 {
00053     int i;
00054 
00055     for (i = 0; macrostr_db[i].ms_cat != NULL; i++)
00056         if (strcmp(macrostr_db[i].ms_cat, cat) == 0 &&
00057           macrostr_db[i].ms_code == code) {
00058             if (desc != NULL)
00059                 *desc = macrostr_db[i].ms_desc;
00060             return macrostr_db[i].ms_macro;
00061         }
00062     if (desc != NULL)
00063         *desc = "?";
00064     return "?";
00065 }

Generated on Fri Apr 23 10:57:03 2004 for AUP2 Example Source by doxygen 1.3.1