Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6954653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:38:00+00:00 2026-05-27T14:38:00+00:00

The author claims that his awk script will print out all the limits for

  • 0

The author claims that his awk script will print out all the limits for a POSIX.1 and XSI compliant system. I am using Red Hat Enterprise Linux Server release 6.0 (Santiago). When I run his awk script it does not seem to be printing out the #ifdef portion of the C program. My thoughts are that sysconf.sym do not exist on this distribution, therefore the while loops never run. Could someone please confirm that? If this is the case what changes would I need to make to the awk script to get it to print out the #ifdef portion of the code? The awk script is:

# Run with awk -f <awk_script>

BEGIN   {
    printf("#include \"apue.h\"\n")
    printf("#include <errno.h>\n")
    printf("#include <limits.h>\n")
    printf("#include <stdio.h>\n")
    printf("\n")

    printf("int log_to_stderr = 0;\n")

    printf("static void pr_sysconf(char *, int);\n")
    printf("static void pr_pathconf(char *, char *, int);\n")
    printf("\n")
    printf("int\n")
    printf("main(int argc, char *argv[])\n")
    printf("{\n")
    printf(" if (argc != 2)\n")
    printf("  err_quit(\"usage: a.out <dirname>\");\n\n")
    FS="\t+"
    while (getline <"sysconf.sym" > 0) {
        printf("#ifdef %s\n", $1)
        printf(" printf(\"%s defined to be %%d\\n\", %s+0);\n", $1, $1)
        printf("#else\n")
        printf(" printf(\"no symbol for %s\\n\");\n", $1)
        printf("#endif\n")
        printf("#ifdef %s\n", $2)
        printf(" pr_sysconf(\"%s =\", %s);\n", $1, $2)
        printf("#else\n")
        printf(" printf(\"no symbol for %s\\n\");\n", $2)
        printf("#endif\n")
    }
    close("sysconf.sym")
    while (getline <"pathconf.sym" > 0) {
        printf("#ifdef %s\n", $1)
        printf(" printf(\"%s defined to be %%d\\n\", %s+0);\n", $1, $1)
        printf("#else\n")
        printf(" printf(\"no symbol for %s\\n\");\n", $1)
        printf("#endif\n")
        printf("#ifdef %s\n", $2)
        printf(" pr_pathconf(\"%s =\", argv[1], %s);\n", $1, $2)
        printf("#else\n")
        printf(" printf(\"no symbol for %s\\n\");\n", $2)
        printf("#endif\n")
    }
    close("pathconf.sym")
    exit
}
END {
    printf(" exit(0);\n")
    printf("}\n\n")
    printf("static void\n")
    printf("pr_sysconf(char *mesg, int name)\n")
    printf("{\n")
    printf(" long val;\n\n")
    printf(" fputs(mesg, stdout);\n")
    printf(" errno = 0;\n")
    printf(" if ((val = sysconf(name)) < 0) {\n")
    printf("  if (errno != 0) {\n")
    printf("   if (errno == EINVAL)\n")
    printf("    fputs(\" (not supported)\\n\", stdout);\n")
    printf("   else\n")
    printf("    err_sys(\"sysconf error\");\n")
    printf("  } else {\n")
    printf("   fputs(\" (no limit)\\n\", stdout);\n")
    printf("  }\n")
    printf(" } else {\n")
    printf("  printf(\" %%ld\\n\", val);\n")
    printf(" }\n")
    printf("}\n\n")
    printf("static void\n")
    printf("pr_pathconf(char *mesg, char *path, int name)\n")
    printf("{\n")
    printf(" long val;\n")
    printf("\n")
    printf(" fputs(mesg, stdout);\n")
    printf(" errno = 0;\n")
    printf(" if ((val = pathconf(path, name)) < 0) {\n")
    printf("  if (errno != 0) {\n")
    printf("   if (errno == EINVAL)\n")
    printf("    fputs(\" (not supported)\\n\", stdout);\n")
    printf("   else\n")
    printf("    err_sys(\"pathconf error, path = %%s\", path);\n")
    printf("  } else {\n")
    printf("   fputs(\" (no limit)\\n\", stdout);\n")
    printf("  }\n")
    printf(" } else {\n")
    printf("  printf(\" %%ld\\n\", val);\n")
    printf(" }\n")
    printf("}\n")
}

Update

If you would like the apue.h header so you can compile the C program that can be found at.
apue.h

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:38:01+00:00Added an answer on May 27, 2026 at 2:38 pm

    I believe that sysconf.sym and pathconf.sym had to be written or were supplied on disk or something. It’s been a while since I read APUE.

    Update: google turned up the following link http://www.cs.karelia.ru/~vadim/sp2009/apue.2e/std/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On this post MongoDB finding nested elements , author claims that the mongodb document
In windows phone 7.5 data recepie cookbook author claims that Linq to XML is
In Learn You a Haskell for Great Good! author claims that Applicative IO instance
I've inherited a Classic ASP app, and the former author claims that: BODY onload=javascript:
As the author of a C# application, I found that troubleshooting issues reported by
in CSS: The missing manual the author says that font-size: medium (or other size
The author of this article states that Normally you don't want to have access
In this article (11 Apr 2009), the author claims Hiro is: the World's Fastest
Someone brought this article to my attention that claims (I'm paraphrasing) the STL term
The author of a web-service that I am trying to connect to, tells me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.