//책추가 void Datainput() { mysql_free_result(sql_result); fprintf(stdout, "--------------------\n"); fprintf(stdout, "책이름을 입력\n"); fgets(bookname, 20, stdin); CHOP(bookname); fprintf(stdout, "저자 입력\n"); fgets(author, 10, stdin); CHOP(author); fprintf(stdout, "출판사 입력\n"); fgets(publisher, 10, stdin); CHOP(publisher); fprintf(stdout, "가격 입력\n"); fgets(price, 10, stdin); CHOP(price); fprintf(stdout, "발행 년도입력\n"); fgets(year, 10, stdin); CHOP(year); fprintf(stdout, "--------------------\n"); sprintf(query, "insert into lib values('%s','%s','%s','%s','%s', 'y')", bookname, author, publisher, price, year); query_stat = mysql_query(connection, query); if (query_stat != 0){ fprintf(stderr, "MySQL Query Error : %s", mysql_error(&conn)); } }
unsigned SOP_Ocean::disableParms() { unsigned changes = SOP_Node::disableParms(); changes += enableParm("normals_toggle",CHOP(0) ? 0 : 1); return changes; }
int pr_auth_banned_by_ftpusers(xaset_t *ctx, const char *user) { int res = FALSE; unsigned char *use_ftp_users; use_ftp_users = get_param_ptr(ctx, "UseFtpUsers", FALSE); if (use_ftp_users == NULL || *use_ftp_users == TRUE) { FILE *fh = NULL; char buf[256]; PRIVS_ROOT fh = fopen(PR_FTPUSERS_PATH, "r"); PRIVS_RELINQUISH if (fh == NULL) return res; memset(buf, '\0', sizeof(buf)); while (fgets(buf, sizeof(buf)-1, fh)) { char *ptr; pr_signals_handle(); buf[sizeof(buf)-1] = '\0'; CHOP(buf); ptr = buf; while (isspace((int) *ptr) && *ptr) { ptr++; } if (!*ptr || *ptr == '#') { continue; } if (strcmp(ptr, user) == 0 ) { res = TRUE; break; } memset(buf, '\0', sizeof(buf)); } fclose(fh); }
//책삭제 void deleteData(){ char name[20]; printf("제거할 책 이름을 입력:"); fgets(name, 20, stdin); CHOP(name); sprintf(query, "delete from lib where book = '%s'", name); query_stat = mysql_query(connection, query); if (query_stat != 0){ printf("에러발생!!\n"); printf("존재하지 않는 책이거나 철자를 똑바로 입력하세용!\n"); } else{ printf("%s가 정상적으로 목록에서 제거되었습니다.", name); } }
char * exts_linefil(struct exts_node_t *q) { CHOP(q->surface); /* remove trailing newline characters */ if (strcmp(q->surface, "EOS") == 0) { /* if the line is "EOS", discard it. */ return NULL; } return q->surface; /* return the whole line as a word. */ #if 0 /* THE FOLLOWING IS A SAMPLE CODE FOR MECAB+UNIDIC */ { char *p; if ((p = strchr(q->surface, '\t'))) { *p = '\0'; return q->surface; } return NULL; } #endif }
/* Checks for the existence of PR_SHUTMSG_PATH. deny and disc are * filled with the times to deny new connections and disconnect * existing ones. */ int check_shutmsg(time_t *shut, time_t *deny, time_t *disc, char *msg, size_t msg_size) { FILE *fp; char *deny_str,*disc_str,*cp, buf[PR_TUNABLE_BUFFER_SIZE+1] = {'\0'}; char hr[3] = {'\0'}, mn[3] = {'\0'}; time_t now,shuttime = (time_t)0; struct tm tm; if (file_exists(PR_SHUTMSG_PATH) && (fp = fopen(PR_SHUTMSG_PATH, "r"))) { if ((cp = fgets(buf, sizeof(buf),fp)) != NULL) { buf[sizeof(buf)-1] = '\0'; CHOP(cp); /* We use this to fill in dst, timezone, etc */ time(&now); tm = *(localtime(&now)); tm.tm_year = atoi(safe_token(&cp)) - 1900; tm.tm_mon = atoi(safe_token(&cp)) - 1; tm.tm_mday = atoi(safe_token(&cp)); tm.tm_hour = atoi(safe_token(&cp)); tm.tm_min = atoi(safe_token(&cp)); tm.tm_sec = atoi(safe_token(&cp)); deny_str = safe_token(&cp); disc_str = safe_token(&cp); if ((shuttime = mktime(&tm)) == (time_t) - 1) { fclose(fp); return 0; } if (deny) { if (strlen(deny_str) == 4) { sstrncpy(hr,deny_str,sizeof(hr)); hr[2] = '\0'; deny_str += 2; sstrncpy(mn,deny_str,sizeof(mn)); mn[2] = '\0'; *deny = shuttime - ((atoi(hr) * 3600) + (atoi(mn) * 60)); } else *deny = shuttime; } if (disc) { if (strlen(disc_str) == 4) { sstrncpy(hr,disc_str,sizeof(hr)); hr[2] = '\0'; disc_str += 2; sstrncpy(mn,disc_str,sizeof(mn)); mn[2] = '\0'; *disc = shuttime - ((atoi(hr) * 3600) + (atoi(mn) * 60)); } else *disc = shuttime; } if (fgets(buf, sizeof(buf),fp) && msg) { buf[sizeof(buf)-1] = '\0'; CHOP(buf); sstrncpy(msg, buf, msg_size-1); } } fclose(fp); if (shut) *shut = shuttime; return 1; } return 0; }
int main(){ int sockfd; int len, val; int cnt=1; char str[50]; struct sockaddr_un address; int result; while(1){ //client socket create sockfd = socket(AF_UNIX, SOCK_STREAM, 0); //server socket name direction address.sun_family = AF_UNIX; strcpy(address.sun_path, "server_socket"); len = sizeof(address); result = connect(sockfd, (struct sockaddr *)&address, len); //connect() 서버로 접속 시도 if (result == -1){ perror("client 1"); exit(1); }else { sprintf(str, "%d번 clinet Connect\n",cnt); write(sockfd, &str, 50); } char ch; menulist(); fprintf(stdout, "Menu Select = "); fscanf(stdin, "%d", &val); getchar(); switch(val){ case 1:{//책목록 ch='1'; write(sockfd, &ch, 1); break; } case 2:{//책대여 ch='2'; write(sockfd, &ch, 1); char name[20]; int bookLen, tmp; printf("빌릴 책이름을 입력하세요: "); fgets(name, 20, stdin); CHOP(name); bookLen = strlen(name); write(sockfd, &bookLen, 1);//1 write(sockfd, &name, bookLen);//2 read(sockfd, &tmp, 1); if (tmp == 1){ printf("책 %s가 정상적으로 대여가 완료되었습니다.\n", name); } else{ printf("요청하신 책이 없습니다. 다른 책을 대여해보세요.\n"); } //close(sockfd); break; } case 3:{//책반납 } case 4:{//내가빌린책 } case 5:{//종료하기 printf("Program Exit!!\n"); return 0; } default: return 0; } } close(sockfd); exit(0); }
/* Checks for the existence of PR_SHUTMSG_PATH. deny and disc are * filled with the times to deny new connections and disconnect * existing ones. */ int check_shutmsg(const char *path, time_t *shut, time_t *deny, time_t *disc, char *msg, size_t msg_size) { FILE *fp; char *deny_str, *disc_str, *cp, buf[PR_TUNABLE_BUFFER_SIZE+1] = {'\0'}; char hr[3] = {'\0'}, mn[3] = {'\0'}; time_t now, shuttime = (time_t) 0; struct tm *tm; if (path == NULL) { errno = EINVAL; return -1; } fp = fopen(path, "r"); if (fp != NULL) { struct stat st; if (fstat(fileno(fp), &st) == 0) { if (S_ISDIR(st.st_mode)) { fclose(fp); errno = EISDIR; return -1; } } cp = fgets(buf, sizeof(buf), fp); if (cp != NULL) { buf[sizeof(buf)-1] = '\0'; CHOP(cp); /* We use this to fill in dst, timezone, etc */ time(&now); tm = pr_localtime(NULL, &now); if (tm == NULL) { fclose(fp); return 0; } tm->tm_year = atoi(safe_token(&cp)) - 1900; tm->tm_mon = atoi(safe_token(&cp)) - 1; tm->tm_mday = atoi(safe_token(&cp)); tm->tm_hour = atoi(safe_token(&cp)); tm->tm_min = atoi(safe_token(&cp)); tm->tm_sec = atoi(safe_token(&cp)); deny_str = safe_token(&cp); disc_str = safe_token(&cp); shuttime = mktime(tm); if (shuttime == (time_t) -1) { fclose(fp); return 0; } if (deny != NULL) { if (strlen(deny_str) == 4) { sstrncpy(hr, deny_str, sizeof(hr)); hr[2] = '\0'; deny_str += 2; sstrncpy(mn, deny_str, sizeof(mn)); mn[2] = '\0'; *deny = shuttime - ((atoi(hr) * 3600) + (atoi(mn) * 60)); } else { *deny = shuttime; } } if (disc != NULL) { if (strlen(disc_str) == 4) { sstrncpy(hr, disc_str, sizeof(hr)); hr[2] = '\0'; disc_str += 2; sstrncpy(mn, disc_str, sizeof(mn)); mn[2] = '\0'; *disc = shuttime - ((atoi(hr) * 3600) + (atoi(mn) * 60)); } else { *disc = shuttime; } } if (fgets(buf, sizeof(buf), fp) && msg) { buf[sizeof(buf)-1] = '\0'; CHOP(buf); sstrncpy(msg, buf, msg_size-1); } } fclose(fp); if (shut != NULL) { *shut = shuttime; } return 1; } return -1; }
OP_ERROR SOP_Ocean::cookMySop(OP_Context &context) { float now = context.getTime(); //std::cout << "cook ocean, t = " << now << std::endl; // lock inputs if (lockInputs(context) >= UT_ERROR_ABORT ) { return error(); } GEO_Point *ppt; UT_Interrupt *boss; // Check to see that there hasn't been a critical error in cooking the SOP. if (error() < UT_ERROR_ABORT) { boss = UTgetInterrupt(); // Start the interrupt server boss->opStart("Updating Ocean"); duplicatePointSource(0,context); int gridres = 1 << int(GRID_RES(now)); float stepsize = GRID_SIZE(now) / (float)gridres; bool do_chop = CHOP(now); bool do_jacobian = JACOBIAN(now); bool do_normals = NORMALS(now) && !do_chop; if (!_ocean || _ocean_needs_rebuild) { if (_ocean) { delete _ocean; } if (_ocean_context) { delete _ocean_context; } _ocean = new drw::Ocean(gridres,gridres,stepsize,stepsize, V(0),L(0),1.0,W(0),1-DAMP(0),ALIGN(0), DEPTH(0),SEED(0)); _ocean_scale = _ocean->get_height_normalize_factor(); _ocean_context = _ocean->new_context(true,do_chop,do_normals,do_jacobian); _ocean_needs_rebuild = false; // std::cout << "######### SOP, rebuilt ocean, norm_factor = " << _ocean_scale // << " chop = " << do_chop // << " norm = " << do_normals // << " jacobian = " << do_jacobian // << std::endl; } float chop_amount = CHOPAMOUNT(now); // sum up the waves at this timestep _ocean->update(TIME(now),*_ocean_context,true,do_chop,do_normals,do_jacobian, _ocean_scale * SCALE(now),chop_amount); bool linterp = ! INTERP(now); // get our attribute indices GA_RWAttributeRef normal_index; GA_RWAttributeRef jminus_index; GA_RWAttributeRef eminus_index; if (do_normals) { normal_index = gdp->addNormalAttribute(GEO_POINT_DICT); } if (do_jacobian) { // jminus_index = gdp->addPointAttrib("mineigval",sizeof(float),GB_ATTRIB_FLOAT,0); // eminus_index = gdp->addPointAttrib("mineigvec",sizeof(UT_Vector3),GB_ATTRIB_VECTOR,0); jminus_index = gdp->addTuple(GA_STORE_REAL32,GA_ATTRIB_POINT,"mineigval",1,GA_Defaults(0)); eminus_index = gdp->addFloatTuple(GA_ATTRIB_POINT,"mineigvec",1,GA_Defaults(0)); } // this is not that fast, can it be done quicker ??? GA_FOR_ALL_GPOINTS(gdp, ppt) { UT_Vector4 p = ppt->getPos(); if (linterp) { _ocean_context->eval_xz(p(0),p(2)); } else { _ocean_context->eval2_xz(p(0),p(2)); } if (do_chop) { p.assign( p(0) + _ocean_context->disp[0], p(1) + _ocean_context->disp[1], p(2) + _ocean_context->disp[2] ); } else { // ppt->getPos()(1) += _ocean_context->disp[1]; UT_Vector4 tmp_p = ppt->getPos(); tmp_p(1) += _ocean_context->disp[1]; ppt->setPos(tmp_p); } if (do_normals) { /* UT_Vector3* normal = (UT_Vector3*) ppt->castAttribData<UT_Vector3>(normal_index); normal->assign(_ocean_context->normal[0], _ocean_context->normal[1], _ocean_context->normal[2]); normal->normalize(); */ ppt->getValue<UT_Vector3>(normal_index).assign(_ocean_context->normal[0], _ocean_context->normal[1], _ocean_context->normal[2]); ppt->getValue<UT_Vector3>(normal_index).normalize(); } if (do_jacobian) {/* float *js = (float*)ppt->castAttribData<float>(jminus_index); *js = _ocean_context->Jminus; UT_Vector3* eminus = (UT_Vector3*)ppt->castAttribData<UT_Vector3>(eminus_index); eminus->assign(_ocean_context->Eminus[0],0,_ocean_context->Eminus[1]); */ ppt->setValue<float>(jminus_index,_ocean_context->Jminus); ppt->getValue<UT_Vector3>(eminus_index).assign(_ocean_context->Eminus[0],0,_ocean_context->Eminus[1]); } ppt->setPos(p); }
OP_ERROR aaOceanSOP::cookMySop(OP_Context &context) { if (lockInputs(context) >= UT_ERROR_ABORT) return error(); duplicateSource(0, context); setVariableOrder(3, 2, 0, 1); setCurGdh(0, myGdpHandle); setupLocalVars(); // variable declarations float now = context.getTime(); // Flag the SOP as being time dependent (i.e. cook on time changes) flags().timeDep = 1; // start pulling in SOP inputs and send to aaOcean enableEigens = (ENABLEEIGENS() != 0); if(pOcean->isChoppy() && enableEigens) enableEigens = TRUE; now = now + TIMEOFFSET(now); pOcean->input( RESOLUTION(), SEED(), OCEANSCALE(now), OCEANDEPTH(now), SURFACETENSION(now), VELOCITY(now), CUTOFF(now), WINDDIR(now), WINDALIGN(), DAMP(now), WAVESPEED(now), WAVEHEIGHT(now), CHOP(now), now, LOOPTIME(now), enableEigens, FALSE); // get the user-specified attribute that holds uv-data getUVAttributeName(UvAttribute); if(UvAttribute.length() == 0) UvAttribute = "uv"; const char* UVAttribName = (const char *)UvAttribute; uvRef = gdp->findFloatTuple(GA_ATTRIB_POINT, UVAttribName, 3); if(uvRef.isValid() == TRUE) { uvAttribute = uvRef.getAttribute(); uvTuple = uvRef.getAIFTuple(); } else { // uv attribute not found char msg[256]; sprintf(msg, "[aaOcean] Specified UV attribute \'%s\' not found on geometry.\ \nUV's are required for aaOcean to cook", UVAttribName); std::cout<<msg; std::cout.flush(); addError(SOP_MESSAGE, msg); unlockInputs(); return error(); } // setup local variables to output Eigens if(enableEigens) { eVecPlusRef = gdp->addFloatTuple(GA_ATTRIB_POINT, eVecPlusName, 3); eVecMinusRef = gdp->addFloatTuple(GA_ATTRIB_POINT, eVecMinusName, 3); eValuesRef = gdp->addFloatTuple(GA_ATTRIB_POINT, eValuesName, 1); eVecPlusHandle = GA_RWHandleV3(eVecPlusRef.getAttribute()); eVecMinusHandle = GA_RWHandleV3(eVecMinusRef.getAttribute()); eValuesHandle = GA_RWHandleF(eValuesRef.getAttribute()); } // inputs validated. Begin writing ocean data to output handles int npts = gdp->getNumPoints(); #pragma omp parallel for for (int pt_offset = 0; pt_offset < npts; ++pt_offset) { UT_Vector3F pos = gdp->getPos3(pt_offset); UT_Vector3F UV; uvTuple->get(uvAttribute, pt_offset, UV.data(), 3); // Houdini V coord runs in opposite direction compared to Softimage/Maya // Conforming with other apps to make ocean shape consistent across apps float u = UV.x(); float v = 1.0f - (fmod(UV.y(), 1.0f)); pos.y() += pOcean->getOceanData(u, v, aaOcean::eHEIGHTFIELD); if(pOcean->isChoppy()) { pos.x() += pOcean->getOceanData(u, v, aaOcean::eCHOPX); pos.z() += pOcean->getOceanData(u, v, aaOcean::eCHOPZ); } gdp->setPos3(pt_offset, pos); if(enableEigens) { UT_Vector3F eigenVectorPlusValue; UT_Vector3F eigenVectorMinusValue; float eigenValue; eigenVectorPlusValue.x() = pOcean->getOceanData(u, v, aaOcean::eEIGENPLUSX); eigenVectorPlusValue.y() = 0.0f; eigenVectorPlusValue.z() = pOcean->getOceanData(u, v, aaOcean::eEIGENPLUSZ); eigenVectorMinusValue.x() = pOcean->getOceanData(u, v, aaOcean::eEIGENMINUSX); eigenVectorMinusValue.y() = 0.0f; eigenVectorMinusValue.z() = pOcean->getOceanData(u, v, aaOcean::eEIGENMINUSZ); eigenValue = pOcean->getOceanData(u, v, aaOcean::eFOAM); eVecPlusHandle.set(pt_offset,eigenVectorPlusValue); eVecMinusHandle.set(pt_offset,eigenVectorMinusValue); eValuesHandle.set(pt_offset,eigenValue); } } unlockInputs(); return error(); }