int main(int argc, char *argv[]) { struct tm *currenttime; time_t caltime; char filename[30]="\0", fileorig[17]="\0"; if (argc != 3) { printf("Usage: makefits inputdatafile inputheaderfile\n"); printf("\n"); printf("Examples:\n"); printf("\n") ; printf("makefits in.dat[ul2560,2048:4] header.fit\n"); printf("\n"); printf("Note that it may be necessary to enclose the input data file name\n"); printf("in single quote characters on the Unix command line.\n"); return(0); } caltime = time ( NULL ); currenttime = gmtime( &caltime ); /* S = Spacecraft (a,b,d) (d is for "development", or anything that is not associated with one or the other s/c); T = a digit representing telescope: 1=EUVI, 2=COR1, 3=COR2, 4=HI1, 5=HI2, 6=GT, 0=generic "development"; L = a digit representing number of images used to create this image, 0 if > 9; */ sprintf (filename, "d01_%04i%02i%02i_%02i%02i%02i.fts", (*currenttime).tm_year+1900, (*currenttime).tm_mon+1, (*currenttime).tm_mday, (*currenttime).tm_hour, (*currenttime).tm_min, (*currenttime).tm_sec); printf ("%s\n",filename); fitscopy ( argv[1], filename ); appendheader ( filename, argv[2] ); addkey ( filename, "FILENAME", filename ); if (!strcspn (argv[1], "[")) strcpy(fileorig, argv[1]); else strncpy(fileorig, argv[1], (strcspn (argv[1], "["))); addkey ( filename, "FILEORIG", fileorig ); return(0); }
void handlepencilmsg(cJSON *json, struct user *usr) { struct pencil *p = &usr->pencil; struct buffer buf; char buffer_empty = 1; char mousedown; json = jsongetjson(json, "data"); if (!json) return; json = json->child; p->ticksolid = max(p->ticksolid + 1, usr->gm->tick + SERVER_DELAY / TICK_LENGTH + usr->gm->inkdelay / TICK_LENGTH); /* this will be sent to other players */ buf.start = 0; appendheader(&buf, MODE_PENCIL, usr->index); appendtick(&buf, p->ticksolid); if ((mousedown = json->valueint == -1)) json = json->next; appendchar(&buf, mousedown); assert(!pthread_mutex_lock(&usr->gm->lock)); while (json) { int x, y, tick; if (!readpencilmsg(&json, &x, &y, &tick)) break; if (tick < p->tick || x < 0 || y < 0 || x > usr->gm->w || y > usr->gm->h) break; if (abs(usr->gm->tick + SERVER_DELAY / TICK_LENGTH - tick) > MAX_LAG_SPIKE / TICK_LENGTH) { warningplayer(usr, "error: tick of pencil msg not valid\n"); break; } regenink(p, tick); if (mousedown) { if (p->ink < MOUSEDOWN_INK) { warningplayer(usr, "error: not enough ink for pencil down. %d required, %f left\n", MOUSEDOWN_INK, p->ink); break; } p->ink -= MOUSEDOWN_INK; p->down = 1; mousedown = 0; } else { double d = getlength(p->x - x, p->y - y); if (!p->down) { warningplayer(usr, "error: pencil move: pencil not down\n"); break; } if (p->ink < d) { warningplayer(usr, "error: pencil move: not enough ink. %f required, %f left\n", d, p->ink); break; } if (d < INK_MIN_DISTANCE) p->down = 0; if (p->x == x && p->y == y) break; p->ink -= d; queuepencilseg(p, x, y); } appendpos(&buf, x, y); p->x = x; p->y = y; buffer_empty = 0; } if (!buffer_empty) airstr(buf.start, buf.at - buf.start, usr->gm, 0); pthread_mutex_unlock(&usr->gm->lock); free(buf.start); }