~ubuntu-branches/debian/sid/net-tools/sid

« back to all changes in this revision

Viewing changes to lib/ax25.c

  • Committer: Package Import Robot
  • Author(s): Martín Ferrari
  • Date: 2015-09-07 01:54:07 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20150907015407-v2tfsgxayjd3iq4i
Tags: 1.60+git20150829.73cef8a-1
* After 14 years without an upstream release, I am producing a new package
  based on today's upstream repository.
  Closes: #391495, #486448, #323261, #260587, #545328, #511395.
* Remove many patches now merged upstream, delete unmaintainable and
  undocumented local changes, and update the rest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
extern struct aftype ax25_aftype;
49
49
 
50
 
static char *AX25_print(unsigned char *ptr)
 
50
static const char *AX25_print(const char *ptr)
51
51
{
52
52
    static char buff[8];
53
53
    int i;
66
66
 
67
67
 
68
68
/* Display an AX.25 socket address. */
69
 
static char *
70
 
 AX25_sprint(struct sockaddr *sap, int numeric)
 
69
static const char *
 
70
 AX25_sprint(const struct sockaddr *sap, int numeric)
71
71
{
72
72
    static char buf[64];
73
73
 
76
76
    return (AX25_print(((struct sockaddr_ax25 *) sap)->sax25_call.ax25_call));
77
77
}
78
78
 
 
79
#ifdef DEBUG
 
80
#define _DEBUG 1
 
81
#else
 
82
#define _DEBUG 0
 
83
#endif
79
84
 
80
85
static int AX25_input(int type, char *bufp, struct sockaddr *sap)
81
86
{
82
 
    unsigned char *ptr;
 
87
    char *ptr;
83
88
    char *orig, c;
84
89
    int i;
85
90
 
95
100
            c = toupper(c);
96
101
        if (!(isupper(c) || isdigit(c))) {
97
102
            safe_strncpy(AX25_errmsg, _("Invalid callsign"), sizeof(AX25_errmsg));
98
 
#ifdef DEBUG
99
 
            fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
100
 
#endif
 
103
            if (_DEBUG)
 
104
                fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
101
105
            errno = EINVAL;
102
106
            return (-1);
103
107
        }
107
111
 
108
112
    /* Callsign too long? */
109
113
    if ((i == 6) && (*bufp != '-') && (*bufp != '\0')) {
110
 
        strcpy(AX25_errmsg, _("Callsign too long"));
111
 
#ifdef DEBUG
112
 
        fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
113
 
#endif
 
114
        safe_strncpy(AX25_errmsg, _("Callsign too long"), sizeof(AX25_errmsg));
 
115
        if (_DEBUG)
 
116
            fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
114
117
        errno = E2BIG;
115
118
        return (-1);
116
119
    }
128
131
    }
129
132
 
130
133
    /* All done. */
131
 
#ifdef DEBUG
132
 
    fprintf(stderr, "ax25_input(%s): ", orig);
133
 
    for (i = 0; i < sizeof(ax25_address); i++)
134
 
        fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
135
 
    fprintf(stderr, "\n");
136
 
#endif
 
134
    if (_DEBUG) {
 
135
        fprintf(stderr, "ax25_input(%s): ", orig);
 
136
        for (i = 0; i < sizeof(ax25_address); i++)
 
137
            fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
 
138
        fprintf(stderr, "\n");
 
139
    }
137
140
 
138
141
    return (0);
139
142
}
140
143
 
141
144
 
142
145
/* Display an error message. */
143
 
static void AX25_herror(char *text)
 
146
static void AX25_herror(const char *text)
144
147
{
145
148
    if (text == NULL)
146
149
        fprintf(stderr, "%s\n", AX25_errmsg);