File: utils.c

package info (click to toggle)
openser 1.1.0-9etch1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 9,828 kB
  • ctags: 11,809
  • sloc: ansic: 120,528; sh: 5,249; yacc: 1,716; makefile: 1,261; php: 656; perl: 205; sql: 190
file content (27 lines) | stat: -rw-r--r-- 437 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdio.h>
#include <string.h>

#include "utils.h"
#include "../../dprint.h"

int scmp(str* s1, str* s2)
{
	int r; 

	if(s1==NULL || s2==NULL || s1->s ==NULL || s2->s==NULL || s1->len<0 || s2->len<0)
	{
		LOG(L_ERR, "scmp: ERROR: bad parameters\n");
		return -2;
	}

	r = strncmp(s1->s, s2->s, s1->len<s2->len?s1->len:s2->len);
	if(r==0)
	{
		if(s1->len<s2->len)
			return 1;
		if(s1->len>s2->len)
			return -1;
	}
	return r;
}