Sponsored Content
Full Discussion: Need some help with this...
Top Forums Programming Need some help with this... Post 302138154 by Legend986 on Saturday 29th of September 2007 04:32:13 PM
Old 09-29-2007
Thank You. One problem I'm facing is that it is giving me a segmentation fault.


Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "extern.h"

char* program_name;

int allpaths;			/* -a */
int readalias;			/* -r */
const char *name = "PATH";
char *value;
int result;
char *filename;
char *pathsep = "/";
int i;

/*PASTED ONLY THE REQUIRED PART*/
int processIt(const char* command,  char* paths[])
{
  /* check your arguments! */
  /* At this point, the command line options have been taken care of assuming that only one option was there.
  Now, we need to take this "command" that was sent to us from the main function and then search for this command in the paths.*/
  
  /*paths contains the current path to be searched*/
  for(i=0;i<MAX_PATHS;i++) {
  strcat(paths[i],pathsep);
  strcat(paths[i],command);
  printf("%s",paths[i]);
  /*result = access(paths[i], F_OK);*/
  printf("%d",result); }
  return 0;
} /* processIt! */

processIt is the function I'm using to find the file. Any advice please?
 
SYSTEMD-PATH(1) 						   systemd-path 						   SYSTEMD-PATH(1)

NAME
systemd-path - List and query system and user paths SYNOPSIS
systemd-path [OPTIONS...] [NAME...] DESCRIPTION
systemd-path may be used to query system and user paths. The tool makes many of the paths described in file-hierarchy(7) available for querying. When invoked without arguments, a list of known paths and their current values is shown. When at least one argument is passed, the path with this name is queried and its value shown. The variables whose name begins with "search-" do not refer to individual paths, but instead to a list of colon-separated search paths, in their order of precedence. OPTIONS
The following options are understood: --suffix= The printed paths are suffixed by the specified string. -h, --help Print a short help text and exit. --version Print a short version string and exit. EXIT STATUS
On success, 0 is returned, a non-zero failure code otherwise. SEE ALSO
systemd(1), file-hierarchy(7) systemd 237 SYSTEMD-PATH(1)
All times are GMT -4. The time now is 03:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy