/* * Ask the user to edit file names and other data for the given * attachment. NULL is returned if no file name is given. */ static struct attachment * read_attachment_data(struct attachment *ap, unsigned number) { char prefix[80], *cp; if (ap == NULL) ap = csalloc(1, sizeof *ap); if (ap->a_msgno) { printf("#%u\tmessage %u\n", number, ap->a_msgno); return ap; } snprintf(prefix, sizeof prefix, catgets(catd, CATSET, 50, "#%u\tfilename: "), number); for (;;) { if ((ap->a_name = readtty(prefix, ap->a_name)) == NULL) break; if (access(ap->a_name, R_OK) == 0) break; perror(ap->a_name); } if (ap->a_name && (value("attachment-ask-charset") || (cp = value("sendcharsets")) != NULL && strchr(cp, ',') != NULL)) { snprintf(prefix, sizeof prefix, "#%u\tcharset: ", number); ap->a_charset = readtty(prefix, ap->a_charset); } /* * The "attachment-ask-content-*" variables are left undocumented * since they are for RFC connoisseurs only. */ if (ap->a_name && value("attachment-ask-content-type")) { if (ap->a_content_type == NULL) ap->a_content_type = mime_filecontent(ap->a_name); snprintf(prefix, sizeof prefix, "#%u\tContent-Type: ", number); ap->a_content_type = readtty(prefix, ap->a_content_type); } if (ap->a_name && value("attachment-ask-content-disposition")) { snprintf(prefix, sizeof prefix, "#%u\tContent-Disposition: ", number); ap->a_content_disposition = readtty(prefix, ap->a_content_disposition); } if (ap->a_name && value("attachment-ask-content-id")) { snprintf(prefix, sizeof prefix, "#%u\tContent-ID: ", number); ap->a_content_id = readtty(prefix, ap->a_content_id); } if (ap->a_name && value("attachment-ask-content-description")) { snprintf(prefix, sizeof prefix, "#%u\tContent-Description: ", number); ap->a_content_description = readtty(prefix, ap->a_content_description); } return ap->a_name ? ap : NULL; }
static struct name * name_expand(char *sname, int ntype) { struct grouphead *gh; struct name *np; if ((gh = findgroup(sname)) != NULL) { np = gexpand(NULL, gh, 0, ntype); } else { np = csalloc(1, sizeof(*np)); np->n_name = sname; np->n_type = ntype; } return np; }
/* * Put the given file to the end of the attachment list. */ struct attachment * add_attachment(struct attachment *attach, const char *file) { struct attachment *ap, *nap; if (access(file, R_OK) != 0) return NULL; /*LINTED*/ nap = csalloc(1, sizeof *nap); nap->a_name = salloc(strlen(file) + 1); strcpy(nap->a_name, file); if (attach != NULL) { for (ap = attach; ap->a_flink != NULL; ap = ap->a_flink); ap->a_flink = nap; nap->a_blink = ap; } else { nap->a_blink = NULL; attach = nap; } return attach; }
seL4_CPtr srv_mint(int badge, seL4_CPtr ep) { assert(ep); seL4_CPtr mintEP = csalloc(); if (!mintEP) { ROS_ERROR("Could not allocate cslot to mint badge."); return 0; } int error = seL4_CNode_Mint ( REFOS_CSPACE, mintEP, REFOS_CDEPTH, REFOS_CSPACE, ep, REFOS_CDEPTH, seL4_NoRead, seL4_CapData_Badge_new(badge) ); if (error != seL4_NoError) { ROS_ERROR("Could not mint badge."); csfree(mintEP); return 0; } return mintEP; }
void *salloc(int id, int type) { if(ammount[type] == max_ammount[type]) return NULL; if(type == SALLOC_TSK || type == SALLOC_THR || type == SALLOC_SMO) { switch(type) { case SALLOC_TSK: if(TST_PTR(id,tsk)) return NULL; break; case SALLOC_THR: if(TST_PTR(id,thr)) return NULL; break; case SALLOC_SMO: if(TST_PTR(id,smo)) return NULL; break; default: break; } // allocate index first, for csalloc is not always atomic if(!index_alloc(id, ALLOC2IDX(type))) return NULL; ammount[type]++; // increment now, for atomicity might be broken on csalloc void * ptr = csalloc(SALLOC2CONT_TYPE(type)); if(ptr == NULL) { ammount[type]--; index_free(id, ALLOC2IDX(type)); return NULL; } switch(type) { case SALLOC_TSK: SET_PTR(id,tsk,ptr); break; case SALLOC_THR: SET_PTR(id,thr,ptr); break; case SALLOC_SMO: SET_PTR(id,smo,ptr); break; default: break; } return ptr; } else { // messages and ports wont have an ID ammount[type]++; // increment now, for atomicity might be broken on csalloc void *ptr = csalloc(SALLOC2CONT_TYPE(type)); if(ptr == NULL) ammount[type]--; return ptr; } }