Kern's ToDo List
-                 17 January 2004
+                 27 January 2004
 
 Documentation to do: (any release a little bit at a time)
 - Document running a test version.
   In SD allow Device to have Multiple MediaTypes
 
 After 1.33:
+- Look at www.nu2.nu/pebuilder as a helper for full windows
+  bare metal restore.
+From Chris Hull:
+   it seems to be complaining about 12:00pm which should be a valid 12
+   hour time.  I changed the time to 11:59am and everything works fine.
+   Also 12:00am works fine.  0:00pm also works (which I don't think
+   should).  None of the values 12:00pm - 12:59pm work for that matter.
 Ideas from Jerry Scharf:
   First let's point out some big pluses that bacula has for this
         it's open source
 
 
 bindir=@SQL_BINDIR@
 
-if $bindir/mysql $* -f <<END-OF-DATA
-DROP DATABASE bacula;
-END-OF-DATA
-then
-   echo "Drop of bacula database succeeded."
+if test xmysql = x@DB_NAME@ ; then 
+  if $bindir/mysql $* -f <<END-OF-DATA
+    DROP DATABASE bacula;
+    END-OF-DATA
+  then
+    echo "Drop of bacula database succeeded."
+  else
+    echo "Drop of bacula database failed."
+  fi
 else
-   echo "Drop of bacula database failed."
+  echo "Bacula is not configured for a MySQL database."
 fi
 exit 0
 
 #
 # shell script to drop Bacula SQLite tables
 
-cd @working_dir@
-rm -rf bacula.db
+if test xsqlite = x@DB_NAME@ ; then 
+  cd @working_dir@
+  rm -rf bacula.db
+else
+  echo "Bacula is not configured for an SQLite database."
+fi
 
    db_unlock(mdb);
 }
 
+/* 
+ * Stupid MySQL is NON-STANDARD !  
+ */
+#ifdef HAVE_MYSQL
+#define FN "CONCAT(Path.Path,Filename.Name)"
+#else
+#define FN "Path.Path||Filename.Name"
+#endif
 
 void
 db_list_files_for_job(JCR *jcr, B_DB *mdb, uint32_t jobid, DB_LIST_HANDLER *sendit, void *ctx)
 {
    db_lock(mdb);
 
-   Mmsg(&mdb->cmd, "SELECT Path.Path,Filename.Name FROM File,\
-Filename,Path WHERE File.JobId=%u AND Filename.FilenameId=File.FilenameId \
-AND Path.PathId=File.PathId",
+   Mmsg(&mdb->cmd, "SELECT " FN " AS Filename FROM File,"
+"Filename,Path WHERE File.JobId=%u AND Filename.FilenameId=File.FilenameId "
+"AND Path.PathId=File.PathId",
       jobid);
 
    if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
 
    strip_trailing_junk(file);
    split_path_and_filename(rx, file);
    Mmsg(&rx->query, uar_jobid_fileindex, date, rx->path, rx->fname, rx->ClientName);
+   Dmsg1(000, "Query=%s\n", rx->query);
    rx->found = false;
    /* Find and insert jobid and File Index */
    if (!db_sql_query(ua->db, rx->query, jobid_fileindex_handler, (void *)rx)) {
 
       FD_SET(sockfd, &sockset);
       errno = 0;
       if ((stat = select(sockfd+1, &sockset, NULL, NULL, NULL)) < 0) {
-        if (errno == EINTR) {
+        if (errno == EINTR || errno == EAGAIN) {
            continue;
         }
         /* Error, get out */
       do {
         clilen = sizeof(cli_addr);
         newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
-      } while (newsockfd < 0 && errno == EINTR);
+      } while (newsockfd < 0 && (errno == EINTR || errno == EAGAIN));
       if (newsockfd < 0) {
         continue;
       }
     * Open a TCP socket  
     */
    for (tlog=0; (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0; tlog -= 10 ) {
-      if (errno == EINTR) {
+      if (errno == EINTR || errno == EAGAIN) {
         continue;
       }
       if (tlog <= 0) {
    serv_addr.sin_port = htons(port);
 
    for (tlog=0; bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0; tlog -= 5 ) {
-      if (errno == EINTR) {
+      if (errno == EINTR || errno == EAGAIN) {
         continue;
       }
       if (tlog <= 0) {
        */
       ready = sockset;
       if ((stat = select(bsock->fd+1, &ready, NULL, NULL, NULL)) < 0) {
-        if (errno == EINTR) {
+        if (errno == EINTR || errno = EAGAIN) {
            errno = 0;
            continue;
         }
       do {
         clilen = sizeof(cli_addr);
         newsockfd = accept(bsock->fd, (struct sockaddr *)&cli_addr, &clilen);
-      } while (newsockfd < 0 && errno == EINTR);
+      } while (newsockfd < 0 && (errno == EINTR || errno = EAGAIN));
       if (newsockfd >= 0) {
         break;
       }