/* Return the key with a given fingerprint from the keytable, NULL if there is none. No reference is provided. */ gpgme_key_t gpa_keytable_lookup_key (GpaKeyTable *keytable, const char *fpr) { if (keytable->initialized) { GList *cur; for (cur = keytable->keys; cur; cur = g_list_next (cur)) { gpgme_key_t key = (gpgme_key_t) cur->data; if (g_str_equal (fpr, key->subkeys->fpr)) { return key; } } return NULL; } else { /* There is no list yet. We really, really, need to one, so we list it. * FIXME: This is a hack and a basic problem. Hopefully it won't cause * any real problems. */ keytable->end = (GpaKeyTableEndFunc) gtk_main_quit; reload_cache (keytable, NULL); gtk_main (); keytable->end = NULL; return gpa_keytable_lookup_key (keytable, fpr); } }
int show_cache(http_request req, http_response page) { char msgbuf[100] = { '\0' }; const char *action; if (!add_page_start(page, PAGE_CACHE) || !response_href(page, "/cache?a=reload", "reload cache") || !response_br(page)) return HTTP_500_INTERNAL_SERVER_ERROR; if ( (action = request_get_parameter_value(req, "a")) == NULL) { /* No action */ } else if (strcmp(action, "reload") == 0) { size_t files; if ( (files = reload_cache()) == 0) strcpy(msgbuf, "No files were added to the cache, an error probably occured"); else { sprintf(msgbuf, "Added %zu files to cache", files); } } if (!add_page_end(page, msgbuf)) return HTTP_500_INTERNAL_SERVER_ERROR; return HTTP_200_OK; }
/* Same as list_keys, but forces the internal cache to be rebuilt. */ void gpa_keytable_force_reload (GpaKeyTable *keytable, GpaKeyTableNextFunc next, GpaKeyTableEndFunc end, gpointer data) { g_return_if_fail (keytable != NULL); g_return_if_fail (GPA_IS_KEYTABLE (keytable)); /* Set up callbacks */ keytable->next = next; keytable->end = end; keytable->data = data; /* List keys */ reload_cache (keytable, NULL); }
/* Load the key with the given fingerprint from GnuPG, replacing it in the * keytable if needed. */ void gpa_keytable_load_new (GpaKeyTable *keytable, const char *fpr, GpaKeyTableNextFunc next, GpaKeyTableEndFunc end, gpointer data) { g_return_if_fail (keytable != NULL); g_return_if_fail (GPA_IS_KEYTABLE (keytable)); /* Set up callbacks */ keytable->next = next; keytable->end = end; keytable->data = data; /* List keys */ keytable->new_key = TRUE; reload_cache (keytable, fpr); }
/* List all keys, return cached copies if they are available. * * The "next" function is called for every key, providing a new * reference for that key that should be freed. * * The "end" function is called when the listing is complete. * * This function MAY not do anything until the application goes back into * the GLib main loop. */ void gpa_keytable_list_keys (GpaKeyTable *keytable, GpaKeyTableNextFunc next, GpaKeyTableEndFunc end, gpointer data) { g_return_if_fail (keytable != NULL); g_return_if_fail (GPA_IS_KEYTABLE (keytable)); /* Set up callbacks */ keytable->next = next; keytable->end = end; keytable->data = data; /* List keys */ if (keytable->keys) { /* There is a cached list */ list_cache (keytable); } else { reload_cache (keytable, NULL); } }
void btRayShape::setLength(btScalar p_length) { m_length = p_length; reload_cache(); }
/** * Parses shtml document for possible script includes. * Accepts includes of the form '%! scriptname'. * * If scriptname starts with ':' it is assumed to be an SSI, * otherwise it will be handled as CGI call. */ static PT_THREAD(handle_scripts(struct httpd_state *s)) { /* Note script includes will attach a leading : to the filename and a trailing zero */ static char scriptname[MAX_SCRIPT_NAME_LENGTH + 1], *pptr; // static uint16_t filelength; static int done, eof, eoc; PT_BEGIN(&s->scriptpt); eoc = eof = done = 0; /* Init cache (null-terminated)*/ load_cache(s); while (!done) { /* Assure we can read at least a '%!' sequence. */ // if (cache_size() < 2) { // reload_cache(s); // } /* Check if we should start executing a script, flagged by %! */ if (file_cache_ptr[0] == ISO_percent && file_cache_ptr[1] == ISO_bang) { /* Test if a whole line is in cache, otherwise reload cache. */ if (strchr(&file_cache_ptr[2], ISO_nl) == NULL) { reload_cache(s); } /* Extract name, if starts with colon include file else call cgi */ s->scriptptr = get_scriptname(scriptname, &file_cache_ptr[2]); // s->scriptlen = files[s->fd].len - (s->scriptptr - file_cache_ptr[0]); PRINTD("httpd: Handle script named %s\n", scriptname); /* Include scripts prefixed with ':' are SSI else CGI scripts */ if (scriptname[0] == ISO_colon) { #if WEBSERVER_CONF_INCLUDE PRINTD("IS SSI\n"); s->scriptfd = httpd_fs_open(&scriptname[1], HTTPD_FS_READ); /* Send script if open succeeded. */ if (s->scriptfd != -1) { s->sendfd = s->scriptfd; PT_WAIT_THREAD(&s->scriptpt, send_file(s)); } else { PRINTD("failed opening %s\n", scriptname); } httpd_fs_close(s->scriptfd); /*TODO dont print anything if file not found */ #endif /* Execute unprefixed scripts. */ } else { PRINTD("IS CGI\n"); #if WEBSERVER_CONF_CGI PT_WAIT_THREAD(&s->scriptpt, httpd_cgi(scriptname)(s, s->scriptptr)); #endif } skip_scriptline(s); file_cache_ptr = s->scriptptr; if (cache_size() < 2) { reload_cache(s); } if (cache_size() == 0) { done = 1; } } else { // no script /* get position of next percent character */ if (file_cache_ptr[0] == ISO_percent) { pptr = (char *) strchr(&file_cache_ptr[1], ISO_percent); } else { pptr = (char *) strchr(&file_cache_ptr[0], ISO_percent); } /* calc new length to send */ if (pptr == NULL) { /* no further percent sign found in cache. */ /* Send to end of cache */ s->sendlen = cache_len - (&file_cache_ptr[0] - &file_cache_array[0]); eoc = 1;// inidcates thate we need new cache } else { s->sendlen = (int) ((int) pptr - (int) &file_cache_ptr[0]); } if (s->sendlen > 0) { PRINTD("httpd: Sending %u bytes from 0x%04x\n", s->sendlen, (unsigned int) pptr); s->sendfd = s->fd; PT_WAIT_THREAD(&s->scriptpt, send_part_of_cache(s)); } /* Reload cache if it was marked as empty. */ if (eoc) { reload_cache(s); } /* If (reloaded) cache empty, stop sending */ if (cache_size() == 0) { done = 1; } } } PT_END(&s->scriptpt); }