void EquipmentEntry::parse_lua_table(const LuaValue& table) { ItemEntry::parse_lua_table(table); if (type == EquipmentEntry::NONE) { type = name2type(table["type"].to_str()); } stackable = false; use_action = LuaAction(LuaValue()); stat_modifiers = parse_stat_modifiers(table); cooldown_modifiers = parse_cooldown_modifiers(table); }
void NAppleHandler::setKind(const char *tname) { io_type=name2type(tname); io_init(io_type); }
/* STATIC */ bool NAppleHandler::recognize(const char *tname) { if(name2type(tname)) return true; return false; }
/* * Get the type of the next [Interface] section * Args: file pointer to config file, pointer to current line number in the file * pointer to an itype * Returns: 0 on successfully finding a valid section or nothing but white space * being found before end of file, -1 otherwise * Side effects: On success, itype is set to the type of the interface name * found or END if the end of file is reached without error. line number is * incremented as the file is read. If an error other than a syntax error is * encountered, the line number is set to 0. * * Note that this routine reads the *existing* contentes of configbuf and * refreshes it only if nothing but white space or comments is found before EOL */ int get_interface_section(FILE *fp, unsigned int *line, enum itype *type) { char *ptr,*sptr; enum itype ttype; /* Discard white space and comments until '[' character is found or EOF * any other char is an error */ for(ptr=configbuf;*ptr != '[';) { if (*ptr == ' ' || *ptr == '\t') { ++ptr; continue; } if (*ptr == '\n' || *ptr == '#' || *ptr == '\0') { /* End of line: Read more */ if (!fgets(configbuf,BUFSIZE,fp)) { if (feof(fp)) { *type=END; return (0); } line=0; return(-1); } /* Increment line count and start again */ (*line)++; ptr=configbuf; continue; } return(-1); } /* Eat white space */ for (++ptr; *ptr == ' ' || *ptr == '\t'; ptr++); /* EOL without finding section details is an error */ if (!*ptr || *ptr == '\n') return(-1); /* points to start of section name. Find the end of it */ for(sptr=ptr;*ptr != ']' && *ptr != ' ' && *ptr != '\t';ptr++) if (*ptr == '\0' || *ptr == '\n') /* End of line before closing ']' */ return(-1); /* Terminate section name with null, checking for closing ']' */ if (*ptr == ']') *ptr++='\0'; else { for (*ptr='\0';*ptr == ' ' || *ptr == '\t';ptr++); if (*ptr != ']') return(-1); } /* Check nothing else on the line except white space and comments */ for (++ptr; *ptr == ' ' || *ptr == '\t'; ptr++); if (*ptr && *ptr != '#' && *ptr != '\n') return(-1); /* Convert string to itype identifier. Error if string is not known type */ if ((ttype = name2type(sptr)) == END) return(-1); /* Set tyoe and return success */ *type = ttype; return(0); }
static void pyccn_Capsule_Destructor(PyObject *capsule) { const char *name; void *pointer; enum _pyccn_capsules type; assert(PyCapsule_CheckExact(capsule)); name = PyCapsule_GetName(capsule); type = name2type(name); pointer = PyCapsule_GetPointer(capsule, name); assert(pointer); switch (type) { case CLOSURE: { PyObject *py_obj_closure; struct ccn_closure *p = pointer; py_obj_closure = PyCapsule_GetContext(capsule); assert(py_obj_closure); Py_DECREF(py_obj_closure); /* No longer referencing Closure object */ /* If we store something else, than ourselves, it probably is a bug */ assert(capsule == p->data); free(p); } break; case CONTENT_OBJECT: { struct content_object_data *context; struct ccn_charbuf *p = pointer; context = PyCapsule_GetContext(capsule); if (context) { if (context->pco) free(context->pco); ccn_indexbuf_destroy(&context->comps); free(context); } ccn_charbuf_destroy(&p); } break; case HANDLE: { struct ccn *p = pointer; ccn_disconnect(p); ccn_destroy(&p); } break; case INTEREST: { struct interest_data *context; struct ccn_charbuf *p = pointer; context = PyCapsule_GetContext(capsule); if (context) { if (context->pi) free(context->pi); free(context); } ccn_charbuf_destroy(&p); } break; case PKEY_PRIV: case PKEY_PUB: { struct ccn_pkey *p = pointer; ccn_pubkey_free(p); } break; case EXCLUSION_FILTER: case KEY_LOCATOR: case NAME: case SIGNATURE: case SIGNED_INFO: { struct ccn_charbuf *p = pointer; ccn_charbuf_destroy(&p); } break; case SIGNING_PARAMS: { struct ccn_signing_params *p = pointer; if (p->template_ccnb) ccn_charbuf_destroy(&p->template_ccnb); free(p); } break; default: debug("Got capsule: %s\n", PyCapsule_GetName(capsule)); panic("Unable to destroy the object: got an unknown capsule"); } }
void pdb2top(FILE *top_file, char *posre_fn, char *molname, t_atoms *atoms, rvec **x, gpp_atomtype_t atype, t_symtab *tab, int nrtp, t_restp rtp[], t_restp *restp, t_hackblock *hb, int nterpairs,t_hackblock **ntdb, t_hackblock **ctdb, gmx_bool bAllowMissing, gmx_bool bVsites, gmx_bool bVsiteAromatics, const char *ff, const char *ffdir, real mHmult, int nssbonds, t_ssbond *ssbonds, real long_bond_dist, real short_bond_dist, gmx_bool bDeuterate, gmx_bool bChargeGroups, gmx_bool bCmap, gmx_bool bRenumRes,gmx_bool bRTPresname) { /* t_hackblock *hb; t_restp *restp; */ t_params plist[F_NRE]; t_excls *excls; t_nextnb nnb; int *cgnr; int *vsite_type; int i,nmissat; int bts[ebtsNR]; init_plist(plist); if (debug) { print_resall(debug, atoms->nres, restp, atype); dump_hb(debug, atoms->nres, hb); } /* Make bonds */ at2bonds(&(plist[F_BONDS]), hb, atoms->nr, atoms->atom, atoms->atomname, atoms->nres, *x, long_bond_dist, short_bond_dist, bAllowMissing); /* specbonds: disulphide bonds & heme-his */ do_ssbonds(&(plist[F_BONDS]), atoms->nr, atoms->atom, atoms->atomname, nssbonds, ssbonds, bAllowMissing); nmissat = name2type(atoms, &cgnr, atype, restp); if (nmissat) { if (bAllowMissing) fprintf(stderr,"There were %d missing atoms in molecule %s\n", nmissat,molname); else gmx_fatal(FARGS,"There were %d missing atoms in molecule %s, if you want to use this incomplete topology anyhow, use the option -missing", nmissat,molname); } /* Cleanup bonds (sort and rm doubles) */ clean_bonds(&(plist[F_BONDS])); snew(vsite_type,atoms->nr); for(i=0; i<atoms->nr; i++) vsite_type[i]=NOTSET; if (bVsites) { /* determine which atoms will be vsites and add dummy masses also renumber atom numbers in plist[0..F_NRE]! */ do_vsites(nrtp, rtp, atype, atoms, tab, x, plist, &vsite_type, &cgnr, mHmult, bVsiteAromatics, ffdir); } /* Make Angles and Dihedrals */ fprintf(stderr,"Generating angles, dihedrals and pairs...\n"); snew(excls,atoms->nr); init_nnb(&nnb,atoms->nr,4); gen_nnb(&nnb,plist); print_nnb(&nnb,"NNB"); gen_pad(&nnb,atoms,restp[0].nrexcl,restp[0].HH14, plist,excls,hb,restp[0].bAlldih,restp[0].bRemoveDih, bAllowMissing); done_nnb(&nnb); /* Make CMAP */ if (TRUE == bCmap) { gen_cmap(&(plist[F_CMAP]), restp, atoms->nr, atoms->atom, atoms->atomname, atoms->nres); if (plist[F_CMAP].nr > 0) { fprintf(stderr, "There are %4d cmap torsion pairs\n", plist[F_CMAP].nr); } } /* set mass of all remaining hydrogen atoms */ if (mHmult != 1.0) do_h_mass(&(plist[F_BONDS]),vsite_type,atoms,mHmult,bDeuterate); sfree(vsite_type); /* Cleanup bonds (sort and rm doubles) */ /* clean_bonds(&(plist[F_BONDS]));*/ fprintf(stderr, "There are %4d dihedrals, %4d impropers, %4d angles\n" " %4d pairs, %4d bonds and %4d virtual sites\n", plist[F_PDIHS].nr, plist[F_IDIHS].nr, plist[F_ANGLES].nr, plist[F_LJ14].nr, plist[F_BONDS].nr, plist[F_VSITE2].nr + plist[F_VSITE3].nr + plist[F_VSITE3FD].nr + plist[F_VSITE3FAD].nr + plist[F_VSITE3OUT].nr + plist[F_VSITE4FD].nr + plist[F_VSITE4FDN].nr ); print_sums(atoms, FALSE); if (FALSE == bChargeGroups) { scrub_charge_groups(cgnr, atoms->nr); } if (bRenumRes) { for(i=0; i<atoms->nres; i++) { atoms->resinfo[i].nr = i + 1; atoms->resinfo[i].ic = ' '; } } if (top_file) { fprintf(stderr,"Writing topology\n"); /* We can copy the bonded types from the first restp, * since the types have to be identical for all residues in one molecule. */ for(i=0; i<ebtsNR; i++) { bts[i] = restp[0].rb[i].type; } write_top(top_file, posre_fn, molname, atoms, bRTPresname, bts, plist, excls, atype, cgnr, restp[0].nrexcl); } /* cleaning up */ free_t_hackblock(atoms->nres, &hb); free_t_restp(atoms->nres, &restp); /* we should clean up hb and restp here, but that is a *L*O*T* of work! */ sfree(cgnr); for (i=0; i<F_NRE; i++) sfree(plist[i].param); for (i=0; i<atoms->nr; i++) sfree(excls[i].e); sfree(excls); }