File: main.cpp

package info (click to toggle)
codelite 12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (70 lines) | stat: -rw-r--r-- 1,945 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#ifdef __WXMSW__
#include <io.h>
#endif

#include "network/clindexerprotocol.h"
#include "network/cl_indexer_reply.h"
#include "network/cl_indexer_request.h"
#include "network/named_pipe_client.h"
#include "network/np_connections_server.h"

#ifdef __WXMSW__
#define PIPE_NAME "\\\\.\\pipe\\codelite_indexer_%s"
#else
#define PIPE_NAME "/tmp/codelite_indexer.%s.sock"
#endif

int main(int argc, char** argv)
{
    if(argc < 2) {
        printf("Usage: %s <unique string>\n", argv[0]);
        printf("   <unique string> - a unique string that identifies the indexer which this client should connect\n");
        printf("                     this string may contain only [a-zA-Z]\n");
        return 1;
    }

    char channel_name[1024];
    sprintf(channel_name, PIPE_NAME, argv[1]);

    clIndexerRequest req;
    clNamedPipeClient client(channel_name);

    // build the request
    req.setCmd(clIndexerRequest::CLI_PARSE_AND_SAVE);
    std::vector<std::string> files;

    char* testFile = getenv("TEST_FILE");
    if(testFile == NULL) {
        printf("ERROR: Please set env variable TEST_FILE\n");
        exit(-1);
    }

    std::string file_name = testFile;
    files.push_back(file_name);

    req.setFiles(files);
    req.setCtagOptions("--excmd=pattern --sort=no --fields=aKmSsnit --c-kinds=+p --C++-kinds=+p  -IwxT,_T");
    for(size_t i = 0; i < 1; i++) {
        // connect to server
        if(!client.connect()) {
            printf("ERROR: failed to connect to server\n");
            break;
        }

        clIndexerProtocol::SendRequest(&client, req);

        clIndexerReply reply;
        std::string errmsg;
        if(!clIndexerProtocol::ReadReply(&client, reply, errmsg)) {
            printf("ERROR: failed to read reply\n");
        }
        std::cout << reply.getTags() << std::endl;
        client.disconnect();
    }
    return 0;
}