+/**
+ * The log function.
+ *
+ * \param ll Loglevel.
+ * \param fml Usual format string.
+ *
+ * All XXX_LOG() macros use this function.
+ */
+__printf_2_3 void __log(int ll, const char* fmt,...)
+{
+ va_list argp;
+ FILE *outfd;
+ struct tm *tm;
+ time_t t1;
+ char str[255] = "";
+
+ if (ll < conf.loglevel_arg)
+ return;
+ outfd = stderr;
+ time(&t1);
+ tm = localtime(&t1);
+ strftime(str, sizeof(str), "%b %d %H:%M:%S", tm);
+ fprintf(outfd, "%s ", str);
+ va_start(argp, fmt);
+ vfprintf(outfd, fmt, argp);
+ va_end(argp);
+}
+
+static int open_user_table(struct user_info *ui, int create)
+{
+ int ret;
+ struct passwd *pw;
+
+ ui->desc = adu_malloc(sizeof(*ui->desc));
+ ui->desc->num_columns = NUM_UT_COLUMNS;
+ ui->desc->flags = 0;
+ ui->desc->column_descriptions = user_table_cols;
+ ui->desc->dir = adu_strdup(conf.database_dir_arg);
+ ui->desc->name = make_message("%u", (unsigned)ui->uid);
+ pw = getpwuid(ui->uid);
+ if (pw && pw->pw_name)
+ ui->pw_name = adu_strdup(pw->pw_name);
+
+ INFO_LOG(".............................uid #%u: %u\n",
+ (unsigned)num_uids, (unsigned)ui->uid);
+ if (create) {
+ ret = osl(osl_create_table(ui->desc));
+ if (ret < 0)
+ goto err;
+ num_uids++;
+ }
+ ret = osl(osl_open_table(ui->desc, &ui->table));
+ if (ret < 0)
+ goto err;
+ return 1;
+err:
+ free((char *)ui->desc->name);
+ free((char *)ui->desc->dir);
+ free(ui->pw_name);
+ free(ui->desc);
+ ui->desc->name = NULL;
+ ui->desc->dir = NULL;
+ ui->desc = NULL;
+ ui->table = NULL;
+ ui->flags = 0;
+ return ret;
+}