0

I am trying to add logging to the web proxy Polipo and as part of this need to log the url request in the following function following line:

httpClientRequest(HTTPRequestPtr request, AtomPtr url)

From compilation I see that AtomPtr is a struct of type _Atom but I cannot find where this is defined so that I can reference the text of the url in a log statement. What is the canonical method of looking up struct definitions in C code?

user1561108
  • 2,666
  • 9
  • 44
  • 69
  • You need to search through the .h files. A grep tool is useful in such situations. Many IDE's offer this feature. – Rishikesh Raje Nov 02 '16 at 06:53
  • 2
    It depends on your system and environment. If you're using an IDE it usually have functionality to find definitions built-in. If you're using the command-line then there are commands that can be used to find text in a set of files (the name of the command depends on the operating system you use). – Some programmer dude Nov 02 '16 at 06:54
  • 2
    Compile with `-D_Atom=123` and see where the first error is – M.M Nov 02 '16 at 07:08

4 Answers4

2

you can search AtomPtr like this and see where AtomPtr is defined

typedef struct _Atom {
    unsigned int refcount;
    struct _Atom *next;
    unsigned short length;
    char string[1];
} AtomRec, *AtomPtr;
saygins
  • 85
  • 1
  • 8
1

Unfortunately, as far as I know, you cannot do this from the source code in C.
If you are working on Linux, and if your sources are all in the src/ directory:

$ find src/ -name ".*\.h" | xargs grep -e "struct _Atom"
Manuel Allenspach
  • 12,467
  • 14
  • 54
  • 76
Right leg
  • 16,080
  • 7
  • 48
  • 81
0

If you are working on Linux, then grep the struct keyword in the current directory to see the definition of it in the file.

0

I was able to look up the definition of a structure MenuType by

grep -Rwn --include \*.h "struct MenuType"

This post helped me.