File: json.c

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (23 lines) | stat: -rw-r--r-- 619 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stddef.h>
#include <stdio.h>
#include <string.h>

int main(int argc,char* argv[]) {
  int i;
  printf("[");
  for (i=1; i<argc; ++i) {
    char* src=argv[i];
    char* dst=strrchr(src,'/');
    char dfn[100];	// enough for our use cases
    if (dst) ++dst; else dst=src;
    size_t j;
    for (j=0; j<90 && dst[j]; ++j) {
      if ((dfn[j]=dst[j])=='.') break;
    }
    dfn[j++]='.';
    dfn[j++]='o';
    dfn[j]=0;
    printf("\n{ \"directory\": \"@\", \"file\": \"%s\", \"output\": \"%s\", \"arguments\": [ \"clang\", \"-c\", \"%s\", \"-I.\" ]}%s ",src,dfn,src,(i+1<argc)?",":"");
  }
  printf("\n]\n");
}