blob: 70d47eca2a3f7f28016f520fdf0c1cb7668084d6 (
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
%% options
copyright owner = Dirk Krause
copyright year = 2015-xxxx
SPDX-License-Identifier: BSD-3-Clause
%% header
/** @file
Compare unique file identifiers.
*/
#ifndef DK4CONF_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4conf.h"
#else
#include <dktools-4/dk4conf.h>
#endif
#endif
#ifndef DK4UFIT_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4ufit.h"
#else
#include <dktools-4/dk4ufit.h>
#endif
#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 "dk4conf.h"
#include "dk4ufic.h"
$!trace-include
int
dk4ufi_compare(const dk4_ufi_t *l, const dk4_ufi_t *r)
{
int back = 0;
$? "+ dk4ufi_compare"
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; $? ". left dev larger"
} else {
if (l->dev < r->dev) {
back = -1; $? ". right dev larger"
}
}
if (0 == back) {
if (l->ino > r->ino) {
back = 1; $? ". left ino larger"
} else {
if (l->ino < r->ino) {
back = -1; $? ". right ino larger"
}
}
}
$? ". %lu/%lu %lu/%lu", (unsigned long)(l->dev), (unsigned long)(l->ino), (unsigned long)(r->dev), (unsigned long)(r->ino)
#endif
} else {
back = 1;
}
} else {
if (NULL != r) {
back = -1;
}
}
$? "- dk4ufi_compare %d", back
return back;
}
|