예제 #1
0
int main(int argc, char *argv[])
{
ParseArguments(argc, argv);//incorrect arguments? print help & exit. Also, fill in SourceDirectoryName and DestinationDirectoryName; process flags.
Vprintf("OddBackup, version %s.\nBackup '%s' to '%s'.\n", VERSION, SourceDirectoryName, DestinationDirectoryName);
switch (Suspicion)
	{
	case 1: Vprintf("All attempts of shell-injections will be eliminated!\n");break;
	case 0: Vprintf("You'll be asked about fixing suspicious filenames.\n");break;
	case -1: Vprintf("You won't be disturbed with suspicious filenames. Enjoy your day!\n");break;
	}
struct dirent * DirectoryEntryPointer;
DIR * ProcessingDirPointer;

PushDir(SourceDirectoryName);

while (ProcessingDirectoryName = PopDir())
	{
	if (DotsCheck(ProcessingDirectoryName))//eliminate "." and ".." entries
		{
		continue;
		}
	if (!TryDirectory(ProcessingDirectoryName))
		{
		printf("Can't backup %s.\n", ProcessingDirectoryName);
		continue;
		}
	Dprintf("Processing %s\n", ProcessingDirectoryName);
	Vprintf("Entering %s\n", ProcessingDirectoryName);
	ProcessingDirPointer = opendir(ProcessingDirectoryName);
	CATCH_ERROR("Can't open directory");
	while ((DirectoryEntryPointer = readdir(ProcessingDirPointer)) != NULL)
		{
		switch(DirectoryEntryPointer->d_type)
			{
			case DT_DIR :	PushDir(AbsoluteSourceName(DirectoryEntryPointer->d_name)); break;//it's a directory - will be processed too
			case DT_REG :	if (IsToBeBackuped(DirectoryEntryPointer->d_name))//it's a file
						{
						BackupAndGzip(DirectoryEntryPointer->d_name);
						};
					break;
			default : printf("%s is neither file nor directory - can't backup.\n", DirectoryEntryPointer->d_name);
			}
		}
	Vprintf("Leaving %s\n", ProcessingDirectoryName);
	closedir(ProcessingDirPointer);
	free(ProcessingDirectoryName);
	}

return 0;
}
예제 #2
0
파일: MGEffect.cpp 프로젝트: EQ4/neonv2
//---------------------------------------------------------------------------//
// Load
//
//---------------------------------------------------------------------------//  
bool CMGEffect::Load(CNodeFile::CNode *pNode)
{
  // Load FX data
  m_FXClass  = pNode->AttrAsString("fxclass");
  m_FXDir    = pNode->AsString    ("fxdir");
  m_FXFile   = pNode->AsString    ("fxfile");
  m_FXName   = pNode->AsString    ("fxname", m_FXName);
  m_FileName = pNode->AsString    ("filename", m_FileName);

  PushDir("Effects/" + m_FXDir);
  CVJEffect::TVJSnapshot Snapshot;
  m_ID = g_pAppMain->VJController()->FXLoad(m_FXClass, m_FXFile, &Snapshot);
  PopDir ();
  if (m_ID != -1)
  {
    // Load controls and snapshot
    LoadSnapshot  (&Snapshot, m_Bitmap);
    CreateControls();

    // Load vars, filters and its links
    LoadVars   (pNode);
    LoadFilters(pNode);
  }

  return (m_ID != -1);
}
예제 #3
0
void cDirectoryListing::Retrieve( DEFINITIONCATEGORIES dir )
{
	bool dirSet = PushDir( dir );
	InternalRetrieve();
	if( dirSet )
		PopDir();
}
예제 #4
0
void cDirectoryListing::Retrieve( std::string dir )
{
	bool dirSet = PushDir( dir );
	InternalRetrieve();
	if( dirSet )
		PopDir();
}
예제 #5
0
//----------------------------------------------------------------------------------------------
vector<string> FileManager::GetFiles(const TCHAR* p_dirPath, char* p_filter)
{
    vector<string> fileNames;

    LPTSTR args[2];
    args[1] = p_filter;

    PushDir(p_dirPath);
    GetFilesAux(2, args, p_filter, fileNames);
    PopDir();

    return fileNames;
}
예제 #6
0
파일: usertabl.c 프로젝트: swhobbit/UUPC
static size_t loaduser( void )
{
   FILE *stream;
   struct UserTable *userp;
   size_t subscript;
   char *token;

/*--------------------------------------------------------------------*/
/*     First, load in the active user as first user in the table      */
/*--------------------------------------------------------------------*/

   userp = inituser( E_mailbox );
   userp->realname = E_name;
   userp->homedir  = E_homedir;

/*--------------------------------------------------------------------*/
/*       Password file format:                                        */
/*          user id:password:::user/system name:homedir:shell         */
/*--------------------------------------------------------------------*/

   if ((stream = FOPEN(E_passwd, "r",TEXT_MODE)) == NULL)
   {
      if ( debuglevel > 2 )
         printerr( E_passwd );

      users = realloc(users, userElements *  sizeof(*users));

      checkref(users);
      return userElements;
   } /* if */

   PushDir( E_confdir );      /* Use standard reference point for     */
                              /* for directories                      */

/*--------------------------------------------------------------------*/
/*                 The password file is open; read it                 */
/*--------------------------------------------------------------------*/

   while (! feof(stream))
   {
      char buf[BUFSIZ];

      if (fgets(buf,BUFSIZ,stream) == NULL)   /* Try to read a line   */
         break;               /* Exit if end of file                  */

      if ((*buf == '#') || (*buf == '\0'))
         continue;            /* Line is a comment; loop again        */

      if ( buf[ strlen(buf) - 1 ] == '\n')
         buf[ strlen(buf) - 1 ] = '\0';

      token = NextField(buf);

      if (token    == NULL)   /* Any data?                            */
         continue;            /* No --> read another line             */

      userp = inituser(token);/* Initialize record for user           */

      if ( userp->uid == NULL )
      {
         panic();
      }

      if (userp->password != NULL)  /* Does the user already exist?   */
      {                       /* Yes --> Report and ignore            */

         printmsg(0,"loaduser: Duplicate entry for '%s' in '%s' ignored",
               token,E_passwd);
         continue;            /* System already in /etc/passwd,
                                 ignore it.                           */
      }

/*--------------------------------------------------------------------*/
/*       Password fields are funny; if the tokenize field function    */
/*       is returns NULL, we set the password to the comparable       */
/*       empty string ("").  But if the password is if asterisk       */
/*       (*), we leave the password NULL, and the user can never      */
/*       login remotely.                                              */
/*--------------------------------------------------------------------*/

      token = NextField(NULL);   /* Get the user password             */

      if ( token == NULL )       /* No password needed for login?     */
      {
         printmsg(2,"loaduser: WARNING: No password assigned for user %s",
                     userp->uid );
         userp->password = "";   /* Assign requested password        */
      }
      else if (!equal(token,"*")) /* User can login with passwd?      */
         userp->password = newstr(token); /* Yes --> Set password     */

      token = NextField(NULL);   /* Use  UNIX user number as tone     */
                                 /* to beep at                        */
      if (token != NULL)
         userp->beep = newstr( token );

      token = NextField(NULL);   /* UNIX group number                 */

      if (token != NULL)         /* Did they provide a group?         */
         userp->group = newstr(token); /* Yes --> Copy                */

      token = NextField(NULL);   /* Get the formal user name          */

      if (token != NULL)         /* Did they provide user name?       */
         userp->realname = newstr(token); /* Yes --> Copy             */

      token = NextField(NULL);   /* Get home directory (optional)     */

      if ( token != NULL)
      {
         userp->homedir = newstr(normalize( token ));
         if ( equal( userp->uid, E_mailbox ))
            E_homedir = userp->homedir;
      }

      token = NextField(NULL);   /* Get user shell (optional)         */

      if ( token != NULL )       /* Did we get it?                    */
         userp->sh = newstr(token); /* Yes --> Copy it in             */

   }  /* while */

   PopDir();

   fclose(stream);
   users = realloc(users, userElements *  sizeof(*users));
   checkref(users);

   qsort(users, userElements ,sizeof(users[0]) , usercmp);

   for (subscript = 0 ; subscript < userElements; subscript ++)
   {
      KWBoolean duplicate = KWFalse;

      if ( subscript && equali( users[subscript].uid,
                                users[subscript- 1 ].uid))
      {
         printmsg(0,"*error* The user id \"%s\" occurs more than once in %s!"
                    "  Delete extra entries!",
                     users[subscript-1].uid,
                     E_passwd );

         duplicate = KWTrue;
      }

      printmsg(duplicate ? 0: 8,
                 "loaduser: user[%d]\tlogin(%s)\tno(%s)\tgroup(%s)"
                 "\tname(%s)\thome(%s)\tshell(%s)",
         subscript,
         users[subscript].uid,
         users[subscript].beep == NULL ? "NONE" : users[subscript].beep,
         users[subscript].group,
         users[subscript].realname,
         users[subscript].homedir,
         users[subscript].sh);
   } /* for */

   return userElements;

} /* loaduser */
예제 #7
0
파일: temp.c 프로젝트: stqism/DEMOS
tinit()
{
	register char *cp, *cp2;
	char uname[PATHSIZE];
	register int err = 0;
	register int pid;

	pid = getpid();
#ifndef MSDOS
	sprintf(tempMail, "/tmp/Rs%05d", pid);
	sprintf(tempResid, "/tmp/Rq%05d", pid);
	sprintf(tempQuit, "/tmp/Rm%05d", pid);
	sprintf(tempEdit, "/tmp/Re%05d", pid);
	sprintf(tempSet, "/tmp/Rx%05d", pid);
	sprintf(tempMesg, "/tmp/Ry%05d", pid);
	sprintf(tempBack, "/tmp/Rb%05d", pid);
#else   /* MSDOS */
	PushDir(".");
	if ((cp = value("MAILDIR")) == NOSTR)
		cp = ".";
	cp = copy(cp, master);
	if (cp[-1] != SEPCHAR)
		*cp++ = SEPCHAR;
	*cp = '\0';
	strcpy(aliases, master);
	strcpy(hlp, master);
	strcpy(rhelp, master);
	strcpy(helpt, master);
	strcpy(rhelpt, master);
#ifdef	NETMAIL
	strcpy(sendprog, calldir);
#endif

	strcat(master, MASTER);
	strcat(aliases, ALIASES);
	strcat(hlp, HELPFILE);
	strcat(rhelp, RHELPFILE);
	strcat(helpt, THELPFILE);
	strcat(rhelpt, RTHELPFILE);
#endif  /* MSDOS */
#ifdef  NETMAIL
	strcat(sendprog, SENDMAIL);
#endif
#ifdef	MSDOS
	(void) atexit(uuiocall);
	(void) atexit(PopDir);
	(void) atexit(TmpDelAll);
	(void) atexit(deltftemp);
	(void) atexit(unlock);
#endif  /* MSDOS */

	if (strlen(myname) != 0) {
#ifndef MSDOS
		uid = getuserid(myname);
		if (uid == -1) {
			printf(ediag(
"\"%s\" is not a user of this system\n",
"\"%s\" не пользователь этой системы\n"),
			    myname);
			exit(1);
		}
#endif
	}
	else {
#ifndef MSDOS
		uid = getuid() & UIDMASK;
#else
		uid = -1;
#endif
		if (username(uid, uname) < 0) {
#ifndef MSDOS
			copy("ubluit", myname);
			err++;
			if (rcvmode) {
				printf(ediag("Who are you!?\n","Кто вы!?\n"));
				exit(1);
			}
#else
			printf(ediag("Who are you? ","Кто вы? "));
			if (!intty)
			    printf(ediag("(user name required)\n",
					 "(должно быть имя пользователя)\n"));
			if (!intty || (flush (), gets(myname)) == NOSTR)
				exit(1);
#endif
		}
		else
			copy(uname, myname);

	}
	if ((cp = value("HOME")) == NOSTR)
		cp = ".";
	cp = copy(cp, homedir);
	if (cp[-1] != SEPCHAR)
		*cp++ = SEPCHAR;
	*cp = '\0';
	findmail();
	cp = copy(homedir, mbox);
	copy("mbox", cp);
	cp = copy(homedir, mailrc);
#ifndef MSDOS
	copy(".mailrc", cp);
#else
	copy("mailrc", cp);
#endif
	cp = copy(homedir, deadletter);
#ifndef MSDOS
	copy("dead.letter", cp);
#else
	copy("dead.let", cp);
#endif
	cp = copy(homedir, signature);
#ifndef MSDOS
	copy(".signature", cp);
#else
	copy("personal.sig", cp);
#endif
	if (debug) {
		printf("uid = %d, user = %s, mailname = %s\n",
		    uid, myname, mailname);
		printf("deadletter = %s, mailrc = %s, mbox = %s\n",
			deadletter, mailrc, mbox);
		flush();
	}
}
예제 #8
0
파일: dcp.c 프로젝트: swhobbit/UUPC
int dcpmain(int argc, char *argv[])
{

   char *logfile_name = NULL;
   KWBoolean  contacted = KWFalse;

   int option;
   int pollMode = POLL_ACTIVE;   /* Default = dial out to system     */
   time_t exitTime = LONG_MAX;

   char recvGrade = ALL_GRADES;
   KWBoolean overrideGrade = KWFalse;
   KWBoolean runUUXQT = KWFalse;

   char *hotUser = NULL;
   BPS  hotBPS = 0;
   int  hotHandle = -1;

   fwork = nil(FILE);

/*--------------------------------------------------------------------*/
/*                        Process our options                         */
/*--------------------------------------------------------------------*/

   while ((option = getopt(argc, argv, "d:g:h:m:l:r:s:tUw:x:z:n?")) != EOF)
      switch (option)
      {

      case 'd':
         exitTime = atoi( optarg );
         exitTime = time(NULL) + hhmm2sec(exitTime);
         pollMode = POLL_PASSIVE;  /* Implies passive polling       */
         break;

      case 'g':
         if (strlen(optarg) == 1 )
            recvGrade = *optarg;
         else {
            recvGrade = checktime( optarg );
                                 /* Get restriction for this hour */
            if ( ! recvGrade )   /* If no class, use the default  */
               recvGrade = ALL_GRADES;
         }
         overrideGrade = KWTrue;
         break;

      case 'h':
         hotHandle = atoi( optarg );   /* Handle opened for us       */
         pollMode = POLL_PASSIVE;  /* Implies passive polling       */
         break;

      case 'm':                     /* Override in modem name     */
         E_inmodem = optarg;
         pollMode = POLL_PASSIVE;  /* Implies passive polling       */
         break;

      case 'l':                     /* Log file name              */
         logfile_name = optarg;
         break;

      case 'n':
         callnow = KWTrue;
         break;

      case 'r':
         pollMode = atoi(optarg);
         break;

      case 's':
         Rmtname = optarg;
         break;

      case 't':
         traceEnabled = KWTrue;
         break;

      case 'U':
         runUUXQT = KWTrue;
         break;

      case 'x':
         debuglevel = atoi(optarg);
         break;

      case 'z':
         hotBPS = (BPS) atoi(optarg);
         pollMode = POLL_PASSIVE;  /* Implies passive polling       */
         break;

      case 'w':
         pollMode = POLL_PASSIVE;  /* Implies passive polling       */
         hotUser = optarg;
         break;

      case '?':
         puts("\nUsage:\tuucico\t"
         "[-s [all | any | sys]] [-r 1|0] [-d hhmm]\n"
         "\t\t[-l logfile] [-n] [-t] [-U] [-x debug]\n"
         "\t\t[-h handle] [-m modem] [-z bps]");
         return 4;
      }

/*--------------------------------------------------------------------*/
/*                Abort if any options were left over                 */
/*--------------------------------------------------------------------*/

   if (optind != argc) {
      puts("Extra parameter(s) at end.");
      return 4;
   }

/*--------------------------------------------------------------------*/
/*        Initialize logging and the name of the systems file         */
/*--------------------------------------------------------------------*/

   openlog( logfile_name );

   if (bflag[F_SYSLOG] && ! bflag[F_MULTITASK])
   {
      syslog = FOPEN(SYSLOG, "a",TEXT_MODE);
      if ((syslog == nil(FILE)) || setvbuf( syslog, NULL, _IONBF, 0))
      {
         printerr( SYSLOG );
         panic();
      }
   }

   PushDir(E_spooldir);
   atexit( PopDir );

   if ( terminate_processing )
      return 100;

/*--------------------------------------------------------------------*/
/*                        Initialize security                         */
/*--------------------------------------------------------------------*/

   if ( !LoadSecurity())
   {
      printmsg(0,"Unable to initialize security, see previous message");
      panic();
   }

   if ( terminate_processing )
      return 100;

#if defined(_Windows)
   atexit(CloseEasyWin);       /* Auto-close EasyWin window on exit   */
#endif

   atexit( shutDown );        /* Insure port is closed by panic()    */
   remote_stats.hstatus = HS_NOCALL;
                              /* Known state for automatic status
                                 update                              */

/*--------------------------------------------------------------------*/
/*                     Begin main processing loop                     */
/*--------------------------------------------------------------------*/

   if (pollMode == POLL_ACTIVE)
      contacted = master(recvGrade, overrideGrade, runUUXQT );
   else if (pollMode == POLL_PASSIVE)
      contacted = client(exitTime,
                         hotUser,
                         hotBPS,
                         hotHandle,
                         runUUXQT);
   else {
      printmsg(0,"Invalid -r flag, must be 0 or 1");
      panic();
   }

/*--------------------------------------------------------------------*/
/*                         Report our results                         */
/*--------------------------------------------------------------------*/

   if (!contacted && (pollMode == POLL_ACTIVE))
   {
      if (dialed)
         printmsg(0, "Could not connect to remote system.");
      else
         printmsg(0,
               "No work for requested system or wrong time to call.");
   }

   dcupdate();

   if (bflag[F_SYSLOG] && ! bflag[F_MULTITASK])
      fclose(syslog);

   return terminate_processing ? 100 : (contacted ? 0 : 5);

} /* dcpmain */
예제 #9
0
FileManager::FileManager()
{
    int length = GetCurrentDirectory(MAX_PATH_LONG, workingDirectory);
    _ASSERTE(length > 0);
    PushDir(workingDirectory);
}
예제 #10
0
bool cDirectoryListing::PushDir( DEFINITIONCATEGORIES toMove )
{
	std::string filePath	= cwmWorldState->ServerData()->Directory( CSDDP_DEFS );
	filePath				+= dirnames[toMove];
	return PushDir( filePath );
}