hostinfo.cc (8655:e4001326a5ba) hostinfo.cc (9142:e9b713df4e1d)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 31 unchanged lines hidden (view full) ---

40#include <cerrno>
41#include <cmath>
42#include <cstdio>
43#include <cstdlib>
44#include <cstring>
45#include <string>
46
47#include "base/misc.hh"
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 31 unchanged lines hidden (view full) ---

40#include <cerrno>
41#include <cmath>
42#include <cstdio>
43#include <cstdlib>
44#include <cstring>
45#include <string>
46
47#include "base/misc.hh"
48#include "base/str.hh"
48#include "base/types.hh"
49
50using namespace std;
51
52string
53__get_hostname()
54{
55 char host[256];

--- 16 unchanged lines hidden (view full) ---

72 char line[80];
73 char format[80];
74 long usage;
75
76 FILE *fp = fopen(filename, "r");
77
78 while (fp && !feof(fp) && !done) {
79 if (fgets(line, 80, fp)) {
49#include "base/types.hh"
50
51using namespace std;
52
53string
54__get_hostname()
55{
56 char host[256];

--- 16 unchanged lines hidden (view full) ---

73 char line[80];
74 char format[80];
75 long usage;
76
77 FILE *fp = fopen(filename, "r");
78
79 while (fp && !feof(fp) && !done) {
80 if (fgets(line, 80, fp)) {
80 if (strncmp(line, target, strlen(target)) == 0) {
81 if (startswith(line, target)) {
81 snprintf(format, sizeof(format), "%s %%ld", target);
82 sscanf(line, format, &usage);
83
84 fclose(fp);
85 return usage ;
86 }
87 }
88 }

--- 30 unchanged lines hidden ---
82 snprintf(format, sizeof(format), "%s %%ld", target);
83 sscanf(line, format, &usage);
84
85 fclose(fp);
86 return usage ;
87 }
88 }
89 }

--- 30 unchanged lines hidden ---