aboutsummaryrefslogtreecommitdiff
path: root/net/csup/files/patch-proto.c
blob: 845137c8ee158d188566ff0f287186c68d4f9727 (plain) (blame)
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
122
123
124
125
126
127
128
129
130
--- proto.c.bak	22 Feb 2006 23:22:04 -0000	1.75
+++ proto.c	23 Feb 2006 01:20:53 -0000	1.76
@@ -196,15 +196,15 @@ proto_greet(struct config *config)
 		if (msg == NULL)
 			goto bad;
 		lprintf(-1, "Rejected by server: %s\n", msg);
-		return (-1);
+		return (STATUS_TRANSIENTFAILURE);
 	} else
 		goto bad;
 	lprintf(2, "Server software version: %s\n",
 	    swver != NULL ? swver : ".");
-	return (0);
+	return (STATUS_SUCCESS);
 bad:
 	lprintf(-1, "Invalid greeting from server\n");
-	return (-1);
+	return (STATUS_FAILURE);
 }
 
 /* Negotiate protocol version with the server. */
@@ -236,12 +236,12 @@ proto_negproto(struct config *config)
 	if (maj != PROTO_MAJ || min != PROTO_MIN) {
 		lprintf(-1, "Server protocol version %d.%d not supported "
 		    "by client\n", maj, min);
-		return (1);
+		return (STATUS_FAILURE);
 	}
-	return (0);
+	return (STATUS_SUCCESS);
 bad:
 	lprintf(-1, "Invalid PROTO command from server\n");
-	return (1);
+	return (STATUS_FAILURE);
 }
 
 static int
@@ -265,24 +265,24 @@ proto_login(struct config *config)
 	if (strcmp(realm, ".") != 0 || strcmp(challenge, ".") != 0) {
 		lprintf(-1, "Authentication required by the server and not "
 		    "supported by client\n");
-		return (1);
+		return (STATUS_FAILURE);
 	}
 	proto_printf(s, "AUTHMD5 . . .\n");
 	stream_flush(s);
 	line = stream_getln(s, NULL);
 	cmd = proto_get_ascii(&line);
 	if (strcmp(cmd, "OK") == 0)
-		return (0);
+		return (STATUS_SUCCESS);
 	if (strcmp(cmd, "!") == 0) {
 		msg = proto_get_rest(&line);
 		if (msg == NULL)
 			goto bad;
 		lprintf(-1, "Server error: %s\n", msg);
-		return (1);
+		return (STATUS_FAILURE);
 	}
 bad:
 	lprintf(-1, "Invalid server reply to AUTHMD5\n");
-	return (1);
+	return (STATUS_FAILURE);
 }
 
 /*
@@ -327,10 +327,10 @@ proto_fileattr(struct config *config)
 	if (line == NULL || strcmp(line, ".") != 0)
 		goto bad;
 	memcpy(config->fasupport, support, sizeof(config->fasupport));
-	return (0);
+	return (STATUS_SUCCESS);
 bad:
 	lprintf(-1, "Protocol error negotiating attribute support\n");
-	return (1);
+	return (STATUS_FAILURE);
 }
 
 /*
@@ -422,10 +422,10 @@ proto_xchgcoll(struct config *config)
 		if (line == NULL)
 			goto bad;
 	}
-	return (0);
+	return (STATUS_SUCCESS);
 bad:
 	lprintf(-1, "Protocol error during collection exchange\n");
-	return (1);
+	return (STATUS_FAILURE);
 }
 
 static struct mux *
@@ -482,7 +482,7 @@ proto_run(struct config *config)
 	struct killer killer;
 	struct threads *workers;
 	struct mux *m;
-	int error, i, status;
+	int i, status;
 
 	/*
 	 * We pass NULL for the close() function because we'll reuse
@@ -490,17 +490,17 @@ proto_run(struct config *config)
 	 */
 	config->server = stream_open_fd(config->socket, stream_read_fd,
 	    stream_write_fd, NULL);
-	error = proto_greet(config);
-	if (!error)
-		error = proto_negproto(config);
-	if (!error)
-		error = proto_login(config);
-	if (!error)
-		error = proto_fileattr(config);
-	if (!error)
-		error = proto_xchgcoll(config);
-	if (error)
-		return (STATUS_FAILURE);
+	status = proto_greet(config);
+	if (status == STATUS_SUCCESS)
+		status = proto_negproto(config);
+	if (status == STATUS_SUCCESS)
+		status = proto_login(config);
+	if (status == STATUS_SUCCESS)
+		status = proto_fileattr(config);
+	if (status == STATUS_SUCCESS)
+		status = proto_xchgcoll(config);
+	if (status != STATUS_SUCCESS)
+		return (status);
 
 	/* Multi-threaded action starts here. */
 	m = proto_mux(config);