Saturday, December 28, 2019

kavithai - 1

ஊரெங்கும் காதல் மழை,
உலர்ந்திருக்க நான் விரும்பவில்லை,
மின்னல் போல் அவள் அழைத்தாள்,
குடையை வைத்து ஏன் மழை மறைத்தாள்.

Tuesday, December 10, 2019

cJSON Tutorial

git clone https://github.com/DaveGamble/cJSON.git
 cd cJSON/
 mkdir build
 cd build/
 cmake ..
 sudo make install
 cd ..
 sudo ln -s /usr/local/lib/libcjson.so /usr/lib/libcjson.so
 sudo ln -s /usr/local/lib/libcjson.so.1 /usr/lib/libcjson.so.1
 sudo ln -s /usr/local/lib/libcjson.so.1.7.12 /usr/lib/libcjson.so.1.7.12
 gcc cJSONTestProgram.c -l cjson
 ./a.out

Planet:
Mars, 6.39e+23 kgs
Moon:
Phobos, 70 kms
Moon:
Deimos, 39 kms
satheesh@skyrdkdev:~/cJSON$ cat cJSONTestProgram.c
//src: https://spacesciencesoftware.wordpress.com/2013/09/10/a-good-way-to-read-json-with-c/
#include stdio.h #include string.h #include cjson/cJSON.h int main(int argc, const char * argv[]) { /*{ "name": "Mars", "mass": 639e21, "moons": [ { "name": "Phobos", "size": 70 }, { "name": "Deimos", "size": 39 } ] }*/ char *strJson = "{\"name\" : \"Mars\",\"mass\":639e21,\"moons\": [{\"name\":\"Phobos\",\"size\":70},{\"name\":\"Deimos\",\"size\":39}]}"; printf("Planet:\n"); // First, parse the whole thing cJSON *root = cJSON_Parse(strJson);
// Let's get some values char *name = cJSON_GetObjectItem(root, "name")->valuestring; double mass = cJSON_GetObjectItem(root, "mass")->valuedouble;
printf("%s, %.2e kgs\n", name, mass); // Note the format! %.2e will print a number with scientific notation and 2 decimals
// Now let's iterate through the moons array cJSON *moons = cJSON_GetObjectItem(root, "moons");
// Get the count int moons_count = cJSON_GetArraySize(moons); int i;
for (i = 0; i < moons_count; i++) { printf("Moon:\n");
// Get the JSON element and then get the values as before cJSON *moon = cJSON_GetArrayItem(moons, i); char *name = cJSON_GetObjectItem(moon, "name")->valuestring; int size = cJSON_GetObjectItem(moon, "size")->valueint; printf("%s, %d kms\n", name, size); } // Finally remember to free the memory! cJSON_Delete(root); return 0; } satheesh@skyrdkdev:~/cJSON$

Monday, December 2, 2019

ஒருதலை காதல்

கண்ணில் ஓவியம் காட்டும்,
உதட்டில் நட்பு பாராட்டும்,
இதயத்தில் ஒளிந்து விளையாடும், இது...

உடல் தேய்ந்த, ஒருதலையாய் நின்ற காதல்,
ஆம், தூக்கம் மறந்து இன்று ஒருதலை நின்ற என் காதல்...

சொன்னால் அது உன்னை சுடுமோ,
கொல்லாமல் இது என்னை விடுமோ,

தூண்டிலில் மாட்டிய மீன்,
மீனவன் தொண்டையில் மாட்டியது போல்....
நான் பட்டை தீட்டிய காதல்,
என்னை பதம் பார்த்திடுமோ....

--சதீஷ் குமார்