//Runs BLAST on the fine FASTA file void blast_fine(struct opt_args *args, uint64_t dbsize){ char *blastn, *blast_args = get_blast_args(args), *fine_blast_args = is_substring("-evalue", blast_args) ? blast_args : "-evalue 1e-30"; int command_length = 1024; blastn = malloc(command_length*sizeof(*blastn)); assert(blastn); sprintf(blastn, "blastn %s CaBLAST_fine.fasta -query %s " "-dbsize %lu -task blastn -outfmt 5 %s > CaBLAST_results.xml", search_flags.fine_blast_db ? "-db" : "-subject", args->args[1], dbsize, fine_blast_args); if (!search_flags.hide_progress) fprintf(stderr, "\n%s\n", blastn); system(blastn); //Run fine BLAST free(blast_args); free(blastn); }
void speech_wtrigger(char_data *actor, char *str) { struct room_data *room; trig_data *t; char buf[MAX_INPUT_LENGTH]; if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_SPEECH)) return; room = &world[IN_ROOM(actor)]; for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) { if (!TRIGGER_CHECK(t, WTRIG_SPEECH)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { sprintf(buf,"SYSERR: W-Speech Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); mudlog(buf, NRM, LVL_BUILDER, TRUE); continue; } if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) || (!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) { ADD_UID_VAR(buf, t, actor, "actor", 0); add_var(&GET_TRIG_VARS(t), "speech", str, 0); script_driver(room, t, WLD_TRIGGER, TRIG_NEW); break; } } }
void speech_mtrigger(char_data *actor, char *str) { char_data *ch, *ch_next; trig_data *t; char buf[MAX_INPUT_LENGTH]; for (ch = world[IN_ROOM(actor)].people; ch; ch = ch_next) { ch_next = ch->next_in_room; if (SCRIPT_CHECK(ch, MTRIG_SPEECH) && AWAKE(ch) && !AFF_FLAGGED(ch, AFF_CHARM) && (actor!=ch)) for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (!TRIGGER_CHECK(t, MTRIG_SPEECH)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { sprintf(buf,"SYSERR: Speech Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); mudlog(buf, NRM, LVL_BUILDER, TRUE); continue; } if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) || (!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) { ADD_UID_VAR(buf, t, actor, "actor", 0); add_var(&GET_TRIG_VARS(t), "speech", str, 0); script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); break; } } } }
int main() { int t = 0; //no of test cases char s1[100001] = {'\0',}; char s2[100001] = {'\0',}; int i = 0; int len = 0; // length of the strings scanf("%d",&t); for(;t--;){ scanf("%s",s1); scanf("%s",s2); if(is_substring(s1,s2)){ printf("YES\n"); } else{ printf("NO\n"); } memset(s1,'\0',sizeof(s1)); memset(s1,'\0',sizeof(s1)); memset(a,0,sizeof(a)); } return 0; }
int is_rotation_string(char *a,char *b) { char temp[1024]; strcat(temp,b); strcat(temp,b); return is_substring(temp,a); }
/** * Returns `true` if `first` is a rotation of `second` (or vice verse since the * relation is symmetric). * * The time complexity is O(x), where x is the time complexity of * `is_substring`. * * The space complexity is O(min(n, m)), where n is the size of `first` and m * is the size of `second`. */ bool is_rotation(const std::string& first, const std::string& second) { if (first.size() != second.size()) { return false; } return is_substring(first, second + second); }
vector<bool> chkSubStr(vector<string> p, int n, string s) { // write code here SuffixTreeNode* root = new SuffixTreeNode(); construct_suffix_tree(root, s); vector<bool> ans; for(auto x: p) { ans.push_back(is_substring(root, x)); } return ans; }
/* Return 1 if str contains a word or phrase from wordlist. Phrases are in * double quotes ("). if wrdlist is NULL, then return 1, if str is NULL, * return 0. */ int word_check(char *str, char *wordlist) { char words[MAX_INPUT_LENGTH], phrase[MAX_INPUT_LENGTH], *s; if (*wordlist == '*') return 1; strcpy(words, wordlist); for (s = one_phrase(words, phrase); *phrase; s = one_phrase(s, phrase)) if (is_substring(phrase, str)) return 1; return 0; }
void act_mtrigger(const char_data *ch, char *str, char_data *actor, char_data *victim, obj_data *object, obj_data *target, char *arg) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (SCRIPT_CHECK(ch, MTRIG_ACT) && !AFF_FLAGGED(ch, AFF_CHARM) && (actor != ch)) for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (!TRIGGER_CHECK(t, MTRIG_ACT)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: Act Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); continue; } if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) || (!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) { if (actor) ADD_UID_VAR(buf, t, actor, "actor", 0); if (victim) ADD_UID_VAR(buf, t, victim, "victim", 0); if (object) ADD_UID_VAR(buf, t, object, "object", 0); if (target) ADD_UID_VAR(buf, t, target, "target", 0); if (str) { /* we're guaranteed to have a string ending with \r\n\0 */ char *nstr = strdup(str), *fstr = nstr, *p = strchr(nstr, '\r'); skip_spaces(&nstr); *p = '\0'; add_var(&GET_TRIG_VARS(t), "arg", nstr, 0); free(fstr); } script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }
void act_mtrigger(const char_data *ch, char *str, char_data *actor, char_data *victim, obj_data *object, obj_data *target, char *arg) { trig_data *t; char buf[MAX_INPUT_LENGTH]; if (SCRIPT_CHECK(ch, MTRIG_ACT) && !AFF_FLAGGED(ch, AFF_CHARM) && (actor!=ch)) for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) { if (!TRIGGER_CHECK(t, MTRIG_ACT)) continue; if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) { sprintf(buf,"SYSERR: Act Trigger #%d has no text argument!", GET_TRIG_VNUM(t)); mudlog(buf, NRM, LVL_BUILDER, TRUE); continue; } if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) || (!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) { if (actor) ADD_UID_VAR(buf, t, actor, "actor", 0); if (victim) ADD_UID_VAR(buf, t, victim, "victim", 0); if (object) ADD_UID_VAR(buf, t, object, "object", 0); if (target) ADD_UID_VAR(buf, t, target, "target", 0); if (arg) { skip_spaces(&arg); add_var(&GET_TRIG_VARS(t), "arg", arg, 0); } script_driver(ch, t, MOB_TRIGGER, TRIG_NEW); break; } } }
/* * find_lofsentry() searches for the real path which this requested LOFS path * (rpath) shadows. If found, it will return the sharetab entry of * the real path that corresponds to the LOFS path. * We first search mnttab to see if the requested path is an automounted * path. If it is an automounted path, it will trigger the mount by stat()ing * the requested path. Note that it is important to check that this path is * actually an automounted path, otherwise we would stat() a path which may * turn out to be NFS and block indefinitely on a dead server. The automounter * times-out if the server is dead, so there's no risk of hanging this * thread waiting for stat(). * After the mount has been triggered (if necessary), we look for a * mountpoint of type LOFS (by searching /etc/mnttab again) which * is a substring of the rpath. If found, we construct a new path by * concatenating the mnt_special and the remaining of rpath, call findentry() * to make sure the 'real path' is shared. */ static struct share * find_lofsentry(char *rpath, int *done_flag) { struct stat r_stbuf; mntlist_t *ml, *mntl, *mntpnt = NULL; struct share *retcode = NULL; char tmp_path[MAXPATHLEN]; int mntpnt_len = 0, tmp; char *p1, *p2; if ((*done_flag)++) return (retcode); /* * While fsgetmntlist() uses lockf() to * lock the mnttab before reading it in, * the lock ignores threads in the same process. * Read in the mnttab with the protection of a mutex. */ (void) mutex_lock(&mnttab_lock); mntl = fsgetmntlist(); (void) mutex_unlock(&mnttab_lock); /* * Obtain the mountpoint for the requested path. */ for (ml = mntl; ml; ml = ml->mntl_next) { for (p1 = ml->mntl_mnt->mnt_mountp, p2 = rpath; *p1 == *p2 && *p1; p1++, p2++); if (is_substring(&p1, &p2) && (tmp = strlen(ml->mntl_mnt->mnt_mountp)) >= mntpnt_len) { mntpnt = ml; mntpnt_len = tmp; } } /* * If the path needs to be autoFS mounted, trigger the mount by * stat()ing it. This is determined by checking whether the * mountpoint we just found is of type autofs. */ if (mntpnt != NULL && strcmp(mntpnt->mntl_mnt->mnt_fstype, "autofs") == 0) { /* * The requested path is a substring of an autoFS filesystem. * Trigger the mount. */ if (stat(rpath, &r_stbuf) < 0) { if (verbose) syslog(LOG_NOTICE, "%s: %m", rpath); goto done; } if ((r_stbuf.st_mode & S_IFMT) == S_IFDIR) { /* * The requested path is a directory, stat(2) it * again with a trailing '.' to force the autoFS * module to trigger the mount of indirect * automount entries, such as /net/jurassic/. */ if (strlen(rpath) + 2 > MAXPATHLEN) { if (verbose) { syslog(LOG_NOTICE, "%s/.: exceeds MAXPATHLEN %d", rpath, MAXPATHLEN); } goto done; } (void) strcpy(tmp_path, rpath); (void) strcat(tmp_path, "/."); if (stat(tmp_path, &r_stbuf) < 0) { if (verbose) syslog(LOG_NOTICE, "%s: %m", tmp_path); goto done; } } /* * The mount has been triggered, re-read mnttab to pick up * the changes made by autoFS. */ fsfreemntlist(mntl); (void) mutex_lock(&mnttab_lock); mntl = fsgetmntlist(); (void) mutex_unlock(&mnttab_lock); } /* * The autoFS mountpoint has been triggered if necessary, * now search mnttab again to determine if the requested path * is an LOFS mount of a shared path. */ mntpnt_len = 0; for (ml = mntl; ml; ml = ml->mntl_next) { if (strcmp(ml->mntl_mnt->mnt_fstype, "lofs")) continue; for (p1 = ml->mntl_mnt->mnt_mountp, p2 = rpath; *p1 == *p2 && *p1; p1++, p2++); if (is_substring(&p1, &p2) && ((tmp = strlen(ml->mntl_mnt->mnt_mountp)) >= mntpnt_len)) { mntpnt_len = tmp; if ((strlen(ml->mntl_mnt->mnt_special) + strlen(p2)) > MAXPATHLEN) { if (verbose) { syslog(LOG_NOTICE, "%s%s: exceeds %d", ml->mntl_mnt->mnt_special, p2, MAXPATHLEN); } if (retcode) sharefree(retcode); retcode = NULL; goto done; } (void) strcpy(tmp_path, ml->mntl_mnt->mnt_special); (void) strcat(tmp_path, p2); if (retcode) sharefree(retcode); retcode = findentry(tmp_path); } } if (retcode) { assert(strlen(tmp_path) > 0); (void) strcpy(rpath, tmp_path); } done: fsfreemntlist(mntl); return (retcode); }
is_presredupl(char *s) { if( is_substring("pres_redupl",s) ) return(1); return(0); }
/* * ote/rhs --> ote/ra_s attic * hs --> a_s for rho, eta, alpha in attic */ gk_string * fix_eta(gk_string *gstr) { gk_string * euphs; char * is_substring(); char * orgstr; char * curs; Dialect d; euphs = CreatGkString(MAXEUPHS); /* * deal with h --> a_ in Attic after rho, epsilon and iota */ orgstr = gkstring_of(gstr); /* PrntGkStr(gstr,stdout); */ if( *orgstr == 'h' && !has_morphflag(morphflags_of(gstr), INDECLFORM) && (((stemtype_of(gstr) & (DECL1|DECL2) ) || degree_of(forminfo_of(gstr)) ) || Is_participle(gstr) || Is_deriv(morphflags_of(gstr)))) { if( (d=AndDialect(dialect_of(gstr) , (Dialect) RHO_ALPHA_DIAL)) >= 0 ) { *euphs = *gstr; curs = gkstring_of(euphs); strcpy(curs,"a_"); strcat(curs,orgstr+1); add_morphflag(morphflags_of(euphs),R_E_I_ALPHA); set_dialect(euphs,ATTIC); return(euphs); } } if( dialect_of(gstr) != RHO_ETA_DIAL && ( degree_of(forminfo_of(gstr)) || Is_participle(gstr) || (stemtype_of(gstr) & (DECL1|DECL2) ) ) ) { if( (is_substring("rh",orgstr))) { char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("rh",orgstr); *s = 0; s++; s++; strcpy(tmp,s); strcat(orgstr,"ra_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); } /* check only for forms such as a)ciwte/ra_ / a)ciwte/rh */ else if( (is_substring("ih",orgstr))) { char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("ih",orgstr); *s = 0; s++; s++; strcpy(tmp,s); strcat(orgstr,"ia_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); } else if( (is_substring("i!h",orgstr))) { /* * grc 10/17/93 * get ou)demi!a_s to be marked as attic! */ char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("i!h",orgstr); *s = 0; s++; s++; s++; strcpy(tmp,s); if(tmp[0] == '=' ) strcat(orgstr,"i!a"); else strcat(orgstr,"i!a_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); } else if( (is_substring("i_h",orgstr))) { char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("i_h",orgstr); *s = 0; s++; s++;s++; strcpy(tmp,s); strcat(orgstr,"i_a_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); } else if( (is_substring("i/h",orgstr))) { char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("i/h",orgstr); *s = 0; s++; s++; s++; strcpy(tmp,s); strcat(orgstr,"i/a_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); } else if( (is_substring("i_/h",orgstr))) { char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("i_/h",orgstr); *s = 0; s++; s++;s++; s++; strcpy(tmp,s); strcat(orgstr,"i_/a_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); } else if( (is_substring("e/-h",orgstr))) { char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("e/-h",orgstr); *s = 0;/* s++; s++; s++; */ strcpy(tmp,s+strlen("e/-h")); strcat(orgstr,"e/-a_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); } /* else if( (is_substring("eh",orgstr))) { char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("eh",orgstr); *s = 0; s++; s++; strcpy(tmp,s); strcat(orgstr,"ea_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); } else if( (is_substring("i_/h",orgstr))) { char tmp[MAXWORDSIZE]; char * s; *euphs = *gstr; orgstr = gkstring_of(euphs); s = is_substring("i_/h",orgstr); *s = 0; s++; s++; s++; s++; strcpy(tmp,s); strcat(orgstr,"i_/a_"); strcat(orgstr,tmp); set_dialect(euphs,ATTIC); dialect_of(gstr) &= ~(ATTIC); return(euphs); }*/ } FreeGkString(euphs); return(NULL); }