summaryrefslogtreecommitdiff
path: root/support/dktools/dk4ufic.ctr
blob: e32216d0a92e5444a1199106dbc16acfa80a95de (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
%%	options

copyright owner	=	Dirk Krause
copyright year	=	2015-xxxx
license		=	bsd


%%	header

/**	@file
	Compare unique file identifiers.
*/

#ifndef DK4UFIT_H_INCLUDED
#include "dk4ufit.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

/**	Compare two unique file identifiers.
	@param	l	Left identifier.
	@param	r	Right identifier.
	@return	1 if l>r, 0 if l=r, -1 if l<r.
*/
int
dk4ufi_compare(const dk4_ufi_t *l, const dk4_ufi_t *r);

#ifdef __cplusplus
}
#endif


%%	module

#include "dk4ufic.h"

int
dk4ufi_compare(const dk4_ufi_t *l, const dk4_ufi_t *r)
{
  if (NULL != l) {
    if (NULL != r) {
#if DK4_ON_WINDOWS
      if (l->ser > r->ser) {
        back = 1;
      } else {
        if (l->ser < r->ser) {
	  back = -1;
	}
      }
      if (0 == back) {
        if (l->inh > r->inh) {
	  back = 1;
	} else {
	  if (l->inh < r->inh) {
	    back = -1;
	  }
	}
      }
      if (0 == back) {
        if (l->inl > r->inl) {
	  back = 1;
	} else {
	  if (l->inl < r->inl) {
	    back = -1;
	  }
	}
      }
#else
      if (l->dev > r->dev) {
        back = 1;
      } else {
        if (l->dev < r->dev) {
	  back = -1;
	}
      }
      if (0 == back) {
        if (l->ino > r->ino) {
	  back = 1;
	} else {
	  if (l->ino < r->ino) {
	    back = -1;
	  }
	}
      }
#endif
    } else {
      back = 1;
    }
  } else {
    if (NULL != r) {
      back = -1;
    }
  }
}