/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: teddy at bsnet
  • Date: 2011-12-24 19:43:26 UTC
  • mto: This revision was merged to the branch mainline in revision 531.
  • Revision ID: teddy@fukt.bsnet.se-20111224194326-egfeyd0140t03xmf
* plugins.d/mandos-client.c (add_server): Return bool; all callers
                                          changed.
  (resolve_callback): Check return value from add_server().
  (main/parse_opt): Bug fix; Remove extra message on --version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
}
203
203
 
204
204
/* Add server to set of servers to retry periodically */
205
 
int add_server(const char *ip, uint16_t port, AvahiIfIndex if_index,
206
 
               int af){
 
205
bool add_server(const char *ip, uint16_t port, AvahiIfIndex if_index,
 
206
                int af){
207
207
  int ret;
208
208
  server *new_server = malloc(sizeof(server));
209
209
  if(new_server == NULL){
210
210
    perror_plus("malloc");
211
 
    return -1;
 
211
    return false;
212
212
  }
213
213
  *new_server = (server){ .ip = strdup(ip),
214
214
                          .port = port,
216
216
                          .af = af };
217
217
  if(new_server->ip == NULL){
218
218
    perror_plus("strdup");
219
 
    return -1;
 
219
    return false;
220
220
  }
221
221
  /* Special case of first server */
222
222
  if (mc.current_server == NULL){
233
233
  ret = clock_gettime(CLOCK_MONOTONIC, &mc.current_server->last_seen);
234
234
  if(ret == -1){
235
235
    perror_plus("clock_gettime");
236
 
    return -1;
 
236
    return false;
237
237
  }
238
 
  return 0;
 
238
  return true;
239
239
}
240
240
 
241
241
/* 
1030
1030
      if(ret == 0){
1031
1031
        avahi_simple_poll_quit(mc.simple_poll);
1032
1032
      } else {
1033
 
        ret = add_server(ip, port, interface,
1034
 
                         avahi_proto_to_af(proto));
 
1033
        if(not add_server(ip, port, interface,
 
1034
                          avahi_proto_to_af(proto))){
 
1035
          fprintf_plus(stderr, "Failed to add server \"%s\" to server"
 
1036
                       " list\n", name);
 
1037
        }
1035
1038
      }
1036
1039
    }
1037
1040
  }
1671
1674
        argp_state_help(state, state->out_stream,
1672
1675
                        ARGP_HELP_USAGE | ARGP_HELP_EXIT_ERR);
1673
1676
      case 'V':                 /* --version */
1674
 
        fprintf_plus(state->out_stream,
1675
 
                     "Mandos plugin mandos-client: ");
1676
1677
        fprintf_plus(state->out_stream, "%s\n", argp_program_version);
1677
1678
        exit(argp_err_exit_status);
1678
1679
        break;