void sudo_setgrent(void) { setgrent(); if (grcache_bygid == NULL) grcache_bygid = rbcreate(cmp_grgid); if (grcache_byname == NULL) grcache_byname = rbcreate(cmp_grnam); }
void sudo_setpwent(void) { setpwent(); if (pwcache_byuid == NULL) pwcache_byuid = rbcreate(cmp_pwuid); if (pwcache_byname == NULL) pwcache_byname = rbcreate(cmp_pwnam); }
void sudo_setpwent(void) { debug_decl(sudo_setpwent, SUDO_DEBUG_NSS) setpwent(); if (pwcache_byuid == NULL) pwcache_byuid = rbcreate(cmp_pwuid); if (pwcache_byname == NULL) pwcache_byname = rbcreate(cmp_pwnam); debug_return; }
void runlargetest() { /* Create a ring buffer with size equal to the LMC ring buffer. */ int size = 700; int readsize = 32; void *tres; unsigned short int *datar; /* Create garbage data to pump into the buffer. */ unsigned short int datas[64] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6'}; assert(rbcreate(size) == 0); printing = 0; /* Create thread and start it. */ running = 1; working = 1; if (pthread_create(&streamingthread, NULL, datathread, NULL) == -1) { printf("Failed to start thread.\n"); return; } done = 0; /* Print the whole buffer. */ /* printa(rb, 64); */ /* Request 32 bytes at a time and print out the data and the buffer. */ while (working); printing = 1; printf("Done initial work.\n"); while (1) { printing = 1; if (rbret(&datar, 32) == 0) { printa(datar, 32); printf("\n"); } printing = 0; if (done) break; } /* Stop the thread. */ running = 0; if (pthread_join(streamingthread, &tres) != 0) { printf("Hmm\n"); } else { printf("Stream not running.\n"); } }
/* * Find the named alias, remove it from the tree and return it. */ struct alias * alias_remove(char *name, int type) { struct rbnode *node; struct alias key; debug_decl(alias_remove, SUDOERS_DEBUG_ALIAS) key.name = name; key.type = type; if ((node = rbfind(aliases, &key)) == NULL) { errno = ENOENT; return NULL; } debug_return_ptr(rbdelete(aliases, node)); } bool init_aliases(void) { debug_decl(init_aliases, SUDOERS_DEBUG_ALIAS) if (aliases != NULL) rbdestroy(aliases, alias_free); aliases = rbcreate(alias_compare); debug_return_bool(aliases != NULL); }
int main(int argc, const char *argv[]) { unsigned short int *buf; unsigned short int sbuf[80] = {'a', 'b', 'c'}; #ifdef QUAXK /* First run ring buffer test. */ assert(rbcreate(5) == 0); printa(sbuf,3); assert(rbstr(sbuf,3) == 0); /* read 2 bytes this should not return an error */ assert(rbret(&buf, 2) == 0); printa(buf,2); assert(buf[1] == 98); /* check available memory */ assert(rbfull(4) == 0); assert(rbfull(5) == 1); /* write 3 bytes */ sbuf[0] = 'd'; sbuf[1] = 'e'; sbuf[2] = 'f'; printa(rb,5); assert(rbstr(sbuf, 3) == 0); printa(rb,5); /* check available memory. */ assert(rbfull(1) == 0); assert(rbfull(2) == 1); /* read 5 bytes, should be error */ assert(rbret(&buf, 5) == 1); /* read 4 bytes. */ assert(rbret(&buf, 4) == 0); //printf("rbenda = %d, buf = %d, rb = %d, rb1 = %d \n",rbenda,buf,rb,rb + 1); printa(buf,4); assert(buf[2] == 101); /* read 2 bytes this should return an error */ assert(rbret(&buf, 2) == 1); /* write 6 bytes. This should be a to large error. */ assert(rbstr(sbuf, 6) == 1); /* write 3 bytes */ sbuf[0] = 'x'; sbuf[1] = 'y'; sbuf[2] = 'z'; assert(rbstr(sbuf, 3) == 0); printa(rb,5); /* Create test that reads 3 chunks of 4 bytes from a buffer with an extra 4 * bytes. */ assert(rbcreate(50) == 0); char dbuf[80] = "abcdefghijklmnopqrstuvwxyzabcdefghijklmopqrstuvwx"; int i; assert(rbstr((unsigned short int *)dbuf, 50) == 0); for (i = 0; i < 4; i++) { assert(rbret(&buf,3) == 0); printa(buf,3); } #endif printf("Beginning large test.\n"); runlargetest(); printf("Complete\n"); /* Then run pointer test to make sure it is getting a usable * and correct address in it. */ return 0; }