mem0 () { register i; register long a; long l, r; funcpgup = pgup; funcpgdn = pgdn; funcup = up; funcdown = down; Jmprintf (2, 4, "Память %c", addr==&addr1 ? '1' : '2'); if ((memreg & (MCMD|MBIN)) == MBIN) { Jmove (1, 18); Jprintf ("6 5 4"); Jprintf (" 3 2 1 "); Jmove (2, 14); Jprintf ("4321098765432109876543210"); Jprintf ("987654321098765432109876543210987654321"); } for (i=0, a= *addr; i<19; ++i, ++a) { Jmove (i+4, 5); ptload (&l, &r, a); prmem (l, r, a & ADDRMASK); } }
static down () { long l, r; *addr = (*addr + 1) & ADDRMASK; ptload (&l, &r, *addr + 18); Jscrool (4, 22, -1); Jmove (22, 5); prmem (l, r, *addr + 18); }
static up () { long l, r; *addr = (*addr - 1) & ADDRMASK; ptload (&l, &r, *addr); Jscrool (4, 22, 1); Jmove (4, 5); prmem (l, r, *addr); }
/* * Produce an auth_state structure for the given identifier */ static struct auth_state *mynewstate(const char *identifier) { struct auth_state *output = NULL; if(canonuser_id && (!strcmp(identifier, canonuser_id) || !strcmp(identifier, canonuser_cache->userid.id))) { /* It's the currently cached user, return the previous result */ free(canonuser_id); canonuser_id = NULL; output = canonuser_cache; canonuser_cache = NULL; return output; } /* * If anyone or anonymous, just pass through. Otherwise, try to load the * groups the user is in */ if(strcmp(identifier, "anyone") && strcmp(identifier, "anonymous")) { if(ptload(identifier, &output) < 0) { syslog(LOG_ERR, "ptload failed for %s", identifier); /* Allowing this to go through is a problem if negative group access is * used significantly. Allowing this to go through is a feature when * the ptserver is having problems and the user wants to get to his * inbox. * * note that even on a failure, output should either be NULL or a * correct (enough) value. */ } } if (output == NULL) { output = (struct auth_state *)xzmalloc(sizeof(struct auth_state)); strlcpy(output->userid.id, identifier, sizeof(output->userid.id)); output->userid.hash = strhash(identifier); syslog(LOG_DEBUG, "creating empty auth_state for %s", identifier); } else { syslog(LOG_DEBUG, "using ptloaded value of: %s", output->userid.id); } return output; }
/* * Convert 'identifier' into canonical form. * Returns a pointer to a static buffer containing the canonical form * or NULL if 'identifier' is invalid. */ static const char *mycanonifyid(const char *identifier, size_t len __attribute__((unused))) { static char retbuf[PTS_DB_KEYSIZE]; if(canonuser_id && (!strcmp(identifier, canonuser_id) || !strcmp(identifier, retbuf))) { /* It's the currently cached user, return the previous result */ return retbuf; } else if(canonuser_id) { /* We've got a new one, invalidate our cache */ free(canonuser_id); myfreestate(canonuser_cache); canonuser_id = NULL; canonuser_cache = NULL; } if(!strcmp(identifier, "anyone") || !strcmp(identifier, "anonymous")) { /* we can fill this in ourselves - no cacheing */ strlcpy(retbuf, identifier, sizeof(retbuf)); return retbuf; } if (!strcmp(identifier, "")) { syslog(LOG_ERR, "unable to canonify empty identifier"); return NULL; } canonuser_cache = NULL; if(ptload(identifier, &canonuser_cache) < 0) { if (canonuser_cache == NULL) { syslog(LOG_ERR, "ptload completely failed: unable to canonify identifier: %s", identifier); return NULL; } else { syslog(LOG_ERR, "ptload failed: but canonified %s -> %s", identifier, canonuser_cache->userid.id); } } canonuser_id = xstrdup(identifier); strlcpy(retbuf, canonuser_cache->userid.id, sizeof(retbuf)); syslog(LOG_DEBUG, "canonified %s -> %s", identifier, retbuf); return retbuf; }