ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/Spectre/Maker.cpp
(Generate patch)

Comparing trunk/Spectre/Maker.cpp (file contents):
Revision 166 by douglas, 2003-06-14T02:20:39-07:00 vs.
Revision 169 by douglas, 2003-06-23T21:09:07-07:00

# Line 66 | Line 66 | void Maker::samba()
66  
67          ipstream smbclient(config.smbclient, args);
68  
69 <        //
69 >        if (connect(smbclient))
70 >        {
71 >                for (unsigned index = 0; index < 2; index++)
72 >                {
73 >                        string line;
74 >
75 >                        getline(smbclient, line);
76 >
77 >                        if (debug) cerr << line << "\n";
78 >                }
79 >
80 >                samba(smbclient);
81 >        }
82 >        else
83 >        {
84 >                cerr << program << ": Connection to " << host << " failed\n";
85 >        }
86 >
87 >        smbclient.close();
88  
89          unlink(credentials);
90   }
91  
92 + bool Maker::connect(ipstream& pin)
93 + {
94 +        while (pin.good())
95 +        {
96 +                string line;
97 +
98 +                getline(pin, line);
99 +
100 +                if (debug) cerr << line << "\n";
101 +
102 +                if (line == "")
103 +                {
104 +                        return true;
105 +                }
106 +                else if (line == "Connection to " + host + " failed")
107 +                {
108 +                        return false;
109 +                }
110 +        }
111 +
112 +        return false;
113 + }
114 +
115 + void Maker::samba(ipstream& pin)
116 + {
117 +        while (pin.good())
118 +        {
119 +                if (pin.peek() != '\t') break;
120 +
121 +                pin.ignore();
122 +                
123 +                char share[16];
124 +                char type[11];
125 +                string comment;
126 +
127 +                pin.get(share, 16);
128 +                pin.get(type, 11);
129 +                getline(pin, comment);
130 +
131 +                if (debug) cerr << "\t" << share << type << comment << "\n";
132 +
133 +                strip(share);
134 +                strip(type);
135 +
136 +                if (string(type) == "Disk")
137 +                {
138 +                        unsigned end = strlen(share) - 1;
139 +
140 +                        if (share[end] == '$') continue;
141 +
142 +                        //
143 +                }
144 +        }
145 +
146 +        string line;
147 +
148 +        getline(pin, line);
149 +
150 +        if (debug) cerr << line << "\n";
151 +
152 +        if (line != "")
153 +        {
154 +                cerr << program << ": Error returning browse list\n";
155 +        }
156 + }
157 +
158 + void Maker::strip(char* name)
159 + {
160 +        for (unsigned index = strlen(name); index > 0; index--)
161 +        {
162 +                if (name[index - 1] == ' ')
163 +                {
164 +                        name[index - 1] = '\0';
165 +                }
166 +                else
167 +                {
168 +                        break;
169 +                }
170 +        }
171 + }
172 +
173   void Maker::make(const string& folder, const string& user)
174   {
175          struct stat dir;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines