2
0

syscgen.inc 744 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // general purpose unix routines for syscall based *nix system unit.
  2. {$ifndef FPC_USE_LIBC}
  3. Function fpgetenv(name:pchar):pchar;[public, alias : 'FPC_SYSC_FPGETENVPCHAR'];
  4. var
  5. p : ppchar;
  6. np,cp : pchar;
  7. len,i : longint;
  8. Begin
  9. if (name=nil) or (envp=NIL) Then
  10. exit(NIL);
  11. np:=name;
  12. while (np^<>#0) and (np^<>'=') DO
  13. inc(np);
  14. len:=np-name;
  15. p:=envp;
  16. while (p^<>NIL) DO
  17. Begin
  18. cp:=p^;
  19. np:=name;
  20. i:=len;
  21. while (i<>0) and (cp^<>#0) DO
  22. Begin
  23. if cp^<>np^ Then
  24. Begin
  25. inc(cp); inc(np);
  26. break;
  27. End;
  28. inc(cp); inc(np);
  29. dec(i)
  30. End;
  31. if (i=0) and (cp^='=') Then
  32. exit(cp+1);
  33. inc(p);
  34. end;
  35. fpgetenv:=nil;
  36. End;
  37. {$ENDIF}