#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <string.h>
#include <libintl.h>
#include <limits.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/varargs.h>
#include "volmgt_private.h"
char *
volmgt_getfullblkname(char *n)
{
extern char *getfullblkname(char *);
char *rval;
char namebuf[MAXPATHLEN+1];
char *s;
char c;
char *res;
rval = getfullblkname(n);
if ((rval != NULL) && (*rval != NULLC)) {
res = rval;
goto dun;
}
if (rval != NULL) {
free(rval);
}
if (((s = strstr(n, "/rfd")) != NULL) ||
((s = strstr(n, "/rdiskette")) != NULL) ||
((s = strstr(n, "/rdsk/")) != NULL)) {
c = *++s;
*s = NULLC;
(void) strcpy(namebuf, n);
*s++ = c;
(void) strcat(namebuf, s);
res = strdup(namebuf);
goto dun;
}
res = strdup("");
dun:
return (res);
}
char *
volmgt_getfullrawname(char *n)
{
extern char *getfullrawname(char *);
char *rval;
char namebuf[MAXPATHLEN+1];
char *s;
char c;
char *res;
#ifdef DEBUG
denter("volmgt_getfullrawname(%s): entering\n", n);
#endif
rval = getfullrawname(n);
if ((rval != NULL) && (*rval != NULLC)) {
res = rval;
goto dun;
}
if (rval != NULL) {
free(rval);
}
if (((s = strstr(n, "/fd")) != NULL) ||
((s = strstr(n, "/diskette")) != NULL) ||
((s = strstr(n, "/dsk/")) != NULL)) {
if (strlen(n) < (MAXPATHLEN - 1)) {
c = *++s;
*s = NULLC;
(void) strcpy(namebuf, n);
*s = c;
(void) strcat(namebuf, "r");
(void) strcat(namebuf, s);
res = strdup(namebuf);
goto dun;
}
}
res = strdup("");
dun:
#ifdef DEBUG
dexit("volmgt_getfullrawname: returning %s\n",
res ? res : "<null ptr>");
#endif
return (res);
}
#ifdef DEBUG
#define DEBUG_INDENT_SPACES " "
int debug_level = 0;
static void
derrprint(char *fmt, va_list ap)
{
int i;
int j;
char date_buf[256];
time_t t;
struct tm *tm;
(void) time(&t);
tm = localtime(&t);
(void) fprintf(stderr, "%02d/%02d/%02d %02d:%02d:%02d ",
tm->tm_mon+1, tm->tm_mday, tm->tm_year % 100,
tm->tm_hour, tm->tm_min, tm->tm_sec);
for (i = 0; i < debug_level; i++) {
(void) fprintf(stderr, DEBUG_INDENT_SPACES);
}
(void) vfprintf(stderr, fmt, ap);
}
void
denter(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
derrprint(fmt, ap);
va_end(ap);
debug_level++;
}
void
dexit(char *fmt, ...)
{
va_list ap;
if (--debug_level < 0) {
debug_level = 0;
}
va_start(ap, fmt);
derrprint(fmt, ap);
va_end(ap);
}
void
dprintf(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
derrprint(fmt, ap);
va_end(ap);
}
#endif