⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proto.c

📁 稀疏矩阵、链表、图、队列、二叉树、多叉树、排序、遗传算法等的实现
💻 C
📖 第 1 页 / 共 2 页
字号:
                      
      { "ceil",       "<h2>&lt;math.h&gt</h2><p>  <h3>"
                      "  double ceil(double x);</h3>" },
                      
      { "floor",      "<h2>&lt;math.h&gt</h2><p>  <h3>"
                      "  double floor(double x);</h3>" },
                      
      { "fabs",       "<h2>&lt;math.h&gt</h2><p>  <h3>"
                      "  double fabs(double x);</h3>" },
                      
      { "ldexp",      "<h2>&lt;math.h&gt</h2><p>  <h3>"
                      "  double ldexp(double x, int n);"
                      "</h3>" },
                      
      { "frexp",      "<h2>&lt;math.h&gt</h2><p>  <h3>"
                      "  double frexp(double x, int *"
                      "exp);</h3>" },
                      
      { "modf",       "<h2>&lt;math.h&gt</h2><p>  <h3>"
                      "  double modf(double x, double *"
                      "ip);</h3>" },
                      
      { "fmod",       "<h2>&lt;math.h&gt</h2><p>  <h3>"
                      "  double fmod(double x, double "
                      "y);</h3>" },
                      
      { "atof",       "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  double atof(const char *s);"
                      "</h3>" },
                      
      { "atoi",       "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  int atoi(const char *s);</h3>"},
                      
      { "atol",       "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  long atol(const char *s);</h3>"},
                      
      { "strtod",     "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  double strtod(const char *s,"
                      " char **endp);</h3>" },
                      
      { "strtol",     "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  long strtol(const char *s,"
                      " char **endp, int base);</h3>" },
                      
      { "strtoul",    "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  long strtoul(const char *s,"
                      " char **endp, int base);</h3>" },
                      
      { "rand",       "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  int rand(void);</h3>" },
                      
      { "srand",      "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "void srand(unsigned int seed);"
                      "</h3>" },
                      
      { "calloc",     "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  void *calloc(size_t nobj,"
                      " size_t size);</h3>" },
                      
      { "malloc",     "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  void *malloc(size_t size);"
                      "</h3>" },
                      
      { "realloc",    "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  void *realloc(void *p, size_t"
                      " size);</h3>" },
                      
      { "free",       "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  void free(void *p);</h3>" },
                      
      { "abort",      "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  void abort(void);</h3>" },
                      
      { "exit",       "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  void exit(int status);</h3>" },
                      
      { "atexit",     "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  int atexit(void (*function)"
                      "(void));</h3>" },
                      
      { "system",     "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  int system(const char *s);"
                      "</h3>"},
                      
      { "getenv",     "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  int getenv(const char *name);"
                      "</h3>" },
                      
      { "bsearch",    "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  void *bsearch (const void *key,"
                      " const void *base, size_t n,"
                      " size_t size, int(*cmp)(const"
                      " void *keyval, const void *datum"
                      "));</h3>" },
                      
      { "qsort",      "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  void qsort(void *base, size_t n,"
                      " size_t size, int(*cmp)(const void"
                      " *, const void *));</h3>" },
                      
      { "abs",        "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "int abs(int n);</h3>" },
                      
      { "labs",       "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  long labs(long n);</h3>" },
                      
      { "div",        "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  div_t div(int num, int denom);"
                      "</h3>" },
                      
      { "ldiv",       "<h2>&lt;stdlib.h&gt</h2><p><h3>"
                      "  ldiv_t div(long num, long"
                      " denom);</h3>" },
                      
      { "assert",     "<h2>&lt;assert.h&gt</h2><p><h3>"
                      "  void assert(int expression);"
                      "</h3>/* This is actually a macro,"
                      " not a function. It is not"
                      " compiled if NDEBUG is defined. "
                      "*/" },
                      
      { "va_start",   "<h2>&lt;stdarg.h&gt</h2><p><h3>"
                      "  [MACRO] va_start(va_list ap,"
                      " lastarg);</h3>" },
                      
      { "va_arg",     "<h2>&lt;stdarg.h&gt</h2><p><h3>"
                      "  [MACRO] type va_arg(va_list ap,"
                      " type);</h3>" },
                      
      { "va_end",     "<h2>&lt;stdarg.h&gt</h2><p><h3>"
                      "  [MACRO] void va_end(va_list ap);"
                      "</h3>" },
                      
      { "setjmp",     "<h2>&lt;setjmp.h&gt</h2><p><h3>"
                      "  int setjmp(jmp_buf env);</h3>" },
                      
      { "longjmp",    "<h2>&lt;setjmp.h&gt</h2><p><h3>"
                      "  void longjmp(jmp_buf env,"
                      " int val);</h3>" },
                      
      { "signal",     "<h2>&lt;signal.h&gt</h2><p><h3>"
                      "  void (*signal(int sig, void"
                      " (*handler)(int)))(int);</h3>" },
                      
      { "raise",      "<h2>&lt;signal.h&gt</h2><p><h3>"
                      "  int raise(int sig);</h3>" },
                      
      { "clock",      "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  clock_t clock(void);</h3>" },
                      
      { "time",       "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  time_t time(time_t *tp);</h3>" },
                      
      { "difftime",   "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  double difftime(time_t time2,"
                      " time_t time1);</h3>" },
                      
      { "mktime",     "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  time_t mktime(struct tm *tp)"
                      ";</h3>" },
                      
      { "asctime",    "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  char *asctime(const struct "
                      "tm *tp);</h3>" },
                      
      { "ctime",      "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  char *ctime(const time_t *tp);"
                      "</h3>" },
                      
      { "gmtime",     "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  struct tm* gmtime(const time_t"
                      " *tp);</h3>" },
                      
      { "localtime",  "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  struct tm* localtime(const"
                      " time_t *tp);</h3>" },
                      
      { "strftime",   "<h2>&lt;time.h&gt</h2><p>  <h3>"
                      "  size_t strftime(char *s,"
                      " size_t smax, const char *fmt,"
                      " const struct tm *tp);</h3>" },
  };
  
  size_t count = sizeof Prototype / sizeof Prototype[0];
  PROTOTYPE *p;
  PROTOTYPE Key;
  char *result = NULL;

  qsort(Prototype,
        count,
        sizeof Prototype[0],
        CompProtos);

  Key.Name = funcname;
  p = bsearch(&Key,
              Prototype,
              count,
              sizeof Prototype[0],
              CompProtos);

  if(p != NULL)
  {
    result = p->Prototype;
  }

  return result;
}

/* CGI program to provide ANSI C Standard
 * Library Function Prototype, given a
 * function name.
 *
 * Note: an input string of "version" will
 * produce, not an ANSI C standard library
 * function prototype (oddly enough), but
 * the version information for this program.
 *
 * Note: This code is generic, and can be
 * used in pretty well all CGI programs. The
 * application-specific bit (which is gratifyingly
 * short) is all in App().
 *
 */

void App(CGI_LIST *List)
{
  char *Proto = NULL;
  int GettingVersionInfo = 0;
  char *VersionInfo =
    "C Unleashed CGI Demo v1.05";
  char *ScriptName = getenv("SCRIPT_NAME");

  /* We are only expecting one item in the list,
   * so let's use it.
   */

  if(strcmp(List->Value, "version") == 0)
  {
    GettingVersionInfo = 1;
  }

  printf("<HTML>\n");
  printf("  <HEAD>\n");
  printf("    <TITLE>\n      ");
  if(GettingVersionInfo)
  {
    printf("Version information for CGI Demo\n");
  }
  else
  {
    printf("Function prototype for %s\n", List->Value);
  }
  printf("    </TITLE>\n");
  printf("  </HEAD>\n");
  printf("  <BODY>\n");
  if(GettingVersionInfo)
  {
    printf("<H1>Version information for CGI Demo<H1>\n");
    printf("<P><P><H2>%s</H2>\n", VersionInfo);
  }
  else
  {
    printf("  <H1><B>%s</B></H1><P>\n", List->Value);

    Proto = GetPrototype(List->Value);
    if(NULL == Proto)
    {
      printf("<I>%s not found. Please"
             " check spelling.</I>\n",
             List->Value);
    }
    else
    {
      printf("<I>%s</I>\n", Proto);
    }
  }

  if(ScriptName != NULL)
  {
    printf("    <BR>\n");
    printf("    <FORM METHOD=\"POST\""
                " ACTION=\"%s\">\n",
                ScriptName);

    printf("      <BR><HR><BR>\n");
    printf("      <CENTER>\n");
    printf("        <FONT SIZE=4>\n");
    printf("          Next search:\n");
    printf("          <BR>\n<BR>\n");
    printf("          Please type in the name "
                      "of the function\n");
    printf("          whose prototype you"
                      " wish to see.\n");
    printf("        </FONT>\n");

    printf("        <BR><BR>\n");
    printf("        <INPUT TYPE=\"text\" NAME="
           "\"function\" SIZE=\"20\">\n");
    printf("        <BR><BR>\n");

    printf("        <INPUT TYPE=\"submit\">\n");
    printf("      </CENTER>\n");
    printf("    </FORM>\n");
  }
    
  printf("  </BODY>\n");
  printf("</HTML>\n");
}

int main(void)
{
  CGI_LIST *List = NULL;
  char *CopyOfQueryString = NULL;
  int ErrorCode = 0;

  /* The next line is required, for HTTP
   * protocol reasons. It will not appear
   * on your output HTML page.
   */
  printf("Content-Type: text/html\n\n");   

  CopyOfQueryString = ReadCGIData(&ErrorCode);

  if(NULL == CopyOfQueryString)
  {
    switch(ErrorCode)
    {
      case CGI_NULL_REQ_METHOD:
        printf("No CGI request method "
               "could be identified.\n");
        break;
      case CGI_UNKNOWN_METHOD:
        printf("Unsupported CGI request method.\n");
        break;
      case CGI_NO_QUERY_STRING:
        printf("No CGI query string found.\n");
        break;
      case CGI_NO_MEMORY:
        printf("Memory allocation failure.\n");
        break;
      case CGI_BAD_CONTENT_LENGTH:
        printf("Missing or invalid CONTENT_LENGTH.\n");
        break;
      case CGI_NO_DATA:
        printf("No CGI input data could be found.\n");
        break;
      default:
        printf("Unknown CGI Error.\n");
        break;
    }

    /* We can't proceed, so we might as well exit. */
    return EXIT_FAILURE;
  }

  List = CGICreateList(CopyOfQueryString);

  /* Whether that worked or not, we don't need
   * CopyOfQueryString any more, so let's dump it.
   */
  free(CopyOfQueryString);
  
  if(NULL == List)
  {
    printf("Can't parse CGI data.\n");
    return EXIT_FAILURE;
  }

  /****************************
   *                          *
   * This is where your CGI   *
   * application gets called! *
   *                          *
   ****************************/
  App(List);

  /* Let's not forget to clean up */
  CGIDestroyList(List);

  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -