//-------------------------------------------------------------------------- // Function: CompType::getMemberStrType ///\brief Returns the string datatype of the specified member in this /// compound datatype. ///\param member_num - IN: Zero-based index of the member ///\return StrType instance ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- StrType CompType::getMemberStrType( unsigned member_num ) const { try { StrType strtype(p_get_member_type(member_num)); return(strtype); } catch (DataTypeIException E) { throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg()); } }
std::string Programme::signature() const { std::string listArgs = ""; int l = arguments.size(); int i; for(i = 0; i < l; i++) { listArgs += (i>0?", ":"") + arguments[i].instancier(); } return strtype() + " " + nom + "("+listArgs+")"; }
static void determine_start(struct grammar * grammar) { for (struct symbol * sym = grammar->symlist.first; sym; sym = sym->next) { if (! sym->use_count) { if (! grammar->start && sym->type == NONTERMINAL) { print("note: using `%s' as start symbol\n", sym->name); grammar->start = sym; } else if (sym != grammar->start && sym->type != UNKNOWN) { print("warning: unused %s symbol `%s'\n", strtype(sym), sym->name); } } } }
int main() { char str[101]; int result[1000]; int i=0; int j=0; while(scanf("%s",str) != EOF) { result[i] = strtype(str); i++; } for(j=0;j<i;j++) print(result[j]); return 0; }
//-------------------------------------------------------------------------- // Function: AbstractDs::getStrType ///\brief Returns the string datatype of this abstract dataset which /// can be a dataset or an attribute. ///\return StrType instance ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- StrType AbstractDs::getStrType() const { // Gets the id of the datatype used by this dataset or attribute using // p_get_type. p_get_type calls either H5Dget_type or H5Aget_type // depending on which object invokes getStrType. Then, create and // return the StrType object try { StrType strtype(p_get_type()); return(strtype); } catch (DataSetIException E) { throw DataTypeIException("DataSet::getStrType", E.getDetailMsg()); } catch (AttributeIException E) { throw DataTypeIException("Attribute::getStrType", E.getDetailMsg()); } }
void printattributes(fsal_attrib_list_t attrs) { if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_RDATTR_ERR)) LogTest("FSAL_ATTR_RDATTR_ERR"); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_TYPE)) LogTest("Type : %s", strtype(attrs.type)); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_SIZE)) LogTest("Size : %llu", attrs.filesize); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_FSID)) LogTest("fsId : %llu.%llu", attrs.fsid.major, attrs.fsid.minor); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_ACL)) LogTest("ACL List ..."); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_FILEID)) LogTest("FileId : %llu", attrs.fileid); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_MODE)) LogTest("Mode : %#o", attrs.mode); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_NUMLINKS)) LogTest("Numlinks : %u", (unsigned int)attrs.numlinks); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_OWNER)) LogTest("uid : %d", attrs.owner); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_GROUP)) LogTest("gid : %d", attrs.group); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_RAWDEV)) LogTest("Rawdev ..."); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_ATIME)) LogTest("atime : %s", ctime((time_t *) & attrs.atime.seconds)); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_CREATION)) LogTest("creation time : %s", ctime((time_t *) & attrs.creation.seconds)); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_CTIME)) LogTest("ctime : %s", ctime((time_t *) & attrs.ctime.seconds)); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_MTIME)) LogTest("mtime : %s", ctime((time_t *) & attrs.mtime.seconds)); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_CHGTIME)) LogTest("chgtime : %s", ctime((time_t *) & attrs.chgtime.seconds)); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_SPACEUSED)) LogTest("spaceused : %llu", attrs.spaceused); if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_MOUNTFILEID)) LogTest("mounted_on_fileid : %llu", attrs.mounted_on_fileid); }
void parseSentence( void ) { int state = S_STATE; word_t symbol; while (state != EOS_STATE) { switch( state ) { case S_STATE: printf("(S "); state = NP_STATE; break; case NP_STATE: printf("(NP "); state = NP_DET_STATE; break; case NP_DET_STATE: getWord( &symbol ); if (symbol.type == DET) { printf("[DET %s] ", symbol.word); getWord( &symbol ); } state = NP_NOUN_STATE; break; case NP_NOUN_STATE: if (symbol.type == NOUN) { printf("(NOUN %s) )", symbol.word); frame.actor = symbol.word; state = VP_STATE; getWord( &symbol ); } else { printf("!ERROR! (type=%s)\n", strtype(symbol.type)); state = EOS_STATE; } break; case VP_STATE: if (symbol.type == EOS) { printf(" )\n"); state = EOS_STATE; } else { printf("\n\t(VP "); state = VP_VERB_STATE; } break; case VP_VERB_STATE: if (symbol.type == VERB) { printf("(VERB %s) ", symbol.word); frame.action = symbol.word; state = VP_NP_STATE; getWord( &symbol ); } else { printf("!ERROR! (type=%s)\n", strtype(symbol.type)); state = EOS_STATE; } break; case VP_NP_STATE: if (symbol.type == EOS) { printf(" ) )\n"); state = EOS_STATE; } else { printf("\n\t\t(VP_NP "); state = VP_NP_DET_STATE; } break; case VP_NP_DET_STATE: if (symbol.type == DET) { printf("[DET %s] ", symbol.word); getWord( &symbol ); } state = VP_NP_ADJ_STATE; break; case VP_NP_ADJ_STATE: if (symbol.type == ADJECTIVE) { printf("[ADJ %s] ", symbol.word); frame.modifier = symbol.word; getWord( &symbol ); } state = VP_NP_NOUN_STATE; break; case VP_NP_NOUN_STATE: if (symbol.type == NOUN) { printf("(NOUN %s) ) ) )\n", symbol.word); frame.object = symbol.word; state = EOS_STATE; } else { printf("!ERROR! (type=%s)\n", strtype(symbol.type)); state = EOS_STATE; } break; } } return; }
int himd_add_string(struct himd * himd, char *string, int type, struct himderrinfo * status) { int curidx, curtype, i, nextidx; int nslots; int idx_firstslot; gsize length; gchar * convertedstring; unsigned char * curchunk; unsigned char strencoding; g_return_val_if_fail(himd != NULL, -1); g_return_val_if_fail(string != NULL, -1); /* try to use Latin-1 or Shift-JIS. If that fails, use Unicode. */ if((convertedstring = g_convert(string,-1,"ISO-8859-1","UTF8", NULL,&length,NULL)) != NULL) strencoding = HIMD_ENCODING_LATIN1; else if((convertedstring = g_convert(string,-1,"SHIFT_JIS","UTF8", NULL,&length,NULL)) != NULL) strencoding = HIMD_ENCODING_SHIFT_JIS; else if((convertedstring = g_convert(string,-1,"UTF-16BE","UTF8", NULL,&length,NULL)) != NULL) strencoding = HIMD_ENCODING_UTF16BE; else { /* should never happen, as utf-16 can encode anything */ set_status_printf(status, HIMD_ERROR_UNKNOWN_ENCODING, "can't encode the string '%s' into anything usable", string); return -1; } /* how many number of slots to store string in? */ nslots = (length+14)/14; /* +13 for rounding up, +1 for the encoding byte */ /* check that there are enough free slots. Start at slot 0 which is the head of the free list. */ curidx = 0; for(i = 0; i < nslots; i--) { curtype = strtype(get_strchunk(himd, curidx)); curidx = strlink(get_strchunk(himd, curidx)); if(!curidx) { g_free(convertedstring); set_status_printf(status, HIMD_ERROR_OUT_OF_STRINGS, "Not enough string space to allocate %d string slots\n", nslots); return -1; } if(curtype != STRING_TYPE_UNUSED) { g_free(convertedstring); set_status_printf(status, HIMD_ERROR_STRING_CHAIN_BROKEN, "String slot %d in free list has type %d\n", curidx, curtype); return -1; } } idx_firstslot = strlink(get_strchunk(himd, 0)); curidx = idx_firstslot; for(i = 0; i < nslots; i++) { /* reserve space for the encoding byte in the first slot */ gsize slotlen = (i != 0) ? 14 : 13; gsize stroffset = i*14 - 1; /* limit length to what is remaining of the string */ if(slotlen > length - stroffset) slotlen = length - stroffset; curchunk = get_strchunk(himd, curidx); nextidx = strlink(curchunk); if(i == 0) { curchunk[0] = strencoding; memcpy(curchunk + 1, convertedstring, slotlen); set_strtype(curchunk, type); } else { memcpy(curchunk, convertedstring + stroffset, slotlen); set_strtype(curchunk, STRING_TYPE_CONTINUATION); } if(i == nslots-1) set_strlink(curchunk, 0); curidx = nextidx; } /* adjust free list head pointer */ set_strlink(get_strchunk(himd, 0), curidx); g_free(convertedstring); return idx_firstslot; }
char* himd_get_string_raw(struct himd * himd, unsigned int idx, int*type, int* length, struct himderrinfo * status) { int curidx; int len; char * rawstr; int actualtype; g_return_val_if_fail(himd != NULL, NULL); g_return_val_if_fail(idx >= 1, NULL); g_return_val_if_fail(idx < 4096, NULL); actualtype = strtype(get_strchunk(himd,idx)); /* Not the head of a string */ if(actualtype < 8) { set_status_printf(status, HIMD_ERROR_NOT_STRING_HEAD, _("String table entry %d is not a head: Type %d"), idx,actualtype); return NULL; } if(type != NULL) *type = actualtype; /* Get length of string */ len = 1; for(curidx = strlink(get_strchunk(himd,idx)); curidx != 0; curidx = strlink(get_strchunk(himd,curidx))) { if(strtype(get_strchunk(himd,curidx)) != STRING_TYPE_CONTINUATION) { set_status_printf(status, HIMD_ERROR_STRING_CHAIN_BROKEN, _("%dth entry in string chain starting at %d has type %d"), len+1,idx,strtype(get_strchunk(himd,curidx))); return NULL; } len++; if(len >= 4096) { set_status_printf(status, HIMD_ERROR_STRING_CHAIN_BROKEN, _("string chain starting at %d loops"),idx); return NULL; } } /* collect fragments */ rawstr = g_malloc(len*14); if(!rawstr) { set_status_printf(status, HIMD_ERROR_OUT_OF_MEMORY, _("Can't allocate %d bytes for raw string (string idx %d)"), len, idx); return NULL; } len = 0; for(curidx = idx; curidx != 0; curidx = strlink(get_strchunk(himd,curidx))) { memcpy(rawstr+len*14,get_strchunk(himd,curidx),14); len++; } *length = 14*len; return rawstr; }