summaryrefslogtreecommitdiff
path: root/web/src/alpined.d/remote.c
blob: 3269a97816252c80ba87d87e70bbea4bcd0e3146 (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
#if !defined(lint) && !defined(DOS)
static char rcsid[] = "$Id: remote.c 101 2006-08-10 22:53:04Z mikes@u.washington.edu $";
#endif

/* ========================================================================
 * Copyright 2006-2007 University of Washington
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * ========================================================================
 */

#include <system.h>
#include <general.h>

#include "../../../c-client/c-client.h"

#include "../../../pith/remote.h"
#include "../../../pith/msgno.h"
#include "../../../pith/filter.h"
#include "../../../pith/util.h"
#include "../../../pith/debug.h"
#include "../../../pith/osdep/collate.h"


/*
 * Internal prototypes
 */

int
rd_prompt_about_forged_remote_data(reason, rd, extra)
    int        reason;
    REMDATA_S *rd;
    char      *extra;
{
    char  tmp[2000];
    char *unknown = "<unknown>";
    char *foldertype, *foldername, *special;

    /*
     * Since we're web based the user doesn't have much recourse in the event of one of these
     * weird errors, so we just report what happened and forge ahead
     */

    foldertype = (rd && rd->t.i.special_hdr && !strucmp(rd->t.i.special_hdr, REMOTE_ABOOK_SUBTYPE))
		   ? "address book"
		   : (rd && rd->t.i.special_hdr && !strucmp(rd->t.i.special_hdr, REMOTE_PINERC_SUBTYPE))
		       ? "configuration"
		       : "data";
    foldername = (rd && rd->rn) ? rd->rn : unknown;
    special = (rd && rd->t.i.special_hdr) ? rd->t.i.special_hdr : unknown;

    dprint((1, "rd_check_out_forged_remote_data: reason: %d, type: $s, name: %s",
	    reason, foldertype ? foldertype : "?", foldername ? foldername : "?"));

    if(rd && rd->flags & USER_SAID_NO)
      return(-1);

    if(reason == -2){
	snprintf(tmp, sizeof(tmp), _("Missing \"%s\" header in remote pinerc"), special);
	tmp[sizeof(tmp)-1] = '\0';
    }
    else if(reason == -1){
	snprintf(tmp, sizeof(tmp), _("Unexpected \"Received\" header in remote pinerc"));
	tmp[sizeof(tmp)-1] = '\0';
    }
    else if(reason >= 0){
	snprintf(tmp, sizeof(tmp), _("Unexpected value \"%s: %s\" in remote pinerc"), special, (extra && *extra) ? extra : "?");
	tmp[sizeof(tmp)-1] = '\0';
    }

    rd->flags |= USER_SAID_YES;
    return(1);
}