home *** CD-ROM | disk | FTP | other *** search
-
- /*+
- * File: main.c
- *
- * Description:
- * List a directory, display it for selection and execute an action on
- * the selected file.
- *
- * This module is the proprietary property of Cottege Computing
- * copyright 1989, all rights reserved.
- *
- * Audit Trail:
- * SCCS = @(#) main.c 1.2 11/20/89 16:45:33
- * Dan Flak - 11/18/89
- *
- -*/
-
- /* #includes */
- #include <stdio.h>
-
- /* #defines */
- #define SAY printf
- #define WIDTH 14
- #define MAXFILES 255
-
- /* external variables */
-
- /* referenced external functions */
- int listdir(); /* Prepares a list of files */
- char *select(); /* shows the list of files for slec-
- * tion */
-
- /* referenced internal functions */
-
- /* global variables */
- char xarray[MAXFILES][WIDTH + 1]; /* Array of filenames */
- char *aptr[MAXFILES]; /* Array of pointers to filenames */
-
- int narray; /* Number of elements in array */
-
- /* static variables */
-
- /*<
- * Function: main (argc, argv)
- *
- * Description:
- * Call listdir to fill the array with filenames. Call select to display
- * them. Exec a command on the selected file.
- *
- * Data Type: int
- *
- * Arguments:
- * argv[1] = directory name
- * argv[2] = sort key (0 = alphabetical, 1 = by date)
- * argv[3] = showdot (0 = don't show .*, 1 = show .*)
- * argv[4] = command to execute
- * . .
- * . .
- * . .
- * argv[n] = options to the command to execute.
- *
- * Returns:
- *
- * Side Effects:
- *
- * Calls:
- *
- * PDL:
- *
- >*/
-
- int
- main (argc, argv)
- int argc;
- char *argv[];
- {
- int i;
- char *ptr;
- char cmdstr[128];
-
- for (i = 0; i < MAXFILES; i++) /* initalize the pointers to the */
- { /* the array */
- aptr[i] = xarray[i];
- }
-
- narray = listdir (argv[1], aptr, atoi (argv[2]), atoi (argv[3]));
- /* get directory contents */
-
- ptr = select (aptr, narray, WIDTH); /* select a file */
-
- if (*ptr != NULL) /* display it */
- {
- chdir (argv[1]);
- strcpy (cmdstr, argv[4]);
- for (i = 5; i < argc; i++)
- {
- sprintf (cmdstr, "%s %s", cmdstr, argv[i]);
- }
- sprintf (cmdstr,"%s %s", cmdstr, ptr);
- system (cmdstr);
- }
- }
-