bool install_slot(struct objc_object *obj, int offset, IMP method, char * types, uint32_t sel) { //Type must match selector type char * seltypes = types_for_selector(sel); if(safestrcmp(seltypes, types) != 0) { return false; } objc_lock_object(obj); if(SLOTS(obj) == NULL) { SLOTS(obj) = SparseArrayNew(); } struct objc_slot * oldSlot = SparseArrayLookup(SLOTS(obj), sel); if(oldSlot) { if(safestrcmp(types, oldSlot->types) != 0) { objc_unlock_object(obj); return false; } oldSlot->offset = offset; oldSlot->method = method; } else { //We are adding a new slot, not modifying an old one, so we need to //invalidate a load of caches. id object = obj; oldSlot = slot_lookup(&object, sel, nil); struct objc_slot * newslot = calloc(1, sizeof(struct objc_slot)); //TODO: Factor this out into a slot constructor newslot->offset = offset; newslot->method = method; if(types == NULL) { newslot->types = NULL; } else { newslot->types = strdup(types); } if(oldSlot != NULL) { oldSlot->version++; } SparseArrayInsert(SLOTS(obj), sel, newslot); } objc_unlock_object(obj); return true; }
int Send_auth_transfer( int *sock, int transfer_timeout, struct job *job, struct job *logjob, char *error, int errlen, char *cmd, struct security *security, struct line_list *info ) { struct stat statb; int ack, len, n, fd; /* ACME! The best... */ int status = JFAIL; /* job status */ char *secure, *destination, *from, *client, *s; char *tempfile; char buffer[SMALLBUFFER]; errno = 0; secure = 0; fd = Make_temp_fd(&tempfile); if( cmd && (s = safestrrchr(cmd,'\n')) ) *s = 0; DEBUG1("Send_auth_transfer: cmd '%s'", cmd ); if(DEBUGL1)Dump_line_list("Send_auth_transfer: info ", info ); destination = Find_str_value(info, DESTINATION, Value_sep ); from = Find_str_value(info, FROM, Value_sep ); client = Find_str_value(info, CLIENT, Value_sep ); if( safestrcmp(security->config_tag, "kerberos") ){ Put_in_auth(fd,DESTINATION,destination); if( Is_server ) Put_in_auth(fd,SERVER,from); Put_in_auth(fd,CLIENT,client); if( cmd ){ Put_in_auth(fd,INPUT,cmd); } } else { if( cmd && (Write_fd_str(fd,cmd) < 0 || Write_fd_str(fd,"\n") < 0) ){ SNPRINTF(error, errlen) "Send_auth_transfer: '%s' write failed - %s", tempfile, Errormsg(errno) ); goto error; } if( Is_server && (Write_fd_str(fd,client) < 0 || Write_fd_str(fd,"\n") < 0) ){ SNPRINTF(error, errlen) "Send_auth_transfer: '%s' write failed - %s", tempfile, Errormsg(errno) ); goto error; }