Subversion Repositories public

Rev

Rev 63 | Rev 67 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 63 Rev 65
Line 150... Line 150...
150
150
151
/// Lists an user table.
151
/// Lists an user table.
152
/**
152
/**
153
 * \param[in] user user name
153
 * \param[in] user user name
154
 * \return true = success, false = failure
154
 * \return true = success, false = failure
155
 *
-
 
156
 * \attention Listing is currently done through 'cat'.
-
 
157
 */
155
 */
158
bool list_table(const char* user)
156
bool list_table(const char* user)
159
{
157
{
160
  std::string tp(InCronTab::GetUserTablePath(user));
158
  std::string tp(InCronTab::GetUserTablePath(user));
161
 
159
 
162
  if (access(tp.c_str(), R_OK) != 0) {
160
  if (eaccess(tp.c_str(), R_OK) != 0) {
163
    if (errno == ENOENT) {
161
    if (errno == ENOENT) {
164
      fprintf(stderr, "no table for %s\n", user);
162
      fprintf(stderr, "no table for %s\n", user);
165
      return true;
163
      return true;
166
    }
164
    }
167
    else {
165
    else {
168
      fprintf(stderr, "cannot read table for %s: %s\n", user, strerror(errno));
166
      fprintf(stderr, "cannot read table for %s: %s\n", user, strerror(errno));
169
      return false;
167
      return false;
170
    }
168
    }
171
  }
169
  }
172
 
170
 
-
 
171
  FILE* f = fopen(tp.c_str(), "r");
-
 
172
  if (f == NULL)
-
 
173
    return false;
-
 
174
   
-
 
175
  char s[1024];
-
 
176
  while (fgets(s, 1024, f) != NULL) {
173
  std::string cmd("cat ");
177
    fputs(s, stdout);
-
 
178
  }
-
 
179
 
174
  cmd.append(tp);
180
  fclose(f);
-
 
181
 
175
  return system(cmd.c_str()) == 0;
182
  return true;
176
}
183
}
177
184
178
/// Allows to edit an user table.
185
/// Allows to edit an user table.
179
/**
186
/**
180
 * \param[in] user user name
187
 * \param[in] user user name