void insert_token(int token) { switch (token) { case T_PUBLIC: case T_PRIVATE: case T_PROTECTED: if (has_token(T_PUBLIC) || has_token(T_PRIVATE) || has_token(T_PROTECTED)) { printf("[Error]: multiple public/private/protected modifier!\n"); } break; } m_modifier_set.insert(token); }
mod_export zlong cond_val(char **args, int num) { char *s = args[num]; if (has_token(s)) { singsub(&s); untokenize(s); } return mathevali(s); }
mod_export char * cond_str(char **args, int num, int raw) { char *s = args[num]; if (has_token(s)) { singsub(&s); if (!raw) untokenize(s); } return s; }
static void cond_subst(char **strp, int glob_ok) { if (glob_ok && checkglobqual(*strp, strlen(*strp), 1, NULL)) { LinkList args = newlinklist(); addlinknode(args, *strp); prefork(args, 0, NULL); while (!errflag && args && nonempty(args) && has_token((char *)peekfirst(args))) zglob(args, firstnode(args), 0); *strp = sepjoin(hlinklist2array(args, 0), NULL, 1); } else singsub(strp); }
void getredirs(LinkList redirs) { LinkNode n; static char *fstr[] = { ">", ">|", ">>", ">>|", "&>", "&>|", "&>>", "&>>|", "<>", "<", "<<", "<<-", "<<<", "<&", ">&", NULL /* >&- */, "<", ">" }; taddchr(' '); for (n = firstnode(redirs); n; incnode(n)) { Redir f = (Redir) getdata(n); switch (f->type) { case REDIR_WRITE: case REDIR_WRITENOW: case REDIR_APP: case REDIR_APPNOW: case REDIR_ERRWRITE: case REDIR_ERRWRITENOW: case REDIR_ERRAPP: case REDIR_ERRAPPNOW: case REDIR_READ: case REDIR_READWRITE: case REDIR_HERESTR: case REDIR_MERGEIN: case REDIR_MERGEOUT: case REDIR_INPIPE: case REDIR_OUTPIPE: if (f->varid) { taddchr('{'); taddstr(f->varid); taddchr('}'); } else if (f->fd1 != (IS_READFD(f->type) ? 0 : 1)) taddchr('0' + f->fd1); if (f->type == REDIR_HERESTR && (f->flags & REDIRF_FROM_HEREDOC)) { if (tnewlins) { /* * Strings that came from here-documents are converted * to here strings without quotation, so convert them * back. */ taddstr(fstr[REDIR_HEREDOC]); taddstr(f->here_terminator); taddpending(f->name, f->munged_here_terminator); } else { int fnamelen, sav; taddstr(fstr[REDIR_HERESTR]); /* * Just a quick and dirty representation. * Remove a terminating newline, if any. */ fnamelen = strlen(f->name); if (fnamelen > 0 && f->name[fnamelen-1] == '\n') { sav = 1; f->name[fnamelen-1] = '\0'; } else sav = 0; /* * Strings that came from here-documents are converted * to here strings without quotation, so add that * now. If tokens are present we need to do double quoting. */ if (!has_token(f->name)) { taddchr('\''); taddstr(quotestring(f->name, NULL, QT_SINGLE)); taddchr('\''); } else { taddchr('"'); taddstr(quotestring(f->name, NULL, QT_DOUBLE)); taddchr('"'); } if (sav) f->name[fnamelen-1] = '\n'; } } else { taddstr(fstr[f->type]); if (f->type != REDIR_MERGEIN && f->type != REDIR_MERGEOUT) taddchr(' '); taddstr(f->name); } taddchr(' '); break; #ifdef DEBUG case REDIR_CLOSE: DPUTS(1, "BUG: CLOSE in getredirs()"); taddchr(f->fd1 + '0'); taddstr(">&- "); break; default: DPUTS(1, "BUG: unknown redirection in getredirs()"); #endif } } tptr--; }
bool is_final() {return has_token(T_FINAL);}
bool is_static() {return has_token(T_STATIC);}
bool is_protected() {return has_token(T_PROTECTED);}
bool is_private() {return has_token(T_PRIVATE);}
bool is_public() {return has_token(T_PUBLIC);}
CK_RV parse_readers(ykpiv_state *state, const CK_BYTE_PTR readers, const CK_ULONG len, ykcs11_slot_t *slots, CK_ULONG_PTR n_slots, CK_ULONG_PTR n_with_token) { CK_BYTE i; CK_BYTE_PTR p; CK_BYTE_PTR s; CK_ULONG l; slot_vendor_t slot; *n_slots = 0; *n_with_token = 0; p = readers; /* * According to pcsc-lite, the format of a reader name is: * name [interface] (serial) index slot * http://ludovicrousseau.blogspot.se/2010/05/what-is-in-pcsc-reader-name.html */ for (i = 0; i < len; i++) if (readers[i] == '\0' && i != len - 1) { slots[*n_slots].vid = get_vendor_id(p); if (slots[*n_slots].vid == UNKNOWN) { // TODO: distinguish between tokenless and unsupported? // Unknown slot, just save what info we have memset(&slots[*n_slots].info, 0, sizeof(CK_SLOT_INFO)); memset(slots[*n_slots].info.slotDescription, ' ', sizeof(slots[*n_slots].info.slotDescription)); if (strlen(p) <= sizeof(slots[*n_slots].info.slotDescription)) strncpy(slots[*n_slots].info.slotDescription, p, strlen(p)); else strncpy(slots[*n_slots].info.slotDescription, p, sizeof(slots[*n_slots].info.slotDescription)); } else { // Supported slot slot = get_slot_vendor(slots[*n_slots].vid); // Values must NOT be null terminated and ' ' padded memset(slots[*n_slots].info.slotDescription, ' ', sizeof(slots[*n_slots].info.slotDescription)); s = slots[*n_slots].info.slotDescription; l = sizeof(slots[*n_slots].info.slotDescription); strncpy((char *)s, (char*)p, l); memset(slots[*n_slots].info.manufacturerID, ' ', sizeof(slots[*n_slots].info.manufacturerID)); s = slots[*n_slots].info.manufacturerID; l = sizeof(slots[*n_slots].info.manufacturerID); if(slot.get_slot_manufacturer(s, l) != CKR_OK) goto failure; if (slot.get_slot_flags(&slots[*n_slots].info.flags) != CKR_OK) goto failure; // Treating hw and fw version the same if (slot.get_slot_version(&slots[*n_slots].info.hardwareVersion) != CKR_OK) goto failure; if (slot.get_slot_version(&slots[*n_slots].info.firmwareVersion) != CKR_OK) goto failure; if (has_token(slots + *n_slots)) { // Save token information (*n_with_token)++; if (create_token(state, p, slots + *n_slots) != CKR_OK) goto failure; } } (*n_slots)++; p += i + 1; } return CKR_OK; failure: // TODO: destroy all token objects for (i = 0; i < *n_slots; i++) if (has_token(slots + i)) destroy_token(slots + i); return CKR_FUNCTION_FAILED; }
int exalias(void) { Reswd rw; hwend(); if (interact && isset(SHINSTDIN) && !strin && !incasepat && tok == STRING && !nocorrect && !(inbufflags & INP_ALIAS) && (isset(CORRECTALL) || (isset(CORRECT) && incmdpos))) spckword(&tokstr, 1, incmdpos, 1); if (!tokstr) { zshlextext = tokstrings[tok]; if (tok == NEWLIN) return 0; return checkalias(); } else { VARARR(char, copy, (strlen(tokstr) + 1)); if (has_token(tokstr)) { char *p, *t; zshlextext = p = copy; for (t = tokstr; (*p++ = itok(*t) ? ztokens[*t++ - Pound] : *t++);); } else zshlextext = tokstr; if ((lexflags & LEXFLAGS_ZLE) && !(inbufflags & INP_ALIAS)) { int zp = lexflags; gotword(); if ((zp & LEXFLAGS_ZLE) && !lexflags) { if (zshlextext == copy) zshlextext = tokstr; return 0; } } if (tok == STRING) { /* Check for an alias */ if ((zshlextext != copy || !isset(POSIXALIASES)) && checkalias()) { if (zshlextext == copy) zshlextext = tokstr; return 1; } /* Then check for a reserved word */ if ((incmdpos || (unset(IGNOREBRACES) && unset(IGNORECLOSEBRACES) && zshlextext[0] == '}' && !zshlextext[1])) && (rw = (Reswd) reswdtab->getnode(reswdtab, zshlextext))) { tok = rw->token; inrepeat_ = (tok == REPEAT); if (tok == DINBRACK) incond = 1; } else if (incond && !strcmp(zshlextext, "]]")) { tok = DOUTBRACK; incond = 0; } else if (incond == 1 && zshlextext[0] == '!' && !zshlextext[1]) tok = BANG; } inalmore = 0; if (zshlextext == copy) zshlextext = tokstr; } return 0; }
int exalias(void) { Alias an; Reswd rw; hwend(); if (interact && isset(SHINSTDIN) && !strin && !incasepat && tok == STRING && !nocorrect && !(inbufflags & INP_ALIAS) && (isset(CORRECTALL) || (isset(CORRECT) && incmdpos))) spckword(&tokstr, 1, incmdpos, 1); if (!tokstr) { yytext = tokstrings[tok]; return 0; } else { VARARR(char, copy, (strlen(tokstr) + 1)); if (has_token(tokstr)) { char *p, *t; yytext = p = copy; for (t = tokstr; (*p++ = itok(*t) ? ztokens[*t++ - Pound] : *t++);); } else yytext = tokstr; if (zleparse && !(inbufflags & INP_ALIAS)) { int zp = zleparse; gotword(); if (zp == 1 && !zleparse) { if (yytext == copy) yytext = tokstr; return 0; } } if (tok == STRING) { /* Check for an alias */ if (!noaliases && isset(ALIASESOPT)) { char *suf; an = (Alias) aliastab->getnode(aliastab, yytext); if (an && !an->inuse && ((an->flags & ALIAS_GLOBAL) || incmdpos || inalmore)) { inpush(an->text, INP_ALIAS, an); if (an->text[0] == ' ') aliasspaceflag = 1; lexstop = 0; if (yytext == copy) yytext = tokstr; return 1; } if ((suf = strrchr(yytext, '.')) && suf[1] && suf > yytext && suf[-1] != Meta && (an = (Alias)sufaliastab->getnode(sufaliastab, suf+1)) && !an->inuse && incmdpos) { inpush(dupstring(yytext), INP_ALIAS, NULL); inpush(" ", INP_ALIAS, NULL); inpush(an->text, INP_ALIAS, an); lexstop = 0; if (yytext == copy) yytext = tokstr; return 1; } } /* Then check for a reserved word */ if ((incmdpos || (unset(IGNOREBRACES) && yytext[0] == '}' && !yytext[1])) && (rw = (Reswd) reswdtab->getnode(reswdtab, yytext))) { tok = rw->token; if (tok == DINBRACK) incond = 1; } else if (incond && !strcmp(yytext, "]]")) { tok = DOUTBRACK; incond = 0; } else if (incond == 1 && yytext[0] == '!' && !yytext[1]) tok = BANG; } inalmore = 0; if (yytext == copy) yytext = tokstr; } return 0; }
int RseLogin::ByteSize() const { int total_size = 0; if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { // optional int32 currentTimeMillis = 1; if (has_currenttimemillis()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->currenttimemillis()); } // optional int32 id = 2; if (has_id()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->id()); } // optional int32 levelBasedOnScore = 3; if (has_levelbasedonscore()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->levelbasedonscore()); } // optional int32 myAccountIsLocked = 4; if (has_myaccountislocked()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->myaccountislocked()); } // optional bool pop = 5; if (has_pop()) { total_size += 1 + 1; } // optional int32 rqId = 6; if (has_rqid()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->rqid()); } // optional int32 sync = 7; if (has_sync()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->sync()); } // optional int32 timeFromLastLogin = 8; if (has_timefromlastlogin()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->timefromlastlogin()); } } if (_has_bits_[8 / 32] & (0xffu << (8 % 32))) { // optional int32 timeFromLastUpdate = 9; if (has_timefromlastupdate()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->timefromlastupdate()); } // optional int32 token = 10; if (has_token()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->token()); } // optional string userId = 11; if (has_userid()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->userid()); } // optional string version = 12; if (has_version()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::StringSize( this->version()); } // optional int32 vip = 13; if (has_vip()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->vip()); } } if (!unknown_fields().empty()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( unknown_fields()); } _cached_size_ = total_size; return total_size; }
void common::tools::message_tokenizer::next() { if (has_token()) tokens_.pop(); }
bool get_index_unk(token_type const& t,index_type unk) const //TODO: optimize? nah, not critical { return has_token(t) ? get_index(t) : unk; }