Jspice3
spiced.c File Reference
#include "spice.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
Include dependency graph for spiced.c:

Go to the source code of this file.

Functions

 main ()
 
char * tilde_expand (char *string)
 

Function Documentation

main ( )

Definition at line 300 of file spiced.c.

301 {
302  fprintf(stderr,
303  "The program \"spiced\" is not available on this system.\n");
304  return (1);
305 }
char* tilde_expand ( char *  string)

Definition at line 309 of file spiced.c.

313 {
314 #ifdef HAVE_GETPWUID
315  struct passwd *pw;
316  char *tail;
317  char buf[512];
318  char *k, c;
319 
320  if (!string)
321  return (NULL);
322 
323  while (*string && isspace(*string))
324  string++;
325 
326  if (*string != '~')
327  return copy(string);
328 
329  string += 1;
330 
331  if (!*string || *string == '/') {
332  pw = getpwuid(getuid());
333  *buf = 0;
334  }
335  else {
336  k = buf;
337  while ((c = *string) && c != '/')
338  *k++ = c, string++;
339  *k = 0;
340  pw = getpwnam(buf);
341  }
342 
343  if (pw) {
344  strcpy(buf, pw->pw_dir);
345  if (*string)
346  strcat(buf, string);
347  }
348  else
349  return (NULL);
350 
351  return (copy(buf));
352 
353 #else
354  return (copy(string));
355 #endif
356 }
static char buf[MAXPROMPT]
Definition: arg.c:18
char * strcpy()
char * copy()
#define NULL
Definition: spdefs.h:121
static double c
Definition: vectors.c:16