| 22 |
|
|
| 23 |
int article_post(SECTION_LIST *p_section, ARTICLE *p_article, ARTICLE_POST_TYPE type) |
int article_post(SECTION_LIST *p_section, ARTICLE *p_article, ARTICLE_POST_TYPE type) |
| 24 |
{ |
{ |
| 25 |
|
ARTICLE_CACHE cache; |
| 26 |
|
EDITOR_DATA *p_editor_data; |
| 27 |
|
|
| 28 |
log_common("Debug: sid=%d aid=%d type=%d\n", |
log_common("Debug: sid=%d aid=%d type=%d\n", |
| 29 |
p_section->sid, (p_article == NULL ? 0 : p_article->aid), type); |
p_section->sid, (p_article == NULL ? 0 : p_article->aid), type); |
| 30 |
|
|
| 31 |
|
switch (type) |
| 32 |
|
{ |
| 33 |
|
case ARTICLE_POST_NEW: |
| 34 |
|
p_editor_data = editor_data_load(""); |
| 35 |
|
if (p_editor_data == NULL) |
| 36 |
|
{ |
| 37 |
|
log_error("editor_data_load() error\n"); |
| 38 |
|
return -2; |
| 39 |
|
} |
| 40 |
|
break; |
| 41 |
|
case ARTICLE_POST_EDIT: |
| 42 |
|
case ARTICLE_POST_REPLY: |
| 43 |
|
if (article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_article) < 0) |
| 44 |
|
{ |
| 45 |
|
log_error("article_cache_load(aid=%d, cid=%d) error\n", p_article->aid, p_article->cid); |
| 46 |
|
return -2; |
| 47 |
|
} |
| 48 |
|
p_editor_data = editor_data_load(cache.p_data); |
| 49 |
|
if (p_editor_data == NULL) |
| 50 |
|
{ |
| 51 |
|
log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, p_article->cid); |
| 52 |
|
return -2; |
| 53 |
|
} |
| 54 |
|
if (article_cache_unload(&cache) < 0) |
| 55 |
|
{ |
| 56 |
|
log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_article->aid, p_article->cid); |
| 57 |
|
return -2; |
| 58 |
|
} |
| 59 |
|
break; |
| 60 |
|
default: |
| 61 |
|
log_error("Unsupported type=%d\n", type); |
| 62 |
|
return -1; |
| 63 |
|
} |
| 64 |
|
|
| 65 |
|
editor_display(p_editor_data); |
| 66 |
|
|
| 67 |
|
// editor_data_save(p_editor_data, p_data_new, data_new_len); |
| 68 |
|
|
| 69 |
|
editor_data_cleanup(p_editor_data); |
| 70 |
|
|
| 71 |
return 0; |
return 0; |
| 72 |
} |
} |