Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[r2332]: trunk / faxd / mkhash.c Maximize Restore History

Download this file

mkhash.c    169 lines (158 with data), 4.3 kB

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