Chinaunix首页 | 论坛 | 博客
  • 博客访问: 81919
  • 博文数量: 21
  • 博客积分: 371
  • 博客等级: 一等列兵
  • 技术积分: 225
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-15 21:32
文章分类

全部博文(21)

文章存档

2013年(5)

2012年(16)

我的朋友

分类: C/C++

2013-07-30 00:10:11


点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <errno.h>
  4. #include <limits.h>

  5. static void pr_sysconf(char *msg, int name);
  6. static void pr_pathconf(char *msg, char *path, int name);

  7. int main(int argc, char *argv[])
  8. {
  9.     if(argc != 2)
  10.     {
  11.         printf("args no enough\n");
  12.         exit(1);
  13.     }
  14.     #ifdef ARG_MAX
  15.     printf("ARG_MAX defined to be %d\n",ARG_MAX + 0);
  16.     #else
  17.     printf("no simble for ARG_MAX\n");
  18.     #endif

  19.     #ifdef _SC_ARG_MAX
  20.     pr_sysconf("arg_MAX = ", _SRC_ARG_MAX);
  21.     #else
  22.     printf("no simbel");
  23.     #endif

  24.     #ifdef _PC_MAX_CANON
  25.     pr_pathconf("max_CANON : ", argv[1], _PC_MAX_CANON);
  26.     #else
  27.     printf("no the sible");
  28.     #endif
  29.     
  30.     return 0;
  31. }
  32. static void pr_sysconf(char *msg, int name)
  33. {
  34.     long val;
  35.     fputs(msg, stdout);
  36.     errno = 0;
  37.     if((val = sysconf(name)) < 0)
  38.     {
  39.         if(errno != 0)
  40.         {
  41.             if(errno == EINVAL)
  42.                 fputs("not suport\n", stdout);
  43.             else
  44.                 printf("sysconf error\n");
  45.         }
  46.         else
  47.             printf("no limit\n");
  48.     }
  49.     else
  50.         printf("%ld\n", val);
  51. }

  52. static void pr_pathconf(char *msg, char *path, int name)
  53. {
  54.     long val;
  55.     errno = 0;
  56.     if((val = pathconf(path, name)) < 0)
  57.     {
  58.         if(errno != 0)
  59.         {
  60.             if(errno == EINVAL)
  61.                 fputs("not suport\n", stdout);
  62.             else
  63.                 printf("sysconf error\n");
  64.         }
  65.         else
  66.             printf("no limit\n");
  67.     }
  68.     else
  69.         printf("%ld\n", val);
  70. }


阅读(1753) | 评论(0) | 转发(0) |
0

上一篇:第十六章 模板与泛型编程

下一篇:没有了

给主人留下些什么吧!~~