Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <limits.h>
- typedef struct {
- char match;
- int length;
- } glob_ret;
- int stricmp(const char *s1, const char *s2) {
- for (;; s1++, s2++) {
- if (!*s1 || !*s2)
- return 0;
- if (*s1 == *s2)
- continue;
- if ((*s1) + 32 == *s2)
- continue;
- if ((*s2) + 32 == *s1)
- continue;
- return 0;
- }
- return 1;
- }
- int a_strlen(const char *s1) {
- int len = 0;
- while (*s1++)
- len++;
- return len;
- }
- char a_toLower(const char s1) {
- return s1 > 96 ? s1 : s1 + 32;
- }
- void a_memcpy(char* c1, char* c2, int len) {
- for (; len; c1++, c2++, len--)
- *c1 = *c2;
- }
- glob_ret match_glob(char seq[], char* pat) {
- const int seqLen = a_strlen(seq);
- const int patLen = a_strlen(pat);
- if (strcmp(pat, "*") == 0)
- return (glob_ret){ 1, seq };
- if(stricmp(pat, seq))
- return (glob_ret) { 1, 0 };
- if((!(seqLen?1:0) != !(patLen?1:0)))
- return (glob_ret) { 0, 0 };
- if (a_toLower(seq[0]) == a_toLower(pat[0])) {
- memcpy(seq, seq+1, seqLen);
- memcpy(pat, pat+1, patLen);
- return match_glob(seq, pat);
- }
- }
- char* save_perm(char* dst, char* seq)
- {
- int counter = 0;
- for (; *seq; counter++, seq++) {
- if (counter == 2) {
- counter = 0;
- *dst = '-';
- dst++;
- }
- *dst = *seq;
- dst++;
- }
- *dst = '\n';
- dst++;
- }
- int main() {
- char* test = malloc(16);
- char* seq = "ATGCCGTA\0";
- save_perm(test, seq);
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement