mkhash.c
上传用户:weiyuanprp
上传日期:2020-05-20
资源大小:1169k
文件大小:4k
源码类别:

传真(Fax)编程

开发平台:

C/C++

  1. /* $Id: mkhash.c,v 1.11 2008/09/16 05:39:07 faxguy Exp $ */
  2. /*
  3.  * Copyright (c) 1990-1996 Sam Leffler
  4.  * Copyright (c) 1991-1996 Silicon Graphics, Inc.
  5.  * HylaFAX is a trademark of Silicon Graphics
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and 
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that (i) the above copyright notices and this permission notice appear in
  10.  * all copies of the software and related documentation, and (ii) the names of
  11.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  12.  * publicity relating to the software without the specific, prior written
  13.  * permission of Sam Leffler and Silicon Graphics.
  14.  * 
  15.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18.  * 
  19.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24.  * OF THIS SOFTWARE.
  25.  */
  26. /*
  27.  * Program to generate hash key values for possible
  28.  * items in a HylaFAX job queue description file.
  29.  */
  30. #include "port.h"
  31. #include <ctype.h>
  32. #include <stdio.h>
  33. #include <string.h>
  34. #define HASH_DECLARE(h) unsigned int h = 0;
  35. #define HASH_ITERATE(h,c) do { unsigned char cc = (c); if (cc != '!') h = 33*h + cc;} while (0)
  36. #define HASH_FINISH(h) do {} while (0);
  37. #define PRINT_HASH()
  38. printf("%sn%sn%sn", 
  39. "#define HASH_DECLARE(h) unsigned int h = 0 ",
  40. "#define HASH_ITERATE(h,c) do { unsigned char cc = (c); if (cc != '!') h = 33*h + cc;} while (0)", 
  41. "#define HASH_FINISH(h) do {} while (0);");
  42. void
  43. hash(const char* cp)
  44. {
  45.     char name[80];
  46.     char* xp = name;
  47.     HASH_DECLARE(nh);
  48.     while (*cp) {
  49. char c = *cp++;
  50. if (c == '!')
  51.     *xp++ = '_';
  52. else
  53.     *xp++ = toupper(c);
  54. HASH_ITERATE(nh, c);
  55.     }
  56.     *xp = '';
  57.     HASH_FINISH(nh);
  58.     printf("#define H_%s %uUn", name, nh);
  59. }
  60. int
  61. main()
  62. {
  63.     printf("/* THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT */n");
  64.     PRINT_HASH();
  65.     hash("external");
  66.     hash("number");
  67.     hash("mailaddr");
  68.     hash("sender");
  69.     hash("jobid");
  70.     hash("jobtag");
  71.     hash("pagehandling");
  72.     hash("modem");
  73.     hash("modemused");
  74.     hash("faxnumber");
  75.     hash("faxname");
  76.     hash("tsi");
  77.     hash("receiver");
  78.     hash("company");
  79.     hash("location");
  80.     hash("voice");
  81.     hash("fromcompany");
  82.     hash("fromlocation");
  83.     hash("fromvoice");
  84.     hash("regarding");
  85.     hash("comments");
  86.     hash("cover");
  87.     hash("client");
  88.     hash("owner");
  89.     hash("groupid");
  90.     hash("signalrate");
  91.     hash("dataformat");
  92.     hash("jobtype");
  93.     hash("tagline");
  94.     hash("subaddr");
  95.     hash("passwd");
  96.     hash("state");
  97.     hash("npages");
  98.     hash("totpages");
  99.     hash("skippages");
  100.     hash("skippedpages");
  101.     hash("nocountcover");
  102.     hash("serverdocover");
  103.     hash("ignoremodembusy");
  104.     hash("ntries");
  105.     hash("ndials");
  106.     hash("totdials");
  107.     hash("maxdials");
  108.     hash("tottries");
  109.     hash("maxtries");
  110.     hash("pagewidth");
  111.     hash("resolution");
  112.     hash("pagelength");
  113.     hash("priority");
  114.     hash("schedpri");
  115.     hash("minbr");
  116.     hash("desiredbr");
  117.     hash("desiredst");
  118.     hash("desiredec");
  119.     hash("desireddf");
  120.     hash("desiredtl");
  121.     hash("useccover");
  122.     hash("usexvres");
  123.     hash("tts");
  124.     hash("killtime");
  125.     hash("retrytime");
  126.     hash("poll");
  127.     hash("tiff");
  128.     hash("pdf");
  129.     hash("!pdf");
  130.     hash("!tiff");
  131.     hash("postscript");
  132.     hash("!postscript");
  133.     hash("pcl");
  134.     hash("!pcl");
  135.     hash("fax");
  136.     hash("data");
  137.     hash("!data");
  138.     hash("page");
  139.     hash("!page");
  140.     hash("notify");
  141.     hash("pagechop");
  142.     hash("chopthreshold");
  143.     hash("csi");
  144.     hash("nsf");
  145.     hash("timeofday");
  146.     hash("errorcode");
  147.     hash("status");
  148.     hash("returned");
  149.     hash("doneop");
  150.     hash("commid");
  151.     hash("canonical");
  152.     return (0);
  153. }