File: prefix.c

package info (click to toggle)
termrec 0.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: ansic: 8,430; makefile: 181; perl: 16; sh: 15
file content (22 lines) | stat: -rw-r--r-- 427 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "config.h"
#include <strings.h>
#include <string.h>
#include "export.h"
#include "stream.h"

int match_suffix(const char *txt, const char *ext, int skip)
{
    int tl,el;

    tl=strlen(txt);
    el=strlen(ext);
    if (tl-el-skip<0)
        return 0;
    txt+=tl-el-skip;
    return !strncasecmp(txt, ext, el);
}

int match_prefix(const char *txt, const char *ext)
{
    return !strncasecmp(txt, ext, strlen(ext));
}