void Klass::set_is_cloneable() { if (name() != vmSymbols::java_lang_invoke_MemberName()) { _access_flags.set_is_cloneable_fast(); } else { assert(is_final(), "no subclasses allowed"); // MemberName cloning should not be intrinsified and always happen in JVM_Clone. } }
bool ContestDijkstra::admit_candidate(const ScanTaskPoint &candidate) const { if (!is_final(candidate)) return true; else return IsFinishAltitudeValid(solution[0], GetPointFast(candidate)); }
bool OLCDijkstra::admit_candidate(const ScanTaskPoint &candidate) const { if (!is_final(candidate)) return true; else return (get_point(candidate).NavAltitude + fixed(m_finish_alt_diff) >= solution[0].NavAltitude); }
int main(){ while(strcmp(buf, "TERMINATE\0") != 0){ readline(buf); if (is_final(buf) == 0){ evalone(buf); } if(write(1, buf, strlen(buf)+1) == -1) syserr("Error in write"); } return 0; }
bool is_final(const message::transaction& tx, size_t block_depth, uint32_t block_time) { if (tx.locktime == 0) return true; uint32_t max_locktime = block_time; if (tx.locktime < locktime_threshold) max_locktime = block_depth; if (tx.locktime < max_locktime) return true; for (const message::transaction_input& tx_input: tx.inputs) if (!is_final(tx_input)) return false; return true; }
// @Override virtual void debug_print(int indent) override { print_space(indent); if (is_public()) printf("public "); else if (is_protected()) printf("protected "); else if (is_private()) printf("private "); if (is_static()) printf("static "); if (is_final()) printf("final "); }
bool is_final(const transaction_type& tx, size_t block_height, uint32_t block_time) { if (tx.locktime == 0) return true; uint32_t max_locktime = block_time; if (tx.locktime < locktime_threshold) max_locktime = static_cast<uint32_t>(block_height); if (tx.locktime < max_locktime) return true; for (const transaction_input_type& tx_input: tx.inputs) if (!is_final(tx_input)) return false; return true; }
void AccessFlags::print_on(outputStream* st) const { if (is_public ()) st->print("public " ); if (is_private ()) st->print("private " ); if (is_protected ()) st->print("protected " ); if (is_static ()) st->print("static " ); if (is_final ()) st->print("final " ); if (is_synchronized()) st->print("synchronized "); if (is_volatile ()) st->print("volatile " ); if (is_transient ()) st->print("transient " ); if (is_native ()) st->print("native " ); if (is_interface ()) st->print("interface " ); if (is_abstract ()) st->print("abstract " ); if (is_strict ()) st->print("strict " ); if (is_synthetic ()) st->print("synthetic " ); if (is_old ()) st->print("{old} " ); if (is_obsolete ()) st->print("{obsolete} " ); }
// ------------------------------------------------------------------ // ciFlags::print_klass_flags void ciFlags::print_klass_flags(outputStream* st) { if (is_public()) { st->print("public"); } else { st->print("DEFAULT_ACCESS"); } if (is_final()) { st->print(",final"); } if (is_super()) { st->print(",super"); } if (is_interface()) { st->print(",interface"); } if (is_abstract()) { st->print(",abstract"); } }
void ContestDijkstra::add_edges(const ScanTaskPoint& origin) { ScanTaskPoint destination(origin.stage_number + 1, origin.point_index); find_solution(origin); // only add last point! if (is_final(destination)) { assert(n_points > 0); destination.point_index = n_points - 1; } for (; destination.point_index != n_points; ++destination.point_index) { if (admit_candidate(destination)) { const unsigned d = get_weighting(origin.stage_number) * distance(origin, destination); dijkstra.link(destination, origin, d); } } }
// ------------------------------------------------------------------ // ciFlags::print_member_flags void ciFlags::print_member_flags(outputStream* st) { if (is_public()) { st->print("public"); } else if (is_private()) { st->print("private"); } else if (is_protected()) { st->print("protected"); } else { st->print("DEFAULT_ACCESS"); } if (is_static()) { st->print(",static"); } if (is_final()) { st->print(",final"); } if (is_synchronized()) { st->print(",synchronized"); } if (is_volatile()) { st->print(",volatile"); } if (is_transient()) { st->print(",transient"); } if (is_native()) { st->print(",native"); } if (is_abstract()) { st->print(",abstract"); } if (is_strict()) { st->print(",strict"); } }
int algorithm2_2(char str[]){ int i = 0; int q = 0; int i_final = 0; int q_final = 0; char c; while(1){ if(is_final(q) == F_YES){ i_final = i; q_final = q; } c = str[i]; if(next_state(q,c) != S_UD){ q = next_state(q,c); i++; }else{ break; } } if(i_final == 0){ i_final = 1; } strncpy(yytext,str,i_final); yytext[i_final] = '\0'; if(marker(q_final) == M_ID){ //IDだった場合 if(strcmp(yytext,"int") == 0){ //yytextが"int"の場合 return M_INT; }else if(strcmp(yytext,"if") == 0){ //yytextが"if"の場合 return M_IF; }else{ //ID以外の場合 return marker(q_final); } }else{ return marker(q_final); } }
bool is_final_method() const { return is_final() || holder()->is_final(); }
static int parse_message(const char *str, Client *c) { typedef enum { ST_INITIAL, ST_WHITESPACE, ST_ARGUMENT, ST_FINAL } State; State state = ST_INITIAL; int error = 0; char quote = '\0'; /* The quote used to open a quote string */ int pos = 0; char *arg_space; int argc = 0; char *argv[MAX_ARGUMENTS]; int argpos = 0; CommandFunc function = NULL; debug(RPT_DEBUG, "%s(str=\"%.120s\", client=[%d])", __FUNCTION__, str, c->sock); /* We will create a list of strings that is shorter or equally long as * the original string str. */ arg_space = malloc(strlen(str)+1); if (arg_space == NULL) { report(RPT_ERR, "%s: Could not allocate memory", __FUNCTION__); sock_send_error(c->sock, "error allocating memory!\n"); } argv[0] = arg_space; while ((state != ST_FINAL) && !error) { char ch = str[pos++]; switch (state) { case ST_INITIAL: case ST_WHITESPACE: if (is_whitespace(ch)) break; if (is_final(ch)) { state = ST_FINAL; break; } /* otherwise fall through */ state = ST_ARGUMENT; case ST_ARGUMENT: if (is_final(ch)) { if (quote) error = 2; if (argc >= MAX_ARGUMENTS-1) { error = 1; } else { argv[argc][argpos] = '\0'; argv[argc+1] = argv[argc] + argpos + 1; argc++; argpos = 0; } state = ST_FINAL; } else if (ch == '\\') { if (str[pos]) { /* We solve quoted chars here right away */ const char escape_chars[] = "nrt"; const char escape_trans[] = "\n\r\t"; char *p = strchr(escape_chars, str[pos]); /* Is it wise to have the characters \n, \r & \t expanded ? * Can the displays deal with them ? */ if (p != NULL) { /* Insert a replacement for the code */ argv[argc][argpos++] = escape_trans[p - escape_chars]; } else { /* Copy char literally */ argv[argc][argpos++] = str[pos]; } pos++; } else { error = 2; /* alternative: argv[argc][argpos++] = ch; */ if (argc >= MAX_ARGUMENTS-1) { error = 1; } else { argv[argc][argpos] = '\0'; argv[argc+1] = argv[argc] + argpos + 1; argc++; argpos = 0; } state = ST_FINAL; } } else if (is_opening_quote(ch, quote)) { quote = ch; } else if (is_closing_quote(ch, quote)) { quote = '\0'; if (argc >= MAX_ARGUMENTS-1) { error = 1; } else { argv[argc][argpos] = '\0'; argv[argc+1] = argv[argc] + argpos + 1; argc++; argpos = 0; } state = ST_WHITESPACE; } else if (is_whitespace(ch) && (quote == '\0')) { if (argc >= MAX_ARGUMENTS-1) { error = 1; } else { argv[argc][argpos] = '\0'; argv[argc+1] = argv[argc] + argpos + 1; argc++; argpos = 0; } state = ST_WHITESPACE; } else { argv[argc][argpos++] = ch; } break; case ST_FINAL: /* This will never be reached */ break; } } if (argc < MAX_ARGUMENTS) argv[argc] = NULL; else error = 1; if (error) { sock_send_error(c->sock, "Could not parse command\n"); free(arg_space); return 0; } #if 0 /* show what we have parsed */ int i; for (i = 0; i < argc; i++) { printf("%s%c", argv[i], (i == argc-1) ? '\n' : ' '); } #endif /* Now find and call the appropriate function...*/ function = get_command_function(argv[0]); if (function != NULL) { error = function(c, argc, argv); if (error) { sock_printf_error(c->sock, "Function returned error \"%.40s\"\n", argv[0]); report(RPT_WARNING, "Command function returned an error after command from client on socket %d: %.40s", c->sock, str); } } else { sock_printf_error(c->sock, "Invalid command \"%.40s\"\n", argv[0]); report(RPT_WARNING, "Invalid command from client on socket %d: %.40s", c->sock, str); } free(arg_space); return 0; }
int main(int argc, char** argv) { if(argc < 2) { print_usage(argv[0]); exit(1); } const char* fichier = argv[1]; // Etape #1 : Lire et stocker la liste des mots dans un tableau FILE *txt = fopen(fichier, "r"); if(txt == NULL) { fprintf(stderr, "%s : Fichier \"%s\" introuvable\n", __FILE__, fichier); exit(1); } int i = 0, j = 0, k = 0; char c; const int buf_size = 1024; //1Ko char buffer[buf_size]; char* list_words[buf_size]; while((c = tolower(fgetc(txt))) != EOF) { if(c == '\n') { buffer[i] = '\0'; list_words[j] = (char*)malloc(sizeof(char) * i+1); memcpy(list_words[j++], buffer, i+1); i = 0; } else { buffer[i++] = (char)c; k++; } } //Libère la mémoire fclose(txt); //Creation de l'automate automate_det* Dx = aho_corasick(list_words, j, k); // Etape #2 : Init les parametres pour la connexion en socket int status = -1, soc_connexion = -1, soc_client = -1; struct addrinfo *res; struct addrinfo hints; const char* port = "2016"; memset(&hints, 0, sizeof(hints)); //Set all bytes to 0 //Init hints hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; //getaddrinfo ! :o What kind of dark magic is that ? if((status = getaddrinfo("localhost", port, &hints, &res)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status)); exit(1); } if((soc_connexion = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) { fprintf(stderr, "socker() error%d\n", errno); exit(-1); } if(bind(soc_connexion, res->ai_addr, res->ai_addrlen) == -1) { fprintf(stderr, "bind() error: %d", errno); exit(1); } if(listen(soc_connexion, 5) == -1) { fprintf(stderr, "listen() error"); exit(1); } // accept struct sockaddr_storage their_addr; socklen_t addr_size = sizeof(their_addr); if((soc_client = accept(soc_connexion, (struct sockaddr*)&their_addr, &addr_size)) == -1) { fprintf(stderr, "accept() error %d\n", errno); exit(1); } while(recv(soc_client, buffer, buf_size, 0) != 0) { for(i = 0; i < buf_size; ++i) { printf("%02x ", buffer[i]); //Converti les octets en bits avant de lire dans l'automate for(j = 1<<7; j > 0; j=j>>1) { read_letter(Dx, (buffer[i] & j ? '1' : '0')); if(is_final(Dx)) { //Envoyer stop close(soc_client); printf("Bits frauduleux trouvée\n"); exit(1); } } } printf("\n"); } //Libérer la mémoire free_automate_det(Dx); for(i = 0; i < j; ++i) free(list_words[i]); close(soc_client); close(soc_connexion); return 0; }
/* * Lookup the given character 'chr' in the font-string and write a readable * display of the glyph */ static void decode_header(void) { int Pe, Pcms, Pw, Pt; char *s; switch (sscanf(font_string + 2, "%d;%d;%d;%d;%d;%d", &FontNumber, &StartingCharNum, &Pe, &Pcms, &Pw, &Pt)) { case 0: FontNumber = 0; /* FALLTHRU */ case 1: StartingCharNum = 0; /* FALLTHRU */ case 2: Pe = 0; /* FALLTHRU */ case 3: Pcms = 0; /* FALLTHRU */ case 4: Pw = 0; /* FALLTHRU */ case 5: Pt = 0; /* FALLTHRU */ case 6: break; } switch (Pcms) { case 1: MatrixWide = 0; MatrixHigh = 0; break; /* illegal */ case 2: MatrixWide = 5; MatrixHigh = 10; break; case 3: MatrixWide = 6; MatrixHigh = 10; break; case 0: case 4: MatrixWide = 7; MatrixHigh = 10; break; default: MatrixWide = Pcms; MatrixHigh = 10; break; /* 5 thru 10 */ } switch (Pe) { case 0: EraseCtl = "this DRCS set"; break; case 1: EraseCtl = "only reloaded chars"; break; case 2: EraseCtl = "all chars in all DRCS sets"; break; default: EraseCtl = "?"; break; } switch (Pw) { case 0: /* FALLTHRU */ case 1: WidthAttr = "80 cols, 24 lines"; break; case 2: WidthAttr = "132 cols, 24 lines"; break; case 11: WidthAttr = "80 cols, 36 lines"; break; case 12: WidthAttr = "132 cols, 36 lines"; break; case 21: WidthAttr = "80 cols, 24 lines"; break; case 22: WidthAttr = "132 cols, 48 lines"; break; default: WidthAttr = "?"; break; } if (Pt == 2) TextCell = "Full Cell"; else TextCell = "Text"; for (s = font_string; *s; s++) { if (*s == L_CURL) { char *t; char tmp[BUFSIZ]; size_t use = 0; for (t = s + 1; *t; t++) { if (is_inter(*t)) { tmp[use++] = *t; } if (is_final(*t)) { tmp[use++] = *t++; tmp[use] = '\0'; FontName = strcpy((char *) malloc(use + 1), tmp); StartingCharPtr = t; break; } } break; } } }