void fetch_message_media (struct message_media *M) { memset (M, 0, sizeof (*M)); M->type = fetch_int (); switch (M->type) { case CODE_message_media_empty: break; case CODE_message_media_photo: fetch_photo (&M->photo); break; case CODE_message_media_video: fetch_video (&M->video); break; case CODE_message_media_geo: fetch_geo (&M->geo); break; case CODE_message_media_contact: M->phone = fetch_str_dup (); M->first_name = fetch_str_dup (); M->last_name = fetch_str_dup (); M->user_id = fetch_int (); break; case CODE_message_media_unsupported: M->data = fetch_str_dup (); break; default: logprintf ("type = 0x%08x\n", M->type); assert (0); } }
void fetch_photo (struct photo *P) { memset (P, 0, sizeof (*P)); unsigned x = fetch_int (); assert (x == CODE_photo_empty || x == CODE_photo); P->id = fetch_long (); if (x == CODE_photo_empty) { return; } P->access_hash = fetch_long (); P->user_id = fetch_int (); P->date = fetch_int (); P->caption = fetch_str_dup (); fetch_geo (&P->geo); assert (fetch_int () == CODE_vector); P->sizes_num = fetch_int (); P->sizes = malloc (sizeof (struct photo_size) * P->sizes_num); int i; for (i = 0; i < P->sizes_num; i++) { fetch_photo_size (&P->sizes[i]); } }
static msg_t geo_thread(void *p) { msg_t msg, result; struct packet_msg *pkt; (void)p; while (TRUE) { msg = fetch_geo(); pkt = (struct packet_msg *) msg; Tgeos1m_packet_geographic *Pmsg = (Tgeos1m_packet_geographic *)pkt->data; double time_s_int; double time_s_fract = modf(Pmsg->time_s, &time_s_int); time_t tstamp = 0x47798280 + (int)time_s_int; struct tm *gtim = gmtime(&tstamp); chprintf((BaseSequentialStream *)&SDDBG, "GEOGRAPH PARSE tstamp = %ld\r\n", tstamp); geoinfo.dtime.msec = (int)(time_s_fract * 1000); geoinfo.dtime.sec = gtim->tm_sec; geoinfo.dtime.min = gtim->tm_min; geoinfo.dtime.hour = gtim->tm_hour; geoinfo.dtime.mday = gtim->tm_mday; geoinfo.dtime.mon = gtim->tm_mon; //(Months *since* january: 0-11) geoinfo.dtime.year = gtim->tm_year + 1900 - 2000; geoinfo.lat = Pmsg->lat; geoinfo.lon = Pmsg->lon; geoinfo.alt = Pmsg->alt; geo_motion2D_pol2geo(Pmsg->course, Pmsg->speed, &geoinfo.motion);// ñêîðîñòü, êóðñ geo_DOP2geo(Pmsg->HDOP, Pmsg->VDOP, Pmsg->TDOP, &geoinfo.prec); #if 0 DEBUGCRLF(GNSS, DETAILED); geo_time_result();//geo&time debug prited by this function dop_result(); #endif chHeapFree(pkt); } return 0; }