This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
struct | AUTOKEY_TABLE_ENTRY |
Defines | |
#define | AUTOKEY_NAMELENGTH (32) |
Functions | |
int | autokey_getkey (void *table, int max, const char *name) |
int | autokey_releasekey (void *table, int max, const char *name, int key) |
|
|
|
Definition at line 95 of file autokey.c. Referenced by SHMEM::open().
00096 { 00097 int index; 00098 struct AUTOKEY_TABLE_ENTRY *ktable = (struct AUTOKEY_TABLE_ENTRY *) table; 00099 unsigned int chksum = 0; 00100 int i; 00101 int tries; 00102 int table_full; 00103 if (0 == table || max < 1 || 0 == name) 00104 { 00105 #ifndef NO_STDIO_SUPPORT 00106 rcs_print_error ("Bad parameters to autokey_getkey(%p,%d,%p)\n", 00107 table, max, name); 00108 #endif 00109 return -1; 00110 } 00111 00112 if (name[0] == 0) 00113 { 00114 #ifndef NO_STDIO_SUPPORT 00115 rcs_print_error ("Bad name for autokey_getkey()\n"); 00116 #endif 00117 return -1; 00118 } 00119 00120 for (i = 0; i < AUTOKEY_NAMELENGTH && name[i] != 0; i++) 00121 { 00122 chksum += (unsigned int) name[i]; 00123 } 00124 00125 00126 /* Check to see if this name is already in the table if so return its entry 00127 number. */ 00128 for (index = 0; index < max; index++) 00129 { 00130 if (!autokey_entry_compare (&(ktable[index]), name, chksum)) 00131 { 00132 rcs_print ("autkey found %d for %s already in table\n", index, 00133 name); 00134 return index; 00135 } 00136 } 00137 00138 tries = 0; 00139 00140 do 00141 { 00142 /* Search the table for and empty or invalid entry and try to claim it. */ 00143 table_full = 1; 00144 for (index = 0; index < max; index++) 00145 { 00146 if (!autokey_entry_check (&(ktable[index]))) 00147 { 00148 // Empty or invalid table entry let's claim it. 00149 autokey_entry_write (&(ktable[index]), name, chksum); 00150 table_full = 0; 00151 break; 00152 } 00153 } 00154 if (table_full) 00155 { 00156 rcs_print_error 00157 ("autokey table is full no room for %s in table of size %d\n", 00158 name, max); 00159 return -1; 00160 } 00161 00162 /* Since we have no mutual exclusion we need to sleep for 10 milliseconds 00163 and check to see that it is still there. */ 00164 esleep (0.01); 00165 00166 if (!autokey_entry_compare (&(ktable[index]), name, chksum)) 00167 { 00168 rcs_print ("autkey adding %d for %s\n", index, name); 00169 return index; 00170 } 00171 } 00172 while (tries < 100); 00173 #ifndef NO_STDIO_SUPPORT 00174 rcs_print_error ("autokey_getkey: timed out\n"); 00175 #endif 00176 return -1; 00177 } |
|
Definition at line 181 of file autokey.c. Referenced by SHMEM::close().
00182 { 00183 int chksum = 0; 00184 int i; 00185 struct AUTOKEY_TABLE_ENTRY *ktable = (struct AUTOKEY_TABLE_ENTRY *) table; 00186 00187 if (0 == table || max < 1 || 0 == name || key >= max) 00188 { 00189 #ifndef NO_STDIO_SUPPORT 00190 rcs_print_error ("Bad parameters to autokey_releasekey(%p,%d,%p,%d)\n", 00191 table, max, name, key); 00192 #endif 00193 return -1; 00194 } 00195 00196 if (name[0] == 0) 00197 { 00198 #ifndef NO_STDIO_SUPPORT 00199 rcs_print_error ("Bad name for autokey_releasekey()\n"); 00200 #endif 00201 return -1; 00202 } 00203 00204 chksum = 0; 00205 00206 for (i = 0; i < AUTOKEY_NAMELENGTH && name[i] != 0; i++) 00207 { 00208 chksum += (unsigned int) name[i]; 00209 } 00210 if (autokey_entry_compare (&(ktable[key]), name, chksum)) 00211 { 00212 #ifndef NO_STDIO_SUPPORT 00213 rcs_print_error 00214 ("autokey_releasekey entry in table for %s no longer matches key so it will not be released.\n", 00215 name); 00216 #endif 00217 return (-1); 00218 } 00219 00220 for (i = 0; i < AUTOKEY_NAMELENGTH && name[i] != 0; i++) 00221 { 00222 ktable[key].name[i] = 0; 00223 } 00224 ktable[key].chksum = 0; 00225 } |